Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package com.itextpdf.layout.renderer;
import com.itextpdf.commons.utils.MessageFormatUtil;
import com.itextpdf.io.font.constants.StandardFonts;
import com.itextpdf.io.logs.IoLogMessageConstant;
import com.itextpdf.io.util.TextUtil;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.numbering.EnglishAlphabetNumbering;
import com.itextpdf.kernel.numbering.GreekAlphabetNumbering;
import com.itextpdf.kernel.numbering.RomanNumbering;
import com.itextpdf.kernel.pdf.tagging.StandardRoles;
import com.itextpdf.layout.element.Image;
import com.itextpdf.layout.element.Text;
import com.itextpdf.layout.layout.LayoutArea;
import com.itextpdf.layout.layout.LayoutContext;
import com.itextpdf.layout.layout.LayoutResult;
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
import com.itextpdf.layout.minmaxwidth.MinMaxWidthUtils;
import com.itextpdf.layout.properties.BaseDirection;
import com.itextpdf.layout.properties.IListSymbolFactory;
import com.itextpdf.layout.properties.ListNumberingType;
import com.itextpdf.layout.properties.ListSymbolPosition;
import com.itextpdf.layout.properties.Property;
import com.itextpdf.layout.properties.UnitValue;
import com.itextpdf.layout.tagging.LayoutTaggingHelper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ListRenderer extends BlockRenderer {
/**
* Creates a ListRenderer from its corresponding layout object.
*
* @param modelElement the {@link com.itextpdf.layout.element.List} which this object should manage
*/
public ListRenderer(com.itextpdf.layout.element.List modelElement) {
super(modelElement);
}
@Override
public LayoutResult layout(LayoutContext layoutContext) {
LayoutResult errorResult = initializeListSymbols(layoutContext);
if (errorResult != null) {
return errorResult;
}
LayoutResult result = super.layout(layoutContext);
// cannot place even the first ListItemRenderer
if (Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT)) && null != result.getCauseOfNothing()) {
if (LayoutResult.FULL == result.getStatus()) {
result = correctListSplitting(this, null, result.getCauseOfNothing(), result.getOccupiedArea());
} else if (LayoutResult.PARTIAL == result.getStatus()) {
result = correctListSplitting(result.getSplitRenderer(), result.getOverflowRenderer(), result.getCauseOfNothing(), result.getOccupiedArea());
}
}
return result;
}
/**
* Gets a new instance of this class to be used as a next renderer, after this renderer is used, if
* {@link #layout(LayoutContext)} is called more than once.
*
*
* If a renderer overflows to the next area, iText uses this method to create a renderer
* for the overflow part. So if one wants to extend {@link ListRenderer}, one should override
* this method: otherwise the default method will be used and thus the default rather than the custom
* renderer will be created.
* @return new renderer instance
*/
@Override
public IRenderer getNextRenderer() {
logWarningIfGetNextRendererNotOverridden(ListRenderer.class, this.getClass());
return new ListRenderer((com.itextpdf.layout.element.List) modelElement);
}
@Override
protected AbstractRenderer createSplitRenderer(int layoutResult) {
AbstractRenderer splitRenderer = super.createSplitRenderer(layoutResult);
splitRenderer.addAllProperties(getOwnProperties());
splitRenderer.setProperty(Property.LIST_SYMBOLS_INITIALIZED, Boolean.TRUE);
return splitRenderer;
}
@Override
protected AbstractRenderer createOverflowRenderer(int layoutResult) {
AbstractRenderer overflowRenderer = super.createOverflowRenderer(layoutResult);
overflowRenderer.addAllProperties(getOwnProperties());
overflowRenderer.setProperty(Property.LIST_SYMBOLS_INITIALIZED, Boolean.TRUE);
return overflowRenderer;
}
@Override
public MinMaxWidth getMinMaxWidth() {
LayoutResult errorResult = initializeListSymbols(new LayoutContext(new LayoutArea(1, new Rectangle(MinMaxWidthUtils.getInfWidth(), AbstractRenderer.INF))));
if (errorResult != null) {
return MinMaxWidthUtils.countDefaultMinMaxWidth(this);
}
return super.getMinMaxWidth();
}
protected IRenderer makeListSymbolRenderer(int index, IRenderer renderer) {
IRenderer symbolRenderer = createListSymbolRenderer(index, renderer);
// underlying should not be applied
if (symbolRenderer != null) {
symbolRenderer.setProperty(Property.UNDERLINE, false);
}
return symbolRenderer;
}
static Object getListItemOrListProperty(IRenderer listItem, IRenderer list, int propertyId) {
return listItem.hasProperty(propertyId) ? listItem.