Browse Source

【OCToSwift】KMFileAttribute

tangchao 1 year ago
parent
commit
7a587b1b9e

+ 8 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -2071,6 +2071,9 @@
 		BB13314E2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB13314D2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift */; };
 		BB13314F2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB13314D2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift */; };
 		BB1331502AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB13314D2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift */; };
+		BB1331542AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1331532AD7A6A1008F6791 /* KMFileAttribute.swift */; };
+		BB1331552AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1331532AD7A6A1008F6791 /* KMFileAttribute.swift */; };
+		BB1331562AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB1331532AD7A6A1008F6791 /* KMFileAttribute.swift */; };
 		BB135C2A29B6CD9A00FD5965 /* KMTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB135C2929B6CD9A00FD5965 /* KMTools.swift */; };
 		BB135C2B29B6CD9A00FD5965 /* KMTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB135C2929B6CD9A00FD5965 /* KMTools.swift */; };
 		BB135C2C29B6CD9A00FD5965 /* KMTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB135C2929B6CD9A00FD5965 /* KMTools.swift */; };
@@ -2893,9 +2896,6 @@
 		BBAFC83F2985194800D0648E /* KMPDFEditAppendWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC83B2985194800D0648E /* KMPDFEditAppendWindow.xib */; };
 		BBAFC8402985194800D0648E /* KMPDFEditAppendWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC83B2985194800D0648E /* KMPDFEditAppendWindow.xib */; };
 		BBAFC8412985194800D0648E /* KMPDFEditAppendWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC83B2985194800D0648E /* KMPDFEditAppendWindow.xib */; };
-		BBAFC844298519A500D0648E /* KMFileAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC842298519A400D0648E /* KMFileAttribute.m */; };
-		BBAFC845298519A500D0648E /* KMFileAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC842298519A400D0648E /* KMFileAttribute.m */; };
-		BBAFC846298519A500D0648E /* KMFileAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = BBAFC842298519A400D0648E /* KMFileAttribute.m */; };
 		BBAFC84D298519F700D0648E /* KMSavePanelAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC849298519F600D0648E /* KMSavePanelAccessoryController.xib */; };
 		BBAFC84E298519F700D0648E /* KMSavePanelAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC849298519F600D0648E /* KMSavePanelAccessoryController.xib */; };
 		BBAFC84F298519F700D0648E /* KMSavePanelAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBAFC849298519F600D0648E /* KMSavePanelAccessoryController.xib */; };
@@ -4252,6 +4252,7 @@
 		BB0A55202A30968900B6E84B /* KMDesignBaseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMDesignBaseView.swift; sourceTree = "<group>"; };
 		BB0A823129C00400002C5C1B /* KMCommonEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCommonEnum.swift; sourceTree = "<group>"; };
 		BB13314D2AD78DC0008F6791 /* KMPDFMergeSizeTabelViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPDFMergeSizeTabelViewCell.swift; sourceTree = "<group>"; };
+		BB1331532AD7A6A1008F6791 /* KMFileAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMFileAttribute.swift; sourceTree = "<group>"; };
 		BB135C2929B6CD9A00FD5965 /* KMTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMTools.swift; sourceTree = "<group>"; };
 		BB146F2F299DC0CF00784A6A /* GTLRBatchQuery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTLRBatchQuery.m; sourceTree = "<group>"; };
 		BB146F30299DC0CF00784A6A /* GTLRService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTLRService.m; sourceTree = "<group>"; };
@@ -4613,8 +4614,6 @@
 		BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMPDFEditAppendWindow.m; sourceTree = "<group>"; };
 		BBAFC83A2985194800D0648E /* KMPDFEditAppendWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMPDFEditAppendWindow.h; sourceTree = "<group>"; };
 		BBAFC83B2985194800D0648E /* KMPDFEditAppendWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMPDFEditAppendWindow.xib; sourceTree = "<group>"; };
-		BBAFC842298519A400D0648E /* KMFileAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMFileAttribute.m; sourceTree = "<group>"; };
-		BBAFC843298519A400D0648E /* KMFileAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMFileAttribute.h; sourceTree = "<group>"; };
 		BBAFC849298519F600D0648E /* KMSavePanelAccessoryController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMSavePanelAccessoryController.xib; sourceTree = "<group>"; };
 		BBAFFB1A29CDD19C00C56112 /* KMMergeSelect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergeSelect.swift; sourceTree = "<group>"; };
 		BBB14A522978DD5400936EDB /* KMRedactTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMRedactTools.swift; sourceTree = "<group>"; };
@@ -8139,6 +8138,7 @@
 			children = (
 				BB6B4C07292F53CE0071CA06 /* KMMergeFileModel.swift */,
 				BBFE6E572930724B00142C01 /* KMMergePageModel.swift */,
