/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../../unisharp/Utils");
const StringBuilder = require("./../../../unisharp/StringBuilder");

const GrLPUpxSw = require("./GrLPUpxSw");
const StkCharGRLPUPX = require("./StkCharGRLPUPX");
const StkTableGRLPUPX = require("./StkTableGRLPUPX");
const StkListGRLPUPX = require("./StkListGRLPUPX");
const StyleCollection = require("./StyleCollection");
const StdfBase = require("./StdfBase");
const StkParaGRLPUPX = require("./StkParaGRLPUPX");

class StyleDefinition {
    
    toString() {
        let tmp = new StringBuilder();
        tmp.append("'").append(this.name).append("'");
        tmp.append(this.getStyles().toString());
        return tmp.toString();
    }
    
    get name() {
        return this.std.xstzName.toString();
    }
    
    get isTextStyle() {
        return this.std.stdf.stdfBase.stk === (GrLPUpxSw.stkCharGRLPUPXStkValue);
    }
    
    constructor(_owner, _std) {
        this.owner = null;
        this.std = null;
        this.owner = _owner;
        this.std = _std;
    }
    
    getStyles() {
        let styles = new Array();
        this.expandStyles(styles);
        return new StyleCollection(styles);
    }
    
    expandStyles(styles) {
        if (Utils.compareUnsigned(this.std.stdf.stdfBase.istdBase, StdfBase.istdNull) != 0) 
            this.owner.styleDefinitionsMap.get(this.std.stdf.stdfBase.istdBase).expandStyles(styles);
        switch (this.std.stdf.stdfBase.stk) { 
        case GrLPUpxSw.stkParaGRLPUPXStkValue: {
            styles.push(this.std.grLPUpxSw.upxPapx.grpprlPapx);
            styles.push(this.std.grLPUpxSw.upxChpx.grpprlChpx);
            break;
        }
        case GrLPUpxSw.stkCharGRLPUPXStkValue: {
            styles.push(this.std.grLPUpxSw.upxChpx.grpprlChpx);
            break;
        }
        case GrLPUpxSw.stkTableGRLPUPXStkValue: {
            styles.push(this.std.grLPUpxSw.upxTapx.grpprlTapx);
            styles.push(this.std.grLPUpxSw.upxPapx.grpprlPapx);
            styles.push(this.std.grLPUpxSw.upxChpx.grpprlChpx);
            break;
        }
        case GrLPUpxSw.stkListGRLPUPXStkValue: {
            styles.push(this.std.grLPUpxSw.upxPapx.grpprlPapx);
            break;
        }
        }
    }
}


module.exports = StyleDefinition