diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-19 18:12:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-19 18:19:04 +0200 |
commit | 788632dcb0450cc9863a5a332b6df50b92f30c4d (patch) | |
tree | 9ef9637a3496f7b17f0e46266a8b66b04c1908d3 | |
parent | 1c06dc14a1f4cf6bf6121aa9a7b62e8890256161 (diff) |
DOCX export: handle SDT end right before a section break introducing headers
Change-Id: I0fab5ae4335ed6016d31aa243b131899c3154388
-rw-r--r-- | sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx | bin | 0 -> 20485 bytes | |||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 4 |
4 files changed, 22 insertions, 1 deletions
diff --git a/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx b/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx Binary files differnew file mode 100644 index 000000000000..334b6e5950de --- /dev/null +++ b/sw/qa/core/exportdata/ooxml/pass/sdt-sectpr.docx diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b3f2255e3ad2..9f43f7f8bb5e 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -292,13 +292,14 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText bEndParaSdt = m_bStartedParaSdt && rMap.find("ParaSdtEndBefore") != rMap.end(); } } - if (bEndParaSdt) + if (bEndParaSdt || (m_bStartedParaSdt && m_bHadSectPr)) { // This is the common case: "close sdt before the current paragraph" was requrested by the next paragraph. EndSdtBlock(); bEndParaSdt = false; m_bStartedParaSdt = false; } + m_bHadSectPr = false; // this mark is used to be able to enclose the paragraph inside a sdr tag. // We will only know if we have to do that later. @@ -5390,6 +5391,7 @@ void DocxAttributeOutput::StartSection() aSeqOrder[i] = aOrder[i]; m_pSerializer->mark( aSeqOrder ); + m_bHadSectPr = true; } void DocxAttributeOutput::EndSection() @@ -8216,6 +8218,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pRedlineData( NULL ), m_nRedlineId( 0 ), m_bOpenedSectPr( false ), + m_bHadSectPr(false), m_bRunTextIsOn( false ), m_bWritingHeaderFooter( false ), m_bAnchorLinkedToNode(false), @@ -8368,4 +8371,14 @@ void DocxAttributeOutput::AddToAttrList( ::sax_fastparser::FastAttributeList* &p va_end( args ); } +void DocxAttributeOutput::SetStartedParaSdt(bool bStartedParaSdt) +{ + m_bStartedParaSdt = bStartedParaSdt; +} + +bool DocxAttributeOutput::IsStartedParaSdt() +{ + return m_bStartedParaSdt; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 343afaf09213..d0bfe9266458 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -746,6 +746,8 @@ private: /// Flag indicating that the section properties are being written bool m_bOpenedSectPr; + /// Did we have a section break in this paragraph? Set by StartSection(), reset by the next StartParagraph(). + bool m_bHadSectPr; /// Flag indicating that the Run Text is being written bool m_bRunTextIsOn; @@ -960,6 +962,8 @@ public: void SetAlternateContentChoiceOpen( bool bAltContentChoiceOpen ) { m_bAlternateContentChoiceOpen = bAltContentChoiceOpen; } bool IsAlternateContentChoiceOpen( ) { return m_bAlternateContentChoiceOpen; } void GetSdtEndBefore(const SdrObject* pSdrObj); + void SetStartedParaSdt(bool bStartedParaSdt); + bool IsStartedParaSdt(); }; #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXATTRIBUTEOUTPUT_HXX diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 43272db6e9ee..7f8ef58c3209 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -714,6 +714,9 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* m_pVMLExport->SetFS( pFS ); m_pSdrExport->setSerializer(pFS); SetFS( pFS ); + bool bStartedParaSdt = m_pAttrOutput->IsStartedParaSdt(); + m_pAttrOutput->SetStartedParaSdt(false); + m_pAttrOutput->switchHeaderFooter(true, m_nHeadersFootersInSection++); // do the work WriteHeaderFooterText( rFmt, bHeader ); @@ -728,6 +731,7 @@ void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* m_pVMLExport->SetFS( m_pDocumentFS ); m_pSdrExport->setSerializer(m_pDocumentFS); SetFS( m_pDocumentFS ); + m_pAttrOutput->SetStartedParaSdt(bStartedParaSdt); // close the tag sal_Int32 nReference; |