Revision: 17987
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17987&view=rev
Author:   hofman
Date:     2011-06-29 13:32:48 +0000 (Wed, 29 Jun 2011)

Log Message:
-----------
Remove PDFMetadata class, include only used code into category for creating a 
pub

Modified Paths:
--------------
    trunk/bibdesk/BibDocument.m
    trunk/bibdesk/BibItem.h
    trunk/bibdesk/BibItem.m
    trunk/bibdesk/BibItem_PubMedLookup.m
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj

Removed Paths:
-------------
    trunk/bibdesk/PDFMetadata.h
    trunk/bibdesk/PDFMetadata.m

Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2011-06-29 11:47:19 UTC (rev 17986)
+++ trunk/bibdesk/BibDocument.m 2011-06-29 13:32:48 UTC (rev 17987)
@@ -90,7 +90,6 @@
 #import "NSTableView_BDSKExtensions.h"
 #import "NSDictionary_BDSKExtensions.h"
 #import "NSSet_BDSKExtensions.h"
-#import "PDFMetadata.h"
 #import "BDSKSharingServer.h"
 #import "BDSKSharingBrowser.h"
 #import "BDSKTemplate.h"
@@ -2371,7 +2370,7 @@
                     newBI = [BibItem itemByParsingPDFFile:fnStr];              
        
                 // fall back on the least reliable metadata source (hidden 
pref)
                 if(newBI == nil && [[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKShouldUsePDFMetadataKey])
-                    newBI = [BibItem itemWithPDFMetadata:[PDFMetadata 
metadataForURL:url error:&xerror]];
+                    newBI = [BibItem itemWithPDFMetadataFromURL:url];
                        }
             if(newBI == nil)
                 newBI = [[[BibItem alloc] init] autorelease];

Modified: trunk/bibdesk/BibItem.h
===================================================================
--- trunk/bibdesk/BibItem.h     2011-06-29 11:47:19 UTC (rev 17986)
+++ trunk/bibdesk/BibItem.h     2011-06-29 13:32:48 UTC (rev 17987)
@@ -824,12 +824,9 @@
 
 @end
 
-@class PDFMetadata;
 
 @interface BibItem (PDFMetadata)
-+ (BibItem *)itemWithPDFMetadata:(PDFMetadata *)metadata;
-- (PDFMetadata *)PDFMetadata;
-- (void)addPDFMetadataToFileForLocalURLField:(NSString *)field;
++ (BibItem *)itemWithPDFMetadataFromURL:(NSURL *)fileURL;
 @end
 
 extern const CFSetCallBacks kBDSKBibItemEqualitySetCallBacks;

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2011-06-29 11:47:19 UTC (rev 17986)
+++ trunk/bibdesk/BibItem.m     2011-06-29 13:32:48 UTC (rev 17987)
@@ -59,7 +59,6 @@
 #import "NSError_BDSKExtensions.h"
 #import "NSImage_BDSKExtensions.h"
 #import "BDSKStringNode.h"
-#import "PDFMetadata.h"
 #import "BDSKField.h"
 #import "BDSKTemplate.h"
 #import "BDSKTemplateParser.h"
@@ -3224,55 +3223,46 @@
 
 @implementation BibItem (PDFMetadata)
 
