Java 类net.sf.jasperreports.engine.util.JRStyledText 实例源码

项目:jasperreports    文件:JRBasePrintText.java   
@Override
public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector)
{
    if (getFullText() == null)
    {
        return null;
    }

    return 
        JRStyledTextParser.getInstance().getStyledText(
            attributeSelector.getStyledTextAttributes(this), 
            getFullText(), 
            !JRCommonText.MARKUP_NONE.equals(getMarkup()),
            JRStyledTextAttributeSelector.getTextLocale(this)
            );
}
项目:jasperreports    文件:JRXlsExporter.java   
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale)
{
    String text = styledText.getText();
    HSSFRichTextString richTextStr = new HSSFRichTextString(text);
    int runLimit = 0;
    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        Map<Attribute,Object> attributes = iterator.getAttributes();
        JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
        short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null ? 
                getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() :
                forecolor;
        HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
        richTextStr.applyFont(iterator.getIndex(), runLimit, font);
        iterator.setIndex(runLimit);
    }
    return richTextStr;
}
项目:jasperreports    文件:TableBuilder.java   
/**
 *
 */
protected void exportStyledText(JRStyledText styledText, Locale locale, boolean startedHyperlink, boolean isIgnoreTextFormatting)
{
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        exportStyledTextRun(
            iterator.getAttributes(), 
            text.substring(iterator.getIndex(), runLimit),
            locale,
            startedHyperlink,
            isIgnoreTextFormatting
            );

        iterator.setIndex(runLimit);
    }
}
项目:jasperreports    文件:JRPdfExporter.java   
protected AbstractPdfTextRenderer getTextRenderer(JRPrintText text, JRStyledText styledText)
{
    AbstractPdfTextRenderer textRenderer;
    if (toUseGlyphRenderer(text)
            && PdfGlyphRenderer.supported()
            && canUseGlyphRendering(text, styledText))
    {
        textRenderer = new PdfGlyphRenderer(jasperReportsContext, awtIgnoreMissingFont,
                glyphRendererAddActualText && !tagHelper.isTagged);
    }
    else if (text.getLeadingOffset() == 0)
    {
        textRenderer = new PdfTextRenderer(jasperReportsContext, awtIgnoreMissingFont);
    }
    else
    {
        textRenderer = new SimplePdfTextRenderer(jasperReportsContext, awtIgnoreMissingFont);//FIXMETAB optimize this
    }

    return textRenderer;
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
protected HSSFRichTextString getRichTextString(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale) {
    String text = styledText.getText();
    HSSFRichTextString richTextStr = new HSSFRichTextString(text);
    int runLimit = 0;
    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) {
        Map<Attribute,Object> attributes = iterator.getAttributes();
        JRFont runFont = attributes.isEmpty()? defaultFont : new JRBaseFont(attributes);
        short runForecolor = attributes.get(TextAttribute.FOREGROUND) != null  
            ? getWorkbookColor((Color)attributes.get(TextAttribute.FOREGROUND)).getIndex() 
            : forecolor;
        HSSFFont font = getLoadedFont(runFont, runForecolor, attributes, locale);
        richTextStr.applyFont(iterator.getIndex(), runLimit, font);
        iterator.setIndex(runLimit);
    }
    return richTextStr;
}
项目:jasperreports    文件:AbstractHtmlExporter.java   
@Override
protected JRStyledText getStyledText(JRPrintText textElement, boolean setBackcolor)
{
    JRStyledText styledText = styledTextUtil.getProcessedStyledText(textElement, 
            setBackcolor ? allSelector : noBackcolorSelector, getExporterKey());

    if (styledText != null)
    {
        short[] lineBreakOffsets = textElement.getLineBreakOffsets();
        if (lineBreakOffsets != null && lineBreakOffsets.length > 0)
        {
            //insert new lines at the line break positions saved at fill time
            //cloning the text first
            //FIXME do we need this?  styled text instances are no longer shared
            styledText = styledText.cloneText();
            styledText.insert("\n", lineBreakOffsets);
        }
    }

    return styledText;
}
项目:jasperreports    文件:DrawVisitor.java   
/**
 *
 */
public DrawVisitor(ReportConverter reportConverter, Graphics2D grx)
{
    this.convertVisitor = new ConvertVisitor(reportConverter);

    JasperReportsContext jasperReportsContext = reportConverter.getJasperReportsContext();
    JRReport report = reportConverter.getReport();
    JRPropertiesUtil propUtil = JRPropertiesUtil.getInstance(jasperReportsContext);

    this.drawVisitor = 
        new PrintDrawVisitor(
            jasperReportsContext,
            new RenderersCache(jasperReportsContext),
            propUtil.getBooleanProperty(report, Graphics2DReportConfiguration.MINIMIZE_PRINTER_JOB_SIZE, true),
            propUtil.getBooleanProperty(report, JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false)
            );

    setGraphics2D(grx);
    this.drawVisitor.setClip(true);
}
项目:jasperreports    文件:JRPptxExporter.java   
/**
 *
 */
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale)
{
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        runHelper.export(
            style, 
            iterator.getAttributes(), 
            text.substring(iterator.getIndex(), runLimit),
            locale,
            invalidCharReplacement
            );

        iterator.setIndex(runLimit);
    }
}
项目:jasperreports    文件:JRXlsxExporter.java   
/**
 *
 */
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean isStyledText)
{
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        runHelper.export(
                style, iterator.getAttributes(), 
                text.substring(iterator.getIndex(), runLimit),
                locale,
                invalidCharReplacement,
                isStyledText
                );

        iterator.setIndex(runLimit);
    }
}
项目:jasperreports    文件:JRFillTextElement.java   
/**
 *
 */
protected JRStyledText getStyledText()
{
    if (styledText == null)
    {
        String text = getRawText();
        if (text != null)
        {
            styledText = 
                filler.getStyledTextParser().getStyledText(
                    getStyledTextAttributes(), 
                    text, 
                    !JRCommonText.MARKUP_NONE.equals(getMarkup()),
                    filler.getLocale()
                    );
        }
        processedStyledText = null;
    }

    return styledText;
}
项目:jasperreports    文件:JRTemplatePrintText.java   
@Override
public JRStyledText getFullStyledText(JRStyledTextAttributeSelector attributeSelector)
{
    if (getFullText() == null)
    {
        return null;
    }

    return 
        JRStyledTextParser.getInstance().getStyledText(
            attributeSelector.getStyledTextAttributes(this), 
            getFullText(), 
            !JRCommonText.MARKUP_NONE.equals(getMarkup()),
            JRStyledTextAttributeSelector.getTextLocale(this)
            );
}
项目:jasperreports    文件:LuceneUtil.java   
protected void addContentField(int pageNo, JRPrintText element) throws IOException {
    String allText;
    JRStyledText styledText = getStyledText(element);
    if (styledText == null) {
        allText = "";
    } else {
        allText = styledText.getText();
    }

    if (allText != null && allText.length() > 0) {
        Field tf = new Field(CONTENT_FIELD, allText, fieldType);
        Document doc = new Document();
        doc.add(new IntField("pageNo", pageNo, Field.Store.YES));

        PrintElementId peid = PrintElementId.forElement(element);
        doc.add(new StringField("uid", peid.toString(), Field.Store.YES));

        displayTokens(allText, peid.toString());

        doc.add(tf);
        writer.addDocument(doc);
    }

}
项目:jasperreports    文件:IconLabelElementCsvHandler.java   
@Override
public String getTextValue(JRCsvExporterContext exporterContext, JRGenericPrintElement element)
{
    JRPrintText labelPrintText = (JRPrintText)element.getParameterValue(IconLabelElement.PARAMETER_LABEL_TEXT_ELEMENT);
    if (labelPrintText == null)
    {
        return null;
    }

    String text = null;

    JRStyledText styledText = ((JRCsvExporter)exporterContext.getExporterRef()).getStyledText(labelPrintText);
    if (styledText == null)
    {
        text = "";
    }
    else
    {
        text = styledText.getText();
    }

    return text;
}
项目:PDFReporter-Studio    文件:JSSDrawVisitor.java   
/**
 *
 */
public JSSDrawVisitor(ReportConverter reportConverter, Graphics2D grx) {
    this.reportConverter = reportConverter;
    this.convertVisitor = new JSSConvertVisitor(reportConverter);
    final JasperReportsContext jasperReportsContext = reportConverter.getJasperReportsContext();
    this.drawVisitor = new PrintDrawVisitor(jasperReportsContext) {
        @Override
        public void setTextRenderer(JRReport report) {
            AwtTextRenderer textRenderer = new AwtTextRenderer(jasperReportsContext, JRPropertiesUtil.getInstance(
                    jasperReportsContext).getBooleanProperty(report, JRGraphics2DExporter.MINIMIZE_PRINTER_JOB_SIZE, true),
                    JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(report,
                            JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false));

            setTextDrawer(new TextDrawer(jasperReportsContext, textRenderer));
            setFrameDrawer(new FrameDrawer(jasperReportsContext, null, textRenderer));

        }

    };
    setTextRenderer(reportConverter.getReport());
    this.grx = grx;
    setGraphics2D(grx);
    this.drawVisitor.setClip(true);
}
项目:jasperreports    文件:SimplePdfTextRenderer.java   
/**
 *
 */
protected Phrase getPhrase(JRStyledText styledText, JRPrintText textElement)
{
    String text = styledText.getText();

    AttributedString as = styledText.getAttributedString();

    return pdfExporter.getPhrase(as, text, textElement);
}
项目:jasperreports    文件:JRXlsExporter.java   
protected final void setRichTextStringCellValue(JRStyledText styledText, short forecolor, JRFont defaultFont, Locale locale)
{   
    if(styledText != null)
    {
        cell.setCellValue(getRichTextString(styledText, forecolor, defaultFont, locale));
    }
}
项目:jasperreports    文件:TableBuilder.java   
/**
 *
 */
protected void exportStyledText(JRPrintText text, boolean startedHyperlink, boolean isIgnoreTextFormatting)
{
    JRStyledText styledText = documentBuilder.getStyledText(text);
    if (styledText != null && styledText.length() > 0)
    {
        exportStyledText(styledText, documentBuilder.getTextLocale(text), startedHyperlink, isIgnoreTextFormatting);
    }
}
项目:jasperreports    文件:JRPdfExporter.java   
@Override
protected void initExport()
{
    super.initExport();

    PdfExporterConfiguration configuration = getCurrentConfiguration();

    Boolean isTagged = configuration.isTagged();
    if (isTagged != null)
    {
        tagHelper.setTagged(isTagged); 
    }

    tagHelper.setLanguage(configuration.getTagLanguage()); 

    this.permissions = getIntegerPermissions(configuration.getAllowedPermissions()) & (~getIntegerPermissions(configuration.getDeniedPermissions()));
    crtDocumentPageNumber = 0;

    awtIgnoreMissingFont = getPropertiesUtil().getBooleanProperty(
            JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT);//FIXMECONTEXT replace with getPropertiesUtil in all exporters

    glyphRendererAddActualText = propertiesUtil.getBooleanProperty( 
            PdfReportConfiguration.PROPERTY_GLYPH_RENDERER_ADD_ACTUAL_TEXT, false);
    if (glyphRendererAddActualText && !tagHelper.isTagged && PdfGlyphRenderer.supported())
    {
        minimalVersion = PdfVersionEnum.VERSION_1_5;
    }
}
项目:jasperreports    文件:JRPdfExporter.java   
protected boolean canUseGlyphRendering(JRPrintText text, JRStyledText styledText)
{
    Locale locale = getTextLocale(text);
    AttributedCharacterIterator attributesIterator = styledText.getAttributedString().getIterator();
    int index = 0;
    while (index < styledText.length())
    {
        FontKey fontKey = extractFontKey(attributesIterator.getAttributes(), locale);
        if (!fontKey.fontAttribute.hasAttribute())
        {
            return false;
        }

        Boolean canUse = glyphRendererFonts.get(fontKey);
        if (canUse == null)
        {
            canUse = canUseGlyphRendering(fontKey);
            glyphRendererFonts.put(fontKey, canUse);
        }

        if (!canUse)
        {
            return false;
        }

        index = attributesIterator.getRunLimit();
        attributesIterator.setIndex(index);
    }
    return true;
}
项目:jasperreports    文件:HtmlExporter.java   
private void addSearchAttributes(JRStyledText styledText, JRPrintText textElement) {
    ReportContext reportContext = getReportContext();
    if (reportContext != null) {
        SpansInfo spansInfo = (SpansInfo) reportContext.getParameterValue("net.sf.jasperreports.search.term.highlighter");
        PrintElementId pei = PrintElementId.forElement(textElement);

        if (spansInfo != null && spansInfo.hasHitTermsInfo(pei.toString())) {
            List<HitTermInfo> hitTermInfos = JRCloneUtils.cloneList(spansInfo.getHitTermsInfo(pei.toString()));

            short[] lineBreakOffsets = textElement.getLineBreakOffsets();
            if (lineBreakOffsets != null && lineBreakOffsets.length > 0) {
                int sz = lineBreakOffsets.length;
                for (HitTermInfo ti: hitTermInfos) {
                    for (int i = 0; i < sz; i++) {
                        if (lineBreakOffsets[i] <= ti.getStart()) {
                            ti.setStart(ti.getStart() + 1);
                            ti.setEnd(ti.getEnd() + 1);
                        } else {
                            break;
                        }
                    }
                }
            }

            AttributedString attributedString = styledText.getAttributedString();
            for (int i = 0, ln = hitTermInfos.size(); i < ln; i = i + spansInfo.getTermsPerQuery()) {
                attributedString.addAttribute(JRTextAttribute.SEARCH_HIGHLIGHT, Color.yellow, hitTermInfos.get(i).getStart(), hitTermInfos.get(i + spansInfo.getTermsPerQuery() - 1).getEnd());
            }
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("No ReportContext to hold search data!");
        }
    }
}
项目:jasperreports    文件:PrintDrawVisitor.java   
/**
 * @deprecated Replaced by {@link #PrintDrawVisitor(JasperReportsContext, RenderersCache, boolean, boolean)}.
 */
