Просмотр исходного кода

【合并】权益弹窗后置

tangchao 1 год назад
Родитель
Сommit
9da2062f80

+ 1 - 0
PDF Office/PDF Master/Class/Merge/OCPart/KMFileAttribute.h

@@ -27,6 +27,7 @@ typedef NS_OPTIONS(NSUInteger, KMPDFSelectPageStringType) {
     NSString        *_password;
 }
 @property (nonatomic,retain) NSString *filePath;
+@property (nonatomic, retain) NSString *oriFilePath;
 @property (nonatomic,retain) PDFDocument *myPDFDocument;
 @property (nonatomic,retain) CPDFDocument *pdfDocument;
 @property (nonatomic) BOOL bAllPage;

+ 3 - 0
PDF Office/PDF Master/Class/Merge/OCPart/KMPDFEditAppendWindow.h

@@ -22,6 +22,9 @@ typedef NS_OPTIONS(NSUInteger, KMPDFPageEditType) {
     };
 
 @interface KMPDFEditAppendWindow : NSWindowController
+
+@property (nonatomic, strong) NSURL *oriDucumentUrl;
+
 @property (nonatomic,copy) void (^saveAsPDFFilePath) (NSString *filePath);
 
 - (id)initWithFilePaths:(NSArray *)files;

+ 33 - 1
PDF Office/PDF Master/Class/Merge/OCPart/KMPDFEditAppendWindow.m

@@ -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];
                                 

+ 8 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -2487,6 +2487,14 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
                 
+                if await (KMLightMemberManager.manager.canPayFunction() == false) {
+                    guard let _url =  KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
+                        return
+                    }
+                    self.showMergeWindow(url: _url, password)
+                    return
+                }
+                
                 if (self.needSaveDocument()) {
                     self.saveDocumentWithProgressAlert { [unowned self] params in
                         self.showMergeWindow(self.listView.document.password)

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -846,6 +846,7 @@ import Cocoa
             if let _url = url {
                 let document = PDFDocument(url: _url)
                 let windowController = KMPDFEditAppendWindow(pdfDocument: document, password: password)
+                windowController?.oriDucumentUrl = self.listView.document.documentURL
                 
                 self.toolbarController.cancelSelected(KMToolbarToolMergeItemIdentifier)