docx - inherit FollowPage before FirstPage
GetPageStyle(bTitlePage == true) will check if the follow exists.
If not, it will create a new style - which defeats the purpose
of inheriting from the previous section if this section didn't define
a new follow.
Change-Id: I235bc9b7bc35c9875295733313a6452ba8896c4f
Reviewed-on: https://gerrit.libreoffice.org/27700
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 094e2b4..f36c150 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1126,17 +1126,8 @@ throw ( css::beans::UnknownPropertyException,
// if no new styles have been created for this section, inherit from the previous section,
// otherwise apply this section's settings to the new style.
// Ensure that FollowPage is inherited first - otherwise GetPageStyle may auto-create a follow when checking FirstPage.
SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext();
if( pLastContext && m_sFirstPageStyleName.isEmpty() )
m_sFirstPageStyleName = pLastContext->GetPageStyleName( /*bFirst=*/true );
else
{
HandleMarginsHeaderFooter( /*bFirst=*/true, rDM_Impl );
GetPageStyle( xPageStyles, xTextFactory, /*bFirst=*/true );
if( rDM_Impl.IsNewDoc() && m_aFirstPageStyle.is() )
ApplyProperties_( m_aFirstPageStyle );
}
if( pLastContext && m_sFollowPageStyleName.isEmpty() )
m_sFollowPageStyleName = pLastContext->GetPageStyleName();
else
@@ -1147,6 +1138,16 @@ throw ( css::beans::UnknownPropertyException,
ApplyProperties_( m_aFollowPageStyle );
}
if( pLastContext && m_sFirstPageStyleName.isEmpty() )
m_sFirstPageStyleName = pLastContext->GetPageStyleName( /*bFirst=*/true );
else
{
HandleMarginsHeaderFooter( /*bFirst=*/true, rDM_Impl );
GetPageStyle( xPageStyles, xTextFactory, /*bFirst=*/true );
if( rDM_Impl.IsNewDoc() && m_aFirstPageStyle.is() )
ApplyProperties_( m_aFirstPageStyle );
}
GetPageStyle( xPageStyles, xTextFactory, /*bFirst=*/true );
// Chain m_aFollowPageStyle to be after m_aFirstPageStyle
m_aFirstPageStyle->setPropertyValue( "FollowStyle", uno::makeAny(m_sFollowPageStyleName) );