import { Document } from "../Document" ; import { Helper } from "../Helper" ; import { Pap } from "../parser/Containers" ; import { RenderChp } from "./RenderChp" ; export class RenderPap { private _pap : Pap ; constructor ( pap ) { this . _pap = pap ; } public apply ( doc , el , rchp , ismaindiv ) { Helper . log ( "[rtf] RenderPap apply:" + ( rchp != null ? " chp=" + JSON . stringify ( rchp . _chp ) : "" ) + " pap=" + JSON . stringify ( this . _pap ) + " ismaindiv=" + ismaindiv ) ; if ( ismaindiv ) { if ( this . _pap . spacebefore !== 0 ) { el . style . marginTop = Helper . _twipsToPt ( this . _pap . spacebefore ) + "pt" ; } else { el . style . marginTop = "" ; } if ( this . _pap . spaceafter !== 0 ) { el . style . marginBottom = Helper . _twipsToPt ( this . _pap . spaceafter ) + "pt" ; } else { el . style . marginBottom = "" ; } if ( rchp != null ) { el . style . minHeight = Math . floor ( rchp . _chp . fontsize / 2 ) + "pt" ; } } else { switch ( this . _pap . justification ) { case Helper . JUSTIFICATION . LEFT : el . style . textAlign = "left" ; break ; case Helper . JUSTIFICATION . RIGHT : el . style . textAlign = "right" ; break ; case Helper . JUSTIFICATION . CENTER : el . style . textAlign = "center" ; break ; case Helper . JUSTIFICATION . JUSTIFY : el . style . textAlign = "justify" ; break ; } } } }