[Libreoffice-commits] .: sw/source

Noel Power noelp at kemper.freedesktop.org
Thu May 26 02:09:21 PDT 2011


 sw/source/filter/ww8/docxattributeoutput.cxx |   18 +++++++++++++-----
 sw/source/filter/ww8/docxattributeoutput.hxx |    9 ++++++++-
 2 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit fb75384566defd74b0769d09ac22eb6f460c20c9
Author: Noel Power <noel.power at novell.com>
Date:   Thu May 26 09:59:43 2011 +0100

    rework of fix for fdo#35826
    
    The problem stems from how and when we get notification ( via EndURL ) of the termination of the hyperlink. On investigation it seems that if we get EndURL before RunText then it's the previous text run that is enclosed in the hyperlink
    if we get endURL after Runtext then it's *this* run that needs to have a following hyperlink close.

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 238c388..9f1d40e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -514,6 +514,8 @@ void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
 
 void DocxAttributeOutput::EndRun()
 {
+    if ( m_nCloseHyperlinkStatus == Detected )
+        m_nCloseHyperlinkStatus = EndInThisRun;
     // Write field starts
     for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); ++pIt )
     {
@@ -547,6 +549,11 @@ void DocxAttributeOutput::EndRun()
         m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
         m_pHyperlinkAttrList = NULL;
     }
+    if ( m_nCloseHyperlinkStatus == EndInPrevRun)
+    {
+        m_pSerializer->endElementNS( XML_w, XML_hyperlink );
+        m_nCloseHyperlinkStatus = Undetected;
+    }
 
     // Write the hyperlink and toc fields starts
     for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); ++pIt )
@@ -580,11 +587,10 @@ void DocxAttributeOutput::EndRun()
         EndField_Impl( m_Fields.front( ) );
         m_Fields.erase( m_Fields.begin( ) );
     }
-
-    if ( m_bCloseHyperlink )
+    if ( m_nCloseHyperlinkStatus == EndInThisRun)
     {
         m_pSerializer->endElementNS( XML_w, XML_hyperlink );
-        m_bCloseHyperlink = false;
+        m_nCloseHyperlinkStatus = Undetected;
     }
 
     // if there is some redlining in the document, output it
@@ -1005,6 +1011,8 @@ static void impl_WriteRunText( FSHelperPtr pSerializer, sal_Int32 nTextToken,
 
 void DocxAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ )
 {
+    if ( m_nCloseHyperlinkStatus == Detected )
+        m_nCloseHyperlinkStatus = EndInPrevRun;
     OUString aText( rText );
 
     // one text can be split into more <w:t>blah</w:t>'s by line breaks etc.
@@ -1192,7 +1200,7 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
 
 bool DocxAttributeOutput::EndURL()
 {
-    m_bCloseHyperlink = true;
+    m_nCloseHyperlinkStatus = Detected;
     return true;
 }
 
@@ -4211,7 +4219,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
       m_bParagraphOpened( false ),
       m_nColBreakStatus( COLBRK_NONE ),
       m_pParentFrame( NULL ),
-      m_bCloseHyperlink( false )
+      m_nCloseHyperlinkStatus( Undetected )
 {
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 5554d1d..bf7c7d3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -581,7 +581,14 @@ private:
 
     const sw::Frame *m_pParentFrame;
     // close of hyperlink needed
-    bool m_bCloseHyperlink;
+    enum HyperLinkCloseState
+    {
+        Undetected = 0,
+        Detected,
+        EndInPrevRun,
+        EndInThisRun
+    };
+    HyperLinkCloseState m_nCloseHyperlinkStatus;
 
 public:
     DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );


More information about the Libreoffice-commits mailing list