+				BB1331532AD7A6A1008F6791 /* KMFileAttribute.swift */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -8541,8 +8541,6 @@
 				BB7507E729861C37002DBDB1 /* PasswordWindowController.xib */,
 				9FCFECA32AD237B500EAD2CB /* KMBatchTableRowView.swift */,
 				9FCFECA72AD243C800EAD2CB /* KMBlankView.swift */,
-				BBAFC843298519A400D0648E /* KMFileAttribute.h */,
-				BBAFC842298519A400D0648E /* KMFileAttribute.m */,
 				9FD0D2A22AD4ECA800DA3FF8 /* KMPDFEditAppendCustomView.swift */,
 				BBAFC83A2985194800D0648E /* KMPDFEditAppendWindow.h */,
 				BBAFC8392985194800D0648E /* KMPDFEditAppendWindow.m */,
@@ -10504,6 +10502,7 @@
 				BBC745F2295F0DD00072C2ED /* KMCropSettingPageSizeView.swift in Sources */,
 				ADCB98E12924776F00B51A03 /* KMBatchProcessingSizeTableCell.swift in Sources */,
 				F3599222292CA27B000D25DE /* CPDFListViewRuntime.m in Sources */,
+				BB1331542AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */,
 				BB0A55182A3074F400B6E84B /* KMHoverView.swift in Sources */,
 				9F53D54F2AD677A000CCF9D8 /* CPDFListViewConfig.swift in Sources */,
 				9F0CB4C4298625F400007028 /* NSColor+KMExtensions.swift in Sources */,
@@ -10586,7 +10585,6 @@
 				9F1FE4D529406E4700E952CA /* NSPasteboard+Utils.m in Sources */,
 				9F1FE4B129406E4700E952CA /* CTTabWindowController.m in Sources */,
 				AD867FA129DEB4B000F00440 /* KMBOTAAnnotationTool.swift in Sources */,
-				BBAFC844298519A500D0648E /* KMFileAttribute.m in Sources */,
 				9F1FE4BD29406E4700E952CA /* URLDropTarget.m in Sources */,
 				9F0CB5052986561E00007028 /* KMDesignToken+BorderRight.swift in Sources */,
 				AD0FA50A29A9E74200EDEB50 /* KMLoginInputPasswordView.swift in Sources */,
@@ -11379,7 +11377,6 @@
 				AD9527CB295297B70039D2BC /* KMPrintModel.swift in Sources */,
 				AD867FA229DEB4B000F00440 /* KMBOTAAnnotationTool.swift in Sources */,
 				9F1FE4B829406E4700E952CA /* CTBrowserFrameView.m in Sources */,
-				BBAFC845298519A500D0648E /* KMFileAttribute.m in Sources */,
 				9F0CB5062986561E00007028 /* KMDesignToken+BorderRight.swift in Sources */,
 				AD0FA50B29A9E74200EDEB50 /* KMLoginInputPasswordView.swift in Sources */,
 				9F1FE4D629406E4700E952CA /* NSPasteboard+Utils.m in Sources */,
@@ -11556,6 +11553,7 @@
 				BB135C2B29B6CD9A00FD5965 /* KMTools.swift in Sources */,
 				9F1FE4A629406E4700E952CA /* CTToolbarView.m in Sources */,
 				BB162E9C295073B50088E9D1 /* KMWatermarkManager.swift in Sources */,
+				BB1331552AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */,
 				BBD1F79D296FF7A600343885 /* KMPageEditSplitSettingModel.swift in Sources */,
 				ADDEEA632AD3A6E700EF675D /* KMPDFSignatureTextView.swift in Sources */,
 				9FCFEC892AD0EF9900EAD2CB /* KMPopMenuButton.swift in Sources */,
@@ -12451,7 +12449,6 @@
 				AD867FC329DFC39400F00440 /* KMBOTAAnnotationItem.swift in Sources */,
 				89E4E7372964148E002DBA6F /* KMAnnotationPropertiesViewController.m in Sources */,
 				ADB1FE8829752F4C00ED072D /* KMBatchWatermarkView.swift in Sources */,
-				BBAFC846298519A500D0648E /* KMFileAttribute.m in Sources */,
 				F37322F8292DF9410013862C /* CSelfSignAnnotation.m in Sources */,
 				ADAC0DE32AC273D600FD4F52 /* KMOCToolClass.swift in Sources */,
 				BB8F457C295AFB330037EA22 /* KMHeaderFooterFontInfoView.swift in Sources */,
@@ -12597,6 +12594,7 @@
 				BBC2BCC8295DA8F30036B983 /* KMCropPreviewController.swift in Sources */,
 				9F1FE50F29407B2B00E952CA /* KMUploadFilePanel.swift in Sources */,
 				9FD0D2AD2AD5143D00DA3FF8 /* KMTableRowView.swift in Sources */,
+				BB1331562AD7A6A1008F6791 /* KMFileAttribute.swift in Sources */,
 				ADC0761C298A2E67006C752F /* KMBatchSecurityViewPresenter.swift in Sources */,
 				BB146FCB299DC0D100784A6A /* GTMSessionFetcher.m in Sources */,
 				9F0CB4CF298654FA00007028 /* KMDesignToken+Height.swift in Sources */,

+ 176 - 0
PDF Office/PDF Master/Class/Merge/Model/KMFileAttribute.swift

@@ -0,0 +1,176 @@
+//
+//  KMFileAttribute.swift
+//  PDF Master
+//
+//  Created by tangchao on 2023/10/12.
+//
+
+import Cocoa
+
+@objcMembers class KMFileAttribute: NSObject {
+    var filePath: String?
+    var oriFilePath: String?
+    var myPDFDocument: PDFDocument?
+    var pdfDocument: CPDFDocument?
+    var bAllPage = true
+    private var _selectPages: [NSNumber] = []
+    var pagesString: String = ""
+    var isLocked = false
+    var password: String?
+    var pagesType: KMPageRange = .all
+    
+    /*
+     @property (nonatomic, assign) BOOL pageRangeError;
+     */
+    
+    func fetchSelectPages() -> [NSNumber] {
+        let _ = self.isInvalidString(self.pagesString)
+        if(!self.bAllPage) {
+            self.QuickSort(&self._selectPages, startIndex: 0, endIndex: self._selectPages.count-1)
+        }
+        return self._selectPages
+    }
+    
+    func isInvalidString(_ text: String) -> Bool {
+        var document: PDFDocument?
+        if (self.myPDFDocument != nil) {
+            document = self.myPDFDocument
+        } else {
+            document = PDFDocument(url: URL(fileURLWithPath: self.filePath ?? ""))
+        }
+        
+        let pageNumber = document?.pageCount ?? 1
+        if (self.bAllPage) {
+            self._selectPages = []
+            for i in 1 ... pageNumber {
+                self._selectPages.append(NSNumber(value: i))
+            }
+            return false
+        }
+        
+        var pageNumbers: [NSNumber] = []
+        var isInvalid = false
+        var c: unichar = 0
+        for c in text {
+            if (c != "0" && c != "1" && c != "2" && c != "3" && c != "4" && c != "5" && c != "6" && c != "7" && c != "8" && c != "9" && c != "," && c != "-") {
+                isInvalid = true
+                break
+            }else{
+                isInvalid = false
+            }
+        }
+        if (!isInvalid) {
+            let array = text.components(separatedBy: ",")
+            for s in array {
+                if s.isEmpty {
+                    isInvalid = true
+                    break
+                }else{
+                    let pages = s.components(separatedBy: "-")
+                    if (pages.count>2) {
+                        isInvalid = true
+                        break
+                    }else if(pages.count==1){
+                        let p = pages.first!
+                        if p.isEmpty || Int(p)! > pageNumber || Int(p) == 0 {
+                            isInvalid = true
+                            break
+                        }else{
+                            var isEqual = false
+                            for pageNumber in pageNumbers {
+                                if pageNumber.stringValue == p {
+                                    isEqual = true
+                                    isInvalid = true
+                                    break
+                                }
+                            }
+                            if (!isEqual) {
+                                pageNumbers.append(NSNumber(value: Int(p)!))
+                            }
+                        }
+                    }else if(pages.count==2){
+                        let p1 = pages[0]
+                        let p2 = pages[1]
+                        if p1.isEmpty || p2.isEmpty || Int(p1)! >= Int(p2)! || Int(p2)! > pageNumber || Int(p1) == 0 {
+                            isInvalid = true
+                            break
+                        }else{
+                            var isEqual = false
+                            for i in Int(p1)! ... Int(p2)! {
+                                for pageNumber in pageNumbers {
+                                    if pageNumber.intValue == i {
+                                        isEqual = true
+                                        isInvalid = true
+                                        break
+                                    }
+                                }
+                            }
+                            if (!isEqual) {
+                                for i in Int(p1)! ... Int(p2)! {
+                                    pageNumbers.append(NSNumber(value: i))
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+            if (text.isEmpty) {
+            isInvalid = true
+        }
+        if (isInvalid) {
+            self._selectPages = []
+        }else{
+            self._selectPages = pageNumbers
+        }
+        return isInvalid
+    }
+    
+    func QuickSort(_ list: inout [NSNumber],startIndex: Int, endIndex: Int) {
+        if(startIndex >= endIndex) {
+            return
+        }
+        
+        let temp = list[startIndex]
+        var tempIndex = startIndex
+        
+        for i in startIndex+1 ... endIndex {
+            let t = list[i]
+            if (temp.intValue > t.intValue) {
+                tempIndex = tempIndex + 1
+                
+                let tmp = list[tempIndex]
+                list[tempIndex] = list[i]
+                list[i] = tmp
+            }
+        }
+        
+        let tmp = list[tempIndex]
+        list[tempIndex] = list[startIndex]
+        list[startIndex] = tmp
+        
+        self.QuickSort(&list, startIndex: startIndex, endIndex: tempIndex-1)
+        self.QuickSort(&list, startIndex: tempIndex+1, endIndex: endIndex)
+    }
+    
+    /*
+
+     /* give our representation to the image browser */
+     - (id)imageRepresentation
+     {
+         return self.filePath;
+     }
+
+     /* use the absolute filepath as identifier */
+     - (NSString *)imageUID
+     {
+         return self.filePath;
+     }
+
+     - (NSString*)imageTitle
+     {
+         return [[self.filePath lastPathComponent] stringByDeletingPathExtension];
+     }
+
+     */
+}

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

@@ -1,42 +0,0 @@
-//
-//  KMFileAttribute.h
-//  PDF to Word
-//
-//  Created by wangshuai on 13-8-14.
-//  Copyright (c) 2013年 kdanmobile. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-#import <Quartz/Quartz.h>
-#import <ComPDFKit/ComPDFKit.h>
-
-typedef NS_OPTIONS(NSUInteger, KMPDFSelectPageStringType) {
-    KMPDFSeleectPageType_AllPages   = 0 ,
-    KMPDFSeleectPageType_OnlyOdd,
-    KMPDFSeleectPageType_OnlyEven,
-    KMPDFSeleectPageType_PagesString,
-};
-
-@interface KMFileAttribute : NSObject{
-    NSString        *_filePath;
-    BOOL            _bAllPage;
-    NSMutableArray  *_selectPages;
-    NSString        *_pagesString;
-    
-    BOOL            _isLocked;
-    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;
-@property (nonatomic,retain) NSMutableArray *selectPages;
-@property (nonatomic,retain) NSString *pagesString;
-@property (nonatomic) BOOL isLocked;
-@property (nonatomic,retain) NSString *password;
-@property (nonatomic,assign) KMPDFSelectPageStringType pagesType;
-
-@property (nonatomic, assign) BOOL pageRangeError;
-
-@end

+ 0 - 183
PDF Office/PDF Master/Class/Merge/OCPart/KMFileAttribute.m

@@ -1,183 +0,0 @@
-//
-//  KMFileAttribute.m
-//  PDF to Word
-//
-//  Created by wangshuai on 13-8-14.
-//  Copyright (c) 2013年 kdanmobile. All rights reserved.
-//
-
-#import "KMFileAttribute.h"
-#import <Quartz/Quartz.h>
-
-@implementation KMFileAttribute
-@synthesize filePath = _filePath;
-@synthesize bAllPage = _bAllPage;
-@synthesize selectPages = _selectPages;
-@synthesize pagesString = _pagesString;
-@synthesize isLocked = _isLocked;
-@synthesize password = _password;
-
-- (id)init
-{
-    self = [super init];
-    if (self) {
-        _bAllPage = YES;
-        _isLocked = NO;
-        _password = nil;
-        _pagesString = @"";
-    }
-    return self;
-}
-
-- (void)dealloc {}
-
-- (NSMutableArray*)selectPages
-{
-    [self isInvalidString:_pagesString];
-    if (!_bAllPage) {
-        [self QuickSort:_selectPages StartIndex:0 EndIndex:[_selectPages count]-1];
-    }
-    return _selectPages;
-}
-
-- (BOOL)isInvalidString:(NSString*)text
-{
-    PDFDocument * document;
-    if (_myPDFDocument) {
-        document = self.myPDFDocument;
-    } else {
-       document = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:self.filePath]];
-    }
-    
-    NSInteger pageNumber = [document pageCount];
-    if (_bAllPage) {
-        _selectPages = [[NSMutableArray alloc] init];
-        for (int i=1; i<=pageNumber; i++) {
-            [_selectPages addObject:[NSNumber numberWithInteger:i]];
-        }
-        return NO;
-    }
-    NSMutableArray *pageNumbers = [[NSMutableArray alloc] init];
-    BOOL isInvalid = NO;
-    unichar c;
-    for (int i=0; i<[text length]; i++) {
-        c = [text characterAtIndex:i];
-        if (c!='0'&&c!='1'&&c!='2'&&c!='3'&&c!='4'&&c!='5'&&c!='6'&&c!='7'&&c!='8'&&c!='9'&&c!=','&&c!='-') {
-            isInvalid = YES;
-            break;
-        }else{
-            isInvalid = NO;
-        }
-    }
-    if (!isInvalid) {
-        NSArray *array = [text componentsSeparatedByString:@","];
-        for(NSString *s in array){
-            if ([s isEqualToString:@""]) {
-                isInvalid = YES;
-                break;
-            }else{
-                NSArray *pages = [s componentsSeparatedByString:@"-"];
-                if ([pages count]>2) {
-                    isInvalid = YES;
-                    break;
-                }else if([pages count]==1){
-                    NSString *p = [pages objectAtIndex:0];
-                    if ([p isEqualToString:@""]||[p intValue]>pageNumber||[p integerValue]==0) {
-                        isInvalid = YES;
-                        break;
-                    }else{
-                        BOOL isEqual = NO;
-                        for(NSNumber *pageNumber in pageNumbers){
-                            if ([pageNumber integerValue]==[p integerValue]) {
-                                isEqual = YES;
-                                isInvalid = YES;
-                                break;
-                            }
-                        }
-                        if (!isEqual) {
-                            [pageNumbers addObject:[NSNumber numberWithInteger:[p integerValue]]];
-                        }
-                    }
-                }else if([pages count]==2){
-                    NSString *p1 = [pages objectAtIndex:0];
-                    NSString *p2 = [pages objectAtIndex:1];
-                    if ([p1 isEqualToString:@""]||[p2 isEqualToString:@""]||
-                        [p1 intValue]>=[p2 intValue]||[p2 intValue]>pageNumber||[p1 integerValue]==0) {
-                        isInvalid = YES;
-                        break;
-                    }else{
-                        BOOL isEqual = NO;
-                        for (int i=[p1 intValue]; i<=[p2 intValue]; i++) {
-                            for(NSNumber *pageNumber in pageNumbers){
-                                if ([pageNumber integerValue]==i) {
-                                    isEqual = YES;
-                                    isInvalid = YES;
-                                    break;
-                                }
-                            }
-                        }
-                        if (!isEqual) {
-                            for (int i=[p1 intValue]; i<=[p2 intValue]; i++) {
-                                [pageNumbers addObject:[NSNumber numberWithInteger:i]];
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    if ([text length]==0) {
-        isInvalid = YES;
-    }
-    if (isInvalid) {
-        _selectPages = nil;
-    }else{
-        _selectPages = pageNumbers;
-    }
-    return isInvalid;
-}
-
--(void)QuickSort:(NSMutableArray *)list StartIndex:(NSInteger)startIndex EndIndex:(NSInteger)endIndex{
-    
-    if(startIndex >= endIndex)return;
-    
-    NSNumber * temp = [list objectAtIndex:startIndex];
-    NSInteger tempIndex = startIndex;
-    
-    for(NSInteger i = startIndex + 1 ; i <= endIndex ; i++){
-        
-        NSNumber *t = [list objectAtIndex:i];
-        
-        if([temp intValue] > [t intValue]){
-            
-            tempIndex = tempIndex + 1;
-            
-            [list exchangeObjectAtIndex:tempIndex withObjectAtIndex:i];
-            
-        }
-        
-    }
-    
-    [list exchangeObjectAtIndex:tempIndex withObjectAtIndex:startIndex];
-    [self QuickSort:list StartIndex:startIndex EndIndex:tempIndex-1];
-    [self QuickSort:list StartIndex:tempIndex+1 EndIndex:endIndex];
-}
-
-/* give our representation to the image browser */
-- (id)imageRepresentation
-{
-	return self.filePath;
-}
-
-/* use the absolute filepath as identifier */
-- (NSString *)imageUID
-{
-    return self.filePath;
-}
-
-- (NSString*)imageTitle
-{
-    return [[self.filePath lastPathComponent] stringByDeletingPathExtension];
-}
-
-@end

+ 7 - 9
PDF Office/PDF Master/Class/Merge/OCPart/KMPDFEditAppendWindow.m

@@ -8,12 +8,10 @@
 
 #import "KMPDFEditAppendWindow.h"
 #import "PasswordWindowController.h"
-#import "KMFileAttribute.h"
 #import <Quartz/Quartz.h>
 #import <Masonry/Masonry.h>
 #import <PDF_Master-Swift.h>
 #import "CTBrowserWindowController.h"
-#import "TextFieldFormatter.h"
 
 @interface KMPDFEditAppendTabelViewCell()
 
@@ -712,12 +710,12 @@ static KMPDFEditAppendWindow *windowController = nil;
     if (itemIndex == 0) {
         KMFileAttribute *currentFile  = [_files objectAtIndex:index];
         [currentFile setBAllPage:YES];
-        currentFile.pagesType = KMPDFSeleectPageType_AllPages;
+        currentFile.pagesType = KMPageRangeAll;
         
         [self.window makeFirstResponder:self];
     } else if (itemIndex == 1) {
         KMFileAttribute *currentFile = [_files objectAtIndex:index];
-        currentFile.pagesType = KMPDFSeleectPageType_OnlyOdd;
+        currentFile.pagesType = KMPageRangeOdd;
         [currentFile setBAllPage:NO];
         PDFDocument *tDocument = currentFile.myPDFDocument;
         if (tDocument == nil) {
@@ -743,7 +741,7 @@ static KMPDFEditAppendWindow *windowController = nil;
         [self.window makeFirstResponder:self];
     } else if (itemIndex == 2) {
         KMFileAttribute *currentFile = [_files objectAtIndex:index];
-        currentFile.pagesType = KMPDFSeleectPageType_OnlyEven;
+        currentFile.pagesType = KMPageRangeEven;
         [currentFile setBAllPage:NO];
         NSString *tPagesString = @"";
         PDFDocument *tDocument = currentFile.myPDFDocument;
@@ -768,7 +766,7 @@ static KMPDFEditAppendWindow *windowController = nil;
         [self.window makeFirstResponder:self];
     } else {
         KMFileAttribute *currentFile  = [_files objectAtIndex:index];
-        currentFile.pagesType = KMPDFSeleectPageType_PagesString;
+        currentFile.pagesType = KMPageRangeCustom;
         currentFile.pagesString = @"";
         [currentFile setBAllPage:NO];
     }
@@ -928,7 +926,7 @@ static KMPDFEditAppendWindow *windowController = nil;
             }
 
             KMFileAttribute *file = [weakSelf.files objectAtIndex:row];
-            if (!file.selectPages) {
+            if (!file.fetchSelectPages) {
 //                file.pageRangeError = YES;
                 if (weakSelf.alert) {
                     return;
@@ -1285,7 +1283,7 @@ static KMPDFEditAppendWindow *windowController = nil;
     
     BOOL allPage = YES;//只有是全部才支持大纲的合并
     for (KMFileAttribute *file in _files) {
-        if (!file.selectPages) {
+        if (!file.fetchSelectPages) {
             dispatch_async(dispatch_get_main_queue(), ^{
                 NSAlert *alert = [[NSAlert alloc] init];
                 [alert setAlertStyle:NSAlertStyleCritical];
@@ -1340,7 +1338,7 @@ static KMPDFEditAppendWindow *windowController = nil;
 //            [tOutline.destination.page dataRepresentation];
 //        }
         
-        for (NSNumber *number in file.selectPages) {
+        for (NSNumber *number in file.fetchSelectPages) {
             PDFPage *page = [tdocument pageAtIndex:[number integerValue]-1];
             [self.PDFDocument insertPage:page atIndex:[self.PDFDocument pageCount]];
 //            [self.PDFDocument insertPageObject:page atIndex:self.PDFDocument.pageCount];

+ 4 - 4
PDF Office/PDF Master/Class/Merge/View/KMPDFMergePageRangeTabelViewCell.swift

@@ -56,16 +56,16 @@ import Cocoa
         
     }
     
-    func updatePageRange(_ pageRange: KMPDFSelectPageStringType, pageStrings: String, isFirstResponser: Bool = true) {
-        if (pageRange == KMPDFSelectPageStringType(rawValue: 0)) {
+    func updatePageRange(_ pageRange: KMPageRange, pageStrings: String, isFirstResponser: Bool = true) {
+        if (pageRange == .all) {
             self.comboBox?.stringValue = KMLocalizedString("All Pages", nil)
             self.comboBox?.editable = false
             self.comboBox?.alert = false
-        } else if (pageRange == .seleectPageType_OnlyOdd) {
+        } else if (pageRange == .odd) {
             self.comboBox?.stringValue = KMLocalizedString("Odd Pages", nil)
             self.comboBox?.editable = false
             self.comboBox?.alert = false
-        } else if (pageRange == .seleectPageType_OnlyEven) {
+        } else if (pageRange == .even) {
             self.comboBox?.stringValue = KMLocalizedString("Even Pages", nil)
             self.comboBox?.editable = false
             self.comboBox?.alert = false

+ 3 - 4
PDF Office/PDF Master/Class/PDFTools/OCR/KMDocumentAIViewController.m

@@ -8,7 +8,6 @@
 #import "KMDocumentAIViewController.h"
 #import "KMOCRBox.h"
 #import "KMDocumentAIManager.h"
-#import "KMFileAttribute.h"
 #import "KMOCRComboBox.h"
 #import <PDF_Master-Swift.h>
 #import <Masonry/Masonry.h>
@@ -366,7 +365,7 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
         fileAttribute.bAllPage = NO;
         fileAttribute.pagesString = _pageRangePopButton.stringValue;
         
-        if (!fileAttribute.selectPages) {
+        if (!fileAttribute.fetchSelectPages) {
             NSAlert *alert = [[NSAlert alloc] init];
             [alert setAlertStyle:NSAlertStyleCritical];
             [alert setMessageText:[NSString stringWithFormat:@"%@ %@",[fileAttribute.filePath lastPathComponent],NSLocalizedString(@"Invalid page range or the page number is out of range. Please try again.", nil)]];
@@ -374,7 +373,7 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
             
             return;
         }
-        for (NSNumber * num in fileAttribute.selectPages) {
+        for (NSNumber * num in fileAttribute.fetchSelectPages) {
             [pages addObject:@(num.integerValue)];
         }
     }
@@ -502,7 +501,7 @@ static inline NSFont * FontWithSize(NSString *strChar, CGSize size) {
     fileAttribute.bAllPage = NO;
     fileAttribute.pagesString = self.pageRangePopButton.stringValue;
     
-    if (!fileAttribute.selectPages) {
+    if (!fileAttribute.fetchSelectPages) {
         return NO;
     }
     return YES;

+ 0 - 1
PDF Office/PDF Master/PDF_Master-Bridging-Header.h

@@ -57,4 +57,3 @@
 #import "CPDFAnnotationHeader.h"
 #import "SKLocalization.h"
 #import "NSImage+PDFListView.h"
-#import "KMFileAttribute.h"