Revision: 6754
http://skim-app.svn.sourceforge.net/skim-app/?rev=6754&view=rev
Author: hofman
Date: 2010-08-30 11:59:38 +0000 (Mon, 30 Aug 2010)
Log Message:
-----------
use full page range when no pages provided in skimconvert extract utility
Modified Paths:
--------------
trunk/SkimNotes/skimconvert.m
Modified: trunk/SkimNotes/skimconvert.m
===================================================================
--- trunk/SkimNotes/skimconvert.m 2010-08-30 11:50:15 UTC (rev 6753)
+++ trunk/SkimNotes/skimconvert.m 2010-08-30 11:59:38 UTC (rev 6754)
@@ -328,28 +328,27 @@
offset = 1;
}
- if (argc < 5 + offset) {
- WRITE_ERROR;
- [pool release];
- exit(EXIT_FAILURE);
- }
-
PDFDocument *pdfDoc = [[[PDFDocument alloc] initWithURL:inURL]
autorelease];
-
- NSString *option = [args objectAtIndex:offset + 3];
+ NSUInteger pageCount = [pdfDoc pageCount];
NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
- if ([option caseInsensitiveCompare:RANGE_OPTION_STRING] ==
NSOrderedSame) {
- NSInteger start = [[args objectAtIndex:offset + 4] intValue];
- NSInteger length = argc < 6 + offset ? (NSInteger)[pdfDoc
pageCount] - start + 1 : [[args objectAtIndex:offset + 5] intValue];
- if (start > 0 && length > 0)
- [indexes addIndexesInRange:NSMakeRange(start - 1, length)];
- } else if ([option caseInsensitiveCompare:PAGE_OPTION_STRING] ==
NSOrderedSame) {
- NSInteger i;
- for (i = offset + 4; i < argc; i++) {
- NSUInteger page = [[args objectAtIndex:i] intValue];
- if (page > 0)
- [indexes addIndex:page - 1];
+ if (argc < 5 + offset) {
+ [indexes addIndexesInRange:NSMakeRange(0, pageCount)];
+ } else {
+ NSString *option = [args objectAtIndex:offset + 3];
+
+ if ([option caseInsensitiveCompare:RANGE_OPTION_STRING] ==
NSOrderedSame) {
+ NSInteger start = [[args objectAtIndex:offset + 4]
intValue];
+ NSInteger length = argc < 6 + offset ?
(NSInteger)pageCount - start + 1 : [[args objectAtIndex:offset + 5] intValue];
+ if (start > 0 && length > 0)
+ [indexes addIndexesInRange:NSMakeRange(start - 1,
length)];
+ } else if ([option caseInsensitiveCompare:PAGE_OPTION_STRING]
== NSOrderedSame) {
+ NSInteger i;
+ for (i = offset + 4; i < argc; i++) {
+ NSUInteger page = [[args objectAtIndex:i] intValue];
+ if (page > 0)
+ [indexes addIndex:page - 1];
+ }
}
}
@@ -357,13 +356,13 @@
error = [NSError errorWithDomain:NSPOSIXErrorDomain
code:ENOENT userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Cannot create
PDF document", NSLocalizedDescriptionKey, nil]];
- } else if ([indexes count] == 0 || [indexes lastIndex] > [pdfDoc
pageCount]) {
+ } else if ([indexes count] == 0 || [indexes lastIndex] >
pageCount) {
error = [NSError errorWithDomain:NSPOSIXErrorDomain
code:ENOENT userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Invalid page
range", NSLocalizedDescriptionKey, nil]];
} else {
- NSUInteger i = [pdfDoc pageCount];
+ NSUInteger i = pageCount;
while (i-- > 0) {
if ([indexes containsIndex:i] == NO)
[pdfDoc removePageAtIndex:i];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit