1 /*
2  * JasperReports - Free Java Reporting Library.
3  * Copyright (C) 2001 - 2019 TIBCO Software Inc. All rights reserved.
4  * http://www.jaspersoft.com
5  *
6  * Unless you have purchased a commercial license agreement from Jaspersoft,
7  * the following license terms apply:
8  *
9  * This program is part of JasperReports.
10  *
11  * JasperReports is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * JasperReports is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
23  */

24 package net.sf.jasperreports.engine.fill;
25
26 import java.io.IOException;
27 import java.io.ObjectInputStream;
28
29 import net.sf.jasperreports.engine.JRAnchor;
30 import net.sf.jasperreports.engine.JRCommonText;
31 import net.sf.jasperreports.engine.JRConstants;
32 import net.sf.jasperreports.engine.JRLineBox;
33 import net.sf.jasperreports.engine.JRParagraph;
34 import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
35 import net.sf.jasperreports.engine.JRPrintText;
36 import net.sf.jasperreports.engine.JRStyledTextAttributeSelector;
37 import net.sf.jasperreports.engine.PrintElementVisitor;
38 import net.sf.jasperreports.engine.type.HorizontalTextAlignEnum;
39 import net.sf.jasperreports.engine.type.HyperlinkTargetEnum;
40 import net.sf.jasperreports.engine.type.HyperlinkTypeEnum;
41 import net.sf.jasperreports.engine.type.RotationEnum;
42 import net.sf.jasperreports.engine.type.RunDirectionEnum;
43 import net.sf.jasperreports.engine.type.VerticalTextAlignEnum;
44 import net.sf.jasperreports.engine.util.JRStyledText;
45 import net.sf.jasperreports.engine.util.JRStyledTextParser;
46 import net.sf.jasperreports.engine.virtualization.VirtualizationInput;
47 import net.sf.jasperreports.engine.virtualization.VirtualizationOutput;
48
49
50 /**
51  * Implementation of {@link net.sf.jasperreports.engine.JRPrintText} that uses
52  * a {@link net.sf.jasperreports.engine.fill.JRTemplateText} instance to
53  * store common attributes. 
54  * 
55  * @author Teodor Danciu (teodord@users.sourceforge.net)
56  */

57 public class JRTemplatePrintText extends JRTemplatePrintElement implements JRPrintText
58 {
59
60
61     /**
62      *
63      */

64     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
65
66     private static final int SERIALIZATION_FLAG_ANCHOR = 1;
67     private static final int SERIALIZATION_FLAG_HYPERLINK = 1 << 1;
68     private static final int SERIALIZATION_FLAG_RTL = 1 << 2;
69     private static final int SERIALIZATION_FLAG_TRUNCATION = 1 << 3;
70     private static final int SERIALIZATION_FLAG_LINE_BREAK_OFFSETS = 1 << 4;
71     private static final int SERIALIZATION_FLAG_ZERO_LINE_BREAK_OFFSETS = 1 << 5;
72     private static final int SERIALIZATION_FLAG_HAS_VALUE = 1 << 6;
73     private static final int SERIALIZATION_FLAG_HYPERLINK_OMITTED = 1 << 7;
74
75     /**
76      *
77      */

78     private String text = "";
79     private Integer textTruncateIndex;
80     private String textTruncateSuffix;
81     private short[] lineBreakOffsets;
82     //private transient String truncatedText;
83     private Object value;
84     private float lineSpacingFactor;
85     private float leadingOffset;
86     private RunDirectionEnum runDirectionValue;
87     private float textHeight;
88     
89     // we're no longer setting this at fill time, all format attributes are in the template.
90     // keeping the field for old serialized JasperPrints.
91     private TextFormat textFormat;
92     
93     private String anchorName;
94     private boolean hyperlinkOmitted;
95     private String hyperlinkReference;
96     private String hyperlinkAnchor;
97     private Integer hyperlinkPage;
98     private String hyperlinkTooltip;
99     private JRPrintHyperlinkParameters hyperlinkParameters;
100
101     /**
102      * The bookmark level for the anchor associated with this field.
103      * @see JRAnchor#getBookmarkLevel()
104      */

105     protected int bookmarkLevel = JRAnchor.NO_BOOKMARK;
106     
107     public JRTemplatePrintText()
108     {
109         
110     }
111     
112     /**
113      * Creates a print text element.
114      * 
115      * @param text the template text that the element will use
116      * @param originator
117      */

118     public JRTemplatePrintText(JRTemplateText text, PrintElementOriginator originator)
119     {
120         super(text, originator);
121     }
122
123     @Override
124     public void setText(String text)
125     {
126         this.text = text;
127         //this.truncatedText = null;
128     }
129
130     @Override
131     public Integer getTextTruncateIndex()
132     {
133         return textTruncateIndex;
134     }
135
136     @Override
137     public void setTextTruncateIndex(Integer textTruncateIndex)
138     {
139         this.textTruncateIndex = textTruncateIndex;
140         //this.truncatedText = null;
141     }
142
143     @Override
144     public String getTextTruncateSuffix()
145     {
146         return textTruncateSuffix;
147     }
148
149     @Override
150     public void setTextTruncateSuffix(String textTruncateSuffix)
151     {
152         this.textTruncateSuffix = textTruncateSuffix;
153         //this.truncatedText = null;
154     }
155
156     @Override
157     public short[] getLineBreakOffsets()
158     {
159         return lineBreakOffsets;
160     }
161
162     @Override
163     public void setLineBreakOffsets(short[] lineBreakOffsets)
164     {
165         this.lineBreakOffsets = lineBreakOffsets;
166     }
167
168     @Override
169     public String getFullText()
170     {
171         String fullText = this.text;
172         if (textTruncateIndex == null && textTruncateSuffix != null)
173         {
174             fullText += textTruncateSuffix;
175         }
176         return fullText;
177     }
178
179     @Override
180     public String getOriginalText()
181     {
182         return text;
183     }
184     
185     @Override
186     public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector)
187     {
188         if (getFullText() == null)
189         {
190             return null;
191         }
192
193         return 
194             JRStyledTextParser.getInstance().getStyledText(
195                 attributeSelector.getStyledTextAttributes(this), 
196                 getFullText(), 
197                 !JRCommonText.MARKUP_NONE.equals(getMarkup()),
198                 JRStyledTextAttributeSelector.getTextLocale(this)
199                 );
200     }
201     
202     @Override
203     public Object getValue()
204     {
205         return value;
206     }
207
208     @Override
209     public void setValue(Object value)
210     {
211         this.value = value;
212     }
213
214     @Override
215     public float getLineSpacingFactor()
216     {
217         return lineSpacingFactor;
218     }
219         
220     @Override
221     public void setLineSpacingFactor(float lineSpacingFactor)
222     {
223         this.lineSpacingFactor = lineSpacingFactor;
224     }
225
226     @Override
227     public float getLeadingOffset()
228     {
229         return leadingOffset;
230     }
231         
232     @Override
233     public void setLeadingOffset(float leadingOffset)
234     {
235         this.leadingOffset = leadingOffset;
236     }
237
238     @Override
239     public HorizontalTextAlignEnum getHorizontalTextAlign()
240     {
241         return ((JRTemplateText)this.template).getHorizontalTextAlign();
242     }
243         
244     @Override
245     public HorizontalTextAlignEnum getOwnHorizontalTextAlign()
246     {
247         return ((JRTemplateText)this.template).getOwnHorizontalTextAlign();
248     }
249         
250     @Override
251     public void setHorizontalTextAlign(HorizontalTextAlignEnum horizontalAlignment)
252     {
253         throw new UnsupportedOperationException();
254     }
255         
256     @Override
257     public VerticalTextAlignEnum getVerticalTextAlign()
258     {
259         return ((JRTemplateText)this.template).getVerticalTextAlign();
260     }
261         
262     @Override
263     public VerticalTextAlignEnum getOwnVerticalTextAlign()
264     {
265         return ((JRTemplateText)this.template).getOwnVerticalTextAlign();
266     }
267         
268     @Override
269     public void setVerticalTextAlign(VerticalTextAlignEnum verticalAlignment)
270     {
271         throw new UnsupportedOperationException();
272     }
273         
274     @Override
275     public RotationEnum getRotationValue()
276     {
277         return ((JRTemplateText)this.template).getRotationValue();
278     }
279         
280     @Override
281     public RotationEnum getOwnRotationValue()
282     {
283         return ((JRTemplateText)this.template).getOwnRotationValue();
284     }
285         
286     @Override
287     public void setRotation(RotationEnum rotation)
288     {
289         throw new UnsupportedOperationException();
290     }
291         
292     
293     @Override
294     public RunDirectionEnum getRunDirectionValue()
295     {
296         return this.runDirectionValue;
297     }
298
299     @Override
300     public void setRunDirection(RunDirectionEnum runDirectionValue)
301     {
302         this.runDirectionValue = runDirectionValue;
303     }
304
305     @Override
306     public float getTextHeight()
307     {
308         return textHeight;
309     }
310         
311     @Override
312     public void setTextHeight(float textHeight)
313     {
314         this.textHeight = textHeight;
315     }
316
317     @Override
318     public String getMarkup()
319     {
320         return ((JRTemplateText)template).getMarkup();
321     }
322         
323     @Override
324     public String getOwnMarkup()
325     {
326         return ((JRTemplateText)template).getOwnMarkup();
327     }
328
329     @Override
330     public void setMarkup(String markup)
331     {
332         throw new UnsupportedOperationException();
333     }
334         
335     @Override
336     public JRLineBox getLineBox()
337     {
338         return ((JRTemplateText)template).getLineBox();
339     }
340         
341     @Override
342     public JRParagraph getParagraph()
343     {
344         return ((JRTemplateText)template).getParagraph();
345     }
346         
347     @Override
348     public void setTextFormat(TextFormat textFormat)
349     {
350         this.textFormat = textFormat;
351     }
352         
353     @Override
354     public String getAnchorName()
355     {
356         return anchorName;
357     }
358         
359     @Override
360     public void setAnchorName(String anchorName)
361     {
362         this.anchorName = anchorName;
363     }
364     
365     public void setHyperlinkOmitted(boolean hyperlinkOmitted)
366     {
367         this.hyperlinkOmitted = hyperlinkOmitted;
368     }
369         
370     @Override
371     public HyperlinkTypeEnum getHyperlinkTypeValue()
372     {
373         return hyperlinkOmitted ? HyperlinkTypeEnum.NONE : ((JRTemplateText)this.template).getHyperlinkTypeValue();
374     }
375         
376     @Override
377     public void setHyperlinkType(HyperlinkTypeEnum hyperlinkType)
378     {
379         throw new UnsupportedOperationException();
380     }
381
382     @Override
383     public HyperlinkTargetEnum getHyperlinkTargetValue()
384     {
385         return ((JRTemplateText)this.template).getHyperlinkTargetValue();
386     }
387         
388     @Override
389     public void setHyperlinkTarget(HyperlinkTargetEnum hyperlinkTarget)
390     {
391         throw new UnsupportedOperationException();
392     }
393
394     @Override
395     public String getLinkTarget()
396     {
397         return ((JRTemplateText)template).getLinkTarget();
398     }
399         
400     @Override
401     public void setLinkTarget(String linkTarget)
402     {
403     }
404     /**
405      *
406      */

