83 Commits
Author SHA1 Message Date
Patrick Luby 0c54c09aeb tdf#155266 force flush after scrolling
This is the second attempt to force a flush after scrolling.
Commit 9c0803edd1 worked on
Mac Silicon but not Mac Intel.

So, instead of calling [NSApp currentEvent] to determine if
scrolling has occurred, mark the AquaSalFrame whenever a
scrollwheel or mouse drag event is dispatched so the frame
will be flushed in the next AquaSalFrame::Flush() call.

Change-Id: I2d0b99d2cd1167e92c7fd89bf53b2f30ab85a165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159003
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-11-06 20:27:08 +01:00
Patrick Luby 55a0fba060 tdf#155266 revert commit 9c0803edd1
While commit 9c0803edd1 fixed tdf#155266
on Mac Silicon, it didn't fix that bug on Mac Intel.

Change-Id: I4dc9eb3a5da319a0c8f58bcdea5abfc3e4ec4a0c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158997
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-11-06 18:28:44 +01:00
Patrick Luby 9c0803edd1 tdf#155266 flush when scrolling or dragging
Delaying flushing until the dispatch level returns to zero causes
scrolling via the scrollwheel or mouse drag to appear laggy and
jerky.

Change-Id: Ib70e7766435baa765dd0d1d704ba2fac87f7fccc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158853
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-11-03 20:55:04 +01:00
Patrick Luby e4821ce3e0 tdf#158014 make image immutable after using Skia to invert
I can't explain why inverting using Skia causes this bug on
macOS but not other platforms. My guess is that Skia on macOS
is sharing some data when different SkiaSalBitmap instances
are created from the same OutputDevice. So, mark this
SkiaSalBitmap instance's image as immutable so that successive
inversions are done with buffered bitmap data instead of Skia.

Change-Id: I8acf90561c48edba14a5f43d16f375f15f25820c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158880
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2023-11-03 18:33:23 +01:00
Patrick Luby 2a5dac6d75 tdf#158047 allow the tdf#157635 fix for palettes with 64 entries
Change-Id: Ib4e4deb5f7e332a7ef3a9231e993231068c21c4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158885
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-11-03 18:32:26 +01:00
Patrick Luby 7a1250b17c Fix testDelayedScaleAlphaImage unit test
Do not return the alpha mask if it is awaiting pending scaling.
Pending scaling has not yet been done at this point since the
scaling is done in the code following this block.

Change-Id: I995d7f7eca4190f0a8b2094928bd92f718f1d5bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158599
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-28 22:45:34 +02:00
Patrick Luby 4cf636fab3 tdf#157790 invert alpha mask
Due to commit 81994cb2b8,
the alpha mask needs to be inverted.

Change-Id: I4771c5f6f3a08fb210b62a0533df895a4a476058
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158410
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-10-25 07:51:13 +02:00
Patrick Luby d8ec731e61 tdf#157795 set color to black outside of of bitmap bounds
Due to commit 81994cb2b8,
transparent areas are now black instead of white.

Change-Id: I9456bb2603d4968a5d5df0a7bdbff48ce9a8e2f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158355
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-23 18:29:08 +02:00
Patrick Luby a98000c028 tdf#157793 limit tdf#157635 fix to only larger palettes
I don't know why, but the fix for tdf#157635 causes
images with a palette of 16 entries to be inverted.
Is this the only condition for masking out black
pixels in non-transparent animation frames?

Change-Id: I9550baab4dc4d9b75a21c8af2f6c0b5eb8e46c12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158214
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-20 14:41:04 +02:00
Patrick Luby fb68f0761c tdf#157565 show tooltip if any parent window is the key window
Commit b69db38a38b09e158e8d46d8b717db85860ca874 caused tooltips
to fail to appear if their immediate parent window was not the
key window. So, look through the parent window's parent windows
and, if any of those windows are the kwy window, show the tooltip.

Change-Id: Icf1aed1144fdeac03b4b208de8ed8ee2db8ad4a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158212
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-20 02:20:42 +02:00
Patrick Luby 5d347c3d72 tdf#157680 scale down size and adjust size and scale factor for /BBox
The size of an embedded PDF files is multiplied by
PDF_INSERT_MAGIC_SCALE_FACTOR for platforms like macOS so undo that
by adjusting the size and scale factor.

For some unknown reason, when exporting the following PDF, the
estimated size of embedded PDF charts are 20x larger than expected.
This only occurs on macOS so possibly there is some special conversion
from MapUnit::MapPoint to MapUnit::MapTwip elsewhere in the code:

  https://bugs.documentfoundation.org/attachment.cgi?id=190109

Change-Id: Id0563466fea3d7a3a0419787ec9da45f0c1d2e0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157852
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-19 18:25:14 +02:00
Patrick Luby fc69d6b227 tdf#101376 don't detach thread if it is the main thread on macOS
On macOS, many AWT classes do their work on the main thread
deep in native methods in the java.awt.* classes. The problem
is that Oracle's and OpenJDK's JVMs don't bracket their
"perform on main thread" native calls with "attach/detach
current thread" calls to the JVM.

Change-Id: I0859dc9e20f34bd0b43bb321898507764fd530fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157985
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-15 15:33:09 +02:00
Patrick Luby 82ed49b81e tdf#157613 make sure surface is not a null pointer
Change-Id: I8e3c1be3f05f7ccc1f3ba00093cd71a564e5ae9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157848
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Tested-by: Patrick Luby <plubius@neooffice.org>
2023-10-11 22:46:58 +02:00
Patrick Luby c3073c8122 tdf#157502 and tdf#157652 invert alpha mask
Due to the switch from transparency to alpha in commit
81994cb2b8, invert the alpha
mask.

Change-Id: Ib6df3523be36ba5d5aaf3887557d4a6a8fa6098c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157731
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-10-09 20:56:33 +02:00
Patrick Luby b2ca39bc5e tdf#157576 and tdf#157635 mask out black pixels
Due to the switch from transparency to alpha in commit
81994cb2b8, mask out black
pixels in bitmap.

Change-Id: I7cc8c39c20d8ec4fed026c3e27fce24396815d68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157665
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-06 22:31:00 +02:00
Patrick Luby fe3fa1699f tdf#156881 Disable Metal with AMD Radeon Pro 5XXX GPUs on macOS Catalina
When running macOS Catalina on a 2019 MacBook Pro, unexpected drawing
artifacts are drawn so disable Metal for the AMD Radeon Pro GPUs listed
for that model in https://support.apple.com/kb/SP809.

