MCGR repair broken offset on import
Armin Le Grand
armin_le_grand at me.com
Wed Apr 19 08:36:40 UTC 2023
Hi,
On 4/8/23 01:14, Regina Henschel wrote:
> Hi Armin,
>
>> Hi,
>>
>> A GradientStopSegment overlapping 0.0 or 1.0 is corrected by moving
>> the value outside [0.0 .. 1.0] to 0.0 or 1.0 resp. and also linearly
>> interpolating the color of the corrected entry to represent that
>> translation >
>> This is done by assuming that an overlapping entry might still
>> contain useful color information and to get as close as possible to
>> what the instance creating that data wanted to define. That might be
>> optimistic, but tries to follow the principle to safe as much input
>> data (evtl. from the user) as possible and useful - even when the
>> definition might be not 100% correct from what we define.
>
> That is different than SVG handles this. But it is fine for me because
> such situation will not occur in a valid ODF document.
Yes, that is true and we can always argue when parameters outside of the
valid range are feed in. Point from my POV is that UNO API needs to
check anyways in all cases - it cannot rely on being only used in XML
im/exports, so it will always need to be checked/corrected at UNO API
when values move to the core and will not be allowed to deliver results
outside defined valid ranges when asking for values from the core. Thus
double checking/correcting at the XML im/exports is just not needed -
and would be double, risking slightly diverging handling. From my POV...
>
>
>>
>> Due to this correction it is ensured that we will (potentially) not
>> write 'wrong' definitions since all data you can get from the model
>> data over the UNO API will be valid in the sense of that definitions.
>> Thus, for export, no nee to check for correctness is needed - just
>> export it.
>
> For export I have kept a correction in the way SVG does it to be sure
> it will be valid in the ODF sense.
Should alreay be cheked, see above. Will do no ham, but should not trigger.
>
>>
>> Since I know no places where data from ODF is imported and not set at
>> the model data, this would automatically correct this at load/import
>> time and in a roundtrip, too. Thus - for simplicity - you might just
>> import from ODF to awt::Gradient2 what is there in the order that is
>> there and leave the corrections to the model.
>
> In import, I now take the values as they are. I have tested with
> offsets out of range and with offsets in wrong order. After loading, a
> save and reload gives the same fill as first load. So I think that works.
Yes, I tested that, too :-)
>
> My version is in https://gerrit.libreoffice.org/c/core/+/150060. It
> does not yet consider theme colors. When your part is finished, it
> should work with simple colors. Currently there are some unit tests,
> which fail. If you are curious how ODF will look, you can test it.
Looking foward to that - when we have ODF im/export we can use MCGR in
templates - e.g. gradient templates in the Area... TabPage :-) And offer
some nice gadients for the uses
>
> Kind regards,
> Regina
>
Regards,
Armin
--
--
ALG (PGP: EE1C 4B3F E751 D8BC C485 DEC1 3C59 F953 D81C F4A2)
More information about the LibreOffice
mailing list