summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2022-05-27 13:12:27 +0200
committerLászló Németh <nemeth@numbertext.org>2022-06-07 19:28:48 +0200
commit8741fd0e0ae9e346de2e09887f0668b831c9b48b (patch)
tree97cf3bb7a883c9e119debe6678e0cca57bdf1faf
parent5a079652c1b1f968a851f47995b0a65b84d2d192 (diff)
tdf#43244 sw: show stripped line-end spaces on margin
in View->Formatting Marks mode instead of hiding them This way it's possible to avoid interoperability issues better, when these (now visible) spaces are stripped only in Writer, but not in MSO, resulting different layout, i.e. bad paragraph alignment, because the users can notice the extra spaces and remove them in Writer. Extend SwHolePortion::Paint() to paint its text, what is probably just a bunch of spaces. It's an initial fix for tdf#43100, tdf#120715 and tdf#104683 (cursor movement on the hidden spaces, end of paragraph sign before the hidden spaces, unable to select spaces after the margin). Follow-up to commit 93d7bdcb855362b88cdcfcb18ea401d89da973fb "fdo#33167, i#20878: Show spaces at the end of line". Co-authored-by: Tibor Nagy (NISZ) Change-Id: I48df3b41af37c77fd594bb6776ca30e845c51490 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135104 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/tiledrendering/data/tdf43244_SpacesOnMargin.odtbin0 -> 9791 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx46
-rw-r--r--sw/source/core/text/portxt.cxx15
3 files changed, 59 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/data/tdf43244_SpacesOnMargin.odt b/sw/qa/extras/tiledrendering/data/tdf43244_SpacesOnMargin.odt
new file mode 100644
index 000000000000..76c293dc0bd5
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/tdf43244_SpacesOnMargin.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 42f7f9e21889..7354782563c4 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2809,6 +2809,52 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testPilcrowRedlining)
comphelper::dispatchCommand(".uno:ControlCodes", {});
}
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTdf43244_SpacesOnMargin)
+{
+ // Load a document where the top left tile contains
+ // paragraph and line break symbols with redlining.
+ SwXTextDocument* pXTextDocument = createDoc("tdf43244_SpacesOnMargin.odt");
+
+ // show non printing characters, including pilcrow and
+ // line break symbols with redlining
+ comphelper::dispatchCommand(".uno:ControlCodes", {});
+
+ // Render a larger area, and then get the colors from the right side of the page.
+ size_t nCanvasWidth = 1024;
+ size_t nCanvasHeight = 512;
+ size_t nTileSize = 64;
+ 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(730, 120), Size(nTileSize, nTileSize));
+ Bitmap::ScopedReadAccess pAccess(aBitmap);
+
+ //Test if we see any spaces on the right margin in a 47x48 rectangle
+ bool bSpaceFound = false;
+ for (int i = 1; i < 48 && !bSpaceFound; i++)
+ {
+ for (int j = 0; j < i; j++)
+ {
+ Color aColor2(pAccess->GetPixel(j, i));
+ Color aColor1(pAccess->GetPixel(i, j + 1));
+
+ if (aColor1.GetRed() < 255 || aColor2.GetRed() < 255)
+ {
+ bSpaceFound = true;
+ break;
+ }
+ }
+ }
+ CPPUNIT_ASSERT(bSpaceFound);
+
+ comphelper::dispatchCommand(".uno:ControlCodes", {});
+}
+
CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testClipText)
{
// Load a document where the top left tile contains table text with
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 140e29c168cc..a5ae0ea7e287 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -760,8 +760,10 @@ void SwHolePortion::Paint( const SwTextPaintInfo &rInf ) const
if( !rInf.GetOut() )
return;
+ bool bPDFExport = rInf.GetVsh()->GetViewOptions()->IsPDFExport();
+
// #i16816# export stuff only needed for tagged pdf support
- if (!SwTaggedPDFHelper::IsExportTaggedPDF( *rInf.GetOut()) )
+ if (bPDFExport && !SwTaggedPDFHelper::IsExportTaggedPDF( *rInf.GetOut()) )
return;
// #i68503# the hole must have no decoration for a consistent visual appearance
@@ -779,7 +781,16 @@ void SwHolePortion::Paint( const SwTextPaintInfo &rInf ) const
pFontSave.reset(new SwFontSave( rInf, pHoleFont.get() ));
}
- rInf.DrawText(" ", *this, TextFrameIndex(0), TextFrameIndex(1));
+ if (bPDFExport)
+ {
+ rInf.DrawText(" ", *this, TextFrameIndex(0), TextFrameIndex(1));
+ }
+ else
+ {
+ // tdf#43244: Paint spaces even at end of line,
+ // but only if this paint is not called for pdf export, to keep that pdf export intact
+ rInf.DrawText(*this, rInf.GetLen());
+ }
pFontSave.reset();
pHoleFont.reset();