[Libreoffice-commits] core.git: Branch 'private/Rosemary/change-tracking' - include/xmloff sw/source xmloff/source

Rosemary Sebastian rosemary.seb8 at gmail.com
Wed Jul 13 01:35:09 UTC 2016


 include/xmloff/XMLTrackedChangesImportContext.hxx     |   15 +++--
 include/xmloff/txtimp.hxx                             |   23 +++++---
 sw/source/filter/xml/XMLRedlineImportHelper.cxx       |   48 +++++++++---------
 sw/source/filter/xml/XMLRedlineImportHelper.hxx       |   18 +++---
 sw/source/filter/xml/xmltexti.cxx                     |   26 +++++----
 sw/source/filter/xml/xmltexti.hxx                     |    9 +--
 xmloff/source/text/XMLChangeElementImportContext.cxx  |    2 
 xmloff/source/text/XMLChangeImportContext.cxx         |    4 -
 xmloff/source/text/XMLTrackedChangesImportContext.cxx |   42 +++++++++------
 xmloff/source/text/txtimp.cxx                         |   43 +++++++++++-----
 xmloff/source/text/txtparai.cxx                       |    7 ++
 11 files changed, 142 insertions(+), 95 deletions(-)

New commits:
commit 45675aed3b9c121266d78e37bccc00dbfbcda09b
Author: Rosemary Sebastian <rosemary.seb8 at gmail.com>
Date:   Wed Jul 13 06:28:30 2016 +0530

    Access aRedlineMap when parsing content.xml
    
    - Moved aRedlineMap to global scope.
    - Made it two-dimensional with the first index indicating the paragraph
      index and the second indicating the text position within the paragraph.
    
    Change-Id: I1c21040e258344c2c42e880fd30dc0efc3689815

diff --git a/include/xmloff/XMLTrackedChangesImportContext.hxx b/include/xmloff/XMLTrackedChangesImportContext.hxx
index f19052a..5737e95 100644
--- a/include/xmloff/XMLTrackedChangesImportContext.hxx
+++ b/include/xmloff/XMLTrackedChangesImportContext.hxx
@@ -57,13 +57,15 @@ public:
     /// redline date
     OUString sDate;
 
-    /// redline date
-    OUString sStart;
+    /// redline start
+    OUString sStartParaPos;
+    OUString sStartTextPos;
 
-    /// redline date
-    OUString sEnd;
+    /// redline end
+    OUString sEndParaPos;
+    OUString sEndTextPos;
 
-    /// redline date
+    /// redline type
     OUString sType;
 
     /// merge-last-paragraph flag
@@ -89,7 +91,8 @@ public:
                        const OUString& rAuthor,
                        const OUString& rComment,
                        const OUString& rDate,
-                       const sal_uInt32);
+                       const OUString& rStartParaPos,
+                       const OUString& rStartTextPos);
 
     /// create redline XText/XTextCursor on demand and register with
     /// XMLTextImportHelper
diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx
index 12825dd..01045d0 100644
--- a/include/xmloff/txtimp.hxx
+++ b/include/xmloff/txtimp.hxx
@@ -390,7 +390,6 @@ private:
     static std::shared_ptr<BackpatcherImpl> MakeBackpatcherImpl();
 
     sal_Int16            nParaIdx = 0;