-+ (BibItem *)itemWithPDFMetadata:(PDFMetadata *)metadata;
++ (BibItem *)itemWithPDFMetadataFromURL:(NSURL *)fileURL
 {
+    NSParameterAssert(fileURL != nil);
+
     BibItem *item = nil;
-    if(metadata != nil){
-        item = [[[self allocWithZone:[self zone]] init] autorelease];
-        
-        NSString *value = nil;
-        
-        // setting to nil can remove some fields (e.g. keywords), so check 
first
-        value = [metadata valueForKey:PDFDocumentAuthorAttribute];
-        if(value)
-            [item setField:BDSKAuthorString toValue:value];
-        
-        value = [metadata valueForKey:PDFDocumentTitleAttribute];
-        if(value)
-            [item setField:BDSKTitleString toValue:value];
-        
-        // @@ this seems to be set by the filesystem, not as metadata?
-        value = [[[metadata valueForKey:PDFDocumentCreationDateAttribute] 
dateWithCalendarFormat:@"%B %Y" timeZone:[NSTimeZone defaultTimeZone]] 
description];
-        if(value)
-            [item setField:BDSKDateString toValue:value];
-        
-        value = [[metadata valueForKey:PDFDocumentKeywordsAttribute] 
componentsJoinedByString:[[NSUserDefaults standardUserDefaults] 
objectForKey:BDSKDefaultGroupFieldSeparatorKey]];
-        if(value)
-            [item setField:BDSKKeywordsString toValue:value];
+    NSDictionary *metadata = nil;
+    PDFDocument *document = nil;
+    
+    if ((fileURL = [fileURL fileURLByResolvingAliases])) {
+        if ((document = [[PDFDocument alloc] initWithURL:fileURL])) {
+            metadata = [document documentAttributes];
+            if ([metadata count]){
+                item = [[[self allocWithZone:[self zone]] init] autorelease];
+                
+                NSString *value = nil;
+                
+                // setting to nil can remove some fields (e.g. keywords), so 
check first
+                value = [metadata valueForKey:PDFDocumentAuthorAttribute];
+                if(value)
+                    [item setField:BDSKAuthorString toValue:value];
+                
+                value = [metadata valueForKey:PDFDocumentTitleAttribute];
+                if(value)
+                    [item setField:BDSKTitleString toValue:value];
+                
+                // @@ this seems to be set by the filesystem, not as metadata?
+                value = [[[metadata 
valueForKey:PDFDocumentCreationDateAttribute] dateWithCalendarFormat:@"%B %Y" 
timeZone:[NSTimeZone defaultTimeZone]] description];
+                if(value)
+                    [item setField:BDSKDateString toValue:value];
+                
+                value = [[metadata valueForKey:PDFDocumentKeywordsAttribute] 
componentsJoinedByString:[[NSUserDefaults standardUserDefaults] 
objectForKey:BDSKDefaultGroupFieldSeparatorKey]];
+                if(value)
+                    [item setField:BDSKKeywordsString toValue:value];
+            }
+            [document release];
+        }
     }
     return item;
 }
 
-
-- (PDFMetadata *)PDFMetadata;
-{
-    return [PDFMetadata metadataWithBibItem:self];
-}
-
-- (void)addPDFMetadataToFileForLocalURLField:(NSString *)field;
-{
-    NSParameterAssert([field isLocalFileField]);
-    
-    if([[NSUserDefaults standardUserDefaults] 
boolForKey:BDSKShouldUsePDFMetadataKey]){
-        NSError *error = nil;
-        if([[self PDFMetadata] addToURL:[self URLForField:field] error:&error] 
== NO && error != nil)
-            [NSApp presentError:error];
-    }
-}
-
-// convenience for metadata methods; the silly name is because the AS category 
implements -(NSString *)keywords
-- (NSArray *)keywordsArray { return [[self groupsForField:BDSKKeywordsString] 
allObjects]; }
-
 @end
 
 #pragma mark -

Modified: trunk/bibdesk/BibItem_PubMedLookup.m
===================================================================
--- trunk/bibdesk/BibItem_PubMedLookup.m        2011-06-29 11:47:19 UTC (rev 
17986)
+++ trunk/bibdesk/BibItem_PubMedLookup.m        2011-06-29 13:32:48 UTC (rev 
17987)
@@ -43,7 +43,6 @@
 #import <AGRegex/AGRegex.h>
 #import "NSURL_BDSKExtensions.h"
 #import "NSString_BDSKExtensions.h"
-#import "PDFMetadata.h"
 
 @interface BDSKPubMedLookupHelper : NSObject
 + (NSData *)xmlReferenceDataForSearchTerm:(NSString *)searchTerm;

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2011-06-29 11:47:19 UTC 
(rev 17986)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2011-06-29 13:32:48 UTC 
(rev 17987)
@@ -428,7 +428,6 @@
                F90C64070AC62B7B008B2DDA /* BDSKShellCommandFormatter.m in 
Sources */ = {isa = PBXBuildFile; fileRef = F90C64050AC62B7B008B2DDA /* 
BDSKShellCommandFormatter.m */; };
                F911D7120CFE90050009C77B /* BDSKLinkedFile.m in Sources */ = 
{isa = PBXBuildFile; fileRef = F911D7110CFE90050009C77B /* BDSKLinkedFile.m */; 
};
                F91B7F28092BEB5A00976F6F /* AddressBook.framework in Frameworks 
*/ = {isa = PBXBuildFile; fileRef = F91B7F27092BEB5A00976F6F /* 
AddressBook.framework */; };
-               F91F286A09A6684900419960 /* PDFMetadata.m in Sources */ = {isa 
= PBXBuildFile; fileRef = F91F284709A661A700419960 /* PDFMetadata.m */; };
                F9201E020B72504C007E45BB /* BDSKMacro.m in Sources */ = {isa = 
PBXBuildFile; fileRef = F9201E000B72504C007E45BB /* BDSKMacro.m */; };
                F923501A089A813E00EFEB06 /* NSDate_BDSKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = F9235018089A813E00EFEB06 /* 
NSDate_BDSKExtensions.m */; };
                F92405030BC5856900672839 /* BDSKLevelIndicatorCell.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = F92405010BC5856900672839 /* 
BDSKLevelIndicatorCell.m */; };
@@ -1545,8 +1544,6 @@
                F91B5CC7076579830011ED22 /* previewtemplate.tex */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = 
previewtemplate.tex; sourceTree = "<group>"; };
                F91B5CE407657A200011ED22 /* template.txt */ = {isa = 
PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = 
template.txt; sourceTree = "<group>"; };
                F91B7F27092BEB5A00976F6F /* AddressBook.framework */ = {isa = 
PBXFileReference; lastKnownFileType = wrapper.framework; name = 
AddressBook.framework; path = /System/Library/Frameworks/AddressBook.framework; 
sourceTree = "<absolute>"; };
-               F91F284609A661A700419960 /* PDFMetadata.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
PDFMetadata.h; sourceTree = "<group>"; };
-               F91F284709A661A700419960 /* PDFMetadata.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= PDFMetadata.m; sourceTree = "<group>"; };
                F9201DFF0B72504C007E45BB /* BDSKMacro.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKMacro.h; sourceTree = "<group>"; };
                F9201E000B72504C007E45BB /* BDSKMacro.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKMacro.m; sourceTree = "<group>"; };
                F920DAFA075C2B69000C5FCA /* BDSKAppController+Scripting.h */ = 
{isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; 
path = "BDSKAppController+Scripting.h"; sourceTree = "<group>"; };
@@ -2236,7 +2233,6 @@
                                F9022C60075802E300C3F701 /* BibAuthor.m */,
                                F9022C6E075802E300C3F701 /* BibItem.m */,
                                F9B3405C0BBC16720072C2B0 /* 
BibItem_PubMedLookup.m */,
-                               F91F284709A661A700419960 /* PDFMetadata.m */,
                                F97C9DBB0C44866F0002EE01 /* WSGeneratedObj.m */,
                        );
                        name = Data;
@@ -2854,7 +2850,6 @@
                                F97073AD0911592000526FC8 /* 
NSWorkspace_BDSKExtensions.h */,
                                45DB3E4B0CAADFC3001EACDA /* 
NSXMLNode_BDSKExtensions.h */,
                                F947A01A09AA80E4004C27FF /* 
PDFDocument_BDSKExtensions.h */,
-                               F91F284609A661A700419960 /* PDFMetadata.h */,
                                CE05CF5C0D7743940034C2A8 /* WebURLsWithTitles.h 
*/,
                                F97C9DBA0C44866F0002EE01 /* WSGeneratedObj.h */,
                        );
@@ -3584,7 +3579,6 @@
                                F9025F310969D66F008A551C /* 
CFString_BDSKExtensions.m in Sources */,
                                CEAE613F097FF60A000B618C /* BDSKJSTORParser.m 
in Sources */,
                                F9E069B70981A03B00AEFBE7 /* 
BDSKWebOfScienceParser.m in Sources */,
-                               F91F286A09A6684900419960 /* PDFMetadata.m in 
Sources */,
                                F941135509B549BF00EE8463 /* 
BDSKEditorTextView.m in Sources */,
                                F94DE74C09CB46FF00B5FD51 /* 
BDSKPersistentSearch.m in Sources */,
                                CEF7295709CC88AB00802D48 /* 
BDSKFieldSheetController.m in Sources */,

Deleted: trunk/bibdesk/PDFMetadata.h
===================================================================
--- trunk/bibdesk/PDFMetadata.h 2011-06-29 11:47:19 UTC (rev 17986)
+++ trunk/bibdesk/PDFMetadata.h 2011-06-29 13:32:48 UTC (rev 17987)
@@ -1,54 +0,0 @@
-//
-//  PDFMetadata.h
-//  Bibdesk
-//
-//  Created by Adam Maxwell on 02/17/06.
-/*
- This software is Copyright (c) 2006-2011
- Adam Maxwell. All rights reserved.
- 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 
- - Neither the name of Adam Maxwell nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@interface PDFMetadata : NSObject {
-    NSMutableDictionary *dictionary;
-}
-
-+ (id)metadataWithBibItem:(id)anItem;
-+ (id)metadataForURL:(NSURL *)fileURL error:(NSError **)outError;
-
-- (NSDictionary *)dictionary;
-- (void)setDictionary:(NSDictionary *)newDictionary;
-
-- (BOOL)addToURL:(NSURL *)fileURL error:(NSError **)outError;
-
-@end
-

Deleted: trunk/bibdesk/PDFMetadata.m
===================================================================
--- trunk/bibdesk/PDFMetadata.m 2011-06-29 11:47:19 UTC (rev 17986)
+++ trunk/bibdesk/PDFMetadata.m 2011-06-29 13:32:48 UTC (rev 17987)
@@ -1,237 +0,0 @@
-//
-//  PDFMetadata.m
-//  Bibdesk
-//
-//  Created by Adam Maxwell on 02/17/06.
-/*
- This software is Copyright (c) 2006-2011
- Adam Maxwell. All rights reserved.
- 
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- 
- - Neither the name of Adam Maxwell nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
- 
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "PDFMetadata.h"
-#import <Quartz/Quartz.h>
-#import "NSURL_BDSKExtensions.h"
-
-static NSDictionary *translator = nil;
-
-/* The purpose of this class is to provide an easy interface to set and get 
the attributes of a PDF document in bulk, acting an an intermediary between our 
model objects and the PDFDocument (or whatever we eventually use). */
-
-@implementation PDFMetadata
-
-+ (void)initialize
-{
-    BDSKINITIALIZE;
-    // provides a dictionary of key paths matched to the PDFDocument keys
-    translator = [[NSDictionary alloc] 
initWithObjectsAndKeys:@"pubAuthorsForDisplay", PDFDocumentAuthorAttribute, 
@"keywordsArray", PDFDocumentKeywordsAttribute, @"title.stringByRemovingTeX", 
PDFDocumentTitleAttribute, @"date", PDFDocumentCreationDateAttribute, nil];
-}
-
-// an "item" is some object that is KVC compliant for the keys in the 
translator; nominally a BibItem
-+ (id)metadataWithBibItem:(id)anItem;
-{
-    PDFMetadata *metadata = [[[self allocWithZone:[self zone]] init] 
autorelease];
-    id value = nil;
-    
-    value = [anItem valueForKeyPath:[translator 
objectForKey:PDFDocumentTitleAttribute]];
-    if(value != nil)
-        [metadata setValue:value forKey:PDFDocumentTitleAttribute];
-    
-    value = [anItem valueForKeyPath:[translator 
objectForKey:PDFDocumentAuthorAttribute]];
-    if(value != nil)
-        [metadata setValue:value forKey:PDFDocumentAuthorAttribute];
-    
-    value = [anItem valueForKeyPath:[translator 
objectForKey:PDFDocumentKeywordsAttribute]];
-    if(value != nil)
-        [metadata setValue:value forKey:PDFDocumentKeywordsAttribute];
-    
-    // docs say this is an NSString, but the PDFDocument returns an NSCFDate 
(header says it's an NSDate) rdar://problem:/4450219
-    value = [anItem valueForKeyPath:[translator 
objectForKey:PDFDocumentCreationDateAttribute]];
-    if(value != nil)
-        [metadata setValue:value forKey:PDFDocumentCreationDateAttribute];
-    
-    return metadata;
-}
-
-+ (id)metadataForURL:(NSURL *)fileURL error:(NSError **)outError;
-{
-    
-    NSParameterAssert(fileURL != nil);
-
-    PDFMetadata *metadata = nil;
-    // check file type first?
-    NSError *error = nil;
-    NSString *errMsg = @"";
-    NSString *privateException = NSStringFromSelector(_cmd);
-    PDFDocument *document = nil;
-    
-    @try {
-        
-        fileURL = [fileURL fileURLByResolvingAliases];
-        if(fileURL == nil){
-            errMsg = NSLocalizedString(@"File does not exist.", @"Error 
description");
-            @throw privateException;
-        }
-        
-        document = [[PDFDocument alloc] initWithURL:fileURL];
-        if(document == nil){
-            errMsg = NSLocalizedString(@"Unable to read as PDF file.", @"Error 
description");
-            @throw privateException;
-        }
-        
-        NSDictionary *attributes = [document documentAttributes];
-        
-        if(attributes){
-            // have to use NSClassFromString unless we link with PDFMetadata
-            metadata = [[[self alloc] init] autorelease];
-            [metadata setDictionary:attributes];
-        } else {
-            errMsg = NSLocalizedString(@"No PDF document attributes for 
file.", @"Error description");
-            @throw privateException;
-        }
-        
-    }
-    
-    @catch(id exception){
-        
-        if([exception isEqual:privateException]){
-            NSMutableDictionary *userInfo = [NSMutableDictionary 
dictionaryWithCapacity:3];
-            if([fileURL path])
-                [userInfo setObject:[fileURL path] forKey:NSFilePathErrorKey];
-            if(errMsg != nil)
-                [userInfo setObject:errMsg forKey:NSLocalizedDescriptionKey];
-            if(error != nil)
-                [userInfo setObject:error forKey:NSUnderlyingErrorKey];
-            error = [NSError errorWithDomain:NSCocoaErrorDomain code:0 
userInfo:userInfo];
-        } else @throw;
-    }
-    
-    @finally {
-        [document release];
-    }
-    
-    if(outError)
-        *outError = error;
-    else
-        NSLog(@"%@ %@", self, error);
-    return metadata; // may be nil
-}
-
-// the keys in the metadata dictionary must be PDFDocument keys
-- (id)init
-{
-    if(self = [super init]){
-        dictionary = [[NSMutableDictionary alloc] initWithCapacity:5];
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    BDSKDESTROY(dictionary);
-    [super dealloc];
-}
-
-- (NSString *)description
-{
-    return [NSString stringWithFormat:@"%@: %@", [self class], dictionary];
-}
-
-// these keys are /always/ PDFDocument keys
-- (id)valueForUndefinedKey:(NSString *)key { return [dictionary 
valueForKey:key]; }
-- (void)setValue:(id)value forUndefinedKey:(NSString *)key {  [dictionary 
setValue:value forKey:key]; }
-
-- (NSDictionary *)dictionary { return dictionary; }
-
-- (void)setDictionary:(NSDictionary *)newDictionary;
-{
-    if(newDictionary != dictionary){
-        [dictionary release];
-        dictionary = [newDictionary mutableCopy];
-    }
-}
-
-- (BOOL)addToURL:(NSURL *)fileURL error:(NSError **)outError;
-{
-    NSParameterAssert(fileURL != nil);
-    
-    // check file type first?
-    NSError *error = nil;
-    NSString *errMsg = @"";
-    NSString *privateException = NSStringFromSelector(_cmd);
-    
-    @try {
-        
-        fileURL = [fileURL fileURLByResolvingAliases];
-        if(fileURL == nil){
-            errMsg = NSLocalizedString(@"File does not exist.", @"Error 
description");
-            @throw privateException;
-        }
-        
-        PDFDocument *document = [[PDFDocument alloc] initWithURL:fileURL];
-        if(document == nil){
-            errMsg = NSLocalizedString(@"Unable to read as PDF file.", @"Error 
description");
-            @throw privateException;
-        }
-        
-        [document setDocumentAttributes:dictionary];
-        
-        // -[PDFDocument writeToURL:] returns YES even if it fails 
rdar://problem/4475062
-        if([[document dataRepresentation] writeToURL:fileURL 
options:NSAtomicWrite error:&error] == NO){
-            errMsg = NSLocalizedString(@"Unable to save PDF file.", @"Error 
description");
-            [document release];
-            @throw privateException;
-        }
-        
-        [document release];
-    }
-    @catch(id exception){
-        
-        if([exception isEqual:privateException]){
-            NSMutableDictionary *userInfo = [NSMutableDictionary 
dictionaryWithCapacity:3];
-            if([fileURL path])
-                [userInfo setObject:[fileURL path] forKey:NSFilePathErrorKey];
-            if(errMsg != nil)
-                [userInfo setObject:errMsg forKey:NSLocalizedDescriptionKey];
-            if(error != nil)
-                [userInfo setObject:error forKey:NSUnderlyingErrorKey];
-            error = [NSError errorWithDomain:NSCocoaErrorDomain code:0 
userInfo:userInfo];
-            if(outError)
-                *outError = error;
-            else
-                NSLog(@"%@ %@", self, error);
-            return NO;
-        } else @throw;
-    }
-    
-    return YES;
-}
-
-@end
-


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

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to