Uknown Field type (1720)


#1

Hi,
This file fields.pptx.zip (6.0 MB)
has a bunch of unknown field types, it doesn’t correspond to any field type from your enumeration https://apireference.aspose.com/net/slides/aspose.slides/fieldtype.

here is code to one of those fields:

String presentationPath = "fields.pptx";
Presentation presentation = new Presentation(presentationPath);

ISlideCollection slides = presentation.getSlides();
ISlide slide = slides.get_Item(38);
AutoShape shape = (AutoShape) slide.getShapes().get_Item(20);
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion portion = paragraph.getPortions().get_Item(0);
IField field = portion.getField();

Can you please check this out?

Thanks,
Zeljko.


#2

@Zeljko,

I have worked with the sample code and presentation file shared by you and have been able to observe the issue specified. An issue with ID SLIDESJAVA-37101 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.


#3

The issues you have found earlier (filed as SLIDESJAVA-37101) have been fixed in this update.


#4

Hi,

I still have the same problem being unable to identify field type in the previously provided file.

Please check the following code:

    private static final String DATE_AND_TIME = "datetime"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_1 = "datetime1"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_2 = "datetime2"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_3 = "datetime3"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_4 = "datetime4"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_5 = "datetime5"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_6 = "datetime6"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_7 = "datetime7"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_8 = "datetime8"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_9 = "datetime9"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_10 = "datetime10"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_11 = "datetime11"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_12 = "datetime12"; //$NON-NLS-1$
    private static final String DATE_AND_TIME_13 = "datetime13"; //$NON-NLS-1$
    private static final String SLIDE_NUMBER = "slidenumber"; //$NON-NLS-1$
    private static final String FOOTER = "footer"; //$NON-NLS-1$
    private static final String HEADER = "header"; //$NON-NLS-1$

    private String getFieldTypeAsString(FieldType fieldType) {

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime())) {
	    return DATE_AND_TIME;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime1())) {
	    return DATE_AND_TIME_1;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime2())) {
	    return DATE_AND_TIME_2;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime3())) {
	    return DATE_AND_TIME_3;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime4())) {
	    return DATE_AND_TIME_4;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime5())) {
	    return DATE_AND_TIME_5;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime6())) {
	    return DATE_AND_TIME_6;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime7())) {
	    return DATE_AND_TIME_7;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime8())) {
	    return DATE_AND_TIME_8;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime9())) {
	    return DATE_AND_TIME_9;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime10())) {
	    return DATE_AND_TIME_10;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime11())) {
	    return DATE_AND_TIME_11;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime12())) {
	    return DATE_AND_TIME_12;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getDateTime13())) {
	    return DATE_AND_TIME_13;
	}

	if (FieldType.op_Equality(fieldType, FieldType.getSlideNumber())) {
	    return SLIDE_NUMBER;
	}
	if (FieldType.op_Equality(fieldType, FieldType.getFooter())) {
	    return FOOTER;
	}
	if (FieldType.op_Equality(fieldType, FieldType.getHeader())) {
	    return HEADER;
	}

	 return StringUtils.EMPTY;
    }

    @Test
    public void test() throws Exception {

	String presentationPath = "fields.pptx";
    Presentation presentation = new Presentation(presentationPath);

	    ISlideCollection slides = presentation.getSlides();
	    ISlide slide = slides.get_Item(38);
	    AutoShape shape = (AutoShape) slide.getShapes().get_Item(20);
	    IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
	    IPortion portion = paragraph.getPortions().get_Item(0);
	    IFieldType fieldType = portion.getField().getType();
    assertNotEquals(StringUtils.EMPTY, getFieldTypeAsString((FieldType) fieldType));
    }

I also have another file with the same problem: file2.pptx.zip (2.3 MB)

  @Test
  public void test2() {

        String presentationPath = "file2.pptx";
     
        Presentation presentation = new Presentation(presentationPath);
      
        ISlide slide = presentation.getSlides().get_Item(2);

	    IShapeCollection shapes = slide.getShapes();

	    IAutoShape shape = (IAutoShape) shapes.get_Item(18);

	    IParagraphCollection paragraphs = shape.getTextFrame().getParagraphs();

	    IParagraph paragraph = paragraphs.get_Item(0);

	    IPortion portion = paragraph.getPortions().get_Item(0);

	    IFieldType fieldType = portion.getField().getType();

	    assertNotEquals(StringUtils.EMPTY, getFieldTypeAsString((FieldType) fieldType));

	    shapes.get_Item(19);

	    paragraphs = shape.getTextFrame().getParagraphs();

	    paragraph = paragraphs.get_Item(0);

	    portion = paragraph.getPortions().get_Item(0);

	    fieldType = portion.getField().getType();

	    assertNotEquals(StringUtils.EMPTY, getFieldTypeAsString((FieldType) fieldType));
 }

Can you check it again?

Thanks,
Zeljko


#5

@Zeljko,

We have verified the issue on our end. Actually, the FieldTypes DateTime - DateTime13 values are reserved in office, but not the only possible. You can set your own datetime field type like “datetime YYYY->MM->DD & hh:mm”.

Presentation presentation = new Presentation(path + "fields.pptx"); 

ISlideCollection slides = presentation.getSlides(); 

AutoShape shape = (AutoShape)slides.get_Item(38).getShapes().get_Item(20); 

IPortion portion = shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0); 

IField field = portion.getField(); 

field.getType().setInternalString("datetime YYYY->MM->DD & hh:mm"); 

presentation.save(path + "fields-out.pptx", SaveFormat.Pptx);`

Such field types as in fields.pptx can be found in old ppt presentations and pptx obtained from them.


#6

Thanks for the help, Mudassir!


#7

@Zeljko,

You are welcome.