diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-11-25 12:30:56 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-25 16:16:39 +0100 |
commit | 24219cc1e9829f82a533667aef0f51b6a7df6fc2 (patch) | |
tree | 7e61f8973223ea3a9658b8c85773bf454680e7aa /desktop | |
parent | 534d43ac5b51c57c01f275d6ecb320ee9e51000a (diff) |
sw lok, .uno:TextFormFields: expose field code of fieldmarks
The fieldmarks in a document were kind of invisible for LOK clients
previously.
The Zotero use-case requires a way to fetch certain types of fieldmarks
from a document, to be able to update them and then write back those
updated versions to the document later.
Fix this by introducing a new .uno:TextFormFields, you can get its value
using the getCommandValues() LOK API. This allows filtering for a
certain field command prefix, which is generic, but e.g. in the Zotero
case allows getting the citations or the bibliography. The returned JSON
is an array of matching fieldmarks, containing their type and field
command. It seems there is no way to return the field result, till the
motivation is to just update that field result. (If there will be need,
the field result can be added.)
Do this in a way that next time we add a Writer-specific command (to be
able to return its values), there will be no need to touch
include/vcl/ITiledRenderable.hxx, causing a large rebuild.
Change-Id: I2ef1159bec4034bbdd6b4ba00715a69423106edd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143275
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 766248ef00ef..15371581c818 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5702,6 +5702,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo static constexpr OStringLiteral aSheetGeometryData(".uno:SheetGeometryData"); static constexpr OStringLiteral aCellCursor(".uno:CellCursor"); static constexpr OStringLiteral aFontSubset(".uno:FontSubset&name="); + static constexpr OStringLiteral aTextFormFields(".uno:TextFormFields"); if (!strcmp(pCommand, ".uno:LanguageStatus")) { @@ -5878,6 +5879,19 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo { return getFontSubset(aCommand.substr(aFontSubset.getLength())); } + else if (o3tl::starts_with(aCommand, aTextFormFields)) + { + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg("Document doesn't support tiled rendering"); + return nullptr; + } + + tools::JsonWriter aJsonWriter; + pDoc->getCommandValues(aJsonWriter, aCommand); + return aJsonWriter.extractData(); + } else { SetLastExceptionMsg("Unknown command, no values returned"); |