Example #1
0
 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());
     }
   }
 }
Example #2
0
  public IStyle getTheme() {
    String themeId = getThemeId();
    if (themeId == null) return null;

    IStyleSheet styleSheet = getOwnedWorkbook().getStyleSheet();
    if (styleSheet == null) return null;

    return styleSheet.findStyle(themeId);
  }
Example #3
0
 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);
   }
 }