Revision: 14931
http://sourceforge.net/p/skim-app/code/14931
Author: hofman
Date: 2025-03-02 09:09:47 +0000 (Sun, 02 Mar 2025)
Log Message:
-----------
don't use macros, most cases are first so need no check
Modified Paths:
--------------
trunk/PDFSelection_SKExtensions.m
Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m 2025-03-01 18:15:29 UTC (rev 14930)
+++ trunk/PDFSelection_SKExtensions.m 2025-03-02 09:09:47 UTC (rev 14931)
@@ -268,9 +268,6 @@
#define RICH_TEXT_CLASSNAME @"rich text"
#define CHARACTERS_KEY @"characters"
-#define SUB_TEXT_STORAGES (subTextStorages ?: (subTextStorages = [textStorage
valueForKey:key]))
-#define SUB_TEXT_STORAGES_COUNT ([key isEqualToString:CHARACTERS_KEY] ?
[textStorage length] : [SUB_TEXT_STORAGES count])
-
static NSArray
*characterRangesAndContainersForSpecifier(NSScriptObjectSpecifier *specifier,
BOOL continuous, BOOL continuousContainers) {
if ([specifier isKindOfClass:[NSScriptObjectSpecifier class]] == NO)
return nil;
@@ -311,7 +308,12 @@
if ([specifier isKindOfClass:[NSPropertySpecifier class]]) {
// this should be the full range of characters, words, or
paragraphs
NSRange range = NSMakeRange(0, 0);
- range.length = SUB_TEXT_STORAGES_COUNT;
+ if ([key isEqualToString:CHARACTERS_KEY]) {
+ range.length = [textStorage length];
+ } else {
+ subTextStorages = [textStorage valueForKey:key];
+ range.length = [subTextStorages count];
+ }
if (range.length)
[tmpRanges addPointer:&range];
} else if ([specifier isKindOfClass:[NSRangeSpecifier class]])
{
@@ -331,8 +333,11 @@
count = -2;
indices = [endSpec
indicesOfObjectsByEvaluatingWithContainer:textStorage count:&count];
endIndex = count > 0 ? indices[count - 1] : -1;
+ } else if ([key isEqualToString:CHARACTERS_KEY]) {
+ endIndex = [textStorage length] - 1;
} else {
- endIndex = SUB_TEXT_STORAGES_COUNT - 1;
+ subTextStorages = [textStorage valueForKey:key];
+ endIndex = [subTextStorages count] - 1;
}
if (startIndex >= 0 && endIndex >= 0) {
NSRange range = NSMakeRange(MIN(startIndex,
endIndex), MAX(startIndex, endIndex) + 1 - MIN(startIndex, endIndex));
@@ -344,7 +349,12 @@
indices = [specifier
indicesOfObjectsByEvaluatingWithContainer:textStorage count:&count];
NSRange range = NSMakeRange(0, 0);
if (count == -1) {
- range.length = SUB_TEXT_STORAGES_COUNT;
+ if ([key isEqualToString:CHARACTERS_KEY]) {
+ range.length = [textStorage length];
+ } else {
+ subTextStorages = [textStorage valueForKey:key];
+ range.length = [subTextStorages count];
+ }
} else if (count > 0) {
for (i = 0; i < count; i++) {
NSUInteger idx = indices[i];
@@ -382,7 +392,9 @@
}
} else {
// translate from subtext ranges to character ranges
- if ([SUB_TEXT_STORAGES count]) {
+ if (subTextStorages == nil)
+ subTextStorages = [textStorage valueForKey:key];
+ if ([subTextStorages count]) {
NSString *string = nil;
NSArray *substrings = nil;
// The private subclass NSSubTextStorage has a -range
method
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit