瀏覽代碼

综合-页面编辑,处理旋转

tangchao 2 年之前
父節點
當前提交
6f73408eb1

二進制
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


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

@@ -20,5 +20,37 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "3213D609-8BBB-4021-A596-B13EE4D639A8"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1076"
+            endingLineNumber = "1076"
+            landmarkName = "leftRotatePageItemAction(menu:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "9CC6BDF7-B9D2-4990-9E77-B9DCEF7080FF"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1072"
+            endingLineNumber = "1072"
+            landmarkName = "rotatePageItemAction(menu:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 12 - 2
PDF Office/PDF Office/Class/Merge/View/KMPDFThumbnialPageView.swift

@@ -28,8 +28,18 @@ class KMPDFThumbnialPageLayer: CATiledLayer {
         var bounds = page.bounds
         let transform = page.transform()
         bounds = bounds.applying(transform);
-        ctx.scaleBy(x: self.bounds.size.width / bounds.size.width,
-                    y: self.bounds.size.height / bounds.size.height);
+        
+        let viewWidth: CGFloat = NSWidth(self.bounds)
+        let viewHeight: CGFloat = NSHeight(self.bounds)
+        
+        if (page.rotation == -90 || page.rotation == -270) {
+            let height = bounds.size.height
+            bounds.size.height = bounds.size.width
+            bounds.size.width = height
+        }
+        
+        ctx.scaleBy(x: viewWidth / bounds.size.width,
+                    y: viewHeight / bounds.size.height);
         page.drawEdit(with: .cropBox, to: ctx)
         ctx.restoreGState();
     }

+ 4 - 4
PDF Office/PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -418,10 +418,10 @@ class KMPDFEditViewController: NSViewController {
             return
         }
         
-        for i in 0 ..< (self.listView?.document.pageCount)!-1 {
+        for i in 0 ..< (self.listView?.document.pageCount)! {
             if (indexs.contains(IndexSet.Element(i))) {
                 var page: CPDFPage = (self.listView?.document.page(at: i))!
-                page.rotation = page.rotation - 90
+                page.rotation = (page.rotation % 360) - 90
             }
         }
         
@@ -439,10 +439,10 @@ class KMPDFEditViewController: NSViewController {
             return
         }
         
-        for i in 0 ..< (self.listView?.document.pageCount)!-1 {
+        for i in 0 ..< (self.listView?.document.pageCount)! {
             if (indexs.contains(IndexSet.Element(i))) {
                 var page: CPDFPage = (self.listView?.document.page(at: i))!
-                page.rotation = page.rotation + 90
+                page.rotation = (page.rotation % 360) + 90
             }
         }
         

+ 25 - 1
PDF Office/PDF Office/Class/PDFTools/PageEdit/View/KMPageEditThumbnailItem.swift

@@ -76,6 +76,10 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
         self.backgroundView.layer?.borderWidth = 1.0
         self.isSelected = false
         
+        self.pageView.wantsLayer = true
+//        self.pageView.layer?.borderWidth = 1
+//        self.pageView.layer?.borderColor = NSColor.red.cgColor
+        
         self.pageTextLabel.font = NSFont.SFProTextRegular(14)
         self.pageTextLabel.textColor = NSColor.titleColor()
         self.pageSizeTextLabel.font = NSFont.SFProTextRegular(14)
@@ -173,6 +177,18 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
          if (self.thumbnailView.isShowPageSize == false) {
             size = NSMakeSize(backgroundViewW-32, backgroundViewH-72)
          }
+
+         if (page.rotation == -90 || page.rotation == -270) {
+             let height = bounds.size.height
+             bounds.size.height = bounds.size.width
+             bounds.size.width = height
+         }
+         
+         if (page.rotation == -90 || page.rotation == -270) {
+             let height = size.height
+             size.height = size.width
+             size.width = height
+         }
          
          if bounds.size.width > bounds.size.height {
              if (bounds.size.width > 0) {
@@ -216,7 +232,15 @@ class KMPageEditThumbnailItem: NSCollectionViewItem {
          let pageBoxH: CGFloat = viewHeight-pageBoxY-8
          self.pageBox.frame = NSMakeRect(margin, pageBoxY, pageBoxW, pageBoxH)
          
-         let pageX: CGFloat = (NSWidth(self.pageBox.frame)-size.width)*0.5
+         var pageX: CGFloat = (NSWidth(self.pageBox.frame)-size.width)*0.5
+         if (pageX < 0) {
+             let tempWidth = size.width + pageX * 2
+             let scale = tempWidth / size.width
+             size.width = size.width * scale
+             size.height = size.height * scale
+             
+             pageX = 0
+         }
          let pageY: CGFloat = (NSHeight(self.pageBox.frame)-size.height)*0.5
          self.pageView.frame = NSMakeRect(pageX, pageY, size.width, size.height)
      }