Change-Id: Iffe44da1f07af2f3bbc367051b5ea4d522216eb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157443
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-10-01 16:44:47 +02:00
Patrick Luby 53c27f66fc Fix iOS build breakages when building on macOS Sonoma
Change-Id: I347e48e9da69c8c9b15581a5afa5c61cdd1d380d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157411
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Patrick Luby <plubius@neooffice.org>
2023-10-01 15:55:55 +02:00
Patrick Luby d43e2a9214 Let SkBitmap determine when it is safe to delete the pixel buffer
Also, make bitmap immutable to avoid making a copy in bitmap.asImage()
and, just to be safe, flush the canvas after drawing the pixel buffer.

Change-Id: I3ac99cf4acf0bf4c8b274dc73295ca7b9f386c70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157333
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-27 19:25:59 +02:00
Patrick Luby c43d11cbba tdf#156539 Draw the gradient with polypolygonal clip when using Skia
For some unkown reason, the previous "draw gradient with XOR, draw
polygon with N0, and draw gradient again with XOR" does not work
with Skia/Raster (at least on macOS). Fortunately, Skia supports
polypolygonal clipping so just clip and draw the gradient.

Change-Id: Id069160312a270096f5ec9c670615eb95ec6200b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157199
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-24 02:25:12 +02:00
Patrick Luby f4c2c7c79c tdf#157312 Don't change priority
Instances of this class are constructed with
TaskPriority::POST_PAINT, but then it was set to
TaskPriority::HIGHEST when reused. Flushing
seems to be expensive (at least with Skia/Metal) so keep the
existing priority when reused.

Change-Id: Ieb40cd6122f543f76e66456cc92a8643e2320d73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157162
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-22 15:03:43 +02:00
Patrick Luby c2d7c8e5c6 tdf#156842 increase scale for external PDF data
For some unknown reason, the scale is 8 times larger than for
non-external PDF XObjects.

This fix also allows the CppunitTest_vcl_pdfexport to run
successfully on macOS.

Change-Id: I166914e6ac575c50985efba3fb7a38ec758dea1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157090
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2023-09-20 08:14:19 +02:00
Patrick Luby 4942aa1533 tdf#156808 force an alpha mask to be created even if it has no alpha
We need an alpha mask, even if it is totally opaque, so that
drawinglayer::primitive2d::ProcessAndBlurAlphaMask() can be called.
Otherwise, blurring of edges will fail in cases like running in a
slideshow or exporting to PDF.

Change-Id: If03b32a8a22ed960f1475710a9831cab33799b60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156903
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-14 01:52:22 +02:00
Patrick Luby 798de29936 tdf#157086 invert the blur mask instead of the alpha mask
An invert is needed to fix tdf#156808 but inverting the alpha mask
causes tdf#157086 so invert the blur mask instead.

Change-Id: Id695d04f008932caadb0fc2b477b0a4b152fa66c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156854
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-12 20:51:48 +02:00
Patrick Luby 26313599b0 attempt to fix macos jenkins hangs - part 3
oox::xls::WorkbookFragment::finalizeImport() calls
AquaSalInstance::DoYield() with bWait set to true. But
since unit tests generally have no expected user generated
events, we can end up blocking and waiting forever so
don't block and wait when running unit tests.

Change-Id: I14cfdb88f04b82f49e8c15e554e5c4b4053e77b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156826
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-12 14:09:40 +02:00
Patrick Luby be9d7bee88 attempt to fix macos jenkins hangs - part 2
Commit a1174a5f1e attempts to fix
sporadic blocking and waiting when fetching a native event so
use the same fix in AquaSalInstance::AnyInput() just to be safe.

Change-Id: I1505b6089f11be825bd13e0219a305159dfc324f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156803
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-09-10 23:25:06 +02:00
Patrick Luby e7496f4156 tdf#150610 fix broken rendering of text meta actions
Even when drawing to a VirtualDevice where antialiasing
is disabled, text will still be drawn with some
antialiased pixels on HiDPI displays. So, expand the
size of the VirtualDevice slightly to capture any of
the pixles drawn past the edges of the destination
bounds.

Change-Id: Ibcba8234708d8784c12f984289ec0a8fcad6694e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156098
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-27 23:11:29 +02:00
Patrick Luby 462f1c43cc tdf#156866 use mSize instead of mPixelSize for inverted surface
Commit 5baac4e531 switched to setting
the surface size to mPixelsSize in an attempt to avoid downscaling
mImage but since it causes tdf#156866, revert back to setting the
surface size to mSize.

Also, in release builds, tdf#156629 and tdf#156630 reappear in many
cases because a BitmapInfoAccess is in a debug block. So, instead
of relying on other code to a create a BitmapInfoAccess instance,
create one here to force the alpha mask to handle any pending
scaling and make the alpha mask immutable.

Change-Id: If9f0dfb7b9a82cf7a3e402965ceffd42eace4c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156022
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-24 15:14:43 +02:00
Patrick Luby 2f5bc5989b tdf#156854 invert alpha mask for macOS native menu item images
At the time of this change, only the AquaSalMenu class calls this
function so it should be safe to invert the alpha mask here.

Change-Id: Id67ad0f453bbf88b43d37087eef36a27ced3ad37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155977
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-23 16:48:44 +02:00
Patrick Luby 7d745697ee tdf#156853: Fix PDF export of bitmap color fonts
Emoji bitmaps need to have their alpha mask inverted like is done
with transparent images and shapes. So, invert the alpha mask of
Type 3 font bitmaps.

Also, add links to test documents for future development and testing.

Regression from:

commit 81994cb2b8
Date:   Fri Apr 16 20:33:10 2021 +0200

    Convert internal vcl bitmap formats transparency->alpha (II)

Change-Id: I18223a231ab751945883ede029d660949a406f7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155960
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-23 13:25:44 +02:00
Patrick Luby 8dc8413b4f Revert "tdf#156853: Fix PDF export of bitmap color fonts"
This reverts commit 3e20c3e73c.

Reason for revert: This breaks every single fix that I have made for exporting alpha masks to PDF. A different solution is needed as the invert needs to be where it was to snapshot the AlphaMask.

Change-Id: I5f743b67067dff43a2324d6ca9bc1f444e245a12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155917
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Tested-by: Patrick Luby <plubius@neooffice.org>
2023-08-22 14:36:44 +02:00
Patrick Luby f9d5887697 Eliminate special alpha mask inversions when Skia is disabled
Commit ad1f69d28d fixed an alpha
blending bug in AlphaMask::BlendWith(const AlphaMask&) so almost
all of the special alpha mask inversions when drawing transparent
meta actions are no longer needed and so, when Skia is disabled,
the same inversions as Skia are now used.

The one special alpha mask inversion that is still needed when Skia
is disabled is when exporting to PDF documents like the following
with transparent gradients:

  https://bugs.documentfoundation.org/attachment.cgi?id=188084

Change-Id: I3212a38916be3d238bb9c868b161031616baf0a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155859
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-19 19:31:46 +02:00
Patrick Luby 5baac4e531 Reimplement fix for tdf#156629 and tdf#156630
Reimplement fix in commit 926c5246b6
in an attempt to reduce the fix's performance hit. Instead of
invoking EnsureBitmapData() and converting the SkImage to a
memory buffer, any pending scaling on alpha masks is handled by
creating a new, scaled SkImage.

Note that in commit 926c5246b6,
EnsureBitmapData() was invoked which converted the SkImage to a
memory buffer. That in turn would make Invert() a noop which
fixed the related bug where an image has been opened and, before
it has been printed or run in a slideshow, the alpha mask would
unexpectedly be inverted. So keep this immutable behavior without
calling EnsureBitmapData() by adding a new mutability flag.

Change-Id: I99dc272b40c53664ea49333402a6a637b1548a5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155850
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-19 15:59:14 +02:00
Patrick Luby f6cae6f1b6 tdf#144073 and tdf#147645: use bounds and angle for gradient
Passing an expanded, rotated polygon noticeably modifies the
drawing of the gradient in a slideshow due to moving of the
starting and ending colors far off the edges of the drawing
surface. So try another way and set the angle of the
gradient and draw only the unadjusted bounds.

Change-Id: I95441dfa3215396d5bc7edfa9f985335480b37de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155729
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-16 13:47:31 +02:00
Patrick Luby 926c5246b6 Related tdf#156630 and tdf#156629 force snapshot of alpha mask
On macOS, with Skia/Metal or Skia/Raster with a Retina display
(i.e. 2.0 window scale), the alpha mask gets upscaled in certain
cases.

This bug appears to be caused by pending scaling of an existing
SkImage in the bitmap parameter. So, force the SkiaSalBitmap to
handle its pending scaling.

This change consolidates the three duplicate fixes added in the
following commits into the AlphaMask(const Bitmap&) constructor.

  commit 12fd870113
  commit ce2d9f5dd4

From my light testing, the bitmap's SkImage is not scaled except
when running macOS with a Retina display. The only exception is
that this fix will be triggered on all platforms when exporting
to PDF images with an alpha mask.

Change-Id: Iea5afd55aac984ca606b2b4b44e457d81d76fac0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155568
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-13 19:46:13 +02:00
Patrick Luby ce2d9f5dd4 Related tdf#156629 force snapshot of alpha mask
On macOS, with Skia/Metal with a Retina display (i.e. 2.0 window
scale), the alpha mask gets upscaled for the font color and the
character background color icons in Writer's properties sidebar
with most icon sets. The Breeze and Colibre icon sets running in
light mode are the most obvious cases.

This bug appears to be caused by asynchronous rendering of the
returned image. So, we force a copy of the alpha mask in case it
changes before the image is actually drawn.

Change-Id: Ie3aa3b26acaee4bd9173e6b356137980c070c7c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155562
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-10 19:39:56 +02:00
Patrick Luby 12fd870113 tdf#156630 eliminate opaque parts when drawing animated PNG images
Due to the switch from transparency to alpha in commit
81994cb2b8, flip the background colors
for the VirtualDevices and invert an alpha mask.

On macOS, with Skia/Raster with a Retina display (i.e.  2.0 window
scale), the alpha mask gets upscaled. Also, when Skia is enabled,
the alpha mask gets inverted in the first export to PDF after
launching the application. These two bugs appear to be caused by
asynchronous rendering of the returned bitmap. So, we force a copy
of the alpha mask in case it changes before the bitmap is actually
drawn.

Lastly, respect system animation settings when determining if the image
should be animated.

Change-Id: I8144691a6c99bf8361b301b88d22172991463f26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155429
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-10 14:01:10 +02:00
Patrick Luby b3053b63c6 Revert "tdf#156540 invert alpha when drawing sprites"
This reverts commit 52637f46cc.

Reason for revert: A better fix is being worked on in https://gerrit.libreoffice.org/c/core/+/155378

Change-Id: I91c6ed96bdd202612d4b10458c015532b9162c1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155308
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Tested-by: Patrick Luby <plubius@neooffice.org>
2023-08-06 01:48:12 +02:00
Patrick Luby 52637f46cc tdf#156540 invert alpha when drawing sprites
Due to the switch from transparency to alpha in commit
81994cb2b8, a sprite's
alpha mask needs to be inverted when Skia is enabled and
the fAlpha value needs to be inverted when Skia is disabled.

Change-Id: Ie802924b07ddbab536a2eddb57bf82e5146cffe7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155358
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-05 22:58:28 +02:00
Patrick Luby fe9efb6d5e Related tdf#156508 fix rendering of the About dialog .svg
After 0e7d4ea64f, white polygons are
drawn in the LibreOffice about .svg in both the About dialog and with
the .svg in a document.

Creating the mask with COL_WHITE instead of COL_BLACK appears to fix
this without causing tdf#156508 to reoccur.

Change-Id: I886451245126c2b7f936e30275965148bf029627
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155362
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-05 14:27:56 +02:00
Patrick Luby 73adf93acc Revert "tdf#144072 prevent use of a deleted pointer"
This reverts commit 01a1d2a849.

That commit appeared to fix tdf#144072 but it only delays the crash as the reportdesign module will keep reusing the same SdHdl pointer that has already been deleted.

Change-Id: I8e416b0376aa8724b697f54ed45f58341b47dc2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155181
Tested-by: Patrick Luby <plubius@neooffice.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-01 21:23:30 +02:00
Patrick Luby 01a1d2a849 tdf#144072 prevent use of a deleted pointer
BegDragObj_createInvisibleObjectAtPosition() may clear the handle
list and that will delete the SdrHdl instances owned by this section
view so set _pHdl to null if it has been deleted during the call.

