Revision: 3461
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3461&view=rev
Author:   hofman
Date:     2008-03-11 05:47:15 -0700 (Tue, 11 Mar 2008)

Log Message:
-----------
Make media box r/w through AppleScript. 

Modified Paths:
--------------
    trunk/PDFPage_SKExtensions.h
    trunk/PDFPage_SKExtensions.m
    trunk/Skim.sdef

Modified: trunk/PDFPage_SKExtensions.h
===================================================================
--- trunk/PDFPage_SKExtensions.h        2008-03-11 12:42:19 UTC (rev 3460)
+++ trunk/PDFPage_SKExtensions.h        2008-03-11 12:47:15 UTC (rev 3461)
@@ -73,6 +73,7 @@
 - (NSData *)boundsAsQDRect;
 - (void)setBoundsAsQDRect:(NSData *)inQDBoundsAsData;
 - (NSData *)mediaBoundsAsQDRect;
+- (void)setMediaBoundsAsQDRect:(NSData *)inQDBoundsAsData;
 - (NSData *)contentBoundsAsQDRect;
 - (id)richText;
 - (NSArray *)notes;

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2008-03-11 12:42:19 UTC (rev 3460)
+++ trunk/PDFPage_SKExtensions.m        2008-03-11 12:47:15 UTC (rev 3461)
@@ -395,6 +395,27 @@
     return [NSData dataWithBytes:&qdBounds length:sizeof(Rect)];
 }
 
+- (void)setMediaBoundsAsQDRect:(NSData *)inQDBoundsAsData {
+    if ([inQDBoundsAsData length] == sizeof(Rect)) {
+        NSUndoManager *undoManager = [[self containingDocument] undoManager];
+        [[undoManager prepareWithInvocationTarget:self] 
setMediaBoundsAsQDRect:[self mediaBoundsAsQDRect]];
+        [undoManager setActionName:NSLocalizedString(@"Crop Page", @"Undo 
action name")];
+        // this will dirty the document, even though no saveable change has 
been made
+        // but we cannot undo the document change count because there may be 
real changes to the document in the script
+        
+        const Rect *qdBounds = (const Rect *)[inQDBoundsAsData bytes];
+        NSRect newBounds = NSRectFromRect(*qdBounds);
+        if (NSWidth(newBounds) < 0.0)
+            newBounds.size.width = 0.0;
+        if (NSHeight(newBounds) < 0.0)
+            newBounds.size.height = 0.0;
+        [self setBounds:newBounds forBox:kPDFDisplayBoxMediaBox];
+        
+        [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFDocumentPageBoundsDidChangeNotification 
+                object:[self document] userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:@"crop", @"action", self, @"page", nil]];
+    }
+}
+
 - (NSData *)contentBoundsAsQDRect {
     Rect qdBounds = RectFromNSRect([self foregroundBox]);
     return [NSData dataWithBytes:&qdBounds length:sizeof(Rect)];

Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef     2008-03-11 12:42:19 UTC (rev 3460)
+++ trunk/Skim.sdef     2008-03-11 12:47:15 UTC (rev 3461)
@@ -615,7 +615,7 @@
                 description="The bounding rectangle for the crop box of the 
page (left, top, right, bottom).">
                 <cocoa key="boundsAsQDRect"/>
             </property>
-            <property name="media bounds" code="MBnd" type="rectangle" 
access="r"
+            <property name="media bounds" code="MBnd" type="rectangle"
                 description="The bounding rectangle for the media box of the 
page (left, top, right, bottom).">
                 <cocoa key="mediaBoundsAsQDRect"/>
             </property>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to