public void setTextRenderer(JRReport report)
{
    AwtTextRenderer textRenderer = 
        new AwtTextRenderer(
            jasperReportsContext,
            JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(report, Graphics2DReportConfiguration.MINIMIZE_PRINTER_JOB_SIZE, true),
            JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(report, JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false)
            );

    textDrawer = new TextDrawer(jasperReportsContext, textRenderer);
    frameDrawer = new FrameDrawer(jasperReportsContext, null, textRenderer);
}
项目:jasperreports    文件:AwtTextRenderer.java   
/**
 * 
 */
public void initialize(Graphics2D grx, JRPrintText text, int offsetX, int offsetY)
{
    JRStyledText styledText = styledTextUtil.getProcessedStyledText(text, noBackcolorSelector, null);
    if (styledText == null)
    {
        return;
    }

    this.grx = grx;

    super.initialize(text, styledText, offsetX, offsetY);
}
项目:jasperreports    文件:JRXlsAbstractExporter.java   
@Override
protected JRStyledText getStyledText(JRPrintText textElement)
{
    JRStyledTextAttributeSelector selector = textElement.getModeValue() == ModeEnum.OPAQUE 
            ? allSelector 
            : noBackcolorSelector;
    return textElement.getFullStyledText(selector);
}
项目:jasperreports    文件:JRFillTextElement.java   
protected JRStyledText getProcessedStyledText()
{
    if (processedStyledText == null)
    {
        JRStyledText text = getStyledText();
        if (text != null)
        {
            processedStyledText = filler.getStyledTextUtil().resolveFonts(text, filler.getLocale());
        }
    }
    return processedStyledText;
}
项目:jasperreports    文件:JRFillTextElement.java   
/**
 *
 */
public String getText()
{
    JRStyledText tmpStyledText = getStyledText();

    if (tmpStyledText == null)
    {
        return null;
    }

    return tmpStyledText.getText();
}
项目:jasperreports    文件:ComplexTextLineWrapper.java   
@Override
public boolean start(JRStyledText styledText)
{
    globalAttributes = styledText.getGlobalAttributes();
    allParagraphs = styledText.getAwtAttributedString(context.getJasperReportsContext(),
            context.isIgnoreMissingFont()).getIterator();
    return true;
}
项目:jasperreports    文件:TextMeasurer.java   
/**
 * 
 */
