44
55use RtfHtmlPhp \Document ;
66
7- #[\AllowDynamicProperties]
87class HtmlFormatter
98{
109 private $ output = '' ;
1110 private $ encoding ;
1211 private $ defaultFont ;
1312
13+ // dinamic declarations fixed
14+
15+ private $ previousState ;
16+ private $ states ;
17+ /**
18+ * State
19+ */
20+ private $ state ;
21+ private $ openedTags ;
22+ private $ RTFencoding ;
23+
24+
1425 // By default, HtmlFormatter uses HTML_ENTITIES for code conversion.
1526 // You can optionally support a different endoing when creating
1627 // the HtmlFormatter instance.
@@ -117,7 +128,7 @@ protected function LoadFont(\RtfHtmlPhp\Group $fontGroup) {
117128 */
118129 }
119130
120- State::SetFont ($ fontNumber , $ font );
131+ State::setFontInFontTable ($ fontNumber , $ font );
121132 }
122133
123134 protected function ExtractFontTable ($ fontTblGrp )
@@ -274,28 +285,28 @@ protected function FormatControlWord($word)
274285 */
275286
276287 case 'b ' : // bold
277- $ this ->state ->bold = $ word ->parameter ;
288+ $ this ->state ->setBold ( $ word ->parameter ) ;
278289 break ;
279290 case 'i ' : // italic
280- $ this ->state ->italic = $ word ->parameter ;
291+ $ this ->state ->setItalic ( $ word ->parameter ) ;
281292 break ;
282293 case 'ul ' : // underline
283- $ this ->state ->underline = $ word ->parameter ;
294+ $ this ->state ->setUnderline ( $ word ->parameter ) ;
284295 break ;
285296 case 'ulnone ' : // no underline
286- $ this ->state ->underline = false ;
297+ $ this ->state ->setUnderline ( false ) ;
287298 break ;
288299 case 'strike ' : // strike-through
289- $ this ->state ->strike = $ word ->parameter ;
300+ $ this ->state ->setStrike ( $ word ->parameter ) ;
290301 break ;
291302 case 'v ' : // hidden
292- $ this ->state ->hidden = $ word ->parameter ;
303+ $ this ->state ->setHidden ( $ word ->parameter ) ;
293304 break ;
294305 case 'fs ' : // Font size
295- $ this ->state ->fontsize = ceil (($ word ->parameter / 24 ) * 16 );
306+ $ this ->state ->setFontsize ( ceil (($ word ->parameter / 24 ) * 16 ) );
296307 break ;
297308 case 'f ' : // Font
298- $ this ->state ->font = $ word ->parameter ;
309+ $ this ->state ->setFont ( $ word ->parameter ) ;
299310 break ;
300311 case 'deff ' : // Store default font
301312 $ this ->defaultFont = $ word ->parameter ;
@@ -307,14 +318,14 @@ protected function FormatControlWord($word)
307318
308319 case 'cf ' :
309320 case 'chcfpat ' :
310- $ this ->state ->fontcolor = $ word ->parameter ;
321+ $ this ->state ->setFontcolor ( $ word ->parameter ) ;
311322 break ;
312323 case 'cb ' :
313324 case 'chcbpat ' :
314- $ this ->state ->background = $ word ->parameter ;
325+ $ this ->state ->setBackground ( $ word ->parameter ) ;
315326 break ;
316327 case 'highlight ' :
317- $ this ->state ->hcolor = $ word ->parameter ;
328+ $ this ->state ->setHcolor ( $ word ->parameter ) ;
318329 break ;
319330
320331 /*
@@ -595,5 +606,149 @@ protected function ord_utf8($chr)
595606
596607 trigger_error ("Invalid Unicode character: {$ chr }" );
597608 }
609+
610+ /**
611+ * Get the value of output
612+ */
613+ public function getOutput ()
614+ {
615+ return $ this ->output ;
616+ }
617+
618+ /**
619+ * Set the value of output
620+ */
621+ public function setOutput ($ output ): self
622+ {
623+ $ this ->output = $ output ;
624+
625+ return $ this ;
626+ }
627+
628+ /**
629+ * Get the value of encoding
630+ */
631+ public function getEncoding ()
632+ {
633+ return $ this ->encoding ;
634+ }
635+
636+ /**
637+ * Set the value of encoding
638+ */
639+ public function setEncoding ($ encoding ): self
640+ {
641+ $ this ->encoding = $ encoding ;
642+
643+ return $ this ;
644+ }
645+
646+ /**
647+ * Get the value of defaultFont
648+ */
649+ public function getDefaultFont ()
650+ {
651+ return $ this ->defaultFont ;
652+ }
653+
654+ /**
655+ * Set the value of defaultFont
656+ */
657+ public function setDefaultFont ($ defaultFont ): self
658+ {
659+ $ this ->defaultFont = $ defaultFont ;
660+
661+ return $ this ;
662+ }
663+
664+ /**
665+ * Get the value of previousState
666+ */
667+ public function getPreviousState ()
668+ {
669+ return $ this ->previousState ;
670+ }
671+
672+ /**
673+ * Set the value of previousState
674+ */
675+ public function setPreviousState ($ previousState ): self
676+ {
677+ $ this ->previousState = $ previousState ;
678+
679+ return $ this ;
680+ }
681+
682+ /**
683+ * Get the value of states
684+ */
685+ public function getStates ()
686+ {
687+ return $ this ->states ;
688+ }
689+
690+ /**
691+ * Set the value of states
692+ */
693+ public function setStates ($ states ): self
694+ {
695+ $ this ->states = $ states ;
696+
697+ return $ this ;
698+ }
699+
700+ /**
701+ * Get the value of state
702+ */
703+ public function getState ()
704+ {
705+ return $ this ->state ;
706+ }
707+
708+ /**
709+ * Set the value of state
710+ */
711+ public function setState ($ state ): self
712+ {
713+ $ this ->state = $ state ;
714+
715+ return $ this ;
716+ }
717+
718+ /**
719+ * Get the value of openedTags
720+ */
721+ public function getOpenedTags ()
722+ {
723+ return $ this ->openedTags ;
724+ }
725+
726+ /**
727+ * Set the value of openedTags
728+ */
729+ public function setOpenedTags ($ openedTags ): self
730+ {
731+ $ this ->openedTags = $ openedTags ;
732+
733+ return $ this ;
734+ }
735+
736+ /**
737+ * Get the value of RTFencoding
738+ */
739+ public function getRTFencoding ()
740+ {
741+ return $ this ->RTFencoding ;
742+ }
743+
744+ /**
745+ * Set the value of RTFencoding
746+ */
747+ public function setRTFencoding ($ RTFencoding ): self
748+ {
749+ $ this ->RTFencoding = $ RTFencoding ;
750+
751+ return $ this ;
752+ }
598753}
599754
0 commit comments