diff options
Diffstat (limited to 'writerfilter/source/dmapper/PropertyMap.cxx')
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 8634d66e1ae5..34058d9c4702 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -882,13 +882,18 @@ void SectionPropertyMap::CopyHeaderFooterTextProperty( const uno::Reference< bea } // Copy headers and footers from the previous page style. -void SectionPropertyMap::CopyHeaderFooter( const uno::Reference< beans::XPropertySet >& xPrevStyle, +void SectionPropertyMap::CopyHeaderFooter( DomainMapper_Impl& rDM_Impl, + const uno::Reference< beans::XPropertySet >& xPrevStyle, const uno::Reference< beans::XPropertySet >& xStyle, bool bOmitRightHeader, bool bOmitLeftHeader, bool bOmitRightFooter, bool bOmitLeftFooter ) { + if (!rDM_Impl.IsNewDoc()) + { // see also DomainMapper_Impl::PushPageHeaderFooter() + return; // tdf#139737 SwUndoInserts cannot deal with new header/footer + } bool bHasPrevHeader = false; bool bHeaderIsShared = true; OUString sHeaderIsOn = getPropertyName( PROP_HEADER_IS_ON ); @@ -966,13 +971,13 @@ void SectionPropertyMap::CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Imp if ( bFirstPage ) { - CopyHeaderFooter( xPrevStyle, xStyle, + CopyHeaderFooter(rDM_Impl, xPrevStyle, xStyle, !m_bFirstPageHeaderLinkToPrevious, true, !m_bFirstPageFooterLinkToPrevious, true ); } else { - CopyHeaderFooter( xPrevStyle, xStyle, + CopyHeaderFooter(rDM_Impl, xPrevStyle, xStyle, !m_bDefaultHeaderLinkToPrevious, !(m_bEvenPageHeaderLinkToPrevious && bUseEvenPages), !m_bDefaultFooterLinkToPrevious, @@ -1146,6 +1151,15 @@ bool SectionPropertyMap::FloatingTableConversion( const DomainMapper_Impl& rDM_I if (rDM_Impl.m_bConvertedTable && !rDM_Impl.GetIsLastSectionGroup() && rInfo.m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextPage) return false; + sal_Int32 nVertOrientPosition = rInfo.getPropertyValue(u"VertOrientPosition").get<sal_Int32>(); + sal_Int16 nHoriOrientRelation = rInfo.getPropertyValue( u"HoriOrientRelation" ).get<sal_Int16>(); + if (nVertOrientPosition < 0 && nHoriOrientRelation != text::RelOrientation::PAGE_FRAME) + { + // Negative vertical position: then need a floating table, as normal tables can't have + // negative top margins. + return true; + } + sal_Int32 nPageWidth = GetPageWidth(); sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin(); // Count the layout width of the table. @@ -1161,7 +1175,6 @@ bool SectionPropertyMap::FloatingTableConversion( const DomainMapper_Impl& rDM_I if ( rInfo.getPropertyValue( u"RightMargin" ) >>= nRightMargin ) nTableWidth += nRightMargin; - sal_Int16 nHoriOrientRelation = rInfo.getPropertyValue( u"HoriOrientRelation" ).get<sal_Int16>(); sal_Int16 nVertOrientRelation = rInfo.getPropertyValue( u"VertOrientRelation" ).get<sal_Int16>(); if ( nHoriOrientRelation == text::RelOrientation::PAGE_FRAME && nVertOrientRelation == text::RelOrientation::PAGE_FRAME ) { @@ -1174,7 +1187,6 @@ bool SectionPropertyMap::FloatingTableConversion( const DomainMapper_Impl& rDM_I // The more close we are to the bottom, the more likely the table will span over to the next page // So if we're in the bottom left quarter, don't do any conversion. sal_Int32 nHoriOrientPosition = rInfo.getPropertyValue( u"HoriOrientPosition" ).get<sal_Int32>(); - sal_Int32 nVertOrientPosition = rInfo.getPropertyValue( u"VertOrientPosition" ).get<sal_Int32>(); sal_Int32 nPageHeight = getProperty( PROP_HEIGHT )->second.get<sal_Int32>(); if ( nHoriOrientPosition < (nPageWidth / 2) && nVertOrientPosition >( nPageHeight / 2 ) ) return false; @@ -1456,9 +1468,26 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } } - xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, + const uno::Reference< text::XTextContent >& xTextContent = + xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties); + // paragraph of the anchoring point of the floating table needs zero top and bottom + // margins, if the table was a not floating table in the footnote, otherwise + // docDefault margins could result bigger vertical spaces around the table + if ( rInfo.m_bConvertToFloatingInFootnote && xTextContent.is() ) + { + uno::Reference<beans::XPropertySet> xParagraph( + xTextContent->getAnchor(), uno::UNO_QUERY); + if ( xParagraph.is() ) + { + xParagraph->setPropertyValue("ParaTopMargin", + uno::makeAny(static_cast<sal_Int32>(0))); + xParagraph->setPropertyValue("ParaBottomMargin", + uno::makeAny(static_cast<sal_Int32>(0))); + } + } + uno::Reference<text::XTextTablesSupplier> xTextDocument(rDM_Impl.GetTextDocument(), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xTables = xTextDocument->getTextTables(); for( size_t i = 0; i < aFramedRedlines.size(); i+=3) @@ -1844,7 +1873,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) rDM_Impl.GetPageStyles()->insertByName( evenOddStyleName, uno::makeAny( evenOddStyle ) ); evenOddStyle->setPropertyValue( "HeaderIsOn", uno::makeAny( false ) ); evenOddStyle->setPropertyValue( "FooterIsOn", uno::makeAny( false ) ); - CopyHeaderFooter( pageProperties, evenOddStyle ); + CopyHeaderFooter(rDM_Impl, pageProperties, evenOddStyle); *pageStyle = evenOddStyleName; // And use it instead of the original one (which is set as follow of this one). if ( m_nBreakType == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_evenPage) ) evenOddStyle->setPropertyValue( getPropertyName( PROP_PAGE_STYLE_LAYOUT ), uno::makeAny( style::PageStyleLayout_LEFT ) ); |