CSSStyle *WordSetupTableGridStyle(CSSSheet *styleSheet, int *changed) { CSSStyle *style = CSSSheetLookupElement(styleSheet,"table","Table_Grid",0,0); if (style == NULL) { style = CSSSheetLookupElement(styleSheet,"table","Table_Grid",1,0); CSSProperties *border = CSSPropertiesNewWithString("border: 1px solid black"); DFHashTable *collapsed = CSSCollapseProperties(border); CSSPropertiesUpdateFromRaw(CSSStyleRule(style),collapsed); CSSPropertiesUpdateFromRaw(CSSStyleCell(style),collapsed); DFHashTableRelease(collapsed); CSSPut(CSSStyleRule(style),"margin-left","auto"); CSSPut(CSSStyleRule(style),"margin-right","auto"); // These must be set last, as updateRaw clears them when modifying rule CSSStyleSetParent(style,"table.Normal_Table"); CSSStyleSetDisplayName(style,"Table Grid"); if (changed != NULL) *changed = 1; CSSPropertiesRelease(border); } return style; }
static void styleParse(WordStyle *wordStyle, WordConverter *converter, CSSStyle *style) { DFNode *concrete = wordStyle->element; WordGetStyle(concrete,style,converter); if (wordStyle->basedOn != NULL) { WordStyle *parent = WordSheetStyleForTypeId(converter->styles,wordStyle->type,wordStyle->basedOn); if (parent != NULL) { CSSStyleSetParent(style,parent->selector); } } }
static void breakCycles(CSSSheet *sheet) { // FIXME: Not covered by tests const char **allSelectors = CSSSheetCopySelectors(sheet); for (int i = 0; allSelectors[i]; i++) { const char *selector = allSelectors[i]; CSSStyle *style = CSSSheetLookupSelector(sheet,selector,0,0); DFHashTable *visited = DFHashTableNew((DFCopyFunction)xstrdup,(DFFreeFunction)free); int depth = 0; while (style != NULL) { if (DFHashTableLookup(visited,style->selector) != NULL) { CSSStyleSetParent(style,NULL); break; } DFHashTableAdd(visited,style->selector,""); style = CSSSheetGetStyleParent(sheet,style); depth++; } DFHashTableRelease(visited); } free(allSelectors); }