Revision: 4971
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4971&view=rev
Author:   hofman
Date:     2008-11-19 13:14:11 +0000 (Wed, 19 Nov 2008)

Log Message:
-----------
Add filewrapper for bundled image for attachment used by thumbnail generator. 
Only include image attachments that are needed for preview.

Modified Paths:
--------------
    trunk/QuickLook-Skim/GeneratePreviewForURL.m
    trunk/QuickLook-Skim/SKQLConverter.m

Modified: trunk/QuickLook-Skim/GeneratePreviewForURL.m
===================================================================
--- trunk/QuickLook-Skim/GeneratePreviewForURL.m        2008-11-18 19:02:11 UTC 
(rev 4970)
+++ trunk/QuickLook-Skim/GeneratePreviewForURL.m        2008-11-19 13:14:11 UTC 
(rev 4971)
@@ -40,16 +40,15 @@
 
 static const CGFloat _fontSize = 12.0;
 
-static NSDictionary *imageAttachments()
+static NSDictionary *imageAttachments(NSSet *imageNames)
 {
     NSMutableDictionary *attachments = [NSMutableDictionary dictionary];
     NSBundle *bundle = SKQLGetMainBundle();
-    NSArray *allImageNames = [NSArray arrayWithObjects:@"FreeText", @"Note", 
@"Circle", @"Square", @"Highlight", @"Underline", @"StrikeOut", @"Line", 
@"Ink", nil];
     NSString *imageName;
     NSMutableDictionary *imgProps;
     NSData *imgData;
     
-    for (imageName in allImageNames) {
+    for (imageName in imageNames) {
         if (imgData = [NSData dataWithContentsOfFile:[bundle 
pathForResource:imageName ofType:@"png"]]) {
             imgProps = [[NSMutableDictionary alloc] init];
             [imgProps setObject:imgData forKey:(NSString 
*)kQLPreviewPropertyAttachmentDataKey];
@@ -86,13 +85,15 @@
         
         NSData *data = [[NSData alloc] initWithContentsOfURL:(NSURL *)url 
options:NSUncachedRead error:NULL];
         if (data) {
-            NSString *htmlString = [SKQLConverter 
htmlStringWithNotes:[NSKeyedUnarchiver unarchiveObjectWithData:data]];
+            NSArray *notes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+            NSString *htmlString = [SKQLConverter htmlStringWithNotes:notes];
             [data release];
             if (data = [htmlString dataUsingEncoding:NSUTF8StringEncoding]) {
+                NSSet *types = [NSSet setWithArray:[notes 
valueForKey:@"type"]];
                 NSDictionary *props = [NSDictionary 
dictionaryWithObjectsAndKeys:
                                             @"UTF-8", (NSString 
*)kQLPreviewPropertyTextEncodingNameKey,
                                             @"text/html", (NSString 
*)kQLPreviewPropertyMIMETypeKey,
-                                            imageAttachments(), (NSString 
*)kQLPreviewPropertyAttachmentsKey, nil];
+                                            imageAttachments(types), (NSString 
*)kQLPreviewPropertyAttachmentsKey, nil];
                 QLPreviewRequestSetDataRepresentation(preview, 
(CFDataRef)data, kUTTypeHTML, (CFDictionaryRef)props);
                 err = noErr;
             }

Modified: trunk/QuickLook-Skim/SKQLConverter.m
===================================================================
--- trunk/QuickLook-Skim/SKQLConverter.m        2008-11-18 19:02:11 UTC (rev 
4970)
+++ trunk/QuickLook-Skim/SKQLConverter.m        2008-11-19 13:14:11 UTC (rev 
4971)
@@ -60,10 +60,8 @@
 
 static NSAttributedString *imageAttachmentForType(NSString *type)
 {        
-    NSImage *image = [[NSImage alloc] 
initWithContentsOfFile:[SKQLGetMainBundle() pathForResource:type 
ofType:@"png"]];
-    NSFileWrapper *wrapper = [[NSFileWrapper alloc] 
initRegularFileWithContents:[image TIFFRepresentation]];
-    [image release];
-    [wrapper setPreferredFilename:[type 
stringByAppendingPathExtension:@"tiff"]];
+    NSFileWrapper *wrapper = [[NSFileWrapper alloc] 
initWithPath:[SKQLGetMainBundle() pathForResource:type ofType:@"png"]];
+    [wrapper setPreferredFilename:[type 
stringByAppendingPathExtension:@"png"]];
     
     NSTextAttachment *attachment = [[NSTextAttachment alloc] 
initWithFileWrapper:wrapper];
     [wrapper release];


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to