001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.model;
015:
016: import org.gjt.xpp.XmlPullNode;
017: import org.jetbrains.annotations.NotNull;
018: import org.jetbrains.annotations.Nullable;
019: import org.pentaho.reportdesigner.crm.report.GraphicsContext;
020: import org.pentaho.reportdesigner.crm.report.PropertyKeys;
021: import org.pentaho.reportdesigner.crm.report.model.functions.ExpressionRegistry;
022: import org.pentaho.reportdesigner.crm.report.model.textlayout.TextParagraph;
023: import org.pentaho.reportdesigner.lib.client.undo.Undo;
024: import org.pentaho.reportdesigner.lib.client.undo.UndoEntry;
025: import org.pentaho.reportdesigner.lib.client.util.UncaughtExcpetionsModel;
026: import org.pentaho.reportdesigner.lib.common.xml.ObjectConverterFactory;
027: import org.pentaho.reportdesigner.lib.common.xml.XMLConstants;
028: import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
029: import org.pentaho.reportdesigner.lib.common.xml.XMLUtils;
030: import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
031:
032: import java.awt.*;
033: import java.awt.font.FontRenderContext;
034: import java.awt.font.LineBreakMeasurer;
035: import java.awt.font.TextAttribute;
036: import java.awt.font.TextLayout;
037: import java.awt.geom.Ellipse2D;
038: import java.awt.geom.Line2D;
039: import java.awt.geom.Rectangle2D;
040: import java.io.IOException;
041: import java.text.AttributedCharacterIterator;
042: import java.text.AttributedString;
043: import java.util.ArrayList;
044:
045: /**
046: * User: Martin
047: * Date: 20.10.2005
048: * Time: 15:40:13
049: */
050: public abstract class TextReportElement extends ReportElement {
051: @NotNull
052: public static final String DEFAULT_FONT = "dialog";
053:
054: @NotNull
055: private Font font;
056: @NotNull
057: private Color foreground;
058:
059: private boolean underline;
060: private boolean strikethrough;
061: private boolean embedFont;
062: private double lineHeight;
063: @Nullable
064: private TextReportElementVerticalAlignment verticalAlignment;
065: @Nullable
066: private TextReportElementHorizontalAlignment horizontalAlignment;
067: @Nullable
068: private String reservedLiteral;
069: private boolean trimTextContent;
070: private boolean wrapTextInExcel;
071: @Nullable
072: private String encoding;
073: public static final double TOLERANCE = 0.01;
074:
075: public TextReportElement() {
076: this (new Font(DEFAULT_FONT, Font.PLAIN, 12));
077: trimTextContent = true;
078: }
079:
080: public TextReportElement(@NotNull
081: Font font) {
082: //noinspection ConstantConditions
083: if (font == null) {
084: throw new IllegalArgumentException("font must not be null");
085: }
086:
087: this .font = font;
088: foreground = Color.BLACK;
089:
090: verticalAlignment = TextReportElementVerticalAlignment.TOP;
091: horizontalAlignment = TextReportElementHorizontalAlignment.LEFT;
092:
093: lineHeight = 0;
094:
095: reservedLiteral = "..";
096:
097: trimTextContent = true;
098:
099: textParagraphs = new ArrayList<TextParagraph>();
100: previousPaintText = "";
101: }
102:
103: @NotNull
104: public Font getFont() {
105: return font;
106: }
107:
108: public void setFont(@NotNull
109: final Font font) {
110: //noinspection ConstantConditions
111: if (font == null) {
112: throw new IllegalArgumentException("font must not be null");
113: }
114:
115: final Font oldFont = this .font;
116: this .font = font;
117:
118: Undo undo = getUndo();
119: if (undo != null && !undo.isInProgress()) {
120: undo.startTransaction(PropertyKeys.FONT);
121: undo.add(new UndoEntry() {
122: public void undo() {
123: setFont(oldFont);
124: }
125:
126: public void redo() {
127: setFont(font);
128: }
129: });
130: undo.endTransaction();
131: }
132:
133: firePropertyChange(PropertyKeys.FONT, oldFont, font);
134: }
135:
136: @NotNull
137: public Color getForeground() {
138: return foreground;
139: }
140:
141: public void setForeground(@NotNull
142: final Color foreground) {
143: //noinspection ConstantConditions
144: if (foreground == null) {
145: throw new IllegalArgumentException(
146: "foreground must not be null");
147: }
148:
149: final Color oldForeground = this .foreground;
150: this .foreground = foreground;
151:
152: Undo undo = getUndo();
153: if (undo != null && !undo.isInProgress()) {
154: undo.startTransaction(PropertyKeys.FOREGROUND);
155: undo.add(new UndoEntry() {
156: public void undo() {
157: setForeground(oldForeground);
158: }
159:
160: public void redo() {
161: setForeground(foreground);
162: }
163: });
164: undo.endTransaction();
165: }
166:
167: firePropertyChange(PropertyKeys.FOREGROUND, oldForeground,
168: foreground);
169: }
170:
171: public boolean isUnderline() {
172: return underline;
173: }
174:
175: public void setUnderline(final boolean underline) {
176: final boolean oldUnderline = this .underline;
177: this .underline = underline;
178:
179: Undo undo = getUndo();
180: if (undo != null && !undo.isInProgress()) {
181: undo.startTransaction(PropertyKeys.UNDERLINE);
182: undo.add(new UndoEntry() {
183: public void undo() {
184: setUnderline(oldUnderline);
185: }
186:
187: public void redo() {
188: setUnderline(underline);
189: }
190: });
191: undo.endTransaction();
192: }
193:
194: firePropertyChange(PropertyKeys.UNDERLINE, oldUnderline,
195: underline);
196: }
197:
198: public boolean isStrikethrough() {
199: return strikethrough;
200: }
201:
202: public void setStrikethrough(final boolean strikethrough) {
203: final boolean oldStrikethrough = this .strikethrough;
204: this .strikethrough = strikethrough;
205:
206: Undo undo = getUndo();
207: if (undo != null && !undo.isInProgress()) {
208: undo.startTransaction(PropertyKeys.STRIKETHROUGH);
209: undo.add(new UndoEntry() {
210: public void undo() {
211: setStrikethrough(oldStrikethrough);
212: }
213:
214: public void redo() {
215: setStrikethrough(strikethrough);
216: }
217: });
218: undo.endTransaction();
219: }
220:
221: firePropertyChange(PropertyKeys.STRIKETHROUGH,
222: oldStrikethrough, strikethrough);
223: }
224:
225: public boolean isEmbedFont() {
226: return embedFont;
227: }
228:
229: public void setEmbedFont(final boolean embedFont) {
230: final boolean oldEmbedFont = this .embedFont;
231: this .embedFont = embedFont;
232:
233: Undo undo = getUndo();
234: if (undo != null && !undo.isInProgress()) {
235: undo.startTransaction(PropertyKeys.EMBED_FONT);
236: undo.add(new UndoEntry() {
237: public void undo() {
238: setEmbedFont(oldEmbedFont);
239: }
240:
241: public void redo() {
242: setEmbedFont(embedFont);
243: }
244: });
245: undo.endTransaction();
246: }
247:
248: firePropertyChange(PropertyKeys.EMBED_FONT, oldEmbedFont,
249: embedFont);
250: }
251:
252: public double getLineHeight() {
253: return lineHeight;
254: }
255:
256: public void setLineHeight(final double lineHeight) {
257: final double oldLineHeight = this .lineHeight;
258: this .lineHeight = lineHeight;
259:
260: Undo undo = getUndo();
261: if (undo != null && !undo.isInProgress()) {
262: undo.startTransaction(PropertyKeys.LINE_HEIGHT);
263: undo.add(new UndoEntry() {
264: public void undo() {
265: setLineHeight(oldLineHeight);
266: }
267:
268: public void redo() {
269: setLineHeight(lineHeight);
270: }
271: });
272: undo.endTransaction();
273: }
274:
275: firePropertyChange(PropertyKeys.LINE_HEIGHT, oldLineHeight,
276: lineHeight);
277: }
278:
279: @Nullable
280: public TextReportElementVerticalAlignment getVerticalAlignment() {
281: return verticalAlignment;
282: }
283:
284: public void setVerticalAlignment(@Nullable
285: final TextReportElementVerticalAlignment verticalAlignment) {
286: final TextReportElementVerticalAlignment oldVerticalAlignment = this .verticalAlignment;
287: this .verticalAlignment = verticalAlignment;
288:
289: Undo undo = getUndo();
290: if (undo != null && !undo.isInProgress()) {
291: undo.startTransaction(PropertyKeys.VERTICAL_ALIGNMENT);
292: undo.add(new UndoEntry() {
293: public void undo() {
294: setVerticalAlignment(oldVerticalAlignment);
295: }
296:
297: public void redo() {
298: setVerticalAlignment(verticalAlignment);
299: }
300: });
301: undo.endTransaction();
302: }
303:
304: firePropertyChange(PropertyKeys.VERTICAL_ALIGNMENT,
305: oldVerticalAlignment, verticalAlignment);
306: }
307:
308: @Nullable
309: public TextReportElementHorizontalAlignment getHorizontalAlignment() {
310: return horizontalAlignment;
311: }
312:
313: public void setHorizontalAlignment(@Nullable
314: final TextReportElementHorizontalAlignment horizontalAlignment) {
315: final TextReportElementHorizontalAlignment oldHorizontalAlignment = this .horizontalAlignment;
316: this .horizontalAlignment = horizontalAlignment;
317:
318: Undo undo = getUndo();
319: if (undo != null && !undo.isInProgress()) {
320: undo.startTransaction(PropertyKeys.HORIZONTAL_ALIGNMENT);
321: undo.add(new UndoEntry() {
322: public void undo() {
323: setHorizontalAlignment(oldHorizontalAlignment);
324: }
325:
326: public void redo() {
327: setHorizontalAlignment(horizontalAlignment);
328: }
329: });
330: undo.endTransaction();
331: }
332:
333: firePropertyChange(PropertyKeys.HORIZONTAL_ALIGNMENT,
334: oldHorizontalAlignment, horizontalAlignment);
335: }
336:
337: @Nullable
338: public String getReservedLiteral() {
339: return reservedLiteral;
340: }
341:
342: public void setReservedLiteral(@Nullable
343: final String reservedLiteral) {
344: final String oldReservedLiteral = this .reservedLiteral;
345: this .reservedLiteral = reservedLiteral;
346:
347: Undo undo = getUndo();
348: if (undo != null && !undo.isInProgress()) {
349: undo.startTransaction(PropertyKeys.RESERVED_LITERAL);
350: undo.add(new UndoEntry() {
351: public void undo() {
352: setReservedLiteral(oldReservedLiteral);
353: }
354:
355: public void redo() {
356: setReservedLiteral(reservedLiteral);
357: }
358: });
359: undo.endTransaction();
360: }
361:
362: firePropertyChange(PropertyKeys.RESERVED_LITERAL,
363: oldReservedLiteral, reservedLiteral);
364: }
365:
366: public boolean isTrimTextContent() {
367: return trimTextContent;
368: }
369:
370: public void setTrimTextContent(final boolean trimTextContent) {
371: final boolean oldTrimTextContent = this .trimTextContent;
372: this .trimTextContent = trimTextContent;
373:
374: Undo undo = getUndo();
375: if (undo != null && !undo.isInProgress()) {
376: undo.startTransaction(PropertyKeys.TRIM_TEXT_CONTENT);
377: undo.add(new UndoEntry() {
378: public void undo() {
379: setTrimTextContent(oldTrimTextContent);
380: }
381:
382: public void redo() {
383: setTrimTextContent(trimTextContent);
384: }
385: });
386: undo.endTransaction();
387: }
388:
389: firePropertyChange(PropertyKeys.TRIM_TEXT_CONTENT,
390: oldTrimTextContent, trimTextContent);
391: }
392:
393: public boolean isWrapTextInExcel() {
394: return wrapTextInExcel;
395: }
396:
397: public void setWrapTextInExcel(final boolean wrapTextInExcel) {
398: final boolean oldWrapTextInExcel = this .wrapTextInExcel;
399: this .wrapTextInExcel = wrapTextInExcel;
400:
401: Undo undo = getUndo();
402: if (undo != null && !undo.isInProgress()) {
403: undo.startTransaction(PropertyKeys.WRAP_TEXT_IN_EXCEL);
404: undo.add(new UndoEntry() {
405: public void undo() {
406: setWrapTextInExcel(oldWrapTextInExcel);
407: }
408:
409: public void redo() {
410: setWrapTextInExcel(wrapTextInExcel);
411: }
412: });
413: undo.endTransaction();
414: }
415:
416: firePropertyChange(PropertyKeys.WRAP_TEXT_IN_EXCEL,
417: oldWrapTextInExcel, wrapTextInExcel);
418: }
419:
420: @Nullable
421: public String getEncoding() {
422: return encoding;
423: }
424:
425: public void setEncoding(@Nullable
426: final String encoding) {
427: final String oldEncoding = this .encoding;
428: this .encoding = encoding;
429:
430: Undo undo = getUndo();
431: if (undo != null && !undo.isInProgress()) {
432: undo.startTransaction(PropertyKeys.ENCODING);
433: undo.add(new UndoEntry() {
434: public void undo() {
435: setEncoding(oldEncoding);
436: }
437:
438: public void redo() {
439: setEncoding(encoding);
440: }
441: });
442: undo.endTransaction();
443: }
444:
445: firePropertyChange(PropertyKeys.ENCODING, oldEncoding, encoding);
446: }
447:
448: @NotNull
449: public String getPaintText() {
450: return getName();
451: }
452:
453: @NotNull
454: private String previousPaintText;
455: @NotNull
456: private ArrayList<TextParagraph> textParagraphs;
457:
458: public void paint(@NotNull
459: GraphicsContext graphicsContext, @NotNull
460: Graphics2D g2d) {
461: Font origFont = g2d.getFont();
462: Shape origClip = g2d.getClip();
463: Color origColor = g2d.getColor();
464: Composite origComposite = g2d.getComposite();
465:
466: Font font = getFont();
467: g2d.setFont(font);
468:
469: Rectangle2D.Double rect = getRectangle();
470:
471: g2d.clip(new Rectangle2D.Double(rect.x, rect.y, rect.width + 1,
472: rect.height + 1));
473: paintBackroundAndBorder(g2d);
474:
475: g2d.clip(rect);
476:
477: g2d.setColor(foreground);
478:
479: String paintText = getPaintText();
480: if (!paintText.equals(previousPaintText)) {
481: previousPaintText = paintText;
482: textParagraphs = TextParagraph.breakStringIntoParagraphs(
483: paintText, false);
484: }
485:
486: Rectangle2D.Double contentRectangle = getContentRectangle();
487: paintText(textParagraphs, g2d, contentRectangle);
488:
489: if (isDynamicContent()) {
490: Object origAntialias = g2d
491: .getRenderingHint(RenderingHints.KEY_ANTIALIASING);
492: g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
493: RenderingHints.VALUE_ANTIALIAS_ON);
494:
495: g2d.setComposite(AlphaComposite.getInstance(
496: AlphaComposite.SRC_OVER, 0.7f));
497:
498: double x = rect.x + rect.width - 25;
499: double y = rect.y + rect.height - 25;
500:
501: Ellipse2D.Double ellipse = new Ellipse2D.Double(x + 10,
502: y + 10, 12, 12);
503:
504: g2d.setColor(Color.WHITE);
505: g2d.fill(ellipse);
506: g2d.setColor(Color.BLACK);
507: g2d.draw(ellipse);
508: g2d.setColor(Color.BLACK);
509:
510: Line2D.Double line = new Line2D.Double(x + 10 + 6, y + 12,
511: x + 10 + 6, y + 20);
512: Line2D.Double line2 = new Line2D.Double(x + 10 + 3,
513: y + 20 - 3, x + 10 + 6, y + 20);
514: Line2D.Double line3 = new Line2D.Double(x + 10 + 6 + 3,
515: y + 20 - 3, x + 10 + 6, y + 20);
516:
517: g2d.draw(line);
518: g2d.draw(line2);
519: g2d.draw(line3);
520:
521: g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
522: origAntialias);
523: }
524:
525: g2d.setComposite(origComposite);
526: g2d.setColor(origColor);
527: g2d.setClip(origClip);
528: g2d.setFont(origFont);
529: }
530:
531: private void paintText(@NotNull
532: ArrayList<TextParagraph> textParagraphs, @NotNull
533: Graphics2D g2d, @NotNull
534: Rectangle2D.Double rect) {
535: try {
536: double heigth;
537:
538: FontRenderContext frc = g2d.getFontRenderContext();
539:
540: float wrappingWidth = (float) (rect.getWidth());
541:
542: float penY = (float) rect.getY();
543:
544: ArrayList<TextLayout> preparedTextLayouts = new ArrayList<TextLayout>();
545: Rectangle2D charBounds;
546: if (getReport() != null && getReport().isUseMaxCharBounds()) {
547: charBounds = font.getMaxCharBounds(frc);
548: } else {
549: charBounds = new Rectangle2D.Double(0, -font.getSize(),
550: 0, font.getSize());
551: }
552:
553: for (TextParagraph textParagraph : textParagraphs) {
554: if (textParagraph.getContent().length() == 0) {
555: preparedTextLayouts.add(null);
556: penY += -charBounds.getY();
557: if (penY
558: + Math.max(charBounds.getHeight(),
559: lineHeight) + charBounds.getY() > rect
560: .getY()
561: + rect.getHeight()) {
562: continue;
563: } else {
564: penY += Math.max(charBounds.getHeight(),
565: lineHeight)
566: + charBounds.getY();//getY()=-40.21844, getHeight()=50.3125
567: continue;
568: }
569: }
570: AttributedString attributedString = new AttributedString(
571: textParagraph.getContent(), font
572: .getAttributes());
573: if (underline) {
574: attributedString.addAttribute(
575: TextAttribute.UNDERLINE,
576: TextAttribute.UNDERLINE_ON);
577: }
578: if (strikethrough) {
579: attributedString.addAttribute(
580: TextAttribute.STRIKETHROUGH,
581: TextAttribute.STRIKETHROUGH_ON);
582: }
583:
584: AttributedCharacterIterator styledText = attributedString
585: .getIterator();
586: LineBreakMeasurer measurer = new LineBreakMeasurer(
587: styledText, frc);
588:
589: double lineHeight = getLineHeight();
590:
591: while (measurer.getPosition() < textParagraph
592: .getContent().length()) {
593: TextLayout layout = measurer
594: .nextLayout(wrappingWidth);
595:
596: penY += -charBounds.getY();
597: if (penY
598: + Math.max(charBounds.getHeight(),
599: lineHeight) + charBounds.getY() > rect
600: .getY()
601: + rect.getHeight()) {
602: penY -= -charBounds.getY();
603: break;
604: }
605: penY += Math
606: .max(charBounds.getHeight(), lineHeight)
607: + charBounds.getY();//getY()=-40.21844, getHeight()=50.3125
608: if (penY > (rect.getY() + rect.getHeight())) {
609: penY -= Math.max(charBounds.getHeight(),
610: lineHeight)
611: + charBounds.getY();//getY()=-40.21844, getHeight()=50.3125
612: break;
613: }
614:
615: preparedTextLayouts.add(layout);
616: }
617: }
618:
619: heigth = penY - rect.getY();
620:
621: //paint
622: float penX = (float) rect.getX();
623: penY = (float) rect.getY();
624: if (getVerticalAlignment() == TextReportElementVerticalAlignment.MIDDLE) {
625: penY += ((rect.getHeight() - heigth) / 2);
626: } else if (getVerticalAlignment() == TextReportElementVerticalAlignment.BOTTOM) {
627: penY += (rect.getHeight() - heigth);
628: }
629:
630: double lineHeight = getLineHeight();
631:
632: for (TextLayout layout : preparedTextLayouts) {
633: penY += -charBounds.getY();
634:
635: float x = penX;
636: if (layout != null) {
637: double width = layout.getBounds().getWidth();
638: if (horizontalAlignment == TextReportElementHorizontalAlignment.RIGHT) {
639: x = (float) (penX + rect.getWidth() - 1 - width);
640: } else if (horizontalAlignment == TextReportElementHorizontalAlignment.CENTER) {
641: x = (float) (((penX + rect.getWidth() - 1 - width) + penX) / 2);
642: }
643: }
644:
645: double ySpaceUsed = penY
646: + Math.max(charBounds.getHeight(), lineHeight)
647: + charBounds.getY();
648: double yAllowed = rect.getY() + rect.getHeight();
649:
650: //TOLERANCE is used for bottom aligned text. When BottomAligned Text is used ySpaceUsed==yAllowed.
651: //Then in depends on the roundoff error if the text is drawn or not->BAD
652: //To overcome this problem we increase yAllowed a little bit
653: if (ySpaceUsed > yAllowed + TOLERANCE
654: && !isDynamicContent()) {
655: break;
656: }
657: if (layout != null) {
658: layout.draw(g2d, x, penY);
659: }
660:
661: penY += Math.max(charBounds.getHeight(), lineHeight)
662: + charBounds.getY();
663:
664: if (penY > (rect.getY() + rect.getHeight())
665: && !isDynamicContent()) {
666: break;
667: }
668: }
669: } catch (Exception e) {
670: UncaughtExcpetionsModel.getInstance().addException(e);
671: }
672: }
673:
674: protected void externalizeElements(@NotNull
675: XMLWriter xmlWriter, @NotNull
676: XMLContext xmlContext) throws IOException {
677: super .externalizeElements(xmlWriter, xmlContext);
678:
679: xmlWriter.writeProperty(PropertyKeys.FONT,
680: ObjectConverterFactory.getInstance().getFontConverter()
681: .getString(font));
682:
683: xmlWriter.writeProperty(PropertyKeys.FOREGROUND,
684: ObjectConverterFactory.getInstance()
685: .getColorConverter().getString(foreground));
686: xmlWriter.writeProperty(PropertyKeys.UNDERLINE, String
687: .valueOf(underline));
688: xmlWriter.writeProperty(PropertyKeys.STRIKETHROUGH, String
689: .valueOf(strikethrough));
690: xmlWriter.writeProperty(PropertyKeys.EMBED_FONT, String
691: .valueOf(embedFont));
692: xmlWriter.writeProperty(PropertyKeys.LINE_HEIGHT, String
693: .valueOf(lineHeight));
694: if (verticalAlignment != null) {
695: xmlWriter.writeProperty(PropertyKeys.VERTICAL_ALIGNMENT,
696: String.valueOf(verticalAlignment));
697: }
698: if (horizontalAlignment != null) {
699: xmlWriter.writeProperty(PropertyKeys.HORIZONTAL_ALIGNMENT,
700: String.valueOf(horizontalAlignment));
701: }
702:
703: if (reservedLiteral != null) {
704: xmlWriter.writeProperty(PropertyKeys.RESERVED_LITERAL,
705: reservedLiteral);
706: }
707: xmlWriter.writeProperty(PropertyKeys.TRIM_TEXT_CONTENT, String
708: .valueOf(trimTextContent));
709: xmlWriter.writeProperty(PropertyKeys.WRAP_TEXT_IN_EXCEL, String
710: .valueOf(wrapTextInExcel));
711:
712: if (encoding != null) {
713: xmlWriter.writeProperty(PropertyKeys.ENCODING, encoding);
714: }
715: }
716:
717: protected void readElement(@NotNull
718: ExpressionRegistry expressions, @NotNull
719: XmlPullNode node, @NotNull
720: XMLContext xmlContext) throws Exception {
721: super.readElement(expressions, node, xmlContext);
722:
723: if (XMLConstants.PROPERTY.equals(node.getRawName())
724: && PropertyKeys.FONT
725: .equals(node
726: .getAttributeValueFromRawName(XMLConstants.NAME))) {
727: font = ObjectConverterFactory.getInstance()
728: .getFontConverter().getObject(
729: XMLUtils.readProperty(PropertyKeys.FONT,
730: node));
731: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
732: && PropertyKeys.FOREGROUND
733: .equals(node
734: .getAttributeValueFromRawName(XMLConstants.NAME))) {
735: foreground = ObjectConverterFactory.getInstance()
736: .getColorConverter().getObject(
737: XMLUtils.readProperty(
738: PropertyKeys.FOREGROUND, node));
739: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
740: && PropertyKeys.UNDERLINE
741: .equals(node
742: .getAttributeValueFromRawName(XMLConstants.NAME))) {
743: underline = Boolean.parseBoolean(XMLUtils.readProperty(
744: PropertyKeys.UNDERLINE, node));
745: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
746: && PropertyKeys.STRIKETHROUGH
747: .equals(node
748: .getAttributeValueFromRawName(XMLConstants.NAME))) {
749: strikethrough = Boolean.parseBoolean(XMLUtils.readProperty(
750: PropertyKeys.STRIKETHROUGH, node));
751: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
752: && PropertyKeys.EMBED_FONT
753: .equals(node
754: .getAttributeValueFromRawName(XMLConstants.NAME))) {
755: embedFont = Boolean.parseBoolean(XMLUtils.readProperty(
756: PropertyKeys.EMBED_FONT, node));
757: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
758: && PropertyKeys.LINE_HEIGHT
759: .equals(node
760: .getAttributeValueFromRawName(XMLConstants.NAME))) {
761: lineHeight = Double.parseDouble(XMLUtils.readProperty(
762: PropertyKeys.LINE_HEIGHT, node));
763: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
764: && PropertyKeys.VERTICAL_ALIGNMENT
765: .equals(node
766: .getAttributeValueFromRawName(XMLConstants.NAME))) {
767: verticalAlignment = TextReportElementVerticalAlignment
768: .valueOf(XMLUtils.readProperty(
769: PropertyKeys.VERTICAL_ALIGNMENT, node));
770: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
771: && PropertyKeys.HORIZONTAL_ALIGNMENT
772: .equals(node
773: .getAttributeValueFromRawName(XMLConstants.NAME))) {
774: horizontalAlignment = TextReportElementHorizontalAlignment
775: .valueOf(XMLUtils.readProperty(
776: PropertyKeys.HORIZONTAL_ALIGNMENT, node));
777: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
778: && PropertyKeys.RESERVED_LITERAL
779: .equals(node
780: .getAttributeValueFromRawName(XMLConstants.NAME))) {
781: reservedLiteral = XMLUtils.readProperty(
782: PropertyKeys.RESERVED_LITERAL, node);
783: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
784: && PropertyKeys.TRIM_TEXT_CONTENT
785: .equals(node
786: .getAttributeValueFromRawName(XMLConstants.NAME))) {
787: trimTextContent = Boolean
788: .parseBoolean(XMLUtils.readProperty(
789: PropertyKeys.TRIM_TEXT_CONTENT, node));
790: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
791: && PropertyKeys.WRAP_TEXT_IN_EXCEL
792: .equals(node
793: .getAttributeValueFromRawName(XMLConstants.NAME))) {
794: wrapTextInExcel = Boolean
795: .parseBoolean(XMLUtils.readProperty(
796: PropertyKeys.WRAP_TEXT_IN_EXCEL, node));
797: } else if (XMLConstants.PROPERTY.equals(node.getRawName())
798: && PropertyKeys.ENCODING
799: .equals(node
800: .getAttributeValueFromRawName(XMLConstants.NAME))) {
801: encoding = XMLUtils.readProperty(PropertyKeys.ENCODING,
802: node);
803: }
804: }
805:
806: }
|