Re: Problem with RTFSprms::equals() method in RTF import

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Regina,

On Mon, Jan 15, 2024 at 04:12:34PM +0100, Regina Henschel <rb.henschel@xxxxxxxxxxx> wrote:
> I see a problem with the RTFSprms::equals() method. The problem is described
> in Bug 158950 - Paste as Rich Text Format loses character color and
> paragraph alignment from styles
> https://bugs.documentfoundation.org/show_bug.cgi?id=158950#c8
> 
> Miklos, as far as I see you have implemented the RTF import. Could you
> please have a look at that problem and comment?

At the end, you ask:

> 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.

RTFValue is a recursive structure. The Value interface in writerfilter/
can kind of contain anything that comes from an XML file:

- XML element (called SPRM)
- XML attribute (called Attribute)
- string
- number
- boolean
- etc.

So that we try to make sure here is that in case you compare two
RTFValues then either the type is a simple one (string, boolean, etc) or
the Id ("name") is the same and all the sub-values (SPRMs, Attributes)
are also the same.

> 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.

That's a clever hack, but you can see that not comparing attributes in
general is incorrect. For example, if I have paragraph borders, then
I'll have various attributes for that, and in case I consider different
border attributes as the same, that'll lead to an incorrect import
result.

So probably the root of the problem you're looking at will be somewhere
else, but likely still in writerfilter/.

I hope this gets you a little bit further. :-)

Regards,

Miklos



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux