diff options
-rw-r--r-- | sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc | bin | 0 -> 22016 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export3.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 6 |
4 files changed, 14 insertions, 2 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc b/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc Binary files differnew file mode 100644 index 000000000000..c45a6c25fd99 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 508636e506b7..05211e47f0f3 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -256,6 +256,12 @@ DECLARE_WW8EXPORT_TEST(testTdf122460_header, "tdf122460_header.odt") CPPUNIT_ASSERT(headerIsOn); } +DECLARE_WW8EXPORT_TEST(testTdf139495_tinyHeader, "tdf139495_tinyHeader.doc") +{ + // In Word 2003, this is one page, but definitely not six pages. + CPPUNIT_ASSERT(getPages() < 3); +} + DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc") { uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 7fca28bb49e5..a9b75588a1b3 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -245,6 +245,10 @@ DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc") CPPUNIT_ASSERT(!pBox->GetLine(eLine)); } } + + //tdf#139495: without the fix, a negative number was converted into a uInt16, overflowing to 115501 + auto nDist = getProperty<sal_uInt32>(getStyles("PageStyles")->getByName("Standard"), "HeaderBodyDistance"); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), nDist); } DECLARE_WW8IMPORT_TEST(testTdf110987, "tdf110987") diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 4753ca2c1114..bf9569c16aab 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -669,8 +669,10 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat, } else { + // Hack alert: these calculations are based on + // #112727# import negative height headers/footers as floating frames inside fixed height headers/footer // #i48832# - set correct spacing between header and body. - const sal_Int32 nHdLowerSpace( std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo ); + const sal_Int32 nHdLowerSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo)); pHdFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwHLo + nHdLowerSpace)); aHdUL.SetLower( static_cast< sal_uInt16 >(nHdLowerSpace) ); pHdFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem( @@ -697,7 +699,7 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat, else { // #i48832# - set correct spacing between footer and body. - const SwTwips nFtUpperSpace( std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp ); + const sal_Int32 nFtUpperSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp)); pFtFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwFUp + nFtUpperSpace)); aFtUL.SetUpper( static_cast< sal_uInt16 >(nFtUpperSpace) ); pFtFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem( |