public TextMeasurer(JasperReportsContext jasperReportsContext, JRCommonText textElement)
{
    this.jasperReportsContext = jasperReportsContext;
    this.textElement = textElement;
    this.propertiesHolder = textElement instanceof JRPropertiesHolder ? (JRPropertiesHolder) textElement : null;//FIXMENOW all elements are now properties holders, so interfaces might be rearranged
    if (textElement.getDefaultStyleProvider() instanceof JRPropertiesHolder)
    {
        this.propertiesHolder = 
            new DelegatePropertiesHolder(
                propertiesHolder, 
                (JRPropertiesHolder)textElement.getDefaultStyleProvider()
                );
    }

    if (textElement instanceof DynamicPropertiesHolder)
    {
        this.dynamicPropertiesHolder = (DynamicPropertiesHolder) textElement;

        // we can check this from the beginning
        this.hasDynamicIgnoreMissingFontProp = this.dynamicPropertiesHolder.hasDynamicProperty(
                JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT);
        this.hasDynamicSaveLineBreakOffsetsProp = this.dynamicPropertiesHolder.hasDynamicProperty(
                JRTextElement.PROPERTY_SAVE_LINE_BREAKS);
    }

    // read static property values
    JRPropertiesUtil propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext);
    defaultIgnoreMissingFont = propertiesUtil.getBooleanProperty(propertiesHolder, 
            JRStyledText.PROPERTY_AWT_IGNORE_MISSING_FONT, false);
    defaultSaveLineBreakOffsets = propertiesUtil.getBooleanProperty(propertiesHolder, 
            JRTextElement.PROPERTY_SAVE_LINE_BREAKS, false);

    Context measureContext = new Context();
    simpleLineWrapper = new SimpleTextLineWrapper();
    simpleLineWrapper.init(measureContext);

    complextLineWrapper = new ComplexTextLineWrapper();
    complextLineWrapper.init(measureContext);
}
项目:jasperreports    文件:JRAbstractExporter.java   
/**
 *
 */
