diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-02-19 22:37:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-21 21:32:59 +0100 |
commit | 055aae14063773bdac9ea43b3207f1d7d6ca6b4c (patch) | |
tree | d7e6f555caca7942f62041d1e989f95cd1db17bc /writerfilter | |
parent | 292e9861adba78303eb43bbb84fae57f2bb5d15b (diff) |
tdf#112694 DOCX import: handle <w:titlePg> when turning on follow style header
Commit 17e51f427b3f0cec74ac8e0a1b3f51189006ae6f (DOCX import: first page
header should always set default headers as well, 2014-11-21) turned on
header/footer of follow page styles of first page styles when the first
page style had the header/footer turned on, but failed to consider if
<w:titlePg> is present or not. When it's not present, the first page
header/footer should be ignored.
An additional problem is that by the time
DomainMapper_Impl::PushPageHeaderFooter() is called, <w:titlePg> is not
parsed yet, so we can't act accordingly.
Fix the problem by moving the check to
SectionPropertyMap::PrepareHeaderFooterProperties(), which runs at the
end of the section properties, where all required info is available,
there we can just check for m_bTitlePage.
This allows reverting the two changes to existing testcases in
CppunitTest_sw_ooxmlexport6 from the original commit as a side-effect.
(cherry picked from commit a16275a3647a2fba9913ed23e8329e45b02123b4)
Change-Id: Ic628adab99a4b148fcfd66ca39d0cf81eb7dd9f1
Reviewed-on: https://gerrit.libreoffice.org/50027
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 10 |
2 files changed, 10 insertions, 11 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index de2a959f019d..3791a7c44295 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1660,17 +1660,6 @@ void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::P getPropertyName(ePropIsOn), uno::makeAny(true)); - if (bFirst) - { - OUString aFollowStyle = xPageStyle->getPropertyValue("FollowStyle").get<OUString>(); - if (GetPageStyles()->hasByName(aFollowStyle)) - { - // This is a first page and has a follow style, then enable the header/footer there as well to be consistent. - uno::Reference<beans::XPropertySet> xFollowStyle(GetPageStyles()->getByName(aFollowStyle), uno::UNO_QUERY); - xFollowStyle->setPropertyValue(getPropertyName(ePropIsOn), uno::makeAny(true)); - } - } - // If the 'Different Even & Odd Pages' flag is turned on - do not ignore it // Even if the 'Even' header/footer is blank - the flag should be imported (so it would look in LO like in Word) if (!bFirst && GetSettingsTable()->GetEvenAndOddHeaders()) diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 84625c073d57..db2f20980bb3 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -901,6 +901,16 @@ void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Imp void SectionPropertyMap::PrepareHeaderFooterProperties( bool bFirstPage ) { + if (bFirstPage && m_bTitlePage && m_aFollowPageStyle.is()) + { + // This is a first page and has a follow style, then enable the + // header/footer there as well to be consistent. + if (HasHeader(/*bFirstPage=*/true)) + m_aFollowPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(true)); + if (HasFooter(/*bFirstPage=*/true)) + m_aFollowPageStyle->setPropertyValue("FooterIsOn", uno::makeAny(true)); + } + sal_Int32 nTopMargin = m_nTopMargin; sal_Int32 nHeaderTop = m_nHeaderTop; if ( HasHeader( bFirstPage ) ) |