+ if (style.HasTextEffects())
+ {
+ if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects()))
+ {
+ int destBits = destStyle.GetTextEffects();
+ int destFlags = destStyle.GetTextEffectFlags();
+
+ int srcBits = style.GetTextEffects();
+ int srcFlags = style.GetTextEffectFlags();
+
+ wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
+
+ destStyle.SetTextEffects(destBits);
+ destStyle.SetTextEffectFlags(destFlags);
+ }
+ }
+
+ if (style.HasOutlineLevel())
+ {
+ if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel()))
+ destStyle.SetOutlineLevel(style.GetOutlineLevel());
+ }
+
+ return true;
+}
+
+// Remove attributes
+bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style)
+{
+ int flags = style.GetFlags();
+ int destFlags = destStyle.GetFlags();
+
+ destStyle.SetFlags(destFlags & ~flags);
+
+ return true;
+}
+
+/// Combine two bitlists, specifying the bits of interest with separate flags.
+bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB)
+{
+ // We want to apply B's bits to A, taking into account each's flags which indicate which bits
+ // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags
+ // indicate it.
+
+ // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero
+ // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant.
+ int valueA2 = ~(~valueB & flagsB) & valueA;
+
+ // Now combine the 1 bits.
+ int valueA3 = (valueB & flagsB) | valueA2;
+
+ valueA = valueA3;
+ flagsA = (flagsA | flagsB);
+
+ return true;
+}
+
+/// Compare two bitlists
+bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags)
+{
+ int relevantBitsA = valueA & flags;
+ int relevantBitsB = valueB & flags;
+ return (relevantBitsA != relevantBitsB);
+}
+
+/// Split into paragraph and character styles
+bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle)
+{
+ wxTextAttrEx defaultCharStyle1(style);
+ wxTextAttrEx defaultParaStyle1(style);
+ defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER);
+ defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH);
+
+ wxRichTextApplyStyle(charStyle, defaultCharStyle1);
+ wxRichTextApplyStyle(parStyle, defaultParaStyle1);
+