Browse Source

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

liujiajie 11 months ago
parent
commit
8d97e1a03e

+ 2 - 0
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -1070,6 +1070,8 @@ extension KMMainDocument {
             return true
         } else if menuItem.action == #selector(saveArchive) {
             return !self.isHome
+        } else if (menuItem.action == #selector(saveTo(_ :))) {
+            return !self.isHome
         }
         return super.validateMenuItem(menuItem)
     }

+ 10 - 0
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -31,6 +31,16 @@ extension KMHomeViewController: NSMenuItemValidation {
                 return _browserWindowC.canMergeAllWindow()
             }
         }
+        if (menuItem.action == #selector(menuItemAction_ConvertToWord) ||
+            menuItem.action == #selector(menuItemAction_ConvertToExcel) ||
+            menuItem.action == #selector(menuItemAction_ConvertToPPT) ||
+            menuItem.action == #selector(menuItemAction_ConvertToRTF) ||
+            menuItem.action == #selector(menuItemAction_ConvertToHTML) ||
+            menuItem.action == #selector(menuItemAction_ConvertToText) ||
+            menuItem.action == #selector(menuItemAction_ConvertToCSV) ||
+            menuItem.action == #selector(menuItemAction_ConvertToImage)) {
+             return false
+        }
         return true
     }
 }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift

@@ -820,7 +820,7 @@ extension KMAddBackgroundView {
     @IBAction func alphaSteperAction(_ sender: NSStepper) {
         alphaTextField.stringValue = "\(Int(sender.doubleValue * 100))%"
         background.opacity = sender.doubleValue
-        alphaStepper.doubleValue = sender.doubleValue
+        alphaSlider.doubleValue = sender.doubleValue
         self.updatePDFView()
 
         if filePathLabel.stringValue.count > 0 {

+ 18 - 23
PDF Office/PDF Master/Class/PDFTools/HeaderFooter/Tools/KMHeaderFooterManager.swift

@@ -5,43 +5,38 @@ private let kHeaderFooterInfoSaveKey = "kHeaderFooterInfoSaveKey"
 class KMHeaderFooterManager: NSObject, NSCoding {
     var headFooterObjects: [KMHeaderFooterObject] = []
     static let defaultManager = KMHeaderFooterManager()
-
+    
     override init() {
         super.init()
         self.reloadData()
     }
-
+    
     required init?(coder: NSCoder) {
-        headFooterObjects = coder.decodeObject(forKey: "headFooterObjects") as? [KMHeaderFooterObject] ?? []
+        if let data = coder.decodeObject(forKey: "headFooterObjects") {
+            headFooterObjects = data as? [KMHeaderFooterObject] ?? []
+        }
     }
-
+    
     func encode(with coder: NSCoder) {
         coder.encode(headFooterObjects, forKey: "headFooterObjects")
     }
 
     func reloadData() {
-        let storedData = UserDefaults.standard.value(forKey: kHeaderFooterInfoSaveKey) as? Data
-        if let storedData = storedData {
-            if let manager = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(storedData) as? KMHeaderFooterManager {
-                
-                self.headFooterObjects = manager.headFooterObjects
+        do {
+            if let storedData = UserDefaults.standard.value(forKey: kHeaderFooterInfoSaveKey) as? Data {
+                NSKeyedUnarchiver.setClass(KMHeaderFooterObject.self, forClassName: "KMHeaderFooterObject")
+                NSKeyedUnarchiver.setClass(KMHeaderFooterManager.self, forClassName: "KMHeaderFooterManager")
+                if let man = NSKeyedUnarchiver.unarchiveObject(with: storedData) as? KMHeaderFooterManager {
+                    self.headFooterObjects = man.headFooterObjects
+                    print(man)
+                }
             }
+        } catch {
+            // 解档失败,处理错误情况
+            print("Error unarchiving data: \(error)")
         }
     }
-//    static func defaultManager() -> KMHeaderFooterManager {
-//        let storedData = UserDefaults.standard.value(forKey: kHeaderFooterInfoSaveKey) as? Data
-//        if let storedData = storedData {
-//            if let manager = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(storedData) as? KMHeaderFooterManager {
-//                return manager
-//            }
-//        }
-//        let manager = KMHeaderFooterManager()
-//        if manager.headFooterObjects.isEmpty {
-//            manager.headFooterObjects = []
-//        }
-//        return manager
-//    }
-
+    
     var onlyHeaderFooterObjects: [KMHeaderFooterObject] {
         return headFooterObjects.filter { !$0.isBates }
     }

+ 19 - 5
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -366,11 +366,25 @@ extension NetService {
 extension KMPrintWindowController: KMPrintBottomViewDelegate {
     func savePDFAction() {
         KMPrint("保存PDF")
-        guard let url = self.presenter.printData.url else { return }
-        let document = CPDFDocument(url: url)
-        NSPanel.savePanel_pdf_success(self.window!, document: document) { result in
-            NSWorkspace.shared.selectFile(result.path, inFileViewerRootedAtPath: "")
-        }
+//        guard let url = self.presenter.printData.url else { return }
+        guard let document = self.tempPDFDocument else { return }
+//        guard let url = self.tempPDFDocument?.documentURL else { return }
+//        let document = CPDFDocument(url: url)
+//        NSPanel.savePanel_pdf_success(self.window!, document: document) { result in
+//            NSWorkspace.shared.selectFile(result.path, inFileViewerRootedAtPath: "")
+//        }
+//        
+        let savePanel = NSSavePanel()
+        savePanel.allowedFileTypes = ["pdf"]
+        savePanel.beginSheetModal(for: NSWindow.currentWindow(), completionHandler: { result in
+            if result != .OK {
+//                completion(result, nil)
+            } else {
+                document.write(to: savePanel.url!)
+                NSWorkspace.shared.selectFile(savePanel.url?.path, inFileViewerRootedAtPath: "")
+//                completion(result, success ? savePanel.url! : nil)
+            }
+        })
     }
     
     func printerAction() {

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.xib

@@ -48,7 +48,7 @@
                     <customView translatesAutoresizingMaskIntoConstraints="NO" id="MIW-E0-38q">
                         <rect key="frame" x="0.0" y="450" width="600" height="50"/>
                         <subviews>
-                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="w7p-YR-VDW">
+                            <textField hidden="YES" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="w7p-YR-VDW">
                                 <rect key="frame" x="14" y="17" width="37" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="hfU-Nk-JkE">
                                     <font key="font" usesAppearanceFont="YES"/>

+ 8 - 30
PDF Office/PDF Master/Class/PDFTools/Print/View/BottomView/KMPrintBottomView.swift

@@ -44,36 +44,14 @@ class KMPrintBottomView: KMBaseXibView {
     override func setup() {
         self.updateButtonState()
         
-//        self.printerButton.wantsLayer = true
-//        self.printerButton.layer?.borderWidth = 1
-//        self.printerButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
-//        self.printerButton.layer?.cornerRadius = 4
-//        self.printerButton.title = NSLocalizedString("Printer", comment: "")
-//        self.printerButton.font = NSFont.SFProTextRegularFont(14)
-//        self.printerButton.contentTintColor = NSColor.km_init(hex: "#252629")
-//        
-//        self.cancelButton.wantsLayer = true
-//        self.cancelButton.layer?.borderWidth = 1
-//        self.cancelButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
-//        self.cancelButton.layer?.cornerRadius = 4
-//        self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
-//        self.cancelButton.font = NSFont.SFProTextRegularFont(14)
-//        self.cancelButton.contentTintColor = NSColor.km_init(hex: "#252629")
-//        
-//        self.savePDFButton.wantsLayer = true
-//        self.savePDFButton.layer?.borderWidth = 1
-//        self.savePDFButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
-//        self.savePDFButton.layer?.cornerRadius = 4
-//        self.savePDFButton.title = NSLocalizedString("Save as PDF", comment: "")
-//        self.savePDFButton.font = NSFont.SFProTextRegularFont(14)
-//        self.savePDFButton.contentTintColor = NSColor.km_init(hex: "#252629")
-//        
-//        self.printButton.wantsLayer = true
-//        self.printButton.layer?.backgroundColor = NSColor.km_init(hex: "#1770F4").cgColor
-//        self.printButton.layer?.cornerRadius = 4
-//        self.printButton.title = NSLocalizedString("Printer", comment: "")
-//        self.printButton.font = NSFont.SFProTextRegularFont(14)
-//        self.printButton.contentTintColor = NSColor.km_init(hex: "#FFFFFF")
+        self.printButton.title = NSLocalizedString("Printer", comment: "")
+        self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
+        self.savePDFButton.title = NSLocalizedString("Save", comment: "")
+         
+        self.posterButton.title = NSLocalizedString("Poster", comment: "")
+        self.bookletButton.title = NSLocalizedString("Booklet", comment: "")
+        self.multipleButton.title = NSLocalizedString("Multiple", comment: "")
+
     }
     
     //刷新界面UI 和 数据

+ 4 - 4
PDF Office/PDF Master/Class/PDFTools/Print/View/Preview/KMPrintPreviewView.swift

@@ -108,7 +108,7 @@ class KMPrintPreviewView: KMBaseXibView {
 //        self.previewContentView.layer?.backgroundColor = NSColor.km_init(hex: "#F7F8FA").cgColor
         
         self.currentPageTextField.textField.font = NSFont.SFProTextRegularFont(12.0)
-        self.currentPageTextField.textField.textColor = NSColor.km_init(hex: "#252629")
+//        self.currentPageTextField.textField.textColor = NSColor.km_init(hex: "#252629")
         self.currentPageTextField.textDidEndEditing = {[unowned self] (string) in
             self.presenter.toPage(index: Int(string) ?? 0)
         }
@@ -125,13 +125,13 @@ class KMPrintPreviewView: KMBaseXibView {
         self.previousButton.layer?.borderWidth = 1
 //        self.previousButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
         self.previousButton.layer?.cornerRadius = 4
-        self.previousButton.image = NSImage(named: "icon_btn_pagination_back_norm")
+//        self.previousButton.image = NSImage(named: "icon_btn_pagination_back_norm")
         
         self.nextButton.wantsLayer = true
         self.nextButton.layer?.borderWidth = 1
 //        self.nextButton.layer?.borderColor = NSColor.km_init(hex: "#DFE1E5").cgColor
         self.nextButton.layer?.cornerRadius = 4
-        self.nextButton.image = NSImage(named: "icon_btn_pagination_lastpage_dis")
+//        self.nextButton.image = NSImage(named: "icon_btn_pagination_lastpage_dis")
     }
     
     func notification() {
@@ -154,7 +154,7 @@ class KMPrintPreviewView: KMBaseXibView {
                 self.currentPageTextField.stringValue = (pageIndex! + 1).description
                 self.pageCountLabel.stringValue = (self.previewView.document?.pageCount.description)!
                 
-                self.titleLabel.stringValue = NSLocalizedString("size", comment: "") + ":" + size.width.description + NSLocalizedString("mm", comment: "") + "*" + String(size.height.description) + NSLocalizedString("mm", comment: "")
+                self.titleLabel.stringValue = NSLocalizedString("Size", comment: "") + ":" + size.width.description + NSLocalizedString("mm", comment: "") + "*" + String(size.height.description) + NSLocalizedString("mm", comment: "")
             }
         }
     }

+ 9 - 5
PDF Office/PDF Master/Class/PDFTools/Print/View/Preview/KMPrintPreviewView.xib

@@ -7,7 +7,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMPrintPreviewView" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMPrintPreviewView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="currentPageTextField" destination="kAa-KE-xvz" id="go0-Ju-aOG"/>
                 <outlet property="nextButton" destination="aL4-Zm-ckR" id="5bn-Qa-tBh"/>
@@ -35,7 +35,7 @@
                                 <pdfView autoresizesSubviews="NO" wantsLayer="YES" displayMode="singlePage" translatesAutoresizingMaskIntoConstraints="NO" id="Sws-Vc-u7D">
                                     <rect key="frame" x="0.0" y="0.0" width="180" height="248"/>
                                 </pdfView>
-                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="1lQ-Db-XbA" customClass="KMPrintPosterPreviewView" customModule="PDF_Master" customModuleProvider="target">
+                                <customView translatesAutoresizingMaskIntoConstraints="NO" id="1lQ-Db-XbA" customClass="KMPrintPosterPreviewView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                     <rect key="frame" x="0.0" y="0.0" width="180" height="248"/>
                                 </customView>
                             </subviews>
@@ -66,7 +66,7 @@
                                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="6T9-7c-n7B">
                                     <rect key="frame" x="56" y="7" width="100" height="40"/>
                                     <subviews>
-                                        <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kAa-KE-xvz" customClass="KMBaseTextField" customModule="PDF_Master" customModuleProvider="target">
+                                        <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kAa-KE-xvz" customClass="KMBaseTextField" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                             <rect key="frame" x="-2" y="12" width="54" height="16"/>
                                             <constraints>
                                                 <constraint firstAttribute="width" constant="50" id="wM0-HX-OL1"/>
@@ -107,7 +107,7 @@
                                 </customView>
                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aL4-Zm-ckR">
                                     <rect key="frame" x="164" y="15" width="24" height="24"/>
-                                    <buttonCell key="cell" type="square" title="-&gt;" bezelStyle="shadowlessSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qlc-in-usF">
+                                    <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSGoRightTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qlc-in-usF">
                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                         <font key="font" metaFont="system"/>
                                     </buttonCell>
@@ -121,7 +121,7 @@
                                 </button>
                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Exe-SJ-Ntq">
                                     <rect key="frame" x="24" y="15" width="24" height="24"/>
-                                    <buttonCell key="cell" type="square" title="&lt;-" bezelStyle="shadowlessSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nbC-RY-oVe">
+                                    <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="NSGoLeftTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="nbC-RY-oVe">
                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                         <font key="font" metaFont="system"/>
                                     </buttonCell>
@@ -165,4 +165,8 @@
             <point key="canvasLocation" x="-183" y="90"/>
         </customView>
     </objects>
+    <resources>
+        <image name="NSGoLeftTemplate" width="128" height="128"/>
+        <image name="NSGoRightTemplate" width="128" height="128"/>
+    </resources>
 </document>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m

@@ -1657,7 +1657,7 @@
 }
 
 - (CGFloat)interiorOpacity {
-    CGFloat opacity = 0;
+    CGFloat opacity = 1;
     //多选注释去拿注释类型的默认值
     if (_annotation && self.annotations.count == 1) {
         if([_annotation isKindOfClass:[CPDFCircleAnnotation class]] ||

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

@@ -2272,7 +2272,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
         NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
         CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
-        CGFloat opacity = [[defaults objectForKey:CFreeTextNoteOpacityKey] floatValue];
+        CGFloat opacity = [[defaults objectForKey:CFreeTextNoteOpacityKey] floatValue] ?:1.0;
 //        CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
 //        defaults.safe_setColor(annotation.color, forKey: CFreeTextNoteColorKey)
 //        defaults.safe_setColor((annotation as! CPDFFreeTextAnnotation).fontColor, forKey: CFreeTextNoteFontColorKey)

+ 4 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -214,9 +214,10 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
             center = [self convertPoint:NSMakePoint(NSMidX([page boundsForBox:[self displayBox]]), NSMidY([page boundsForBox:[self displayBox]])) fromPage:page];
         }
     }
-    
-    CGFloat defaultWidth = 360;
-    CGFloat defaultHeight = 90;
+
+    CGSize imageSize = CGSizeMake(image.size.width * 0.5, image.size.height * 0.5);
+    CGFloat defaultWidth = imageSize.width?:360;
+    CGFloat defaultHeight = imageSize.height?:90;
     NSSize defaultSize = ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
 
     // Convert to "page space".

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarView.swift

@@ -60,7 +60,7 @@ private let KMToolbarItemSpace = 8.0
         _moreButton.target = self
         _moreButton.action = #selector(_moreButtonAction)
         _moreButton.wantsLayer = true
-        _moreButton.layer?.backgroundColor = NSColor(red: 223.0/255.0, green: 225.0/255.0, blue: 229.0/255.0, alpha: 1).cgColor
+        _moreButton.layer?.backgroundColor = NSColor.clear.cgColor
         return _moreButton
     }()
     

+ 1 - 1
PDF Office/PDF Master/Class/Purchase/Category/SKInspectPublicTool.swift

@@ -11,7 +11,7 @@ class SKInspectPublicTool: NSObject {
 
     @objc static func currentisLanguageHans() -> Bool {
         let language = Bundle.main.preferredLocalizations[0]
-        if language == "zh_CN" {
+        if language == "zh_CN" || language == "zh-Hans" {
             return true
         }
         return false

File diff suppressed because it is too large
+ 1113 - 227
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist