diff options
author | Justin Luth <justin.luth@collabora.com> | 2020-08-01 12:08:51 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-08-07 10:11:52 +0200 |
commit | 75b45d43b53abd457c98f47078ca7ff3c492ce2c (patch) | |
tree | 4761c134f9d0307d8c510f83eef489bd3dd73028 /writerfilter | |
parent | e73ca98ebeeddac05dcf224e517970ede582eb9f (diff) |
tdf#135343 writerfilter: compat15 treats section nextCol as nextPage
... and also handle a document that starts with a nextColumn break
... and also handle a nextColumn with a different number of columns.
Starting in Word 2013's compatibilityMode=15, it appears
(based on testing, but no documentation found to prove it)
that the hard-to-create column-section-break is always
handled the same way as a page break.
It already was like this if it occurred when the previous
section did not have columns. Only when the previous section
had the same # of columns did it act as a regular column break.
In any case, LO never handled any of it well.
P.S. I never liked "lastContext" since it isn't clear
whether it means the very last something or something earlier.
So I changed it to PrevSection which is much nicer.
still to do: figure out how to just do a regular column
break in the previous section.
Change-Id: I3cef4a1ab185d25dfde90b85338706e8909b72dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99936
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index c1980623b072..6b5af2fd9404 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1324,14 +1324,29 @@ void SectionPropertyMap::HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) { + SectionPropertyMap* pPrevSection = rDM_Impl.GetLastSectionContext(); + // The default section type is nextPage. if ( m_nBreakType == -1 ) m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage; - // if page orientation differs from previous section, it can't be treated as continuous + else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextColumn ) + { + // Word 2013+ seems to treat a section column break as a page break all the time. + // It always acts like a page break if there are no columns, or a different number of columns. + // Also, if this is the first section, the break type is basically irrelevant - works best as nextPage. + if ( rDM_Impl.GetSettingsTable()->GetWordCompatibilityMode() > 14 + || !pPrevSection + || m_nColumnCount < 2 + || m_nColumnCount != pPrevSection->ColumnCount() + ) + { + m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage; + } + } else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_continuous ) { - SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext(); - if ( pLastContext ) + // if page orientation differs from previous section, it can't be treated as continuous + if ( pPrevSection ) { bool bIsLandscape = false; std::optional< PropertyMap::Property > pProp = getProperty( PROP_IS_LANDSCAPE ); @@ -1339,7 +1354,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) pProp->second >>= bIsLandscape; bool bPrevIsLandscape = false; - pProp = pLastContext->getProperty( PROP_IS_LANDSCAPE ); + pProp = pPrevSection->getProperty( PROP_IS_LANDSCAPE ); if ( pProp ) pProp->second >>= bPrevIsLandscape; @@ -1562,9 +1577,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } // these BreakTypes are effectively page-breaks: don't evenly distribute text in columns before a page break; - SectionPropertyMap* pLastContext = rDM_Impl.GetLastSectionContext(); - if ( pLastContext && pLastContext->ColumnCount() ) - pLastContext->DontBalanceTextColumns(); + if ( pPrevSection && pPrevSection->ColumnCount() ) + pPrevSection->DontBalanceTextColumns(); //prepare text grid properties sal_Int32 nHeight = 1; |