mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 13:50:37 +00:00
Fixed problem when fixing up paragraph style attributes ... would get
into an infinite loop if no style was set at the beginning of paragraph git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11596 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7239377230
commit
8abb202934
1 changed files with 41 additions and 13 deletions
|
@ -890,28 +890,56 @@ documentAttributes: (NSDictionary **)dict
|
||||||
NSRange found;
|
NSRange found;
|
||||||
unsigned end;
|
unsigned end;
|
||||||
|
|
||||||
// Extend loc to take in entire paragraph if necessary.
|
/* Extend loc to take in entire paragraph if necessary. */
|
||||||
r = [str lineRangeForRange: NSMakeRange (loc, 1)];
|
r = [str lineRangeForRange: NSMakeRange (loc, 1)];
|
||||||
end = NSMaxRange (r);
|
end = NSMaxRange (r);
|
||||||
|
|
||||||
// get the style in effect at the paragraph start.
|
/* Get the style in effect at the paragraph start. */
|
||||||
style = [self attribute: NSParagraphStyleAttributeName
|
style = [self attribute: NSParagraphStyleAttributeName
|
||||||
atIndex: r.location
|
atIndex: r.location
|
||||||
longestEffectiveRange: &found
|
longestEffectiveRange: &found
|
||||||
inRange: r];
|
inRange: r];
|
||||||
|
if (style == nil)
|
||||||
if (style != nil && NSMaxRange (found) < end)
|
{
|
||||||
{
|
/* No style found at the beginning of paragraph. found is
|
||||||
// Styles differ - add the old style to the remainder of the range.
|
the range without the style set. */
|
||||||
found.location = NSMaxRange (found);
|
if ((NSMaxRange (found) + 1) < end)
|
||||||
found.length = end - found.location;
|
{
|
||||||
[self addAttribute: NSParagraphStyleAttributeName
|
/* This skips the range with style not set, and attempts
|
||||||
value: style
|
again to set the style for the whole paragraph taking
|
||||||
range: found];
|
the style at the first location with a style set. */
|
||||||
loc = end;
|
loc = NSMaxRange (found) + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* All the paragraph without a style ... too bad, fixup
|
||||||
|
the whole paragraph using the default paragraph style. */
|
||||||
|
[self addAttribute: NSParagraphStyleAttributeName
|
||||||
|
value: [NSParagraphStyle defaultParagraphStyle]
|
||||||
|
range: r];
|
||||||
|
|
||||||
|
/* Move on to the next paragraph. */
|
||||||
|
loc = end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
loc = NSMaxRange (found);
|
{
|
||||||
|
if (NSMaxRange (found) < end)
|
||||||
|
{
|
||||||
|
/* Not the whole paragraph has the same style ... add
|
||||||
|
the style found at the beginning to the remainder of
|
||||||
|
the paragraph. */
|
||||||
|
found.location = NSMaxRange (found);
|
||||||
|
found.length = end - found.location;
|
||||||
|
[self addAttribute: NSParagraphStyleAttributeName
|
||||||
|
value: style
|
||||||
|
range: found];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move on to the next paragraph. */
|
||||||
|
loc = end;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue