[Libreoffice-commits] core.git: Branch 'feature/refactor-god-objects' - sw/inc sw/Library_sw.mk sw/qa sw/source

Valentin Kettner vakevk+libreoffice at gmail.com
Sat Jul 19 06:39:02 PDT 2014


Rebased ref, commits from common ancestor:
commit 65ad15a56d0a1a91e5a2bf0f0a002f24cc0b8340
Author: Valentin Kettner <vakevk+libreoffice at gmail.com>
Date:   Wed Jul 16 22:19:33 2014 +0200

    Refactored IDocumentRedlineAccess out of SwDoc.
    
    Into the new class DocumentRedlineManager.
    Added an non const version of GetRedlineTbl to the interface.
    Also Moved SetAutoFmtRedlineComment which is not part of interface.
    
    Change-Id: I600d5821d5d5831557f5fc5375fb1203fe67a295

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 0366a64..68f5d11 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -194,6 +194,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/doc/DocumentListsManager \
     sw/source/core/doc/DocumentOutlineNodesManager \
     sw/source/core/doc/DocumentContentOperationsManager \
+    sw/source/core/doc/DocumentRedlineManager \
     sw/source/core/doc/extinput \
     sw/source/core/doc/fmtcol \
     sw/source/core/doc/ftnidx \
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index e974880..4ff9600 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -127,6 +127,7 @@ public:
     virtual bool IsIgnoreRedline() const = 0;
 
     virtual const SwRedlineTbl& GetRedlineTbl() const = 0;
+    virtual SwRedlineTbl& GetRedlineTbl() = 0;
     virtual const SwExtraRedlineTbl& GetExtraRedlineTbl() const = 0;
     virtual SwExtraRedlineTbl& GetExtraRedlineTbl() = 0;
     virtual bool HasExtraRedlineTbl() const = 0;
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 779df32..d6b7497 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -21,8 +21,8 @@
 
 // SwDoc interfaces
 #include <IInterface.hxx>
-#include <IDocumentMarkAccess.hxx>
 #include <IDocumentRedlineAccess.hxx>
+#include <IDocumentMarkAccess.hxx>
 #include <IDocumentFieldsAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
 #include <IDocumentLineNumberAccess.hxx>
@@ -193,6 +193,7 @@ class IDocumentListItems;
 class IDocumentListsAccess;
 class IDocumentOutlineNodes;
 class IDocumentContentOperations;
+class IDocumentRedlineAccess;
 class _SetGetExpFlds;
 
 namespace sw { namespace mark {
@@ -212,6 +213,7 @@ namespace sw {
     class DocumentListsManager;
     class DocumentOutlineNodesManager;
     class DocumentContentOperationsManager;
+    class DocumentRedlineManager;
 }
 
 namespace com { namespace sun { namespace star {
@@ -249,7 +251,6 @@ void StartGrammarChecking( SwDoc &rDoc );
 // Represents the model of a Writer document.
 class SW_DLLPUBLIC SwDoc :
     public IInterface,
-    public IDocumentRedlineAccess,
     public IDocumentFieldsAccess,
     public IDocumentStylePoolAccess,
     public IDocumentLineNumberAccess,
@@ -274,7 +275,6 @@ class SW_DLLPUBLIC SwDoc :
     Timer       maOLEModifiedTimer;      //< Timer for update modified OLE-Objecs
     Timer       maStatsUpdateTimer;      //< Timer for asynchronous stats calculation
     SwDBData    maDBData;                //< database descriptor
-    ::com::sun::star::uno::Sequence <sal_Int8 > maRedlinePasswd;
     OUString    msTOIAutoMarkURL;        //< URL of table of index AutoMark file
     boost::ptr_vector< boost::nullable<OUString> > maPatternNms;          // Array for names of document-templates
     com::sun::star::uno::Reference<com::sun::star::container::XNameContainer>
@@ -284,6 +284,7 @@ class SW_DLLPUBLIC SwDoc :
     const ::boost::scoped_ptr< ::sw::mark::MarkManager> mpMarkManager;
     const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager;
     const ::boost::scoped_ptr< ::sw::DocumentDrawModelManager > m_pDocumentDrawModelManager;
+    const ::boost::scoped_ptr< ::sw::DocumentRedlineManager > m_pDocumentRedlineManager;
     const ::boost::scoped_ptr< ::sw::UndoManager > m_pUndoManager;
     const ::boost::scoped_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager;
     const ::boost::scoped_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager;
@@ -343,10 +344,6 @@ class SW_DLLPUBLIC SwDoc :
     // Hash map to find numrules by name
     mutable boost::unordered_map<OUString, SwNumRule *, OUStringHash> maNumRuleMap;
 
-    SwRedlineTbl        *mpRedlineTbl;           //< List of all Ranged Redlines.
-    SwExtraRedlineTbl   *mpExtraRedlineTbl;      //< List of all Extra Redlines.
-    OUString            *mpAutoFmtRedlnComment;  //< Comment for Redlines inserted via AutoFormat.
-
     SwUnoCrsrTbl    *mpUnoCrsrTbl;
 
     SwPagePreviewPrtData *mpPgPViewPrtData;  //< Indenting / spacing for printing of page view.
@@ -374,11 +371,6 @@ private:
     sal_uInt16  mnUndoCnt;           //< Count of Undo Actions.
     sal_uInt16  mnUndoSttEnd;        //< != 0 -> within parentheses.
 
-    sal_uInt16 mnAutoFmtRedlnCommentNo;  /**< SeqNo for conjoining of AutoFmt-Redlines.
-                                         by the UI. Managed by SwAutoFmt! */
-
-    RedlineMode_t meRedlineMode;     //< Current Redline Mode.
-
     sal_uInt32  mnRsid;              //< current session ID of the document
     sal_uInt32  mnRsidRoot;          //< session ID when the document was created
 
@@ -539,39 +531,11 @@ public:
     const IDocumentMarkAccess* getIDocumentMarkAccess() const;
 
     // IDocumentRedlineAccess
-    virtual RedlineMode_t GetRedlineMode() const SAL_OVERRIDE;
-    virtual void SetRedlineMode_intern(/*[in]*/RedlineMode_t eMode) SAL_OVERRIDE;
-    virtual void SetRedlineMode(/*[in]*/RedlineMode_t eMode) SAL_OVERRIDE;
-    virtual bool IsRedlineOn() const SAL_OVERRIDE;
-    virtual bool IsIgnoreRedline() const SAL_OVERRIDE;
-    virtual bool IsInRedlines(const SwNode& rNode) const SAL_OVERRIDE;
-    virtual const SwRedlineTbl& GetRedlineTbl() const SAL_OVERRIDE;
-    virtual const SwExtraRedlineTbl& GetExtraRedlineTbl() const SAL_OVERRIDE;
-    virtual SwExtraRedlineTbl& GetExtraRedlineTbl() SAL_OVERRIDE;
-    virtual bool HasExtraRedlineTbl() const SAL_OVERRIDE;
-    virtual bool AppendRedline(/*[in]*/SwRangeRedline* pPtr, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool AppendTableRowRedline(/*[in]*/SwTableRowRedline* pPtr, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool AppendTableCellRedline(/*[in]*/SwTableCellRedline* pPtr, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool SplitRedline(const SwPaM& rPam) SAL_OVERRIDE;
-    virtual bool DeleteRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bSaveInUndo, /*[in]*/sal_uInt16 nDelType) SAL_OVERRIDE;
-    virtual bool DeleteRedline(/*[in]*/const SwStartNode& rSection, /*[in]*/bool bSaveInUndo, /*[in]*/sal_uInt16 nDelType) SAL_OVERRIDE;
-    virtual sal_uInt16 GetRedlinePos(/*[in]*/const SwNode& rNode, /*[in]*/sal_uInt16 nType) const SAL_OVERRIDE;
-    virtual void CompressRedlines() SAL_OVERRIDE;
-    virtual const SwRangeRedline* GetRedline(/*[in]*/const SwPosition& rPos, /*[in]*/sal_uInt16* pFndPos) const SAL_OVERRIDE;
-    virtual bool IsRedlineMove() const SAL_OVERRIDE;
-    virtual void SetRedlineMove(/*[in]*/bool bFlag) SAL_OVERRIDE;
-    virtual bool AcceptRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool RejectRedline(/*[in]*/sal_uInt16 nPos, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool bCallDelete) SAL_OVERRIDE;
-    virtual const SwRangeRedline* SelNextRedline(/*[in]*/SwPaM& rPam) const SAL_OVERRIDE;
-    virtual const SwRangeRedline* SelPrevRedline(/*[in]*/SwPaM& rPam) const SAL_OVERRIDE;
-    virtual void UpdateRedlineAttr() SAL_OVERRIDE;
-    virtual sal_uInt16 GetRedlineAuthor() SAL_OVERRIDE;
-    virtual sal_uInt16 InsertRedlineAuthor(const OUString& rAuthor) SAL_OVERRIDE;
-    virtual bool SetRedlineComment(/*[in]*/const SwPaM& rPam, /*[in]*/const OUString& rComment) SAL_OVERRIDE;
-    virtual const ::com::sun::star::uno::Sequence <sal_Int8>& GetRedlinePassword() const SAL_OVERRIDE;
-    virtual void SetRedlinePassword(/*[in]*/const ::com::sun::star::uno::Sequence <sal_Int8>& rNewPassword) SAL_OVERRIDE;
+    IDocumentRedlineAccess const& getIDocumentRedlineAccess() const;
+    IDocumentRedlineAccess& getIDocumentRedlineAccess();
+
+    ::sw::DocumentRedlineManager const& GetDocumentRedlineManager() const;
+    ::sw::DocumentRedlineManager& GetDocumentRedlineManager();
 
     // IDocumentUndoRedo
     IDocumentUndoRedo      & GetIDocumentUndoRedo();
@@ -1573,11 +1537,6 @@ public:
     // Merge two documents.
     long MergeDoc( const SwDoc& rDoc );
 
-    /** Set comment-text for Redline. It then comes in via AppendRedLine.
-     Used by AutoFormat. 0-pointer resets mode.
-     Sequence number is for conjoining of Redlines by the UI. */
-    void SetAutoFmtRedlineComment( const OUString* pTxt, sal_uInt16 nSeqNo = 0 );
-
     bool IsAutoFmtRedline() const           { return mbIsAutoFmtRedline; }
     void SetAutoFmtRedline( bool bFlag )    { mbIsAutoFmtRedline = bFlag; }
 
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 75cbf77..d58f5bc 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -32,6 +32,7 @@
 
 #include "breakit.hxx"
 #include "doc.hxx"
+#include <IDocumentRedlineAccess.hxx>
 #include "docsh.hxx"
 #include "docstat.hxx"
 #include "docufld.hxx"
@@ -252,9 +253,9 @@ void SwDocTest::testModelToViewHelper()
         aPaM.DeleteMark();
 
         //turn on red-lining and show changes
-        m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT);
-        CPPUNIT_ASSERT_MESSAGE("redlining should be on", m_pDoc->IsRedlineOn());
-        CPPUNIT_ASSERT_MESSAGE("redlines should be visible", IDocumentRedlineAccess::IsShowChanges(m_pDoc->GetRedlineMode()));
+        m_pDoc->getIDocumentRedlineAccess().SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT);
+        CPPUNIT_ASSERT_MESSAGE("redlining should be on", m_pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+        CPPUNIT_ASSERT_MESSAGE("redlines should be visible", IDocumentRedlineAccess::IsShowChanges(m_pDoc->getIDocumentRedlineAccess().GetRedlineMode()));
 
         //set start of selection to last A
         aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 4);
@@ -623,9 +624,9 @@ void SwDocTest::testSwScanner()
         CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(2));
 
         //turn on red-lining and show changes
-        m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT);
-        CPPUNIT_ASSERT_MESSAGE("redlining should be on", m_pDoc->IsRedlineOn());
-        CPPUNIT_ASSERT_MESSAGE("redlines should be visible", IDocumentRedlineAccess::IsShowChanges(m_pDoc->GetRedlineMode()));
+        m_pDoc->getIDocumentRedlineAccess().SetRedlineMode(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_DELETE|nsRedlineMode_t::REDLINE_SHOW_INSERT);
+        CPPUNIT_ASSERT_MESSAGE("redlining should be on", m_pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+        CPPUNIT_ASSERT_MESSAGE("redlines should be visible", IDocumentRedlineAccess::IsShowChanges(m_pDoc->getIDocumentRedlineAccess().GetRedlineMode()));
 
         //delete everything except the first word
         aPaM.SetMark(); //set start of selection to current pos
@@ -642,9 +643,9 @@ void SwDocTest::testSwScanner()
         pTxtNode->SetWordCountDirty(true);
 
         //keep red-lining on but hide changes
-        m_pDoc->SetRedlineMode(nsRedlineMode_t::REDLINE_ON);
-        CPPUNIT_ASSERT_MESSAGE("redlining should be still on", m_pDoc->IsRedlineOn());
-        CPPUNIT_ASSERT_MESSAGE("redlines should be invisible", !IDocumentRedlineAccess::IsShowChanges(m_pDoc->GetRedlineMode()));
+        m_pDoc->getIDocumentRedlineAccess().SetRedlineMode(nsRedlineMode_t::REDLINE_ON);
+        CPPUNIT_ASSERT_MESSAGE("redlining should be still on", m_pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+        CPPUNIT_ASSERT_MESSAGE("redlines should be invisible", !IDocumentRedlineAccess::IsShowChanges(m_pDoc->getIDocumentRedlineAccess().GetRedlineMode()));
 
         aDocStat.Reset();
         pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len()); //but word-counting the text should only count the non-deleted text
@@ -653,7 +654,7 @@ void SwDocTest::testSwScanner()
         OUString sLorem = pTxtNode->GetTxt();
         CPPUNIT_ASSERT(sLorem == "Lorem");
 
-        const SwRedlineTbl& rTbl = m_pDoc->GetRedlineTbl();
+        const SwRedlineTbl& rTbl = m_pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
 
         SwNodes& rNds = m_pDoc->GetNodes();
         CPPUNIT_ASSERT(rTbl.size() == 1);
@@ -876,7 +877,7 @@ getRandomPosition(SwDoc *pDoc, int /* nOffset */)
 
 void SwDocTest::randomTest()
 {
-    CPPUNIT_ASSERT_MESSAGE("SwDoc::IsRedlineOn()", !m_pDoc->IsRedlineOn());
+    CPPUNIT_ASSERT_MESSAGE("SwDoc::IsRedlineOn()", !m_pDoc->getIDocumentRedlineAccess().IsRedlineOn());
     RedlineMode_t modes[] = {
         nsRedlineMode_t::REDLINE_ON,
         nsRedlineMode_t::REDLINE_SHOW_MASK,
@@ -896,7 +897,7 @@ void SwDocTest::randomTest()
         m_pDoc->ClearDoc();
 
         // setup redlining
-        m_pDoc->SetRedlineMode(modes[rlm]);
+        m_pDoc->getIDocumentRedlineAccess().SetRedlineMode(modes[rlm]);
         SW_MOD()->SetRedlineAuthor(OUString::createFromAscii(authors[0]));
 
         for( int i = 0; i < 2000; i++ )
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f13d1c7..10cb454 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -330,7 +330,7 @@ void SwUiWriterTest::testCp1000071()
     SwDoc* pDoc = createDoc("cp1000071.odt");
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 
-    const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
+    const SwRedlineTbl& rTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
     CPPUNIT_ASSERT_EQUAL( size_t( 2 ), rTbl.size());
     sal_uLong redlineStart0NodeIndex = rTbl[ 0 ]->Start()->nNode.GetIndex();
     sal_Int32 redlineStart0Index = rTbl[ 0 ]->Start()->nContent.GetIndex();
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index a484556..089d3d9 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -51,6 +51,7 @@
 #include <unocrsr.hxx>
 #include <unoport.hxx>
 #include <doc.hxx>
+#include <IDocumentRedlineAccess.hxx>
 #include <crsskip.hxx>
 #include <txtatr.hxx>
 #include <acchyperlink.hxx>
@@ -719,7 +720,7 @@ const SwRangeRedline* SwAccessibleParagraph::GetRedlineAtIndex( sal_Int32 )
             const SwDoc* pDoc = pNode->GetDoc();
             if ( pDoc )
             {
-                pRedline = pDoc->GetRedline( *pStart, NULL );
+                pRedline = pDoc->getIDocumentRedlineAccess().GetRedline( *pStart, NULL );
             }
         }
     }
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 6fcef4a..05d4d45 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -27,6 +27,7 @@
 #include <crsrsh.hxx>
 #include <doc.hxx>
 #include <IDocumentUndoRedo.hxx>
+#include <IDocumentRedlineAccess.hxx>
 #include <pagefrm.hxx>
 #include <cntfrm.hxx>
 #include <rootfrm.hxx>
@@ -1412,7 +1413,7 @@ bool SwCrsrShell::GetContentAtPos( const Point& rPt,
 
                 if( !bRet && SwContentAtPos::SW_REDLINE & rCntntAtPos.eCntntAtPos )
                 {
-                    const SwRangeRedline* pRedl = GetDoc()->GetRedline(aPos, NULL);
+                    const SwRangeRedline* pRedl = GetDoc()->getIDocumentRedlineAccess().GetRedline(aPos, NULL);
                     if( pRedl )
                     {
                         rCntntAtPos.aFnd.pRedl = pRedl;
@@ -1942,7 +1943,7 @@ const SwRangeRedline* SwCrsrShell::SelNextRedline()
         SwCallLink aLk( *this ); // watch Crsr-Moves
         SwCrsrSaveState aSaveState( *m_pCurCrsr );
 
-        pFnd = GetDoc()->SelNextRedline( *m_pCurCrsr );
+        pFnd = GetDoc()->getIDocumentRedlineAccess().SelNextRedline( *m_pCurCrsr );
         if( pFnd && !m_pCurCrsr->IsInProtectTable() && !m_pCurCrsr->IsSelOvr() )
             UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
         else
@@ -1960,7 +1961,7 @@ const SwRangeRedline* SwCrsrShell::SelPrevRedline()
         SwCallLink aLk( *this ); // watch Crsr-Moves
         SwCrsrSaveState aSaveState( *m_pCurCrsr );
 
-        pFnd = GetDoc()->SelPrevRedline( *m_pCurCrsr );
+        pFnd = GetDoc()->getIDocumentRedlineAccess().SelPrevRedline( *m_pCurCrsr );
         if( pFnd && !m_pCurCrsr->IsInProtectTable() && !m_pCurCrsr->IsSelOvr() )
             UpdateCrsr( SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE|SwCrsrShell::READONLY);
         else
@@ -1975,7 +1976,7 @@ const SwRangeRedline* SwCrsrShell::_GotoRedline( sal_uInt16 nArrPos, bool bSelec
     SwCallLink aLk( *this ); // watch Crsr-Moves
     SwCrsrSaveState aSaveState( *m_pCurCrsr );
 
-    pFnd = GetDoc()->GetRedlineTbl()[ nArrPos ];
+    pFnd = GetDoc()->getIDocumentRedlineAccess().GetRedlineTbl()[ nArrPos ];
     if( pFnd )
     {
         *m_pCurCrsr->GetPoint() = *pFnd->Start();
@@ -2044,7 +2045,7 @@ const SwRangeRedline* SwCrsrShell::GotoRedline( sal_uInt16 nArrPos, bool bSelect
     {
         SET_CURR_SHELL( this );
 
-        const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl();
+        const SwRedlineTbl& rTbl = GetDoc()->getIDocumentRedlineAccess().GetRedlineTbl();
         const SwRangeRedline* pTmp = rTbl[ nArrPos ];
         sal_uInt16 nSeqNo = pTmp->GetSeqNo();
         if( nSeqNo && bSelect )
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index c93bfc7..396940a 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -30,6 +30,7 @@
 #include <unocrsr.hxx>
 #include <doc.hxx>
 #include <IDocumentUndoRedo.hxx>
+#include <IDocumentRedlineAccess.hxx>
 #include <docary.hxx>
 #include <ndtxt.hxx>
 #include <section.hxx>
@@ -1410,13 +1411,13 @@ static OUString lcl_MaskDeletedRedlines( const SwTxtNode* pTxtNd )
         //mask deleted redlines
         OUString sNodeText(pTxtNd->GetTxt());
         const SwDoc& rDoc = *pTxtNd->GetDoc();
-        const bool nShowChg = IDocumentRedlineAccess::IsShowChanges( rDoc.GetRedlineMode() );
+        const bool nShowChg = IDocumentRedlineAccess::IsShowChanges( rDoc.getIDocumentRedlineAccess().GetRedlineMode() );
         if ( nShowChg )
         {
-            sal_uInt16 nAct = rDoc.GetRedlinePos( *pTxtNd, USHRT_MAX );
-            for ( ; nAct < rDoc.GetRedlineTbl().size(); nAct++ )
+            sal_uInt16 nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( *pTxtNd, USHRT_MAX );
+            for ( ; nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTbl().size(); nAct++ )
             {
-                const SwRangeRedline* pRed = rDoc.GetRedlineTbl()[ nAct ];
+                const SwRangeRedline* pRed = rDoc.getIDocumentRedlineAccess().GetRedlineTbl()[ nAct ];
                 if ( pRed->Start()->nNode > pTxtNd->GetIndex() )
                     break;
 
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index be6ef44..54a15c9 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -20,6 +20,7 @@
 #include <doc.hxx>
 #include <IDocumentUndoRedo.hxx>
 #include <IDocumentMarkAccess.hxx>
+#include <IDocumentRedlineAccess.hxx>
 #include <UndoManager.hxx>
 #include <docary.hxx>
 #include <textboxhelper.hxx>
@@ -284,7 +285,7 @@ namespace
     static void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam )
     {
         const SwDoc* pSrcDoc = rPam.GetDoc();
-        const SwRedlineTbl& rTbl = pSrcDoc->GetRedlineTbl();
+        const SwRedlineTbl& rTbl = pSrcDoc->getIDocumentRedlineAccess().GetRedlineTbl();
         if( !rTbl.empty() )
         {
             SwDoc* pDestDoc = rCpyPam.GetDoc();
@@ -296,7 +297,7 @@ namespace
             SwNodeIndex aCorrIdx( pStt->nNode );
 
             sal_uInt16 n = 0;
-            pSrcDoc->GetRedline( *pStt, &n );
+            pSrcDoc->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
             for( ; n < rTbl.size(); ++n )
             {
                 const SwRangeRedline* pRedl = rTbl[ n ];
@@ -344,8 +345,8 @@ namespace
 
             if( pDelPam )
             {
-                RedlineMode_t eOld = pDestDoc->GetRedlineMode();
-                pDestDoc->SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+                RedlineMode_t eOld = pDestDoc->getIDocumentRedlineAccess().GetRedlineMode();
+                pDestDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
 
                 ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
 
@@ -357,7 +358,7 @@ namespace
                 } while( true );
                 delete pDelPam;
 
-                pDestDoc->SetRedlineMode_intern( eOld );
+                pDestDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
             }
         }
     }
@@ -365,7 +366,7 @@ namespace
     static void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg )
     {
         SwDoc* pSrcDoc = rRg.aStart.GetNode().GetDoc();
-        if( !pSrcDoc->GetRedlineTbl().empty() )
+        if( !pSrcDoc->getIDocumentRedlineAccess().GetRedlineTbl().empty() )
         {
             SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
             SwPaM aCpyTmp( rCpyRg.aStart, rCpyRg.aEnd );
@@ -625,17 +626,17 @@ namespace
 
         // get first relevant redline
         sal_uInt16 nCurrentRedline;
-        pDoc->GetRedline( *pStart, &nCurrentRedline );
+        pDoc->getIDocumentRedlineAccess().GetRedline( *pStart, &nCurrentRedline );
         if( nCurrentRedline > 0)
             nCurrentRedline--;
 
         // redline mode REDLINE_IGNORE|REDLINE_ON; save old mode
-        RedlineMode_t eOld = pDoc->GetRedlineMode();
-        pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+        RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
 
         // iterate over relevant redlines and decide for each whether it should
         // be saved, or split + saved
-        SwRedlineTbl& rRedlineTable = const_cast<SwRedlineTbl&>( pDoc->GetRedlineTbl() );
+        SwRedlineTbl& rRedlineTable = const_cast<SwRedlineTbl&>( pDoc->getIDocumentRedlineAccess().GetRedlineTbl() );
         for( ; nCurrentRedline < rRedlineTable.size(); nCurrentRedline++ )
         {
             SwRangeRedline* pCurrent = rRedlineTable[ nCurrentRedline ];
@@ -660,7 +661,7 @@ namespace
                     SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
                     *pNewRedline->End() = *pStart;
                     *pCurrent->Start() = *pStart;
-                    pDoc->AppendRedline( pNewRedline, true );
+                    pDoc->getIDocumentRedlineAccess().AppendRedline( pNewRedline, true );
                 }
 
                 // split end, if necessary
@@ -670,7 +671,7 @@ namespace
                     SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
                     *pNewRedline->Start() = *pEnd;
                     *pCurrent->End() = *pEnd;
-                    pDoc->AppendRedline( pNewRedline, true );
+                    pDoc->getIDocumentRedlineAccess().AppendRedline( pNewRedline, true );
                 }
 
                 // save the current redline
@@ -680,21 +681,21 @@ namespace
         }
 
         // restore old redline mode
-        pDoc->SetRedlineMode_intern( eOld );
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     }
 
     static void lcl_RestoreRedlines( SwDoc* pDoc, const SwPosition& rPos, _SaveRedlines& rArr )
     {
-        RedlineMode_t eOld = pDoc->GetRedlineMode();
-        pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+        RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
 
         for( size_t n = 0; n < rArr.size(); ++n )
         {
             rArr[ n ].SetPos( rPos );
-            pDoc->AppendRedline( rArr[ n ].pRedl, true );
+            pDoc->getIDocumentRedlineAccess().AppendRedline( rArr[ n ].pRedl, true );
         }
 
-        pDoc->SetRedlineMode_intern( eOld );
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     }
 
     static void lcl_SaveRedlines( const SwNodeRange& rRg, _SaveRedlines& rArr )
@@ -703,14 +704,14 @@ namespace
         sal_uInt16 nRedlPos;
         SwPosition aSrchPos( rRg.aStart ); aSrchPos.nNode--;
         aSrchPos.nContent.Assign( aSrchPos.nNode.GetNode().GetCntntNode(), 0 );
-        if( pDoc->GetRedline( aSrchPos, &nRedlPos ) && nRedlPos )
+        if( pDoc->getIDocumentRedlineAccess().GetRedline( aSrchPos, &nRedlPos ) && nRedlPos )
             --nRedlPos;
-        else if( nRedlPos >= pDoc->GetRedlineTbl().size() )
+        else if( nRedlPos >= pDoc->getIDocumentRedlineAccess().GetRedlineTbl().size() )
             return ;
 
-        RedlineMode_t eOld = pDoc->GetRedlineMode();
-        pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
-        SwRedlineTbl& rRedlTbl = (SwRedlineTbl&)pDoc->GetRedlineTbl();
+        RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+        SwRedlineTbl& rRedlTbl = (SwRedlineTbl&)pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
 
         do {
             SwRangeRedline* pTmp = rRedlTbl[ nRedlPos ];
@@ -773,28 +774,28 @@ namespace
                     pTmpPos->nNode = rRg.aEnd;
                     pTmpPos->nContent.Assign(
                                 pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
-                    pDoc->AppendRedline( pTmp, true );
+                    pDoc->getIDocumentRedlineAccess().AppendRedline( pTmp, true );
                 }
             }
             else
                 break;
 
-        } while( ++nRedlPos < pDoc->GetRedlineTbl().size() );
-        pDoc->SetRedlineMode_intern( eOld );
+        } while( ++nRedlPos < pDoc->getIDocumentRedlineAccess().GetRedlineTbl().size() );
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     }
 
     static void lcl_RestoreRedlines( SwDoc* pDoc, sal_uInt32 nInsPos, _SaveRedlines& rArr )
     {
-        RedlineMode_t eOld = pDoc->GetRedlineMode();
-        pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+        RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
 
         for( size_t n = 0; n < rArr.size(); ++n )
         {
             rArr[ n ].SetPos( nInsPos );
-            pDoc->AppendRedline( rArr[ n ].pRedl, true );
+            pDoc->getIDocumentRedlineAccess().AppendRedline( rArr[ n ].pRedl, true );
         }
 
-        pDoc->SetRedlineMode_intern( eOld );
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     }
 
     static bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd,
@@ -1125,8 +1126,8 @@ namespace //local functions originally from docfmt.cxx
                     bRet = history.InsertItems(
                         aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet;
 
-                    if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
-                                    && !pDoc->GetRedlineTbl().empty())))
+                    if (bRet && (pDoc->getIDocumentRedlineAccess().IsRedlineOn() || (!pDoc->getIDocumentRedlineAccess().IsIgnoreRedline()
+                                    && !pDoc->getIDocumentRedlineAccess().GetRedlineTbl().empty())))
                     {
                         SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
                                     pStt->nNode, pStt->nContent.GetIndex() );
@@ -1134,10 +1135,10 @@ namespace //local functions originally from docfmt.cxx
                         if( pUndo )
                             pUndo->SaveRedlineData( aPam, true );
 
-                        if( pDoc->IsRedlineOn() )
-                            pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+                        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
+                            pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
                         else
-                            pDoc->SplitRedline( aPam );
+                            pDoc->getIDocumentRedlineAccess().SplitRedline( aPam );
                     }
                 }
             }
@@ -1165,8 +1166,8 @@ namespace //local functions originally from docfmt.cxx
                     bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
                            || bRet;
 
-                    if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
-                                    && !pDoc->GetRedlineTbl().empty())))
+                    if (bRet && (pDoc->getIDocumentRedlineAccess().IsRedlineOn() || (!pDoc->getIDocumentRedlineAccess().IsIgnoreRedline()
+                                    && !pDoc->getIDocumentRedlineAccess().GetRedlineTbl().empty())))
                     {
                         // Was text content inserted? (RefMark/TOXMarks without an end)
                         bool bTxtIns = nInsCnt != rSt.GetIndex();
@@ -1176,13 +1177,13 @@ namespace //local functions originally from docfmt.cxx
                         if( pUndo )
                             pUndo->SaveRedlineData( aPam, bTxtIns );
 
-                        if( pDoc->IsRedlineOn() )
-                            pDoc->AppendRedline(
+                        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
+                            pDoc->getIDocumentRedlineAccess().AppendRedline(
                                 new SwRangeRedline(
                                     bTxtIns ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ),
                                     true);
                         else if( bTxtIns )
-                            pDoc->SplitRedline( aPam );
+                            pDoc->getIDocumentRedlineAccess().SplitRedline( aPam );
                     }
                 }
             }
@@ -1348,13 +1349,13 @@ namespace //local functions originally from docfmt.cxx
                 bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags )
                     || bRet;
 
-                if( pDoc->IsRedlineOn() )
+                if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
                 {
                     SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
 
                     if( pUndo )
                         pUndo->SaveRedlineData( aPam, false );
-                    pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
+                    pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
                 }
             }
             if( pOtherSet && pOtherSet->Count() )
@@ -1374,11 +1375,11 @@ namespace //local functions originally from docfmt.cxx
             return bRet;
         }
 
-        if( pDoc->IsRedlineOn() && pCharSet && pCharSet->Count() )
+        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() && pCharSet && pCharSet->Count() )
         {
             if( pUndo )
                 pUndo->SaveRedlineData( rRg, false );
-            pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
+            pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
         }
 
         /* now if range */
@@ -1606,11 +1607,11 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
     }
 
     SwPaM* pRedlineRange = 0;
-    if( pDoc->IsRedlineOn() ||
-        (!pDoc->IsIgnoreRedline() && !pDoc->GetRedlineTbl().empty() ) )
+    if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() ||
+        (!pDoc->getIDocumentRedlineAccess().IsIgnoreRedline() && !pDoc->getIDocumentRedlineAccess().GetRedlineTbl().empty() ) )
         pRedlineRange = new SwPaM( rPos );
 
-    RedlineMode_t eOld = pDoc->GetRedlineMode();
+    RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
 
     bool bRet = false;
 
@@ -1634,7 +1635,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
         OSL_ENSURE( &m_rSwdoc == pDoc, " invalid copy branch!" );
         OSL_FAIL("mst: i thought this could be dead code;"
                 "please tell me what you did to get here!");
-        pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+        pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
 
         // Then copy the area to the underlying document area
         // (with start/end nodes clamped) and move them to
@@ -1694,13 +1695,13 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
         bRet = true;
     }
 
-    pDoc->SetRedlineMode_intern( eOld );
+    pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     if( pRedlineRange )
     {
-        if( pDoc->IsRedlineOn() )
-            pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pRedlineRange ), true);
+        if( pDoc->getIDocumentRedlineAccess().IsRedlineOn() )
+            pDoc->getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pRedlineRange ), true);
         else
-            pDoc->SplitRedline( *pRedlineRange );
+            pDoc->getIDocumentRedlineAccess().SplitRedline( *pRedlineRange );
         delete pRedlineRange;
     }
 
@@ -1719,7 +1720,7 @@ void DocumentContentOperationsManager::DeleteSection( SwNode *pNode )
 
     // delete all Flys, Bookmarks, ...
     DelFlyInRange( aSttIdx, aEndIdx );
-    m_rSwdoc.DeleteRedline( *pSttNd, true, USHRT_MAX );
+    m_rSwdoc.getIDocumentRedlineAccess().DeleteRedline( *pSttNd, true, USHRT_MAX );
     _DelBookmarks(aSttIdx, aEndIdx);
 
     {
@@ -1744,7 +1745,7 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam )
                         pNd->StartOfSectionIndex();
     sal_uInt32 nNodeDiff = rEnd.nNode.GetIndex() - rStt.nNode.GetIndex();
 
-    if ( nSectDiff-2 <= nNodeDiff || m_rSwdoc.IsRedlineOn() ||
+    if ( nSectDiff-2 <= nNodeDiff || m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() ||
          /* #i9185# Prevent getting the node after the end node (see below) */
         rEnd.nNode.GetIndex() + 1 == m_rSwdoc.GetNodes().Count() )
     {
@@ -1880,7 +1881,7 @@ bool DocumentContentOperationsManager::DeleteAndJoin( SwPaM & rPam,
     if ( lcl_StrLenOverflow( rPam ) )
         return false;
 
-    return lcl_DoWithBreaks( *this, rPam, (m_rSwdoc.IsRedlineOn())
+    return lcl_DoWithBreaks( *this, rPam, (m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn())
                 ? &DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl
                 : &DocumentContentOperationsManager::DeleteAndJoinImpl,
                 bForceJoinNext );
@@ -1902,7 +1903,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
 
     // save redlines (if DOC_MOVEREDLINES is used)
     _SaveRedlines aSaveRedl;
-    if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.GetRedlineTbl().empty() )
+    if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() )
     {
         lcl_SaveRedlines( rPaM, aSaveRedl );
 
@@ -2150,25 +2151,25 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
 
     _SaveRedlines aSaveRedl;
     std::vector<SwRangeRedline*> aSavRedlInsPosArr;
-    if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.GetRedlineTbl().empty() )
+    if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() )
     {
         lcl_SaveRedlines( rRange, aSaveRedl );
 
         // Find all RedLines that end at the InsPos.
         // These have to be moved back to the "old" position after the Move.
-        sal_uInt16 nRedlPos = m_rSwdoc.GetRedlinePos( rPos.GetNode(), USHRT_MAX );
+        sal_uInt16 nRedlPos = m_rSwdoc.getIDocumentRedlineAccess().GetRedlinePos( rPos.GetNode(), USHRT_MAX );
         if( USHRT_MAX != nRedlPos )
         {
             const SwPosition *pRStt, *pREnd;
             do {
-                SwRangeRedline* pTmp = m_rSwdoc.GetRedlineTbl()[ nRedlPos ];
+                SwRangeRedline* pTmp = m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl()[ nRedlPos ];
                 pRStt = pTmp->Start();
                 pREnd = pTmp->End();
                 if( pREnd->nNode == rPos && pRStt->nNode < rPos )
                 {
                     aSavRedlInsPosArr.push_back( pTmp );
                 }
-            } while( pRStt->nNode < rPos && ++nRedlPos < m_rSwdoc.GetRedlineTbl().size());
+            } while( pRStt->nNode < rPos && ++nRedlPos < m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().size());
         }
     }
 
@@ -2221,7 +2222,7 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod
         for( sal_uInt16 n = 0; n < aSavRedlInsPosArr.size(); ++n )
         {
             SwRangeRedline* pTmp = aSavRedlInsPosArr[ n ];
-            if( m_rSwdoc.GetRedlineTbl().Contains( pTmp ) )
+            if( m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().Contains( pTmp ) )
             {
                 SwPosition* pEnd = pTmp->End();
                 pEnd->nNode = aIdx;
@@ -2370,17 +2371,17 @@ bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUStri
     }
 
     if (!m_rSwdoc.GetIDocumentUndoRedo().DoesUndo() &&
-        !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty())
+        !m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty())
     {
         SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
-        m_rSwdoc.DeleteRedline( aPam, true, USHRT_MAX );
+        m_rSwdoc.getIDocumentRedlineAccess().DeleteRedline( aPam, true, USHRT_MAX );
     }
-    else if( m_rSwdoc.IsRedlineOn() )
+    else if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() )
     {
         // FIXME: this redline is WRONG: there is no DELETE, and the skipped
         // characters are also included in aPam
         SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
-        m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+        m_rSwdoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
     }
 
     m_rSwdoc.SetModified();
@@ -2464,18 +2465,18 @@ bool DocumentContentOperationsManager::InsertString( const SwPaM &rRg, const OUS
     }
 
     // To-Do - add 'SwExtraRedlineTbl' also ?
-    if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+    if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() ))
     {
         SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
                     rPos.nNode, rPos.nContent.GetIndex());
-        if( m_rSwdoc.IsRedlineOn() )
+        if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() )
         {
-            m_rSwdoc.AppendRedline(
+            m_rSwdoc.getIDocumentRedlineAccess().AppendRedline(
                 new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
         }
         else
         {
-            m_rSwdoc.SplitRedline( aPam );
+            m_rSwdoc.getIDocumentRedlineAccess().SplitRedline( aPam );
         }
     }
 
@@ -2887,15 +2888,15 @@ bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool b
             pCntntStore->Restore( &m_rSwdoc, rPos.nNode.GetIndex()-1, 0, true );
 
         // To-Do - add 'SwExtraRedlineTbl' also ?
-        if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+        if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() ))
         {
             SwPaM aPam( rPos );
             aPam.SetMark();
             aPam.Move( fnMoveBackward );
-            if( m_rSwdoc.IsRedlineOn() )
-                m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+            if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() )
+                m_rSwdoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
             else
-                m_rSwdoc.SplitRedline( aPam );
+                m_rSwdoc.getIDocumentRedlineAccess().SplitRedline( aPam );
         }
     }
 
@@ -2926,15 +2927,15 @@ bool DocumentContentOperationsManager::AppendTxtNode( SwPosition& rPos )
     }
 
     // To-Do - add 'SwExtraRedlineTbl' also ?
-    if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+    if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() ))
     {
         SwPaM aPam( rPos );
         aPam.SetMark();
         aPam.Move( fnMoveBackward );
-        if( m_rSwdoc.IsRedlineOn() )
-            m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+        if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() )
+            m_rSwdoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
         else
-            m_rSwdoc.SplitRedline( aPam );
+            m_rSwdoc.getIDocumentRedlineAccess().SplitRedline( aPam );
     }
 
     m_rSwdoc.SetModified();
@@ -2997,7 +2998,7 @@ bool DocumentContentOperationsManager::ReplaceRange( SwPaM& rPam, const OUString
         rStart.nContent = *iter + 1;
         if (rEnd.nContent != rStart.nContent) // check if part is empty
         {
-            bRet &= (m_rSwdoc.IsRedlineOn())
+            bRet &= (m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn())
                 ? DeleteAndJoinWithRedlineImpl(aPam)
                 : DeleteAndJoinImpl(aPam, false);
         }
@@ -3159,7 +3160,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
             aCpyTmp );
     }
 
-    if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() ))
+    if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->getIDocumentRedlineAccess().GetRedlineMode() ))
         lcl_DeleteRedlines( rRg, aCpyRange );
 
     pDest->GetNodes()._DelDummyNodes( aCpyRange );
@@ -3194,7 +3195,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
               (pAnchor->GetAnchorId() == FLY_AT_CHAR)) &&
              (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() )
                     ? rRg.aStart <= pAPos->nNode.GetIndex() + 1
-                    : ( m_rSwdoc.IsRedlineMove()
+                    : ( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineMove()
                             ? rRg.aStart < pAPos->nNode
                             : rRg.aStart <= pAPos->nNode )) &&
              pAPos->nNode <= rRg.aEnd )
@@ -3207,7 +3208,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
             bool bAdd = false;
             if( pAPos->nNode < rRg.aEnd )
                 bAdd = true;
-            if (!bAdd && !m_rSwdoc.IsRedlineMove()) // fdo#40599: not for redline move
+            if (!bAdd && !m_rSwdoc.getIDocumentRedlineAccess().IsRedlineMove()) // fdo#40599: not for redline move
             {
                 bool bEmptyNode = false;
                 bool bLastNode = false;
@@ -3453,11 +3454,11 @@ DocumentContentOperationsManager::~DocumentContentOperationsManager()
 
 bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool )
 {
-    OSL_ENSURE( m_rSwdoc.IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" );
+    OSL_ENSURE( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" );
 
     {
         SwUndoRedlineDelete* pUndo = 0;
-        RedlineMode_t eOld = m_rSwdoc.GetRedlineMode();
+        RedlineMode_t eOld = m_rSwdoc.getIDocumentRedlineAccess().GetRedlineMode();
         m_rSwdoc.checkRedlining( eOld );
         if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
         {
@@ -3465,7 +3466,7 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
             /* please don't translate -- for cultural reasons this comment is protected
                until the redline implementation is finally fixed some day */
             //JP 06.01.98: MUSS noch optimiert werden!!!
-            m_rSwdoc.SetRedlineMode(
+            m_rSwdoc.getIDocumentRedlineAccess().SetRedlineMode(
                 (RedlineMode_t) ( nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) );
 
             m_rSwdoc.GetIDocumentUndoRedo().StartUndo( UNDO_DELETE, NULL );
@@ -3474,7 +3475,7 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
         }
 
         if ( *rPam.GetPoint() != *rPam.GetMark() )
-            m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, rPam ), true );
+            m_rSwdoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, rPam ), true );
         m_rSwdoc.SetModified();
 
         if ( pUndo )
@@ -3501,7 +3502,7 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
                 }
             }
             //JP 06.01.98: MUSS noch optimiert werden!!!
-            m_rSwdoc.SetRedlineMode( eOld );
+            m_rSwdoc.getIDocumentRedlineAccess().SetRedlineMode( eOld );
         }
         return true;
     }
@@ -3618,8 +3619,8 @@ bool DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam)
         return true;
     }
 
-    if( !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() )
-        m_rSwdoc.DeleteRedline( rPam, true, USHRT_MAX );
+    if( !m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() )
+        m_rSwdoc.getIDocumentRedlineAccess().DeleteRedline( rPam, true, USHRT_MAX );
 
     // Delete and move all "Flys at the paragraph", which are within the Selection
     DelFlyInRange(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
@@ -3721,8 +3722,8 @@ bool DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam)
 
     } while( false );
 
-    if( !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() )
-        m_rSwdoc.CompressRedlines();
+    if( !m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().empty() )
+        m_rSwdoc.getIDocumentRedlineAccess().CompressRedlines();
     m_rSwdoc.SetModified();
 
     return true;
@@ -3763,9 +3764,9 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
 
         SwDataChanged aTmp( aDelPam );
 
-        if( m_rSwdoc.IsRedlineOn() )
+        if( m_rSwdoc.getIDocumentRedlineAccess().IsRedlineOn() )
         {
-            RedlineMode_t eOld = m_rSwdoc.GetRedlineMode();
+            RedlineMode_t eOld = m_rSwdoc.getIDocumentRedlineAccess().GetRedlineMode();
             m_rSwdoc.checkRedlining(eOld);
             if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
             {
@@ -3775,7 +3776,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
                 const ::sw::mark::IMark* pBkmk = m_rSwdoc.getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
 
                 //JP 06.01.98: MUSS noch optimiert werden!!!
-                m_rSwdoc.SetRedlineMode(
+                m_rSwdoc.getIDocumentRedlineAccess().SetRedlineMode(
                     (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
 
                 *aDelPam.GetPoint() = pBkmk->GetMarkPos();
@@ -3855,7 +3856,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
                     new SwUndoRedlineDelete( aDelPam, UNDO_REPLACE );
                 m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndoRD);
             }
-            m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, aDelPam ), true);
+            m_rSwdoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, aDelPam ), true);
 
             *rPam.GetMark() = *aDelPam.GetMark();
             if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
@@ -3873,7 +3874,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
                 rPam.GetPoint()->nContent = rIdx;
                 *rPam.GetMark() = *rPam.GetPoint();
                 //JP 06.01.98: MUSS noch optimiert werden!!!
-                m_rSwdoc.SetRedlineMode( eOld );
+                m_rSwdoc.getIDocumentRedlineAccess().SetRedlineMode( eOld );
 
                 *rPam.GetPoint() = pBkmk->GetMarkPos();
                 if(pBkmk->IsExpanded())
@@ -3884,8 +3885,8 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt
         }
         else
         {
-            if( !m_rSwdoc.IsIgnoreRedline() && m_rSwdoc.GetRedlineTbl().size() )
-                m_rSwdoc.DeleteRedline( aDelPam, true, USHRT_MAX );
+            if( !m_rSwdoc.getIDocumentRedlineAccess().IsIgnoreRedline() && m_rSwdoc.getIDocumentRedlineAccess().GetRedlineTbl().size() )
+                m_rSwdoc.getIDocumentRedlineAccess().DeleteRedline( aDelPam, true, USHRT_MAX );
 
             SwUndoReplace* pUndoRpl = 0;
             bool const bDoesUndo = m_rSwdoc.GetIDocumentUndoRedo().DoesUndo();
@@ -4018,8 +4019,8 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
         pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
     }
 
-    RedlineMode_t eOld = pDoc->GetRedlineMode();
-    pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+    RedlineMode_t eOld = pDoc->getIDocumentRedlineAccess().GetRedlineMode();
+    pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
 
     // Move the PaM one node back from the insert position, so that
     // the position doesn't get moved
@@ -4448,7 +4449,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
                           aListIdToPropagate, true, true );
     }
 
