Revision: 7786
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7786&view=rev
Author:   hofman
Date:     2012-11-05 10:51:26 +0000 (Mon, 05 Nov 2012)
Log Message:
-----------
remove now unused synchronizer server class

Modified Paths:
--------------
    trunk/Skim.xcodeproj/project.pbxproj

Removed Paths:
-------------
    trunk/SKPDFSynchronizerServer.h
    trunk/SKPDFSynchronizerServer.m

Deleted: trunk/SKPDFSynchronizerServer.h
===================================================================
--- trunk/SKPDFSynchronizerServer.h     2012-11-05 10:40:58 UTC (rev 7785)
+++ trunk/SKPDFSynchronizerServer.h     2012-11-05 10:51:26 UTC (rev 7786)
@@ -1,84 +0,0 @@
-//
-//  SKPDFSynchronizerServer.h
-//  Skim
-//
-//  Created by Christiaan Hofman on 1/11/09.
-/*
- This software is Copyright (c) 2009-2012
- Christiaan Hofman. 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 Christiaan Hofman 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>
-#import "synctex_parser.h"
-
-
-@interface SKPDFSynchronizerServer : NSObject {
-    NSString *fileName;
-    NSString *syncFileName;
-    NSDate *lastModDate;
-    BOOL isPdfsync;
-    
-    NSFileManager *fileManager;
-    
-    NSMutableArray *pages;
-    NSMapTable *lines;
-    
-    NSMapTable *filenames;
-    synctex_scanner_t scanner;
-    
-    id clientProxy;
-    NSConnection *connection;
-    BOOL stopRunning;
-    struct SKServerFlags *serverFlags;
-}
-
-// these properties are thread safe
-@property BOOL shouldKeepRunning;
-@property (copy) NSString *fileName;
-
-// this sets up the background thread and connects back to the client, blocks 
until it's fully set up
-- (void)startDOServerForPorts:(NSArray *)ports;
-
-@end
-
-// these methods can be sent to the proxy for the server and are implemented 
by the server
-@protocol SKPDFSynchronizerServer
-- (oneway void)stopRunning; 
-- (oneway void)findFileAndLineForLocation:(NSPoint)point inRect:(NSRect)rect 
pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex;
-- (oneway void)findPageAndLocationForLine:(NSInteger)line inFile:(bycopy 
NSString *)file options:(NSInteger)options;
-@end
-
-// these methods can be sent to the proxy for the client and must be 
implemented by the client
-@protocol SKPDFSynchronizerClient
-- (void)setServerProxy:(byref id)anObject;
-- (oneway void)foundLine:(NSInteger)line inFile:(bycopy NSString *)file;
-- (oneway void)foundLocation:(NSPoint)point atPageIndex:(NSUInteger)pageIndex 
options:(NSInteger)options;
-@end

Deleted: trunk/SKPDFSynchronizerServer.m
===================================================================
--- trunk/SKPDFSynchronizerServer.m     2012-11-05 10:40:58 UTC (rev 7785)
+++ trunk/SKPDFSynchronizerServer.m     2012-11-05 10:51:26 UTC (rev 7786)
@@ -1,676 +0,0 @@
-//
-//  SKPDFSynchronizerServer.m
-//  Skim
-//
-//  Created by Christiaan Hofman on 1/11/09.
-/*
- This software is Copyright (c) 2009-2012
- Christiaan Hofman. 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 Christiaan Hofman 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 "SKPDFSynchronizerServer.h"
-#import "SKPDFSynchronizer.h"
-#import <libkern/OSAtomic.h>
-#import "SKPDFSyncRecord.h"
-#import "NSCharacterSet_SKExtensions.h"
-#import "NSScanner_SKExtensions.h"
-#import <CoreFoundation/CoreFoundation.h>
-#import "NSFileManager_SKExtensions.h"
-#import "NSMapTable_SKExtensions.h"
-
-#define PDFSYNC_TO_PDF(coord) ((CGFloat)coord / 65536.0)
-
-// Offset of coordinates in PDFKit and what pdfsync tells us. Don't know what 
they are; is this implementation dependent?
-static NSPoint pdfOffset = {0.0, 0.0};
-
-#define SKPDFSynchronizerPdfsyncExtension @"pdfsync"
-static NSArray *SKPDFSynchronizerTexExtensions = nil;
-
-struct SKServerFlags {
-    volatile int32_t shouldKeepRunning;
-    volatile int32_t serverReady;
-};
-
-#pragma mark -
-
-@implementation SKPDFSynchronizerServer
-
-@dynamic shouldKeepRunning, fileName;
-
-+ (void)initialize {
-    SKINITIALIZE;
-    SKPDFSynchronizerTexExtensions = [[NSArray alloc] initWithObjects:@"tex", 
@"ltx", @"latex", @"ctx", @"lyx", nil];
-}
-
-- (id)init {
-    self = [super init];
-    if (self) {
-        fileName = nil;
-        syncFileName = nil;
-        lastModDate = nil;
-        isPdfsync = YES;
-        
-        pages = nil;
-        lines = nil;
-        
-        filenames = nil;
-        scanner = NULL;
-        
-        // these will be set when the background thread sets up
-        connection = nil;
-        clientProxy = nil;
-        
-        serverFlags = NSZoneCalloc(NSDefaultMallocZone(), 1, sizeof(struct 
SKServerFlags));
-        serverFlags->shouldKeepRunning = 1;
-        serverFlags->serverReady = 0;
-        
-        stopRunning = NO;
-    }
-    return self;
-}
-
-- (void)dealloc {
-    NSZoneFree(NSDefaultMallocZone(), serverFlags);
-    SKDESTROY(pages);
-    SKDESTROY(lines);
-    SKDESTROY(filenames);
-    SKDESTROY(fileName);
-    SKDESTROY(syncFileName);
-    SKDESTROY(lastModDate);
-    [super dealloc];
-}
-
-#pragma mark DO Server
-
-#pragma mark | Thread safe accessors
-
-- (BOOL)shouldKeepRunning {
-    OSMemoryBarrier();
-    return serverFlags->shouldKeepRunning == 1;
-}
-
-- (void)setShouldKeepRunning:(BOOL)flag {
-    int32_t old = flag ? 0 : 1, new = flag ? 1 : 0;
-    OSAtomicCompareAndSwap32Barrier(old, new, (int32_t 
*)&serverFlags->shouldKeepRunning);
-}
-
-#pragma mark | Running the server
-
-- (void)runDOServerForPorts:(NSArray *)ports {
-    // detach a new thread to run this
-    NSAssert(connection == nil, @"server is already running");
-    
-    NSAutoreleasePool *pool = [NSAutoreleasePool new];
-    
-    @try {
-        // we'll use this to communicate between threads on the localhost
-        connection = [[NSConnection alloc] initWithReceivePort:[ports 
objectAtIndex:0] sendPort:[ports objectAtIndex:1]];
-        if (connection == nil)
-            @throw @"Unable to get default connection";
-        [connection setRootObject:self];
-        
-        clientProxy = [[connection rootProxy] retain];
-        [clientProxy setProtocolForProxy:@protocol(SKPDFSynchronizerClient)];
-        // handshake, this sets the proxy at the other side
-        [clientProxy setServerProxy:self];
-        
-        fileManager = [[NSFileManager alloc] init];
-        
-        OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t 
*)&serverFlags->serverReady);
-        
-        NSRunLoop *rl = [NSRunLoop currentRunLoop];
-        BOOL didRun;
-        
-        // see 
http://lists.apple.com/archives/cocoa-dev/2006/Jun/msg01054.html for a helpful 
explanation of NSRunLoop
-        do {
-            [pool release];
-            pool = [NSAutoreleasePool new];
-            didRun = [rl runMode:NSDefaultRunLoopMode beforeDate:[NSDate 
distantFuture]];
-        } while (stopRunning == NO && didRun);
-    }
-    @catch(id exception) {
-        NSLog(@"Discarding exception \"%@\" raised in object %@", exception, 
self);
-        // allow the main thread to continue, anyway
-        OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t 
*)&serverFlags->serverReady);
-    }
-    @finally {
-        SKDESTROY(fileManager);
-        
-        // clean up the connection in the server thread
-        [connection setRootObject:nil];
-        
-        // this frees up the CFMachPorts created in -init
-        [[connection receivePort] invalidate];
-        [[connection sendPort] invalidate];
-        [connection invalidate];
-        SKDESTROY(connection);
-        SKDESTROY(clientProxy);    
-        
-        if (scanner) {
-            synctex_scanner_free(scanner);
-            scanner = NULL;
-        }
-        
-        [pool release];
-    }
-}
-
-- (void)startDOServerForPorts:(NSArray *)ports {
-    [NSThread detachNewThreadSelector:@selector(runDOServerForPorts:) 
toTarget:self withObject:ports];
-    
-    // wait till the server is set up
-    do {
-        if (NO == [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]])
-            [self setShouldKeepRunning:NO];
-        OSMemoryBarrier();
-    } while (serverFlags->serverReady == 0 && serverFlags->shouldKeepRunning 
== 1);
-}
-
-#pragma mark | Server protocol
-
-- (oneway void)stopRunning {
-    stopRunning = YES;
-}
-
-#pragma mark Finding and Parsing
-
-#pragma mark | Thread safe accessors
-
-- (NSString *)fileName {
-    NSString *file = nil;
-    @synchronized(self) {
-        file = [[fileName retain] autorelease];
-    }
-    return file;
-}
-
-- (void)setFileName:(NSString *)newFileName {
-    // we compare filenames in canonical form throughout, so we need to make 
sure fileName also is in canonical form
-    newFileName = [[newFileName stringByResolvingSymlinksInPath] 
stringByStandardizingPath];
-    @synchronized(self) {
-        if (fileName != newFileName) {
-            if ([fileName isEqualToString:newFileName] == NO) {
-                SKDESTROY(syncFileName);
-                SKDESTROY(lastModDate);
-            }
-            [fileName release];
-            fileName = [newFileName retain];
-        }
-    }
-}
-
-- (NSString *)syncFileName {
-    NSString *file = nil;
-    @synchronized(self) {
-        file = [[syncFileName retain] autorelease];
-    }
-    return file;
-}
-
-// this should only be used from the server thread
-- (void)setSyncFileName:(NSString *)newSyncFileName {
-    @synchronized(self) {
-        if (syncFileName != newSyncFileName) {
-            [syncFileName release];
-            syncFileName = [newSyncFileName retain];
-        }
-        [lastModDate release];
-        lastModDate = [(syncFileName ? [[fileManager 
attributesOfItemAtPath:syncFileName error:NULL] fileModificationDate] : nil) 
retain];
-    }
-}
-
-- (NSDate *)lastModDate {
-    NSDate *date = nil;
-    @synchronized(self) {
-        date = [[lastModDate retain] autorelease];
-    }
-    return date;
-}
-
-#pragma mark | Support
-
-- (NSString *)sourceFileForFileName:(NSString *)file isTeX:(BOOL)isTeX 
removeQuotes:(BOOL)removeQuotes {
-    if (removeQuotes && [file length] > 2 && [file characterAtIndex:0] == '"' 
&& [file characterAtIndex:[file length] - 1] == '"')
-        file = [file substringWithRange:NSMakeRange(1, [file length] - 2)];
-    if ([file isAbsolutePath] == NO)
-        file = [[[self fileName] stringByDeletingLastPathComponent] 
stringByAppendingPathComponent:file];
-    if (isTeX && [fileManager fileExistsAtPath:file] == NO && 
[SKPDFSynchronizerTexExtensions containsObject:[[file pathExtension] 
lowercaseString]] == NO) {
-        for (NSString *extension in SKPDFSynchronizerTexExtensions) {
-            NSString *tryFile = [file 
stringByAppendingPathExtension:extension];
-            if ([fileManager fileExistsAtPath:tryFile]) {
-                file = tryFile;
-                break;
-            }
-        }
-    }
-    // the docs say -stringByStandardizingPath uses 
-stringByResolvingSymlinksInPath, but it doesn't 
-    return [[file stringByResolvingSymlinksInPath] stringByStandardizingPath];
-}
-
-- (NSString *)sourceFileForFileSystemRepresentation:(const char *)fileRep 
isTeX:(BOOL)isTeX {
-    NSString *file = (NSString 
*)CFStringCreateWithFileSystemRepresentation(NULL, fileRep);
-    return [self sourceFileForFileName:[file autorelease] isTeX:isTeX 
removeQuotes:NO];
-}
-
-#pragma mark | PDFSync
-
-- (BOOL)loadPdfsyncFile:(NSString *)theFileName {
-
-    if (pages)
-        [pages removeAllObjects];
-    else
-        pages = [[NSMutableArray alloc] init];
-    if (lines)
-        [lines removeAllObjects];
-    else
-        lines = [[NSMapTable alloc] initForCaseInsensitiveStringKeys];
-    
-    [self setSyncFileName:theFileName];
-    isPdfsync = YES;
-    
-    NSString *pdfsyncString = [NSString stringWithContentsOfFile:theFileName 
encoding:NSUTF8StringEncoding error:NULL];
-    BOOL rv = NO;
-    
-    if ([pdfsyncString length]) {
-        
-        SKPDFSyncRecords *records = [[SKPDFSyncRecords alloc] init];
-        NSMutableArray *files = [[NSMutableArray alloc] init];
-        NSString *file;
-        NSInteger recordIndex, line, pageIndex;
-        double x, y;
-        SKPDFSyncRecord *record;
-        NSMutableArray *array;
-        unichar ch;
-        NSScanner *sc = [[NSScanner alloc] initWithString:pdfsyncString];
-        NSCharacterSet *newlines = [NSCharacterSet newlineCharacterSet];
-        
-        [sc setCharactersToBeSkipped:[NSCharacterSet whitespaceCharacterSet]];
-        
-        if ([sc scanUpToCharactersFromSet:newlines intoString:&file] &&
-            [sc scanCharactersFromSet:newlines intoString:NULL]) {
-            
-            file = [self sourceFileForFileName:file isTeX:YES 
removeQuotes:YES];
-            [files addObject:file];
-            
-            array = [[NSMutableArray alloc] init];
-            [lines setObject:array forKey:file];
-            [array release];
-            
-            // we ignore the version
-            if ([sc scanString:@"version" intoString:NULL] && [sc 
scanInteger:NULL]) {
-                
-                [sc scanCharactersFromSet:newlines intoString:NULL];
-                
-                while ([self shouldKeepRunning] && [sc scanCharacter:&ch]) {
-                    
-                    switch (ch) {
-                        case 'l':
-                            if ([sc scanInteger:&recordIndex] && [sc 
scanInteger:&line]) {
-                                // we ignore the column
-                                [sc scanInteger:NULL];
-                                record = [records recordForIndex:recordIndex];
-                                [record setFile:file];
-                                [record setLine:line];
-                                [[lines objectForKey:file] addObject:record];
-                            }
-                            break;
-                        case 'p':
-                            // we ignore * and + modifiers
-                            if ([sc scanString:@"*" intoString:NULL] == NO)
-                                [sc scanString:@"+" intoString:NULL];
-                            if ([sc scanInteger:&recordIndex] && [sc 
scanDouble:&x] && [sc scanDouble:&y]) {
-                                record = [records recordForIndex:recordIndex];
-                                [record setPageIndex:[pages count] - 1];
-                                [record setPoint:NSMakePoint(PDFSYNC_TO_PDF(x) 
+ pdfOffset.x, PDFSYNC_TO_PDF(y) + pdfOffset.y)];
-                                [[pages lastObject] addObject:record];
-                            }
-                            break;
-                        case 's':
-                            // start of a new page, the scanned integer should 
always equal [pages count]+1
-                            if ([sc scanInteger:&pageIndex] == NO) pageIndex = 
[pages count] + 1;
-                            while (pageIndex > (NSInteger)[pages count]) {
-                                array = [[NSMutableArray alloc] init];
-                                [pages addObject:array];
-                                [array release];
-                            }
-                            break;
-                        case '(':
-                            // start of a new source file
-                            if ([sc scanUpToCharactersFromSet:newlines 
intoString:&file]) {
-                                file = [self sourceFileForFileName:file 
isTeX:YES removeQuotes:YES];
-                                [files addObject:file];
-                                if ([lines objectForKey:file] == nil) {
-                                    array = [[NSMutableArray alloc] init];
-                                    [lines setObject:array forKey:file];
-                                    [array release];
-                                }
-                            }
-                            break;
-                        case ')':
-                            // closing of a source file
-                            if ([files count]) {
-                                [files removeLastObject];
-                                file = [files lastObject];
-                            }
-                            break;
-                        default:
-                            // shouldn't reach
-                            break;
-                    }
-                    
-                    [sc scanUpToCharactersFromSet:newlines intoString:NULL];
-                    [sc scanCharactersFromSet:newlines intoString:NULL];
-                }
-                
-                NSSortDescriptor *lineSortDescriptor = [[[NSSortDescriptor 
alloc] initWithKey:@"line" ascending:YES] autorelease];
-                NSSortDescriptor *xSortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:@"x" ascending:YES] autorelease];
-                NSSortDescriptor *ySortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:@"y" ascending:NO] autorelease];
-                NSArray *lineSortDescriptors = [NSArray 
arrayWithObjects:lineSortDescriptor, nil];
-                
-                for (array in [lines objectEnumerator])
-                    [array sortUsingDescriptors:lineSortDescriptors];
-                [pages 
makeObjectsPerformSelector:@selector(sortUsingDescriptors:)
-                                       withObject:[NSArray 
arrayWithObjects:ySortDescriptor, xSortDescriptor, nil]];
-                
-                rv = [self shouldKeepRunning];
-            }
-        }
-        
-        [records release];
-        [files release];
-        [sc release];
-    }
-    
-    return rv;
-}
-
-- (BOOL)pdfsyncFindFileLine:(NSInteger *)linePtr file:(NSString **)filePtr 
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds 
atPageIndex:(NSUInteger)pageIndex {
-    BOOL rv = NO;
-    if (pageIndex < [pages count]) {
-        
-        SKPDFSyncRecord *record = nil;
-        SKPDFSyncRecord *beforeRecord = nil;
-        SKPDFSyncRecord *afterRecord = nil;
-        NSMutableDictionary *atRecords = [NSMutableDictionary dictionary];
-        
-        for (record in [pages objectAtIndex:pageIndex]) {
-            if ([record line] == 0)
-                continue;
-            NSPoint p = [record point];
-            if (p.y > NSMaxY(rect)) {
-                beforeRecord = record;
-            } else if (p.y < NSMinY(rect)) {
-                afterRecord = record;
-                break;
-            } else if (p.x < NSMinX(rect)) {
-                beforeRecord = record;
-            } else if (p.x > NSMaxX(rect)) {
-                afterRecord = record;
-                break;
-            } else {
-                [atRecords setObject:record forKey:[NSNumber 
numberWithDouble:fabs(p.x - point.x)]];
-            }
-        }
-        
-        record = nil;
-        if ([atRecords count]) {
-            NSNumber *nearest = [[[atRecords allKeys] 
sortedArrayUsingSelector:@selector(compare:)] objectAtIndex:0];
-            record = [atRecords objectForKey:nearest];
-        } else if (beforeRecord && afterRecord) {
-            NSPoint beforePoint = [beforeRecord point];
-            NSPoint afterPoint = [afterRecord point];
-            if (beforePoint.y - point.y < point.y - afterPoint.y)
-                record = beforeRecord;
-            else if (beforePoint.y - point.y > point.y - afterPoint.y)
-                record = afterRecord;
-            else if (beforePoint.x - point.x < point.x - afterPoint.x)
-                record = beforeRecord;
-            else if (beforePoint.x - point.x > point.x - afterPoint.x)
-                record = afterRecord;
-            else
-                record = beforeRecord;
-        } else if (beforeRecord) {
-            record = beforeRecord;
-        } else if (afterRecord) {
-            record = afterRecord;
-        }
-        
-        if (record) {
-            *linePtr = [record line];
-            *filePtr = [record file];
-            rv = YES;
-        }
-    }
-    if (rv == NO)
-        NSLog(@"PDFSync was unable to find file and line.");
-    return rv;
-}
-
-- (BOOL)pdfsyncFindPage:(NSUInteger *)pageIndexPtr location:(NSPoint 
*)pointPtr forLine:(NSInteger)line inFile:(NSString *)file {
-    BOOL rv = NO;
-    NSArray *theLines = [lines objectForKey:file];
-    if (theLines) {
-        
-        SKPDFSyncRecord *record = nil;
-        SKPDFSyncRecord *beforeRecord = nil;
-        SKPDFSyncRecord *afterRecord = nil;
-        SKPDFSyncRecord *atRecord = nil;
-        
-        for (record in theLines) {
-            if ([record pageIndex] == NSNotFound)
-                continue;
-            NSInteger l = [record line];
-            if (l < line) {
-                beforeRecord = record;
-            } else if (l > line) {
-                afterRecord = record;
-                break;
-            } else {
-                atRecord = record;
-                break;
-            }
-        }
-        
-        if (atRecord) {
-            record = atRecord;
-        } else if (beforeRecord && afterRecord) {
-            NSInteger beforeLine = [beforeRecord line];
-            NSInteger afterLine = [afterRecord line];
-            if (beforeLine - line > line - afterLine)
-                record = afterRecord;
-            else
-                record = beforeRecord;
-        } else if (beforeRecord) {
-            record = beforeRecord;
-        } else if (afterRecord) {
-            record = afterRecord;
-        }
-        
-        if (record) {
-            *pageIndexPtr = [record pageIndex];
-            *pointPtr = [record point];
-            rv = YES;
-        }
-    }
-    if (rv == NO)
-        NSLog(@"PDFSync was unable to find location and page.");
-    return rv;
-}
-
-#pragma mark | SyncTeX
-
-- (BOOL)loadSynctexFileForFile:(NSString *)theFileName {
-    BOOL rv = NO;
-    if (scanner)
-        synctex_scanner_free(scanner);
-    scanner = synctex_scanner_new_with_output_file([theFileName 
fileSystemRepresentation], NULL, 1);
-    if (scanner) {
-        [self setSyncFileName:[self 
sourceFileForFileSystemRepresentation:synctex_scanner_get_synctex(scanner) 
isTeX:NO]];
-        if (filenames)
-            [filenames removeAllObjects];
-        else
-            filenames = [[NSMapTable alloc] initForCaseInsensitiveStringKeys];
-        const char *fileRep;
-        NSString *filename;
-        synctex_node_t node = synctex_scanner_input(scanner);
-        do {
-            if ((fileRep = synctex_scanner_get_name(scanner, 
synctex_node_tag(node)))) {
-                filename = (NSString 
*)CFStringCreateWithFileSystemRepresentation(NULL, fileRep);
-                [filenames setObject:filename forKey:[self 
sourceFileForFileName:filename isTeX:YES removeQuotes:NO]];
-                [filename release];
-            }
-        } while (node = synctex_node_next(node));
-        isPdfsync = NO;
-        rv = [self shouldKeepRunning];
-    }
-    return rv;
-}
-
-- (BOOL)synctexFindFileLine:(NSInteger *)linePtr file:(NSString **)filePtr 
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds 
atPageIndex:(NSUInteger)pageIndex {
-    BOOL rv = NO;
-    if (synctex_edit_query(scanner, (int)pageIndex + 1, point.x, 
NSMaxY(bounds) - point.y) > 0) {
-        synctex_node_t node;
-        const char *file;
-        while (rv == NO && (node = synctex_next_result(scanner))) {
-            if ((file = synctex_scanner_get_name(scanner, 
synctex_node_tag(node)))) {
-                *linePtr = MAX(synctex_node_line(node), 1) - 1;
-                *filePtr = [self sourceFileForFileSystemRepresentation:file 
isTeX:YES];
-                rv = YES;
-            }
-        }
-    }
-    if (rv == NO)
-        NSLog(@"SyncTeX was unable to find file and line.");
-    return rv;
-}
-
-- (BOOL)synctexFindPage:(NSUInteger *)pageIndexPtr location:(NSPoint 
*)pointPtr forLine:(NSInteger)line inFile:(NSString *)file {
-    BOOL rv = NO;
-    NSString *filename = [filenames objectForKey:file] ?: [filenames 
objectForKey:[[file stringByResolvingSymlinksInPath] 
stringByStandardizingPath]];
-    if (filename == nil) {
-        for (NSString *fn in filenames) {
-            if ([[fn lastPathComponent] caseInsensitiveCompare:[file 
lastPathComponent]] == NSOrderedSame) {
-                filename = [filenames objectForKey:file];
-                break;
-            }
-        }
-        if (filename == nil)
-            filename = [file lastPathComponent];
-    }
-    if (synctex_display_query(scanner, [filename fileSystemRepresentation], 
(int)line + 1, 0) > 0) {
-        synctex_node_t node = synctex_next_result(scanner);
-        if (node) {
-            NSUInteger page = synctex_node_page(node);
-            *pageIndexPtr = MAX(page, 1u) - 1;
-            *pointPtr = NSMakePoint(synctex_node_visible_h(node), 
synctex_node_visible_v(node));
-            rv = YES;
-        }
-    }
-    if (rv == NO)
-        NSLog(@"SyncTeX was unable to find location and page.");
-    return rv;
-}
-
-#pragma mark | Generic
-
-- (BOOL)loadSyncFileIfNeeded {
-    NSString *theFileName = [self fileName];
-    BOOL rv = NO;
-    
-    if (theFileName) {
-        NSString *theSyncFileName = [self syncFileName];
-        
-        if (theSyncFileName && [fileManager fileExistsAtPath:theSyncFileName]) 
{
-            NSDate *modDate = [[fileManager attributesOfItemAtPath:theFileName 
error:NULL] fileModificationDate];
-            NSDate *currentModDate = [self lastModDate];
-        
-            if (currentModDate && [modDate compare:currentModDate] != 
NSOrderedDescending)
-                rv = YES;
-            else if (isPdfsync)
-                rv = [self loadPdfsyncFile:theSyncFileName];
-            else
-                rv = [self loadSynctexFileForFile:theFileName];
-        } else {
-            rv = [self loadSynctexFileForFile:theFileName];
-            if (rv == NO) {
-                theSyncFileName = [[theFileName stringByDeletingPathExtension] 
stringByAppendingPathExtension:SKPDFSynchronizerPdfsyncExtension];
-                if ([fileManager fileExistsAtPath:theSyncFileName])
-                    rv = [self loadPdfsyncFile:theSyncFileName];
-            }
-        }
-    }
-    if (rv == NO)
-        NSLog(@"Unable to find or load synctex or pdfsync file.");
-    return rv;
-}
-
-#pragma mark || Server protocol
-
-- (oneway void)findFileAndLineForLocation:(NSPoint)point inRect:(NSRect)rect 
pageBounds:(NSRect)bounds atPageIndex:(NSUInteger)pageIndex {
-    if ([self shouldKeepRunning] && [self loadSyncFileIfNeeded]) {
-        NSInteger foundLine = 0;
-        NSString *foundFile = nil;
-        BOOL success = NO;
-        
-        if (isPdfsync)
-            success = [self pdfsyncFindFileLine:&foundLine file:&foundFile 
forLocation:point inRect:rect pageBounds:bounds atPageIndex:pageIndex];
-        else
-            success = [self synctexFindFileLine:&foundLine file:&foundFile 
forLocation:point inRect:rect pageBounds:bounds atPageIndex:pageIndex];
-        
-        if (success && [self shouldKeepRunning])
-            [clientProxy foundLine:foundLine inFile:foundFile];
-    }
-}
-
-- (oneway void)findPageAndLocationForLine:(NSInteger)line inFile:(bycopy 
NSString *)file options:(NSInteger)options {
-    if (file && [self shouldKeepRunning] && [self loadSyncFileIfNeeded]) {
-        NSUInteger foundPageIndex = NSNotFound;
-        NSPoint foundPoint = NSZeroPoint;
-        BOOL success = NO;
-        
-        file = [self sourceFileForFileName:file isTeX:YES removeQuotes:NO];
-        
-        if (isPdfsync)
-            success = [self pdfsyncFindPage:&foundPageIndex 
location:&foundPoint forLine:line inFile:file];
-        else
-            success = [self synctexFindPage:&foundPageIndex 
location:&foundPoint forLine:line inFile:file];
-        
-        if (success && [self shouldKeepRunning]) {
-            if (isPdfsync)
-                options &= ~SKPDFSynchronizerFlippedMask;
-            else
-                options |= SKPDFSynchronizerFlippedMask;
-            [clientProxy foundLocation:foundPoint atPageIndex:foundPageIndex 
options:options];
-        }
-    }
-}
-
-@end

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2012-11-05 10:40:58 UTC (rev 
7785)
+++ trunk/Skim.xcodeproj/project.pbxproj        2012-11-05 10:51:26 UTC (rev 
7786)
@@ -83,7 +83,6 @@
                CE12A73E134F215F003AED67 /* SKSelectCommand.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CE12A73D134F215F003AED67 /* SKSelectCommand.m 
*/; };
                CE139A171450207500E9C069 /* NSGraphics_SKExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE139A161450207500E9C069 /* 
NSGraphics_SKExtensions.m */; };
                CE171E3512C3AC1600291179 /* SKFileUpdateChecker.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE171E3412C3AC1600291179 /* 
SKFileUpdateChecker.m */; };
-               CE17F47E0F1A17E200E741DD /* SKPDFSynchronizerServer.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE17F47D0F1A17E200E741DD /* 
SKPDFSynchronizerServer.m */; };
                CE19446310627483007E8770 /* BookmarksWindow.xib in Resources */ 
= {isa = PBXBuildFile; fileRef = CE19445C10627483007E8770 /* 
BookmarksWindow.xib */; };
                CE19446410627483007E8770 /* ConversionProgressWindow.xib in 
Resources */ = {isa = PBXBuildFile; fileRef = CE19445D10627483007E8770 /* 
ConversionProgressWindow.xib */; };
                CE19446510627483007E8770 /* MainWindow.xib in Resources */ = 
{isa = PBXBuildFile; fileRef = CE19445E10627483007E8770 /* MainWindow.xib */; };
@@ -676,8 +675,6 @@
                CE171E3312C3AC1600291179 /* SKFileUpdateChecker.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKFileUpdateChecker.h; sourceTree = "<group>"; };
                CE171E3412C3AC1600291179 /* SKFileUpdateChecker.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKFileUpdateChecker.m; sourceTree = "<group>"; };
                CE17EE460E24ED7C00DE06EA /* Skim-App.xcconfig */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = 
"Skim-App.xcconfig"; sourceTree = "<group>"; };
-               CE17F47C0F1A17E200E741DD /* SKPDFSynchronizerServer.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path 
= SKPDFSynchronizerServer.h; sourceTree = "<group>"; };
-               CE17F47D0F1A17E200E741DD /* SKPDFSynchronizerServer.m */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; 
path = SKPDFSynchronizerServer.m; sourceTree = "<group>"; };
                CE19445C10627483007E8770 /* BookmarksWindow.xib */ = {isa = 
PBXFileReference; lastKnownFileType = file.xib; path = BookmarksWindow.xib; 
sourceTree = "<group>"; };
                CE19445D10627483007E8770 /* ConversionProgressWindow.xib */ = 
{isa = PBXFileReference; lastKnownFileType = file.xib; path = 
ConversionProgressWindow.xib; sourceTree = "<group>"; };
                CE19445E10627483007E8770 /* MainWindow.xib */ = {isa = 
PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; 
sourceTree = "<group>"; };
@@ -1780,8 +1777,6 @@
                                CE5FA1660C909886008BE480 /* SKFDFParser.m */,
                                CE1E2B260BDAB6180011D9DD /* SKPDFSynchronizer.h 
*/,
                                CE1E2B270BDAB6180011D9DD /* SKPDFSynchronizer.m 
*/,
-                               CE17F47C0F1A17E200E741DD /* 
SKPDFSynchronizerServer.h */,
-                               CE17F47D0F1A17E200E741DD /* 
SKPDFSynchronizerServer.m */,
                                CE48BAD50C089EA300A166C6 /* SKTemplateParser.h 
*/,
                                CE48BAD60C089EA300A166C6 /* SKTemplateParser.m 
*/,
                        );
@@ -2558,7 +2553,6 @@
                                CE7611650EA49D1400301E45 /* SKPrintableView.m 
in Sources */,
                                CEE0F5EB0EBB3DEC000A7A8C /* 
SKLevelIndicatorCell.m in Sources */,
                                CE0A3C8E0EBF3AAA00526C74 /* 
NSResponder_SKExtensions.m in Sources */,
-                               CE17F47E0F1A17E200E741DD /* 
SKPDFSynchronizerServer.m in Sources */,
                                CE32531F0F4723EA0021BADD /* 
SKMainWindowController_Actions.m in Sources */,
                                CE80A81E0FDAB1690086A46C /* 
SKHighlightingPopUpButton.m in Sources */,
                                CE9B804A1030642400EA8774 /* SKTransitionInfo.m 
in Sources */,

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


------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to