sw/qa/extras/ww8export/data/redline-export-1.odt |binary
 sw/qa/extras/ww8export/ww8export.cxx             |   13 +++++
 sw/source/filter/ww8/attributeoutputbase.hxx     |    2 
 sw/source/filter/ww8/wrtw8nds.cxx                |   50 +++++++++++++++++------
 sw/source/filter/ww8/wrtww8.hxx                  |    2 
 sw/source/filter/ww8/ww8atr.cxx                  |    4 -
 sw/source/filter/ww8/ww8attributeoutput.hxx      |    2 
 7 files changed, 55 insertions(+), 18 deletions(-)

New commits:
commit 1e882a1dc49cc60aed7bae98b4924871ea1bf935
Author: Caolán McNamara <caol...@redhat.com>
Date:   Fri Sep 19 13:15:36 2014 +0100

    consider following redline as well
    
    a) In word each range that character properties affect are just stored by 
their
    end. So the range is from the last end to the current one.
    
    b) In word the paragraph end marker is a real character, in writer it is 
not.
    
    c) So for redlining if a paragraph is redlined, but the previous one is not
    then the redlining propes of the 2nd para will affect the end marker of the
    previous one if the previous char properties do not include the para end 
mark.
    
    We were currently handing the case where a paragraph end mark *is* inside
    redlining and including it in the char property range, but we were not
    considering the case where the paragraph end mark is *not* inside redlining
    but the following paragraph *is*
    
    to get the end of the previous paragraph not part of the following paragraph
    character run, we emit an empty char section of it for this case.
    
    Change-Id: I816335067f60d1d9332bfdb1117fb1448b564972

diff --git a/sw/qa/extras/ww8export/data/redline-export-1.odt 
b/sw/qa/extras/ww8export/data/redline-export-1.odt
new file mode 100644
index 0000000..31aacce
Binary files /dev/null and b/sw/qa/extras/ww8export/data/redline-export-1.odt 
differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx 
b/sw/qa/extras/ww8export/ww8export.cxx
index 61655ee..184815d 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -344,6 +344,19 @@ DECLARE_WW8EXPORT_TEST(testBorderColoursExport, 
"bordercolours.odt")
 #endif
 }
 
+DECLARE_WW8EXPORT_TEST(testRedlineExport1, "redline-export-1.odt")
+{
+    uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
+    uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xRunEnum = 
xRunEnumAccess->createEnumeration();
+    //there must be no redline information on the first line before or after 
reloading
+    while (xRunEnum->hasMoreElements())
+    {
+        uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), 
uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(false, hasProperty(xRun, "RedlineType"));
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx 
b/sw/source/filter/ww8/attributeoutputbase.hxx
index a823b5f..0a644c2 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -224,7 +224,7 @@ public:
     /// Output FKP (Formatted disK Page) - necessary for binary formats only.
     /// FIXME having it in AttributeOutputBase is probably a hack, it
     /// should be in WW8AttributeOutput only...
-    virtual void OutputFKP() {}
+    virtual void OutputFKP(bool /*bForce*/ = false) {}
 
     /// Output style.
     virtual void ParagraphStyle( sal_uInt16 nStyle ) = 0;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index fbd1d54..c17e3af 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1252,7 +1252,7 @@ int SwWW8AttrIter::OutAttrWithRange(sal_Int32 nPos)
     return nRet;
 }
 
-bool SwWW8AttrIter::IsRedlineAtEnd( sal_Int32 nEnd ) const
+bool SwWW8AttrIter::IncludeEndOfParaCRInRedlineProperties( sal_Int32 nEnd ) 
const
 {
     // search next Redline
     for( sal_uInt16 nPos = nCurRedlinePos;
@@ -1260,16 +1260,32 @@ bool SwWW8AttrIter::IsRedlineAtEnd( sal_Int32 nEnd ) 
const
     {
         const SwRangeRedline *pRange = 
m_rExport.pDoc->getIDocumentRedlineAccess().GetRedlineTbl()[nPos];
         const SwPosition* pEnd = pRange->End();
+        const SwPosition* pStart = pRange->Start();
+        // In word the paragraph end marker is a real character, in writer it 
is not.
+        // Here we find out if the para end marker we will emit is affected by
+        // redlining, in which case it must be included by the range of 
character
+        // attributes that contains the redlining information.
         if (pEnd->nNode == rNd)
         {
-            // In word the paragraph end marker is a real character, in writer 
it is not.
             if (pEnd->nContent.GetIndex() == nEnd)
             {
-                // This condition detects if the pseudo-char we will export is 
affected
-                // by redlining
+                // This condition detects if the pseudo-char we will export
+                // should be explicitly included by the redlining char
+                // properties on this node
                 return true;
             }
         }
+        else if (pStart->nNode.GetIndex()-1 == rNd.GetIndex())
+        {
+            if (pStart->nContent.GetIndex() == 0)
+            {
+                // This condition detects if the pseudo-char we will export
+                // should be implictly excluded by the redlining char
+                // properties starting on the next node.
+                return true;
+            }
+        }
+
         else
             break;
     }
@@ -2050,7 +2066,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& 
rNode )
 
     sal_Int32 nAktPos = 0;
     sal_Int32 const nEnd = aStr.getLength();
-    bool bRedlineAtEnd = false;
+    bool bIncludeEndOfParaCRInRedlineProperties = false;
     sal_Int32 nOpenAttrWithRange = 0;
     OUString aStringForImage("\001");
 
@@ -2236,8 +2252,8 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& 
rNode )
             OSL_ENSURE( nOpenAttrWithRange >= 0, "odd to see this happening, 
expected >= 0" );
             if ( !bTxtAtr && nOpenAttrWithRange <= 0 )
             {
-                if ( aAttrIter.IsRedlineAtEnd( nEnd ) )
-                    bRedlineAtEnd = true;
+                if ( aAttrIter.IncludeEndOfParaCRInRedlineProperties( nEnd ) )
+                    bIncludeEndOfParaCRInRedlineProperties = true;
                 else
                 {
                     // insert final graphic anchors if any before CR
@@ -2287,7 +2303,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& 
rNode )
 
             AttrOutput().OutputFKP();
 
-            if ( bTxtAtr || bAttrWithRange || bRedlineAtEnd )
+            if (bTxtAtr || bAttrWithRange || 
bIncludeEndOfParaCRInRedlineProperties)
             {
                 // insert final graphic anchors if any before CR
                 nStateOfFlyFrame = aAttrIter.OutFlys( nEnd );
@@ -2308,10 +2324,14 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& 
rNode )
                     AttrOutput().EndTOX( *pTOXSect );
                 }
 
-                if ( bRedlineAtEnd )
+                if (bIncludeEndOfParaCRInRedlineProperties)
                 {
                     AttrOutput().Redline( aAttrIter.GetRunLevelRedline( nEnd ) 
);
-                    AttrOutput().OutputFKP();
+                    //If if there was no redline property emitted, force adding
+                    //another entry for the CR so that in the case that this
+                    //has no redline, but the next para does, then this one is
+                    //not merged with the next
+                    AttrOutput().OutputFKP(true);
                 }
             }
         }
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 3d44e4c..8110165 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1536,7 +1536,7 @@ public:
     SwWW8AttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd );
 
     bool IsTxtAttr( sal_Int32 nSwPos );
-    bool IsRedlineAtEnd( sal_Int32 nPos ) const;
+    bool IncludeEndOfParaCRInRedlineProperties(sal_Int32 nPos) const;
     bool IsDropCap( int nSwPos );
     bool RequiresImplicitBookmark();
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 684e00e..ec257d5 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1063,9 +1063,9 @@ void WW8AttributeOutput::RawText( const OUString& rText, 
bool bForceUnicode, rtl
     m_rWW8Export.OutSwString( rText, 0, rText.getLength(), bForceUnicode, 
eCharSet );
 }
 
-void WW8AttributeOutput::OutputFKP()
+void WW8AttributeOutput::OutputFKP(bool bForce)
 {
-    if ( !m_rWW8Export.pO->empty() )
+    if (!m_rWW8Export.pO->empty() || bForce)
     {
         m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
                 m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx 
b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 8e8f392..5074c96 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -92,7 +92,7 @@ public:
     /// Output FKP (Formatted disK Page) - necessary for binary formats only.
     /// FIXME having it in AttributeOutputBase is probably a hack, it
     /// should be in WW8AttributeOutput only...
-    virtual void OutputFKP() SAL_OVERRIDE;
+    virtual void OutputFKP(bool bForce = false) SAL_OVERRIDE;
 
     /// Output style.
     virtual void ParagraphStyle( sal_uInt16 nStyle ) SAL_OVERRIDE;
commit b9b6e413f06d10b1a8dc5a25a45d7d8a26ff60ff
Author: Caolán McNamara <caol...@redhat.com>
Date:   Fri Sep 19 12:38:21 2014 +0100

    refactor IsRedlineAtEnd
    
    should be no logic change, just added a comment as to
    what is going on here and ready for extension
    
    Change-Id: Ibf1a3893ece9a09ad342bb06f39e119c1340e0db

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index e000918..fbd1d54 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1258,16 +1258,20 @@ bool SwWW8AttrIter::IsRedlineAtEnd( sal_Int32 nEnd ) 
const
     for( sal_uInt16 nPos = nCurRedlinePos;
         nPos < 
m_rExport.pDoc->getIDocumentRedlineAccess().GetRedlineTbl().size(); ++nPos )
     {
-        const SwPosition* pEnd = 
m_rExport.pDoc->getIDocumentRedlineAccess().GetRedlineTbl()[ nPos ]->End();
-        if( pEnd->nNode != rNd )
-        {
-            break;
-        }
-
-        if( pEnd->nContent.GetIndex() == nEnd )
+        const SwRangeRedline *pRange = 
m_rExport.pDoc->getIDocumentRedlineAccess().GetRedlineTbl()[nPos];
+        const SwPosition* pEnd = pRange->End();
+        if (pEnd->nNode == rNd)
         {
-            return true;
+            // In word the paragraph end marker is a real character, in writer 
it is not.
+            if (pEnd->nContent.GetIndex() == nEnd)
+            {
+                // This condition detects if the pseudo-char we will export is 
affected
+                // by redlining
+                return true;
+            }
         }
+        else
+            break;
     }
     return false;
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to