Commit graph

874 commits

Author SHA1 Message Date
Caolán McNamara
da10eb9996 return failure early in case of oversized tiles
it shouldn't happen, but return early if it does

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I1733d346ff370827fd882caacebca111f790bbe1
2023-07-06 14:25:31 +01:00
Caolán McNamara
7833e8ce02 asan error seen in testRleComplex
=============== START DeltaTests::testRleComplex
../kit/Delta.hpp:98:23: runtime error: index 4 out of bounds for type 'const uint64_t[4]' (aka 'const unsigned long[4]')
    #0 0x55d29dacd21b in DeltaGenerator::DeltaBitmapRow::PixIterator::next() libreoffice/online-san/test/../kit/Delta.hpp:98:23
    #1 0x55d29da8d514 in DeltaTests::testRleComplex() libreoffice/online-san/test/DeltaTests.cpp:316:16
    #2 0x55d29daf7a87 in void std::__invoke_impl<void, void (DeltaTests::*&)(), DeltaTests*&>(std::__invoke_memfun_deref, void (DeltaTests::*&)(), DeltaTests*&) /usr/bin/../lib64/gcc/x86_64-suse-linux/9/../../../../include/c++/9/bits/invoke.h:73:14

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib6e13eaf0fb89ad086a99251d5b8edcdcedd6800
2023-07-06 11:40:48 +01:00
Caolán McNamara
28f5273ad7 cid#318876 Wrapper object use after free
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: If80119af29ffde7ca437047da4646c0876d98014
2023-07-05 14:49:59 +02:00
Caolán McNamara
76a5a9baff transport in rgba order
so if core is compiled with a cairo using rgba the pixels can
be sent without need to reorder in server or client

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iaf0410f1eaa605b9ce2716625f6c968bca523ccb
2023-07-05 11:58:54 +01:00
Michael Meeks
36818e9153 tiles: track invalidation by monotonic timestamp.
We want to keep pre-loaded, and invalidated tiles around so that
we have something to render in lots of cases, particularly for
other parts, and slides. However - we need to know that it is
invalid so we can on-demand fetch something better.

It is very important that this invalid state doesn't race with
tile arrivals ie. in a banal way:

	invalidate, req, invalidate, req, tile, invalidate, req, tile

it is unclear whether the latest tile is still invalid; similarly,
if we request(req) a tile and there is no change to it we get no
response.

To disambiguate this, use the monotonic wid to check we are in-sync.

Re-factor:
	setup debug tile layer more pro-active.y
	rename HasContent to NeedsFetch to be more explicit.

Remove:
	previous _invalidCount that was perhaps a similar idea.
	previous .loaded concept.
	previous _pruneTiles concept - now it seems we can be
	confident in cached tiles from other slides and sheets.

Change-Id: Ibc6d3b6050e756ace91a9bd53d3e4efe12b023cf
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-07-03 20:27:07 +01:00
Caolán McNamara
52338a50f1 cid#318841 String not null terminated
help coverity see that this is not true

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ie2b72e7c0bcc649509310edc5498ec7adc7ebe72
2023-06-29 08:03:00 -04:00
Paris Oplopoios
738de114d7 Make writer page background match document color
It used to be that scrolling in dark mode would show a white color while
the tiles were loading - now shows the document background color.

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: Id4c3881e728ae18496bf276e8c565a7abc1de7b5
2023-06-29 11:22:04 +01:00
Jaume Pujantell
aceb8912fd Handle LOK_CALLBACK_DOCUMENT_PASSWORD_RESET
Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: Ibc2be5bc7676b1b67b7494c200011e4622a5b294
2023-06-23 18:17:14 +02:00
Caolán McNamara
490b0c0d0d drop non-standard width=400 height=400 tile request in unit test
there since:

commit 232499f542
Date:   Thu Apr 21 12:34:30 2016 +0300

and

commit bf66f7a908
Date:   Mon Jun 13 20:31:14 2016 -0400

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I04745be0581a697bbc3b15ba1d8bb94207320a7a
2023-06-23 16:55:25 +01:00
Caolán McNamara
2e64ad700d push unpremultiply to client
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4aef21179a4ace084762f83f5235c7022d670752
2023-06-23 14:20:42 +01:00
Caolán McNamara
962ecba493 push bgra->rgba conversion to the client
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I425655bfd5e6fd9e1e3ca0b6bcc914511ba188b3
2023-06-23 14:20:42 +01:00
Caolán McNamara
9c780bec82 double delta cache
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I4f06f9c4bd6f6fc41b6eed23eb2331daa26f0b5b
2023-06-23 14:07:31 +01:00
Michael Meeks
12e0830b1b Kill canceltiles support completely.
This stopped working well a long time ago, and is already disabled
on the coolwsd side, so dung out the rest of the code & docs on this.

Change-Id: I2e0b73fe9780e16c3cc74ae3a38ae6b04434717a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-06-22 09:35:22 +01:00
Caolán McNamara
d3ecb6c95f the tile is assumed to be 256 in width
but as seen with unit-tiletest that is not always the case

==24170==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x63400001e808 at pc 0x558a6f505973 bp 0x7ffc0670e7d0 sp 0x7ffc0670e7c8
READ of size 8 at 0x63400001e808 thread T0 (kitbroker_002)
    #0 0x558a6f505972 in DeltaGenerator::DeltaBitmapRow::initRow(unsigned int const*, unsigned int) Delta.hpp:129:36
    #1 0x558a6f4fc318 in DeltaGenerator::DeltaData::DeltaData(unsigned int, unsigned char*, unsigned long, unsigned long, int, int, TileLocation const&, int, int) Delta.hpp:233:21
    #2 0x558a6f4f8a22 in DeltaGenerator::createDelta(unsigned char*, unsigned long, unsigned long, int, int, int, int, TileLocation const&, std::vector<char, std::allocator<char> >&, unsigned int, bool) Delta.hpp:574:17
    #3 0x558a6f4f2a35 in DeltaGenerator::compressOrDelta(unsigned char*, unsigned long, unsigned long, int, int, int, int, TileLocation const&, std::vector<char, std::allocator<char> >&, unsigned int, bool, bool, LibreOfficeKitTileMode) Delta.hpp:669:14
    #4 0x558a6f41f300 in RenderTiles::doRender(std::shared_ptr<lok::Document>, DeltaGenerator&, TileCombined&, ThreadPool&, bool, std::function<void (unsigned char*, int, int, unsigned long, unsigned long, int, int, LibreOfficeKitTileMode)> const&, std::function<void (char const*, unsigned long)> const&, unsigned int, int, bool)::$_0::operator()() const /home/vmiklos/git/libreoffice/online-san/./common/RenderTiles.hpp:304:38

so just use the rle cache for the first 256 pixels

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I8d34ea53bd20b69184e100b56017dfc0a904eaab
2023-06-21 21:31:48 +01:00
Caolán McNamara
cc809fda24 fix asan build test
../kit/Delta.hpp:96:23: runtime error: index 4 out of bounds for type 'const uint64_t[4]' (aka 'const unsigned long[4]')
    #0 0x558e8e0f800b in DeltaGenerator::DeltaBitmapRow::PixIterator::next() libreoffice/online-san/test/../kit/Delta.hpp:96:23
    #1 0x558e8e0b8304 in DeltaTests::testRleComplex() libreoffice/online-san/test/DeltaTests.cpp:317:16

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I01da1e99b5d224411344659dce8bd2f29e7d74b0
2023-06-21 17:09:24 +02:00
Michael Meeks
28808ebf6a delta: Add unit tests for RLE encoding, and debugging support.
Change-Id: Ie0b62dbad8af2ab6ff95d6279c69de083c2cd888
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks
9d8e84effb deltas: RLE compress pixel runs to save space & time.
Store a bitmap of whether a pixel is identical to the last
pixel in a set of four 64bit members. These double as a
simple CRC. Store the allocated row size too, and use the
stack as a temporary scratch-space to do the building in.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks
74a1047452 deltas: pure re-factor, store pixels in each DeltaBitmapRow.
Un-necessary allocation overhead for now, but more follows.

