Browse Source

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

tangchao 11 months ago
parent
commit
28e75df05c
15 changed files with 187 additions and 94 deletions
  1. 4 4
      PDF Office/PDF Master/Base.lproj/Main.storyboard
  2. 7 1
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift
  3. 1 0
      PDF Office/PDF Master/Class/PDFTools/Merge/OCPart/KMSavePanelAccessoryController.swift
  4. 10 0
      PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift
  5. 1 1
      PDF Office/PDF Master/Class/PDFTools/Print/Model/KMPrintPageModel.swift
  6. 73 22
      PDF Office/PDF Master/Class/PDFTools/Print/Presenter/KMPrintPresenter.swift
  7. 7 6
      PDF Office/PDF Master/Class/PDFTools/Print/View/ChooseView/View/View/DealPaper/KMPrintChoosePageSizePosterView.swift
  8. 1 1
      PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/View/Poster/KMPrintPosterView.swift
  9. 1 1
      PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/ViewModel/KMPrintViewModel.swift
  10. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m
  11. 12 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Tool.m
  12. 2 46
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift
  13. 57 5
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift
  14. 5 3
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift
  15. 5 1
      PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift

+ 4 - 4
PDF Office/PDF Master/Base.lproj/Main.storyboard

@@ -1246,25 +1246,25 @@ CA
                                                             <action selector="themesColor:" target="Ady-hI-5gd" id="HLl-GU-gSk"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Themes1" tag="4" hidden="YES" id="DWn-PU-6hc">
+                                                    <menuItem title="Themes1" tag="4" id="DWn-PU-6hc">
                                                         <modifierMask key="keyEquivalentModifierMask"/>
                                                         <connections>
                                                             <action selector="themesColor:" target="Ady-hI-5gd" id="8T5-Lt-1gP"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Themes2" tag="5" hidden="YES" id="YvI-0f-WA5">
+                                                    <menuItem title="Themes2" tag="5" id="YvI-0f-WA5">
                                                         <modifierMask key="keyEquivalentModifierMask"/>
                                                         <connections>
                                                             <action selector="themesColor:" target="Ady-hI-5gd" id="hII-p1-9lS"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Themes3" tag="6" hidden="YES" id="i1z-vh-727">
+                                                    <menuItem title="Themes3" tag="6" id="i1z-vh-727">
                                                         <modifierMask key="keyEquivalentModifierMask"/>
                                                         <connections>
                                                             <action selector="themesColor:" target="Ady-hI-5gd" id="a5H-OG-3BX"/>
                                                         </connections>
                                                     </menuItem>
-                                                    <menuItem title="Themes4" tag="7" hidden="YES" id="o8C-LV-ujc">
+                                                    <menuItem title="Themes4" tag="7" id="o8C-LV-ujc">
                                                         <modifierMask key="keyEquivalentModifierMask"/>
                                                         <connections>
                                                             <action selector="themesColor:" target="Ady-hI-5gd" id="TKn-6z-q43"/>

+ 7 - 1
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift

@@ -150,7 +150,12 @@ extension KMMergeWindowController {
     }
     
     func mergeFiles(files: [KMFileAttribute], size: CGSize = CGSizeZero) {
-        if !IAPProductsManager.default().isAvailableAllFunction() && files.count > 2 {
+        var size = 0.0
+        for file in files {
+            size = size + file.fileSize
+        }
+        
+        if !IAPProductsManager.default().isAvailableAllFunction() && (files.count > 2 || size > 20 * 1024 * 1024) {
             KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
             return
         }
@@ -262,6 +267,7 @@ extension KMMergeWindowController {
     //                self.savePanelAccessoryViewController = savePanelAccessoryViewController;
                     savePanel.beginSheetModal(for: self.window!) { result in
                         if result == .OK {
+                            self.cancelAction?()
                             var outputSavePanel = savePanel.url?.path
                             DispatchQueue.main.async {
                                 var success = self.oldPDFDocument.write(toFile: outputSavePanel!)

+ 1 - 0
PDF Office/PDF Master/Class/PDFTools/Merge/OCPart/KMSavePanelAccessoryController.swift

@@ -29,6 +29,7 @@ class KMSavePanelAccessoryController: NSViewController {
         openAutomaticButton.title = NSLocalizedString("Open the document after saving", comment: "")
         let autoOpen = KMDataManager.ud_bool(forKey: KMAutoOpenDocumentKey)
         openAutomaticButton.state = autoOpen ? .on : .off
+        _needOpen = autoOpen
     }
 
     @IBAction func buttonClickedOpenAutomatic(_ sender: NSButton) {

+ 10 - 0
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -179,6 +179,16 @@ class KMPrintWindowController: KMBaseWindowController, NetServiceBrowserDelegate
     }
     
     static func showNewPrintWindowControll(inputDocument: CPDFDocument?, inputType: DataNavigationViewButtonActionType = .Print, inputPageRange: KMPrintPageRange, printType: KMPrintModelType = .size) {
+        //订阅
+        if !IAPProductsManager.default().isAvailableAllFunction(){
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+        
+        if inputDocument != nil {
+            guard let  pdfDocument = PDFDocument(url: inputDocument!.documentURL) else { return }
+        }
+        
         let printWindowController: KMPrintWindowController = KMPrintWindowController.init(windowNibName: "KMPrintWindowController")
 
         printWindowController.printType = printType

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/Model/KMPrintPageModel.swift

@@ -169,7 +169,7 @@ struct KMPrintPageOperation {
         var overlap: Float = 0.0
         var isCutMark: Bool = false
         var isTags: Bool = false
-        var tags: [String] = ["(column,row)1.pdf 2023-01-09 05:49:54"]
+        var tags: String = "(column,row)1.pdf 2023-01-09 05:49:54"
         
         enum PosterType {
             case tile //平铺

+ 73 - 22
PDF Office/PDF Master/Class/PDFTools/Print/Presenter/KMPrintPresenter.swift

@@ -519,36 +519,42 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
                         context.strokePath()
                     }
                     NSGraphicsContext.restoreGraphicsState()
+                    if data.page.operation.poster.isTags {
+                        self.drawLabelText(data: data, point: CGPointMake(CGFloat(i + 1), CGFloat(j + 1)))
+                    }
 //                        page.setBounds(NSRect(x: 0, y: 0, width: pageRect.size.width, height: pageRect.size.height), for: .cropBox)
                 }
             }
         }
     }
     
-    func drawLabelTextContextSize(context: CGContext) {
-        let pageSize = CGSize(width: 0, height: 0)
-        let KBlankA4W = pageSize.width
-        let KBlankA4H = pageSize.height
+    func drawLabelText(data: KMPrintModel, point: NSPoint) {
+        let paperSize: CGSize = self.fetchPaperSize(data.paper)//纸张大小
+        
+        let KBlankA4W = paperSize.width
+        let KBlankA4H = paperSize.height
         
         var contextString: String
-//        if let labelString = PDFPrint.labelString, !labelString.isEmpty {
-//            contextString = labelString
-//        } else {
+        let labelString = data.page.operation.poster.tags
+        
+        if labelString.count != 0 {
+            contextString = labelString
+        } else {
             let date = Date()
             let formatter = DateFormatter()
             formatter.dateFormat = "YYYY-MM-dd hh:mm:ss"
-        contextString = "(\("1"),\("1")) \("filePath.lastPathComponent") \(formatter.string(from: date))"
-//        }
+            contextString = "(\(point.x),\(point.y)) \(self.document?.documentURL.lastPathComponent) \(formatter.string(from: date))"
+        }
         
         let fontSize = 12.0 * (max(KBlankA4W, KBlankA4H) / 842)
         let font = NSFont.systemFont(ofSize: fontSize)
         let color = NSColor.black
         
-        var size = NSSize.zero
-        var style = NSMutableParagraphStyle()
+        var size = CGSize.zero
+        let style = NSMutableParagraphStyle()
         style.alignment = .center
         style.lineBreakMode = .byCharWrapping
-        var attributes = [NSAttributedString.Key: Any]()
+        var attributes: [NSAttributedString.Key: Any] = [:]
         attributes[.paragraphStyle] = style
         attributes[.foregroundColor] = color
         attributes[.font] = font
@@ -556,18 +562,63 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
                                           options: [.usesLineFragmentOrigin, .usesFontLeading],
                                           attributes: attributes).size
         
-//        if PDFPrint.splitType == .pageNumber {
-            contextString.draw(in: CGRect(x: 10 + 10,
-                                          y: KBlankA4H - 10 + size.height,
-                                          width: size.width, height: size.height),
-                                withAttributes: attributes)
+        let drawRect: CGRect
+//        if data.page.operation.poster.type == .tile {
+//            drawRect = CGRect(x: 20 + 10,
+//                              y: 100 + size.height,
+//                              width: size.width, height: size.height)
 //        } else {
-//            contextString.draw(in: CGRect(x: PDFPrint.edgeInsets.left + 10,
-//                                          y: KBlankA4H - PDFPrint.edgeInsets.top + size.height,
-//                                          width: size.width, height: size.height),
-//                                withAttributes: attributes)
+            drawRect = CGRect(x: 20,
+                              y: paperSize.height - size.height - 40,
+                              width: size.width, height: size.height)
 //        }
+        
+        contextString.draw(in: drawRect, withAttributes: attributes)
     }
+    
+//    func drawLabelTextContextSize(context: CGContext) {
+//        let pageSize = CGSize(width: 0, height: 0)
+//        let KBlankA4W = pageSize.width
+//        let KBlankA4H = pageSize.height
+//        
+//        var contextString: String
+////        if let labelString = PDFPrint.labelString, !labelString.isEmpty {
+////            contextString = labelString
+////        } else {
+//            let date = Date()
+//            let formatter = DateFormatter()
+//            formatter.dateFormat = "YYYY-MM-dd hh:mm:ss"
+//        contextString = "(\("1"),\("1")) \("filePath.lastPathComponent") \(formatter.string(from: date))"
+////        }
+//        
+//        let fontSize = 12.0 * (max(KBlankA4W, KBlankA4H) / 842)
+//        let font = NSFont.systemFont(ofSize: fontSize)
+//        let color = NSColor.black
+//        
+//        var size = NSSize.zero
+//        var style = NSMutableParagraphStyle()
+//        style.alignment = .center
+//        style.lineBreakMode = .byCharWrapping
+//        var attributes = [NSAttributedString.Key: Any]()
+//        attributes[.paragraphStyle] = style
+//        attributes[.foregroundColor] = color
+//        attributes[.font] = font
+//        size = contextString.boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude),
+//                                          options: [.usesLineFragmentOrigin, .usesFontLeading],
+//                                          attributes: attributes).size
+//        
+////        if PDFPrint.splitType == .pageNumber {
+//            contextString.draw(in: CGRect(x: 10 + 10,
+//                                          y: KBlankA4H - 10 + size.height,
+//                                          width: size.width, height: size.height),
+//                                withAttributes: attributes)
+////        } else {
+////            contextString.draw(in: CGRect(x: PDFPrint.edgeInsets.left + 10,
+////                                          y: KBlankA4H - PDFPrint.edgeInsets.top + size.height,
+////                                          width: size.width, height: size.height),
+////                                withAttributes: attributes)
+////        }
+//    }
 
 }
 
@@ -1064,7 +1115,7 @@ extension KMPrintPresenter: KMPrintPresenterDraw {
     //    }
     
     func drawString(_ pageModel: KMPrintPageModel, _ contextSize: CGSize) {
-        var string = pageModel.operation.poster.tags.first ?? ""
+        var string = pageModel.operation.poster.tags
 //        if string.isEmpty {
 //            string =
 //        }

+ 7 - 6
PDF Office/PDF Master/Class/PDFTools/Print/View/ChooseView/View/View/DealPaper/KMPrintChoosePageSizePosterView.swift

@@ -71,7 +71,8 @@ class KMPrintChoosePageSizePosterView: KMBaseXibView {
         self.tagsTextField.onlyNumber = false
         self.tagsTextField.placeholderString = "(column,row)1.pdf 2023-01-09 05:49:54"
         self.tagsTextField.textDidChange = { [unowned self] (string) in
-            self.outputData.tags = string.components(separatedBy: " ")
+            self.outputData.tags = string
+//            self.outputData.tags = string.components(separatedBy: " ")
             self.actionReloadData()
         }
         
@@ -106,12 +107,12 @@ class KMPrintChoosePageSizePosterView: KMBaseXibView {
         self.tagsButton.state = (self.outputData.isTags == true) ? .on : .off
         
         self.tileScaleTextField.stringValue = (self.outputData.scale * 100).description
-        var string: String = ""
-        for s in self.outputData.tags {
-            string += " " + s
-        }
+//        var string: String = ""
+//        for s in self.outputData.tags {
+//            string += " " + s
+//        }
         
-        self.tagsTextField.stringValue = string
+        self.tagsTextField.stringValue = self.outputData.tags
     }
 }
 

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/View/Poster/KMPrintPosterView.swift

@@ -272,7 +272,7 @@ extension KMPrintPosterView {
             labelTextField.isEditable = false
         }
     
-        self.viewModel.posterTagsAction(isSelect: labelButton.state == .on, tags:[labelTextField.stringValue]) { success, model in
+        self.viewModel.posterTagsAction(isSelect: labelButton.state == .on, tags:labelTextField.stringValue) { success, model in
             self.updatePDFView(isPageChange: false)
         }
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/View/PrintSettingView/ViewModel/KMPrintViewModel.swift

@@ -180,7 +180,7 @@ extension KMPrintViewModel {
         completion(true, model)
     }
     
-    func posterTagsAction(isSelect: Bool, tags: [String], completion: KMPrintViewModelCompletion) {
+    func posterTagsAction(isSelect: Bool, tags: String, completion: KMPrintViewModelCompletion) {
         if isSelect == self.model.page.operation.poster.isTags {
             completion(false, nil)
             return

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -4225,7 +4225,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     NSDictionary *dict = sender.representedObject;
     CPDFPage *page = dict[@"page"];
     CPDFAnnotation *annotation = dict[@"annotation"];
-    [self moveAnnotationOnPage:page annotation:annotation newIndex:[page.annotations indexOfObject:annotation] + 1];
+    [self moveAnnotationOnPage:page annotation:annotation newIndex:[page.annotations indexOfObject:annotation] + 2];
 }
 
 - (IBAction)menuItemClick_SendBackward:(NSMenuItem *)sender {

+ 12 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Tool.m

@@ -539,8 +539,18 @@
     }
     
     [[[self undoManager] prepareWithInvocationTarget:self] moveAnnotationOnPage:aPage annotation:anAnnotation newIndex:originalIndex];
-    [aPage moveHierarchyWithAnnotation:anAnnotation atIndex:newIndex];
-    [self setNeedsDisplayAnnotationViewForVisiblePages];
+//    [aPage moveHierarchyWithAnnotation:anAnnotation atIndex:newIndex];
+//    [self setNeedsDisplayAnnotationViewForVisiblePages];
+    NSMutableArray *newAddArray = [NSMutableArray arrayWithArray:aPage.annotations];
+    for (CPDFAnnotation *anno in newAddArray) {
+        [aPage removeAnnotation:anno];
+    }
+    [newAddArray removeObject:anAnnotation];
+    [newAddArray insertObject:anAnnotation atIndex:newIndex];
+    for (NSUInteger i = 0; i < newAddArray.count; i++) {
+        [aPage addAnnotation:newAddArray[i]];
+    }
+    [self setNeedsDisplay:YES];
 }
 
 - (void)showHUDHint:(CPDFAnnotation *)newActiveAnnotation {

+ 2 - 46
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -1593,10 +1593,8 @@ let KMColorPickerViewHeight: CGFloat = 64
         
         if annotationType == .freeText {
             if let fillColorPickerColor = fillColorPickerView.color {
-                fillColorPickerColor.usingColorSpaceName(.calibratedRGB)?.getRed(&red, green: &green, blue: &blue, alpha: &opacity)
-                let color = NSColor(calibratedRed: red, green: green, blue: blue, alpha: opacity)
-                annotationModel?.setColor(color)
-                annotationModel?.setOpacity(opacity)
+                annotationModel?.setColor(fillColorPickerColor)
+//                annotationModel?.setOpacity(opacity)
             }
         } else {
             annotationModel?.setColor(fillColor)
@@ -1606,48 +1604,6 @@ let KMColorPickerViewHeight: CGFloat = 64
     }
     
     @IBAction func fontViewCorloPVAction(_ sender: Any) {
-//        var fillColor: NSColor = NSColor.clear
-//        var red: CGFloat = 0.0, green: CGFloat = 0.0, blue: CGFloat = 0.0, opacity: CGFloat = 0.0
-//        
-//        if let textColor = fontViewCorloPV.color {
-//            textColor.usingColorSpaceName(.calibratedRGB)?.getRed(&red, green: &green, blue: &blue, alpha: &opacity)
-//            if fabs(opacity - 0) < 0.001 {
-//                if annotationType == .freeText || annotationType == .signText || annotationType == .signDate {
-//                    annotationModel?.setOpacity(0)
-//                    annotationModel?.setFontColor(.black)
-//                } else {
-//                    annotationModel?.setOpacity(0)
-//                    annotationModel?.setFontColor(.black)
-//                }
-//            } else {
-//                if annotationType == .freeText || annotationType == .signText || annotationType == .signDate {
-//                    annotationModel?.setOpacity(opacity)
-//                    annotationModel?.setFontColor(textColor)
-//                } else {
-//                    annotationModel?.setOpacity(opacity)
-//                    annotationModel?.setColor(textColor)
-//                }
-//            }
-//            
-//            opacitySlider.floatValue = Float(opacity)
-//            
-//            if annotationModel?.annotation != nil {
-//                if annotationModel?.annotation is CPDFFreeTextAnnotation {
-//                    let textNote = (annotationModel?.annotation as! CPDFFreeTextAnnotation)
-//                    if let isEdit = pdfView?.isEdit(withCurrentFreeText: textNote), isEdit {
-//                        pdfView?.setEditAnnotationFreeTextColor(textColor, freeText: textNote)
-//                    } else {
-//                        updateAnnotation()
-//                    }
-//                } else {
-//                    updateAnnotation()
-//                }
-//                generalImageView.image = annotationModel?.annotationImage
-//            } else {
-//                updateAnnotation()
-//            }
-//        }
-        
         var red: CGFloat = 0.0, green: CGFloat = 0.0, blue: CGFloat = 0.0, opacity: CGFloat = 0.0
         if let fontViewPickerColor = fontViewCorloPV.color {
             fontViewPickerColor.usingColorSpaceName(.calibratedRGB)?.getRed(&red, green: &green, blue: &blue, alpha: &opacity)

+ 57 - 5
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -424,10 +424,29 @@ extension KMMainViewController {
             self.listView.displayMode = .night
         } else if mode == 3 {
             self.listView.displayMode = .green
+        } else {
+            self.listView.displayMode = .custom
+            
+            var data: Data? = nil
+            if let themesData = UserDefaults.standard.object(forKey: "kKMPDFViewModeThemesArray") as? Data {
+                data = themesData
+            }
+            let appArray = NSKeyedUnarchiver.unarchiveObject(with: data ?? Data()) as? [Any] ?? []
+            let mutableArray = appArray
+            if mutableArray.count > 0 {
+                let themesArray = mutableArray as! [NSColor]
+                let color = themesArray[mode]
+                self.listView.displayModeCustomColor = color
+            }
         }
         
         self.listView.layoutDocumentView()
         self.listView.setNeedsDisplayForVisiblePages()
+        
+//        [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:mode] forKey:@"kPDFViewModeKey"];
+//        [[NSUserDefaults standardUserDefaults] synchronize];
+        UserDefaults.standard.set(mode, forKey: "kPDFViewModeKey")
+        UserDefaults.standard.synchronize()
     }
     
     @IBAction func toggleStatusBar(_ sender: Any?) {
@@ -1476,16 +1495,49 @@ extension KMMainViewController: NSMenuItemValidation, NSMenuDelegate {
                 return true
             } else if action == KMSystemMenu.View.themesColorSelector {
                 let mode = menuItem.tag
+                
+                var viewMode: KMPDFViewMode = .normal
+                if let storedViewMode = UserDefaults.standard.value(forKey: "kPDFViewModeKey") as? Int {
+                    viewMode = KMPDFViewMode(rawValue: UInt(storedViewMode)) ?? .normal
+                }
+
                 if mode == 0 {
-                    menuItem.state = self.listView.displayMode == .normal ? .on : .off
+                    menuItem.state = viewMode == .normal ? .on : .off
                 } else if mode == 1 {
-                    menuItem.state = self.listView.displayMode == .soft ? .on : .off
+                    menuItem.state = viewMode == .soft ? .on : .off
                 } else if mode == 2 {
-                    menuItem.state = self.listView.displayMode == .night ? .on : .off
+                    menuItem.state = viewMode == .night ? .on : .off
                 } else if mode == 3 {
-                    menuItem.state = self.listView.displayMode == .green ? .on : .off
+                    menuItem.state = viewMode == .green ? .on : .off
+                } else if mode == 4 {
+                    menuItem.state = viewMode == .themes1 ? .on : .off
+                } else if mode == 5 {
+                    menuItem.state = viewMode == .themes2 ? .on : .off
+                } else if mode == 6 {
+                    menuItem.state = viewMode == .themes3 ? .on : .off
+                } else if mode == 7 {
+                    menuItem.state = viewMode == .themes4 ? .on : .off
                 }
-                return true
+                
+                var data: Data? = nil
+                if let themesData = UserDefaults.standard.object(forKey: "kKMPDFViewModeThemesArray") as? Data {
+                    data = themesData
+                }
+                var themesCount = 0
+                let appArray = NSKeyedUnarchiver.unarchiveObject(with: data ?? Data()) as? [Any] ?? []
+                if appArray.count > 0 {
+                    themesCount = menuItem.tag - appArray.count
+                } else {
+                    themesCount = menuItem.tag - 4
+                }
+                if themesCount >= 0 {
+                    menuItem.isHidden = true
+                    return false
+                }else {
+                    menuItem.isHidden = false
+                    return true
+                }
+//                return true
             } else if action == KMSystemMenu.View.splitViewActionSelector {
                 let mode = menuItem.tag
                 if mode == 0 { // hor

+ 5 - 3
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -1402,9 +1402,9 @@ let LOCKED_KEY  = "locked"
             }
             
             guard let _url = documentURL else { return }
+            guard let document = PDFDocument(url: _url) else { return }
             
-            let document = PDFDocument(url: _url)
-            let windowController = KMMergeWindowController(document: document!, password: password ?? "")
+            let windowController = KMMergeWindowController(document: document, password: password ?? "")
             windowController.oriDucumentUrl = self.listView.document.documentURL
             windowController.pageIndex = self.listView.currentPageIndex
             self.currentWindowController = windowController
@@ -2867,7 +2867,9 @@ let LOCKED_KEY  = "locked"
                     tMenuItems?.append(self.exportImageArea())
                 }
             } else {
-                tMenuItems?.swapAt(0, 1)
+                if tMenuItems?.count != 1 {
+                    tMenuItems?.swapAt(0, 1)
+                }
             }
         } else if areas.count == 0 {
             tMenuItems?.append(NSMenuItem.separator())

+ 5 - 1
PDF Office/PDF Master/Class/Preference/Controller/KMGeneralPreferences.swift

@@ -81,7 +81,11 @@ class KMGeneralPreferences: NSViewController {
         
         self.openTabLabel.stringValue = String(format: "%@:", KMLocalizedString("Open a document in", nil))
         for item in self.openTabButton.itemArray {
-            item.title = KMLocalizedString(item.title, nil)
+            if IAPProductsManager.default().isAvailableAllFunction(){
+                item.title = KMLocalizedString(item.title, nil)
+            }else{
+                item.title = KMLocalizedString("a new window")
+            }
         }
         self.showConvertMenuButton.title = KMLocalizedString("Show PDF Reader Pro in menu bar", nil)
         self.defaultOpenButton.title = KMLocalizedString("Set PDF Reader Pro as the default PDF viewer", nil)