summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-05-16 15:26:53 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-16 18:57:00 +0200
commit659c0227a50d298780d72902314e03df8824bc06 (patch)
treef83ec0b8ef994ff91b79b95ed0b738b415a8de96 /writerfilter
parentd849231dd2064ebed96d17bf54286a33954304ab (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. Change-Id: I71a92d2b10e52e505665831caacad2948d22b4e1 Reviewed-on: https://gerrit.libreoffice.org/37683 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx3
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx5
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx18
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
5 files changed, 23 insertions, 7 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 7ed678863e37..db2c4fa4d5c9 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1178,6 +1178,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 af1991b67e44..fc076998fa9b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1227,6 +1227,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 b43d310db917..65274fcc7d46 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -308,6 +308,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,
@@ -753,6 +755,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 8e308940e7e0..3df7c864cd55 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1021,12 +1021,17 @@ void SectionPropertyMap::HandleMarginsHeaderFooter( bool bFirstPage, DomainMappe
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.
@@ -1113,12 +1118,17 @@ void SectionPropertyMap::InheritOrFinalizePageStyles( DomainMapper_Impl& rDM_Imp
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();
@@ -1151,10 +1161,6 @@ 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;
-
// depending on the break type no page styles should be created
// Continuous sections usually create only a section, and not a new page style
const bool bTreatAsContinuous = m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextPage
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index a45bef692b70..96883755159f 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -284,7 +284,7 @@ private:
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:
enum PageType