mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix whitespace in some more files.
This commit is contained in:
parent
00e4902ea3
commit
fd5a950d7f
@ -156,7 +156,7 @@ SOURCEFILES = \
|
||||
TocWidget.cpp \
|
||||
Toolbars.cpp \
|
||||
ToolTipFormatter.cpp \
|
||||
Validator.cpp
|
||||
Validator.cpp
|
||||
|
||||
NOMOCHEADER = \
|
||||
ButtonController.h \
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "AppleScript.h"
|
||||
|
||||
@ -26,21 +26,21 @@
|
||||
NSString * directParameter = [self directParameter];
|
||||
NSString *arg = [theArguments objectForKey: @"arg"];
|
||||
|
||||
|
||||
|
||||
// Execute the command
|
||||
LyXFunctionResult result = applescript_execute_command([directParameter UTF8String], [arg UTF8String]);
|
||||
|
||||
|
||||
// Construct the result record
|
||||
NSString *message = [NSString stringWithCString:result.message encoding:NSUTF8StringEncoding];
|
||||
free(result.message);
|
||||
|
||||
free(result.message);
|
||||
|
||||
if (result.code != 0) {
|
||||
NSScriptCommand* c = [NSScriptCommand currentCommand];
|
||||
[c setScriptErrorNumber:result.code];
|
||||
NSScriptCommand* c = [NSScriptCommand currentCommand];
|
||||
[c setScriptErrorNumber:result.code];
|
||||
[c setScriptErrorString:message];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ static NSString * toLanguage(AppleSpeller speller, const char * lang)
|
||||
NSString * lang_ = toString(lang);
|
||||
if ([NSSpellChecker instancesRespondToSelector:@selector(availableLanguages)]) {
|
||||
NSArray * languages = [speller->checker availableLanguages];
|
||||
|
||||
|
||||
for (NSString *element in languages) {
|
||||
if (0 == [element caseInsensitiveCompare:lang_]) {
|
||||
result = element;
|
||||
@ -94,7 +94,7 @@ SpellCheckResult AppleSpeller_check(AppleSpeller speller, const char * word, con
|
||||
SpellCheckResult result = SPELL_CHECK_FAILED;
|
||||
int start = 0;
|
||||
int length = [word_ length];
|
||||
|
||||
|
||||
[speller->misspelled release];
|
||||
speller->misspelled = nil;
|
||||
|
||||
@ -201,7 +201,7 @@ void AppleSpeller_learn(AppleSpeller speller, const char * word)
|
||||
|
||||
if ([NSSpellChecker instancesRespondToSelector:@selector(learnWord:)])
|
||||
[speller->checker learnWord:word_];
|
||||
|
||||
|
||||
[word_ release];
|
||||
[pool release];
|
||||
#endif
|
||||
@ -216,7 +216,7 @@ void AppleSpeller_unlearn(AppleSpeller speller, const char * word)
|
||||
|
||||
if ([NSSpellChecker instancesRespondToSelector:@selector(unlearnWord:)])
|
||||
[speller->checker unlearnWord:word_];
|
||||
|
||||
|
||||
[word_ release];
|
||||
[pool release];
|
||||
#endif
|
||||
|
@ -6,30 +6,30 @@
|
||||
// Copyright (c) 2004, Nisus Software, Inc.
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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,
|
||||
// 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
|
||||
// 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 the Nisus Software, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// Neither the name of the Nisus Software, Inc. nor the names of its
|
||||
// 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,
|
||||
// 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
|
||||
// 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.
|
||||
//
|
||||
|
||||
@ -55,38 +55,38 @@ NSString* LinkBackRefreshActionName = @"_Refresh" ;
|
||||
// Support Functions
|
||||
//
|
||||
|
||||
id MakeLinkBackData(NSString* serverName, id appData)
|
||||
id MakeLinkBackData(NSString* serverName, id appData)
|
||||
{
|
||||
return [NSDictionary linkBackDataWithServerName: serverName appData: appData] ;
|
||||
}
|
||||
|
||||
id LinkBackGetAppData(id LinkBackData)
|
||||
id LinkBackGetAppData(id LinkBackData)
|
||||
{
|
||||
return [LinkBackData linkBackAppData] ;
|
||||
}
|
||||
|
||||
NSString* LinkBackUniqueItemKey()
|
||||
NSString* LinkBackUniqueItemKey()
|
||||
{
|
||||
static int counter = 0 ;
|
||||
|
||||
|
||||
NSString* base = [[NSBundle mainBundle] bundleIdentifier] ;
|
||||
unsigned long time = [NSDate timeIntervalSinceReferenceDate] ;
|
||||
return [NSString stringWithFormat: @"%@%.8lx.%.4x",base,time,counter++] ;
|
||||
}
|
||||
|
||||
BOOL LinkBackDataBelongsToActiveApplication(id data)
|
||||
BOOL LinkBackDataBelongsToActiveApplication(id data)
|
||||
{
|
||||
return [data linkBackDataBelongsToActiveApplication] ;
|
||||
}
|
||||
|
||||
NSString* LinkBackEditMultipleMenuTitle()
|
||||
NSString* LinkBackEditMultipleMenuTitle()
|
||||
{
|
||||
NSBundle* bundle = [NSBundle bundleForClass: [LinkBack class]] ;
|
||||
NSString* ret = [bundle localizedStringForKey: @"_EditMultiple" value: @"Edit LinkBack Items" table: @"Localized"] ;
|
||||
return ret ;
|
||||
}
|
||||
|
||||
NSString* LinkBackEditNoneMenuTitle()
|
||||
NSString* LinkBackEditNoneMenuTitle()
|
||||
{
|
||||
NSBundle* bundle = [NSBundle bundleForClass: [LinkBack class]] ;
|
||||
NSString* ret = [bundle localizedStringForKey: @"_EditNone" value: @"Edit LinkBack Item" table: @"Localized"] ;
|
||||
@ -101,12 +101,12 @@ NSString* LinkBackEditNoneMenuTitle()
|
||||
|
||||
@implementation NSDictionary (LinkBackData)
|
||||
|
||||
+ (NSDictionary*)linkBackDataWithServerName:(NSString*)serverName appData:(id)appData
|
||||
+ (NSDictionary*)linkBackDataWithServerName:(NSString*)serverName appData:(id)appData
|
||||
{
|
||||
return [self linkBackDataWithServerName: serverName appData: appData actionName: nil suggestedRefreshRate: (float)0];
|
||||
}
|
||||
|
||||
+ (NSDictionary*)linkBackDataWithServerName:(NSString*)serverName appData:(id)appData suggestedRefreshRate:(NSTimeInterval)rate
|
||||
+ (NSDictionary*)linkBackDataWithServerName:(NSString*)serverName appData:(id)appData suggestedRefreshRate:(NSTimeInterval)rate
|
||||
{
|
||||
return [self linkBackDataWithServerName: serverName appData: appData actionName: LinkBackRefreshActionName suggestedRefreshRate: rate] ;
|
||||
}
|
||||
@ -122,45 +122,45 @@ NSString* LinkBackEditNoneMenuTitle()
|
||||
id version = @"A" ;
|
||||
|
||||
if (nil==serverName) [NSException raise: NSInvalidArgumentException format: @"LinkBack Data cannot be created without a server name."] ;
|
||||
|
||||
|
||||
// callback information
|
||||
[ret setObject: bundleId forKey: LinkBackServerBundleIdentifierKey];
|
||||
[ret setObject: bundleId forKey: LinkBackServerBundleIdentifierKey];
|
||||
[ret setObject: serverName forKey: LinkBackServerNameKey] ;
|
||||
[ret setObject: version forKey: LinkBackVersionKey] ;
|
||||
|
||||
|
||||
// additional information
|
||||
if (appName) [ret setObject: appName forKey: LinkBackServerApplicationNameKey] ;
|
||||
if (action) [ret setObject: action forKey: LinkBackServerActionKey] ;
|
||||
if (appData) [ret setObject: appData forKey: LinkBackApplicationDataKey] ;
|
||||
if (url) [ret setObject: url forKey: LinkBackApplicationURLKey] ;
|
||||
[ret setObject: [NSNumber numberWithDouble: rate] forKey: LinkBackSuggestedRefreshKey] ;
|
||||
|
||||
|
||||
return [ret autorelease] ;
|
||||
}
|
||||
|
||||
- (BOOL)linkBackDataBelongsToActiveApplication
|
||||
- (BOOL)linkBackDataBelongsToActiveApplication
|
||||
{
|
||||
NSString* bundleId = [[NSBundle mainBundle] bundleIdentifier] ;
|
||||
NSString* dataId = [self objectForKey: LinkBackServerBundleIdentifierKey] ;
|
||||
return (dataId && [dataId isEqualToString: bundleId]) ;
|
||||
}
|
||||
|
||||
- (id)linkBackAppData
|
||||
- (id)linkBackAppData
|
||||
{
|
||||
return [self objectForKey: LinkBackApplicationDataKey] ;
|
||||
}
|
||||
|
||||
- (NSString*)linkBackSourceApplicationName
|
||||
- (NSString*)linkBackSourceApplicationName
|
||||
{
|
||||
return [self objectForKey: LinkBackServerApplicationNameKey] ;
|
||||
}
|
||||
|
||||
- (NSString*)linkBackActionName
|
||||
- (NSString*)linkBackActionName
|
||||
{
|
||||
NSBundle* bundle = [NSBundle bundleForClass: [LinkBack class]] ;
|
||||
NSString* ret = [self objectForKey: LinkBackServerActionKey] ;
|
||||
if (nil==ret) ret = LinkBackEditActionName ;
|
||||
|
||||
|
||||
ret = [bundle localizedStringForKey: ret value: ret table: @"Localized"] ;
|
||||
return ret ;
|
||||
}
|
||||
@ -175,18 +175,18 @@ NSString* LinkBackEditNoneMenuTitle()
|
||||
return ret ;
|
||||
}
|
||||
|
||||
- (NSString*)linkBackVersion
|
||||
- (NSString*)linkBackVersion
|
||||
{
|
||||
return [self objectForKey: LinkBackVersionKey] ;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)linkBackSuggestedRefreshRate
|
||||
- (NSTimeInterval)linkBackSuggestedRefreshRate
|
||||
{
|
||||
id obj = [self objectForKey: LinkBackSuggestedRefreshKey] ;
|
||||
return (obj) ? [obj floatValue] : 0 ;
|
||||
}
|
||||
|
||||
- (NSURL*)linkBackApplicationURL
|
||||
- (NSURL*)linkBackApplicationURL
|
||||
{
|
||||
id obj = [self objectForKey: LinkBackApplicationURLKey] ;
|
||||
if (obj) obj = [NSURL URLWithString: obj] ;
|
||||
@ -196,7 +196,7 @@ NSString* LinkBackEditNoneMenuTitle()
|
||||
@end
|
||||
|
||||
// ...........................................................................
|
||||
// LinkBackServer
|
||||
// LinkBackServer
|
||||
//
|
||||
// one of these exists for each registered server name. This is the receiver of server requests.
|
||||
|
||||
@ -216,12 +216,12 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
keyedLinkBacks = [[NSMutableDictionary alloc] init] ;
|
||||
}
|
||||
|
||||
+ (LinkBack*)activeLinkBackForItemKey:(id)aKey
|
||||
+ (LinkBack*)activeLinkBackForItemKey:(id)aKey
|
||||
{
|
||||
return [keyedLinkBacks objectForKey: aKey] ;
|
||||
}
|
||||
|
||||
- (id)initServerWithClient: (LinkBack*)aLinkBack delegate: (id<LinkBackServerDelegate>)aDel
|
||||
- (id)initServerWithClient: (LinkBack*)aLinkBack delegate: (id<LinkBackServerDelegate>)aDel
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
peer = [aLinkBack retain] ;
|
||||
@ -232,7 +232,7 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
delegate = aDel ;
|
||||
[keyedLinkBacks setObject: self forKey: key] ;
|
||||
}
|
||||
|
||||
|
||||
return self ;
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
pboard = [[NSPasteboard pasteboardWithUniqueName] retain] ;
|
||||
key = [aKey copy] ;
|
||||
}
|
||||
|
||||
|
||||
return self ;
|
||||
}
|
||||
|
||||
@ -254,30 +254,30 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
{
|
||||
[repobj release] ;
|
||||
[sourceName release] ;
|
||||
|
||||
|
||||
if (peer) [self closeLink] ;
|
||||
[peer release] ;
|
||||
|
||||
|
||||
if (!isServer) [pboard releaseGlobally] ; // client owns the pboard.
|
||||
[pboard release] ;
|
||||
|
||||
|
||||
[super dealloc] ;
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
// General Use methods
|
||||
|
||||
- (NSPasteboard*)pasteboard
|
||||
- (NSPasteboard*)pasteboard
|
||||
{
|
||||
return pboard ;
|
||||
}
|
||||
|
||||
- (id)representedObject
|
||||
- (id)representedObject
|
||||
{
|
||||
return repobj ;
|
||||
}
|
||||
|
||||
- (void)setRepresentedObject:(id)obj
|
||||
- (void)setRepresentedObject:(id)obj
|
||||
{
|
||||
[obj retain] ;
|
||||
[repobj release] ;
|
||||
@ -289,7 +289,7 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
return sourceName ;
|
||||
}
|
||||
|
||||
- (NSString*)sourceApplicationName
|
||||
- (NSString*)sourceApplicationName
|
||||
{
|
||||
return sourceApplicationName ;
|
||||
}
|
||||
@ -300,26 +300,26 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
}
|
||||
|
||||
// this method is called to initial a link closure from this side.
|
||||
- (void)closeLink
|
||||
- (void)closeLink
|
||||
{
|
||||
// inform peer of closure
|
||||
if (peer) {
|
||||
[peer remoteCloseLink] ;
|
||||
[peer remoteCloseLink] ;
|
||||
[peer release] ;
|
||||
peer = nil ;
|
||||
[self release] ;
|
||||
[keyedLinkBacks removeObjectForKey: [self itemKey]];
|
||||
[keyedLinkBacks removeObjectForKey: [self itemKey]];
|
||||
}
|
||||
}
|
||||
|
||||
// this method is called whenever the link is about to be or has been closed by the other side.
|
||||
- (oneway void)remoteCloseLink
|
||||
- (oneway void)remoteCloseLink
|
||||
{
|
||||
if (peer) {
|
||||
[peer release] ;
|
||||
peer = nil ;
|
||||
[self release] ;
|
||||
[keyedLinkBacks removeObjectForKey: [self itemKey]];
|
||||
[keyedLinkBacks removeObjectForKey: [self itemKey]];
|
||||
}
|
||||
|
||||
if (delegate) [delegate linkBackDidClose: self] ;
|
||||
@ -328,18 +328,18 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
// ...........................................................................
|
||||
// Server-side methods
|
||||
//
|
||||
+ (BOOL)publishServerWithName:(NSString*)name delegate:(id<LinkBackServerDelegate>)del
|
||||
+ (BOOL)publishServerWithName:(NSString*)name delegate:(id<LinkBackServerDelegate>)del
|
||||
{
|
||||
return [LinkBackServer publishServerWithName: name delegate: del] ;
|
||||
}
|
||||
|
||||
+ (void)retractServerWithName:(NSString*)name
|
||||
+ (void)retractServerWithName:(NSString*)name
|
||||
{
|
||||
LinkBackServer* server = [LinkBackServer LinkBackServerWithName: name] ;
|
||||
if (server) [server retract] ;
|
||||
}
|
||||
|
||||
- (void)sendEdit
|
||||
- (void)sendEdit
|
||||
{
|
||||
if (!peer) [NSException raise: NSGenericException format: @"tried to request edit from a live link not connect to a server."] ;
|
||||
[peer refreshEditWithPasteboardName: [pboard name]] ;
|
||||
@ -362,10 +362,10 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
{
|
||||
// if an active live link already exists, use that. Otherwise, create a new one.
|
||||
LinkBack* ret = [keyedLinkBacks objectForKey: aKey] ;
|
||||
|
||||
|
||||
if(nil==ret) {
|
||||
BOOL ok = [data isKindOfClass: [NSDictionary class]] ;
|
||||
|
||||
|
||||
if (ok) {
|
||||
// collect server contact information from data.
|
||||
NSString* serverName = [data objectForKey: LinkBackServerNameKey] ;
|
||||
@ -378,7 +378,7 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
|
||||
// create the live link object and try to connect to the server.
|
||||
ret = [[LinkBack alloc] initClientWithSourceName: aName delegate: del itemKey: aKey] ;
|
||||
|
||||
|
||||
if (![ret connectToServerWithName: serverName inApplication: serverId fallbackURL: url appName: appName]) {
|
||||
[ret release] ;
|
||||
ret = nil ;
|
||||
@ -387,38 +387,38 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
[NSException raise: NSInvalidArgumentException format: @"LinkBackData is not of the correct format: %@", data] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now with a live link in hand, request an edit
|
||||
if (ret) {
|
||||
// if connected to server, publish data and inform server.
|
||||
NSPasteboard* my_pboard = [ret pasteboard] ;
|
||||
[my_pboard declareTypes: [NSArray arrayWithObject: LinkBackPboardType] owner: ret] ;
|
||||
[my_pboard setPropertyList: data forType: LinkBackPboardType] ;
|
||||
|
||||
|
||||
[ret requestEdit] ;
|
||||
|
||||
|
||||
// if connection to server failed, return nil.
|
||||
}
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
- (BOOL)connectToServerWithName:(NSString*)aName inApplication:(NSString*)bundleIdentifier fallbackURL:(NSURL*)url appName:(NSString*)appName
|
||||
- (BOOL)connectToServerWithName:(NSString*)aName inApplication:(NSString*)bundleIdentifier fallbackURL:(NSURL*)url appName:(NSString*)appName
|
||||
{
|
||||
// get the LinkBackServer.
|
||||
LinkBackServer* server = [LinkBackServer LinkBackServerWithName: aName inApplication: bundleIdentifier launchIfNeeded: YES fallbackURL: url appName: appName] ;
|
||||
if (!server) return NO ; // failed to get server
|
||||
|
||||
|
||||
peer = [[server initiateLinkBackFromClient: self] retain] ;
|
||||
if (!peer) return NO ; // failed to initiate session
|
||||
|
||||
|
||||
// if we connected, then add to the list of active keys
|
||||
[keyedLinkBacks setObject: self forKey: [self itemKey]] ;
|
||||
|
||||
|
||||
return YES ;
|
||||
}
|
||||
|
||||
- (void)requestEdit
|
||||
- (void)requestEdit
|
||||
{
|
||||
if (!peer) [NSException raise: NSGenericException format: @"tried to request edit from a live link not connect to a server."] ;
|
||||
[peer requestEditWithPasteboardName: [pboard name]] ;
|
||||
@ -431,8 +431,8 @@ NSMutableDictionary* keyedLinkBacks = nil ;
|
||||
if (![pboardName isEqualToString: [pboard name]]) {
|
||||
[pboard release] ;
|
||||
pboard = [[NSPasteboard pasteboardWithName: pboardName] retain] ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// inform delegate
|
||||
[delegate performSelectorOnMainThread: @selector(linkBackServerDidSendEdit:) withObject: self waitUntilDone: NO] ;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@
|
||||
NSLog(@"Cannot read file %@", fileName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
// Get linkback data which comes behind the pdf data.
|
||||
// The pdf data length are the last 4 bytes.
|
||||
UInt32 pdfLen = 0;
|
||||
@ -70,21 +70,21 @@
|
||||
NSLog(@"Invalid file %@ for LinkBack", fileName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSData * linkBackData
|
||||
= [data subdataWithRange:NSMakeRange(pdfLen, [data length] - pdfLen - 4)];
|
||||
|
||||
NSData * linkBackData
|
||||
= [data subdataWithRange:NSMakeRange(pdfLen, [data length] - pdfLen - 4)];
|
||||
if (linkBackData == nil) {
|
||||
NSLog(@"Invalid file %@ for LinkBack", fileName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary * linkBackDataDict
|
||||
= [NSUnarchiver unarchiveObjectWithData:linkBackData];
|
||||
if (linkBackDataDict == nil) {
|
||||
NSLog(@"LinkBack data in %@ corrupted", fileName);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
// create the link to the LinkBack server
|
||||
LinkBack * link = [LinkBack editLinkBackData:linkBackDataDict
|
||||
sourceName:fileName delegate:self itemKey:fileName];
|
||||
@ -98,7 +98,7 @@
|
||||
NSLog(@"LinkBack exception: %@", exception);
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@
|
||||
NSLog(@"No PDF or LinkBack data in pasteboard");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get new linkback data
|
||||
id linkBackDataDict = [pboard propertyListForType:LinkBackPboardType];
|
||||
if (linkBackDataDict == nil) {
|
||||
@ -135,14 +135,14 @@
|
||||
NSLog(@"Cannot archive LinkBack data");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get pdf
|
||||
NSData * pdfData = [pboard dataForType:NSPDFPboardType];
|
||||
if (pdfData == nil) {
|
||||
NSLog(@"Cannot get PDF data from pasteboard");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// update the file
|
||||
NSString * fileName = [link itemKey];
|
||||
NSFileHandle * file = [NSFileHandle fileHandleForUpdatingAtPath:fileName];
|
||||
@ -153,7 +153,7 @@
|
||||
[file truncateFileAtOffset:0];
|
||||
[file writeData:pdfData];
|
||||
[file writeData:linkBackData];
|
||||
|
||||
|
||||
UInt32 pdfLen = NSSwapHostLongToBig([pdfData length]); // big endian
|
||||
NSData * lenData = [NSData dataWithBytes:&pdfLen length:4];
|
||||
[file writeData:lenData];
|
||||
@ -187,7 +187,7 @@ void getLinkBackData(void const * * buf, unsigned * len)
|
||||
// get linkback data from pasteboard
|
||||
NSPasteboard * pboard = [NSPasteboard generalPasteboard];
|
||||
id linkBackData = [pboard propertyListForType:LinkBackPboardType];
|
||||
|
||||
|
||||
NSData * nsdata = [NSArchiver archivedDataWithRootObject:linkBackData];
|
||||
if (nsdata == nil) {
|
||||
*buf = 0;
|
||||
|
@ -6,30 +6,30 @@
|
||||
// Copyright (c) 2004, Nisus Software, Inc.
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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,
|
||||
// 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
|
||||
// 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 the Nisus Software, Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from this
|
||||
// Neither the name of the Nisus Software, Inc. nor the names of its
|
||||
// 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,
|
||||
// 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
|
||||
// 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.
|
||||
//
|
||||
|
||||
@ -50,18 +50,18 @@ NSMutableDictionary* LinkBackServers = nil ;
|
||||
static BOOL inited = NO ;
|
||||
if (inited) return ;
|
||||
|
||||
[super initialize] ;
|
||||
[super initialize] ;
|
||||
inited = YES ;
|
||||
|
||||
|
||||
if (!LinkBackServers) LinkBackServers = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
+ (LinkBackServer*)LinkBackServerWithName:(NSString*)aName
|
||||
+ (LinkBackServer*)LinkBackServerWithName:(NSString*)aName
|
||||
{
|
||||
return [LinkBackServers objectForKey: aName] ;
|
||||
}
|
||||
|
||||
+ (BOOL)publishServerWithName:(NSString*)aName delegate:(id<LinkBackServerDelegate>)del
|
||||
+ (BOOL)publishServerWithName:(NSString*)aName delegate:(id<LinkBackServerDelegate>)del
|
||||
{
|
||||
LinkBackServer* serv = [[LinkBackServer alloc] initWithName: aName delegate: del] ;
|
||||
BOOL ret = [serv publish] ; // retains if successful
|
||||
@ -78,7 +78,7 @@ BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
|
||||
int idx ;
|
||||
#endif
|
||||
NSString* curServer = supportedServers ;
|
||||
|
||||
|
||||
// NOTE: supportedServers may be nil, an NSArray, or NSString.
|
||||
if (supportedServers) {
|
||||
if ([supportedServers isKindOfClass: [NSArray class]]) {
|
||||
@ -87,9 +87,9 @@ BOOL LinkBackServerIsSupported(NSString* name, id supportedServers)
|
||||
curServer = [supportedServers objectAtIndex: --idx] ;
|
||||
ret = [curServer isEqualToString: name] ;
|
||||
}
|
||||
} else ret = [curServer isEqualToString: name] ;
|
||||
} else ret = [curServer isEqualToString: name] ;
|
||||
}
|
||||
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
@ -105,41 +105,41 @@ NSString* FindLinkBackServer(NSString* bundleIdentifier, NSString* serverName, N
|
||||
NSArray* contents = [fm directoryContentsAtPath: dir] ;
|
||||
int idx ;
|
||||
#endif
|
||||
|
||||
|
||||
// working info
|
||||
NSString* cpath ;
|
||||
NSBundle* cbundle ;
|
||||
NSString* cbundleIdentifier ;
|
||||
id supportedServers ;
|
||||
|
||||
|
||||
NSLog(@"searching for %@ in folder: %@", serverName, dir) ;
|
||||
|
||||
// resolve any symlinks, expand tildes.
|
||||
dir = [dir stringByStandardizingPath] ;
|
||||
|
||||
|
||||
// find all .app bundles in the directory and test them.
|
||||
idx = (contents) ? [contents count] : 0 ;
|
||||
while((nil==ret) && (idx > 0)) {
|
||||
cpath = [contents objectAtIndex: --idx] ;
|
||||
|
||||
|
||||
if ([[cpath pathExtension] isEqualToString: @"app"]) {
|
||||
cpath = [dir stringByAppendingPathComponent: cpath] ;
|
||||
cbundle = [NSBundle bundleWithPath: cpath] ;
|
||||
cbundleIdentifier = [cbundle bundleIdentifier] ;
|
||||
|
||||
|
||||
if ([cbundleIdentifier isEqualToString: bundleIdentifier]) {
|
||||
supportedServers = [[cbundle infoDictionary] objectForKey: @"LinkBackServer"] ;
|
||||
ret= (LinkBackServerIsSupported(serverName, supportedServers)) ? cpath : nil ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if the app was not found, descend into non-app dirs. only descend 4 levels to avoid taking forever.
|
||||
if ((nil==ret) && (level<4)) {
|
||||
idx = (contents) ? [contents count] : 0 ;
|
||||
while((nil==ret) && (idx > 0)) {
|
||||
BOOL isdir ;
|
||||
|
||||
|
||||
cpath = [contents objectAtIndex: --idx] ;
|
||||
[fm fileExistsAtPath: cpath isDirectory: &isdir] ;
|
||||
if (isdir && (![[cpath pathExtension] isEqualToString: @"app"])) {
|
||||
@ -148,30 +148,30 @@ NSString* FindLinkBackServer(NSString* bundleIdentifier, NSString* serverName, N
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
|
||||
{
|
||||
int result ;
|
||||
|
||||
|
||||
// strings for panel
|
||||
NSBundle* b = [NSBundle bundleForClass: [LinkBack class]] ;
|
||||
NSString* title ;
|
||||
NSString* msg ;
|
||||
NSString* ok ;
|
||||
NSString* urlstr ;
|
||||
|
||||
|
||||
title = NSLocalizedStringFromTableInBundle(@"_AppNotFoundTitle", @"Localized", b, @"app not found title") ;
|
||||
ok = NSLocalizedStringFromTableInBundle(@"_OK", @"Localized", b, @"ok") ;
|
||||
|
||||
msg = (url) ? NSLocalizedStringFromTableInBundle(@"_AppNotFoundMessageWithURL", @"Localized", b, @"app not found msg") : NSLocalizedStringFromTableInBundle(@"_AppNotFoundMessageNoURL", @"Localized", b, @"app not found msg") ;
|
||||
|
||||
|
||||
urlstr = (url) ? NSLocalizedStringFromTableInBundle(@"_GetApplication", @"Localized", b, @"Get application") : nil ;
|
||||
|
||||
title = [NSString stringWithFormat: title, appName] ;
|
||||
|
||||
|
||||
result = NSRunCriticalAlertPanel(title, @"%@", ok, urlstr, nil, msg) ;
|
||||
if (NSAlertAlternateReturn == result) {
|
||||
[[NSWorkspace sharedWorkspace] openURL: url] ;
|
||||
@ -184,27 +184,27 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
|
||||
NSString* serverName = MakeLinkBackServerName(bundleIdentifier, aName) ;
|
||||
id ret = nil ;
|
||||
NSTimeInterval tryMark ;
|
||||
|
||||
|
||||
// Try to connect
|
||||
ret = [NSConnection rootProxyForConnectionWithRegisteredName: serverName host: nil] ;
|
||||
|
||||
|
||||
// if launchIfNeeded, and the connection was not available, try to launch.
|
||||
if((!ret) && (flag)) {
|
||||
NSString* appPath ;
|
||||
id linkBackServers ;
|
||||
|
||||
|
||||
// first, try to find the app with the bundle identifier
|
||||
appPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier: bundleIdentifier] ;
|
||||
linkBackServers = [[[NSBundle bundleWithPath: appPath] infoDictionary] objectForKey: @"LinkBackServer"] ;
|
||||
linkBackServers = [[[NSBundle bundleWithPath: appPath] infoDictionary] objectForKey: @"LinkBackServer"] ;
|
||||
appPath = (LinkBackServerIsSupported(aName, linkBackServers)) ? appPath : nil ;
|
||||
|
||||
|
||||
// if the found app is not supported, we will need to search for the app ourselves.
|
||||
if (nil==appPath) appPath = FindLinkBackServer(bundleIdentifier, aName, @"/Applications",0);
|
||||
|
||||
|
||||
if (nil==appPath) appPath = FindLinkBackServer(bundleIdentifier, aName, @"~/Applications",0);
|
||||
|
||||
|
||||
if (nil==appPath) appPath = FindLinkBackServer(bundleIdentifier, aName, @"/Network/Applications",0);
|
||||
|
||||
|
||||
// if app path has been found, launch the app.
|
||||
if (appPath) {
|
||||
[[NSWorkspace sharedWorkspace] launchApplication: appName] ;
|
||||
@ -213,15 +213,15 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
|
||||
connect = NO ;
|
||||
}
|
||||
}
|
||||
|
||||
// if needed, try to connect.
|
||||
|
||||
// if needed, try to connect.
|
||||
// retry connection for a while if we did not succeed at first. This gives the app time to launch.
|
||||
if (connect && (nil==ret)) {
|
||||
tryMark = [NSDate timeIntervalSinceReferenceDate] ;
|
||||
do {
|
||||
ret = [NSConnection rootProxyForConnectionWithRegisteredName: serverName host: nil] ;
|
||||
} while ((!ret) && (([NSDate timeIntervalSinceReferenceDate]-tryMark)<10)) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// setup protocol and return
|
||||
@ -237,7 +237,7 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
|
||||
delegate = aDel ;
|
||||
listener = nil ;
|
||||
}
|
||||
|
||||
|
||||
return self ;
|
||||
}
|
||||
|
||||
@ -252,40 +252,40 @@ void LinkBackRunAppNotFoundPanel(NSString* appName, NSURL* url)
|
||||
{
|
||||
NSString* serverName = MakeLinkBackServerName([[NSBundle mainBundle] bundleIdentifier], name) ;
|
||||
BOOL ret = YES ;
|
||||
|
||||
|
||||
// create listener and connect
|
||||
NSPort* port = [NSPort port] ;
|
||||
listener = [NSConnection connectionWithReceivePort: port sendPort:port] ;
|
||||
[listener setRootObject: self] ;
|
||||
ret = [listener registerName: serverName] ;
|
||||
|
||||
|
||||
// if successful, retain connection and add self to list of servers.
|
||||
if (ret) {
|
||||
[listener retain] ;
|
||||
[LinkBackServers setObject: self forKey: name] ;
|
||||
} else listener = nil ; // listener will dealloc on its own.
|
||||
|
||||
} else listener = nil ; // listener will dealloc on its own.
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
- (void)retract
|
||||
- (void)retract
|
||||
{
|
||||
if (listener) {
|
||||
[listener invalidate] ;
|
||||
[listener release] ;
|
||||
listener = nil ;
|
||||
}
|
||||
|
||||
|
||||
[LinkBackServers removeObjectForKey: name] ;
|
||||
}
|
||||
|
||||
- (LinkBack*)initiateLinkBackFromClient:(LinkBack*)clientLinkBack
|
||||
- (LinkBack*)initiateLinkBackFromClient:(LinkBack*)clientLinkBack
|
||||
{
|
||||
LinkBack* ret = [[LinkBack alloc] initServerWithClient: clientLinkBack delegate: delegate] ;
|
||||
|
||||
|
||||
// NOTE: we do not release because LinkBack will release itself when it the link closes. (caj)
|
||||
|
||||
return ret ;
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -248,8 +248,8 @@ Since \fBtex2lyx\fR is relatively new, it's got a number of problems. As it
|
||||
matures, these bugs will be squished.
|
||||
.IP "\(bu" 4
|
||||
\*[lq]Exact\*[rq] copying of unknown environments and commands isn't quite exact.
|
||||
This will yield ugly LyX, but in almost all cases the output will be the same.
|
||||
However, most parts of the file will be copied perfectly, including whitespace
|
||||
This will yield ugly LyX, but in almost all cases the output will be the same.
|
||||
However, most parts of the file will be copied perfectly, including whitespace
|
||||
and comments. This includes: the LaTeX preamble, verbatim environments as well as
|
||||
\f(CW\everb\fR commands, and skip blocks.
|
||||
.IP "\(bu" 4
|
||||
@ -260,9 +260,9 @@ More importantly, \fBtex2lyx\fR doesn't translate \f(CW\enewcommands\fR, unknown
|
||||
\f(CW\eusepackage\fR commands and other unknown code in the preamble. It
|
||||
simply copies that into the LaTeX preamble. If you use special commands, e.g. to
|
||||
specify the text layout in a way that that is not understood by LyX, tex2lyx won't
|
||||
recognize it. Note that these settings will be overwritten if you modify the text
|
||||
layout in LyX's document settings. Better remove these special options from the LaTeX
|
||||
preamble (Document->Settings->LaTeX Preamble) and use the corresponding LyX document
|
||||
recognize it. Note that these settings will be overwritten if you modify the text
|
||||
layout in LyX's document settings. Better remove these special options from the LaTeX
|
||||
preamble (Document->Settings->LaTeX Preamble) and use the corresponding LyX document
|
||||
settings, if possible.
|
||||
.IP "\(bu" 4
|
||||
The foil document class has a couple of bugs. \fBtex2lyx\fR may do weird things with optional
|
||||
@ -273,8 +273,8 @@ All known bugs of \fBtex2lyx\fR can be found on \fI\s-1http://www.lyx.org/trac/w
|
||||
.PP
|
||||
\fBtex2lyx\fR is rather robust. As mentioned above, it may not translate
|
||||
your file perfectly, but the result should be usable and it shouldn't crash. If you encounter
|
||||
problems---and the problem is not one of those mentioned above or on
|
||||
\fI\s-1http://www.lyx.org/trac/wiki/BugTrackerHome\s0\fR---please report the issue as described in the section
|
||||
problems---and the problem is not one of those mentioned above or on
|
||||
\fI\s-1http://www.lyx.org/trac/wiki/BugTrackerHome\s0\fR---please report the issue as described in the section
|
||||
on \fIBug Reports\fR.
|
||||
.SS "What LyX Can't Handle"
|
||||
LyX itself is missing a couple of features, such that even if \fBtex2lyx\fR translates
|
||||
@ -290,10 +290,10 @@ environment.
|
||||
LyX support for tables isn't perfect. For complicated tables, use a \*[lq]skip\*[rq]
|
||||
block, so that they will be copied in TeX mode.
|
||||
.IP "\(bu" 4
|
||||
LyX allows figures to have sizes in the units known to TeX, such as in, cm, etc. It also
|
||||
translates percentages of \etextwidth, \etextheight, \ecolumnwidth, but no other lengths
|
||||
(e.g. if you wanted to scale a figure to size \etopmargin for some reason). \fBtex2lyx\fR
|
||||
will copy figures with untranslatable sizes in TeX mode. Again, you might be able to fix
|
||||
LyX allows figures to have sizes in the units known to TeX, such as in, cm, etc. It also
|
||||
translates percentages of \etextwidth, \etextheight, \ecolumnwidth, but no other lengths
|
||||
(e.g. if you wanted to scale a figure to size \etopmargin for some reason). \fBtex2lyx\fR
|
||||
will copy figures with untranslatable sizes in TeX mode. Again, you might be able to fix
|
||||
that within LyX.
|
||||
.SH "EXAMPLES"
|
||||
tex2lyx \fB\-f\fR \fB\-r\fR \*[lq]myenv\*[rq] foo.tex
|
||||
@ -312,10 +312,10 @@ article.
|
||||
.SS "Bug Reports"
|
||||
Bugs should be reported to the LyX bug tracker at http://www.lyx.org/trac/wiki/BugTrackerHome. Additionally,
|
||||
you can post a message to the LyX developers' mailing list. Its address is currently
|
||||
lyx-devel@lists.lyx.org. If your message bounces, you can check the LyX home page,
|
||||
http://www.lyx.org/. If you are running \fBtex2lyx\fR on a huge file, please do not send all of the output in
|
||||
your bug report. Just include the last ten or twenty lines of output, along with
|
||||
the piece of the LaTeX file it crashed on. Or, even better, attach a small but
|
||||
lyx-devel@lists.lyx.org. If your message bounces, you can check the LyX home page,
|
||||
http://www.lyx.org/. If you are running \fBtex2lyx\fR on a huge file, please do not send all of the output in
|
||||
your bug report. Just include the last ten or twenty lines of output, along with
|
||||
the piece of the LaTeX file it crashed on. Or, even better, attach a small but
|
||||
complete file which causes the same problem as your original file.
|
||||
.SS "Layout Files"
|
||||
\fBtex2lyx\fR reads a LyX layout file to know how to handle LaTeX environments and
|
||||
@ -424,7 +424,7 @@ The user directory is, in order of precedence:
|
||||
.SH "FILES"
|
||||
.PP
|
||||
If \fI\s-1LIBDIR\s0\fR is the system-wide LyX directory and
|
||||
\fI\s-1MY_LYXDIR\s0\fR
|
||||
\fI\s-1MY_LYXDIR\s0\fR
|
||||
is your personal LyX directory, then the following files are read by tex2lyx:
|
||||
.IP "\fI\s-1MY_LYXDIR\s0\fR/layouts/*.layout" 4
|
||||
User's personal layout files for document classes
|
||||
|
Loading…
Reference in New Issue
Block a user