Kaydet (Commit) f10ab342 authored tarafından Eilidh McAdam's avatar Eilidh McAdam Kaydeden (comit) Miklos Vajna

tdf#78606: Write DOCX header even if section is first paragraph

Header flags are now set prior to export if a section is the first
thing in the document (ODF -> DOCX).

Change-Id: I84ba61c11da78a012938163d986ee5fcd301d405
Reviewed-on: https://gerrit.libreoffice.org/15369Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst b4845f5d
...@@ -974,6 +974,7 @@ public: ...@@ -974,6 +974,7 @@ public:
void GetSdtEndBefore(const SdrObject* pSdrObj); void GetSdtEndBefore(const SdrObject* pSdrObj);
void SetStartedParaSdt(bool bStartedParaSdt); void SetStartedParaSdt(bool bStartedParaSdt);
bool IsStartedParaSdt(); bool IsStartedParaSdt();
bool IsFirstParagraph() { return m_bIsFirstParagraph; }
/// Stores the table export state to the passed context and resets own state. /// Stores the table export state to the passed context and resets own state.
void pushToTableExportContext(DocxTableExportContext& rContext); void pushToTableExportContext(DocxTableExportContext& rContext);
......
...@@ -460,7 +460,7 @@ void DocxExport::ExportDocument_Impl() ...@@ -460,7 +460,7 @@ void DocxExport::ExportDocument_Impl()
void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum )
{ {
AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() ); AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
m_pSections->AppendSection( pPageDesc, pFmt, nLnNum ); m_pSections->AppendSection( pPageDesc, pFmt, nLnNum, m_pAttrOutput->IsFirstParagraph() );
} }
void DocxExport::OutputEndNode( const SwEndNode& rEndNode ) void DocxExport::OutputEndNode( const SwEndNode& rEndNode )
......
...@@ -1157,12 +1157,12 @@ const WW8_SepInfo* MSWordSections::CurrentSectionInfo() ...@@ -1157,12 +1157,12 @@ const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
} }
void MSWordSections::AppendSection( const SwPageDesc* pPd, void MSWordSections::AppendSection( const SwPageDesc* pPd,
const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo ) const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo, bool bIsFirstParagraph )
{ {
if (HeaderFooterWritten()) { if (HeaderFooterWritten()) {
return; // #i117955# prevent new sections in endnotes return; // #i117955# prevent new sections in endnotes
} }
aSects.push_back( WW8_SepInfo( pPd, pSectionFmt, nLnNumRestartNo ) ); aSects.push_back( WW8_SepInfo( pPd, pSectionFmt, nLnNumRestartNo, boost::none, NULL, bIsFirstParagraph ) );
NeedsDocumentProtected( aSects.back() ); NeedsDocumentProtected( aSects.back() );
} }
...@@ -1828,7 +1828,8 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt ...@@ -1828,7 +1828,8 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
? &pPd->GetFollow()->GetMaster() ? &pPd->GetFollow()->GetMaster()
: &pPd->GetLeft(); : &pPd->GetLeft();
if ( nBreakCode != 0 ) // Ensure that headers are written if section is first paragraph
if ( nBreakCode != 0 || ( rSepInfo.pSectionFmt && rSepInfo.bIsFirstParagraph ))
{ {
if ( titlePage ) if ( titlePage )
{ {
......
...@@ -164,16 +164,19 @@ struct WW8_SepInfo ...@@ -164,16 +164,19 @@ struct WW8_SepInfo
const SwTxtNode* pNumNd; const SwTxtNode* pNumNd;
sal_uLong nLnNumRestartNo; sal_uLong nLnNumRestartNo;
::boost::optional<sal_uInt16> oPgRestartNo; ::boost::optional<sal_uInt16> oPgRestartNo;
bool bIsFirstParagraph;
WW8_SepInfo() WW8_SepInfo()
: pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0) : pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0), bIsFirstParagraph(false)
{} {}
WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt, WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt,
sal_uLong nLnRestart, ::boost::optional<sal_uInt16> oPgRestart = boost::none, const SwNode* pNd = NULL ) sal_uLong nLnRestart, ::boost::optional<sal_uInt16> oPgRestart = boost::none,
const SwNode* pNd = NULL, bool bIsFirstPara = false )
: pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ), : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ),
nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart ) nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart ),
bIsFirstParagraph( bIsFirstPara )
{} {}
bool IsProtected() const; bool IsProtected() const;
...@@ -202,7 +205,8 @@ public: ...@@ -202,7 +205,8 @@ public:
void AppendSection( const SwPageDesc* pPd, void AppendSection( const SwPageDesc* pPd,
const SwSectionFmt* pSectionFmt = 0, const SwSectionFmt* pSectionFmt = 0,
sal_uLong nLnNumRestartNo = 0 ); sal_uLong nLnNumRestartNo = 0,
bool bIsFirstParagraph = false );
void AppendSection( const SwFmtPageDesc& rPd, void AppendSection( const SwFmtPageDesc& rPd,
const SwNode& rNd, const SwNode& rNd,
const SwSectionFmt* pSectionFmt, const SwSectionFmt* pSectionFmt,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment