|
@@ -253,6 +253,7 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
KMFileAttribute *file = [[KMFileAttribute alloc] init];
|
|
|
file.myPDFDocument = document;
|
|
|
file.filePath = document.documentURL.path;
|
|
|
+ file.oriFilePath = self.oriDucumentUrl.path;
|
|
|
if (password && password.length > 0) {
|
|
|
file.password = password;
|
|
|
file.isLocked = YES;
|
|
@@ -262,6 +263,13 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+- (void)setOriDucumentUrl:(NSURL *)oriDucumentUrl {
|
|
|
+ _oriDucumentUrl = oriDucumentUrl;
|
|
|
+
|
|
|
+ KMFileAttribute *file = self.files.firstObject;
|
|
|
+ file.oriFilePath = oriDucumentUrl.path;
|
|
|
+}
|
|
|
+
|
|
|
- (void)windowDidLoad {
|
|
|
|
|
|
[super windowDidLoad];
|
|
@@ -944,8 +952,14 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
if (cell == nil) {
|
|
|
cell = [[KMPDFMergeFileNameTabelViewCell alloc] init];
|
|
|
}
|
|
|
+
|
|
|
+ NSString *fileName = [fileAttribute.filePath lastPathComponent];
|
|
|
+ if (fileAttribute.oriFilePath.length > 0) {
|
|
|
+ fileName = fileAttribute.oriFilePath.stringByDeletingPathExtension.lastPathComponent;
|
|
|
+ }
|
|
|
+
|
|
|
cell.numberLabel.stringValue = [NSString stringWithFormat:@"%ld",(row + 1)];;
|
|
|
- cell.fileNameLabel.stringValue = [fileAttribute.filePath lastPathComponent];
|
|
|
+ cell.fileNameLabel.stringValue = fileName;
|
|
|
cell.pageNumberLabel.stringValue = [NSString stringWithFormat:@"%ld %@",pdf.pageCount,NSLocalizedString(@"Pages", nil)];;
|
|
|
|
|
|
// cell.iconImageView.image = [[pdf pageAtIndex:0] thumbnailWithSize:60*2 forBox:kPDFDisplayBoxCropBox];
|
|
@@ -1099,8 +1113,19 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
}
|
|
|
|
|
|
#pragma mark Buutton Action
|
|
|
+
|
|
|
+- (void)_clearData {
|
|
|
+ for (KMFileAttribute *file in self.files) {
|
|
|
+ if (file.oriFilePath.length > 0 && [[NSFileManager defaultManager] fileExistsAtPath:file.filePath]) {
|
|
|
+ [[NSFileManager defaultManager] removeItemAtURL:[NSURL fileURLWithPath:file.filePath] error:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (IBAction)buttonItemClicked_Cancel:(id)sender
|
|
|
{
|
|
|
+ [self _clearData];
|
|
|
+
|
|
|
_isSuccessfully = NO;
|
|
|
[NSApp endSheet:[self window] returnCode:[(NSView *)sender tag]];
|
|
|
[[self window] orderOut:self];
|
|
@@ -1243,6 +1268,9 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
|
|
|
KMFileAttribute *file = self.files.firstObject;
|
|
|
NSString *fileName = file.filePath.stringByDeletingPathExtension.lastPathComponent;
|
|
|
+ if (file.oriFilePath.length > 0) {
|
|
|
+ fileName = file.oriFilePath.stringByDeletingPathExtension.lastPathComponent;
|
|
|
+ }
|
|
|
fileName = [NSString stringWithFormat:@"%@_Merged", fileName];
|
|
|
if (_editType == KMPDFPageEditMerge) {
|
|
|
_isSuccessfully = NO;
|
|
@@ -1287,6 +1315,8 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
self.loading_backgroundView.hidden = YES;
|
|
|
|
|
|
if (self->_isSuccessfully) {
|
|
|
+ [self _clearData];
|
|
|
+
|
|
|
[NSApp endSheet:[self window] returnCode:[(NSView *)sender tag]];
|
|
|
[[self window] orderOut:self];
|
|
|
|
|
@@ -1376,6 +1406,8 @@ static KMPDFEditAppendWindow *windowController = nil;
|
|
|
self.loading_backgroundView.hidden = YES;
|
|
|
|
|
|
if (self->_isSuccessfully) {
|
|
|
+ [self _clearData];
|
|
|
+
|
|
|
[NSApp endSheet:[self window] returnCode:[(NSView *)sender tag]];
|
|
|
[[self window] orderOut:self];
|
|
|
|