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

Merge branch 'develop' of git.kdan.cc:Mac_PDF/PDF_Office into develop

tangchao 2 лет назад
Родитель
Сommit
8e3874caf1

+ 10 - 0
PDF Office/PDF Office.xcodeproj/project.pbxproj

@@ -830,6 +830,9 @@
 		9F78EFC628F7E965001E66F4 /* KMHomeViewController+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F78EFC528F7E965001E66F4 /* KMHomeViewController+UI.swift */; };
 		9F78EFC728F7E965001E66F4 /* KMHomeViewController+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F78EFC528F7E965001E66F4 /* KMHomeViewController+UI.swift */; };
 		9F78EFC828F7E965001E66F4 /* KMHomeViewController+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F78EFC528F7E965001E66F4 /* KMHomeViewController+UI.swift */; };
+		9F81ADC229B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F81ADC129B87C7F002251F4 /* KMConvertPDFManagerOC.m */; };
+		9F81ADC329B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F81ADC129B87C7F002251F4 /* KMConvertPDFManagerOC.m */; };
+		9F81ADC429B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9F81ADC129B87C7F002251F4 /* KMConvertPDFManagerOC.m */; };
 		9F8539BE2943085A00DF644E /* KMBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F8539BD2943085A00DF644E /* KMBrowser.swift */; };
 		9F8539BF2943085A00DF644E /* KMBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F8539BD2943085A00DF644E /* KMBrowser.swift */; };
 		9F8539C02943085A00DF644E /* KMBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F8539BD2943085A00DF644E /* KMBrowser.swift */; };
@@ -3393,6 +3396,8 @@
 		9F78EFBA28F7C1CC001E66F4 /* KMHomeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMHomeViewController.xib; sourceTree = "<group>"; };
 		9F78EFC128F7E395001E66F4 /* KMHomeViewController+Action.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KMHomeViewController+Action.swift"; sourceTree = "<group>"; };
 		9F78EFC528F7E965001E66F4 /* KMHomeViewController+UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KMHomeViewController+UI.swift"; sourceTree = "<group>"; };
+		9F81ADC029B87C7F002251F4 /* KMConvertPDFManagerOC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMConvertPDFManagerOC.h; sourceTree = "<group>"; };
+		9F81ADC129B87C7F002251F4 /* KMConvertPDFManagerOC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMConvertPDFManagerOC.m; sourceTree = "<group>"; };
 		9F8539BD2943085A00DF644E /* KMBrowser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBrowser.swift; sourceTree = "<group>"; };
 		9F8539C529430AC400DF644E /* KMToolbarRightView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMToolbarRightView.swift; sourceTree = "<group>"; };
 		9F8539C929430BF300DF644E /* KMBrowserWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBrowserWindowController.swift; sourceTree = "<group>"; };
@@ -7161,6 +7166,8 @@
 			children = (
 				BB88E453294045B4002B3655 /* KMPDFConvertManager.swift */,
 				9FDD0F76294FEF64000C4DAD /* KMConvertPDFManager.swift */,
+				9F81ADC029B87C7F002251F4 /* KMConvertPDFManagerOC.h */,
+				9F81ADC129B87C7F002251F4 /* KMConvertPDFManagerOC.m */,
 				BB88E45729404752002B3655 /* KMPDFConvert.swift */,
 			);
 			path = Common;
@@ -9230,6 +9237,7 @@
 				ADB1FE8E29752F7000ED072D /* KMBatchBackgroundView.swift in Sources */,
 				9FDD0F77294FEF64000C4DAD /* KMConvertPDFManager.swift in Sources */,
 				9F8539D62943180000DF644E /* KMTabAppearance.swift in Sources */,
+				9F81ADC229B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */,
 				BB5DF1E92959C5CB0025CDA1 /* KMHeaderFooterPreviewController.swift in Sources */,
 				9FDD0F6B294AD12C000C4DAD /* KMMainViewController+UI.swift in Sources */,
 				89D9897428FE743E003A3E87 /* KMOutlineView.swift in Sources */,
@@ -9938,6 +9946,7 @@
 				ADB1FE8F29752F7000ED072D /* KMBatchBackgroundView.swift in Sources */,
 				AD44D653292C9E7900A94554 /* KMImageToPDFChooseView.swift in Sources */,
 				89D2D2E3294C452B00BFF5FE /* KMPDFThumbnailView.swift in Sources */,
