From 75c102f30498fac8d6ae14f55dc82e854bf7ee10 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sat, 25 Jun 2016 21:23:35 +0200 Subject: [PATCH] fixed: rtf-producer colortable dead index issue --- AppKit/CPTextView/_CPRTFParser.j | 3 +-- AppKit/CPTextView/_CPRTFProducer.j | 20 +++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/AppKit/CPTextView/_CPRTFParser.j b/AppKit/CPTextView/_CPRTFParser.j index f6f0bac94..ae3a1ff7f 100644 --- a/AppKit/CPTextView/_CPRTFParser.j +++ b/AppKit/CPTextView/_CPRTFParser.j @@ -569,8 +569,7 @@ var kRgsymRtf = { if (_currentRun && fontIndex >= 0 && fontIndex < _fontArray.length) _currentRun.fontName = _fontArray[fontIndex]; - - break; + break; case "fs": // change font size _currentRun.fontSize = parseInt(param) / 2; diff --git a/AppKit/CPTextView/_CPRTFProducer.j b/AppKit/CPTextView/_CPRTFProducer.j index 5ec93381d..f0f9957f1 100644 --- a/AppKit/CPTextView/_CPRTFProducer.j +++ b/AppKit/CPTextView/_CPRTFProducer.j @@ -149,11 +149,10 @@ function _points2twips(a) { return (a) * 20.0; } next, i; - while ((next = [keyEnum nextObject]) != nil) + while ((next = [keyEnum nextObject]) !== nil) { var cn = [colorDict objectForKey:next]; - - [list insertObject:next atIndex:[cn intValue] - 1]; + [list insertObject:[CPColor colorWithCSSString:next] atIndex:[cn intValue]-1]; } result = [CPString stringWithString:@"{\\colortbl;"]; @@ -276,18 +275,13 @@ function _points2twips(a) { return (a) * 20.0; } - (int)numberForColor:(CPColor)color { - var cn, - num = [colorDict objectForKey:color]; + var num = [colorDict objectForKey:[color cssString]]; - if (num === nil) - { - cn = [colorDict count]; - [colorDict setObject:[CPNumber numberWithInt:cn + 1] forKey:color]; - } - else - cn = [num intValue]; + if (!num) + [colorDict setObject:num = [CPNumber numberWithInt:[colorDict count] + 1] + forKey:[color cssString]]; - return cn + 1; + return [num intValue]; } - (CPString)paragraphStyle:(CPParagraphStyle)paraStyle