use of org.apache.poi.hslf.record.TxMasterStyleAtom in project poi by apache.
the class HSLFSlideMaster method setSlideShow.
/**
* Assign SlideShow for this slide master.
*/
@Internal
@Override
protected void setSlideShow(HSLFSlideShow ss) {
super.setSlideShow(ss);
//after the slide show is assigned collect all available style records
assert (_txmaster == null);
_txmaster = new TxMasterStyleAtom[9];
TxMasterStyleAtom txdoc = getSlideShow().getDocumentRecord().getEnvironment().getTxMasterStyleAtom();
_txmaster[txdoc.getTextType()] = txdoc;
TxMasterStyleAtom[] txrec = ((MainMaster) getSheetContainer()).getTxMasterStyleAtoms();
for (int i = 0; i < txrec.length; i++) {
int txType = txrec[i].getTextType();
if (txType < _txmaster.length && _txmaster[txType] == null) {
_txmaster[txType] = txrec[i];
}
}
for (List<HSLFTextParagraph> paras : getTextParagraphs()) {
for (HSLFTextParagraph htp : paras) {
int txType = htp.getRunType();
if (txType >= _txmaster.length || _txmaster[txType] == null) {
throw new HSLFException("Master styles not initialized");
}
int level = htp.getIndentLevel();
List<TextPropCollection> charStyles = _txmaster[txType].getCharacterStyles();
List<TextPropCollection> paragraphStyles = _txmaster[txType].getParagraphStyles();
if (charStyles == null || paragraphStyles == null || charStyles.size() <= level || paragraphStyles.size() <= level) {
throw new HSLFException("Master styles not initialized");
}
htp.setMasterStyleReference(paragraphStyles.get(level));
for (HSLFTextRun htr : htp.getTextRuns()) {
htr.setMasterStyleReference(charStyles.get(level));
}
}
}
}
use of org.apache.poi.hslf.record.TxMasterStyleAtom in project poi by apache.
the class HSLFSlideMaster method getStyleAttribute.
/**
* Pickup a style attribute from the master.
* This is the "workhorse" which returns the default style attributes.
*/
@Override
public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
if (_txmaster.length <= txtype) {
return null;
}
TxMasterStyleAtom t = _txmaster[txtype];
List<TextPropCollection> styles = isCharacter ? t.getCharacterStyles() : t.getParagraphStyles();
TextProp prop = null;
for (int i = Math.min(level, styles.size() - 1); prop == null && i >= 0; i--) {
prop = styles.get(i).findByName(name);
}
if (prop != null) {
return prop;
}
switch(txtype) {
case TextHeaderAtom.CENTRE_BODY_TYPE:
case TextHeaderAtom.HALF_BODY_TYPE:
case TextHeaderAtom.QUARTER_BODY_TYPE:
txtype = TextHeaderAtom.BODY_TYPE;
break;
case TextHeaderAtom.CENTER_TITLE_TYPE:
txtype = TextHeaderAtom.TITLE_TYPE;
break;
default:
return null;
}
return getStyleAttribute(txtype, level, name, isCharacter);
}
Aggregations