From 46b6bad7db21f3743a26b328f23e5d66f8211bb8 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 31 Mar 2011 12:13:38 +0100 Subject: [PATCH] fix for fdo#35826, fix hyperlink export fixes the case where if the hyperlink is associated with a textrange ( in multiple runs ) the hyperlink element is associated only with the text ine the first run. --- sw/source/filter/ww8/docxattributeoutput.cxx | 19 +++++++++++-------- sw/source/filter/ww8/docxattributeoutput.hxx | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index bc60b3e21e74..3a559a05eadc 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -545,6 +545,7 @@ void DocxAttributeOutput::EndRun() XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList ); m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList ); + m_pHyperlinkAttrList = NULL; } // Write the hyperlink and toc fields starts @@ -574,18 +575,18 @@ void DocxAttributeOutput::EndRun() // append the actual run end m_pSerializer->endElementNS( XML_w, XML_r ); - if ( m_pHyperlinkAttrList ) - { - m_pSerializer->endElementNS( XML_w, XML_hyperlink ); - m_pHyperlinkAttrList = NULL; - } - while ( m_Fields.begin() != m_Fields.end() ) { EndField_Impl( m_Fields.front( ) ); m_Fields.erase( m_Fields.begin( ) ); } + if ( m_bCloseHyperlink ) + { + m_pSerializer->endElementNS( XML_w, XML_hyperlink ); + m_bCloseHyperlink = false; + } + // if there is some redlining in the document, output it EndRedline(); } @@ -1165,8 +1166,8 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget ) else { // Output a hyperlink XML element - m_pHyperlinkAttrList = m_pSerializer->createAttrList(); + if ( !bBookmarkOnly ) { OUString osUrl( sUrl ); @@ -1193,6 +1194,7 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget ) bool DocxAttributeOutput::EndURL() { + m_bCloseHyperlink = true; return true; } @@ -4129,7 +4131,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_nTableDepth( 0 ), m_bParagraphOpened( false ), m_nColBreakStatus( COLBRK_NONE ), - m_pParentFrame( NULL ) + m_pParentFrame( NULL ), + m_bCloseHyperlink( false ) { } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 8eee66c51ad6..c178e87c7847 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -578,6 +578,8 @@ private: DocxColBreakStatus m_nColBreakStatus; const sw::Frame *m_pParentFrame; + // close of hyperlink needed + bool m_bCloseHyperlink; public: DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML );