vcl/workben/pasteboard.mm | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
New commits: commit 1dacb8cb94162310345b7f63f7ceda35a7152d0a Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Thu Jan 14 16:39:37 2021 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Thu Jan 14 15:49:49 2021 +0100 Add an option to dump pasteboard data for a type to stdout Change-Id: Iafa24799c5c18abef93f032a2f637c39f4a9cf5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109296 Tested-by: Tor Lillqvist <t...@collabora.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/vcl/workben/pasteboard.mm b/vcl/workben/pasteboard.mm index b38b19387602..3d523afeb383 100644 --- a/vcl/workben/pasteboard.mm +++ b/vcl/workben/pasteboard.mm @@ -12,13 +12,59 @@ // Build with: clang++ -Wall -o pasteboard vcl/workben/pasteboard.mm -framework AppKit +#import <unistd.h> + #import <iostream> #import <AppKit/AppKit.h> +static void usage() +{ + std::cout << + "Usage: pastebord\n" + " --List the types on the pasteboard and in each pasteboard item.\n" + " pasteboard -t type\n" + " --Output the data for the type in question to stdout. Note: output will in many cases be binary.\n"; +} + int main(int argc, char** argv) { + NSString* requestedType; + + int ch; + + while ((ch = getopt(argc, argv, "t:")) != -1) + { + switch (ch) + { + case 't': + requestedType = [NSString stringWithUTF8String:optarg]; + break; + case '?': + usage(); + break; + } + } + + argc -= optind; + argv += optind; + + if (argc > 0) + { + usage(); + return 1; + } + NSPasteboard* pb = [NSPasteboard generalPasteboard]; + if ([requestedType length] > 0) + { + NSData *data = [pb dataForType:requestedType]; + + std::cout.write((const char *)[data bytes], [data length]); + + return 0; + } + { NSArray<NSPasteboardType>* types = [pb types]; std::cout << "Types directly on pasteboard:\n"; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits