Jos van den Oever skrev den 2016-11-08 16:24:
Hello Dag,
The way the inhertance works is described here:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416276_253892949
Yes, this looks fairly sane, thanks.
Roughly, if a style does not define a property, there are quite a few
places
where the code can look to find a value. First it looks in the parent
styles.
If those do not define the property, that style of the parent element
(and it's
parent styles) are queried. If that leads nowhere, the
<style:default-style/>
comes into play and only then should the code resort to using an
implementation specific default value.
I think Sheets are close to doing this, except for the case I outline
below but I have to look at it again with a clear head.
Thanks again.
Cheers,
Jos
On Tuesday 08 November 2016 14:25:54 Dag wrote:
Hi, I'm tracking a bug in Sheets style handling but I'm uncertain of
how
to fix it because I don't understand the code alt. how styles should
work.
I thought default styles where used when there was no style assigned
to
an object, and *maybe* used to give default values for things not
specified in a style (but I thought parent style where used for that)?
In Odf::loadSheetInsertStyles()
we have code like this:
if (autoStyles.contains(styleNames[i])) {
Style style;
style.setDefault(); // "overwrite" existing style
style.merge(autoStyles[styleNames[i]]);
outStyleRegions.append(qMakePair(styleRegion, style));
} else {
which effectivly adds a default sub style to the autostyle.
Then there is the comment: // "overwrite" existing style
What can that mean?
Later a new style is composed based on this style with code in:
StyleStorage::composeStyle()
for (int i = 0; i < subStyles.count(); ++i) {
if (subStyles[i]->type() == Style::DefaultStyleKey) {
style = *styleManager()->defaultStyle();
qDebug()<<Q_FUNC_INFO<<subStyles<<"default:"<<style;
} else if (subStyles[i]->type() == Style::NamedStyleKey) {
etc. (adding the different substyles)
One problem here is that the position of the default substyle in the
list seems to be random, and since all substyles positioned *before*
the
default substyle is forgotten about, the resulting style is also
random.
Boudewijn, git blame says you added this in 2009, I'm sure you can
remember why? It is only 7 years ago :)
The way I hit this was to format a number as scientific and then
save/load; sometimes it is formatted as scientific, other times as a
float.
Cheers, Dag