When adding the linked style, lets name it to “Heading 1”. Heading 1 has - paragraph level ‘Heading 1’ and character level ‘Heading 1 Char’.
So, while adding this to docA which already has ‘Heading 1’ in it, addCopy would create a copy of it rather than overriding.
We were using a work-around as second copy is added because of character level style - “Heading 1 Char” read again from the document. So, we skipped the applying when it ends with character level.
But now since we are not applying “Heading 1 Char”, the docA’s Heading 1 Char would be retained.
So, after applying the docA would have - ‘Heading 1’ the newly one, and the ‘Heading 1 Char’ the older one.
Since some text is using Heading 1 Char in docA, it is still based upon older ‘Heading 1 Char’ and not the newer one which is with linked - ‘Heading 1’.
So, in this case expected behavior is while applying Heading 1, the Heading 1 Char should also be overridden from docA, and not only Heading 1.
For reproduction you can try adding Heading 1 (tweaked) from some document to the any ‘docA’.
Please suggest us the way to override the ‘Heading 1 Char’ (retained character style, previously part of linked style).