diff options
author | Serge Krot <Serge.Krot@cib.de> | 2018-06-27 11:18:41 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-01 15:07:09 +0100 |
commit | 8f648a4efad512627a3113dff4fb08111bd369b1 (patch) | |
tree | 5e3ccd657cf1c868de81db7bfb1778b79d66aa99 /sw/source | |
parent | 47789c45dfc7ba8509eedab37f1dbd70ea79da41 (diff) |
tdf#118393: FILESAVE: DOCX Export loses header/footer
Reviewed-on: https://gerrit.libreoffice.org/56522
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit fa8b2c533265a6d74e16ffae55673d6aa0fbf6a5)
Change-Id: If47a2e4953e4b98f41c9115779522a755eea8192
Reviewed-on: https://gerrit.libreoffice.org/60873
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 29 |
4 files changed, 37 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 250aea6fcf8f..7289bdd8f9d2 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -977,7 +977,7 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport ) sal_uLong nRstLnNum = pSet ? pSet->Get( RES_LINENUMBER ).GetStartValue() : 0; const SwTableNode* pTableNd = rExport.m_pCurPam->GetNode().FindTableNode(); - const SwSectionNode* pSectNd; + const SwSectionNode* pSectNd = nullptr; if ( pTableNd ) { pSet = &pTableNd->GetTable().GetFrameFormat()->GetAttrSet(); @@ -1001,6 +1001,11 @@ MSWordSections::MSWordSections( MSWordExportBase& rExport ) pFormat = pSectNd->GetSection().GetFormat(); } + // tdf#118393: FILESAVE: DOCX Export loses header/footer + rExport.m_bFirstTOCNodeWithSection = pSectNd && + ( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() || + TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() ); + // Try to get page descriptor of the first node if ( pSet && SfxItemState::SET == pSet->GetItemState( RES_PAGEDESC, true, &pI ) && diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 833de9c7b452..655716d9e988 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3588,6 +3588,7 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM , m_nOrigRedlineFlags(RedlineFlags::NONE) , m_pCurrentPageDesc(nullptr) , m_bPrevTextNodeIsEmpty(false) + , m_bFirstTOCNodeWithSection(false) , m_pPapPlc(nullptr) , m_pChpPlc(nullptr) , m_pChpIter(nullptr) diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 0345a8d1ac87..8a911bd381e9 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -489,6 +489,7 @@ public: ww8::Frames m_aFrames; // The floating frames in this document const SwPageDesc *m_pCurrentPageDesc; bool m_bPrevTextNodeIsEmpty; + bool m_bFirstTOCNodeWithSection; WW8_WrPlcPn* m_pPapPlc; WW8_WrPlcPn* m_pChpPlc; MSWordAttrIter* m_pChpIter; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index ce6d2e4b2f6b..7e2420899738 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -452,6 +452,35 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode */ if ( isCellOpen && ( m_pCurrentPageDesc->GetName() != pPageDesc->GetName() ) ) pSet = nullptr; + + // tdf#118393: FILESAVE: DOCX Export loses header/footer + { + bool bPlausableSingleWordSection = sw::util::IsPlausableSingleWordSection(m_pCurrentPageDesc->GetFirstMaster(), pPageDesc->GetMaster()); + + { + const SwFrameFormat& rTitleFormat = m_pCurrentPageDesc->GetFirstMaster(); + const SwFrameFormat& rFollowFormat = pPageDesc->GetMaster(); + + auto pHeaderFormat1 = rTitleFormat.GetHeader().GetHeaderFormat(); + auto pHeaderFormat2 = rFollowFormat.GetHeader().GetHeaderFormat(); + + if (pHeaderFormat1 != pHeaderFormat2) + bPlausableSingleWordSection = false; + + auto pFooterFormat1 = rTitleFormat.GetFooter().GetFooterFormat(); + auto pFooterFormat2 = rFollowFormat.GetFooter().GetFooterFormat(); + + if (pFooterFormat1 != pFooterFormat2) + bPlausableSingleWordSection = false; + } + + if ( !bPlausableSingleWordSection && m_bFirstTOCNodeWithSection ) + { + bBreakSet = false; + bNewPageDesc = true; + m_pCurrentPageDesc = pPageDesc; + } + } } else if (!sw::util::IsPlausableSingleWordSection(m_pCurrentPageDesc->GetFirstMaster(), pPageDesc->GetMaster())) { |