Change-Id: I1012678daf021cf63d8fc6e52d25d2dec703c4fb
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Michael Meeks
675c41c644 deltas: pure re-factor: extract out diffRowTo.
Change-Id: I908a486c0c67beaee7b41a85a3bde911f9fe141a
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-06-21 10:00:10 +01:00
Caolán McNamara
1063fdbcba cid#318963 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I459f70a41e5c1bab2e575c8d9ee699e213f2456e
2023-06-14 10:10:46 +02:00
Caolán McNamara
c8c49c5b53 cid#318908 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I24f1ec683651439761fda48d2db68fee19afcc62
2023-06-14 10:10:46 +02:00
Caolán McNamara
2d6b190805 cid#318977 AUTO_CAUSES_COPY
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Idea2efdb46d1b819b8210a380bd026789d666e2b
2023-06-14 10:10:46 +02:00
Tomaž Vajngerl
d23ddf1342 support callback for changing the color palette
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I8d0dec4afd91bcdf66799f3afba1fd77cbc223db
2023-06-09 14:30:45 +02:00
Miklos Vajna
a901db436c kit: fix missing init of _isDumpingTiles in ChildSession
This was forgotten in commit 21966e1a9c
(Fix copy command going out of bounds during delta creation,
2023-05-31).

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I91ce26f46cc6cb7a2dc3ab0665dc9aeea8a5c00f
2023-06-09 01:36:58 +03:00
Marco Cecchetti
d01bedc09c a11y: add config for enable/disable accessibility in general
A new section about accessibility has been appended to coolwsd.xml
config file

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I086abdf73646639283eb655ae60f200fb64e495a
2023-06-08 00:00:51 +02:00
Paris Oplopoios
21966e1a9c Fix copy command going out of bounds during delta creation
When creating a delta, the copy command could copy from rows that are
bigger than the height of the tile. This would go unnoticed on light
mode because the js side that applied the delta would apply these out of
bounds rows with a white color, but it is noticable in dark mode. Made
it so the copy command stops copying from out of bounds.

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I4d05cb411958d0945933edb5c812de2dfd9c1abd
2023-06-05 08:59:39 +01:00
Paris Oplopoios
baaecac852 Add debug option that allows tile dumping
Added a debug option (triggerable using the about debug menu) that
allows you to dump tiles as they come in

Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: If5939b816c1e3598e50c2db4971710524f855909
2023-06-05 08:59:39 +01:00
Paris Oplopoios
b6d4c88f90 Replace documentbackgroundcolor with applicationbackgroundcolor
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I31dc013f239daec039b194a2b15365a6f3d71621
2023-06-05 08:59:39 +01:00
Marco Cecchetti
b9f9cef60a a11y: populating editable area with focused paragraph
We handle notification from core about currently focused paragraph:
content, caret position, text selection start/end.
Notifications are sent on any text changes, even when the text has
been modified in another view.
Moreover we can request such info to core at any time.
That allows AT software to read focused paragraph and selected text.
All that keeping editing still working.
A set of new cypress tests for checking clipboard content has been
developed.

failing cpp unit test:
- HTTPWSTest::testInactiveClient
'unexpected message' assertion was failing since an idle client can
receive an a11yfocuschanged message when the same paragraph has focus
in both view and the active view is editing the paragraph.

failing cypress tests:
desktop
- calc/autofilter_spec.js
  - added more wait time before performing clickOnFirstCell
- impress/undo_redo_spec.js
  - Repair Document was broken
    - we need to select 'Hello world' in order to overwrite it

mobile
- impress/spellchecking_spec.js
  - Apply suggestion
    - better use selectTextOfShape instead of Ctrl-A

Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I070d390543fa66fe786c4a0661fa09f891b9883e
2023-05-31 22:43:51 +02:00
Ashod Nakashian
cec4cf087a wsd: test: initialize logs before unit-tests
Make sure that the logging subsystem is
already initialized before starting
unit-tests.

Change-Id: I2ce3ffdb2d3b0094ae7ed496d7cacfc02af89c21
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-31 07:40:11 -04:00
Szymon Kłos
376e8fdd97 linking-api: zoom document to avoid empty space on thumbnail
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I572dc8bd239265a9ab9311aa109e82b1d4e06efb
2023-05-17 16:43:54 +02:00
Ashod Nakashian
fd87ab6b32 wsd: clang tidy fixes
Change-Id: I7b3b08c8040ba4397ce660c5eaa1d0413c3ec611
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 08:47:26 +01:00
Ashod Nakashian
ff1657934a wsd: simplify log streaming
Change-Id: Id22de0bc06680f957e7475f142bcaf1131fdbdb9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Gökay Şatır
9d6296e4b3 Remove unused document signing code.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com>
Change-Id: I30cf381d1fa282cf222ab5abc676374ab7eefb6c
2023-05-08 21:51:47 +03:00
Paris Oplopoios
26c55fc417 Handle LOK_CALLBACK_APPLICATION_BACKGROUND_COLOR in ChildSession
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: Icef1e490e847ca21bc525dfd989190940b746b78
2023-05-05 12:38:59 +03:00
Michael Meeks
f6bd976f00 Jail cleanup - include coolwsd pid + hash into a jails sub-directory.
This avoids removing the jails of other running coolwsd that share
the same jails/ directory, such as unit-tests, cypress tests etc.