protected JRStyledText getStyledText(JRPrintText textElement, boolean setBackcolor)
{
    return styledTextUtil.getStyledText(textElement, setBackcolor ? allSelector : noBackcolorSelector);
}
项目:jasperreports    文件:JRAbstractExporter.java   
protected JRStyledText getStyledText(JRPrintText textElement)
{
    return getStyledText(textElement, true);
}
项目:jasperreports    文件:JRXlsExporter.java   
@Override
public void exportText(JRPrintText textElement, JRExporterGridCell gridCell, int colIndex, int rowIndex) throws JRException
{
    JRStyledText styledText = getStyledText(textElement);

    if (styledText == null)
    {
        return;
    }

    short forecolor = getWorkbookColor(textElement.getForecolor()).getIndex();

    TextAlignHolder textAlignHolder = getTextAlignHolder(textElement);
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment(textAlignHolder);
    VerticalAlignment verticalAlignment = getVerticalAlignment(textAlignHolder);
    short rotation = getRotation(textAlignHolder);

    FillPatternType mode = backgroundMode;
    short backcolor = whiteIndex;
    if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && gridCell.getCellBackcolor() != null)
    {
        mode = FillPatternType.SOLID_FOREGROUND;
        backcolor = getWorkbookColor(gridCell.getCellBackcolor()).getIndex();
    }

    StyleInfo baseStyle = 
        isIgnoreTextFormatting(textElement) 
        ? new StyleInfo(
            mode,
            whiteIndex,
            horizontalAlignment,
            verticalAlignment,
            (short)0,
            null,
            (JRExporterGridCell)null, 
            isWrapText(textElement) || Boolean.TRUE.equals(((JRXlsExporterNature)nature).getColumnAutoFit(textElement)),
            isCellLocked(textElement),
            isCellHidden(textElement),
            isShrinkToFit(textElement)
            )
        : new StyleInfo(
            mode,
            backcolor,
            horizontalAlignment,
            verticalAlignment,
            rotation,
            getLoadedFont(textElement, forecolor, null, getTextLocale(textElement)),
            gridCell, 
            isWrapText(textElement) || Boolean.TRUE.equals(((JRXlsExporterNature)nature).getColumnAutoFit(textElement)),
            isCellLocked(textElement),
            isCellHidden(textElement),
            isShrinkToFit(textElement)
            );
    createTextCell(textElement, gridCell, colIndex, rowIndex, styledText, baseStyle, forecolor);
}
项目:jasperreports    文件:JROdtExporter.java   
@Override
public JRStyledText getStyledText(JRPrintText text) 
{
    return JROdtExporter.this.getStyledText(text);
}
项目:jasperreports    文件:JROdsExporter.java   
@Override
public JRStyledText getStyledText(JRPrintText text) 
{
    return JROdsExporter.this.getStyledText(text);
}
项目:jasperreports    文件:JROdsExporter.java   
@Override
protected void exportTextContents(JRPrintText textElement)
{
    String href = null;

    String ignLnkPropName = getIgnoreHyperlinkProperty();
    Boolean ignoreHyperlink = HyperlinkUtil.getIgnoreHyperlink(ignLnkPropName, textElement);
    boolean isIgnoreTextFormatting = isIgnoreTextFormatting(textElement);
    if (ignoreHyperlink == null)
    {
        ignoreHyperlink = getPropertiesUtil().getBooleanProperty(jasperPrint, ignLnkPropName, false);
    }

    if (!ignoreHyperlink)
    {
        href = documentBuilder.getHyperlinkURL(textElement, getCurrentItemConfiguration().isOnePagePerSheet());
    }

    if (href == null)
    {
        exportStyledText(textElement, false, isIgnoreTextFormatting);
    }
    else
    {
        JRStyledText styledText = getStyledText(textElement);
        if (styledText != null && styledText.length() > 0)
        {
            String text = styledText.getText();
            Locale locale = getTextLocale(textElement);

            int runLimit = 0;
            AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();
            while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
            {
                // ODS does not like text:span inside text:a
                // writing one text:a inside text:span for each style run
                String runText = text.substring(iterator.getIndex(), runLimit);
                startTextSpan(
                        iterator.getAttributes(), 
                        runText, 
                        locale,
                        isIgnoreTextFormatting);
                writeHyperlink(textElement, href, true);
                writeText(runText);
                endHyperlink(true);
                endTextSpan();
                iterator.setIndex(runLimit);
            }
        }
    }
}
项目:jasperreports    文件:JsonMetadataExporter.java   
@Override
protected JRStyledText getStyledText(JRPrintText textElement)
{
    return textElement.getFullStyledText(noneSelector);
}
项目:jasperreports    文件:HtmlExporter.java   
protected void exportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted) throws IOException
{
    Locale locale = getTextLocale(printText);
    LineSpacingEnum lineSpacing = printText.getParagraph().getLineSpacing();
    Float lineSpacingSize = printText.getParagraph().getLineSpacingSize();
    float lineSpacingFactor = printText.getLineSpacingFactor();
    Color backcolor = printText.getBackcolor();

    String text = styledText.getText();

    int runLimit = 0;

    addSearchAttributes(styledText, printText);

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    boolean first = true;
    boolean startedSpan = false;

    boolean highlightStarted = false;

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        //if there are several text runs, write the tooltip into a parent <span>
        if (first && runLimit < styledText.length() && tooltip != null)
        {
            startedSpan = true;
            writer.write("<span title=\"");
            writer.write(JRStringUtil.xmlEncode(tooltip));
            writer.write("\">");
            //reset the tooltip so that inner <span>s to not use it
            tooltip = null;
        }
        first = false;

        Map<Attribute,Object> attributes = iterator.getAttributes();
        Color highlightColor = (Color) attributes.get(JRTextAttribute.SEARCH_HIGHLIGHT);
        if (highlightColor != null && !highlightStarted) {
            highlightStarted = true;
            writer.write("<span class=\"jr_search_result\">");
        } else if (highlightColor == null && highlightStarted) {
            highlightStarted = false;
            writer.write("</span>");
        }

        exportStyledTextRun(
            attributes,
            text.substring(iterator.getIndex(), runLimit),
            tooltip,
            locale,
            lineSpacing,
            lineSpacingSize,
            lineSpacingFactor,
            backcolor,
            hyperlinkStarted
        );

        iterator.setIndex(runLimit);
    }

    if (highlightStarted) {
        writer.write("</span>");
    }

    if (startedSpan)
    {
        writer.write("</span>");
    }
}
项目:jasperreports    文件:AbstractTextRenderer.java   
/**
 *
 */
public JRStyledText getStyledText()
{
    return styledText;
}
项目:jasperreports    文件:TextDrawer.java   
@Override
    public void draw(Graphics2D grx, JRPrintText text, int offsetX, int offsetY)
    {
        textRenderer.initialize(grx, text, offsetX, offsetY);

        JRStyledText styledText = textRenderer.getStyledText();

        if (styledText == null)
        {
            return;
        }

        double angle = 0;

        switch (text.getRotationValue())
        {
            case LEFT :
            {
                angle = - Math.PI / 2;
                break;
            }
            case RIGHT :
            {
                angle = Math.PI / 2;
                break;
            }
            case UPSIDE_DOWN :
            {
                angle = Math.PI;
                break;
            }
            case NONE :
            default :
            {
            }
        }

        grx.rotate(angle, textRenderer.getX(), textRenderer.getY());

        if (text.getModeValue() == ModeEnum.OPAQUE)
        {
            grx.setColor(text.getBackcolor());
            grx.fillRect(textRenderer.getX(), textRenderer.getY(), textRenderer.getWidth(), textRenderer.getHeight()); 
        }
//      else
//      {
//          /*
//          grx.setColor(text.getForecolor());
//          grx.setStroke(new BasicStroke(1));
//          grx.drawRect(x, y, width, height);
//          */
//      }

        String allText = textRenderer.getPlainText();
        if (allText.length() > 0)
        {
            grx.setColor(text.getForecolor());

            /*   */
            textRenderer.render();
        }

        grx.rotate(-angle, textRenderer.getX(), textRenderer.getY());

        /*   */
        drawBox(grx, text.getLineBox(), text, offsetX, offsetY);
    }
