Need some help with styles

Dag danders at get2net.dk
Tue Nov 8 13:25:54 GMT 2016


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





More information about the calligra-devel mailing list