Assert on fatal system error to help catch this during test builds.

Remove old unit-test specific approach, and generalize it, since
apparently we did a recursive cleanup of other people's jails anyway.

Remove over-complicated recursive approach, for a rather simpler
one-level scheme. Avoid following symlinks too for safety.

Remove obsolete lo_jail_subpath setting.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I371f8c0e22f64fb2befb4b58f72cefa39567f3b5
2023-04-25 10:41:57 +01:00
Tor Lillqvist
bc6b3bbaee Fix build for iOS (and possibly for Android)
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5eb5187b896b7e80aaab5660a8f10268b565dc8f
2023-04-24 17:15:47 +03:00
Ashod Nakashian
2097e936f5 wsd: only external insertfile names
Change-Id: I76e63dcbf724249e23003353a6fdd2237570fd39
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-24 14:04:43 +02:00
Michael Meeks
07d1260058 Consistency checking at various points: load, save.
Check that everything is where it should be; catch and warn
about jails that are corrupted beyond our control, or perhaps
manually un-mounted etc.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ib5f7769ded119d7c6126984b040d0e5565ca8055
2023-04-21 19:20:50 -04:00
Ashod Nakashian
fecad56715 wsd: shutdown the Kit socket before terminating to flush
In some rare cases we can't write to the socket
before we terminate, and the last message is
lost. This is observed in tests and especially
when we simulate socket write failure.

Change-Id: I9fb298edfe53de3c7ea0c2f31c02ba370167f96e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30:14 +01:00
Michael Meeks
7444decf9f trim memory when user is inactive.
Builds on a new LOK API to do the same in the core.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4443cd2ffbb6c7af0726162aec2ba78fc354d901
2023-03-23 11:31:24 +00:00
Paris Oplopoios
8ade29f112 Handle LOK_CALLBACK_VIEW_RENDER_STATE in the Kit
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: Ie4d03a3600cb9ebdf9b76ee4779d62da30ad3eb6
2023-03-17 17:34:05 +00:00
Paris Oplopoios
ab176b13a8 Move canonicalId creation to the Kit
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I943bfa0436487e517b25d3fce19157ebd576604f
2023-03-17 17:34:05 +00:00
Paris Oplopoios
d26c425dae Move _canonicalViewId out of Session
Signed-off-by: Paris Oplopoios <paris.oplopoios@collabora.com>
Change-Id: I9c06440ed47eb217e973d2f530f2c3646d55d85b
2023-03-17 17:34:05 +00:00
Tor Lillqvist
43a8ed3f1c Rename variables to match meaning and add a few comments
It is misleading to use the word "pixel" in a variable name when the
variable specifies a size in twips.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Idc59c3dafd63a9ae73601f9c367b37c495e1593a
2023-03-13 12:33:49 +01:00
Tor Lillqvist
12c22706f9 We aparently want thumbnails to be of size 1200x630 pixels
Tweak the "zoom" variabe to be 1 so that with this thumbnail size, for
a typical document we get more of it into the thumbnail.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I419afccbf57eae23062ab4c849dd41293f068f00
2023-03-13 12:33:49 +01:00
Tor Lillqvist
b72edec3b5 There is no separate paintThumbnail() API in LibreOfficeKit any longer
It was just a thin wrapper around paintTile() anyway.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I7cca1b05b1ded754ae1f50a0e9d434b505247e70
2023-03-10 19:41:16 +00:00
Szymon Kłos
7cb8005df9 Send thumbnail in binary format
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: Iad5aec0cfa699f7e38a28c3c6812426ea345bafb
2023-03-10 19:41:16 +00:00
Szymon Kłos
50b5c06ad7 Scroll to target
using URL parameter we setup documents position on load.
example: ...&target=image6.png|graphic

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I855bdb148819966e0d51dde217a94474003a6437
2023-03-10 19:41:16 +00:00
Szymon Kłos
e82aa05293 Handle target in get-thumbnail
Using target parameter we move cursor to the desired position.
Thumbnail then is created and sent to the client.
Example target: "image7.png|graphic"

Original author was Mert Tümer.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I170f6af6fd29c420565feca69b8bef034fd91a66
2023-03-10 19:41:16 +00:00