sw/source/filter/ww8/docxattributeoutput.cxx | 28 ++++++++++++++------------- sw/source/filter/ww8/docxattributeoutput.hxx | 10 +-------- 2 files changed, 17 insertions(+), 21 deletions(-)
New commits: commit 5cd2ae45c3da7b018b45ce00153f7ca4791a5d11 Author: LuboÅ¡ LuÅák <l.lu...@suse.cz> Date: Mon Dec 12 18:11:17 2011 +0100 fix docx hyperlink writing This is a rewrite of the fix for fdo#35826, needed for writing the document from bnc#706138 as docx. The sequence there is startURL(), runText(), endRun(), endUrl(), startUrl(), runText(), endUrl(), endRun(), so by the second endRun(), it is needed to close both the previous and current hyperlink run. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 42a132d..d9f3376 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -516,8 +516,6 @@ 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 ) { @@ -543,6 +541,11 @@ void DocxAttributeOutput::EndRun() // before "postponed run start") m_pSerializer->mark(); // let's call it "actual run start" + if ( m_closeHyperlinkInPreviousRun ) + { + m_pSerializer->endElementNS( XML_w, XML_hyperlink ); + m_closeHyperlinkInPreviousRun = false; + } // prepend the actual run start if ( m_pHyperlinkAttrList ) { @@ -551,11 +554,6 @@ 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(); ) @@ -592,10 +590,10 @@ void DocxAttributeOutput::EndRun() EndField_Impl( m_Fields.front( ) ); m_Fields.erase( m_Fields.begin( ) ); } - if ( m_nCloseHyperlinkStatus == EndInThisRun) + if ( m_closeHyperlinkInThisRun ) { m_pSerializer->endElementNS( XML_w, XML_hyperlink ); - m_nCloseHyperlinkStatus = Undetected; + m_closeHyperlinkInThisRun = false; } // if there is some redlining in the document, output it @@ -1043,8 +1041,11 @@ 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; + if( m_closeHyperlinkInThisRun ) + { + m_closeHyperlinkInPreviousRun = true; + m_closeHyperlinkInThisRun = false; + } OUString aText( rText ); // one text can be split into more <w:t>blah</w:t>'s by line breaks etc. @@ -1232,7 +1233,7 @@ bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget ) bool DocxAttributeOutput::EndURL() { - m_nCloseHyperlinkStatus = Detected; + m_closeHyperlinkInThisRun = true; return true; } @@ -4350,7 +4351,8 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_bParagraphOpened( false ), m_nColBreakStatus( COLBRK_NONE ), m_pParentFrame( NULL ), - m_nCloseHyperlinkStatus( Undetected ), + m_closeHyperlinkInThisRun( false ), + m_closeHyperlinkInPreviousRun( false ), m_postponedGraphic( NULL ), m_postponedMath( NULL ), m_postitFieldsMaxId( 0 ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 10ee7cd..79c8b02 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -588,14 +588,8 @@ private: const sw::Frame *m_pParentFrame; // close of hyperlink needed - enum HyperLinkCloseState - { - Undetected = 0, - Detected, - EndInPrevRun, - EndInThisRun - }; - HyperLinkCloseState m_nCloseHyperlinkStatus; + bool m_closeHyperlinkInThisRun; + bool m_closeHyperlinkInPreviousRun; struct PostponedGraphic {
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits