Browse Source

【综合】自定义图章大小&鼠标样式大小兼容统一, 文字控件大小初始化调整

niehaoyu 8 months ago
parent
commit
dfe1f361f1

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSCursor+PDFListView.m

@@ -617,7 +617,7 @@ static NSCursor *textSelfSignCursor = nil;
             NSImage *cursorImage = [tampSignatureObject stampPreImage];
             CGSize size = cursorImage.size;
             CGFloat newWidth = 140.0, newHeight = 140.0;
-            if (size.width > 140 || size.height > 140) {
+            if (size.width > 200.0 || size.height > 200.0) {
                 if (size.width > size.height) {
                     newHeight = 140/size.width * size.height;
                 } else {

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

@@ -2587,7 +2587,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 ((CPDFFreeTextAnnotation *)annotation).color = NSColor.whiteColor;
                 
                 if (toolbarType == CSToolbarTypeText) {
-                    
+                    originalBounds = [annotation bounds];
+                    NSRect newBounds = [self getValidFreetText:((CPDFFreeTextAnnotation *)annotation) rect:originalBounds];
+                    originalBounds.size.width = newBounds.size.width;
+                    originalBounds.size.height = newBounds.size.height;
+                    annotation.bounds = originalBounds;
                 } else if (toolbarType == CSToolbarTypeDateText) {
                     ((CPDFFreeTextAnnotation *)annotation).contents = self.customStampTextValue;
                     ((CPDFFreeTextAnnotation *)annotation).customStampAnnotationType = @"dateText";
@@ -3899,7 +3903,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     [style setAlignment:freeTextAn.alignment];
     [dictionary setObject:style forKey:NSParagraphStyleAttributeName];
     
-    CGSize textViewSize = [freeTextAn.contents?:@"" boundingRectWithSize:CGSizeMake(rect.size.width, MAXFLOAT)
+    CGSize textViewSize = [freeTextAn.contents?:@" " boundingRectWithSize:CGSizeMake(rect.size.width, MAXFLOAT)
                                                                  options:NSStringDrawingUsesLineFragmentOrigin
                                                               attributes:dictionary].size;
     

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

@@ -78,6 +78,25 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
     if (CPDFStampTypeImage == self.stampObject.stampCategoryType) {
         NSImage * image = [[NSImage alloc] initWithContentsOfFile:self.stampObject.imagePath];
         annotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:image];
+        
+        CGFloat newWidth = image.size.width;
+        CGFloat newHeight = image.size.height;
+        CGSize size = CGSizeMake(360, 360);
+        if (bounds.size.width > newWidth || bounds.size.height > newWidth) {
+            if (size.width > size.height) {
+                newHeight = newHeight/size.width * size.height;
+            } else {
+                newWidth = newWidth/size.height * size.width;
+            }
+            bounds.size = CGSizeMake(newWidth, newHeight);
+        }
+        
+//        if (bounds.size.width > image.size.width &&
+//            bounds.size.height > image.size.height) {
+//            bounds.size.width = image.size.width;
+//            bounds.size.height = image.size.height;
+//        }
+        bounds = CPDFListViewRectFromCenterAndSize(pagePoint, bounds.size);
         annotation.bounds = bounds;
     } else if(self.stampObject.isSignatureAnnotation) {
         NSImage * image = self.stampObject.signatureImage;