项目:jasperreports    文件:JRXlsAbstractMetadataExporter.java   
@Override
protected JRStyledText getStyledText(JRPrintText textElement)
{
    return textElement.getFullStyledText(noneSelector);
}
项目:jasperreports    文件:JRDocxExporter.java   
/**
     *
     */
    public void exportText(DocxTableHelper tableHelper, JRPrintText text, JRExporterGridCell gridCell)
    {
        tableHelper.getCellHelper().exportHeader(text, gridCell);

        JRStyledText styledText = getStyledText(text);

        int textLength = 0;

        if (styledText != null)
        {
            textLength = styledText.length();
        }

//      if (styleBuffer.length() > 0)
//      {
//          writer.write(" style=\"");
//          writer.write(styleBuffer.toString());
//          writer.write("\"");
//      }
//
//      writer.write(">");
        docHelper.write("     <w:p>\n");

        tableHelper.getParagraphHelper().exportProps(text);
        if (startPage)
        {
            insertBookmark(pageAnchor, docHelper);
        }
        if (text.getAnchorName() != null)
        {
            insertBookmark(text.getAnchorName(), docHelper);
        }

        boolean startedHyperlink = startHyperlink(text, true);
        boolean isNewLineAsParagraph = false;
        if (HorizontalTextAlignEnum.JUSTIFIED.equals(text.getHorizontalTextAlign()))
        {
            if (text.hasProperties() && text.getPropertiesMap().containsProperty(DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH))
            {
                isNewLineAsParagraph = getPropertiesUtil().getBooleanProperty(text, DocxReportConfiguration.PROPERTY_NEW_LINE_AS_PARAGRAPH, false);
            }
            else
            {
                isNewLineAsParagraph = getCurrentItemConfiguration().isNewLineAsParagraph();
            }
        }

        if (textLength > 0)
        {
            exportStyledText(
                getCurrentJasperPrint().getDefaultStyleProvider().getStyleResolver().getBaseStyle(text), 
                styledText, 
                getTextLocale(text),
                getPropertiesUtil().getBooleanProperty(text, PROPERTY_HIDDEN_TEXT, false),
                startedHyperlink, 
                isNewLineAsParagraph
                );
        }

        if (startedHyperlink)
        {
            endHyperlink(true);
        }

        docHelper.write("     </w:p>\n");

        tableHelper.getCellHelper().exportFooter();
    }
项目:jasperreports    文件:JRDocxExporter.java   
/**
 *
 */
protected void exportStyledText(JRStyle style, JRStyledText styledText, Locale locale, boolean hiddenText, boolean startedHyperlink, boolean isNewLineJustified)
{
    Color elementBackcolor = null;
    Map<AttributedCharacterIterator.Attribute, Object> globalAttributes = styledText.getGlobalAttributes();
    if (globalAttributes != null)
    {
        elementBackcolor = (Color)styledText.getGlobalAttributes().get(TextAttribute.BACKGROUND);
    }

    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length())
    {
        Map<Attribute,Object> attributes = iterator.getAttributes();

        boolean localHyperlink = false;

        if (!startedHyperlink)
        {
            JRPrintHyperlink hyperlink = (JRPrintHyperlink)attributes.get(JRTextAttribute.HYPERLINK);
            if (hyperlink != null)
            {
                localHyperlink = startHyperlink(hyperlink, true);
            }
        }

        runHelper.export(
            style, 
            iterator.getAttributes(), 
            text.substring(iterator.getIndex(), runLimit),
            locale,
            hiddenText,
            invalidCharReplacement,
            elementBackcolor,
            isNewLineJustified
            );

        if (localHyperlink)
        {
            endHyperlink(true);
        }

        iterator.setIndex(runLimit);
    }
}