As a PS, if formatting is an issue, and the parent format differs from the child format, you can choose between copying the formatting of the parent row to the prefix for the child, or preserving the formatting of the child.
Whpalmer4 's script already works very well for the former option. (A bold row with italic children will confer a bold prefix on each child, preserving the italic formatting of their main text).
If, however, you wanted the children to simply inherit the prefix text from the parent row, preserving their own formatting for prefix as well as main text, you could try the following variant on whpalmer's script:
Code:
-- Variant in which both prefix and main text of each child row preserve child row formatting
-- (For cases where parent and child row formatting differ)
tell application id "com.omnigroup.OmniOutlinerPro3"
tell front document
set refSeldParents to (a reference to (selected rows where its children is not children of its children))
if ((count of refSeldParents) < 1) then
display dialog "You need to select at least one parent row to use this script." buttons "Cancel" default button "Cancel"
end if
repeat with oRow in refSeldParents
set strTopic to (topic of oRow as string) & ": "
set lngChars to length of strTopic
-- Duplicate the parent text as a prefix for first child
-- (character by character retaining child formatting)
set refChiln to children of oRow
set oChild to first item of refChiln
set refChildTopic to (a reference to topic of oChild)
if refChildTopic does not start with strTopic then
set refFirst to (a reference to first character of refChildTopic)
repeat with iChar from lngChars to 1 by -1
duplicate refFirst to before refFirst
set text of refFirst to character iChar of strTopic
end repeat
end if
-- Now duplicate the prefix of the first child to the start of any siblings
-- (a bit faster)
set lngChildren to count of refChiln
if lngChildren > 1 then
set refTemplate to (a reference to characters 1 thru lngChars of refChildTopic)
repeat with iSibling from 2 to lngChildren
set refSibTopic to (a reference to topic of item iSibling of refChiln)
if refSibTopic does not start with strTopic then ¬
duplicate refTemplate to before first character of refSibTopic
end repeat
end if
end repeat
end tell
end tell