+				9F81ADC329B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */,
 				BB5DF1EA2959C5CB0025CDA1 /* KMHeaderFooterPreviewController.swift in Sources */,
 				BB6B4C0D292F62B20071CA06 /* KMPDFThumbnialPageView.swift in Sources */,
 				9F8539D72943180000DF644E /* KMTabAppearance.swift in Sources */,
@@ -11128,6 +11137,7 @@
 				9FBC48C1299E23B100CA39D7 /* NSViewController+DesignToken.swift in Sources */,
 				89752DF429389F82003FF08E /* KMToolbarItem.m in Sources */,
 				F34BF93229530559002C25A2 /* NSBitmapImageRep+PDFListView.m in Sources */,
+				9F81ADC429B87C7F002251F4 /* KMConvertPDFManagerOC.m in Sources */,
 				BBC3484C2958222C008D2CD1 /* KMBackgroundOutsideView.swift in Sources */,
 				AD0FA51429A9FA8600EDEB50 /* KMResetPasswordView.swift in Sources */,
 				9F0CB49129683DEE00007028 /* KMPropertiesPanelLineSubVC.swift in Sources */,

+ 10 - 0
PDF Office/PDF Office/Class/Home/Category/String+KMExtensions.swift

@@ -50,6 +50,16 @@ extension String {
         }
     }
     
+    public func substring(form index: Int) -> String {
+        if(self.count > index){
+            let startindex = self.index(self.startIndex, offsetBy: index)
+            let subString = self[startindex..<self.endIndex]
+            return String(subString)
+        }else{
+            return self
+        }
+    }
+    
     // MARK: String 转换为 CGFloat
     
     func stringToCGFloat() -> CGFloat {

+ 29 - 1
PDF Office/PDF Office/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -433,7 +433,35 @@ extension KMHomeViewController {
     }
     
     func openOfficeFile(url: URL) -> Void {
-        
+        let filePath = url.path
+        let folderPath = "convertToPDF.pdf"
+        let savePath = folderPath.kUrlToPDFFolderPath()
+        if savePath == nil {
+            return
+        }
+        KMConvertPDFManagerOC.convertFile(filePath, savePath: savePath!) { success, errorDic in
+            if errorDic != nil || !success || !FileManager.default.fileExists(atPath: savePath!) {
+                if FileManager.default.fileExists(atPath: savePath!) {
+                    try?FileManager.default.removeItem(atPath: savePath!)
+                }
+                let alert = NSAlert.init()
+                alert.alertStyle = .critical
+                var infoString = ""
+                if errorDic != nil {
+                    for key in (errorDic! as Dictionary).keys {
+                        infoString = infoString.appendingFormat("%@\n", errorDic![key] as! CVarArg)
+                    }
+                }
+                alert.informativeText = infoString
+                alert.messageText = NSLocalizedString("Conversion Failed", comment: "")
+                alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+                alert.runModal()
+                return
+            }
+            NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: savePath!), display: true) { document, documentWasAlreadyOpen, error in
+
+            }
+        }
     }
     
     override func keyDown(with event: NSEvent) -> Void {

+ 19 - 0
PDF Office/PDF Office/Class/PDFTools/Convert/Common/KMConvertPDFManagerOC.h

@@ -0,0 +1,19 @@
+//
+//  KMConvertPDFManagerOC.h
+//  PDF Office
+//
+//  Created by wanjun on 2023/3/8.
+//
+
+#import <Foundation/Foundation.h>
+#import <Quartz/Quartz.h>
+
+@interface KMConvertPDFManagerOC : NSObject
+
++ (NSArray *)supportFileType;
+
++ (void)convertFile:(NSString *)filePath
+           savePath:(NSString *)savePath
+  completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet;
+
+@end

+ 303 - 0
PDF Office/PDF Office/Class/PDFTools/Convert/Common/KMConvertPDFManagerOC.m

@@ -0,0 +1,303 @@
+//
+//  KMConvertPDFManagerOC.m
+//  PDF Office
+//
+//  Created by wanjun on 2023/3/8.
+//
+
+#import "KMConvertPDFManagerOC.h"
+
+@implementation KMConvertPDFManagerOC
+
+#pragma mark - Public
+
++ (NSArray *)supportFileType
+{
+    NSMutableArray *supportArray = [NSMutableArray array];
+    
+    [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportImages]];
+    
+    if ([KMConvertPDFManagerOC isSupportConvertPages]) {
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportPages]];
+    } else if ([KMConvertPDFManagerOC isSupportConvertWord]){
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportWord]];
+    }
+    
+    if ([KMConvertPDFManagerOC isSupportConvertKeynote]) {
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportKeynote]];
+    } else if ([KMConvertPDFManagerOC isSupportConvertPPTX]){
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportPPTX]];
+    }
+
+    if ([KMConvertPDFManagerOC isSupportConvertNumber]) {
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportNumber]];
+    } else if ([KMConvertPDFManagerOC isSupportConvertExcel]){
+        /**
+         经测试(2011版 Excel)转档成功以后地址会存在问题,暂时建议不要用
+         **/
+        [supportArray addObjectsFromArray:[KMConvertPDFManagerOC supportExcel]];
+    }
+
+    return supportArray;
+}
+
++ (void)convertFile:(NSString *)filePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    NSString *tSavePath = savePath;
+    if ([[tSavePath substringToIndex:1] isEqualToString:@"/"]) {
+        tSavePath = [tSavePath substringFromIndex:1];
+    }
+    tSavePath = [tSavePath stringByReplacingOccurrencesOfString:@"/" withString:@":"];
+    
+    NSString *tFilePath = filePath;
+    if ([[tFilePath substringToIndex:1] isEqualToString:@"/"]) {
+        tFilePath = [tFilePath substringFromIndex:1];
+    }
+    tFilePath = [tFilePath stringByReplacingOccurrencesOfString:@"/" withString:@":"];
+
+    NSString * extension = [filePath.pathExtension lowercaseString];
+    
+    if ([[KMConvertPDFManagerOC supportPages] containsObject:extension]) {
+        if ([[KMConvertPDFManagerOC supportWord] containsObject:extension]){
+            [KMConvertPDFManagerOC convertWordPath:tFilePath savePath:tSavePath completionHandler:^(BOOL success,NSDictionary *errorDic){
+                complet(success,errorDic);
+            }];
+        } else {
+            [KMConvertPDFManagerOC convertApplicationName:@"Pages" filePath:tFilePath savePath:tSavePath completionHandler:^(BOOL success, NSDictionary *errorDic) {
+                complet(success,errorDic);
+            }];
+        }
+        
+    } else if ([[KMConvertPDFManagerOC supportKeynote] containsObject:extension]){
+        if ([[KMConvertPDFManagerOC supportPPTX] containsObject:extension]){
+            [KMConvertPDFManagerOC convertPPTXPath:tFilePath savePath:tSavePath completionHandler:^(BOOL success,NSDictionary *errorDic){
+                complet(success,errorDic);
+            }];
+        } else {
+            [KMConvertPDFManagerOC convertApplicationName:@"Keynote" filePath:tFilePath savePath:tSavePath completionHandler:^(BOOL success, NSDictionary *errorDic) {
+                complet(success,errorDic);
+            }];
+        }
+    } else if ([[KMConvertPDFManagerOC supportNumber] containsObject:extension]){
+        if ([[KMConvertPDFManagerOC supportExcel] containsObject:extension]){
+            [KMConvertPDFManagerOC convertExcelPath:tFilePath savePath:tSavePath completionHandler:^(BOOL success,NSDictionary *errorDic){
+                complet(success,errorDic);
+            }];
+        } else {
+            [KMConvertPDFManagerOC convertApplicationName:@"Numbers" filePath:tFilePath savePath:tSavePath completionHandler:^(BOOL success, NSDictionary *errorDic) {
+                complet(success,errorDic);
+            }];
+        }
+    } else if ([[KMConvertPDFManagerOC supportImages] containsObject:extension]){
+        [KMConvertPDFManagerOC convertImagePath:filePath savePath:savePath completionHandler:^(BOOL success, NSDictionary *errorDic) {
+            complet(success,errorDic);
+        }];
+    } else {
+        NSDictionary * dic = nil;
+        complet(NO,dic);
+    }
+}
+
++ (NSArray *)supportImages
+{
+    return [NSArray arrayWithObjects:@"jpg",@"cur",@"bmp",@"jpeg",@"gif",@"png",@"tiff",@"tif",/*@"pic",*/@"ico",@"icns",@"tga",@"psd",@"eps",@"hdr",@"jp2",@"jpc",@"pict",@"sgi", nil];
+}
+
+#pragma mark - convert Word
++ (BOOL)isSupportConvertWord
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Microsoft Word"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportWord
+{
+    return [NSArray arrayWithObjects:@"docx",@"doc",nil];
+}
+
++ (void)convertWordPath:(NSString *)filePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        NSString *  convertString = [NSString stringWithFormat:@"set filePath to\"%@\"\n",filePath];
+        convertString = [convertString stringByAppendingFormat:@"set savePath to \"%@\"\n",savePath];
+        convertString = [convertString stringByAppendingFormat:@"tell application \"Microsoft Word\"\n"];
+        convertString = [convertString stringByAppendingFormat:@"set isRun to running\n"];
+        convertString = [convertString stringByAppendingFormat:@"open file filePath\n"];
+        convertString = [convertString stringByAppendingFormat:@"save as active document file format format PDF file name savePath\n"];
+        convertString = [convertString stringByAppendingFormat:@"close active document\n"];
+        convertString = [convertString stringByAppendingFormat:@"if not isRun then quit\n"];
+        convertString = [convertString stringByAppendingFormat:@"end tell\n"];
+        
+        NSDictionary * dic = nil;
+        NSAppleScript *docScript = [[NSAppleScript alloc] initWithSource:convertString];
+        [docScript executeAndReturnError:&dic];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            complet(YES,dic);
+        });
+    });
+}
+
+#pragma mark - convert Numbers
++ (BOOL)isSupportConvertNumber
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Numbers"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportNumber
+{
+    return [NSArray arrayWithObjects:@"xls",@"xlsx",@"numbers",@"csv",nil];
+}
+
++ (void)convertApplicationName:(NSString *)appName filePath:(NSString *)filePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        NSString * convertString = [NSString stringWithFormat:@"tell application \"%@\"\n",appName];
+        convertString = [convertString stringByAppendingFormat:@"set isRun to running\n"];
+        convertString = [convertString stringByAppendingFormat:@"set in_file to \"%@\"\n",filePath];
+        convertString = [convertString stringByAppendingFormat:@"set out_file to \"%@\"\n",savePath];
+        convertString = [convertString stringByAppendingFormat:@"set mydoc to open file in_file\n"];
+        convertString = [convertString stringByAppendingFormat:@"export mydoc to file out_file as PDF\n"];
+        convertString = [convertString stringByAppendingFormat:@"close mydoc saving no\n"];
+        convertString = [convertString stringByAppendingFormat:@"if not isRun then quit\n"];
+        convertString = [convertString stringByAppendingFormat:@"end tell"];
+        NSDictionary * dic = nil;
+        NSAppleScript *docScript = [[NSAppleScript alloc] initWithSource:convertString];
+        [docScript executeAndReturnError:&dic];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            complet(YES,dic);
+        });
+    });
+}
+
+#pragma mark - convert Keynote
++ (BOOL)isSupportConvertKeynote
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Keynote"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportKeynote
+{
+    return [NSArray arrayWithObjects:@"ppt",@"pptx",@"key",nil];
+}
+
+#pragma mark - convert Pages
++ (BOOL)isSupportConvertPages
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Pages"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportPages
+{
+    return [NSArray arrayWithObjects:@"pages",@"docx",@"doc",@"txt",@"rtf",nil];
+}
+
+#pragma mark - convert PPTX
++ (BOOL)isSupportConvertPPTX
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Microsoft PowerPoint"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportPPTX
+{
+    return [NSArray arrayWithObjects:@"ppt",@"pptx",nil];
+}
+
++ (void)convertPPTXPath:(NSString *)filePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        NSString * convertString = [NSString stringWithFormat:@"tell application \"Microsoft PowerPoint\"\n"];
+        convertString = [convertString stringByAppendingFormat:@"set isRun to running\n"];
+        convertString = [convertString stringByAppendingFormat:@"set savePath to \"%@\"\n",savePath];
+        convertString = [convertString stringByAppendingFormat:@"set filePath to \"%@\"\n",filePath];
+        convertString = [convertString stringByAppendingFormat:@"open file filePath\n"];
+        convertString = [convertString stringByAppendingFormat:@"save active presentation in savePath as save as PDF\n"];
+        convertString = [convertString stringByAppendingFormat:@"if not isRun then quit\n"];
+        convertString = [convertString stringByAppendingFormat:@"close active presentation\n"];
+        convertString = [convertString stringByAppendingFormat:@"end tell\n"];
+        
+        NSDictionary * dic = nil;
+        NSAppleScript *docScript = [[NSAppleScript alloc] initWithSource:convertString];
+        [docScript executeAndReturnError:&dic];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            complet(YES,dic);
+        });
+    });
+}
+
+#pragma mark - convert Excel
++ (BOOL)isSupportConvertExcel
+{
+    NSString * fullPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:@"Microsoft Excel"];
+    if (fullPath) {
+        return YES;
+    }
+    return NO;
+}
+
++ (NSArray *)supportExcel
+{
+    return [NSArray arrayWithObjects:@"xlsx",@"xls",nil];
+}
+
++ (void)convertExcelPath:(NSString *)filePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        NSString *  convertString = [NSString stringWithFormat:@"set filePath to\"%@\"\n",filePath];
+        convertString = [convertString stringByAppendingFormat:@"set savePath to \"%@\"\n",savePath];
+        convertString = [convertString stringByAppendingFormat:@"set tFile to (POSIX path of filePath) as POSIX file\n"];
+
+        convertString = [convertString stringByAppendingFormat:@"tell application \"Microsoft Excel\"\n"];
+        convertString = [convertString stringByAppendingFormat:@"set isRun to running\n"];
+        convertString = [convertString stringByAppendingFormat:@"set wkbk1 to open workbook workbook file name tFile\n"];
+        convertString = [convertString stringByAppendingFormat:@"alias savePath\n"];
+        convertString = [convertString stringByAppendingFormat:@"save workbook as wkbk1 filename savePath file format PDF file format with overwrite\n"];
+        convertString = [convertString stringByAppendingFormat:@"close wkbk1 saving no\n"];
+        convertString = [convertString stringByAppendingFormat:@"if not isRun then quit\n"];
+        convertString = [convertString stringByAppendingFormat:@"end tell\n"];
+        
+        NSDictionary * dic = nil;
+        NSAppleScript *docScript = [[NSAppleScript alloc] initWithSource:convertString];
+        [docScript executeAndReturnError:&dic];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            complet(YES,dic);
+        });
+    });
+}
+
+#pragma mark - convert Image
++ (void)convertImagePath:(NSString *)imgaePath savePath:(NSString *)savePath completionHandler:(void (^)(BOOL success,NSDictionary *errorDic))complet
+{
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        PDFDocument *pdf = [[PDFDocument alloc] init];
+        NSImage *imag = [[NSImage alloc] initWithContentsOfFile:imgaePath];
+        PDFPage *page = [[PDFPage alloc] initWithImage:imag];
+        [pdf insertPage:page atIndex: [pdf pageCount]];
+        
+        BOOL isSucceed = [pdf writeToFile:savePath];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            NSDictionary * dic = nil;
+            complet(isSucceed,dic);
+        });
+    });
+}
+
+@end

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

