[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 08:27:59 UTC 2016


 include/xmloff/txtimp.hxx                       |    4 +-
 sw/source/filter/xml/XMLRedlineImportHelper.cxx |   44 ++++++++++++++++++++++++
 sw/source/filter/xml/XMLRedlineImportHelper.hxx |    3 +
 sw/source/filter/xml/xmltexti.cxx               |   13 ++++++-
 sw/source/filter/xml/xmltexti.hxx               |    3 +
 xmloff/source/text/txtimp.cxx                   |    8 +++-
 xmloff/source/text/txtparai.cxx                 |    5 ++
 xmloff/source/text/txtparai.hxx                 |    3 +
 8 files changed, 75 insertions(+), 8 deletions(-)

New commits:
commit a6bc6c2b7138b7de5dcd45944eb5321fbd16d53b
Author: Rosemary Sebastian <rosemary.seb8 at gmail.com>
Date:   Wed Jul 13 13:53:30 2016 +0530

    WIP Insert redline into document
    
    Change-Id: I98857e98503176c812b0fb70a41cb8e79637da78

diff --git a/include/xmloff/txtimp.hxx b/include/xmloff/txtimp.hxx
index 01045d0..01b3f0a 100644
--- a/include/xmloff/txtimp.hxx
+++ b/include/xmloff/txtimp.hxx
@@ -678,7 +678,9 @@ public:
 
     virtual bool CheckRedlineExists(
         /// ID used to RedlineAdd() call
-        const OUString& rId);
+        const OUString& rStartParaPos);
+
+    virtual void InsertRedlinesWithinParagraph(const OUString& rStartParaPos, bool bStart, bool bIsOutsideOfParagraph);
 
     virtual void RedlineSetCursor(
         /// ID used to RedlineAdd() call
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index 686d606..0767c50 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -503,6 +503,50 @@ bool XMLRedlineImportHelper::Check(
     return false;
 }
 
+void XMLRedlineImportHelper::InsertWithinParagraph(const OUString& rParaPos, bool bStart,
+    Reference<XTextRange> & rRange, bool bIsOutsideOfParagraph)
+{
+    ::std::map<OUString, RedlineInfo*>::iterator aFind = aRedlineMap[rParaPos].begin();
+    for( ; aRedlineMap[rParaPos].end() != aFind; ++aFind )
+    {
+        // RedlineInfo found; now set Cursor
+        RedlineInfo* pInfo = aFind->second;
+        if (bIsOutsideOfParagraph)
+        {
+            // outside of paragraph: remember SwNodeIndex
+            if (bStart)
+            {
+                pInfo->aAnchorStart.SetAsNodeIndex(rRange);
+            }
+            else
+            {
+                pInfo->aAnchorEnd.SetAsNodeIndex(rRange);
+            }
+
+            // also remember that we expect an adjustment for this redline
+            pInfo->bNeedsAdjustment = true;
+        }
+        else
+        {
+            // inside of a paragraph: use regular XTextRanges (bookmarks)
+            if (bStart)
+                pInfo->aAnchorStart.Set(rRange);
+            else
+                pInfo->aAnchorEnd.Set(rRange);
+        }
+
+        // if this Cursor was the last missing info, we insert the
+        // node into the document
+        // then we can remove the entry from the map and destroy the object
+        if (IsReady(pInfo))
+        {
+            InsertIntoDocument(pInfo);
+            delete pInfo;
+        }
+    }
+    aRedlineMap[rParaPos].clear();
+}
+
 void XMLRedlineImportHelper::SetCursor(
     const OUString& rParaPos,
     const OUString& rTextPos,
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.hxx b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
index af3f6c9..adb5695 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.hxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.hxx
@@ -86,6 +86,9 @@ public:
     bool Check(
         const OUString& rParaPos);
 
+    void InsertWithinParagraph(const OUString& rParaPos, bool bStart,
+        css::uno::Reference<css::text::XTextRange> & rRange, bool bIsOusideOfParagraph);
+
     // Set start or end position for a redline in the text body.
     // Accepts XTextRange objects.
     void SetCursor(
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index 1c4b2c4..05c1cb6 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -1001,14 +1001,23 @@ uno::Reference<XTextCursor> SwXMLTextImportHelper::RedlineCreateText(
 }
 
 bool SwXMLTextImportHelper::CheckRedlineExists(
-    const OUString& rId)
+    const OUString& rStartParaPos)
 {
     if(pRedlineHelper != nullptr)
-        return pRedlineHelper->Check(rId);
+        return pRedlineHelper->Check(rStartParaPos);
     return false;
     // else: ignore redline (wasn't added before, else we'd have a helper)
 }
 
+void SwXMLTextImportHelper::InsertRedlinesWithinParagraph(const OUString& rStartParaPos, bool bStart, bool bIsOutsideOfParagraph)
+{
+    if(pRedlineHelper != nullptr)
+    {
+        uno::Reference<XTextRange> xTextRange( GetCursor()->getStart() );
+        pRedlineHelper->InsertWithinParagraph(rStartParaPos, bStart, xTextRange, bIsOutsideOfParagraph);
+    }
+}
+
 void SwXMLTextImportHelper::RedlineSetCursor(
     const OUString& rParaPos,
     const OUString& rTextPos,
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
index 4b09805..79dae30 100644
--- a/sw/source/filter/xml/xmltexti.hxx
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -97,7 +97,8 @@ public:
             css::uno::Reference<css::text::XTextCursor> & rOldCursor, /// needed to get the document
             const OUString& rParPos, const OUString& rTextPos) override;    /// ID used to RedlineAdd() call
     virtual bool CheckRedlineExists(
-        const OUString& rId) override;         /// ID used to RedlineAdd() call
+        const OUString& rStartParaPos) override;         /// ID used to RedlineAdd() call
+    virtual void InsertRedlinesWithinParagraph(const OUString& rStartParaPos, bool bStart, bool bIsOutsideOfParagraph) override;
     virtual void RedlineSetCursor(
         const OUString& rStartParaPos,
         const OUString& rStartTextPos,
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index e97901d..1e7c58e 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -2161,7 +2161,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext(
         }
         pContext = new XMLParaContext( rImport,
                                        nPrefix, rLocalName,
-                                       xAttrList, bHeading, bInsertRedline );
+                                       xAttrList, bHeading, bInsertRedline, sParaIdx );
         if (m_xImpl->m_bProgress && XML_TEXT_TYPE_SHAPE != eType)
         {
             rImport.GetProgressBarHelper()->Increment();
@@ -2758,11 +2758,15 @@ Reference<XTextCursor> XMLTextImportHelper::RedlineCreateText(
 }
 
 bool XMLTextImportHelper::CheckRedlineExists(
-    const OUString& /*rId*/)
+    const OUString& /*rStartParaPos*/)
 {
     return true;
 }
 
+void XMLTextImportHelper::InsertRedlinesWithinParagraph(const OUString& /*rStartParaPos*/, bool /*bStart*/, bool /*bIsOutsideOfParagraph*/)
+{
+}
+
 void XMLTextImportHelper::RedlineSetCursor(
     const OUString& /*rParaPos*/,
     const OUString& /*rTextPos*/,
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 86c5736..f3c3c58 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -1820,7 +1820,8 @@ XMLParaContext::XMLParaContext(
         const OUString& rLName,
         const Reference< xml::sax::XAttributeList > & xAttrList,
         bool bHead,
-        bool bInsertRedln) :
+        bool bInsertRedln,
+        const OUString& rStartParaPos) :
     SvXMLImportContext( rImport, nPrfx, rLName ),
     xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
     m_bHaveAbout(false),
@@ -1831,6 +1832,7 @@ XMLParaContext::XMLParaContext(
     bIgnoreLeadingSpace( true ),
     bHeading( bHead ),
     bInsertRedline( bInsertRedln ),
+    sStartParaPos(rStartParaPos),
     bIsListHeader( false ),
     bIsRestart (false),
     nStartValue(0),
@@ -2232,6 +2234,7 @@ void XMLParaContext::Characters( const OUString& rChars )
     if(bInsertRedline)
     {
         GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
+        GetImport().GetTextImport()->InsertRedlinesWithinParagraph(sStartParaPos, true, false);
     }
     else
         GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx
index 8124806..e6fd5dc 100644
--- a/xmloff/source/text/txtparai.hxx
+++ b/xmloff/source/text/txtparai.hxx
@@ -50,6 +50,7 @@ class XMLParaContext : public SvXMLImportContext
     bool                 bIgnoreLeadingSpace;
     bool                 bHeading;
     bool                 bInsertRedline;
+    OUString             sStartParaPos;
     bool                 bIsListHeader;
     bool                 bIsRestart;
     sal_Int16            nStartValue;
@@ -63,7 +64,7 @@ public:
             const OUString& rLName,
             const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
             bool bHeading,
-            bool bInsertRedln = false );
+            bool bInsertRedln = false, const OUString& rStartParaPos = OUString() );
 
     virtual ~XMLParaContext();
 


More information about the Libreoffice-commits mailing list