public IStyle getTheme() { String themeId = getThemeId(); if (themeId == null) return null; IStyleSheet styleSheet = getOwnedWorkbook().getStyleSheet(); if (styleSheet == null) return null; return styleSheet.findStyle(themeId); }
public void setStyle(String key, String value) { IStyleSelector ss = branch.getBranchPolicy().getStyleSelector(branch); if (ss instanceof DummyStyleSelector) { ((DummyStyleSelector) ss).setOverridedStyle(key, value); } else { IStyleSheet styleSheet = topic.getOwnedWorkbook().getStyleSheet(); IStyle style = styleSheet.findStyle(topic.getStyleId()); if (style == null) { style = styleSheet.createStyle(IStyle.TOPIC); styleSheet.addStyle(style, IStyleSheet.NORMAL_STYLES); topic.setStyleId(style.getId()); } style.setProperty(key, value); } }
private static void setThemeStyles( IWorkbook workbook, IStyleSheet styleSheet, ISheet sheet, IStyle theme, String... sheetStyleNames) { IStyle sheetTheme = theme.getDefaultStyle(Styles.FAMILY_MAP); if (sheetTheme == null) return; IStyle sheetStyle = styleSheet.findStyle(sheet.getStyleId()); if (sheetStyle != null) { sheetStyle = Core.getWorkbookBuilder().createWorkbook().getStyleSheet().importStyle(sheetStyle); } String value = null; for (String styleName : sheetStyleNames) { value = sheetTheme.getProperty(styleName); if (value != null) { if (sheetStyle == null) sheetStyle = Core.getWorkbookBuilder() .createWorkbook() .getStyleSheet() .createStyle(sheet.getStyleType()); sheetStyle.setProperty(styleName, value); } else if (sheetStyle != null) { sheetStyle.setProperty(styleName, value); } } if (sheetStyle != null) { sheetStyle = workbook.getStyleSheet().importStyle(sheetStyle); if (sheetStyle != null) { sheet.setStyleId(sheetStyle.getId()); } } }
public static void setTheme(ISheet sheet, IStyle theme) { if (sheet == null) return; if (theme == null || theme.isEmpty()) { sheet.setThemeId(null); } else { IWorkbook workbook = sheet.getOwnedWorkbook(); IStyleSheet styleSheet = workbook.getStyleSheet(); theme = styleSheet.importStyle(theme); if (theme == null || theme.isEmpty()) { sheet.setThemeId(null); } else { sheet.setThemeId(theme.getId()); setThemeStyles( workbook, styleSheet, sheet, theme, Styles.MultiLineColors, Styles.LineTapered); } } }