Revision: 27291
http://sourceforge.net/p/bibdesk/svn/27291
Author: hofman
Date: 2022-03-10 10:18:09 +0000 (Thu, 10 Mar 2022)
Log Message:
-----------
Simplify tex task API, combine latex and ltb accessors, make some properties
private
Modified Paths:
--------------
trunk/bibdesk/BDSKItemPasteboardHelper.m
trunk/bibdesk/BDSKTeXTask.h
trunk/bibdesk/BDSKTeXTask.m
Modified: trunk/bibdesk/BDSKItemPasteboardHelper.m
===================================================================
--- trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-10 07:30:30 UTC (rev
27290)
+++ trunk/bibdesk/BDSKItemPasteboardHelper.m 2022-03-10 10:18:09 UTC (rev
27291)
@@ -188,7 +188,7 @@
generatedType = BDSKGenerateLaTeX;
} else if (dragCopyType == BDSKDragCopyLTB) {
BDSKASSERT([type isEqualToString:NSPasteboardTypeString]);
- generatedType = BDSKGenerateLTB;
+ generatedType = BDSKGenerateAMSRefsLaTeX;
} else {
BDSKASSERT((dragCopyType == BDSKDragCopyPDF && [type
isEqualToString:NSPasteboardTypePDF]) ||
(dragCopyType == BDSKDragCopyRTF && [type
isEqualToString:NSPasteboardTypeRTF]));
@@ -199,10 +199,8 @@
[delegate pasteboardHelperWillBeginGenerating:self];
if ([texTask runWithBibTeXString:bibString citeKeys:citeKeys
generatedType:generatedType]) {
- if (generatedType == BDSKGenerateLaTeX) {
+ if (generatedType == BDSKGenerateLaTeX || generatedType ==
BDSKGenerateAMSRefsLaTeX) {
string = [texTask LaTeXString];
- } else if (generatedType == BDSKGenerateLTB) {
- string = [texTask LTBString];
} else {
data = [texTask PDFData];
if (dragCopyType == BDSKDragCopyRTF && data) {
Modified: trunk/bibdesk/BDSKTeXTask.h
===================================================================
--- trunk/bibdesk/BDSKTeXTask.h 2022-03-10 07:30:30 UTC (rev 27290)
+++ trunk/bibdesk/BDSKTeXTask.h 2022-03-10 10:18:09 UTC (rev 27291)
@@ -40,7 +40,7 @@
#import <Cocoa/Cocoa.h>
typedef NS_ENUM(NSInteger, BDSKGeneratedType) {
- BDSKGenerateLTB = 0,
+ BDSKGenerateAMSRefsLaTeX = 0,
BDSKGenerateLaTeX = 1,
BDSKGeneratePDF = 2,
};
@@ -81,19 +81,13 @@
- (void)terminate;
@property (nonatomic, readonly) NSString *logFileString;
-@property (nonatomic, readonly) NSString *LTBString;
@property (nonatomic, readonly) NSString *LaTeXString;
@property (nonatomic, readonly) NSData *PDFData;
@property (nonatomic, readonly) NSString *logFilePath;
-@property (nonatomic, readonly) NSString *LTBFilePath;
@property (nonatomic, readonly) NSString *LaTeXFilePath;
@property (nonatomic, readonly) NSString *PDFFilePath;
-@property (nonatomic, readonly) BOOL hasLTB;
-@property (nonatomic, readonly) BOOL hasLaTeX;
-@property (nonatomic, readonly) BOOL hasPDFData;
-
@property (nonatomic, readonly, getter=isProcessing) BOOL processing;
@end
Modified: trunk/bibdesk/BDSKTeXTask.m
===================================================================
--- trunk/bibdesk/BDSKTeXTask.m 2022-03-10 07:30:30 UTC (rev 27290)
+++ trunk/bibdesk/BDSKTeXTask.m 2022-03-10 10:18:09 UTC (rev 27291)
@@ -50,7 +50,7 @@
enum {
BDSKGeneratedNoneMask = 0,
- BDSKGeneratedLTBMask = 1 << BDSKGenerateLTB,
+ BDSKGeneratedAMSRefsLaTeXMask = 1 << BDSKGenerateAMSRefsLaTeX,
BDSKGeneratedLaTeXMask = 1 << BDSKGenerateLaTeX,
BDSKGeneratedPDFMask = 1 << BDSKGeneratePDF,
};
@@ -84,8 +84,12 @@
#pragma mark -
-@interface BDSKTeXTask (Private)
+@interface BDSKTeXTask ()
+@property (nonatomic, readonly) BOOL hasLTB;
+@property (nonatomic, readonly) BOOL hasLaTeX;
+@property (nonatomic, readonly) BOOL hasPDFData;
+
- (NSArray *)helperFileURLs;
- (void)writeHelperFiles;
@@ -128,7 +132,7 @@
@implementation BDSKTeXTask
-@dynamic logFileString, LTBString, LaTeXString, PDFData, logFilePath,
LTBFilePath, LaTeXFilePath, PDFFilePath, hasLTB, hasLaTeX, hasPDFData,
processing;
+@dynamic logFileString, LaTeXString, PDFData, logFilePath, LaTeXFilePath,
PDFFilePath, hasLTB, hasLaTeX, hasPDFData, processing;
+ (void)initialize
{
@@ -234,7 +238,7 @@
generatedDataMask = BDSKGeneratedNoneMask;
- BOOL success = [self writeTeXFileForCiteKeys:citeKeys isLTB:generatedType
== BDSKGenerateLTB] && [self writeBibTeXFile:bibStr];
+ BOOL success = [self writeTeXFileForCiteKeys:citeKeys isLTB:generatedType
== BDSKGenerateAMSRefsLaTeX] && [self writeBibTeXFile:bibStr];
if (success) {
NSParameterAssert([pendingTasks count] == 0);
@@ -286,19 +290,6 @@
// the .bbl file contains either a LaTeX style bilbiography or an Amsrefs ltb
style bibliography
// which one was generated depends on the generatedType argument, and can be
seen from the hasLTB and hasLaTeX flags
-- (NSString *)LTBString{
- NSString *string = nil;
- if([self hasLTB]) {
- string = [NSString stringWithContentsOfFile:[texPath bblFilePath]
encoding:[[NSUserDefaults standardUserDefaults]
integerForKey:BDSKTeXPreviewFileEncodingKey] error:NULL];
- NSUInteger start, end;
- start = [string rangeOfString:@"\\bib{"].location;
- end = [string rangeOfString:@"\\end{biblist}"
options:NSBackwardsSearch].location;
- if (start != NSNotFound && end != NSNotFound)
- string = [string substringWithRange:NSMakeRange(start, end -
start)];
- }
- return string;
-}
-
- (NSString *)LaTeXString{
NSString *string = nil;
if([self hasLaTeX]) {
@@ -308,6 +299,13 @@
end = [string rangeOfString:@"\\end{thebibliography}"
options:NSBackwardsSearch].location;
if (start != NSNotFound && end != NSNotFound)
string = [string substringWithRange:NSMakeRange(start, end -
start)];
+ } else if([self hasLTB]) {
+ string = [NSString stringWithContentsOfFile:[texPath bblFilePath]
encoding:[[NSUserDefaults standardUserDefaults]
integerForKey:BDSKTeXPreviewFileEncodingKey] error:NULL];
+ NSUInteger start, end;
+ start = [string rangeOfString:@"\\bib{"].location;
+ end = [string rangeOfString:@"\\end{biblist}"
options:NSBackwardsSearch].location;
+ if (start != NSNotFound && end != NSNotFound)
+ string = [string substringWithRange:NSMakeRange(start, end -
start)];
}
return string;
}
@@ -320,12 +318,8 @@
return [texPath logFilePath];
}
-- (NSString *)LTBFilePath{
- return [self hasLTB] ? [texPath bblFilePath] : nil;
-}
-
- (NSString *)LaTeXFilePath{
- return [self hasLaTeX] ? [texPath bblFilePath] : nil;
+ return [self hasLaTeX] ? [texPath bblFilePath] : [self hasLTB] ? [texPath
bblFilePath] : nil;
}
- (NSString *)PDFFilePath{
@@ -333,7 +327,7 @@
}
- (BOOL)hasLTB{
- return 0 != (generatedDataMask & BDSKGeneratedLTBMask);
+ return 0 != (generatedDataMask & BDSKGeneratedAMSRefsLaTeXMask);
}
- (BOOL)hasLaTeX{
@@ -348,11 +342,8 @@
return currentTask != nil;
}
-@end
+#pragma mark Private
-
-@implementation BDSKTeXTask (Private)
-
- (NSArray *)helperFileURLs{
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *appSupportURL = [fm applicationSupportDirectoryURL];
@@ -463,7 +454,7 @@
NSString *commandKey = nil;
NSString *extraArg = nil;
- if ((type & (BDSKGeneratedLaTeXMask | BDSKGeneratedLTBMask))) {
+ if ((type & (BDSKGeneratedLaTeXMask | BDSKGeneratedAMSRefsLaTeXMask))) {
// This task runs bibtex on our bib file
commandKey = BDSKBibTeXBinPathKey;
} else {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit