summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-05-11 21:08:35 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-05-12 09:02:43 +0200
commit51534ac2b9747975945acb6a1e1ba5cc6d73f5c2 (patch)
treeb39fb0577bac479321027ae08640c11f3d2d0bc2 /sw/source
parent23d9966751566028c50ca95ca203d20f36c64f30 (diff)
tdf#127778 DOCX import: fix unexpected heading on non-first page ...
... when the first page has a heading Regression from commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (DOCX import: first page header should always set default headers as well, 2014-11-21), the problem is around how to split a first + follow page style on import, and then do the opposite on export. This is described using a single section in OOXML, but Writer has 2 page styles for this (unlike in case of the DOC filter). This means the header margin has to be taken from one of these page styles. The above commit tweaked the import, so the follow page style has the wanted header margin, but this leads to incorrect layout. Fix the problem by tweaking the export instead: it has random access to the doc model, so it can take the header margin from the first page style if needed, and then the import side can be reverted, leading to correct layout. Also remove some leftover debug code in test/, which was added in commit 5352d45dd4a04f8f02cf7f6ad4169126d3b3586a (convert AnimationImport to fast-parser APIs, 2020-02-18). Change-Id: I4bbf7271f3a437e8432399bd1e32e9d24190a501 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94013 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx11
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx12
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx1
3 files changed, 24 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 7c576e26538e..a5aa741447af 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -8380,6 +8380,17 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
sal_Int32 nHeader = 0;
if ( aDistances.HasHeader() )
nHeader = sal_Int32( aDistances.dyaHdrTop );
+ else if (m_rExport.m_pFirstPageFormat)
+ {
+ HdFtDistanceGlue aFirstPageDistances(m_rExport.m_pFirstPageFormat->GetAttrSet());
+ if (aFirstPageDistances.HasHeader())
+ {
+ // The follow page style has no header, but the first page style has. In Word terms,
+ // this means that the header margin of "the" section is coming from the first page
+ // style.
+ nHeader = sal_Int32(aFirstPageDistances.dyaHdrTop);
+ }
+ }
// Page top
m_pageMargins.nTop = aDistances.dyaTop;
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index ddf0347ab3b9..653078824a6c 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1783,7 +1783,19 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
m_pISet = &pPdFormat->GetAttrSet();
if (!bOutputStyleItemSet)
+ {
+ if (titlePage)
+ {
+ m_pFirstPageFormat = pPdFirstPgFormat;
+ }
+
AttrOutput().OutputStyleItemSet( pPdFormat->GetAttrSet(), false );
+
+ if (titlePage)
+ {
+ m_pFirstPageFormat = nullptr;
+ }
+ }
AttrOutput().SectionPageBorders( pPdFormat, pPdFirstPgFormat );
m_pISet = pOldI;
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 00da29d78ce7..99063ef12a20 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -450,6 +450,7 @@ public:
OUString m_aMainStg;
std::vector<const SwTOXType*> m_aTOXArr;
const SfxItemSet* m_pISet; // for double attributes
+ const SwFrameFormat* m_pFirstPageFormat = nullptr;
WW8_WrPct* m_pPiece; // Pointer to Piece-Table
std::unique_ptr<SwNumRuleTable> m_pUsedNumTable; // all used NumRules
/// overriding numdef index -> (existing numdef index, abstractnumdef index)