tdf#136706 writerfilter: don't create page style for footnote
Each time CloseSectionGroup is called for a non-continuous break, it wants to create a new page style. Each footnote calls CloseSectionGroup twice, so two unused ConvertedX page styles were created for each footnote. A quick glance through the code makes me wonder whether footnotes can skip CloseSectionGroup altogether, (unit tests suggest that it can...) but it might be necessary for a floating table that should be in-lined, or setting relative width (although tables aren't really supported in footnotes). In any case, the safest approach is to change as little as possible, so that is what I have done. HandleMargins...() only seems to add the margin information into the page style, so it should be safe to avoid that function, even though relative width stuff checks the margins. Comments are already excluded, and the function is not even called for isInIndexContext() || isInBibliographyContext(). I thought header/footers were also considered sections, but that does not appear to be the case. I'm not aware of any other types of non-text sections, but if there are, they may need similar treatment. Change-Id: I4325604c286ca1132e5765a56627be4b7e64ba4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102723 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
2ce8446ac4
commit
df2f2c8bf1
@@ -575,6 +575,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123262_textFootnoteSeparators, "tdf123262_textFo
|
||||
// Ensure that paragraph markers are not lost.
|
||||
xFootnoteText.set(xFootnotes->getByIndex(1), uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in second footnote", 2, getParagraphs(xFootnoteText) );
|
||||
|
||||
|
||||
// tdf#136706: Two useless page styles were created for each of the four footnotes.
|
||||
CPPUNIT_ASSERT( !getStyles("PageStyles")->hasByName("Converted8") );
|
||||
CPPUNIT_ASSERT( !getStyles("PageStyles")->hasByName("Converted1") );
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79668,"fdo79668.docx")
|
||||
|
||||
@@ -679,6 +679,7 @@ void DomainMapper_Impl::PopProperties(ContextType eId)
|
||||
{
|
||||
if (m_aPropertyStacks[eId].size() == 1) // tdf#112202 only top level !!!
|
||||
{
|
||||
assert( !IsInFootOrEndnote() && !m_bIsInComments );
|
||||
m_pLastSectionContext = m_aPropertyStacks[eId].top();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,6 +477,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( DomainMa
|
||||
{
|
||||
if ( m_sFirstPageStyleName.isEmpty() && xPageStyles.is() )
|
||||
{
|
||||
assert( !rDM_Impl.IsInFootOrEndnote() && "Don't create useless page styles" );
|
||||
m_sFirstPageStyleName = rDM_Impl.GetUnusedPageStyleName();
|
||||
m_aFirstPageStyle.set( xTextFactory->createInstance( "com.sun.star.style.PageStyle" ),
|
||||
uno::UNO_QUERY );
|
||||
@@ -503,6 +504,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( DomainMa
|
||||
{
|
||||
if ( m_sFollowPageStyleName.isEmpty() && xPageStyles.is() )
|
||||
{
|
||||
assert( !rDM_Impl.IsInFootOrEndnote() && "Don't create useless page styles" );
|
||||
m_sFollowPageStyleName = rDM_Impl.GetUnusedPageStyleName();
|
||||
m_aFollowPageStyle.set( xTextFactory->createInstance( "com.sun.star.style.PageStyle" ),
|
||||
uno::UNO_QUERY );
|
||||
@@ -1646,9 +1648,14 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
|
||||
ApplyProtectionProperties( xSection, rDM_Impl );
|
||||
|
||||
//get the properties and create appropriate page styles
|
||||
uno::Reference< beans::XPropertySet > xFollowPageStyle = GetPageStyle( rDM_Impl, false );
|
||||
uno::Reference< beans::XPropertySet > xFollowPageStyle;
|
||||
//This part certainly is not needed for footnotes, so don't create unused page styles.
|
||||
if ( !rDM_Impl.IsInFootOrEndnote() )
|
||||
{
|
||||
xFollowPageStyle.set( GetPageStyle( rDM_Impl, false ) );
|
||||
|
||||
HandleMarginsHeaderFooter(/*bFirstPage=*/false, rDM_Impl );
|
||||
HandleMarginsHeaderFooter(/*bFirstPage=*/false, rDM_Impl );
|
||||
}
|
||||
|
||||
if ( rDM_Impl.GetSettingsTable()->GetMirrorMarginSettings() )
|
||||
{
|
||||
@@ -1662,7 +1669,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
|
||||
xSection = rDM_Impl.appendTextSectionAfter( m_xStartingRange );
|
||||
if ( xSection.is() )
|
||||
ApplyColumnProperties( xSection, rDM_Impl );
|
||||
else
|
||||
else if ( xFollowPageStyle.is() )
|
||||
xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl );
|
||||
}
|
||||
|
||||
@@ -1757,7 +1764,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
|
||||
Insert( PROP_GRID_BASE_WIDTH, uno::makeAny( nCharWidth ) );
|
||||
Insert( PROP_GRID_RUBY_HEIGHT, uno::makeAny( sal_Int32( 0 ) ) );
|
||||
|
||||
if ( rDM_Impl.IsNewDoc() )
|
||||
if ( rDM_Impl.IsNewDoc() && xFollowPageStyle.is() )
|
||||
ApplyProperties_( xFollowPageStyle );
|
||||
|
||||
//todo: creating a "First Page" style depends on HasTitlePage and _fFacingPage_
|
||||
|
||||
Reference in New Issue
Block a user