[Libreoffice-commits] core.git: sw/source

Eilidh McAdam eilidh.mcadam at itomig.de
Tue Apr 21 01:07:03 PDT 2015


 sw/source/filter/ww8/docxattributeoutput.hxx |    1 +
 sw/source/filter/ww8/docxexport.cxx          |    2 +-
 sw/source/filter/ww8/wrtw8sty.cxx            |    7 ++++---
 sw/source/filter/ww8/wrtww8.hxx              |   12 ++++++++----
 4 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit f10ab3425f02a4caea22b2bdbf60a731bd059419
Author: Eilidh McAdam <eilidh.mcadam at itomig.de>
Date:   Wed Mar 18 01:33:43 2015 +0000

    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/15369
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 3acde5b..70f5cc3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -974,6 +974,7 @@ public:
     void GetSdtEndBefore(const SdrObject* pSdrObj);
     void SetStartedParaSdt(bool bStartedParaSdt);
     bool IsStartedParaSdt();
+    bool IsFirstParagraph() { return m_bIsFirstParagraph; }
 
     /// Stores the table export state to the passed context and resets own state.
     void pushToTableExportContext(DocxTableExportContext& rContext);
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 2490066..cb48a7f 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -460,7 +460,7 @@ void DocxExport::ExportDocument_Impl()
 void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum )
 {
     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 )
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index d3c0488..1b4a5d9 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1157,12 +1157,12 @@ const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
 }
 
 void MSWordSections::AppendSection( const SwPageDesc* pPd,
-    const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo )
+    const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo, bool bIsFirstParagraph )
 {
     if (HeaderFooterWritten()) {
         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() );
 }
 
@@ -1828,7 +1828,8 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
         ? &pPd->GetFollow()->GetMaster()
         : &pPd->GetLeft();
 
-    if ( nBreakCode != 0 )
+    // Ensure that headers are written if section is first paragraph
+    if ( nBreakCode != 0 || ( rSepInfo.pSectionFmt && rSepInfo.bIsFirstParagraph ))
     {
         if ( titlePage )
         {
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 1a35a65..372789b 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -164,16 +164,19 @@ struct WW8_SepInfo
     const SwTxtNode* pNumNd;
     sal_uLong  nLnNumRestartNo;
     ::boost::optional<sal_uInt16> oPgRestartNo;
+    bool bIsFirstParagraph;
 
     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,
-        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 ),
-          nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart )
+          nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart ),
+          bIsFirstParagraph( bIsFirstPara )
     {}
 
     bool IsProtected() const;
@@ -202,7 +205,8 @@ public:
 
     void AppendSection( const SwPageDesc* pPd,
                     const SwSectionFmt* pSectionFmt = 0,
-                    sal_uLong nLnNumRestartNo = 0 );
+                    sal_uLong nLnNumRestartNo = 0,
+                    bool bIsFirstParagraph = false );
     void AppendSection( const SwFmtPageDesc& rPd,
                     const SwNode& rNd,
                     const SwSectionFmt* pSectionFmt,


More information about the Libreoffice-commits mailing list