diff options
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 52 |
3 files changed, 55 insertions, 7 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b938343bb7ef..3efd32d45ad5 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -677,7 +677,10 @@ void DomainMapper_Impl::PopProperties(ContextType eId) if ( eId == CONTEXT_SECTION ) { - m_pLastSectionContext = m_aPropertyStacks[eId].top( ); + if (m_aPropertyStacks[eId].size() == 1) // tdf#112202 only top level !!! + { + m_pLastSectionContext = m_aPropertyStacks[eId].top(); + } } else if (eId == CONTEXT_CHARACTER) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 8780bc1d51fd..97f7cddb7f16 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -932,6 +932,11 @@ public: void SetIsOutsideAParagraph(bool bval) { m_bIsOutsideAParagraph = bval;} void ApplySettingsTable(); + + css::uno::Reference<css::text::XTextAppend> GetCurrentXText() { + return m_aTextAppendStack.empty() ? nullptr : m_aTextAppendStack.top().xTextAppend; + } + SectionPropertyMap * GetSectionContext(); /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules) css::uno::Reference<css::beans::XPropertySet> GetCurrentNumberingCharStyle(); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 00678668845f..1aefd554c402 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1360,12 +1360,13 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } catch ( const uno::Exception& ) { - OSL_FAIL( "Exception in SectionPropertyMap::CloseSectionGroup" ); + DBG_UNHANDLED_EXCEPTION("writerfilter.dmapper", "Exception in SectionPropertyMap::CloseSectionGroup"); } } } - if ( m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) ) + if (m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous) + && !rDM_Impl.IsInComments()) { //todo: insert a section or access the already inserted section uno::Reference< beans::XPropertySet > xSection = @@ -1385,7 +1386,43 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) OUString aName = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName; uno::Reference< beans::XPropertySet > xRangeProperties( lcl_GetRangeProperties( m_bIsFirstSection, rDM_Impl, m_xStartingRange ) ); if ( m_bIsFirstSection && !aName.isEmpty() && xRangeProperties.is() ) + { xRangeProperties->setPropertyValue( getPropertyName( PROP_PAGE_DESC_NAME ), uno::makeAny( aName ) ); + } + else if ((!m_bFirstPageHeaderLinkToPrevious || + !m_bFirstPageFooterLinkToPrevious || + !m_bDefaultHeaderLinkToPrevious || + !m_bDefaultFooterLinkToPrevious || + !m_bEvenPageHeaderLinkToPrevious || + !m_bEvenPageFooterLinkToPrevious) + && rDM_Impl.GetCurrentXText()) + { // find a node in the section that has a page break and change + // it to apply the page style; see "nightmare scenario" in + // wwSectionManager::InsertSegments() + auto xTextAppend = rDM_Impl.GetCurrentXText(); + uno::Reference<container::XEnumerationAccess> const xCursor( + xTextAppend->createTextCursorByRange( + uno::Reference<text::XTextContent>(xSection, uno::UNO_QUERY_THROW)->getAnchor()), + uno::UNO_QUERY_THROW); + uno::Reference<container::XEnumeration> const xEnum( + xCursor->createEnumeration()); + while (xEnum->hasMoreElements()) + { + uno::Reference<beans::XPropertySet> xElem; + xEnum->nextElement() >>= xElem; + if (xElem->getPropertySetInfo()->hasPropertyByName("BreakType")) + { + style::BreakType bt; + if ((xElem->getPropertyValue("BreakType") >>= bt) + && bt == style::BreakType_PAGE_BEFORE) + { + xElem->setPropertyValue(getPropertyName(PROP_PAGE_DESC_NAME), + uno::makeAny(aName)); + break; + } + } + } + } } catch ( const uno::Exception& ) { @@ -1395,7 +1432,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) // If the section is of type "New column" (0x01), then simply insert a column break. // But only if there actually are columns on the page, otherwise a column break // seems to be handled like a page break by MSO. - else if ( m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_nextColumn) && m_nColumnCount > 0 ) + else if (m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_nextColumn) + && 0 < m_nColumnCount && !rDM_Impl.IsInComments()) { try { @@ -1414,7 +1452,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } catch ( const uno::Exception& ) {} } - else + else if (!rDM_Impl.IsInComments()) { uno::Reference< beans::XPropertySet > xSection; ApplyProtectionProperties( xSection, rDM_Impl ); @@ -1525,7 +1563,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } catch ( const uno::Exception& ) { - OSL_ENSURE( false, "Exception in SectionPropertyMap::CloseSectionGroup" ); + DBG_UNHANDLED_EXCEPTION("writerfilter.dmapper", "Exception in SectionPropertyMap::CloseSectionGroup"); } Insert( PROP_GRID_BASE_HEIGHT, uno::makeAny( nGridLinePitch ) ); @@ -1600,11 +1638,13 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { // Avoid setting page style in case of autotext: so inserting the autotext at the // end of the document does not introduce an unwanted page break. - if (!rDM_Impl.IsReadGlossaries()) + if (!rDM_Impl.IsReadGlossaries() && !rDM_Impl.IsInFootOrEndnote()) + { xRangeProperties->setPropertyValue( getPropertyName( PROP_PAGE_DESC_NAME ), uno::makeAny( m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName ) ); + } if (0 <= m_nPageNumber) { |