diff options
author | Justin Luth <justin.luth@collabora.com> | 2021-04-06 16:40:25 +0200 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2021-04-09 11:20:35 +0200 |
commit | 28a9a92105f3155d82fd9e31095efabd3ec706ea (patch) | |
tree | 6824ff80dd25865ada4b52acca71dc2373223bb6 /sw/qa | |
parent | 3236020c4b8bed68dcf57210c0437f43f4160130 (diff) |
tdf#139495 doc import: prevent negative Int forced into uInt
Don't cast a negative number into a sal_uInt16
and expect good results. (ww8import test)
But for bug 139495 (and ww8export3), the problem area is also
related to pHdFormat->SetFormatAttr(SwFormatFrameSize...
which takes an awt::Size which consists of Longs.
So they should accept negative numbers.
Likely the result is being treated as a uInt somewhere.
And a negative height doesn't mean very much anyway.
There seems to be a fundamental difference between
Word and LO here. Word sets the page margins,
but that is irrelevant to the header/footer,
which have their own distance from the edge.
In LO, the header starts at the page margin,
and the body text must follow the header,
(In Word, the body text can start above the header,
as seen in the ww8export3 unit test.)
[FYI: DOC format (since forever) seems to ignore the header size,
allowing the content to at least overlap with the body text,
but DOCX doesn't have that.
Likely this is #112727# using floating frames hack.
So I'd better not keep messing around in here.]
Change-Id: Ie7bffec8a3de25958cf1f311ff2c8338d4870d99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113681
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/qa')
-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 |
3 files changed, 10 insertions, 0 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") |