Revision: 4871
http://skim-app.svn.sourceforge.net/skim-app/?rev=4871&view=rev
Author: hofman
Date: 2008-10-26 14:52:25 +0000 (Sun, 26 Oct 2008)
Log Message:
-----------
non-undoable variant of add/remove note to/from pdfview
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKPDFDocument.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-10-26 11:11:49 UTC (rev 4870)
+++ trunk/SKMainWindowController.m 2008-10-26 14:52:25 UTC (rev 4871)
@@ -810,7 +810,6 @@
PDFAnnotation *annotation;
NSDictionary *dict;
PDFDocument *pdfDoc = [pdfView document];
- NSMutableArray *observedNotes = [self
mutableArrayValueForKey:SKMainWindowNotesKey];
// create new annotations from the dictionary and add them to their page
and to the document
while (dict = [e nextObject]) {
@@ -821,15 +820,7 @@
else if (pageIndex >= [pdfDoc pageCount])
pageIndex = [pdfDoc pageCount] - 1;
PDFPage *page = [pdfDoc pageAtIndex:pageIndex];
- if (undoable) {
- [pdfView addAnnotation:annotation toPage:page];
- } else {
- [annotation setShouldDisplay:[pdfView hideNotes] == NO];
- [annotation setShouldPrint:[pdfView hideNotes] == NO];
- [page addAnnotation:annotation];
- [pdfView setNeedsDisplayForAnnotation:annotation];
- [observedNotes addObject:annotation];
- }
+ [pdfView addAnnotation:annotation toPage:page undoable:undoable];
[annotation release];
}
}
@@ -848,18 +839,9 @@
// remove the current annotations
[pdfView setActiveAnnotation:nil];
- while (annotation = [e nextObject]) {
- if (undoable) {
- [pdfView removeAnnotation:annotation];
- } else {
- [pdfView setNeedsDisplayForAnnotation:annotation];
- [[annotation page] removeAnnotation:annotation];
- }
- }
+ while (annotation = [e nextObject])
+ [pdfView removeAnnotation:annotation undoable:undoable];
- if (undoable == NO)
- [self removeAllObjectsFromNotes];
-
[self addAnnotationsFromDictionaries:noteDicts undoable:undoable];
}
Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m 2008-10-26 11:11:49 UTC (rev 4870)
+++ trunk/SKPDFDocument.m 2008-10-26 14:52:25 UTC (rev 4871)
@@ -922,6 +922,8 @@
[self setPDFDataUndoable:[pdfDoc dataRepresentation]];
[pdfDoc release];
+
+ [[self undoManager] setActionName:NSLocalizedString(@"Convert Notes",
@"Undo action name")];
}
[[self progressController] endSheet];
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2008-10-26 11:11:49 UTC (rev 4870)
+++ trunk/SKPDFView.h 2008-10-26 14:52:25 UTC (rev 4871)
@@ -184,9 +184,11 @@
- (void)addAnnotation:(id)sender;
- (void)addAnnotationWithType:(SKNoteType)annotationType;
- (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page;
+- (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page
undoable:(BOOL)undoable;
- (void)removeActiveAnnotation:(id)sender;
- (void)removeThisAnnotation:(id)sender;
- (void)removeAnnotation:(PDFAnnotation *)annotation;
+- (void)removeAnnotation:(PDFAnnotation *)annotation undoable:(BOOL)undoable;
- (void)editActiveAnnotation:(id)sender;
- (void)editThisAnnotation:(id)sender;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-10-26 11:11:49 UTC (rev 4870)
+++ trunk/SKPDFView.m 2008-10-26 14:52:25 UTC (rev 4871)
@@ -2001,7 +2001,12 @@
}
- (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page {
- [[[self undoManager] prepareWithInvocationTarget:self]
removeAnnotation:annotation];
+ [self addAnnotation:annotation toPage:page undoable:YES];
+}
+
+- (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page
undoable:(BOOL)undoable {
+ if (undoable)
+ [[[self undoManager] prepareWithInvocationTarget:self]
removeAnnotation:annotation];
[annotation setShouldDisplay:hideNotes == NO];
[annotation setShouldPrint:hideNotes == NO];
[page addAnnotation:annotation];
@@ -2015,8 +2020,6 @@
- (void)removeActiveAnnotation:(id)sender{
if ([activeAnnotation isSkimNote]) {
[self removeAnnotation:activeAnnotation];
- [accessibilityChildren release];
- accessibilityChildren = nil;
[[self undoManager] setActionName:NSLocalizedString(@"Remove Note",
@"Undo action name")];
}
}
@@ -2026,28 +2029,29 @@
if (annotation) {
[self removeAnnotation:annotation];
- [accessibilityChildren release];
- accessibilityChildren = nil;
[[self undoManager] setActionName:NSLocalizedString(@"Remove Note",
@"Undo action name")];
}
}
-- (void)removeAnnotation:(PDFAnnotation *)annotation{
+- (void)removeAnnotation:(PDFAnnotation *)annotation {
+ [self removeAnnotation:annotation undoable:YES];
+}
+
+- (void)removeAnnotation:(PDFAnnotation *)annotation undoable:(BOOL)undoable {
PDFAnnotation *wasAnnotation = [annotation retain];
PDFPage *page = [wasAnnotation page];
BOOL wasNote = [[wasAnnotation type] isEqualToString:SKNNoteString];
- [[[self undoManager] prepareWithInvocationTarget:self]
addAnnotation:wasAnnotation toPage:page];
- [[self undoManager] setActionName:NSLocalizedString(@"Remove Note", @"Undo
action name")];
-
+ if (undoable)
+ [[[self undoManager] prepareWithInvocationTarget:self]
addAnnotation:wasAnnotation toPage:page];
if ([self isEditing] && activeAnnotation == annotation)
[self endAnnotationEdit:self];
if (activeAnnotation == annotation)
[self setActiveAnnotation:nil];
[self setNeedsDisplayForAnnotation:wasAnnotation];
[page removeAnnotation:wasAnnotation];
- if (accessibilityChildren)
- [accessibilityChildren removeObject:[SKAccessibilityProxyFauxUIElement
elementWithObject:wasAnnotation parent:[self documentView]]];
+ [accessibilityChildren release];
+ accessibilityChildren = nil;
if (wasNote)
[self resetPDFToolTipRects];
[[NSNotificationCenter defaultCenter]
postNotificationName:SKPDFViewDidRemoveAnnotationNotification object:self
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit