diff --git a/Tools/xpbs.m b/Tools/xpbs.m index b5ae9adf..deae543f 100644 --- a/Tools/xpbs.m +++ b/Tools/xpbs.m @@ -83,7 +83,8 @@ "image/svg", "application/rtf", "text/richtext", - "text/plain;charset=utf-8" + "text/plain;charset=utf-8", + "application/pdf" }; static Atom atoms[sizeof(atom_names)/sizeof(char*)]; @@ -128,6 +129,7 @@ #define XG_MIME_APP_RTF atoms[34] #define XG_MIME_TEXT_RICHTEXT atoms[35] #define XG_MIME_UTF8 atoms[36] +#define XG_MIME_PDF atoms[37] /** Return the GNUstep pasteboard type corresponding to the given atom * or nil if there is no corresponding type. @@ -158,6 +160,11 @@ return NSRTFPboardType; } + if (XG_MIME_PDF == type) + { + return NSPasteboardTypePDF; + } + if (XG_MIME_PNG == type) { return NSPasteboardTypePNG; @@ -856,7 +863,11 @@ - (void) pasteboard: (NSPasteboard*)pb provideDataForType: (NSString*)type else if ([type isEqual: NSPasteboardTypePNG]) { NSDebugLLog(@"Pbs", @"pasteboard: provideDataForType: - requestData XG_MIME_PNG"); - [self requestData: XG_MIME_PNG]; + [self requestData: (xType = XG_MIME_PNG)]; + } + else if ([type isEqual: NSPasteboardTypePDF]) + { + [self requestData: (xType = XG_MIME_PDF)]; } // FIXME: Support more types else @@ -1331,6 +1342,10 @@ - (void) xSelectionNotify: (XSelectionEvent*)xEvent { [self setData: md]; } + else if (actual_type == XG_MIME_PDF) + { + [self setData: md]; + } else if (actual_type == XG_MIME_PNG) { [self setData: md]; @@ -1414,7 +1429,7 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent { unsigned numTypes = 0; // ATTENTION: Increase this array when adding more types - Atom xTypes[18]; + Atom xTypes[19]; /* * The requestor wants a list of the types we can supply it with. @@ -1455,6 +1470,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent xTypes[numTypes++] = XG_MIME_TIFF; } + if ([types containsObject: NSPasteboardTypePDF]) + { + xTypes[numTypes++] = XG_MIME_PDF; + } + if ([types containsObject: NSPasteboardTypePNG]) { xTypes[numTypes++] = XG_MIME_PNG; @@ -1548,6 +1568,11 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent xEvent->target = XG_MIME_TIFF; [self xProvideSelection: xEvent]; } + else if ([types containsObject: NSPasteboardTypePDF]) + { + xEvent->target = XG_MIME_PDF; + [self xProvideSelection: xEvent]; + } else if ([types containsObject: NSPasteboardTypePNG]) { xEvent->target = XG_MIME_PNG; @@ -1691,6 +1716,14 @@ - (BOOL) xProvideSelection: (XSelectionRequestEvent*)xEvent format = 8; numItems = [data length]; } + else if ((xEvent->target == XG_MIME_PDF) + && [types containsObject: NSPasteboardTypePDF]) + { + data = [_pb dataForType: NSPasteboardTypePDF]; + xType = xEvent->target; + format = 8; + numItems = [data length]; + } else if ((xEvent->target == XG_MIME_PNG) && [types containsObject: NSPasteboardTypePNG]) {