[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 23 09:28:00 UTC 2019


 sw/inc/redline.hxx                            |    4 +++-
 sw/qa/extras/uiwriter/uiwriter2.cxx           |    7 +++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |    6 ++++++
 sw/source/core/doc/docredln.cxx               |   22 +++++++++++++++++-----
 4 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit 61ed17cafc90d9b4303b52260f729638eed107c7
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed Aug 7 13:51:32 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Aug 23 11:27:06 2019 +0200

    tdf#127101 Change tracking: fix format reject at paragraph join
    
    Now "Reject tracked change" can restore the
    original format of multiple paragraphs of a tracked
    deletion during editing.
    
    Change-Id: I83a307b4206ab610af3458f8cb6e9de905b88776
    Reviewed-on: https://gerrit.libreoffice.org/77101
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index c75cb932d35d..c7cddc9fad3a 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -55,9 +55,10 @@ class SW_DLLPUBLIC SwRedlineExtraData_FormatColl : public SwRedlineExtraData
     OUString m_sFormatNm;
     std::unique_ptr<SfxItemSet> m_pSet;
     sal_uInt16 m_nPoolId;
+    bool m_bFormatAll; // don't strip the last paragraph mark
 public:
     SwRedlineExtraData_FormatColl( const OUString& rColl, sal_uInt16 nPoolFormatId,
-                                const SfxItemSet* pSet = nullptr );
+                                const SfxItemSet* pSet = nullptr, bool bFormatAll = true );
     virtual ~SwRedlineExtraData_FormatColl() override;
     virtual SwRedlineExtraData* CreateNew() const override;
     virtual void Reject( SwPaM& rPam ) const override;
@@ -66,6 +67,7 @@ public:
     const OUString& GetFormatName() const        { return m_sFormatNm; }
     void SetItemSet( const SfxItemSet& rSet );
     SfxItemSet* GetItemSet( ) const { return m_pSet.get(); }
+    void SetFormatAll( bool bAll )               { m_bFormatAll = bAll; }
 };
 
 class SwRedlineExtraData_Format : public SwRedlineExtraData
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 992ffe190d88..6ae3c023439c 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -572,6 +572,13 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119571_keep_numbering_with_Reject)
     sNumName = getProperty<OUString>(getParagraph(3), "NumberingStyleName");
     CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty());
     CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline");
+
+    // third paragraph: normal text without numbering
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+                         getProperty<OUString>(getParagraph(4), "ParaStyleName"));
+    sNumName = getProperty<OUString>(getParagraph(4), "NumberingStyleName");
+    CPPUNIT_ASSERT_MESSAGE("Bad numbering", sNumName.isEmpty());
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109376_redline)
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 1ed3851c90b2..2372429afc70 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2026,6 +2026,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
                         SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
                         SwTextNode* pTextNode;
                         SwNodeIndex aIdx( pEnd->nNode.GetNode() );
+                        bool bFirst = true;
 
                         while (pDelNode != nullptr && pTextNd != nullptr && pDelNd->GetIndex() < pTextNd->GetIndex())
                         {
@@ -2045,6 +2046,8 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
                                 if (pExtraData)
                                 {
                                     std::unique_ptr<SwRedlineExtraData_FormatColl> xRedlineExtraData;
+                                    if (!bFirst)
+                                        pExtraData->SetFormatAll(false);
                                     xRedlineExtraData.reset(pExtraData);
                                     pPar->SetExtraData( xRedlineExtraData.get() );
                                 }
@@ -2054,6 +2057,9 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
                                 lcl_CopyStyle(*pStt, aPos);
                             }
                             pTextNd = SwNodes::GoPrevious( &aIdx );
+
+                            if (bFirst)
+                                bFirst = false;
                         }
                     }
                 }
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 08bfa9e51c77..2585b1208751 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -753,8 +753,9 @@ bool SwRedlineExtraData::operator == ( const SwRedlineExtraData& ) const
 
 SwRedlineExtraData_FormatColl::SwRedlineExtraData_FormatColl( const OUString& rColl,
                                                 sal_uInt16 nPoolFormatId,
-                                                const SfxItemSet* pItemSet )
-    : m_sFormatNm(rColl), m_nPoolId(nPoolFormatId)
+                                                const SfxItemSet* pItemSet,
+                                                bool bFormatAll )
+    : m_sFormatNm(rColl), m_nPoolId(nPoolFormatId), m_bFormatAll(bFormatAll)
 {
     if( pItemSet && pItemSet->Count() )
         m_pSet.reset( new SfxItemSet( *pItemSet ) );
@@ -766,7 +767,7 @@ SwRedlineExtraData_FormatColl::~SwRedlineExtraData_FormatColl()
 
 SwRedlineExtraData* SwRedlineExtraData_FormatColl::CreateNew() const
 {
-    return new SwRedlineExtraData_FormatColl( m_sFormatNm, m_nPoolId, m_pSet.get() );
+    return new SwRedlineExtraData_FormatColl( m_sFormatNm, m_nPoolId, m_pSet.get(), m_bFormatAll );
 }
 
 void SwRedlineExtraData_FormatColl::Reject( SwPaM& rPam ) const
@@ -781,11 +782,21 @@ void SwRedlineExtraData_FormatColl::Reject( SwPaM& rPam ) const
     RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
     pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore));
 
+    SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
+
+    if ( !m_bFormatAll )
+    {
+        // don't reject the format of the next paragraph (that is handled by the next redline)
+        aPam.GetPoint()->nNode--;
+        SwContentNode* pNode = aPam.GetPoint()->nNode.GetNode().GetContentNode();
+        aPam.GetPoint()->nContent.Assign( pNode, pNode->Len() );
+    }
+
     if( pColl )
-        pDoc->SetTextFormatColl( rPam, pColl, false );
+        pDoc->SetTextFormatColl( aPam, pColl, false );
 
     if( m_pSet )
-        pDoc->getIDocumentContentOperations().InsertItemSet( rPam, *m_pSet );
+        pDoc->getIDocumentContentOperations().InsertItemSet( aPam, *m_pSet );
 
     pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
 }
@@ -794,6 +805,7 @@ bool SwRedlineExtraData_FormatColl::operator == ( const SwRedlineExtraData& r) c
 {
     const SwRedlineExtraData_FormatColl& rCmp = static_cast<const SwRedlineExtraData_FormatColl&>(r);
     return m_sFormatNm == rCmp.m_sFormatNm && m_nPoolId == rCmp.m_nPoolId &&
+            m_bFormatAll == rCmp.m_bFormatAll &&
             ( ( !m_pSet && !rCmp.m_pSet ) ||
                ( m_pSet && rCmp.m_pSet && *m_pSet == *rCmp.m_pSet ) );
 }


More information about the Libreoffice-commits mailing list