summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2011-05-26 09:59:43 +0100
committerNoel Power <noel.power@novell.com>2011-05-26 10:09:10 +0100
commitfb75384566defd74b0769d09ac22eb6f460c20c9 (patch)
tree6a3e8c72514d3bc71d98f7716c15f6e126f5edba
parentb1b3fa5b0acc78c5aef1e1a144f828e4cab81773 (diff)
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.
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx18
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx9
2 files changed, 21 insertions, 6 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 238c3888ea..9f1d40e7c5 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 5554d1d8ea..bf7c7d3af7 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 );