@@ -1273,6 +1273,21 @@ extension KMMainViewController {
             toItem.unEnabled = true
         }
     }
+    
+    func updateZoomInOutButtonState() {
+        let item : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentZoomToolbarItemIdentifier))!
+        let toItem : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentZoomOutToolbarItemIdentifier))!
+        if self.listView.canZoomIn {
+            item.unEnabled = false
+        } else {
+            item.unEnabled = true
+        }
+        if self.listView.canZoomOut {
+            toItem.unEnabled = false
+        } else {
+            toItem.unEnabled = true
+        }
+    }
 }
 
 extension KMMainViewController: KMSecondaryViewControllerDelegate {
@@ -1349,10 +1364,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
     
     func changePDFViewZoomInAction() {
         self.listView.zoomIn(nil)
+        self.updateZoomInOutButtonState()
     }
     
     func changePDFViewZoomOutAction() {
         self.listView.zoomOut(nil)
+        self.updateZoomInOutButtonState()
     }
     
     func changePDFViewGotoNextPageAction() {

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

@@ -287,8 +287,7 @@ import Cocoa
         controller.itemClick = {
             [weak self] (index: Int, param: Any) in
             if (index == 1) { /// 双击退出
-                self?.exitPageEdit()
-                
+                self?.enterEditMode(self!.leftSideViewController)
                 DispatchQueue.main.async {
                     let pageIndex: Int = param as! Int
                     self?.listView.go(toPageIndex: pageIndex, animated: true)

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

@@ -67,3 +67,4 @@
 #import "KMCellEmptyView.h"
 #import "KMSelfSignAnnotation.h"
 #import "SKTextFieldSheetController.h"
+#import "KMConvertPDFManagerOC.h"