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

安全-首页处理密码阻挡

tangchao 2 лет назад
Родитель
Сommit
963ddd1bfc

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 16 - 0
PDF Office/PDF Office.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -164,5 +164,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "9356D276-0C46-4D0D-8E18-74D0B7AA7237"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "257"
+            endingLineNumber = "257"
+            landmarkName = "setDocument"
+            landmarkType = "24">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 8 - 5
PDF Office/PDF Office/Class/PDFTools/Secure/Controller/KMSecureEncryptWindowController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -24,11 +24,11 @@
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
             <rect key="contentRect" x="196" y="240" width="432" height="314"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
+            <rect key="screenRect" x="0.0" y="0.0" width="3008" height="1667"/>
             <value key="minSize" type="size" width="432" height="314"/>
             <value key="maxSize" type="size" width="432" height="314"/>
-            <view key="contentView" misplaced="YES" id="se5-gp-TjO">
-                <rect key="frame" x="0.0" y="0.0" width="432" height="456"/>
+            <view key="contentView" id="se5-gp-TjO">
+                <rect key="frame" x="0.0" y="0.0" width="432" height="314"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="80r-fS-f21" userLabel="titleBarBox">
@@ -152,6 +152,9 @@
                                     <buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="JNe-Yo-ygc">
                                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                         <font key="font" metaFont="system"/>
+                                        <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
                                     </buttonCell>
                                 </button>
                                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GPY-D5-rTa">

+ 16 - 10
PDF Office/PDF Office/Class/PDFTools/Secure/View/KMSecureEncryptPasswordCellView.swift

@@ -15,7 +15,7 @@ class KMSecureEncryptPasswordCellView: NSTableCellView {
     private var passwordView: KMSecureTextFiled = KMSecureTextFiled()
     private var openOrClosePasswordButton: NSButton!
     
-    var kmEnabled: Bool!
+    var kmEnabled: Bool = false
     
     var itemClick: KMSecureEncryptPasswordCellViewItemClick!
     var valueChange: KMSecureEncryptPasswordCellViewValueChange!
@@ -27,6 +27,20 @@ class KMSecureEncryptPasswordCellView: NSTableCellView {
     override init(frame frameRect: NSRect) {
         super.init(frame: frameRect)
         
+        self.initSubViews()
+    }
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+        
+        self.initSubViews()
+    }
+    
+    override var isFlipped: Bool {
+        return true
+    }
+    
+    func initSubViews() {
         addSubview(checkBox)
         addSubview(passwordView)
         
@@ -64,14 +78,6 @@ class KMSecureEncryptPasswordCellView: NSTableCellView {
         }
     }
     
-    required init?(coder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    override var isFlipped: Bool {
-        return true
-    }
-    
     override func layout() {
         super.layout()
         
@@ -79,7 +85,7 @@ class KMSecureEncryptPasswordCellView: NSTableCellView {
         checkBox.frame = NSMakeRect(8, 6, width-12*2, 22)
         
         let passwordY: CGFloat = checkBox.frame.maxY + 8
-        passwordView.frame = NSMakeRect(8, passwordY, width-8-16, 32)
+        passwordView.frame = NSMakeRect(8, passwordY, width-8-8, 32)
     }
 
     @objc func checkBoxAction(sender: NSButton) {

+ 9 - 9
PDF Office/PDF Office/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift

@@ -63,11 +63,11 @@ private var passwordInputWindow: KMPasswordInputWindow?
             
             let titleLabel = self.myTitleLabel
             if (titleLabel != nil) {
-                if (newValue == .open) {
-                    titleLabel!.stringValue = NSLocalizedString("Open Password", comment: "")
-                } else {
+//                if (newValue == .open) {
+//                    titleLabel!.stringValue = NSLocalizedString("Open Password", comment: "")
+//                } else {
                     titleLabel!.stringValue = NSLocalizedString("Permission Password", comment: "")
-                }
+//                }
             }
 
             var despLabel = self.myDespLabel
@@ -83,13 +83,13 @@ private var passwordInputWindow: KMPasswordInputWindow?
                 let ps = NSMutableParagraphStyle()
                 ps.lineSpacing = 5
 //                ps.lineBreakMode = .byTruncatingTail
-                if (newValue == .open) {
-                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter a Document Open Password.", comment: ""))"
-                    despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegular(14), .paragraphStyle : ps])
-                } else {
+//                if (newValue == .open) {
+//                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter a Document Open Password.", comment: ""))"
+//                    despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegular(14), .paragraphStyle : ps])
+//                } else {
                     despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter the password to unlock it.", comment: ""))"
                     despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegular(14), .paragraphStyle : ps])
-                }
+//                }
             }
         }
     }

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

@@ -1861,17 +1861,17 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                         return
                     }
 
-                    self!.listView.document.unlock(withPassword: password)
-                    let result = self?.listView.document.writeDecrypt(to: self?.listView.document.documentURL)
+                    self?.listView.document.unlock(withPassword: password)
+                    let result: Bool? = self?.listView.document.writeDecrypt(to: self?.listView.document.documentURL)
 
                     let tip = KMRemovePasswordResultTipView()
-                    if result! {
+                    if (result != nil && result!) {
                         tip.result = .success
                     } else {
 
                         tip.result = .failure
                     }
-                    tip.showInView(superView: self!.listView.superview!)
+                    tip.showInView(superView: (self?.listView.superview)!)
                 }
                 return
             }

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

@@ -104,6 +104,28 @@ import Cocoa
         self.toolbarController.listView = self.listView
     }
     
+//    override func viewDidAppear() {
+//        super.viewDidAppear()
+//
+//        if (self.document == nil) {
+//            return
+//        }
+//        if (self.document!.isLocked == false) {
+//            return
+//        }
+//        if (self.view.window == nil) {
+//            return
+//        }
+//        KMPasswordInputWindow.openWindow(window: self.view.window!, url: self.document!.documentURL) { result , password in
+//            if (result == .cancel) {
+//                self.browserWindowController?.browser.closeTab()
+//                return
+//            }
+//            self.document?.unlock(withPassword: password)
+//            self.listView.document = self.document
+//        }
+//    }
+    
     override func viewDidLoad() {
         super.viewDidLoad()