Search in sources :

Example 1 with MainMaster

use of org.apache.poi.hslf.record.MainMaster 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));
            }
        }
    }
}
Also used : HSLFException(org.apache.poi.hslf.exceptions.HSLFException) MainMaster(org.apache.poi.hslf.record.MainMaster) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection) TxMasterStyleAtom(org.apache.poi.hslf.record.TxMasterStyleAtom) Internal(org.apache.poi.util.Internal)

Aggregations

HSLFException (org.apache.poi.hslf.exceptions.HSLFException)1 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)1 MainMaster (org.apache.poi.hslf.record.MainMaster)1 TxMasterStyleAtom (org.apache.poi.hslf.record.TxMasterStyleAtom)1 Internal (org.apache.poi.util.Internal)1