sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 5 +++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 1 + writerfilter/source/dmapper/PropertyMap.cxx | 15 +++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-)
New commits: commit df2f2c8bf1004d00dd6cdff0e3edb9bf5777ffbd Author: Justin Luth <[email protected]> AuthorDate: Tue Sep 15 11:45:22 2020 +0300 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Sep 16 14:34:18 2020 +0200 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 <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index af9cd5c86a56..df0ab21a7512 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -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") diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b0facd429e0e..4e5b17863d41 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -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(); } } diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 7a2807746141..60dbe6c4cc4f 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -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_ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
