throw new NullPointerException("StyleFamily must not be null");
}
if (styleName != null)
{
final OfficeStyle currentAuto =
stylesCollection.getAutomaticStyles().getStyle(styleFamily,
styleName);
if (currentAuto != null)
{
// handle an automatic style ..
final OfficeStyle derivedStyle =
deriveAutomaticStyle(currentAuto, styleFamily, styleName,
generator, commonCollection, predefCollection);
stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
return derivedStyle;
}
final OfficeStyle currentCommon =
stylesCollection.getCommonStyles().getStyle(styleFamily, styleName);
if (currentCommon != null)
{
// handle an common style ..
final OfficeStyle derivedStyle =
deriveCommonStyle(currentCommon, styleFamily, styleName,
generator, commonCollection, predefCollection);
stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
return derivedStyle;
}
// final OfficeStyle commonAuto =
// commonCollection.getAutomaticStyles().getStyle(styleFamily,
// styleName);
// if (commonAuto != null)
// {
// // handle an automatic style ..
// final OfficeStyle derivedStyle =
// deriveAutomaticStyle(commonAuto, styleFamily, styleName,
// generator, commonCollection, predefCollection);
// stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
// return derivedStyle;
// }
final OfficeStyle commonCommon =
commonCollection.getCommonStyles().getStyle(styleFamily, styleName);
if (commonCommon != null)
{
// handle an common style ..
final OfficeStyle derivedStyle =
deriveCommonStyle(commonCommon, styleFamily, styleName,
generator, commonCollection, predefCollection);
stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
return derivedStyle;
}
final OfficeStyle predefAuto =
predefCollection.getAutomaticStyles().getStyle(styleFamily,
styleName);
if (predefAuto != null)
{
// handle an automatic style ..
final OfficeStyle derivedStyle =
deriveAutomaticStyle(predefAuto, styleFamily, styleName,
generator, commonCollection, predefCollection);
stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
return derivedStyle;
}
final OfficeStyle predefCommon =
predefCollection.getCommonStyles().getStyle(styleFamily, styleName);
if (predefCommon != null)
{
// handle an common style ..
final OfficeStyle derivedStyle =
deriveCommonStyle(predefCommon, styleFamily, styleName,
generator, commonCollection, predefCollection);
stylesCollection.getAutomaticStyles().addStyle(derivedStyle);
return derivedStyle;
}
}
// No such style. Create a new one ..
final OfficeStyle autostyle = new OfficeStyle();
autostyle.setNamespace(OfficeNamespaces.STYLE_NS);
autostyle.setType("style");
autostyle.setStyleFamily(styleFamily);
if (styleName != null)
{
autostyle.setStyleName(styleName);
}
else
{
autostyle.setStyleName(generator.generateName("derived_anonymous"));
}
final OfficeStyles autoStyles = stylesCollection.getAutomaticStyles();
autoStyles.addStyle(autostyle);
return autostyle;