Change-Id: I89606958f8a76a2c35685d1aff6b0159739a464a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155119
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-08-01 14:27:49 +02:00
Patrick Luby ccc31ed4d9 tdf#156470 add SAL_INFO calls for debugging
In the verious LibreOffice samples attached to tdf#156470, it appears
that LibreOffice spends a lot of time the GetTextArray() calls in
SvxFont::QuickGetTextSize(). So add logging to determine if any of
the GetTextArray() calls are returning unusual sizes.

Change-Id: Ie6f0fcc85396b47342b6a93180d4bc9873420931
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155072
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-31 18:11:53 +02:00
Patrick Luby f324cba860 tdf#156506 Fix failure to draw copy border on Windows
Revert portion of commit 9d68c794d6
that stops the animated border when a copy action is performed in
a different document by cancelling the animated border.

While the change worked on macOS and Linux, on Windows it stops
the currently active copy border so revert this fix.

Change-Id: I0dbdc8b1bf3077eecadbbe591a27e60ef3d48b7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155067
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-30 16:37:22 +02:00
Patrick Luby 1184a0130e tdf#144053 Compare version to ProductKey entry in bootstraprc
Using the mdls command fails if macOS Spotlight is disabled for the path
selected by the user. So, instead, check if the path contains a matching
"ProductKey=<version>" line in its Contents/Resources/bootstraprc file.

Change-Id: Idbf8e2712b9fae8efa0997cf5c5c0f3fa6e68658
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154718
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-26 14:40:02 +02:00
Patrick Luby e7ff004892 Regression: eliminate white lines in infobar's close button
When drawing the close button's background, the right and bottom need to be
extended by 1 or there will be a white line on both edges.

Change-Id: I67dcad422c0f33af3035621cd624c1ddafc89d00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154871
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-24 21:14:14 +02:00
Patrick Luby 9d68c794d6 tdf#155414 include system "reduce animation" preferences
Allow the system's "reduce animation" preferences to disable the
Calc animated border when copying a selection of cells.

Also, fix failure to stop the animated border when a copy action is
performed in a different document by cancelling the animated border.
This transferable has lost ownership of the system clipboard so,
in essence, the previous copy action that created this transferable
has been cancelled.

Change-Id: I4da6d557c5dbf653c38a99eb7a16d961843a41d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154752
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-24 18:30:25 +02:00
Patrick Luby 3c63cb1298 tdf#156361 use slow blending path if alpha mask blending is diabled
SkiaSalGraphicsImpl::blendBitmap() fails unexpectedly in the following
cases so return false and use the non-Skia alpha mask blending code:
- Unexpected white areas when running a slideshow or printing:
    https://bugs.documentfoundation.org/attachment.cgi?id=188447
- Unexpected scaling of bitmap and/or alpha mask when exporting to PDF:
    https://bugs.documentfoundation.org/attachment.cgi?id=188498

