use of com.lowagie.text.rtf.list.RtfList in project itext2 by albfernandez.
the class RtfImportMgr method importStylesheetList.
/**
* Imports a stylesheet list value. The stylesheet number for the stylesheet defined
* is determined and then the resulting mapping is added.
*/
public boolean importStylesheetList(String listNr, List listIn) {
RtfList rtfList = new RtfList(this.rtfDoc, listIn);
rtfList.setRtfDocument(this.rtfDoc);
// this.importStylesheetListMapping.put(listNr, Integer.toString(this.rtfDoc.getDocumentHeader().getRtfParagraphStyle(styleName)(rtfList)));
return true;
}
use of com.lowagie.text.rtf.list.RtfList in project itext2 by albfernandez.
the class RtfDestinationListTable method handleControlWord.
public boolean handleControlWord(RtfCtrlWordData ctrlWordData) {
boolean result = true;
boolean skipCtrlWord = false;
if (this.rtfParser.isImport()) {
skipCtrlWord = true;
if (ctrlWordData.ctrlWord.equals("listtable")) {
result = true;
this.currentListMappingNumber = 0;
} else /* Picture info for icons/images for lists */
if (ctrlWordData.ctrlWord.equals("listpicture")) /* DESTINATION */
{
skipCtrlWord = true;
// this.rtfParser.setTokeniserStateSkipGroup();
result = true;
} else /* list */
if (ctrlWordData.ctrlWord.equals("list")) /* DESTINATION */
{
skipCtrlWord = true;
this.newList = new RtfList(this.rtfParser.getRtfDocument());
// set default
this.newList.setListType(RtfList.LIST_TYPE_NORMAL);
this.currentLevel = -1;
this.currentListMappingNumber++;
this.currentSubGroupCount = 0;
result = true;
} else if (ctrlWordData.ctrlWord.equals("listtemplateid")) /* // List item*/
{
// ignore this because it gets regenerated in every document
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("listsimple")) /* // List item*/
{
// is value 0 or 1
if (ctrlWordData.hasParam && ctrlWordData.param == "1") {
this.newList.setListType(RtfList.LIST_TYPE_SIMPLE);
} else {
this.newList.setListType(RtfList.LIST_TYPE_NORMAL);
}
skipCtrlWord = true;
result = true;
// this gets set internally. Don't think it should be imported
} else if (ctrlWordData.ctrlWord.equals("listhybrid")) /* // List item*/
{
this.newList.setListType(RtfList.LIST_TYPE_HYBRID);
skipCtrlWord = true;
result = true;
// this gets set internally. Don't think it should be imported
} else if (ctrlWordData.ctrlWord.equals("listrestarthdn")) /* // List item*/
{
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("listid")) {
// List item cannot be between -1 and -5
// needs to be mapped for imports and is recreated
// we have the new id and the old id. Just add it to the mapping table here.
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("listname")) /* // List item*/
{
this.newList.setName(ctrlWordData.param);
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("liststyleid")) /* // List item*/
{
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("liststylename")) /* // List item*/
{
skipCtrlWord = true;
result = true;
} else /* listlevel */
if (ctrlWordData.ctrlWord.equals("listlevel")) /* DESTINATION There are 1 or 9 listlevels per list */
{
this.currentLevel++;
this.currentListLevel = this.newList.getListLevel(this.currentLevel);
this.currentListLevel.setTentative(false);
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("leveljc")) {
// this is the old number. Only use it if the current type is not set
if (this.currentListLevel.getAlignment() == RtfListLevel.LIST_TYPE_UNKNOWN) {
switch(ctrlWordData.intValue()) {
case 0:
this.currentListLevel.setAlignment(Element.ALIGN_LEFT);
break;
case 1:
this.currentListLevel.setAlignment(Element.ALIGN_CENTER);
break;
case 2:
this.currentListLevel.setAlignment(Element.ALIGN_RIGHT);
break;
}
}
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("leveljcn")) {
// if this exists, use it and it overrides the old setting
switch(ctrlWordData.intValue()) {
case 0:
this.currentListLevel.setAlignment(Element.ALIGN_LEFT);
break;
case 1:
this.currentListLevel.setAlignment(Element.ALIGN_CENTER);
break;
case 2:
this.currentListLevel.setAlignment(Element.ALIGN_RIGHT);
break;
}
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelstartat")) {
this.currentListLevel.setListStartAt(ctrlWordData.intValue());
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("lvltentative")) {
this.currentListLevel.setTentative(true);
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelold")) {
// old style. ignore
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelprev")) {
// old style. ignore
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelprevspace")) {
// old style. ignore
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelspace")) {
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelindent")) {
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("leveltext")) {
/* FIX */
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelfollow")) {
this.currentListLevel.setLevelFollowValue(ctrlWordData.intValue());
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levellegal")) {
this.currentListLevel.setLegal(ctrlWordData.param == "1" ? true : false);
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelnorestart")) {
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("chrfmt")) {
/* FIX */
// set an attribute pair
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelpicture")) {
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("li")) {
// set an attribute pair
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("fi")) {
// set an attribute pair
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("jclisttab")) {
// set an attribute pair
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("tx")) {
// set an attribute pair
skipCtrlWord = true;
result = true;
} else /* number */
if (ctrlWordData.ctrlWord.equals("levelnfc")) /* old style */
{
if (this.currentListLevel.getListType() == RtfListLevel.LIST_TYPE_UNKNOWN) {
this.currentListLevel.setListType(ctrlWordData.intValue() + RtfListLevel.LIST_TYPE_BASE);
}
skipCtrlWord = true;
result = true;
} else if (ctrlWordData.ctrlWord.equals("levelnfcn")) /* new style takes priority over levelnfc.*/
{
this.currentListLevel.setListType(ctrlWordData.intValue() + RtfListLevel.LIST_TYPE_BASE);
skipCtrlWord = true;
result = true;
} else /* level text */
if (ctrlWordData.ctrlWord.equals("leveltemplateid")) {
// ignore. this value is regenerated in each document.
skipCtrlWord = true;
result = true;
} else /* levelnumber */
if (ctrlWordData.ctrlWord.equals("levelnumbers")) {
skipCtrlWord = true;
result = true;
}
}
if (this.rtfParser.isConvert()) {
if (ctrlWordData.ctrlWord.equals("shppict")) {
result = true;
}
if (ctrlWordData.ctrlWord.equals("nonshppict")) {
skipCtrlWord = true;
this.rtfParser.setTokeniserStateSkipGroup();
result = true;
}
}
if (!skipCtrlWord) {
switch(this.rtfParser.getConversionType()) {
case RtfParser.TYPE_IMPORT_FULL:
// writeBuffer();
// writeText(ctrlWordData.toString());
result = true;
break;
case RtfParser.TYPE_IMPORT_FRAGMENT:
// writeBuffer();
// writeText(ctrlWordData.toString());
result = true;
break;
case RtfParser.TYPE_CONVERT:
result = true;
break;
default:
// error because is should be an import or convert
result = false;
break;
}
}
return result;
}
use of com.lowagie.text.rtf.list.RtfList in project itext2 by albfernandez.
the class RtfMapper method mapElement.
/**
* Takes an Element subclass and returns an array of RtfBasicElement
* subclasses, that contained the mapped RTF equivalent to the Element
* passed in.
*
* @param element The Element to wrap
* @return An array of RtfBasicElement wrapping the Element
* @throws DocumentException
*/
public RtfBasicElement[] mapElement(Element element) throws DocumentException {
ArrayList rtfElements = new ArrayList();
if (element instanceof RtfBasicElement) {
RtfBasicElement rtfElement = (RtfBasicElement) element;
rtfElement.setRtfDocument(this.rtfDoc);
return new RtfBasicElement[] { rtfElement };
}
switch(element.type()) {
case Element.CHUNK:
Chunk chunk = (Chunk) element;
if (chunk.hasAttributes()) {
if (chunk.getAttributes().containsKey(Chunk.IMAGE)) {
rtfElements.add(new RtfImage(rtfDoc, chunk.getImage()));
} else if (chunk.getAttributes().containsKey(Chunk.NEWPAGE)) {
rtfElements.add(new RtfNewPage(rtfDoc));
} else if (chunk.getAttributes().containsKey(Chunk.TAB)) {
Float tabPos = (Float) ((Object[]) chunk.getAttributes().get(Chunk.TAB))[1];
RtfTab tab = new RtfTab(tabPos.floatValue(), RtfTab.TAB_LEFT_ALIGN);
tab.setRtfDocument(rtfDoc);
rtfElements.add(tab);
rtfElements.add(new RtfChunk(rtfDoc, new Chunk("\t")));
} else {
rtfElements.add(new RtfChunk(rtfDoc, (Chunk) element));
}
} else {
rtfElements.add(new RtfChunk(rtfDoc, (Chunk) element));
}
break;
case Element.PHRASE:
rtfElements.add(new RtfPhrase(rtfDoc, (Phrase) element));
break;
case Element.PARAGRAPH:
rtfElements.add(new RtfParagraph(rtfDoc, (Paragraph) element));
break;
case Element.ANCHOR:
rtfElements.add(new RtfAnchor(rtfDoc, (Anchor) element));
break;
case Element.ANNOTATION:
rtfElements.add(new RtfAnnotation(rtfDoc, (Annotation) element));
break;
case Element.IMGRAW:
case Element.IMGTEMPLATE:
case Element.JPEG:
rtfElements.add(new RtfImage(rtfDoc, (Image) element));
break;
case Element.AUTHOR:
case Element.SUBJECT:
case Element.KEYWORDS:
case Element.TITLE:
case Element.PRODUCER:
case Element.CREATIONDATE:
rtfElements.add(new RtfInfoElement(rtfDoc, (Meta) element));
break;
case Element.LIST:
// TODO: Testing
rtfElements.add(new RtfList(rtfDoc, (List) element));
break;
case Element.LISTITEM:
// TODO: Testing
rtfElements.add(new RtfListItem(rtfDoc, (ListItem) element));
break;
case Element.SECTION:
rtfElements.add(new RtfSection(rtfDoc, (Section) element));
break;
case Element.CHAPTER:
rtfElements.add(new RtfChapter(rtfDoc, (Chapter) element));
break;
case Element.TABLE:
try {
rtfElements.add(new RtfTable(rtfDoc, (Table) element));
} catch (ClassCastException e) {
rtfElements.add(new RtfTable(rtfDoc, ((SimpleTable) element).createTable()));
}
break;
case Element.PTABLE:
try {
rtfElements.add(new RtfTable(rtfDoc, (PdfPTable) element));
} catch (ClassCastException e) {
rtfElements.add(new RtfTable(rtfDoc, ((SimpleTable) element).createTable()));
}
break;
}
return (RtfBasicElement[]) rtfElements.toArray(new RtfBasicElement[rtfElements.size()]);
}
Aggregations