Send encoded JSON string instead of decoded.
This way it will not have special characters, and it will
reach the core side even with a \n or \r inside ot it.
This way we can set multi-line text to a contentControl.
Signed-off-by: Attila Szűcs <attila.szucs@collabora.com>
Change-Id: I8b32aeef522faf7f4597405bec9bbb37b99d53cf
Example use of filter:
curl -F "data=@docStructure2.docx" -F "filter=contentcontrol" http://localhost:9980/cool/extract-document-structure > out.json
it will extract contentControls only if filter=contentcontrol is used,
or if no filter is used.
No filter means extract everything.
Signed-off-by: Attila Szűcs <attila.szucs@collabora.com>
Change-Id: I001a2cc525be7502d53b5849bb61a99d087ed807
Use extract-document-structure to get document structure
Use transform-document-structure to change its content
Example use of Transform:
curl -F "data=@CC.odt" -F "transform={\"Transforms\":{\"ContentControls.ByIndex.1\":{\"content\":\"Short text\"}}}"
https://localhost:9980/cool/transform-document-structure > out.odt
Note: Please do not use \n (EOL) in transform.
Example output for extract
{
"DocStructure": {
"ContentControls.ByIndex.0": {
"id": 0,
"tag": "",
"alias": "",
"content": "FieldValue1",
"type": "plain-text"
},
"ContentControls.ByIndex.1": {
"id": 0,
"tag": "",
"alias": "",
"content": "☒",
"type": "checkbox",
"Checked": "true"
}
}
}
Signed-off-by: Attila Szűcs <attila.szucs@collabora.com>
Change-Id: I4b362376651e9bb5482949529e2bd7720231debf
This adds support for getting the presentation info from core.
This change uses the new GetPresentationInfo() funciton that was
added to the LOKit API.
Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I19f5809fd841e4b2603a2446e1d9d54392dd1bd7
Right now .uno:CopyHyperlinkLocation only works on edit mode or
inside a draw object, but LOK_CALLBACK_HYPERLINK_CLICKED is
dispatched outside of edit mode and the copy command from
the pop-up is ignored.
Since there is no text cursor, the position of the hyperlink is
needed to discriminate the correct field, since there could be
multiple hyperlink fields inside the same cell.
Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: Ie814867e0a4a319e78381b68343847491034d85f
It is useful to send mode always, including the default 0. The 0
is significant; and there is a JS code that treats absent mode as
"current".
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I8dbaaa47b302d96c8e867c1e9cb31b558e13db09
Since other view modes are needed, too, not only master page view, we need
to send / handle status updates not only in case of SlideMasterPage update.
The ".uno:DocumentStatus" pseudo-command update sent from ChangeEditMode
in core serves for that.
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: If7bc7ae124d161658b06784f3e86d85f3c76f3c6
Hopefully this can abort more helpfully if we have no chance to bgsave.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I3ca8a3d577c1dc6d11049ddaee9dcf77e00a9a3a
Have two COOL servers, copy on one instance, paste an on other instance,
nothing happens on Ctrl-V.
It appears the JS code in Clipboard.js
_dataTransferDownloadAndPasteAsync() gets the correct HTML, but when it
tries to contact the "copy" server for the underlying full clipboard,
some security policy prevents the JS code from doing that. Which means
1) perhaps we should do that HTTP fetch on the server, not in JS and 2)
the fallback code should at least work via normal HTML.
Fix 2) by extending ChildSession::setClipboard() to recognize if the
data has the typical HTML header, and only start the usual parsing in
case the data we got is not bare HTML.
The 1) still needs fixing.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I55a102c2a39d21ac898f82041760a220e46784cb
- we don't depend on OnMouseUp event of AutoFillMarkerSection.ts anymore
which makes the popup more stable in terms of open and close.
- requires: added LOK_CALLBACK_CELL_ACTIONS with
https://gerrit.libreoffice.org/c/core/+/168086 - 1cf2a23c7cb0a149562635432b003164059617b5
Signed-off-by: Bayram Çiçek <bayram.cicek@collabora.com>
Change-Id: I2294f6aa091231c2ddf1a448776f51a3a892b646
- add new LOK callback for vertical & horizontal ruler update
Signed-off-by: Darshan-upadhyay1110 <darshan.upadhyay@collabora.com>
Change-Id: I3c0e26f22072de4612e128d58ac41b629be82807
Add vertical ruler and implement margin calculation
- Added new vertical ruler file to separate it from horizontal ruler calculation
- For vertical ruler we do not need tab stops so removed it.
- next stpe will be to implement add top and bottom margin by drag
Signed-off-by: Darshan-upadhyay1110 <darshan.upadhyay@collabora.com>
Change-Id: I8186c874ff59571db7a75ec4c31f81fc655ef301
To silence errors until feature arrives. Occurs after
following core commit:
11b936629dd4ef9308d63b312900b8b7c8ff19b4
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I6d9b01b265e3f07db2bc4ac7da46cbfcd0e17da5
To avoid the HTTP[S] request racing the websocket and sometimes
loosing we need to:
* get a notification from the Kit when the copy / cut is complete
* wait on a Promise for this, to allow the HTTP fetch to start
* re-work to do a single, rather than two fetches by sharing
the download promise.
Change-Id: Ic23f7f817cc855ff08f25a2afefcd73d6fc3472b
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
We need to mark core unmodified so we can track modifications
to the core that date from after the background save process is
forked.
We avoid telling WSD about our new modification status until
we are sure the background save completed successfully, and only
in the case that we have not been subsequently modified.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I2c9fbce942ff0af2bb727c3685f4ec479e18fa27
We need to get more helpful structure into this message, and add a
type=bg flag to handle background progress messages.
Add unit test for merging progress: setvalue commands.
Simplify ProtocolHandler sendTextMessage with a std::string wrapper.
Android code needs manual testing.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I54ce807e2fc5de80118905e68557a95e637fbd18
This added 200+ lines of code, made things harder to
understand, and was used only in a single test that can be
covered in another way.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I4ed8d1d52d533f8b24be7dd5e12dbb7702ef1a80
Centralize more logging functionality in Log.cpp, simplify and
wrap underlying logging APIs better.
Code is much more generic, and hides implementation details
much more thoroughly, while keeping the same API / wrappers.
To do this we have to sub-class Poco::Logger to get access to
its generic 'log' method instead of a mess of in-line wrappers,
this lets us avoid lots of code.
Change-Id: I541d3aef49f99ce582655c5102a0041bf84cd56a
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Get the polarity of the check on whether we succeeded to spawn a
background save process right, so we don't spawn two saves
concurrently, and block input processing in the wrong place.
Also a few obvious sillies fixed, and some more assertions for
good measure; was not good:
[ kitbgsv_001_001 ] TRC ToMaster-002: Finished synchronous background saving ...| kit/ChildSession.cpp:882
[ kitbgsv_001_001 ] TRC ToMaster-002: saveDocumentBackground returns succesful start.| kit/ChildSession.cpp:887
[ kitbgsv_001_001 ] TRC Document - input processing now: disabled was enabled| kit/Kit.cpp:2095
[ kitbgsv_001_001 ] TRC ToMaster-002: uno command .uno:Save {... notify: true| kit/ChildSession.cpp:1944
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ie06a74a538bdd5038ca9c94b422f27cff9e4a82e
problem:
in LOK/online to support async save, files in jails may have
different extensions (ie: .upload, .uploading)
this caused problem to detect files as original file name may not exist.
As result property like file size were always set to 0
chronology of events:
1. File is saved normally with existing name
2. After saved we make it ready for upload and add extension .upload in "renameForUpload"(kit/ChildSession.cpp)
3 We change to .uploading extension when we are uploading (DocumentBroker::handleSaveResponse, DocumentBroker::uploadAfterLoadingTemplate)
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: Ibda40b0c134ef6baef9edb0427b3c56340924858
Also pass 'autosave' status in a more conventional way.
Ideally we would split 'save' away from a ChildSession / ClientSession
and have this on DocumentBroker / Document - for the future.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I39a6caf8b17fa2fc2d940ae0d11bdc2d4da20b6c
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I9098f7137d81bbc63e2449fbc8ecc53b3f1e7e7e
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Initial background save implementation from the Kit perspective.
To do a background save we:
1. join known threads - we can't fork with >1 thread.
2. check all is well: one thread, nothing unusual...
3. create a socketpair to communicate with the child
4. fork
5. child: cleanup duplicated sockets
6. child: setup LOK to not damage our shared file-system
7. child: save
8. child: report status back to parent & _Exit
There is still a substantial TODO, but this can be built on.
Change-Id: Ibf2c492372e2b5133932773e230ad05e18521794
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
problem:
when online created file using WOPI clients, creation dates were never set.
in online files are created using templates, even empty files are created using
an empty template
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I312d7af17bf322ca55b6e20bba344e4fc6628e66
Visit the
/cool/clipboard?WOPISrc=...&MimeType=text/html,text/plain;charset=utf-8
endpoint, you get a JSON with HTML and plain text. Visit
/cool/clipboard?WOPISrc=...&MimeType=text/html, you get HTML with a
custom header that is only possibly to skip easily because HTML itself
has as well-known header.
This is decied in ChildSession::getClipboard(), which has 3 cases: 1)
single specific format 2) multiple specific formats and 3) all formats.
So far only 2) used JSON, but the new async clipboard copy will want to
(als) request just plain text, where skipping our own custom header is
hard, given that the text itself has no well-known header (unlike HTML).
Solve the problem by always using JSON when a specific format is
requested, so both the HTML and HTML+plaintext case gives JSON.
The client side of this is the recently introduced Clipboard.js
parseClipboard(), which can cope with JSON already.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I8298f3f82d2a3871777c369f5aee6bb81d66a553
In case the selection is complex (not simple), we used to just request
HTML, and then the browser converted that to plain text, which has the
downsides already mentioned in commit
7f9de46688 (cool#8465 clipboard: improve
handling of plain text copy, simple case, 2024-03-08).
Steps to support this:
1) Clipboard.js now asks for the text/html,text/plain;charset=utf-8 MIME
types.
2) wsd: ClientRequestDispatcher::handleClipboardRequest() now maps this
to DocumentBroker::CLIP_REQUEST_GET_HTML_PLAIN_ONLY
3) ClientSession::handleClipboardRequest() maps this to the HTML+plain
text MIME type list.
4) kit: ChildSession::getClipboard() is now improved to take a list of
MIME types, not just 1 or everything.
5) kit: ChildSession::getClipboard() now emits JSON in case not all, but
multiple MIME types are requested.
6) wsd: ClientSession::postProcessCopyPayload() now knows how to
postprocess clipboardcontent messages, which may or may not be JSON
(it's JSON if more formats are requested explicitly, leaving the 1
format or all format cases unchanged)
7) Control.DownloadProgress.js now handles the case when we get JSON and
sets the core-provided plain text next to the HTML.
Leave the handling of non-JSON case in, because this means we can
copy from an old COOL server to a new one.
Note that this approach has the benefit that once the clipboard marker
is inserted, the length of the text/html format would change, which
means we can't parse the clipboard data till the marker is removed.
Emitting JSON for html+text means adding the marker keeps the ability to
parse the HTML and the plain text part of the clipboard in JS.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I67a1f669e8a638d34cc25a2f288a7b30884b9892
Reduce the uses of MOBILEAPP conditionals by using the isMobileApp
function.
Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com>
Change-Id: If541307fbc457b342674cc560b6c53454f3904cf
problem:
before this patch innert textarea svg was not updated after changing text,
it was static based on first selection of textbox/shape,
to update the textarea we needed to unselect and reselect shape/textbox
Signed-off-by: Pranam Lashkari <lpranam@collabora.com>
Change-Id: I11ceaf76867cecf5a356149d2072181e9f10b86e
Currently the current selection is always requested as HTML by the
browser, and then we ask the browser to convert it to plain text.
The problem is that e.g. Writer can produce much better plain text from
its model, compared to the plain text by the browser, e.g. bullet
characters for bullet points.
Fix the problem by:
- CanvasTileLayer.js, _onTextSelectionMsg(): requesting both HTML and
plain text. Use ',' as a separator, as that's already established,
e.g. the HTTP Accept header does that already
- Switching the textselectioncontent protocol message from just HTML to
JSON that contains both HTML and plain text. This is produced in
ChildSession::getTextSelection() and parsed in CanvasTileLayer.js,
_onMessage()
- Clipboard.js, setTextSelectionHTML(): allowing setting both HTML and
plain text.
- ClientSession::postProcessCopyPayload(): knowing if the content to be
processed is HTML-in-JSON or just HTML, do additional escaping in the
JSON / textselectioncontent case, but leave the other clipboardcontent
case unchanged.
So far this only handles the simple case, the behavior for complex
selections are left unchanged for now. The payload is also unchanged
when a single format is requested, as many tests depend on test.
Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: I2fe1378a8d50b7901ac9e808eb78858cd8ff8575
Replace "The server encountered a xxx error while parsing
the yyy command." with more informative "Document cannot
be exported. Please try again." on export issues.
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I2683720d043713af95ccc61d46c3da09e6f5092b
Replace a few cases of Util::toString(...), too.
Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I53c5dbbdf2f60710e94add9dd137aa9becb7bd3e
Cue up some basic state for being signal safe dumped on crash/abort.
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ibc6713aef2a0e7b878b178b05f0e13c8d40b47fc
Send "tooltip: <payload>" to client for this callback type.
Client-side handling should be implemented separately.
Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com>
Change-Id: I2d1a07dd36fa20a4b5ff785da788356e0f41d62f
Converting the coordinates were inconsistent.
Created JSON was not valid.
This PR fixes the issues.
Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: Ibb9cf4e4517a8e3f2d5fc701fdcf287ce72b6b9c
Have the document's DocumentViewController display a save dialog and
export a copy of the file written by the LibreOffice code.
Signed-off-by: Patrick Luby <guibomacdev@gmail.com>
Change-Id: Idf8136bc321893f18010eb74f9c39b21f0f698d5
* These changes are made primarily for reading the hyperlink data from the document in readonly mode.
* Added readonlyclick event.
* Added readonlyhyperlinkclicked event.
* And the handlers for these.
When user clicks on document in readonly mode, a readonlyclick event is sent to the server.
Childsession checks if there is a hyperlink at the clicked location.
If so, the information of the hyperlink is sent to the client.
Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: I9c104a1ec770491725337b9bbb1e2d1c2851321b
Avoid screen reader to wrongly report text when a shape or image is
selected:
- Got editable area to be made empty when user is not editing text
- Got default for any input to be prevented (except for some special
cases) when user is not editing text so editable area is kept empty
The selection action and the selected object name (e.g. "Rectangle",
"Presentation Title", etc.) are sent to the client.
That allows screen reader to report: "Presentation Title selected" or
"Rectangle unselected", according to the action type.
Selection text content is reported too when available.
Something alike is reported on cell navigation in a spreadsheet.
Signed-off-by: Marco Cecchetti <marco.cecchetti@collabora.com>
Change-Id: I75a8b66ef8cb7b24b28d749f0b24afe2587de45e