https://bugs.documentfoundation.org/show_bug.cgi?id=158950
--- Comment #8 from Regina Henschel <[email protected]> --- Created attachment 191954 --> https://bugs.documentfoundation.org/attachment.cgi?id=191954&action=edit font color in paragraph style The attached document has a font color in paragraph style. It shows the same problem, that the font color is black instead of the color of the style. I have investigated further with these results (addressed to developers): The problem starts in the method static void cloneAndDeduplicateSprm(std::pair<Id, RTFValue::Pointer_t> const& rSprm, RTFSprms& ret, Id nStyleType, RTFSprms* pDirect = nullptr) in https://opengrok.libreoffice.org/xref/core/writerfilter/source/rtftok/rtfsprm.cxx?r=75f6a86a#283 This method essentially looks whether parameter 'rSprm' is already contained in parameter 'ret' and removes it from 'ret' in such case. It is called from RTFSprms::cloneAndDeduplicate(..). rSprm is a std::pair<Id, RTFValue::Pointer_t> ret is essentially a std::vector< std::pair<Id, RTFValue::Pointer_t> >. The cloneAndDeduplicateSprm method first compares '.first' components, the 'Id'. If a matching item is found then pValue points to the .second component from it. In a second step the method compares the '.second' components. If they are equal, the item is removed from 'ret'. In case of the example document and color (id 92551, usable in VS as condition for breakpoint), you see that the items rSprm.second and *pValue are equal, when you manually compare them. But the comparison 'rSprm.second->equals(*pValue)' returns false. Let's step into that comparison and see why it fails. The 'equals' method is RTFValue::equals() from https://opengrok.libreoffice.org/xref/core/writerfilter/source/rtftok/rtfvalue.cxx?r=f6fa9c45#164 '*this' and parameter rOther are the same {m_nValue=0 m_sValue=empty m_pAttributes={Params: 1} ...}. So the conditions if (m_nValue != rOther.m_nValue) and if (m_sValue != rOther.m_sValue) are wrong and we reach if (!m_pAttributes->equals(rOther)) In the example document the vector this->m_pAttributes has one item (91603, {m_nValue=5154606 m_sValue=empty m_pAttributes={Params: 0}...}) rOther is the RTFValue object {m_nValue=0 m_sValue=empty m_pAttributes={Params: 1} ... } from *pValue above. I wonder why here the sub-item m_pAttributes is compared with the total RTFValue. Let's step into that comparison. This 'equals' method is a RTFSprms::equals() from https://opengrok.libreoffice.org/xref/core/writerfilter/source/rtftok/rtfsprm.cxx?r=75f6a86a#440 That method uses a std:all_of, which iterates over all items in m_pSprms. The things which are combined in the conjunction are the return values of a lambda-function. The lambda-function compares its parameter raPair with the capture rOther. Actual values of the parameter raPair are the items in vector *m_pAttributes, rOther is the same in all comparisons. The comparison is done in raPair.second->equals(rOther). For the example document we get raPair.second={m_nValue=5154606 m_sValue=empty m_pAttributes={Params: 0}...} rOther={m_nValue=0 m_sValue=empty m_pAttributes={Params: 1} ... } This 'equals' method is a RTFValue::equals. It returns immediately 'false' because m_nValue=5154606 and rOther.m_nValue=0, thus different. The same mechanism was in the version without lambda-function. (BTW, the old version is much easier to understand.) I wonder about this RTFSprms::equals() method. It compares a vector of (Id, RTFValue) items with a single RTFValue? I would expect that its input parameter is a vector of (Id, RTFValues) and the iteration is parallel about both vectors. If I disable the comparison if (!m_pAttributes->equals(rOther)) return false; in RTFValue::equals(const RTFValue& rOther), then the example document loads with the correct colors. -- You are receiving this mail because: You are the assignee for the bug.