-    pDoc->SetRedlineMode_intern( eOld );
+    pDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
     pDoc->SetModified();
 
     return true;
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
new file mode 100644
index 0000000..a540fee
--- /dev/null
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -0,0 +1,2651 @@
+
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+*/
+#include <DocumentRedlineManager.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <redline.hxx>
+#include <UndoRedline.hxx>
+#include <docary.hxx>
+#include <ndtxt.hxx>
+#include <comcore.hrc>
+#include <swmodule.hxx>
+
+using namespace com::sun::star;
+
+#ifdef DBG_UTIL
+
+    #define _ERROR_PREFIX "redline table corrupted: "
+
+    namespace
+    {
+        // helper function for lcl_CheckRedline
+        // 1. make sure that pPos->nContent points into pPos->nNode
+        //    (or into the 'special' no-content-node-IndexReg)
+        // 2. check that position is valid and doesn't point behind text
+        static void lcl_CheckPosition( const SwPosition* pPos )
+        {
+            SwPosition aComparePos( *pPos );
+            aComparePos.nContent.Assign(
+                aComparePos.nNode.GetNode().GetCntntNode(), 0 );
+            OSL_ENSURE( pPos->nContent.GetIdxReg() ==
+                        aComparePos.nContent.GetIdxReg(),
+                        _ERROR_PREFIX "illegal position" );
+
+            SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
+            if( pTxtNode == NULL )
+            {
+                OSL_ENSURE( pPos->nContent == 0,
+                            _ERROR_PREFIX "non-text-node with content" );
+            }
+            else
+            {
+                OSL_ENSURE( pPos->nContent >= 0  &&
+                            pPos->nContent <= pTxtNode->Len(),
+                            _ERROR_PREFIX "index behind text" );
+            }
+        }
+
+        static void lcl_CheckPam( const SwPaM* pPam )
+        {
+            OSL_ENSURE( pPam != NULL, _ERROR_PREFIX "illegal argument" );
+            lcl_CheckPosition( pPam->GetPoint() );
+            lcl_CheckPosition( pPam->GetMark() );
+        }
+
+        // check validity of the redline table. Checks redline bounds, and make
+        // sure the redlines are sorted and non-overlapping.
+        static void lcl_CheckRedline( IDocumentRedlineAccess& redlineAccess )
+        {
+            const SwRedlineTbl& rTbl = redlineAccess.GetRedlineTbl();
+
+            // verify valid redline positions
+            for( sal_uInt16 i = 0; i < rTbl.size(); ++i )
+                lcl_CheckPam( rTbl[ i ] );
+
+            for( sal_uInt16 j = 0; j < rTbl.size(); ++j )
+            {
+                // check for empty redlines
+                OSL_ENSURE( ( *(rTbl[j]->GetPoint()) != *(rTbl[j]->GetMark()) ) ||
+                            ( rTbl[j]->GetContentIdx() != NULL ),
+                            _ERROR_PREFIX "empty redline" );
+             }
+
+            // verify proper redline sorting
+            for( sal_uInt16 n = 1; n < rTbl.size(); ++n )
+            {
+                const SwRangeRedline* pPrev = rTbl[ n-1 ];
+                const SwRangeRedline* pCurrent = rTbl[ n ];
+
+                // check redline sorting
+                SAL_WARN_IF( *pPrev->Start() > *pCurrent->Start(), "sw",
+                             _ERROR_PREFIX "not sorted correctly" );
+
+                // check for overlapping redlines
+                SAL_WARN_IF( *pPrev->End() > *pCurrent->Start(), "sw",
+                             _ERROR_PREFIX "overlapping redlines" );
+            }
+        }
+    }
+
+    #define _CHECK_REDLINE( pDoc ) lcl_CheckRedline( pDoc );
+
+#else
+
+    #define _CHECK_REDLINE( pDoc )
+
+#endif
+
+namespace
+{
+    static inline bool IsPrevPos( const SwPosition rPos1, const SwPosition rPos2 )
+    {
+        const SwCntntNode* pCNd;
+        return 0 == rPos2.nContent.GetIndex() &&
+               rPos2.nNode.GetIndex() - 1 == rPos1.nNode.GetIndex() &&
+               0 != ( pCNd = rPos1.nNode.GetNode().GetCntntNode() ) &&
+               rPos1.nContent.GetIndex() == pCNd->Len();
+    }
+
+    static bool lcl_AcceptRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
+                            bool bCallDelete,
+                            const SwPosition* pSttRng = 0,
+                            const SwPosition* pEndRng = 0 )
+    {
+        bool bRet = true;
+        SwRangeRedline* pRedl = rArr[ rPos ];
+        SwPosition *pRStt = 0, *pREnd = 0;
+        SwComparePosition eCmp = POS_OUTSIDE;
+        if( pSttRng && pEndRng )
+        {
+            pRStt = pRedl->Start();
+            pREnd = pRedl->End();
+            eCmp = ComparePosition( *pSttRng, *pEndRng, *pRStt, *pREnd );
+        }
+
+        pRedl->InvalidateRange();
+
+        switch( pRedl->GetType() )
+        {
+        case nsRedlineType_t::REDLINE_INSERT:
+        case nsRedlineType_t::REDLINE_FORMAT:
+            {
+                bool bCheck = false, bReplace = false;
+                switch( eCmp )
+                {
+                case POS_INSIDE:
+                    if( *pSttRng == *pRStt )
+                        pRedl->SetStart( *pEndRng, pRStt );
+                    else
+                    {
+                        if( *pEndRng != *pREnd )
+                        {
+                            // split up
+                            SwRangeRedline* pNew = new SwRangeRedline( *pRedl );
+                            pNew->SetStart( *pEndRng );
+                            rArr.Insert( pNew ); ++rPos;
+                        }
+                        pRedl->SetEnd( *pSttRng, pREnd );
+                        bCheck = true;
+                    }
+                    break;
+
+                case POS_OVERLAP_BEFORE:
+                    pRedl->SetStart( *pEndRng, pRStt );
+                    bReplace = true;
+                    break;
+
+                case POS_OVERLAP_BEHIND:
+                    pRedl->SetEnd( *pSttRng, pREnd );
+                    bCheck = true;
+                    break;
+
+                case POS_OUTSIDE:
+                case POS_EQUAL:
+                    rArr.DeleteAndDestroy( rPos-- );
+                    break;
+
+                default:
+                    bRet = false;
+                }
+
+                if( bReplace || ( bCheck && !pRedl->HasValidRange() ))
+                {
+                    // re-insert
+                    rArr.Remove( pRedl );
+                    rArr.Insert( pRedl );
+                }
+            }
+            break;
+        case nsRedlineType_t::REDLINE_DELETE:
+            {
+                SwDoc& rDoc = *pRedl->GetDoc();
+                const SwPosition *pDelStt = 0, *pDelEnd = 0;
+                bool bDelRedl = false;
+                switch( eCmp )
+                {
+                case POS_INSIDE:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pSttRng;
+                        pDelEnd = pEndRng;
+                    }
+                    break;
+
+                case POS_OVERLAP_BEFORE:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pRStt;
+                        pDelEnd = pEndRng;
+                    }
+                    break;
+                case POS_OVERLAP_BEHIND:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pREnd;
+                        pDelEnd = pSttRng;
+                    }
+                    break;
+
+                case POS_OUTSIDE:
+                case POS_EQUAL:
+                    {
+                        rArr.Remove( rPos-- );
+                        bDelRedl = true;
+                        if( bCallDelete )
+                        {
+                            pDelStt = pRedl->Start();
+                            pDelEnd = pRedl->End();
+                        }
+                    }
+                    break;
+                default:
+                    bRet = false;
+                }
+
+                if( pDelStt && pDelEnd )
+                {
+                    SwPaM aPam( *pDelStt, *pDelEnd );
+                    SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();
+                    SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode();
+
+                    if( bDelRedl )
+                        delete pRedl;
+
+                    RedlineMode_t eOld = rDoc.getIDocumentRedlineAccess().GetRedlineMode();
+                    rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
+
+                    if( pCSttNd && pCEndNd )
+                        rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
+                    else
+                    {
+                        rDoc.getIDocumentContentOperations().DeleteRange( aPam );
+
+                        if( pCSttNd && !pCEndNd )
+                        {
+                            aPam.GetBound( true ).nContent.Assign( 0, 0 );
+                            aPam.GetBound( false ).nContent.Assign( 0, 0 );
+                            aPam.DeleteMark();
+                            rDoc.getIDocumentContentOperations().DelFullPara( aPam );
+                        }
+                    }
+                    rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
+                }
+                else if( bDelRedl )
+                    delete pRedl;
+            }
+            break;
+
+        case nsRedlineType_t::REDLINE_FMTCOLL:
+            rArr.DeleteAndDestroy( rPos-- );
+            break;
+
+        default:
+            bRet = false;
+        }
+        return bRet;
+    }
+
+    static bool lcl_RejectRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
+                            bool bCallDelete,
+                            const SwPosition* pSttRng = 0,
+                            const SwPosition* pEndRng = 0 )
+    {
+        bool bRet = true;
+        SwRangeRedline* pRedl = rArr[ rPos ];
+        SwPosition *pRStt = 0, *pREnd = 0;
+        SwComparePosition eCmp = POS_OUTSIDE;
+        if( pSttRng && pEndRng )
+        {
+            pRStt = pRedl->Start();
+            pREnd = pRedl->End();
+            eCmp = ComparePosition( *pSttRng, *pEndRng, *pRStt, *pREnd );
+        }
+
+        pRedl->InvalidateRange();
+
+        switch( pRedl->GetType() )
+        {
+        case nsRedlineType_t::REDLINE_INSERT:
+            {
+                SwDoc& rDoc = *pRedl->GetDoc();
+                const SwPosition *pDelStt = 0, *pDelEnd = 0;
+                bool bDelRedl = false;
+                switch( eCmp )
+                {
+                case POS_INSIDE:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pSttRng;
+                        pDelEnd = pEndRng;
+                    }
+                    break;
+
+                case POS_OVERLAP_BEFORE:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pRStt;
+                        pDelEnd = pEndRng;
+                    }
+                    break;
+                case POS_OVERLAP_BEHIND:
+                    if( bCallDelete )
+                    {
+                        pDelStt = pREnd;
+                        pDelEnd = pSttRng;
+                    }
+                    break;
+                case POS_OUTSIDE:
+                case POS_EQUAL:
+                    {
+                        // delete the range again
+                        rArr.Remove( rPos-- );
+                        bDelRedl = true;
+                        if( bCallDelete )
+                        {
+                            pDelStt = pRedl->Start();
+                            pDelEnd = pRedl->End();
+                        }
+                    }
+                    break;
+
+                default:
+                    bRet = false;
+                }
+                if( pDelStt && pDelEnd )
+                {
+                    SwPaM aPam( *pDelStt, *pDelEnd );
+
+                    SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();
+                    SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode();
+
+                    if( bDelRedl )
+                        delete pRedl;
+
+                    RedlineMode_t eOld = rDoc.getIDocumentRedlineAccess().GetRedlineMode();
+                    rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
+
+                    if( pCSttNd && pCEndNd )
+                        rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
+                    else
+                    {
+                        rDoc.getIDocumentContentOperations().DeleteRange( aPam );
+
+                        if( pCSttNd && !pCEndNd )
+                        {
+                            aPam.GetBound( true ).nContent.Assign( 0, 0 );
+                            aPam.GetBound( false ).nContent.Assign( 0, 0 );
+                            aPam.DeleteMark();
+                            rDoc.getIDocumentContentOperations().DelFullPara( aPam );
+                        }
+                    }
+                    rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
+                }
+                else if( bDelRedl )
+                    delete pRedl;
+            }
+            break;
+        case nsRedlineType_t::REDLINE_DELETE:
+            {
+                SwRangeRedline* pNew = 0;
+                bool bCheck = false, bReplace = false;
+
+                switch( eCmp )
+                {
+                case POS_INSIDE:
+                    {
+                        if( 1 < pRedl->GetStackCount() )
+                        {
+                            pNew = new SwRangeRedline( *pRedl );
+                            pNew->PopData();
+                        }
+                        if( *pSttRng == *pRStt )
+                        {
+                            pRedl->SetStart( *pEndRng, pRStt );
+                            bReplace = true;
+                            if( pNew )
+                                pNew->SetEnd( *pEndRng );
+                        }
+                        else
+                        {
+                            if( *pEndRng != *pREnd )
+                            {
+                                // split up
+                                SwRangeRedline* pCpy = new SwRangeRedline( *pRedl );
+                                pCpy->SetStart( *pEndRng );
+                                rArr.Insert( pCpy ); ++rPos;
+                                if( pNew )
+                                    pNew->SetEnd( *pEndRng );
+                            }
+
+                            pRedl->SetEnd( *pSttRng, pREnd );
+                            bCheck = true;
+                            if( pNew )
+                                pNew->SetStart( *pSttRng );
+                        }
+                    }
+                    break;
+
+                case POS_OVERLAP_BEFORE:
+                    if( 1 < pRedl->GetStackCount() )
+                    {
+                        pNew = new SwRangeRedline( *pRedl );
+                        pNew->PopData();
+                    }
+                    pRedl->SetStart( *pEndRng, pRStt );
+                    bReplace = true;
+                    if( pNew )
+                        pNew->SetEnd( *pEndRng );
+                    break;
+
+                case POS_OVERLAP_BEHIND:
+                    if( 1 < pRedl->GetStackCount() )
+                    {
+                        pNew = new SwRangeRedline( *pRedl );
+                        pNew->PopData();
+                    }
+                    pRedl->SetEnd( *pSttRng, pREnd );
+                    bCheck = true;
+                    if( pNew )
+                        pNew->SetStart( *pSttRng );
+                    break;
+
+                case POS_OUTSIDE:
+                case POS_EQUAL:
+                    if( !pRedl->PopData() )
+                        // deleting the RedlineObject is enough
+                        rArr.DeleteAndDestroy( rPos-- );
+                    break;
+
+                default:
+                    bRet = false;
+                }
+
+                if( pNew )
+                {
+                    rArr.Insert( pNew ); ++rPos;
+                }
+
+                if( bReplace || ( bCheck && !pRedl->HasValidRange() ))
+                {
+                    // re-insert
+                    rArr.Remove( pRedl );
+                    rArr.Insert( pRedl );
+                }
+            }
+            break;
+
+        case nsRedlineType_t::REDLINE_FORMAT:
+        case nsRedlineType_t::REDLINE_FMTCOLL:
+            {
+                if( pRedl->GetExtraData() )
+                    pRedl->GetExtraData()->Reject( *pRedl );
+                rArr.DeleteAndDestroy( rPos-- );
+            }
+            break;
+
+        default:
+            bRet = false;
+        }
+        return bRet;
+    }
+
+    typedef bool (*Fn_AcceptReject)( SwRedlineTbl& rArr, sal_uInt16& rPos,
+                            bool bCallDelete,
+                            const SwPosition* pSttRng,
+                            const SwPosition* pEndRng);
+
+
+    static int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject,
+                                SwRedlineTbl& rArr, bool bCallDelete,
+                                const SwPaM& rPam)
+    {
+        sal_uInt16 n = 0;
+        int nCount = 0;
+
+        const SwPosition* pStt = rPam.Start(),
+                        * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
+                                                         : rPam.GetPoint();
+        const SwRangeRedline* pFnd = rArr.FindAtPosition( *pStt, n, true );
+        if( pFnd &&     // Is new a part of it?
+            ( *pFnd->Start() != *pStt || *pFnd->End() > *pEnd ))
+        {
+            // Only revoke the partial selection
+            if( (*fn_AcceptReject)( rArr, n, bCallDelete, pStt, pEnd ))
+                nCount++;
+            ++n;
+        }
+
+        for( ; n < rArr.size(); ++n )
+        {
+            SwRangeRedline* pTmp = rArr[ n ];
+            if( pTmp->HasMark() && pTmp->IsVisible() )
+            {
+                if( *pTmp->End() <= *pEnd )
+                {
+                    if( (*fn_AcceptReject)( rArr, n, bCallDelete, 0, 0 ))
+                        nCount++;
+                }
+                else
+                {
+                    if( *pTmp->Start() < *pEnd )
+                    {
+                        // Only revoke the partial selection
+                        if( (*fn_AcceptReject)( rArr, n, bCallDelete, pStt, pEnd ))
+                            nCount++;
+                    }
+                    break;
+                }
+            }
+        }
+        return nCount;
+    }
+
+    static void lcl_AdjustRedlineRange( SwPaM& rPam )
+    {
+        // The Selection is only in the ContentSection. If there are Redlines
+        // to Non-ContentNodes before or after that, then the Selections
+        // expand to them.
+        SwPosition* pStt = rPam.Start(),
+                  * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
+                                                   : rPam.GetPoint();
+        SwDoc* pDoc = rPam.GetDoc();
+        if( !pStt->nContent.GetIndex() &&
+            !pDoc->GetNodes()[ pStt->nNode.GetIndex() - 1 ]->IsCntntNode() )
+        {
+            const SwRangeRedline* pRedl = pDoc->getIDocumentRedlineAccess().GetRedline( *pStt, 0 );
+            if( pRedl )
+            {
+                const SwPosition* pRStt = pRedl->Start();
+                if( !pRStt->nContent.GetIndex() && pRStt->nNode.GetIndex() ==
+                    pStt->nNode.GetIndex() - 1 )
+                    *pStt = *pRStt;
+            }
+        }
+        if( pEnd->nNode.GetNode().IsCntntNode() &&
+            !pDoc->GetNodes()[ pEnd->nNode.GetIndex() + 1 ]->IsCntntNode() &&
+            pEnd->nContent.GetIndex() == pEnd->nNode.GetNode().GetCntntNode()->Len()    )
+        {
+            const SwRangeRedline* pRedl = pDoc->getIDocumentRedlineAccess().GetRedline( *pEnd, 0 );
+            if( pRedl )
+            {
+                const SwPosition* pREnd = pRedl->End();
+                if( !pREnd->nContent.GetIndex() && pREnd->nNode.GetIndex() ==
+                    pEnd->nNode.GetIndex() + 1 )
+                    *pEnd = *pREnd;
+            }
+        }
+    }
+}
+
+namespace sw
+{
+
+DocumentRedlineManager::DocumentRedlineManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ),
+                                                                    meRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
+                                                                    mpRedlineTbl( new SwRedlineTbl ),
+                                                                    mpExtraRedlineTbl ( new SwExtraRedlineTbl ),
+                                                                    mpAutoFmtRedlnComment( 0 ),
+                                                                    mbIsRedlineMove(false),
+                                                                    mnAutoFmtRedlnCommentNo( 0 )
+{
+}
+
+RedlineMode_t DocumentRedlineManager::GetRedlineMode() const
+{
+    return meRedlineMode;
+}
+
+void DocumentRedlineManager::SetRedlineMode( RedlineMode_t eMode )
+{
+    if( meRedlineMode != eMode )
+    {
+        if( (nsRedlineMode_t::REDLINE_SHOW_MASK & meRedlineMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode)
+            || 0 == (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode) )
+        {
+            bool bSaveInXMLImportFlag = m_rSwdoc.IsInXMLImport();
+            m_rSwdoc.SetInXMLImport( false );
+            // and then hide/display everything
+            void (SwRangeRedline::*pFnc)( sal_uInt16 ) = 0;
+
+            switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eMode )
+            {
+            case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE :
+                pFnc = &SwRangeRedline::Show;
+                break;
+            case nsRedlineMode_t::REDLINE_SHOW_INSERT:
+                pFnc = &SwRangeRedline::Hide;
+                break;
+            case nsRedlineMode_t::REDLINE_SHOW_DELETE:
+                pFnc = &SwRangeRedline::ShowOriginal;
+                break;
+
+            default:
+                pFnc = &SwRangeRedline::Hide;
+                eMode = (RedlineMode_t)(eMode | nsRedlineMode_t::REDLINE_SHOW_INSERT);
+                break;
+            }
+
+            _CHECK_REDLINE( *this )
+
+            if( pFnc )
+                for( sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop )
+                    for( sal_uInt16 i = 0; i < mpRedlineTbl->size(); ++i )
+                        ((*mpRedlineTbl)[ i ]->*pFnc)( nLoop );
+            _CHECK_REDLINE( *this )
+            m_rSwdoc.SetInXMLImport( bSaveInXMLImportFlag );
+        }
+        meRedlineMode = eMode;
+        m_rSwdoc.SetModified();
+    }
+
+    // #TODO - add 'SwExtraRedlineTbl' also ?
+}
+
+bool DocumentRedlineManager::IsRedlineOn() const
+{
+    return IDocumentRedlineAccess::IsRedlineOn(meRedlineMode);
+}
+
+bool DocumentRedlineManager::IsIgnoreRedline() const
+{
+    return (nsRedlineMode_t::REDLINE_IGNORE & meRedlineMode);
+}
+
+void DocumentRedlineManager::SetRedlineMode_intern(RedlineMode_t eMode)
+{
+    meRedlineMode = eMode;
+}
+
+const SwRedlineTbl& DocumentRedlineManager::GetRedlineTbl() const
+{
+    return *mpRedlineTbl;
+}
+
+SwRedlineTbl& DocumentRedlineManager::GetRedlineTbl()
+{
+    return *mpRedlineTbl;
+}
+
+const SwExtraRedlineTbl& DocumentRedlineManager::GetExtraRedlineTbl() const
+{
+    return *mpExtraRedlineTbl;
+}
+
+SwExtraRedlineTbl& DocumentRedlineManager::GetExtraRedlineTbl()
+{
+    return *mpExtraRedlineTbl;
+}
+
+bool DocumentRedlineManager::HasExtraRedlineTbl() const
+{
+    return mpExtraRedlineTbl ? true : false;
+}
+
+bool DocumentRedlineManager::IsInRedlines(const SwNode & rNode) const
+{
+    SwPosition aPos(rNode);
+    SwNode & rEndOfRedlines = m_rSwdoc.GetNodes().GetEndOfRedlines();
+    SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()),
+               SwPosition(rEndOfRedlines));
+
+    return aPam.ContainsPosition(aPos);
+}
+
+bool DocumentRedlineManager::IsRedlineMove() const
+{
+    return mbIsRedlineMove;
+}
+
+void DocumentRedlineManager::SetRedlineMove(bool bFlag)
+{
+    mbIsRedlineMove = bFlag;
+}
+
+/*
+Text means Text not "polluted" by Redlines.
+
+Behaviour of Insert-Redline:
+    - in the Text                       - insert Redline Object
+    - in InsertRedline (own)            - ignore, existing is extended
+    - in InsertRedline (others)         - split up InsertRedline and
+                                          insert Redline Object
+    - in DeleteRedline                  - split up DeleteRedline or
+                                          move at the end/beginning
+
+Behaviour of Delete-Redline:
+    - in the Text                       - insert Redline Object
+    - in DeleteRedline (own/others)     - ignore
+    - in InsertRedline (own)            - ignore, but delete character
+    - in InsertRedline (others)         - split up InsertRedline and
+                                          insert Redline Object
+    - Text and own Insert overlap       - delete Text in the own Insert,
+                                          extend in the other Text
+                                          (up to the Insert!)
+    - Text and other Insert overlap     - insert Redline Object, the
+                                          other Insert is overlapped by
+                                          the Delete
+*/
+bool DocumentRedlineManager::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
+{
+    bool bMerged = false;
+    _CHECK_REDLINE( *this )
+
+    if (IsRedlineOn() && !IsShowOriginal(meRedlineMode))
+    {
+        pNewRedl->InvalidateRange();
+
+        if( m_rSwdoc.IsAutoFmtRedline() )
+        {
+            pNewRedl->SetAutoFmtFlag();
+            if( mpAutoFmtRedlnComment && !mpAutoFmtRedlnComment->isEmpty() )
+            {
+                pNewRedl->SetComment( *mpAutoFmtRedlnComment );
+                pNewRedl->SetSeqNo( mnAutoFmtRedlnCommentNo );
+            }
+        }
+
+        SwPosition* pStt = pNewRedl->Start(),
+                  * pEnd = pStt == pNewRedl->GetPoint() ? pNewRedl->GetMark()
+                                                        : pNewRedl->GetPoint();
+        {
+            SwTxtNode* pTxtNode = pStt->nNode.GetNode().GetTxtNode();
+            if( pTxtNode == NULL )
+            {
+                if( pStt->nContent > 0 )
+                {
+                    OSL_ENSURE( false, "Redline start: non-text-node with content" );
+                    pStt->nContent = 0;
+                }
+            }
+            else
+            {
+                if( pStt->nContent > pTxtNode->Len() )
+                {
+                    OSL_ENSURE( false, "Redline start: index behind text" );
+                    pStt->nContent = pTxtNode->Len();
+                }
+            }
+            pTxtNode = pEnd->nNode.GetNode().GetTxtNode();
+            if( pTxtNode == NULL )
+            {
+                if( pEnd->nContent > 0 )
+                {
+                    OSL_ENSURE( false, "Redline end: non-text-node with content" );
+                    pEnd->nContent = 0;
+                }
+            }
+            else
+            {
+                if( pEnd->nContent > pTxtNode->Len() )
+                {
+                    OSL_ENSURE( false, "Redline end: index behind text" );
+                    pEnd->nContent = pTxtNode->Len();
+                }
+            }
+        }
+        if( ( *pStt == *pEnd ) &&
+            ( pNewRedl->GetContentIdx() == NULL ) )
+        {   // Do not insert empty redlines
+            delete pNewRedl;
+            return false;
+        }
+        bool bCompress = false;
+        sal_uInt16 n = 0;
+        // look up the first Redline for the starting position
+        if( !GetRedline( *pStt, &n ) && n )
+            --n;
+        bool bDec = false;
+
+        for( ; pNewRedl && n < mpRedlineTbl->size(); bDec ? n : ++n )
+        {
+            bDec = false;
+
+            SwRangeRedline* pRedl = (*mpRedlineTbl)[ n ];
+            SwPosition* pRStt = pRedl->Start(),
+                      * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
+                                                           : pRedl->GetPoint();
+
+            // #i8518# remove empty redlines while we're at it
+            if( ( *pRStt == *pREnd ) &&
+                ( pRedl->GetContentIdx() == NULL ) )
+            {
+                mpRedlineTbl->DeleteAndDestroy(n);
+                continue;
+            }
+
+            SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
+
+            switch( pNewRedl->GetType() )
+            {
+            case nsRedlineType_t::REDLINE_INSERT:
+                switch( pRedl->GetType() )
+                {
+                case nsRedlineType_t::REDLINE_INSERT:
+                    if( pRedl->IsOwnRedline( *pNewRedl ) )
+                    {
+                        bool bDelete = false;
+
+                        // Merge if applicable?
+                        if( (( POS_BEHIND == eCmpPos &&
+                               IsPrevPos( *pREnd, *pStt ) ) ||
+                             ( POS_COLLIDE_START == eCmpPos ) ||
+                             ( POS_OVERLAP_BEHIND == eCmpPos ) ) &&
+                            pRedl->CanCombine( *pNewRedl ) &&
+                            ( n+1 >= (sal_uInt16)mpRedlineTbl->size() ||
+                             ( *(*mpRedlineTbl)[ n+1 ]->Start() >= *pEnd &&
+                             *(*mpRedlineTbl)[ n+1 ]->Start() != *pREnd ) ) )
+                        {
+                            pRedl->SetEnd( *pEnd, pREnd );
+                            if( !pRedl->HasValidRange() )
+                            {
+                                // re-insert
+                                mpRedlineTbl->Remove( n );
+                                mpRedlineTbl->Insert( pRedl );
+                            }
+
+                            bMerged = true;
+                            bDelete = true;
+                        }
+                        else if( (( POS_BEFORE == eCmpPos &&
+                                    IsPrevPos( *pEnd, *pRStt ) ) ||
+                                   ( POS_COLLIDE_END == eCmpPos ) ||
+                                  ( POS_OVERLAP_BEFORE == eCmpPos ) ) &&
+                            pRedl->CanCombine( *pNewRedl ) &&
+                            ( !n ||
+                             *(*mpRedlineTbl)[ n-1 ]->End() != *pRStt ))
+                        {
+                            pRedl->SetStart( *pStt, pRStt );
+                            // re-insert
+                            mpRedlineTbl->Remove( n );
+                            mpRedlineTbl->Insert( pRedl );
+
+                            bMerged = true;
+                            bDelete = true;
+                        }
+                        else if ( POS_OUTSIDE == eCmpPos )
+                        {
+                            // own insert-over-insert redlines:
+                            // just scrap the inside ones
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                        }
+                        else if( POS_OVERLAP_BEHIND == eCmpPos )
+                        {
+                            *pStt = *pREnd;
+                            if( ( *pStt == *pEnd ) &&
+                                ( pNewRedl->GetContentIdx() == NULL ) )
+                                bDelete = true;
+                        }
+                        else if( POS_OVERLAP_BEFORE == eCmpPos )
+                        {
+                            *pEnd = *pRStt;
+                            if( ( *pStt == *pEnd ) &&
+                                ( pNewRedl->GetContentIdx() == NULL ) )
+                                bDelete = true;
+                        }
+                        else if( POS_INSIDE == eCmpPos || POS_EQUAL == eCmpPos)
+                            bDelete = true;
+
+                        if( bDelete )
+                        {
+                            delete pNewRedl, pNewRedl = 0;
+                            bCompress = true;
+                        }
+                    }
+                    else if( POS_INSIDE == eCmpPos )
+                    {
+                        // split up
+                        if( *pEnd != *pREnd )
+                        {
+                            SwRangeRedline* pCpy = new SwRangeRedline( *pRedl );
+                            pCpy->SetStart( *pEnd );
+                            mpRedlineTbl->Insert( pCpy );
+                        }
+                        pRedl->SetEnd( *pStt, pREnd );
+                        if( ( *pStt == *pRStt ) &&
+                            ( pRedl->GetContentIdx() == NULL ) )
+                        {
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                        }
+                        else if( !pRedl->HasValidRange() )
+                        {
+                            // re-insert
+                            mpRedlineTbl->Remove( n );
+                            mpRedlineTbl->Insert( pRedl );
+                        }
+                    }
+                    else if ( POS_OUTSIDE == eCmpPos )
+                    {
+                        // handle overlapping redlines in broken documents
+
+                        // split up the new redline, since it covers the
+                        // existing redline. Insert the first part, and
+                        // progress with the remainder as usual
+                        SwRangeRedline* pSplit = new SwRangeRedline( *pNewRedl );
+                        pSplit->SetEnd( *pRStt );
+                        pNewRedl->SetStart( *pREnd );
+                        mpRedlineTbl->Insert( pSplit );
+                        if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
+                        {
+                            delete pNewRedl;
+                            pNewRedl = 0;
+                            bCompress = true;
+                        }
+                    }
+                    else if ( POS_OVERLAP_BEHIND == eCmpPos )
+                    {
+                        // handle overlapping redlines in broken documents
+                        pNewRedl->SetStart( *pREnd );
+                    }
+                    else if ( POS_OVERLAP_BEFORE == eCmpPos )
+                    {
+                        // handle overlapping redlines in broken documents
+                        *pEnd = *pRStt;
+                        if( ( *pStt == *pEnd ) &&
+                            ( pNewRedl->GetContentIdx() == NULL ) )
+                        {
+                            delete pNewRedl;
+                            pNewRedl = 0;
+                            bCompress = true;
+                        }
+                    }
+                    break;
+                case nsRedlineType_t::REDLINE_DELETE:
+                    if( POS_INSIDE == eCmpPos )
+                    {
+                        // split up
+                        if( *pEnd != *pREnd )
+                        {
+                            SwRangeRedline* pCpy = new SwRangeRedline( *pRedl );
+                            pCpy->SetStart( *pEnd );
+                            mpRedlineTbl->Insert( pCpy );
+                        }
+                        pRedl->SetEnd( *pStt, pREnd );
+                        if( ( *pStt == *pRStt ) &&
+                            ( pRedl->GetContentIdx() == NULL ) )
+                        {
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                        }
+                        else if( !pRedl->HasValidRange() )
+                        {
+                            // re-insert
+                            mpRedlineTbl->Remove( n );
+                            mpRedlineTbl->Insert( pRedl, n );
+                        }
+                    }
+                    else if ( POS_OUTSIDE == eCmpPos )
+                    {
+                        // handle overlapping redlines in broken documents
+
+                        // split up the new redline, since it covers the
+                        // existing redline. Insert the first part, and
+                        // progress with the remainder as usual
+                        SwRangeRedline* pSplit = new SwRangeRedline( *pNewRedl );
+                        pSplit->SetEnd( *pRStt );
+                        pNewRedl->SetStart( *pREnd );
+                        mpRedlineTbl->Insert( pSplit );
+                        if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
+                        {
+                            delete pNewRedl;
+                            pNewRedl = 0;
+                            bCompress = true;
+                        }
+                    }
+                    else if ( POS_EQUAL == eCmpPos )
+                    {
+                        // handle identical redlines in broken documents
+                        // delete old (delete) redline
+                        mpRedlineTbl->DeleteAndDestroy( n );
+                        bDec = true;
+                    }
+                    else if ( POS_OVERLAP_BEHIND == eCmpPos )
+                    {   // Another workaround for broken redlines
+                        pNewRedl->SetStart( *pREnd );
+                    }
+                    break;
+                case nsRedlineType_t::REDLINE_FORMAT:
+                    switch( eCmpPos )
+                    {
+                    case POS_OVERLAP_BEFORE:
+                        pRedl->SetStart( *pEnd, pRStt );
+                        // re-insert
+                        mpRedlineTbl->Remove( n );
+                        mpRedlineTbl->Insert( pRedl, n );
+                        bDec = true;
+                        break;
+
+                    case POS_OVERLAP_BEHIND:
+                        pRedl->SetEnd( *pStt, pREnd );
+                        if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
+                        {
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                        }
+                        break;
+
+                    case POS_EQUAL:
+                    case POS_OUTSIDE:
+                        // Overlaps the current one completely or has the
+                        // same dimension, delete the old one
+                        mpRedlineTbl->DeleteAndDestroy( n );
+                        bDec = true;
+                        break;
+
+                    case POS_INSIDE:
+                        // Overlaps the current one completely,
+                        // split or shorten the new one
+                        if( *pEnd != *pREnd )
+                        {
+                            if( *pEnd != *pRStt )
+                            {
+                                SwRangeRedline* pNew = new SwRangeRedline( *pRedl );
+                                pNew->SetStart( *pEnd );
+                                pRedl->SetEnd( *pStt, pREnd );
+                                if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
+                                    mpRedlineTbl->DeleteAndDestroy( n );
+                                AppendRedline( pNew, bCallDelete );
+                                n = 0;      // re-initialize
+                                bDec = true;
+                            }
+                        }
+                        else
+                            pRedl->SetEnd( *pStt, pREnd );
+                        break;
+                    default:
+                        break;
+                    }
+                    break;
+                default:
+                    break;
+                }
+                break;
+
+            case nsRedlineType_t::REDLINE_DELETE:
+                switch( pRedl->GetType() )
+                {
+                case nsRedlineType_t::REDLINE_DELETE:
+                    switch( eCmpPos )
+                    {
+                    case POS_OUTSIDE:
+                        {
+                            // Overlaps the current one completely,
+                            // split the new one
+                            if( *pEnd != *pREnd )
+                            {
+                                SwRangeRedline* pNew = new SwRangeRedline( *pNewRedl );
+                                pNew->SetStart( *pREnd );
+                                pNewRedl->SetEnd( *pRStt, pEnd );
+                                AppendRedline( pNew, bCallDelete );
+                                n = 0;      // re-initialize
+                                bDec = true;
+                            }
+                            else
+                                pNewRedl->SetEnd( *pRStt, pEnd );
+                        }
+                        break;
+
+                    case POS_INSIDE:
+                    case POS_EQUAL:
+                        delete pNewRedl, pNewRedl = 0;
+                        bCompress = true;
+                        break;
+
+                    case POS_OVERLAP_BEFORE:
+                    case POS_OVERLAP_BEHIND:
+                        if( pRedl->IsOwnRedline( *pNewRedl ) &&
+                            pRedl->CanCombine( *pNewRedl ))
+                        {
+                            // If that's the case we can merge it, meaning
+                            // the new one covers this well
+                            if( POS_OVERLAP_BEHIND == eCmpPos )
+                                pNewRedl->SetStart( *pRStt, pStt );
+                            else
+                                pNewRedl->SetEnd( *pREnd, pEnd );
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                        }
+                        else if( POS_OVERLAP_BEHIND == eCmpPos )
+                            pNewRedl->SetStart( *pREnd, pStt );
+                        else
+                            pNewRedl->SetEnd( *pRStt, pEnd );
+                        break;
+
+                    case POS_COLLIDE_START:
+                    case POS_COLLIDE_END:
+                        if( pRedl->IsOwnRedline( *pNewRedl ) &&
+                            pRedl->CanCombine( *pNewRedl ) )
+                        {
+                            if( IsHideChanges( meRedlineMode ))
+                            {
+                                // Before we can merge, we make it visible!
+                                // We insert temporarily so that pNew is
+                                // also dealt with when moving the indices.
+                                mpRedlineTbl->Insert( pNewRedl );
+                                pRedl->Show();
+                                mpRedlineTbl->Remove( pNewRedl );
+                                pRStt = pRedl->Start();
+                                pREnd = pRedl->End();
+                            }
+
+                            // If that's the case we can merge it, meaning
+                            // the new one covers this well
+                            if( POS_COLLIDE_START == eCmpPos )
+                                pNewRedl->SetStart( *pRStt, pStt );
+                            else
+                                pNewRedl->SetEnd( *pREnd, pEnd );
+
+                            // delete current (below), and restart process with
+                            // previous
+                            sal_uInt16 nToBeDeleted = n;
+                            bDec = true;
+
+                            if( *(pNewRedl->Start()) <= *pREnd )
+                            {
+                                // Whoooah, we just extended the new 'redline'
+                                // beyond previous redlines, so better start
+                                // again. Of course this is not supposed to
+                                // happen, and in an ideal world it doesn't,
+                                // but unfortunately this code is buggy and
+                                // totally rotten so it does happen and we
+                                // better fix it.
+                                n = 0;
+                                bDec = true;
+                            }
+
+                            mpRedlineTbl->DeleteAndDestroy( nToBeDeleted );
+                        }
+                        break;
+                    default:
+                        break;
+                    }
+                    break;
+
+                case nsRedlineType_t::REDLINE_INSERT:
+                {
+                    // b62341295: Do not throw away redlines
+                    // even if they are not allowed to be combined
+                    RedlineMode_t eOld = meRedlineMode;
+                    if( !( eOld & nsRedlineMode_t::REDLINE_DONTCOMBINE_REDLINES ) &&
+                        pRedl->IsOwnRedline( *pNewRedl ) )
+                    {
+
+              // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
+              // The ShowMode needs to be retained!
+              meRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
+                        switch( eCmpPos )
+                        {
+                        case POS_EQUAL:
+                            bCompress = true;
+                            mpRedlineTbl->DeleteAndDestroy( n );
+                            bDec = true;
+                            // no break!
+
+                        case POS_INSIDE:
+                            if( bCallDelete )
+                            {
+                              meRedlineMode = (RedlineMode_t)(meRedlineMode | nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES);
+
+                                // DeleteAndJoin does not yield the
+                                // desired result if there is no paragraph to

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list