summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-26 09:37:04 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-29 14:12:56 +0100
commitf164c68296b66d534ed2c9de6da4c01e328959d9 (patch)
tree8770978bbb6ecbc9f73cfabf936f106cfccfc145 /sw/source/filter/xml
parent506a1b1e3d23e1e9cf0cf2e43d00447ccdcbbd92 (diff)
Introduce dedicated SwXMLTableContext::MAX_WIDTH, replacing USHRT_MAX
For one, this should make it more obvious what the magic constant USHRT_MAX meant in the context of SwXMLTableContext::m_nWidth (and shows that it should arguably have value SAL_MAX_UINT16, not USHRT_MAX). For another, at least some Android builds are stuck with a broken C library that defines USHRT_MAX to be of type unsigned int instead of signed int, which caused various -Wsign-compare that are removed as a side effect. Change-Id: If2676954f4e7159b0c0d3656b8bc0186f0771e10 Reviewed-on: https://gerrit.libreoffice.org/48661 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/xmltbli.cxx24
-rw-r--r--sw/source/filter/xml/xmltbli.hxx5
2 files changed, 19 insertions, 10 deletions
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 0d45824e43ca..61b629673256 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1228,6 +1228,10 @@ public:
}
};
+#if __cplusplus <= 201402
+constexpr sal_Int32 SwXMLTableContext::MAX_WIDTH;
+#endif
+
const SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
sal_uInt32 nCol ) const
{
@@ -1479,8 +1483,8 @@ void SwXMLTableContext::InsertColumn( sal_Int32 nWidth2, bool bRelWidth2,
if( nWidth2 < MINLAY )
nWidth2 = MINLAY;
- else if( nWidth2 > USHRT_MAX )
- nWidth2 = USHRT_MAX;
+ else if( nWidth2 > MAX_WIDTH )
+ nWidth2 = MAX_WIDTH;
m_aColumnWidths.emplace_back(nWidth2, bRelWidth2 );
if( (pDfltCellStyleName && !pDfltCellStyleName->isEmpty()) ||
m_pColumnDefaultCellStyleNames )
@@ -2425,7 +2429,7 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
// In this case, the columns get the correct width even if
// the sum of the relative widths is smaller than the available
// width in TWIP. Therefore, we can use the relative width.
- m_nWidth = std::min<sal_Int32>(nRelWidth, USHRT_MAX);
+ m_nWidth = std::min(nRelWidth, MAX_WIDTH);
}
if( nRelWidth != m_nWidth && nRelWidth && nCols )
{
@@ -2679,9 +2683,9 @@ void SwXMLTableContext::MakeTable()
// of the relative column widths as reference width.
// Unfortunately this works only if this sum interpreted as
// twip value is larger than the space that is available.
- // We don't know that space, so we have to use USHRT_MAX, too.
+ // We don't know that space, so we have to use MAX_WIDTH, too.
// Even if a size is specified, it will be ignored!
- m_nWidth = USHRT_MAX;
+ m_nWidth = MAX_WIDTH;
break;
default:
if( pSize )
@@ -2695,14 +2699,14 @@ void SwXMLTableContext::MakeTable()
{
m_nWidth = pSize->GetWidth();
sal_Int32 const min = static_cast<sal_Int32>(
- std::min<sal_uInt32>(GetColumnCount() * MINLAY, USHRT_MAX));
+ std::min<sal_uInt32>(GetColumnCount() * MINLAY, MAX_WIDTH));
if( m_nWidth < min )
{
m_nWidth = min;
}
- else if( m_nWidth > USHRT_MAX )
+ else if( m_nWidth > MAX_WIDTH )
{
- m_nWidth = USHRT_MAX;
+ m_nWidth = MAX_WIDTH;
}
m_bRelWidth = false;
}
@@ -2712,7 +2716,7 @@ void SwXMLTableContext::MakeTable()
eHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH == eHoriOrient
? text::HoriOrientation::NONE : text::HoriOrientation::FULL;
bSetHoriOrient = true;
- m_nWidth = USHRT_MAX;
+ m_nWidth = MAX_WIDTH;
}
break;
}
@@ -2722,7 +2726,7 @@ void SwXMLTableContext::MakeTable()
else
{
bSetHoriOrient = true;
- m_nWidth = USHRT_MAX;
+ m_nWidth = MAX_WIDTH;
}
SwTableLine *pLine1 = m_pTableNode->GetTable().GetTabLines()[0U];
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
index 0f2fc81c8031..7a1868ed1dbe 100644
--- a/sw/source/filter/xml/xmltbli.hxx
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -91,6 +91,11 @@ class SwXMLTableContext : public XMLTextTableContext
sal_uInt32 m_nCurCol;
sal_Int32 m_nWidth;
+ // The maxiumum table width (i.e., maximum value for m_nWidth); musts be >= MINLAY and must also
+ // fit into ColumnWidthInfo::width (of type sal_uInt16), see e.g. the emplacement of
+ // MINLAY<=nWidht2<=MAX_WIDTH into m_aColumnWidths in SwXMLTableContext::InsertColumn:
+ static constexpr sal_Int32 MAX_WIDTH = SAL_MAX_UINT16;
+
SwTableBox *NewTableBox( const SwStartNode *pStNd,
SwTableLine *pUpper );
SwTableBox *MakeTableBox( SwTableLine *pUpper,