summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/PropertyMap.cxx
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2020-08-01 10:11:30 +0300
committerJustin Luth <justin_luth@sil.org>2020-08-01 14:41:27 +0200
commite6b0def979c8e6076f2548a2f4c376867c9e7fdc (patch)
treec140e5e191794d0f1d54dfee536bf6d027b28ad9 /writerfilter/source/dmapper/PropertyMap.cxx
parenta27236b9071d3cf09adbb5bc4fea9edebe96d145 (diff)
NFC writerfilter: change m_nColumnCount to be the # of cols
Change-Id: I00f6fea1ee93bf2598d0cfde73fb2de17f0eb379 --- and not # of columns - 1. Life is already too confusing to add that complication to it. Not quite NFC. There is one place where a column count of 1 would have set column separator/space. I didn't think that would be necessary. Change-Id: I87a7bfb5e746e8b7e4c57ddf40b0740d0ef35aba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99930 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter/source/dmapper/PropertyMap.cxx')
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx31
1 files changed, 16 insertions, 15 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 44e34fad585c..5f8d9a906ba3 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -721,6 +721,7 @@ uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
DomainMapper_Impl& rDM_Impl )
{
uno::Reference< text::XTextColumns > xColumns;
+ assert( m_nColumnCount > 1 && "ApplyColumnProperties called without any columns" );
try
{
const OUString sTextColumns = getPropertyName( PROP_TEXT_COLUMNS );
@@ -728,13 +729,13 @@ uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
xColumnContainer->getPropertyValue( sTextColumns ) >>= xColumns;
uno::Reference< beans::XPropertySet > xColumnPropSet( xColumns, uno::UNO_QUERY_THROW );
if ( !m_bEvenlySpaced &&
- ( sal_Int32(m_aColWidth.size()) == (m_nColumnCount + 1) ) &&
- ( (sal_Int32(m_aColDistance.size()) == m_nColumnCount) || (sal_Int32(m_aColDistance.size()) == m_nColumnCount + 1) ) )
+ ( sal_Int32(m_aColWidth.size()) == m_nColumnCount ) &&
+ ( (sal_Int32(m_aColDistance.size()) == m_nColumnCount - 1) || (sal_Int32(m_aColDistance.size()) == m_nColumnCount) ) )
{
// the column width in word is an absolute value, in OOo it's relative
// the distances are both absolute
sal_Int32 nColSum = 0;
- for ( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol )
+ for ( sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol )
{
nColSum += m_aColWidth[nCol];
if ( nCol )
@@ -743,29 +744,29 @@ uno::Reference< text::XTextColumns > SectionPropertyMap::ApplyColumnProperties(
sal_Int32 nRefValue = xColumns->getReferenceValue();
double fRel = nColSum ? double( nRefValue ) / double( nColSum ) : 0.0;
- uno::Sequence< text::TextColumn > aColumns( m_nColumnCount + 1 );
+ uno::Sequence< text::TextColumn > aColumns( m_nColumnCount );
text::TextColumn* pColumn = aColumns.getArray();
nColSum = 0;
- for ( sal_Int32 nCol = 0; nCol <= m_nColumnCount; ++nCol )
+ for ( sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol )
{
const double fLeft = nCol ? m_aColDistance[nCol - 1] / 2 : 0;
pColumn[nCol].LeftMargin = fLeft;
- const double fRight = nCol == m_nColumnCount ? 0 : m_aColDistance[nCol] / 2;
+ const double fRight = (nCol == m_nColumnCount - 1) ? 0 : m_aColDistance[nCol] / 2;
pColumn[nCol].RightMargin = fRight;
const double fWidth = m_aColWidth[nCol];
pColumn[nCol].Width = (fWidth + fLeft + fRight) * fRel;
nColSum += pColumn[nCol].Width;
}
if ( nColSum != nRefValue )
- pColumn[m_nColumnCount].Width += (nRefValue - nColSum);
- assert( pColumn[m_nColumnCount].Width >= 0 );
+ pColumn[m_nColumnCount - 1].Width += (nRefValue - nColSum);
+ assert( pColumn[m_nColumnCount - 1].Width >= 0 );
xColumns->setColumns( aColumns );
}
else
{
- xColumns->setColumnCount( m_nColumnCount + 1 );
+ xColumns->setColumnCount( m_nColumnCount );
xColumnPropSet->setPropertyValue( getPropertyName( PROP_AUTOMATIC_DISTANCE ), uno::makeAny( m_nColumnDistance ) );
}
@@ -1189,7 +1190,7 @@ bool SectionPropertyMap::FloatingTableConversion( const DomainMapper_Impl& rDM_I
// If there are columns, always create the fly, otherwise the columns would
// restrict geometry of the table.
- if ( ColumnCount() + 1 >= 2 )
+ if ( ColumnCount() > 1 )
return true;
return false;
@@ -1416,7 +1417,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
rDM_Impl.appendTextSectionAfter( m_xStartingRange );
if ( xSection.is() )
{
- if ( m_nColumnCount > 0 )
+ if ( m_nColumnCount > 1 )
ApplyColumnProperties( xSection, rDM_Impl );
ApplyProtectionProperties( xSection, rDM_Impl );
@@ -1515,7 +1516,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
// 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)
- && 0 < m_nColumnCount && !rDM_Impl.IsInComments())
+ && m_nColumnCount > 1 && !rDM_Impl.IsInComments())
{
try
{
@@ -1549,7 +1550,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
Insert( PROP_PAGE_STYLE_LAYOUT, uno::makeAny( style::PageStyleLayout_MIRRORED ) );
}
uno::Reference< text::XTextColumns > xColumns;
- if ( m_nColumnCount > 0 )
+ if ( m_nColumnCount > 1 )
{
// prefer setting column properties into a section, not a page style if at all possible.
if ( !xSection.is() )
@@ -1744,13 +1745,13 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
// Now that the margins are known, resize relative width shapes because some shapes in LO do not support percentage-sizes
sal_Int32 nParagraphWidth = GetPageWidth() - m_nLeftMargin - m_nRightMargin;
- if ( m_nColumnCount > 0 )
+ if ( m_nColumnCount > 1 )
{
// skip custom-width columns since we don't know what column the shape is in.
if ( !m_aColWidth.empty() )
nParagraphWidth = 0;
else
- nParagraphWidth = (nParagraphWidth - (m_nColumnDistance * m_nColumnCount)) / (m_nColumnCount + 1);
+ nParagraphWidth = (nParagraphWidth - (m_nColumnDistance * (m_nColumnCount - 1))) / m_nColumnCount;
}
if ( nParagraphWidth > 0 )
{