407     public void setLinkTarget(byte hyperlinkTarget)
408     {
409     }
410
411     @Override
412     public String getHyperlinkReference()
413     {
414         return hyperlinkReference;
415     }
416         
417     @Override
418     public void setHyperlinkReference(String hyperlinkReference)
419     {
420         this.hyperlinkReference = hyperlinkReference;
421     }
422         
423     @Override
424     public String getHyperlinkAnchor()
425     {
426         return hyperlinkAnchor;
427     }
428         
429     @Override
430     public void setHyperlinkAnchor(String hyperlinkAnchor)
431     {
432         this.hyperlinkAnchor = hyperlinkAnchor;
433     }
434         
435     @Override
436     public Integer getHyperlinkPage()
437     {
438         return hyperlinkPage;
439     }
440         
441     @Override
442     public void setHyperlinkPage(Integer hyperlinkPage)
443     {
444         this.hyperlinkPage = hyperlinkPage;
445     }
446
447
448     @Override
449     public int getBookmarkLevel()
450     {
451         return bookmarkLevel;
452     }
453
454
455     @Override
456     public void setBookmarkLevel(int bookmarkLevel)
457     {
458         this.bookmarkLevel = bookmarkLevel;
459     }
460
461     @Override
462     public String getFontName()
463     {
464         return ((JRTemplateText)template).getFontName();
465     }
466
467     @Override
468     public String getOwnFontName()
469     {
470         return ((JRTemplateText)template).getOwnFontName();
471     }
472
473     @Override
474     public void setFontName(String fontName)
475     {
476     }
477
478
479     @Override
480     public boolean isBold()
481     {
482         return ((JRTemplateText)template).isBold();
483     }
484
485     @Override
486     public Boolean isOwnBold()
487     {
488         return ((JRTemplateText)template).isOwnBold();
489     }
490
491     /**
492      * @deprecated Replaced by {@link #setBold(Boolean)}.
493      */

494     @Override
495     public void setBold(boolean isBold)
496     {
497     }
498
499     /**
500      * Alternative setBold method which allows also to reset
501      * the "own" isBold property.
502      */

503     @Override
504     public void setBold(Boolean isBold)
505     {
506     }
507
508
509     @Override
510     public boolean isItalic()
511     {
512         return ((JRTemplateText)template).isItalic();
513     }
514
515     @Override
516     public Boolean isOwnItalic()
517     {
518         return ((JRTemplateText)template).isOwnItalic();
519     }
520
521     /**
522      * @deprecated Replaced by {@link #setItalic(Boolean)}.
523      */

524     @Override
525     public void setItalic(boolean isItalic)
526     {
527     }
528
529     /**
530      * Alternative setItalic method which allows also to reset
531      * the "own" isItalic property.
532      */

533     @Override
534     public void setItalic(Boolean isItalic)
535     {
536     }
537
538     @Override
539     public boolean isUnderline()
540     {
541         return ((JRTemplateText)template).isUnderline();
542     }
543
544     @Override
545     public Boolean isOwnUnderline()
546     {
547         return ((JRTemplateText)template).isOwnUnderline();
548     }
549
550     /**
551      * @deprecated Replaced by {@link #setUnderline(Boolean)}.
552      */

553     @Override
554     public void setUnderline(boolean isUnderline)
555     {
556     }
557
558     /**
559      * Alternative setUnderline method which allows also to reset
560      * the "own" isUnderline property.
561      */

562     @Override
563     public void setUnderline(Boolean isUnderline)
564     {
565     }
566
567     @Override
568     public boolean isStrikeThrough()
569     {
570         return ((JRTemplateText)template).isStrikeThrough();
571     }
572
573     @Override
574     public Boolean isOwnStrikeThrough()
575     {
576         return ((JRTemplateText)template).isOwnStrikeThrough();
577     }
578
579     /**
580      * @deprecated Replaced by {@link #setStrikeThrough(Boolean)}.
581      */

582     @Override
583     public void setStrikeThrough(boolean isStrikeThrough)
584     {
585         setStrikeThrough((Boolean)isStrikeThrough);
586     }
587
588     /**
589      * Alternative setStrikeThrough method which allows also to reset
590      * the "own" isStrikeThrough property.
591      */

592     @Override
593     public void setStrikeThrough(Boolean isStrikeThrough)
594     {
595     }
596
597     @Override
598     public float getFontsize()
599     {
600         return ((JRTemplateText)template).getFontsize();
601     }
602
603     @Override
604     public Float getOwnFontsize()
605     {
606         return ((JRTemplateText)template).getOwnFontsize();
607     }
608
609     /**
610      * Method which allows also to reset the "own" size property.
611      */

612     @Override
613     public void setFontSize(Float fontSize)
614     {
615     }
616
617     @Override
618     public String getPdfFontName()
619     {
620         return ((JRTemplateText)template).getPdfFontName();
621     }
622
623     @Override
624     public String getOwnPdfFontName()
625     {
626         return ((JRTemplateText)template).getOwnPdfFontName();
627     }
628
629     @Override
630     public void setPdfFontName(String pdfFontName)
631     {
632     }
633
634
635     @Override
636     public String getPdfEncoding()
637     {
638         return ((JRTemplateText)template).getPdfEncoding();
639     }
640
641     @Override
642     public String getOwnPdfEncoding()
643     {
644         return ((JRTemplateText)template).getOwnPdfEncoding();
645     }
646
647     @Override
648     public void setPdfEncoding(String pdfEncoding)
649     {
650     }
651
652
653     @Override
654     public boolean isPdfEmbedded()
655     {
656         return ((JRTemplateText)template).isPdfEmbedded();
657     }
658
659     @Override
660     public Boolean isOwnPdfEmbedded()
661     {
662         return ((JRTemplateText)template).isOwnPdfEmbedded();
663     }
664
665     /**
666      * @deprecated Replaced by {@link #setPdfEmbedded(Boolean)}.
667      */

668     @Override
669     public void setPdfEmbedded(boolean isPdfEmbedded)
670     {
671     }
672
673     /**
674      * Alternative setPdfEmbedded method which allows also to reset
675      * the "own" isPdfEmbedded property.
676      */

