Procházet zdrojové kódy

【快照】toolBar补充入口

tangchao před 1 rokem
rodič
revize
29ffde2d23

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

@@ -356,5 +356,21 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "F76F12E2-82CF-4A15-B64B-73D5CBA94A5C"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2330"
+            endingLineNumber = "2330"
+            landmarkName = "pdfListView(_:showSnapshotAtPageNumber:for:scaleFactor:autoFits:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.h

@@ -271,4 +271,6 @@ typedef NS_ENUM(NSUInteger, KMPDFViewActiveFormsType) {
 
 - (void)PDFListViewAnnotationAttributeHasChange:(CPDFListView *)pdfListView withAnnotation:(CPDFAnnotation *)annotation;
 
+- (void)PDFListView:(CPDFListView *)sender showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
+
 @end

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.h

@@ -35,6 +35,8 @@
 - (BOOL)canCopy;
 - (BOOL)canPaste;
 
+- (void)takeSnapshot:(id)sender;
+
 @end
 
 @interface CPDFView (KMExtension)

+ 40 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -16,6 +16,8 @@
 #import <objc/runtime.h>
 #import <PDF_Master-Swift.h>
 
+CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
+
 @implementation CPDFListView (Extension)
 
 - (CPDFAnnotation *)addPDFSelection:(CPDFSelection *)currentSelection annotationTyoe:(CAnnotationType)annotationType {
@@ -452,6 +454,44 @@
     return NO;
 }
 
+#pragma mark Snapshots
+
+- (void)takeSnapshot:(id)sender {
+    NSPoint point;
+    CPDFPage *page = nil;
+    NSRect rect = NSZeroRect;
+    BOOL autoFits = NO;
+    
+    if (self.toolMode == CSelectToolMode && NSIsEmptyRect(self.selectionRect) == NO && self.selectionPageIndex != NSNotFound) {
+        page = [self currentSelectionPage];
+        rect = NSIntersectionRect(self.selectionRect, [page boundsForBox:CPDFDisplayCropBox]);
+        autoFits = YES;
+    }
+    if (NSIsEmptyRect(rect)) {
+        // the represented object should be the location for the menu event
+        point = [sender representedObject] ? [[sender representedObject] pointValue] : [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil];
+        page = [self pageForPoint:point nearest:NO];
+        if (page == nil) {
+            // Get the center
+            NSRect viewFrame = [self frame];
+//            point = KMCenterPoint(viewFrame);
+            point = NSMakePoint(NSMidX(viewFrame), NSMidY(viewFrame));
+            page = [self pageForPoint:point nearest:YES];
+        }
+        
+        point = [self convertPoint:point toPage:page];
+        
+        rect = [self convertRect:[page boundsForBox:CPDFDisplayCropBox] fromPage:page];
+        rect.origin.y = point.y - 0.5 * DEFAULT_SNAPSHOT_HEIGHT;
+        rect.size.height = DEFAULT_SNAPSHOT_HEIGHT;
+        
+        rect = [self convertRect:rect toPage:page];
+    }
+    
+    if ([[self pdfListViewDelegate] respondsToSelector:@selector(PDFListView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
+        [[self pdfListViewDelegate] PDFListView:self showSnapshotAtPageNumber:[page pageIndex] forRect:rect scaleFactor:[self scaleFactor] autoFits:autoFits];
+}
+
 @end
 
 @implementation CPDFView (KMExtension)

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

@@ -3597,7 +3597,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 } else if toolbarItem.itemIdentifier == KMToolbarViewSettingIdentifier {
                     Swift.debugPrint("KMToolbarViewSettingIdentifier ...")
                 } else if toolbarItem.itemIdentifier == KMToolbarSnapshotIdentifier {
-                    Swift.debugPrint("KMToolbarSnapshotIdentifier ...")
+                    self.listView.takeSnapshot(nil)
                 } else if toolbarItem.itemIdentifier == KMToolbarTTSIdentifier {
                     Swift.debugPrint("KMToolbarTTSIdentifier ...")
                 } else if toolbarItem.itemIdentifier == KMToolbarConversionOCRIdentifier {

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

@@ -2323,7 +2323,10 @@ import Cocoa
                 self.topTipBox.contentView?.addSubview(view!)
             }
         }
-
+    }
+    
+    func pdfListView(_ sender: CPDFListView!, showSnapshotAtPageNumber pageNum: Int, for rect: NSRect, scaleFactor: CGFloat, autoFits: Bool) {
+        
     }
 }