PDFViewer/pdfviewer/PDFViewer.m
changeset 1 58bbaa38119e
parent 0 c344b61ddaf6
child 2 fd23014eaa85
equal deleted inserted replaced
0:c344b61ddaf6 1:58bbaa38119e
     8 
     8 
     9 #import "PDFViewer.h"
     9 #import "PDFViewer.h"
    10 
    10 
    11 @implementation PDFViewer
    11 @implementation PDFViewer
    12 
    12 
    13 -(void) awakeFromNib {
    13 - (void)awakeFromNib {
    14     synthesizer = [[NSSpeechSynthesizer alloc] initWithVoice:[NSSpeechSynthesizer defaultVoice]];
    14   synthesizer = [[NSSpeechSynthesizer alloc] initWithVoice:[NSSpeechSynthesizer defaultVoice]];
    15 }
    15 }
    16 
    16 
    17 -(NSMutableString*) getTexts {
    17 - (NSMutableString *)getTexts {
    18     NSMutableString *strings = [[NSMutableString alloc] init];
    18   NSMutableString *strings = [[NSMutableString alloc] init];
    19     NSUInteger nOps = [[self document] pageCount];
    19   NSUInteger nOps = [[self document] pageCount];
    20     
    20 
    21     [strings appendString: [NSString stringWithFormat: @"Genosse Parteisekretär, das Dokument hat %lu Seiten", nOps]];
    21   [strings appendString:[NSString stringWithFormat:@"Genosse Parteisekretär, das Dokument hat %lu Seiten", nOps]];
    22     
    22 
    23     for (int pages = 0; pages < nOps; pages++) {
    23   for (int pages = 0; pages < nOps; pages++) {
    24         PDFPage *page = [[self document] pageAtIndex: pages];
    24     PDFPage *page = [[self document] pageAtIndex:pages];
    25         [strings appendString: [self replaceString: [page string]]];
    25     [strings appendString:[self replaceString:[page string]]];
    26     }
    26   }
    27     
    27 
    28     return strings;
    28   return strings;
    29 }
    29 }
    30 
    30 
    31 -(void) speak: (NSMutableString*) texts {
    31 - (void)speak:(NSMutableString *)texts {
    32     // Die Audioausgabe muss immer gestoppt werden, bevor Sie erneut gestartet werden darf!
    32   // Die Audioausgabe muss immer gestoppt werden, bevor Sie erneut gestartet
    33     [self stopSpeaking];
    33   // werden darf!
    34     
    34   [self stopSpeaking];
    35     [synthesizer startSpeakingString:texts];    
    35 
       
    36   [synthesizer startSpeakingString:texts];
    36 }
    37 }
    37 
    38 
    38 -(void) stopSpeaking {
    39 - (void)stopSpeaking {
    39     if ([synthesizer isSpeaking]) {
    40   if ([synthesizer isSpeaking]) {
    40         [synthesizer stopSpeaking];
    41     [synthesizer stopSpeaking];
    41     }
    42   }
    42 }
    43 }
    43 
    44 
    44 -(NSString*) replaceString: (NSString*) inputStr {
    45 - (NSString *)replaceString:(NSString *)inputStr {
    45     NSDictionary *replacements = @{
    46   NSDictionary *replacements = @{
    46        @"SED": @"S.E.D.",
    47     @"SED" : @"S.E.D.",
    47        @"DDR": @"D.D.R.",
    48     @"DDR" : @"D.D.R.",
    48        @" IM ": @" I.M. ",
    49     @" IM " : @" I.M. ",
    49     };
    50   };
    50     
    51 
    51     for (id key in replacements) {
    52   for (id key in replacements) {
    52         inputStr = [inputStr stringByReplacingOccurrencesOfString:key withString: replacements[key]];
    53     inputStr = [inputStr stringByReplacingOccurrencesOfString:key withString:replacements[key]];
    53     }
    54   }
    54     
    55 
    55     return inputStr;
    56   return inputStr;
    56 }
    57 }
    57 
    58 
    58 @end
    59 @end