677     @Override
678     public void setPdfEmbedded(Boolean isPdfEmbedded)
679     {
680     }
681
682
683     @Override
684     public String getValueClassName()
685     {
686         return  textFormat == null ? ((JRTemplateText) template).getValueClassName() : textFormat.getValueClassName();
687     }
688
689     @Override
690     public String getPattern()
691     {
692         return textFormat == null ? ((JRTemplateText) template).getPattern() : textFormat.getPattern();
693     }
694
695     @Override
696     public String getFormatFactoryClass()
697     {
698         return textFormat == null ? ((JRTemplateText) template).getFormatFactoryClass() : textFormat.getFormatFactoryClass();
699     }
700
701     @Override
702     public String getLocaleCode()
703     {
704         return textFormat == null ? ((JRTemplateText) template).getLocaleCode() : textFormat.getLocaleCode();
705     }
706
707     @Override
708     public String getTimeZoneId()
709     {
710         return textFormat == null ? ((JRTemplateText) template).getTimeZoneId() : textFormat.getTimeZoneId();
711     }
712
713     
714     @Override
715     public JRPrintHyperlinkParameters getHyperlinkParameters()
716     {
717         return hyperlinkParameters;
718     }
719
720     
721     @Override
722     public void setHyperlinkParameters(JRPrintHyperlinkParameters hyperlinkParameters)
723     {
724         this.hyperlinkParameters = hyperlinkParameters;
725     }
726
727     @Override
728     public String getLinkType()
729     {
730         return hyperlinkOmitted ? null : ((JRTemplateText) template).getLinkType();
731     }
732
733     @Override
734     public void setLinkType(String type)
735     {
736     }
737
738     
739     @Override
740     public String getHyperlinkTooltip()
741     {
742         return hyperlinkTooltip;
743     }
744
745     
746     @Override
747     public void setHyperlinkTooltip(String hyperlinkTooltip)
748     {
749         this.hyperlinkTooltip = hyperlinkTooltip;
750     }
751
752     /*
753      * These fields are only for serialization backward compatibility.
754      */

755     private int PSEUDO_SERIAL_VERSION_UID = JRConstants.PSEUDO_SERIAL_VERSION_UID; //NOPMD
756     /**
757      * @deprecated
758      */

759     private byte runDirection;
760     
761     @SuppressWarnings("deprecation")
762     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
763     {
764         in.defaultReadObject();
765
766         if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
767         {
768             runDirectionValue = RunDirectionEnum.getByValue(runDirection);
769         }
770     }
771
772     @Override
773     public <T> void accept(PrintElementVisitor<T> visitor, T arg)
774     {
775         visitor.visit(this, arg);
776     }
777     
778     @Override
779     public void writeVirtualized(VirtualizationOutput out) throws IOException
780     {
781         super.writeVirtualized(out);
782         
783         int flags = 0;
784         boolean hasAnchor = anchorName != null || bookmarkLevel != JRAnchor.NO_BOOKMARK;
785         boolean hasHyperlink = hyperlinkReference != null || hyperlinkAnchor != null
786                 || hyperlinkPage != null || hyperlinkTooltip != null || hyperlinkParameters != null;
787         boolean hasTrunc = textTruncateIndex != null || textTruncateSuffix != null;
788         boolean hasLineBreakOffsets = lineBreakOffsets != null;
789         boolean zeroLineBreakOffsets = lineBreakOffsets != null && lineBreakOffsets.length == 0;
790         //FIXME add a flag for null value
791         boolean hasValue = !(text == null ? value == null : (value instanceof String && text.equals(value)));
792         
793         if (hasAnchor)
794         {
795             flags |= SERIALIZATION_FLAG_ANCHOR;
796         }
797         if (hasHyperlink)
798         {
799             flags |= SERIALIZATION_FLAG_HYPERLINK;
800         }
801         if (hasTrunc)
802         {
803             flags |= SERIALIZATION_FLAG_TRUNCATION;
804         }
805         if (hasLineBreakOffsets)
806         {
807             flags |= SERIALIZATION_FLAG_LINE_BREAK_OFFSETS;
808         }
809         if (zeroLineBreakOffsets)
810         {
811             flags |= SERIALIZATION_FLAG_ZERO_LINE_BREAK_OFFSETS;
812         }
813         if (hasValue)
814         {
815             flags |= SERIALIZATION_FLAG_HAS_VALUE;
816         }
817         if (runDirectionValue == RunDirectionEnum.RTL)
818         {
819             flags |= SERIALIZATION_FLAG_RTL;
820         }
821         if (hyperlinkOmitted)
822         {
823             flags |= SERIALIZATION_FLAG_HYPERLINK_OMITTED;
824         }
825         
826         out.writeIntCompressed(flags);
827         
828         out.writeJRObject(text);
829         if (hasValue)
830         {
831             out.writeJRObject(value);
832         }
833         
834         //FIXME these usually repeat, keep in memory?
835         out.writeFloat(lineSpacingFactor);
836         out.writeFloat(leadingOffset);
837         out.writeFloat(textHeight);
838
839         if (hasTrunc)
840         {
841             out.writeJRObject(textTruncateIndex);
842             out.writeJRObject(textTruncateSuffix);
843         }
844         
845         if (hasLineBreakOffsets && !zeroLineBreakOffsets)
846         {
847             out.writeIntCompressed(lineBreakOffsets.length);
848             for (short offset : lineBreakOffsets)
849             {
850                 out.writeIntCompressed(offset);
851             }
852         }
853         
854         if (hasAnchor)
855         {
856             out.writeJRObject(anchorName);
857             out.writeIntCompressed(bookmarkLevel);
858         }
859
860         if (hasHyperlink)
861         {
862             out.writeJRObject(hyperlinkReference);
863             out.writeJRObject(hyperlinkAnchor);
864             out.writeJRObject(hyperlinkPage);
865             out.writeJRObject(hyperlinkTooltip);
866             out.writeJRObject(hyperlinkParameters);
867         }
868     }
869
870     @Override
871     public void readVirtualized(VirtualizationInput in) throws IOException
872     {
873         super.readVirtualized(in);
874         
875         int flags = in.readIntCompressed();
876         text = (String) in.readJRObject();
877         
878         if ((flags & SERIALIZATION_FLAG_HAS_VALUE) != 0)
879         {
880             value = in.readJRObject();
881         }
882         else
883         {
884             value = text;
885         }
886         
887         lineSpacingFactor = in.readFloat();
888         leadingOffset = in.readFloat();
889         textHeight = in.readFloat();
890         
891         if ((flags & SERIALIZATION_FLAG_TRUNCATION) != 0)
892         {
893             textTruncateIndex = (Integer) in.readJRObject();
894             textTruncateSuffix = (String) in.readJRObject();
895         }
896         
897         if ((flags & SERIALIZATION_FLAG_LINE_BREAK_OFFSETS) != 0)
898         {
899             if ((flags & SERIALIZATION_FLAG_ZERO_LINE_BREAK_OFFSETS) != 0)
900             {
901                 lineBreakOffsets = JRPrintText.ZERO_LINE_BREAK_OFFSETS;
902             }
903             else
904             {
905                 int offsetCount = in.readIntCompressed();
906                 lineBreakOffsets = new short[offsetCount];
907                 for (int i = 0; i < offsetCount; i++)
908                 {
909                     lineBreakOffsets[i] = (short) in.readIntCompressed();
910                 }
911             }
912         }
913         
914         if ((flags & SERIALIZATION_FLAG_ANCHOR) != 0)
915         {
916             anchorName = (String) in.readJRObject();
917             bookmarkLevel = in.readIntCompressed();
918         }
919         else
920         {
921             bookmarkLevel = JRAnchor.NO_BOOKMARK;
922         }
923         
924         if ((flags & SERIALIZATION_FLAG_HYPERLINK_OMITTED) != 0)
925         {
926             hyperlinkOmitted = true;
927         }
928
929         if ((flags & SERIALIZATION_FLAG_HYPERLINK) != 0)
930         {
931             hyperlinkReference = (String) in.readJRObject();
932             hyperlinkAnchor = (String) in.readJRObject();
933             hyperlinkPage = (Integer) in.readJRObject();
934             hyperlinkTooltip = (String) in.readJRObject();
935             hyperlinkParameters = (JRPrintHyperlinkParameters) in.readJRObject();
936         }
937         
938         runDirectionValue = (flags & SERIALIZATION_FLAG_RTL) != 0 ? RunDirectionEnum.RTL : RunDirectionEnum.LTR;
939         
940         PSEUDO_SERIAL_VERSION_UID = JRConstants.PSEUDO_SERIAL_VERSION_UID;
941     }
942     
943 }
944