diff options
author | László Németh <nemeth@numbertext.org> | 2020-03-20 15:12:06 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-04-01 17:22:30 +0200 |
commit | b6ef43f678c55330d7d8174201fadc55d5381f42 (patch) | |
tree | 9f2edc2073a9205085f0da45dc88acba58ebd575 /sw/qa | |
parent | c95db2f6a088de12012b88fa8505ae42b0cc90c7 (diff) |
tdf#117448 Writer table: don't clip text on margins
Use area of paragraph margins to show top and bottom
of the clipped text at small fixed line height, like
MSO does. This results noticeable difference in tables,
where small fixed line height is a method to set narrow
table rows, but LibreOffice hid top and bottom of the
characters according to the line height which is smaller,
than the character height.
Note: PDF export has already showed top and bottom of the
characters in this case, and not in tables. But according
to the editing glitches (missing update of the clipped
area during typing), we don't want to extend this behaviour
for not table content, yet.
Change-Id: I7aff5405314948f301bfb71bf35cc1911e194f8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90798
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/data/tdf117448.fodt | 29 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 |
2 files changed, 61 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/data/tdf117448.fodt b/sw/qa/extras/tiledrendering/data/tdf117448.fodt new file mode 100644 index 000000000000..eccadee25974 --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/tdf117448.fodt @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:styles> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text"> + <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" loext:contextual-spacing="false" fo:line-height="115%"/> + </style:style> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:paragraph-properties fo:margin-top="6.01pt" fo:margin-bottom="6.01pt" loext:contextual-spacing="false" fo:line-height="6.01pt"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <table:table table:name="Táblázat1" table:style-name="Táblázat1"> + <table:table-column table:style-name="Táblázat1.A"/> + <table:table-row> + <table:table-cell table:style-name="Táblázat1.A1" office:value-type="string"> + <text:p text:style-name="P1">Text without clipping.</text:p> + </table:table-cell> + </table:table-row> + </table:table> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 1e8baea4312f..e6272136f4ab 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -121,6 +121,7 @@ public: void testVisCursorInvalidation(); void testDeselectCustomShape(); void testSemiTransparent(); + void testClipText(); void testAnchorTypes(); void testLanguageStatus(); void testRedlineNotificationDuringSave(); @@ -184,6 +185,7 @@ public: CPPUNIT_TEST(testVisCursorInvalidation); CPPUNIT_TEST(testDeselectCustomShape); CPPUNIT_TEST(testSemiTransparent); + CPPUNIT_TEST(testClipText); CPPUNIT_TEST(testAnchorTypes); CPPUNIT_TEST(testLanguageStatus); CPPUNIT_TEST(testRedlineNotificationDuringSave); @@ -2382,6 +2384,36 @@ void SwTiledRenderingTest::testSemiTransparent() CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.B)); } +void SwTiledRenderingTest::testClipText() +{ + // Load a document where the top left tile contains table text with + // too small line height, but with top and bottom paragraph margins, + // avoiding of clipping top and bottom parts of the characters. + SwXTextDocument* pXTextDocument = createDoc("tdf117448.fodt"); + + // Render a larger area, and then get the top and bottom of the text in that tile + size_t nCanvasWidth = 1024; + size_t nCanvasHeight = 512; + size_t nTileSize = 256; + std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0); + ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT); + pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), + Fraction(1.0), Point(), aPixmap.data()); + pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, + /*nTilePosY=*/0, /*nTileWidth=*/15360, /*nTileHeight=*/7680); + pDevice->EnableMapMode(false); + Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); + Bitmap::ScopedReadAccess pAccess(aBitmap); + + // check top of the letter "T", it's not a white pixel + Color aTopTextColor(pAccess->GetPixel(98, 100)); + CPPUNIT_ASSERT_LESS(255, static_cast<int>(aTopTextColor.R)); + // check bottom of the letter "g", it's not a white pixel + Color aBottomTextColor(pAccess->GetPixel(112, 228)); + CPPUNIT_ASSERT_LESS(255, static_cast<int>(aBottomTextColor.R)); +} + void SwTiledRenderingTest::testAnchorTypes() { SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); |