summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxattributeoutput.cxx
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2023-03-06 15:34:57 +0100
committerLászló Németh <nemeth@numbertext.org>2023-03-10 11:46:59 +0000
commit05df784c6febd1d77e95db8ef3dfdc03347a48a3 (patch)
tree3657cb803b65ce390c635c5883663f17972f0925 /sw/source/filter/ww8/docxattributeoutput.cxx
parent50b68c341f2543c4d841fce4d4b3e080f4491e1d (diff)
tdf#149996 DOCX export: fix hyperlinks in nested paragraphs
Close all hyperlinks in the paragraph where they start. Regression from commit 20a3792502120d67b1a9fdea641e15ea504359d3 "fdo#76316 : File gets corrupt after Roundtrip". Change-Id: Ied5be90601f5a494f927d43aa6ff7efd3545f993 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148353 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 05efeafbd19b..1b1afa152e69 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -516,6 +516,7 @@ sal_Int32 DocxAttributeOutput::StartParagraph(ww8::WW8TableNodeInfo::Pointer_t p
m_bParagraphOpened = true;
m_bIsFirstParagraph = false;
+ m_nHyperLinkCount.push(0);
return nParaId;
}
@@ -1083,12 +1084,12 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
/* If m_nHyperLinkCount > 0 that means hyperlink tag is not yet closed.
* This is due to nested hyperlink tags. So close it before end of paragraph.
*/
- if(m_nHyperLinkCount > 0)
+ if(m_nHyperLinkCount.top() > 0)
{
- for(sal_Int32 nHyperLinkToClose = 0; nHyperLinkToClose < m_nHyperLinkCount; ++nHyperLinkToClose)
+ for(sal_Int32 nHyperLinkToClose = 0; nHyperLinkToClose < m_nHyperLinkCount.top(); ++nHyperLinkToClose)
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
- m_nHyperLinkCount = 0;
}
+ m_nHyperLinkCount.pop();
if (m_aRunSdt.m_bStartedSdt)
{
@@ -1688,7 +1689,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
m_startedHyperlink = false;
m_endPageRef = false;
- m_nHyperLinkCount--;
+ m_nHyperLinkCount.top()--;
}
m_closeHyperlinkInPreviousRun = false;
}
@@ -1768,7 +1769,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In
m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList );
m_startedHyperlink = true;
- m_nHyperLinkCount++;
+ m_nHyperLinkCount.top()++;
}
// if there is some redlining in the document, output it
@@ -1930,7 +1931,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, sal_In
m_pSerializer->endElementNS( XML_w, XML_hyperlink );
m_startedHyperlink = false;
- m_nHyperLinkCount--;
+ m_nHyperLinkCount.top()--;
}
m_closeHyperlinkInThisRun = false;
}
@@ -6271,8 +6272,8 @@ void DocxAttributeOutput::pushToTableExportContext(DocxTableExportContext& rCont
rContext.m_bStartedRunSdt = m_aRunSdt.m_bStartedSdt;
m_aRunSdt.m_bStartedSdt = false;
- rContext.m_nHyperLinkCount = m_nHyperLinkCount;
- m_nHyperLinkCount = 0;
+ rContext.m_nHyperLinkCount = m_nHyperLinkCount.top();
+ m_nHyperLinkCount.top() = 0;
}
void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const & rContext)
@@ -6282,7 +6283,7 @@ void DocxAttributeOutput::popFromTableExportContext(DocxTableExportContext const
m_tableReference.m_nTableDepth = rContext.m_nTableDepth;
m_aParagraphSdt.m_bStartedSdt = rContext.m_bStartedParaSdt;
m_aRunSdt.m_bStartedSdt = rContext.m_bStartedRunSdt;
- m_nHyperLinkCount = rContext.m_nHyperLinkCount;
+ m_nHyperLinkCount.top() = rContext.m_nHyperLinkCount;
}
void DocxAttributeOutput::WriteTextBox(uno::Reference<drawing::XShape> xShape)
@@ -9955,7 +9956,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_closeHyperlinkInThisRun( false ),
m_closeHyperlinkInPreviousRun( false ),
m_startedHyperlink( false ),
- m_nHyperLinkCount(0),
m_nFieldsInHyperlink( 0 ),
m_bExportingOutline(false),
m_nChartCount(0),
@@ -9971,6 +9971,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_nParaAfterSpacing(0)
, m_nStateOfFlyFrame( FLY_NOT_PROCESSED )
{
+ m_nHyperLinkCount.push(0);
}
DocxAttributeOutput::~DocxAttributeOutput()