// Copies all structural properties from source (clearing the property) to destination. private static void TransferStructuralProperties(Inline source, Inline destination) { bool sourceIsChild = (source.Parent == destination); for (int i = 0; i < TextSchema.StructuralCharacterProperties.Length; i++) { DependencyProperty property = TextSchema.StructuralCharacterProperties[i]; if ((sourceIsChild && HasLocalInheritableStructuralPropertyValue(source)) || (!sourceIsChild && HasLocalStructuralPropertyValue(source))) { object value = source.GetValue(property); source.ClearValue(property); destination.SetValue(property, value); } } }
// Helper for PreserveBlockContentStructuralProperty. private static void SetStructuralPropertyOnInline(Inline inline, DependencyProperty property, object value) { if (inline is Run && !inline.IsEmpty && !HasLocalPropertyValue(inline, property)) { // If the only child is a Run, set the value directly. // Otherwise there's no need to set the value. inline.SetValue(property, value); } }