[Libreoffice-commits] core.git: vcl/workben
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 23 14:12:10 UTC 2021
vcl/workben/pasteboard.mm | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
New commits:
commit 14de0fdeb7f84097650d0616bc850f5391642fe6
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Mar 23 16:04:12 2021 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Mar 23 16:10:41 2021 +0200
Add -a option to dump all pasteboard types plus some minor cleanup
Change-Id: I1cbc11eaad16a7af9b8ff665c4c35b417b1860bc
diff --git a/vcl/workben/pasteboard.mm b/vcl/workben/pasteboard.mm
index 279d3e6cc595..6a28430831b4 100644
--- a/vcl/workben/pasteboard.mm
+++ b/vcl/workben/pasteboard.mm
@@ -20,10 +20,13 @@
static void usage()
{
std::cout << "Usage: pasteboard\n"
- " --List the types on the pasteboard and in each pasteboard item.\n"
+ " List the types on the pasteboard and in each pasteboard item.\n"
+ " pasteboard -a\n"
+ " Output the data for all types to stdout. Note: output will\n"
+ " in many cases be binary. The different types are separated by a textual header.\n"
" pasteboard -t type\n"
- " --Output the data for the type in question to stdout. Note: output will "
- "in many cases be binary.\n";
+ " Output the data for the type in question to stdout. Note: output will\n"
+ " in many cases be binary.\n";
}
int main(int argc, char** argv)
@@ -32,16 +35,19 @@ int main(int argc, char** argv)
int ch;
- while ((ch = getopt(argc, argv, "t:")) != -1)
+ while ((ch = getopt(argc, argv, "at:")) != -1)
{
switch (ch)
{
+ case 'a':
+ requestedType = @"*";
+ break;
case 't':
requestedType = [NSString stringWithUTF8String:optarg];
break;
case '?':
usage();
- break;
+ return 0;
}
}
@@ -56,6 +62,22 @@ int main(int argc, char** argv)
NSPasteboard* pb = [NSPasteboard generalPasteboard];
+ if ([requestedType isEqualToString:@"*"])
+ {
+ NSArray<NSPasteboardType>* types = [pb types];
+ for (unsigned i = 0; i < [types count]; i++)
+ {
+ NSData* data = [pb dataForType:types[i]];
+ std::cout << i << ": " << [types[i] UTF8String] << ": " << std::to_string([data length]) << " bytes:\n";
+ if (data != nil)
+ {
+ std::cout.write((const char*)[data bytes], [data length]);
+ std::cout << "\n";
+ }
+ }
+ return 0;
+ }
+
if ([requestedType length] > 0)
{
NSData* data = [pb dataForType:requestedType];
More information about the Libreoffice-commits
mailing list