• Stephan Bergmann's avatar
    In FitToAcutalSize, keep SwColumn's width >= left + right borders · 0d0119ef
    Stephan Bergmann yazdı
    Given SwColumn::m_nWish is documented as "Desired width, borders included."
    (sw/inc/fmtclds.hxx), it appears that the invariant
    
      GetWishWidth() >= GetLeft() + GetRight()
    
    should always hold for SwColumn instances.
    
    However, during UITest_writer_tests4's test_tdf113284 loading of
    sw/qa/uitest/writer_tests/data/tdf113284.odt, it appears that some five-column
    table is created for which initially all SwColumns'
    
      GetWishWidth() = 13107
      GetLeft() = 144 (except for first SwColumn, where it's 0)
      GetRight() = 144 (except for last SwColumn, where it's 0)
    
    and later FitToActualSize is called reducing each SwColunn to
    
      GetWishWidth() = 286
    
    so that for most SwColumns (except first and last), GetLeft() + GetRight() = 288
    would exceed GetWishWidth().  And then (still during loading of the test's
    document), SwFormatCol::CalcPrtColWidth (sw/source/core/layout/atrfrm.cxx) is
    called for such a problematic SwColumn, trying to subtract from its
    GetWishWidth() (the result of SwFormatCol::CalcColWidth) both GetLeft() and
    GetRight(), and store that into sal_uInt16 nRet.  Which triggers Clang's
    -fsanitize=implicit-signed-integer-truncation "runtime error: implicit
    conversion from type 'int' of value -2 (32-bit, signed) to type 'sal_uInt16'
    (aka 'unsigned short') changed the value to 65534 (16-bit, unsigned)".
    
    So make sure that FitToAcutalSize upholds that presumed SwColumns invariant,
    shrinking the borders as necessary.
    
    Change-Id: I3f6fc07e65a0fc5d5f58c99f1dcdea4467b825f0
    Reviewed-on: https://gerrit.libreoffice.org/68463
    Tested-by: Jenkins
    Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
    0d0119ef