-    bool                 bInsertRedline = false;
 protected:
     virtual SvXMLImportContext *CreateTableChildContext(
                 SvXMLImport& rImport,
@@ -658,8 +657,6 @@ public:
     virtual void RedlineAdd(
             /// redline type (insert, del,... )
             const OUString& rType,
-            /// use to identify this redline
-            const OUString& rId,
             /// name of the author
             const OUString& rAuthor,
             /// redline comment
@@ -668,13 +665,16 @@ public:
             const css::util::DateTime& rDateTime,
             /// merge last paras
             bool bMergeLastParagraph,
-            const sal_uInt32 nStartParaPos);
+            /// start position
+            const OUString& rStartParaPos,
+            const OUString& rStartTextPos);
 
     virtual css::uno::Reference< css::text::XTextCursor> RedlineCreateText(
             /// needed to get the document
             css::uno::Reference< css::text::XTextCursor > & rOldCursor,
             /// ID used to RedlineAdd() call
-            const OUString& rId);
+            const OUString& rParaPos,
+            const OUString& rTextPos);
 
     virtual bool CheckRedlineExists(
         /// ID used to RedlineAdd() call
@@ -682,7 +682,8 @@ public:
 
     virtual void RedlineSetCursor(
         /// ID used to RedlineAdd() call
-        const OUString& rId,
+        const OUString& rParaPos,
+        const OUString& rTextPos,
         /// start or end Cursor
         bool bStart,
         /// range is not within <text:p>
@@ -695,11 +696,15 @@ public:
         const css::uno::Sequence<sal_Int8> & rProtectionKey );
 
     /// get the last open redline ID
-    OUString GetOpenRedlineId();
+    OUString GetOpenRedlineParaPos();
+    /// get the last open redline ID
+    OUString GetOpenRedlineTextPos();
+    /// modify the last open redline ID
+    void SetOpenRedlineParaPos( OUString const & rParaPos);
     /// modify the last open redline ID
-    void SetOpenRedlineId( OUString const & rId);
+    void SetOpenRedlineTextPos( OUString const & rTextPos);
     /// reset the last open redline ID
-    void ResetOpenRedlineId();
+    void ResetOpenRedlinePositions();
 
     /** redlining : Setter to remember the fact we are inside/outside
      * a <text:deletion> element (deleted redline section) */
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index 7a8d992..686d606 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -45,6 +45,9 @@ using ::com::sun::star::beans::XPropertySetInfo;
 // collision with tools/DateTime: use UNO DateTime as util::DateTime
 // using util::DateTime;
 
+typedef ::std::map< OUString, RedlineInfo* > RedlineMapType;
+::std::map< OUString, ::std::map< OUString, RedlineInfo* > > aRedlineMap;
+
 // a few helper functions
 static SwDoc* lcl_GetDocViaTunnel( Reference<XTextCursor> & rCursor )
 {
@@ -67,6 +70,7 @@ static SwDoc* lcl_GetDocViaTunnel( Reference<XTextRange> & rRange )
     return (pXRange) ? &pXRange->GetDoc() : nullptr;
 }
 
+
 // XTextRangeOrNodeIndexPosition: store a position into the text
 // *either* as an XTextRange or as an SwNodeIndex. The reason is that
 // we must store either pointers to StartNodes (because redlines may
@@ -246,7 +250,6 @@ XMLRedlineImportHelper::XMLRedlineImportHelper(
         sInsertion( GetXMLToken( XML_INSERTION )),
         sDeletion( GetXMLToken( XML_DELETION )),
         sFormatChange( GetXMLToken( XML_FORMAT_CHANGE )),
-        aRedlineMap(),
         bIgnoreRedlines(bNoRedlinesPlease),
         xModelPropertySet(rModel),
         xImportInfoPropertySet(rImportInfo)
@@ -287,7 +290,7 @@ XMLRedlineImportHelper::XMLRedlineImportHelper(
 }
 
 XMLRedlineImportHelper::~XMLRedlineImportHelper()
-{
+{/*
     // delete all left over (and obviously incomplete) RedlineInfos (and map)
     RedlineMapType::iterator aFind = aRedlineMap.begin();
     for( ; aRedlineMap.end() != aFind; ++aFind )
@@ -322,7 +325,7 @@ XMLRedlineImportHelper::~XMLRedlineImportHelper()
         }
         delete pInfo;
     }
-    aRedlineMap.clear();
+    aRedlineMap.clear();*/
 
     // set redline mode, either to info property set, or directly to
     // the document
@@ -370,12 +373,12 @@ XMLRedlineImportHelper::~XMLRedlineImportHelper()
 
 void XMLRedlineImportHelper::Add(
     const OUString& rType,
-    const OUString& rId,
     const OUString& rAuthor,
     const OUString& rComment,
     const util::DateTime& rDateTime,
     bool bMergeLastPara,
-    const sal_uInt32 nStartParaPos)
+    const OUString& rStartParaPos,
+    const OUString& rStartTextPos)
 {
     // we need to do the following:
     // 1) parse type string
@@ -413,13 +416,12 @@ void XMLRedlineImportHelper::Add(
     pInfo->sComment = rComment;
     pInfo->aDateTime = rDateTime;
     pInfo->bMergeLastParagraph = bMergeLastPara;
-    pInfo->nStartParagraphPos = nStartParaPos;
 
     // ad 3)
-    if (aRedlineMap.end() == aRedlineMap.find(rId))
+    if (aRedlineMap.end() == aRedlineMap.find(rStartParaPos) || aRedlineMap[rStartParaPos].end() == aRedlineMap[rStartParaPos].find(rStartTextPos))
     {
         // 3a) insert into map
-        aRedlineMap[rId] = pInfo;
+        aRedlineMap[rStartParaPos][rStartTextPos] = pInfo;
     }
     else
     {
@@ -429,7 +431,7 @@ void XMLRedlineImportHelper::Add(
 
         // find last element
         RedlineInfo* pInfoChain;
-        for( pInfoChain = aRedlineMap[rId];
+        for( pInfoChain = aRedlineMap[rStartParaPos][rStartTextPos];
             nullptr != pInfoChain->pNextRedline;
             pInfoChain = pInfoChain->pNextRedline) ; // empty loop
 
@@ -440,7 +442,7 @@ void XMLRedlineImportHelper::Add(
 
 Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection(
     Reference<XTextCursor> xOldCursor,
-    const OUString& rId)
+    const OUString& rParaPos, const OUString& rTextPos)
 {
     Reference<XTextCursor> xReturn;
 
@@ -448,8 +450,8 @@ Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection(
     SolarMutexGuard aGuard;
 
     // get RedlineInfo
-    RedlineMapType::iterator aFind = aRedlineMap.find(rId);
-    if (aRedlineMap.end() != aFind)
+    RedlineMapType::iterator aFind = aRedlineMap[rParaPos].find(rTextPos);
+    if (aRedlineMap[rParaPos].end() != aFind)
     {
         // get document from old cursor (via tunnel)
         SwDoc* pDoc = lcl_GetDocViaTunnel(xOldCursor);
@@ -491,9 +493,9 @@ Reference<XTextCursor> XMLRedlineImportHelper::CreateRedlineTextSection(
 }
 
 bool XMLRedlineImportHelper::Check(
-    const OUString& rId)
+    const OUString& rParaPos)
 {
-    RedlineMapType::iterator aFind = aRedlineMap.find(rId);
+    ::std::map<OUString, ::std::map<OUString, RedlineInfo*>>::iterator aFind = aRedlineMap.find(rParaPos);
     if (aRedlineMap.end() != aFind)
     {
         return true;
@@ -502,13 +504,14 @@ bool XMLRedlineImportHelper::Check(
 }
 
 void XMLRedlineImportHelper::SetCursor(
-    const OUString& rId,
+    const OUString& rParaPos,
+    const OUString& rTextPos,
     bool bStart,
     Reference<XTextRange> & rRange,
     bool bIsOutsideOfParagraph)
 {
-    RedlineMapType::iterator aFind = aRedlineMap.find(rId);
-    if (aRedlineMap.end() != aFind)
+    RedlineMapType::iterator aFind = aRedlineMap[rParaPos].find(rTextPos);
+    if (aRedlineMap[rParaPos].end() != aFind)
     {
         // RedlineInfo found; now set Cursor
         RedlineInfo* pInfo = aFind->second;
@@ -542,7 +545,7 @@ void XMLRedlineImportHelper::SetCursor(
         if (IsReady(pInfo))
         {
             InsertIntoDocument(pInfo);
-            aRedlineMap.erase(rId);
+            aRedlineMap[rParaPos].erase(rTextPos);
             delete pInfo;
         }
     }
@@ -550,7 +553,8 @@ void XMLRedlineImportHelper::SetCursor(
 }
 
 void XMLRedlineImportHelper::AdjustStartNodeCursor(
-    const OUString& rId,        /// ID used in RedlineAdd() call
+    const OUString& rStartParaPos,
+    const OUString& rStartTextPos,
     bool /*bStart*/,
     Reference<XTextRange> & /*rRange*/)
 {
@@ -560,8 +564,8 @@ void XMLRedlineImportHelper::AdjustStartNodeCursor(
     // start + end nodes are treated the same. For either it's
     // necessary that the target node already exists.
 
-    RedlineMapType::iterator aFind = aRedlineMap.find(rId);
-    if (aRedlineMap.end() != aFind)
+    RedlineMapType::iterator aFind = aRedlineMap[rStartParaPos].find(rStartTextPos);
+    if (aRedlineMap[rStartParaPos].end() != aFind)
     {
         // RedlineInfo found; now set Cursor
         RedlineInfo* pInfo = aFind->second;
@@ -572,7 +576,7 @@ void XMLRedlineImportHelper::AdjustStartNodeCursor(
         if( IsReady(pInfo) )
         {
             InsertIntoDocument(pInfo);
-            aRedlineMap.erase(rId);
+            aRedlineMap[rStartParaPos].erase(rStartTextPos);
             delete pInfo;
         }
     }
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.hxx b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
index 240c36c..af3f6c9 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.hxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
@@ -36,15 +36,12 @@ namespace com { namespace sun { namespace star {
     namespace frame { class XModel; }
 } } }
 
-typedef ::std::map< OUString, RedlineInfo* > RedlineMapType;
-
 class XMLRedlineImportHelper
 {
     const OUString sInsertion;
     const OUString sDeletion;
     const OUString sFormatChange;
 
-    RedlineMapType aRedlineMap;
 
     // if true, no redlines should be inserted into document
     // (This typically happen when a document is loaded in 'insert'-mode.)
@@ -72,26 +69,28 @@ public:
     //  and end cursor has been set.)
     void Add(
         const OUString& rType,       // redline type (insert, del,... )
-        const OUString& rId,         // use to identify this redline
         const OUString& rAuthor,     // name of the author
         const OUString& rComment,    // redline comment
         const css::util::DateTime& rDateTime, // date+time
         bool bMergeLastParagraph,      // merge last paragraph?
-        const sal_uInt32 nStartParaPos); // start paragraph position
+        const OUString& rStartParaPos, // start paragraph position
+        const OUString& rStartTextPos);
 
     // create a text section for the redline, and return an
     // XText/XTextCursor that may be used to write into it.
     css::uno::Reference<css::text::XTextCursor> CreateRedlineTextSection(
             css::uno::Reference<css::text::XTextCursor> xOldCursor, // needed to get the document
-            const OUString& rId);    // ID used to RedlineAdd() call
+            const OUString& rParaPos,
+            const OUString& rTextPos);
 
     bool Check(
-        const OUString& rId);     // ID used in RedlineAdd() call
+        const OUString& rParaPos);
 
     // Set start or end position for a redline in the text body.
     // Accepts XTextRange objects.
     void SetCursor(
-        const OUString& rId,     // ID used in RedlineAdd() call
+        const OUString& rParaPos,
+        const OUString& rTextPos,
         bool bStart,                // start or end Range
         css::uno::Reference<css::text::XTextRange> & rRange, // the actual XTextRange
         // text range is (from an XML view) outside of a paragraph
@@ -107,7 +106,8 @@ public:
      * only be considered valid if it points to the next text node
      * after the position given in a previous SetCursor */
     void AdjustStartNodeCursor(
-         const OUString& rId,        // ID used in RedlineAdd() call
+         const OUString& rStartParaPos,
+         const OUString& rStartTextPos,
         bool bStart,
         // XTextRange _inside_ a table/section
         css::uno::Reference<css::text::XTextRange> & rRange);
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index d103310..1c4b2c4 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -972,29 +972,29 @@ void SwXMLTextImportHelper::endAppletOrPlugin(
 // (override to provide the real implementation)
 void SwXMLTextImportHelper::RedlineAdd(
     const OUString& rType,
-    const OUString& rId,
     const OUString& rAuthor,
     const OUString& rComment,
     const util::DateTime& rDateTime,
     bool bMergeLastPara,
-    const sal_uInt32 nStartParaPos)
+    const OUString& rStartParaPos,
+    const OUString& rStartTextPos)
 {
     // create redline helper on demand
     OSL_ENSURE(nullptr != pRedlineHelper, "helper should have been created in constructor");
     if (nullptr != pRedlineHelper)
-        pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime,
-                            bMergeLastPara, nStartParaPos);
+        pRedlineHelper->Add(rType, rAuthor, rComment, rDateTime,
+                            bMergeLastPara, rStartParaPos, rStartTextPos);
 }
 
 uno::Reference<XTextCursor> SwXMLTextImportHelper::RedlineCreateText(
     uno::Reference<XTextCursor> & rOldCursor,
-    const OUString& rId)
+    const OUString& rParaPos, const OUString& rTextPos)
 {
     uno::Reference<XTextCursor> xRet;
 
     if (nullptr != pRedlineHelper)
     {
-        xRet = pRedlineHelper->CreateRedlineTextSection(rOldCursor, rId);
+        xRet = pRedlineHelper->CreateRedlineTextSection(rOldCursor, rParaPos, rTextPos);
     }
 
     return xRet;
@@ -1010,13 +1010,14 @@ bool SwXMLTextImportHelper::CheckRedlineExists(
 }
 
 void SwXMLTextImportHelper::RedlineSetCursor(
-    const OUString& rId,
+    const OUString& rParaPos,
+    const OUString& rTextPos,
     bool bStart,
     bool bIsOutsideOfParagraph)
 {
     if (nullptr != pRedlineHelper) {
         uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
-        pRedlineHelper->SetCursor(rId, bStart, xTextRange,
+        pRedlineHelper->SetCursor(rParaPos, rTextPos, bStart, xTextRange,
                                   bIsOutsideOfParagraph);
     }
     // else: ignore redline (wasn't added before, else we'd have a helper)
@@ -1025,12 +1026,13 @@ void SwXMLTextImportHelper::RedlineSetCursor(
 void SwXMLTextImportHelper::RedlineAdjustStartNodeCursor(
     bool bStart)
 {
-    OUString rId = GetOpenRedlineId();
-    if ((nullptr != pRedlineHelper) && !rId.isEmpty())
+    OUString rParaPos = GetOpenRedlineParaPos();
+    OUString rTextPos = GetOpenRedlineTextPos();
+    if ((nullptr != pRedlineHelper) && !rParaPos.isEmpty() && !rTextPos.isEmpty())
     {
         uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
-        pRedlineHelper->AdjustStartNodeCursor(rId, bStart, xTextRange );
-        ResetOpenRedlineId();
+        pRedlineHelper->AdjustStartNodeCursor(rParaPos, rTextPos, bStart, xTextRange );
+        ResetOpenRedlinePositions();
     }
     // else: ignore redline (wasn't added before, or no open redline ID
 }
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
index 57d334f..4b09805 100644
--- a/sw/source/filter/xml/xmltexti.hxx
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -87,19 +87,20 @@ public:
     // (here is the real implementation)
     virtual void RedlineAdd(
         const OUString& rType,       /// redline type (insert, del,... )
-        const OUString& rId,         /// use to identify this redline
         const OUString& rAuthor,     /// name of the author
         const OUString& rComment,    /// redline comment
         const css::util::DateTime& rDateTime,  /// date+time
         bool bMergeLastPara,           /// merge last paragraph
-        const sal_uInt32 nStartParaPos) override;
+        const OUString& rStartParaPos,
+        const OUString& rStartTextPos) override;
     virtual css::uno::Reference<css::text::XTextCursor> RedlineCreateText(
             css::uno::Reference<css::text::XTextCursor> & rOldCursor, /// needed to get the document
-            const OUString& rId) override;    /// ID used to RedlineAdd() call
+            const OUString& rParPos, const OUString& rTextPos) override;    /// ID used to RedlineAdd() call
     virtual bool CheckRedlineExists(
         const OUString& rId) override;         /// ID used to RedlineAdd() call
     virtual void RedlineSetCursor(
-        const OUString& rId,         /// ID used to RedlineAdd() call
+        const OUString& rStartParaPos,
+        const OUString& rStartTextPos,
         bool bStart,                    /// start or end Cursor
         bool bIsOutsideOfParagraph) override;
     virtual void RedlineAdjustStartNodeCursor( bool bStart) override;
diff --git a/xmloff/source/text/XMLChangeElementImportContext.cxx b/xmloff/source/text/XMLChangeElementImportContext.cxx
index fad9712..e81bcff 100644
--- a/xmloff/source/text/XMLChangeElementImportContext.cxx
+++ b/xmloff/source/text/XMLChangeElementImportContext.cxx
@@ -70,7 +70,7 @@ SvXMLImportContext* XMLChangeElementImportContext::CreateChildContext(
     return pContext;
 }
 
-void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& xAttrList )
+void XMLChangeElementImportContext::StartElement( const Reference< XAttributeList >& )
 {
     if(bAcceptContent)
     {
diff --git a/xmloff/source/text/XMLChangeImportContext.cxx b/xmloff/source/text/XMLChangeImportContext.cxx
index f8b863a..f563b31 100644
--- a/xmloff/source/text/XMLChangeImportContext.cxx
+++ b/xmloff/source/text/XMLChangeImportContext.cxx
@@ -68,7 +68,7 @@ void XMLChangeImportContext::StartElement(
             rtl::Reference<XMLTextImportHelper> rHelper =
                 GetImport().GetTextImport();
             OUString sID = xAttrList->getValueByIndex(nAttr);
-
+/*
             // call for bStart and bEnd (may both be true)
             if (bIsStart)
                 rHelper->RedlineSetCursor(sID, true, bIsOutsideOfParagraph);
@@ -79,7 +79,7 @@ void XMLChangeImportContext::StartElement(
             if (bIsOutsideOfParagraph)
             {
                 rHelper->SetOpenRedlineId(sID);
-            }
+            }*/
         }
         // else: ignore
     }
diff --git a/xmloff/source/text/XMLTrackedChangesImportContext.cxx b/xmloff/source/text/XMLTrackedChangesImportContext.cxx
index ffe4659..ccd3f7b 100644
--- a/xmloff/source/text/XMLTrackedChangesImportContext.cxx
+++ b/xmloff/source/text/XMLTrackedChangesImportContext.cxx
@@ -101,7 +101,7 @@ SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
     const Reference<XAttributeList> & xAttrList)
 {
     SvXMLImportContext* pContext = nullptr;
-    sal_uInt32 nStartParaPos, nEndParaPos, nStartTextPos, nEndTextPos;
+    OUString sStart, sEnd;
 
     if (XML_NAMESPACE_TEXT == nPrefix)
     {
@@ -116,7 +116,7 @@ SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
             for( sal_Int16 i = 0; i < nLength; i++ )
             {
                 OUString sLocalName;
-                sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
+                nPrefix = GetImport().GetNamespaceMap().
                     GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
                 const OUString sValue = xAttrList->getValueByIndex(i);
                 if (XML_NAMESPACE_C == nPrefix)
@@ -124,10 +124,28 @@ SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
                     if (IsXMLToken(sLocalName, xmloff::token::XML_START))
                     {
                         sStart = sValue.pData->buffer + 1;
+                        if(sStart.indexOf('/') != -1)
+                        {
+                            sStartParaPos = OUString( sStart.getStr(), sStart.indexOf('/') );
+                            sStartTextPos = sStart.pData->buffer + sStart.indexOf('/') + 1;
+                        }
+                        else
+                        {
+                            sStartParaPos = sStart;
+                        }
                     }
                     if (IsXMLToken(sLocalName, XML_END))
                     {
-                        sEnd = sValue;
+                        sEnd = sValue.pData->buffer + 1;
+                        if(sEnd.indexOf('/') != -1)
+                        {
+                            sEndParaPos = OUString(sEnd.getStr(), sEnd.indexOf('/'));
+                            sEndTextPos = sEnd.pData->buffer + sEnd.indexOf('/') + 1;
+                        }
+                        else
+                        {
+                            sEndParaPos = sEnd;
+                        }
                     }
                 }
                 if (XML_NAMESPACE_DC == nPrefix)
@@ -138,17 +156,7 @@ SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
                     }
                 }
             }
-            if(sStart.indexOf('/') != -1)
-            {
-                sID = OUString(sStart.getStr(), sStart.indexOf('/'));
-                nStartParaPos = sID.toUInt32();
-            }
-            else
-            {
-                nStartParaPos = sStart.toUInt32();
-                sID = sStart;
-            }
-            SetChangeInfo( rLocalName, sAuthor, sComment, sDate, nStartParaPos );
+            SetChangeInfo( rLocalName, sAuthor, sComment, sDate, sStartParaPos, sStartTextPos );
 
             // create XMLChangeElementImportContext for all kinds of changes
             pContext = new XMLChangeElementImportContext(
@@ -178,13 +186,13 @@ SvXMLImportContext* XMLTrackedChangesImportContext::CreateChildContext(
     return pContext;
 }
 
-void XMLTrackedChangesImportContext::SetChangeInfo(const OUString& rType, const OUString& rAuthor, const OUString& rComment, const OUString& rDate, const sal_uInt32 nStartParaPos)
+void XMLTrackedChangesImportContext::SetChangeInfo(const OUString& rType, const OUString& rAuthor, const OUString& rComment, const OUString& rDate, const OUString& rStartParaPos, const OUString& rStartTextPos)
 {
     util::DateTime aDateTime;
     if (::sax::Converter::parseDateTime(aDateTime, nullptr, rDate))
     {
         GetImport().GetTextImport()->RedlineAdd(
-            rType, sID, rAuthor, rComment, aDateTime, bMergeLastPara, nStartParaPos);
+            rType, rAuthor, rComment, aDateTime, bMergeLastPara, rStartParaPos, rStartTextPos);
     }
 }
 
@@ -199,7 +207,7 @@ void XMLTrackedChangesImportContext::UseRedlineText()
 
         // create Redline and new Cursor
         Reference<XTextCursor> xNewCursor =
-            rHelper->RedlineCreateText(xCursor, sID);
+            rHelper->RedlineCreateText(xCursor, sStartParaPos, sStartTextPos);
 
         if (xNewCursor.is())
         {
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 11fed00..e97901d 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -536,7 +536,8 @@ struct XMLTextImportHelper::Impl
     BookmarkVector_t m_BookmarkVector;
 
     /// name of the last 'open' redline that started between paragraphs
-    OUString m_sOpenRedlineIdentifier;
+    OUString m_sOpenRedlineParaPos;
+    OUString m_sOpenRedlineTextPos;
 
     uno::Reference<text::XText> m_xText;
     uno::Reference<text::XTextCursor> m_xCursor;
@@ -2144,6 +2145,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
 
     const SvXMLTokenMap& rTokenMap = GetTextElemTokenMap();
     bool bHeading = false;
+    bool bInsertRedline = false;
     bool bContent = true;
     sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
     OUString sParaIdx;
@@ -2153,6 +2155,10 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
         bHeading = true;
     case XML_TOK_TEXT_P:
         sParaIdx = OUString::number(++nParaIdx);
+        if( rImport.GetTextImport()->CheckRedlineExists(sParaIdx) )
+        {
+            bInsertRedline = true;
+        }
         pContext = new XMLParaContext( rImport,
                                        nPrefix, rLocalName,
                                        xAttrList, bHeading, bInsertRedline );
@@ -2730,19 +2736,20 @@ void XMLTextImportHelper::endAppletOrPlugin(
 }
 // redline helper: dummy implementation to be overridden in sw/filter/xml
 void XMLTextImportHelper::RedlineAdd( const OUString& /*rType*/,
-                                      const OUString& /*rId*/,
                                       const OUString& /*rAuthor*/,
                                       const OUString& /*rComment*/,
                                       const util::DateTime& /*rDateTime*/,
                                       bool /*bMergeLastPara*/,
-                                      const sal_uInt32 /*nStartParaPos*/)
+                                      const OUString& /*rStartParaPos*/,
+                                      const OUString& /*rStartTextPos*/)
 {
     // dummy implementation: do nothing
 }
 
 Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
     Reference<XTextCursor> & /*rOldCursor*/,
-    const OUString& /*rId*/)
+    const OUString& /*rParaPos*/,
+    const OUString& /*rTextPos*/)
 
 {
     // dummy implementation: do nothing
@@ -2751,13 +2758,14 @@ Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
 }
 
 bool XMLTextImportHelper::CheckRedlineExists(
-    const OUString& rId)
+    const OUString& /*rId*/)
 {
     return true;
 }
 
 void XMLTextImportHelper::RedlineSetCursor(
-    const OUString& /*rId*/,
+    const OUString& /*rParaPos*/,
+    const OUString& /*rTextPos*/,
     bool /*bStart*/,
     bool /*bIsOutsideOfParagraph*/)
 {
@@ -2784,19 +2792,30 @@ void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
 }
 
 
-OUString XMLTextImportHelper::GetOpenRedlineId()
+OUString XMLTextImportHelper::GetOpenRedlineParaPos()
+{
+    return m_xImpl->m_sOpenRedlineParaPos;
+}
+
+OUString XMLTextImportHelper::GetOpenRedlineTextPos()
+{
+    return m_xImpl->m_sOpenRedlineTextPos;
+}
+
+void XMLTextImportHelper::SetOpenRedlineParaPos( OUString const & rParaPos)
 {
-    return m_xImpl->m_sOpenRedlineIdentifier;
+    m_xImpl->m_sOpenRedlineParaPos = rParaPos;
 }
 
-void XMLTextImportHelper::SetOpenRedlineId( OUString const & rId)
+void XMLTextImportHelper::SetOpenRedlineTextPos( OUString const & rTextPos)
 {
-    m_xImpl->m_sOpenRedlineIdentifier = rId;
+    m_xImpl->m_sOpenRedlineTextPos = rTextPos;
 }
 
-void XMLTextImportHelper::ResetOpenRedlineId()
+void XMLTextImportHelper::ResetOpenRedlinePositions()
 {
-    SetOpenRedlineId("");
+    SetOpenRedlineParaPos("");
+    SetOpenRedlineTextPos("");
 }
 
 void
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index cb3b7b1..86c5736 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -2229,7 +2229,12 @@ void XMLParaContext::Characters( const OUString& rChars )
         GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
                                                        nStarFontsConvFlags,
                                                        true, GetImport() );
-    GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
+    if(bInsertRedline)
+    {
+        GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
+    }
+    else
+        GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
 }
 
 


More information about the Libreoffice-commits mailing list