Change-Id: I13ae613f24bff4cd018110a08ed70559a1714687
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154678
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-20 19:58:35 +02:00
Patrick Luby 693411e60c Related tdf#155125: add MacPorts to GPG's fallback search on macOS
Change-Id: I52a5031b531dc542b2eea72191a1c240f78820bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154474
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-15 02:25:39 +02:00
Patrick Luby 3c7b230910 tdf#155125 add "Encrypt with GPG key" checkbox in macOS native save dialog
Change-Id: I85cdf71c1beaef51e8c66e30aa5b0c7de5f4b72c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154396
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-13 22:35:30 +02:00
Patrick Luby dd1d74281a Natively draw to pixel buffer with RBGA pixel format in iOS app
Change-Id: I31917f914ed22bebffc52777cb974224d08bed83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154367
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
(cherry picked from commit 272de6ec30021fdbda38a1bd84a3036a0afc73d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154325
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-12 22:14:58 +02:00
Patrick Luby aa5c3d32d7 Fix failure to generate the correct color mask
OutputDevice::ImplDrawRotateText() draws black text but
that will generate gray pixels due to antialiasing so
count dark gray the same as black, light gray the same
as white, and the rest as medium gray.

The results are not smooth since LibreOffice appears to
redraw these semi-transparent masks repeatedly without
clearing the background so the semi-transparent pixels
will grow darker with repeatedly redraws due to
cumulative blending. But it is now better than before.

Change-Id: If64ff5ab52a6e441b587aa3c3c12b08137ecf34e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154079
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-07-06 00:46:54 +02:00
Patrick Luby b31c9722d1 Fix nightly build failures on Mac Intel
When adding entitlements in a debug, non-codesigned build, the
codesign command fails on some Mac Intel machines. Since this
command is only executed in non-release builds, ignore any
failures.

Change-Id: I4d89e03bbbc00725b2902446f2abbb99f273eab7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153269
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-19 19:15:24 +02:00
Patrick Luby b6299c9e56 tdf#146626 catch IndexOutOfBoundsException when fetching accessible children
com::sun::star::accessibility::XAccessibleContext::getAccessibleChild()
can throw an IndexOutOfBoundsException exception even when fetching with
an index that is positive and less than the value returned by a call to
the accessible context's getAccessibleChildCount() method so put every
getAccessibleChild() call in a try/catch block.

Note: this is actually expected behavior even though it is rare. For
example, accessibility::AccessibleTextHelper_Impl::getAccessibleChild()
uses the following code snippet to throw such an exception:

    if( 0 > i || i >= getAccessibleChildCount() ||
        GetTextForwarder().GetParagraphCount() <= i )

In the case of tdf#146626, getAccessibleChildCount() returns 22 but
getAccessibleChild(1) throws such an exception due to the last
condition in the above code snippet.

Change-Id: If974afb7b9178faa99b91dcd79eb5f169bbfe13e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153160
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-16 18:38:55 +02:00
Patrick Luby ca060dac4b Fix hanging when selecting a column or row in Calc
When a Calc column is selected, the child count will be
at least a million. Constructing that many C++ Calc objects
takes several minutes even on a fast Silicon Mac so apply
the maximum table cell limit here.

Change-Id: I4e3ebf9fdf7367620313e4e10dd0918de9d6bffb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152853
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-12 02:02:11 +02:00
Patrick Luby 312adca5c5 Fix iOS build breakage
Two new functions that are used only on macOS were added in commit
75dc3a54fc.

Change-Id: I18d0f7aaa9d1ca6634b13eafc76b4fd39dfa52ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152771
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-08 22:50:35 +02:00
Patrick Luby 67b808eea0 Set entitlements in non-release in $(INSTROOTBASE) and .dmg package
Also, when building a .dmg for macOS, skip codesigning for non-release
builds, both with and without the macOS sandbox, if there is no identity
set but set entitlements to allow Xcode's Instruments application to
connect to the application.

Lastly, add entitlements when building soffice in $(INSTROOTBASE) if
this is a non-release build.

Change-Id: I764bf5bd5d44e878669c4287906e6efd6aac593f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152655
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-07 22:08:50 +02:00
Patrick Luby 75dc3a54fc Partial fix tdf#155376 use NSAccessibilityElement instead of NSView
On macOS, accessibility is implemented by creating a native NSView
for each C++ accessible element. The problem with using an NSView
for each element is that NSViews are very slow to add to or remove from
an NSWindow once the number of NSViews is more than a thousand or so.

Fortunately, Apple added a protocol that allows adding a native
accessible element using the lightweight NSAccessiblityElement class.
The topmost NSAccessiblityElement elements are connected to the single
SalFrameView in each NSWindow but since NSAccessiblityElements are not
NSViews, they are not connected to any of NSWindow's event or draw
dispatching. This makes NSAccessiblityElements significantly faster to
add to or remove from an NSWindow with no apparent loss in functionality.

Note: this change is a subset of the LibreOffice 4.4 code changes that I
wrote for NeoOffice.

Change-Id: I408108d57217db407512dfa3457fe26d2ab455de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152717
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-06-07 21:48:54 +02:00
Patrick Luby b76a3bdc99 Revert "Script that adds "com.apple.security.get-task-allow" entitlement to soffice"
This reverts commit ff95984c8e.

Reason for revert: The script was just a quick hack that I whipped up during other development work and I didn't know how to integrate it into debug builds by default. @Christian Lohmeier reviewed the script and noted the existing build scripts that add entitlements based on build type where I can put this new entitlement.

Change-Id: I4246639e99a62c63fb1ba38b19cac0442c71c0a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152031
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-05-29 01:39:30 +02:00
Patrick Luby cb4fb9e31e Related tdf#tdf155376 fix minor memory leaks
Change-Id: I9cdc5fb38ffba113e3d069d9d766dbe1a82c492d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152352
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
(cherry picked from commit 7ae89a2ad89c9e7702fbd2b31269ee4c61fe5bcb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152316
2023-05-29 01:10:01 +02:00
Patrick Luby 1bf7da6098 Partial fix tdf#146626 Catch uncaught DisposedException
Fix crash due to an uncaught DisposedException thrown by
SwAccessibleParagraph::getTextRange() by using the same try/catch
block in -[A11yWrapper accessibilityAttributeValue:] in
-[A11yWrapper accessibilityAttributeValue:forParameter].

Change-Id: Ifcaec3eb2d76f32bddc56a1242f6d86f8b90f782
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152361
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
(cherry picked from commit f8cc6f960e8aeb37547d447fed2b2c6e6ddc02e3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152317
2023-05-29 00:24:26 +02:00
Patrick Luby ff95984c8e Script that adds "com.apple.security.get-task-allow" entitlement to soffice
To connect Xcode's Instruments application to profile LibreOffice, the
"com.apple.security.get-task-allow" entitlement must be added to the
soffice executable.

This script will set the "com.apple.security.get-task-allow" entitlement
instdir/LibreOfficeDev.app/Contents/MacOS/soffice executable so that
profiling can be done using a local build.

Credit for documenting this Xcode requirement goes to the following blog:
  https://cocoaphony.micro.blog/2022/10/29/solving-required-kernel.html

Change-Id: I547edf7c1ad340267e9ed4c396fc723b7ea719be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151981
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-05-18 21:53:08 +02:00
Patrick Luby 976cd8c1c1 Disable test that always fails with Apple Retina displays
With a HiDPI display on macOS, each logical pixel is backed
by 4 physical pixels. Turning off antialiasing and drawing a
diagonal line causes many logical pixels on the edge of the
diagonal line to have a mixture of white and blue physical
pixels. Then, when such logical pixels are fetched via
BitmapEx::GetPixelColor(), their underlying 4 white and blue
physical pixels are combined into blended shades of white
and blue.

Change-Id: I1aca121f294ce2f4cb7b17a93b904425c8049f80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151705
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-05-12 19:28:11 +02:00
Patrick Luby bf2cf74730 tdf#152173 Don't display tooltip windows when mousing over non-key windows
Don't display tooltips when mousing over non-key windows even if the
application is active as the tooltip window will pull the non-key
window in front of the key window.

Change-Id: I425b9af09de0272ebee84a218e2e5ae8c200a4e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151646
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-05-10 23:26:59 +02:00
Patrick Luby a0d8251336 tdf#147342 Notify Skia that the window's backing properties changed
Change-Id: I4185a240a2ca6df1c92e86ff9950f86234d4ace8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146142
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-01-26 14:19:29 +00:00
Patrick Luby de1d75a0cd tdf#148453 Fix crash by turning off optimization for Objective-C selector
The default attributes sequence sometimes crashes when it is released but
only when compiler optimization is enabled, so disable optimization for the
+[AquaA11yTextAttributesWrapper createAttributedStringForElement] selector.

Also, disabling optimization by itself is apparently not enough to stop
the crashing. Acquiring the solar mutex during native accessibility calls
is also needed. Native accessibility calls are called from native input
sources in [NSApp nextEventMatchingMask:untilDate:inMode:dequeue:]. Since
AquaSalInstance::DoYield() releases the solar mutex before calling
[NSApp nextEventMatchingMask:untilDate:inMode:dequeue:], we need to
always acquire the solar mutex during all NSAccessibility selectors (both
the old informal protocol and the newer formal protocol) that we implement.

Change-Id: I9b715e17e9c5a32b7ce28815e288b2af236c3cc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145742
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-01-20 19:36:14 +00:00
Patrick Luby ef558d0aab Related: tdf#42437 Skip special press-and-hold handling for action keys
Pressing and holding action keys such as arrow keys must not be handled
like pressing and holding a character key as it will insert unexpected
text.

Change-Id: I6beaff265e6cae30337b025791692ff67b760ff8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145689
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-01-17 22:21:04 +00:00
Patrick Luby fed429e4f6 Related: tdf#152703 Eliminate potential blocking during live resize
Some events and timers call Application::Reschedule() or
Application::Yield() so don't block and wait for events when a
window is in live resize.

Also, only native events and timers need to be dispatched to redraw
the window so skip dispatching user events when a window is in
live resize.

Lastly, only higher priority tasks need to be fired to redraw the
window so skip firing potentially long-running tasks, such as the
Writer idle layout timer, when a window is in live resize.

Change-Id: I5d449caa432399e836b8e59781e5cc53af718873
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145211
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
2023-01-13 14:10:00 +00:00
Patrick Luby d96c986475 tdf#152648 Handle overflow when multiplying rows and columns
Change-Id: I1f3b4853fb6e6a66e74e798d6594342c84d5a695
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145245
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-10 06:53:53 +00:00
Patrick Luby 2d1a0d86d2 Related: tdf#152703 Prevent possible hang when live resizing a window
Application::Reschedule() can potentially display a modal dialog which
will cause a hang so temporarily disable live resize by clampiing the
window's minimum and maximum sizes to the current frame size which in
Application::Reschedule().

Also, eliminate flickering during live resizing of a window when using
Skia/Metal. When in live resize, the SkiaSalGraphicsImpl class does not
detect that the window size has changed until after the flush has been
called so call checkSurface() to recreate the SkSurface if needed before
flushing. Flushing had to be moved during [self windowDidResize:] to eliminate
flicker. Flushing in [self displayIfNeeded] does not eliminate flicker so
apparently [self windowDidResize:] is called earlier.

Change-Id: Id3de838d2e17fee85cb583b6c4e862b571d47142
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145053
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-05 18:32:49 +00:00
Patrick Luby 3f7406bc4d tdf#152703 Force relayout during live resizing of window
During a live resize, macOS floods the application with windowDidResize:
notifications so sending a paint event does not trigger redrawing with
the new size. Instead, force relayout by dispatching all pending internal
events and firing any pending timers.

Also, force a repaint of the window after live resizing ends by reposting
this notification so that [self windowDidResize:] will be called at least
once after live resizing ends.

Change-Id: I9d93108c989418bab6d80c7f6afaccc1daaa746e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145042
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-04 18:49:55 +00:00
Patrick Luby d118be7ed4 Related: tdf#152703 Eliminate empty window with Skia/Metal while resizing
The window will clear its background in [SalFrameWindow displayIfNeeded]
so when Skia/Metal is enabled, explicitly flush the Skia graphics to the
window during live resizing or else nothing will be drawn until after live
resizing has ended.

Also, when Skia/Metal is enabled, rapidly resizing a window has a noticeable
amount of flicker so don't send any paint events during live resizing. Also,
it appears that most of the LibreOffice layouts do not change their layout
much during live resizing so apply this change when Skia is not enabled to
ensure consistent behavior whether Skia is enabled or not.

Change-Id: If6423faa72529b9de8735e04e69c9511aceb2276
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144979
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-03 07:12:20 +00:00
Patrick Luby b99464ef2f Related: tdf#146842 Eliminate temporary copies of SkiaSalBitmap when printing
Commit 9eb732a320 fixed crashing when
printing SkiaSalBitmaps to a non-Skia SalGraphics. However, the fix
almost always makes two copies of the SkiaSalBitmap's bitmap data: the
first copy is made in SkiaSalBitmap::AcquireBuffer() and then
QuartzSalBitmap makes a copy of the first copy.

By making QuartzSalBitmap's methods that return a CGImageRef pure
virtual, a non-Skia SalGraphics can now create a CGImageRef directly
from a SkiaSalBitmap's Skia bitmap data without copying to any
intermediate buffers.

Change-Id: If6ab7f175889cb4839d8a2461b7be7671e575c08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144856
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-29 14:14:36 +00:00
Patrick Luby 1b6acdc60b tdf#150177 Limit minimum blink cursor rate
This bug occurs when the values for NSTextInsertionPointBlinkPeriodOn or
NSTextInsertionPointBlinkPeriodOff are set to zero or close to zero.
LibreOffice becomes very sluggish opening documents when either is set
at 100 milliseconds or less so set the blink rate to the maximum of
500 milliseconds, NSTextInsertionPointBlinkPeriodOn, and
NSTextInsertionPointBlinkPeriodOff.

Change-Id: I953bddda757f8514221ac5cd9c04bd749a994fda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144775
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-23 13:49:00 +00:00
Patrick Luby 1e4ef6d69b tdf#42437 Enable press-and-hold special character input method
The first step to enable this input method is to always return a valid selected
range location. -[NSResponder interpretKeyEvents:] will not call
[self firstRectForCharacterRange:actualRange:] if the selected range location
is NSNotFound so that is what was disabling display of the press-and-hold
input method popup.

Once [self firstRectForCharacterRange:actualRange:] is called, emulate the
press-and-hold behavior of the TextEdit application by setting the marked text
to the last key down event's characters. The characters will already have been
committed by the special character input method so set the
mbTextInputWantsNonRepeatKeyDown flag to indicate that the characters need to
be deleted if the input method replaces the committed characters.

Also, emulate the press-and-hold behavior of the TextEdit application by
committing any uncommitted text when either the escape or the return key is
pressed while the press-and-hold input method popup is displayed.

Lastly, handle repeat key events by explicitly inserting the text if there is
no uncommitted text before -[NSResponder interpretKeyEvents:] is called.

Change-Id: I104b3d64a8c66fef3a5a1cec0fba1daa553cd9a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144630
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-22 16:43:55 +00:00
Patrick Luby 5c98d8e79b tdf#151341 Use lzfse compression instead of bzip2
Several users reported that copying the LibreOffice.app package
in the Finder from a .dmg file compressed with lzfse compression
copies the package several times faster than from a .dmg compressed
with bzip2 compression.

On a mid-2015 Intel MacBook Pro running macOS, copying in the Finder
was at least 5 times faster with lzfse than with bzip2. Also, the
hdiutil man page as of macOS Monterey 12.6.2 has marked bzip2 as
deprecated. lzfse is marked as supported since macOS El Capitan 10.11
so this change appears safe.

The one thing that bzip2 has is better compression so a .dmg with
bzip2 should be smaller than with lzfse. A .dmg built from a debug
build was 262M with bzip2 and 273MB for lzfse. So it appears that
lzfse creates .dmg files that are only 4% or 5% larger than bzip2.

Change-Id: I61e2a08cede19a5bb8c257d4fa4762168a3a9dc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144342
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2022-12-20 14:22:01 +00:00
Patrick Luby 07f9f22e68 tdf#146765 Fix infinite recursion in -[NSView visibleRect]
HACK: Adding a subview to an NSView that is not attached
to an NSWindow leads to infinite recursion in the native
NSViewGetVisibleRect() function. This seems to be a new
behavior starting with macOS 12.6.2.

In the case of tdf#146765, we end up here because
-[AquaA11yWrapper childrenAttribute] is called by a
wrapper that is already attached to an NSWindow. That is
normal. What isn't normal is that the child wrapper's
unignored accessible parent is a differnt wrapper than
the caller and that different wrapper is not yet
attached to an NSWindow.

TODO: switch the AquaA11yWrapper class to inherit the
lightweight NSAccessibilityElement class instead of the
NSView class to possibly avoid the need for this hack.

Change-Id: Ic6c2a60e90a154786dd7f5935582ef7d3f57584c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-16 16:19:29 +00:00
Patrick Luby 9ec57a3dc7 tdf#145843 Do not use CGBitmapContextCreate() to create a bitmap context
As described in the comment in the above code, CGBitmapContextCreate()
and CGBitmapContextCreateWithData() will try to access pixels up to
mDirtyRect.x() + pixmap.bounds.width() for each row. When reading the
last line in the SkPixmap, the buffer allocated for the SkPixmap ends at
mDirtyRect.x() + mDirtyRect.width() and mDirtyRect.width() is clamped to
pixmap.bounds.width() - mDirtyRect.x().

This behavior looks like an optimization within CGBitmapContextCreate()
to draw with a single memcpy() so fix this bug by chaining the
CGDataProvider(), CGImageCreate(), and CGImageCreateWithImageInRect()
functions to create the screen image.

Change-Id: Ic83f6162f8eb63de22693c0c40015da3b88aee65
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144194
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-15 05:33:36 +00:00
Patrick Luby 229b0ce8d8 tdf#151700 Display native print panel even if there are no printers
Prevent the non-native LibreOffice PrintDialog from displaying by creating a fake printer if there are no printers. This will allow the LibreOffice printing code to proceed with native NSPrintOperation which will display the native print panel.

Change-Id: Iee13305520360b0165464889f0ee51b1207dd5ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143794
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-13 06:08:54 +00:00
Patrick Luby d491791dad Fix infinite loop in sw_ooxmlexport17 unit test on macOS Intel
When running the sw_ooxmlexport17 unit test on slower macOS Intel
machines, This loop will never end even after 1M+ loops so set a
maximum number of loops like is done in the nested while loops.

Change-Id: If3a6140e03f21f4a16f6d90be7988c28c8f36753
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143947
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-12-13 06:08:40 +00:00
Patrick Luby 9eb732a320 Related: tdf#146842 Convert SkiaSalBitmap to QuartzSalBitmap
Commit de3f13e217 disabled Skia for printing.
However, since all SalBitmaps created are either all QuartzSalBitmaps or all
SkiaSalBitmaps, a crash occurs whenever a SkiaSalBitmap is passed to a
printer's SalGraphics instance which is now always non-Skia.

Change-Id: I7c1b0e1a9993e21db18ba5695a106cb10cc4088a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143939
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-11 20:02:53 +00:00
Patrick Luby de3f13e217 tdf#146842 Do not use Skia for printing
Skia does not work with a native print graphics contexts. I am not sure why but from what I can see, the Skia implementation drawing to a bitmap buffer. However, in an NSPrintOperation, the print view's backing buffer is CGPDFContext so even if this bug could be solved by blitting the Skia bitmap buffer, the printed PDF would not have selectable text so always disable Skia for print graphics contexts.

Change-Id: I214ba83b6e368af3ef51ea770b093612d04047a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143798
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-09 09:17:42 +00:00
Patrick Luby 9ee57f36e2 tdf#82115 Commit uncommitted text when a popup menu is opened
The Windows implementation of the SalFrame::EndExtTextInput() method commits or discards the native input method session. It appears that most macOS applications discard the uncommitted text when cancelling a session so always commit the uncommitted text. This change also commits any uncommitted text and cancels the native input method session whenever a window loses focus like in Safari, Firefox, and Excel.

Note: if there is any marked text, SalEvent::EndExtTextInput may leave the cursor hidden so commit the marked range to force the cursor to be visible.

Dispatching SalEvent::EndExtTextInput in SalFrame::EndExtTextInput() creates some other related native input method handling bugs that have also been fixed in this patch:

- Whenever a SalEvent::EndExtTextInput event is dispatched, cancel the native input method session so that the native input context's state is in sync with LibreOffice's internal state. The only exceptions are in [SalFrameView insertText:replacementRange:] or [SalFrameView setMarkedText:selectedRange:replacementRange:] because when these two selectors commit text, the native input method session has already been cancelled and calling [SalFrameView endExtTextInput] will cause repeated text insertions from the native macOS Character Viewer dialog to overwrite previous insertions.

- Highlight all characters in the selected range. Normally uncommitted text is underlined but when an item is selected in the native input method popup or selecting a subblock of uncommitted text using the left or right arrow keys, the selection range is set and the selected range is either highlighted like in Excel or is bold underlined like in Safari. Highlighting the selected range was chosen because highlighting was used in LibreOffice 7.4.x and using bold and double underlines can get clipped making the selection range indistinguishable from the rest of the uncommitted text.

- The fix for ooo#106901 always returns a zero length range if [self markedRange] called outside of mbInKeyInput. If a zero length range is returned, macOS won't call [self firstRectForCharacterRange:actualRange:] for any newly appended uncommitted text and the native input method popup will appear in the bottom left corner of the screen. So, [self markedRange] now returns the marked range if is valid.

- Commit uncommitted text before dispatching menu item selections and key shortcuts. In certain cases such as selecting the Insert > Comment menu item or pressing Command-Option-C in a Writer document while there is uncommitted text will call AquaSalFrame::EndExtTextInput() which will dispatch a SalEvent::EndExtTextInput event. Writer's handler for that event will delete the uncommitted text and then insert the committed text but LibreOffice will crash when deleting the uncommitted text because deletion of the text also removes and deletes the newly inserted comment.

Change-Id: I4ff4682aeef7d42ce26059aa76f971a68128833c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143619
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-08 09:33:38 +00:00
Patrick Luby 60d2dd11a7 Related: tdf#82115 Fix crash when handling input method events
The nodes in mpIMEInfos may be deleted in ImpEditEngine::Clear() which causes a crash in the CommandEventId::ExtTextInput and CommandEventId::EndExtTextInput event handlers.

This crash occurs on Windows or macOS using the following steps:
- Enter uncommitted text (enter "aaa" with a Japanese Hiragana input method) in a comment in a Writer document
- Switch to another empty Writer document without committing the text in the first Writer document
- Switch back to the first Writer document

The above steps may need to be repeated a few times but it will eventually crash with the following stack trace:

(lldb) bt 25
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x00000001b928ad98 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001b92bfee0 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001b91fa340 libsystem_c.dylib`abort + 168
  * frame #3: 0x00000001b91f9754 libsystem_c.dylib`__assert_rtn + 272
    frame #4: 0x000000010374a09c libeditenglo.dylib`ImpEditEngine::ImpRemoveParagraph(this=0x000000011a684e00, nPara=-2147483648) at impedit2.cxx:2512:5
    frame #5: 0x0000000103739658 libeditenglo.dylib`ImpEditEngine::ImpDeleteSelection(this=0x000000011a684e00, rCurSel=0x000000016fdf7250) at impedit2.cxx:2473:9
    frame #6: 0x0000000103739328 libeditenglo.dylib`ImpEditEngine::DeleteSelected(this=0x000000011a684e00, rSel=0x000000016fdf7250) at impedit2.cxx:259:19
    frame #7: 0x000000010373aac4 libeditenglo.dylib`ImpEditEngine::Command(this=0x000000011a684e00, rCEvt=0x000000016fdf7698, pView=0x0000600000169e10) at impedit2.cxx:408:24
    frame #8: 0x0000000103721744 libeditenglo.dylib`ImpEditView::Command(this=0x00000002e3f8b7b0, rCEvt=0x000000016fdf7698) at impedit.cxx:1757:41
    frame #9: 0x00000001036d7df4 libeditenglo.dylib`EditView::Command(this=0x0000600000169e10, rCEvt=0x000000016fdf7698) at editview.cxx:495:26
    frame #10: 0x000000010b1d2420 libsvxlo.dylib`WeldEditView::Command(this=0x0000600002b11e30, rCEvt=0x000000016fdf7698) at weldeditview.cxx:312:23
    frame #11: 0x00000002ea78dd50 libswlo.dylib`sw::sidebarwindows::SidebarTextControl::Command(this=0x0000600002b11e30, rCEvt=0x000000016fdf7698) at SidebarTxtControl.cxx:461:26
    frame #12: 0x000000011656f3d4 libvcllo.dylib`weld::CustomWeld::DoCommand(this=0x000060000016a740, rPos=0x000000016fdf7698) at customweld.cxx:93:32
    frame #13: 0x000000011656ee7c libvcllo.dylib`weld::CustomWeld::LinkStubDoCommand(instance=0x000060000016a740, data=0x000000016fdf7698) at customweld.cxx:91:1
    frame #14: 0x0000000115ca1dd4 libvcllo.dylib`Link<CommandEvent const&, bool>::Call(this=0x00000002e3f8bc48, data=0x000000016fdf7698) const at link.hxx:111:45
    frame #15: 0x00000001165b1658 libvcllo.dylib`SalInstanceDrawingArea::CommandHdl(this=0x00000002e3f8bb50, rEvent=0x000000016fdf7698) at salvtables.cxx:6473:26
    frame #16: 0x00000001165af588 libvcllo.dylib`SalInstanceDrawingArea::LinkStubCommandHdl(instance=0x00000002e3f8bb50, data=0x000000016fdf7698) at salvtables.cxx:6471:1
    frame #17: 0x0000000115ca1dd4 libvcllo.dylib`Link<CommandEvent const&, bool>::Call(this=0x00000002e3f90208, data=0x000000016fdf7698) const at link.hxx:111:45
    frame #18: 0x0000000115d047d0 libvcllo.dylib`VclDrawingArea::Command(this=0x00000002e3f90080, rEvent=0x000000016fdf7698) at layout.hxx:685:27
    frame #19: 0x0000000115e2e2bc libvcllo.dylib`ImplCallCommand(pChild=0x000000016fdf77c8, nEvt=ExtTextInput, pData=0x000000016fdf77d8, bMouse=false, pPos=0x0000000000000000) at winproc.cxx:229:17
    frame #20: 0x0000000115e34458 libvcllo.dylib`ImplHandleExtTextInput(pWindow=0x0000600002aa8930, rText=0x000000016fdf8290, pTextAttr=0x0000600000018710, nCursorPos=4, nCursorFlags=1) at winproc.cxx:1424:13
    frame #21: 0x0000000115e30dc8 libvcllo.dylib`ImplWindowFrameProc(_pWindow=0x0000600002aa8930, nEvent=ExtTextInput, pEvent=0x000000016fdf8290) at winproc.cxx:2863:20
    frame #22: 0x000000011b0424e0 libvclplug_osxlo.dylib`SalFrame::CallCallback(this=0x00000001378ffb40, nEvent=ExtTextInput, pEvent=0x000000016fdf8290) const at salframe.hxx:306:29
    frame #23: 0x000000011b0ef8f4 libvclplug_osxlo.dylib`-[SalFrameView setMarkedText:selectedRange:replacementRange:](self=0x00000002c4b0d980, _cmd="setMarkedText:selectedRange:replacementRange:", aString="嗚呼嗚呼", selRange=location=4, length=0, replacementRange=location=9223372036854775807, length=0) at salframeview.mm:1595:18
    frame #24: 0x00000001bc8d6a2c AppKit`-[NSTextInputContext(NSInputContext_WithCompletion) setMarkedText:selectedRange:replacementRange:completionHandler:] + 168

Change-Id: I500824967d56232272041f8a2b972cdb2c9fe05c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143806
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-12-08 09:32:32 +00:00