diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-05-16 15:26:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-05-17 10:59:45 +0200 |
commit | aadbf483583acab13f043ac36af035be570a0b20 (patch) | |
tree | 010b2a0504476b72b11578aa84e614ea4a2cf778 /writerfilter | |
parent | 8c9002a9509fb161ebebccc0f358a0dc5b6a8a12 (diff) |
tdf#107889 DOCX import: consider page breaks for multi-page floattables
This is the DOCX equivalent of commit
6aba29576df7a2a40e54040d4dd09d94d6594741 (tdf#107773 DOC import:
consider page breaks for multi-page floattables, 2017-05-11): a specific
case where it's clearly superior to import a multi-page floating table
as a multi-page one, rather than a floating one.
Reviewed-on: https://gerrit.libreoffice.org/37683
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 659c0227a50d298780d72902314e03df8824bc06)
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
writerfilter/source/dmapper/PropertyMap.cxx
writerfilter/source/dmapper/PropertyMap.hxx
Change-Id: I71a92d2b10e52e505665831caacad2948d22b4e1
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.hxx | 2 |
5 files changed, 23 insertions, 3 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 36f30a36c39c..5676a3c3ce80 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -1142,6 +1142,9 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, comphelper::containerToSequence(aFrameProperties)); } } + + // We're right after a table conversion. + m_rDMapper_Impl.m_bConvertedTable = true; } m_aTableProperties.reset(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 47ae4e654438..4cb55513eacb 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1225,6 +1225,8 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap ) xTextRange = xTextAppend->finishParagraph( comphelper::containerToSequence(aProperties) ); m_xPreviousParagraph.set(xTextRange, uno::UNO_QUERY); + // We're no longer right after a table conversion. + m_bConvertedTable = false; if (xCursor.is()) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 6823e741619d..44a2be003c30 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -310,6 +310,8 @@ struct FloatingTableInfo css::uno::Reference<css::text::XTextRange> m_xEnd; css::uno::Sequence<css::beans::PropertyValue> m_aFrameProperties; sal_Int32 m_nTableWidth; + /// Break type of the section that contains this table. + sal_Int32 m_nBreakType = -1; FloatingTableInfo(css::uno::Reference<css::text::XTextRange> const& xStart, css::uno::Reference<css::text::XTextRange> const& xEnd, @@ -747,6 +749,9 @@ public: DeletableTabStop m_aCurrentTabStop; + /// If we're right after the end of a table. + bool m_bConvertedTable = false; + bool IsOOXMLImport() const { return m_eDocumentType == SourceDocumentType::OOXML; } bool IsRTFImport() const { return m_eDocumentType == SourceDocumentType::RTF; } diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 556c9be7aff2..c8cf96bb1f7f 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1057,12 +1057,17 @@ void SectionPropertyMap::HandleMarginsHeaderFooter(bool bFirstPage, DomainMapper PrepareHeaderFooterProperties( bFirstPage ); } -bool SectionPropertyMap::FloatingTableConversion(FloatingTableInfo& rInfo) +bool SectionPropertyMap::FloatingTableConversion(DomainMapper_Impl& rDM_Impl, FloatingTableInfo& rInfo) { // Note that this is just a list of heuristics till sw core can have a // table that is floating and can span over multiple pages at the same // time. + // If there is an explicit section break right after a table, then there + // will be no wrapping anyway. + if (rDM_Impl.m_bConvertedTable && !rDM_Impl.GetIsLastSectionGroup() && rInfo.m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextPage) + return false; + sal_Int32 nPageWidth = GetPageWidth(); sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin(); // Count the layout width of the table. @@ -1154,12 +1159,17 @@ throw ( css::beans::UnknownPropertyException, void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { + // The default section type is nextPage. + if ( m_nBreakType == -1 ) + m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage; + // Text area width is known at the end of a section: decide if tables should be converted or not. std::vector<FloatingTableInfo>& rPendingFloatingTables = rDM_Impl.m_aPendingFloatingTables; uno::Reference<text::XTextAppendAndConvert> xBodyText( rDM_Impl.GetBodyText(), uno::UNO_QUERY ); for (FloatingTableInfo & rInfo : rPendingFloatingTables) { - if (FloatingTableConversion(rInfo)) + rInfo.m_nBreakType = m_nBreakType; + if (FloatingTableConversion(rDM_Impl, rInfo)) xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd, rInfo.m_aFrameProperties); } rPendingFloatingTables.clear(); diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 9fe090273150..4aad5da6873b 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -264,7 +264,7 @@ class SectionPropertyMap : public PropertyMap sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth); /// Determines if conversion of a given floating table is wanted or not. - bool FloatingTableConversion(FloatingTableInfo& rInfo); + bool FloatingTableConversion(DomainMapper_Impl& rDM_Impl, FloatingTableInfo& rInfo); public: explicit SectionPropertyMap(bool bIsFirstSection); |