We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Loading stencils in Visio 2013 format fails

Hi, we tried to load some stencils in Visio 2013 format, but got a NullpointerException. sadly we cannot find out what happened, since we do not have the sources for your library.


Here is the code - necessary ressources are attached:
package test.visio.aspose;

import com.aspose.diagram.;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;

import static org.junit.Assert.;

public class AsposeExportTest
{
private Diagram diagram;
private Page drawingPage;
private int shapeCount = 0;

@Before
public void prepare() throws Exception
{
createDocument(getClass().getResourceAsStream(“template.vtx”), 210, 297, “test”);
}

protected void createDocument(final InputStream templateFileStream,
final int width, final int height, final String configName)
throws Exception
{
diagram = new Diagram(templateFileStream);

final DocumentProperties dProps = diagram.getDocumentProps();

dProps.setCreator(replaceSpecialChars(System.getProperty(“user.name”)));
dProps.setTimeCreated(new DateTime(new Date()));
dProps.setSubject(configName);

XForm xform = diagram.getPages().get(0).getPageSheet().getXForm();
xform.getWidth().setValue(width);
xform.getHeight().setValue(height);

xform = diagram.getPages().get(1).getPageSheet().getXForm();
xform.getWidth().setValue(width);
xform.getHeight().setValue(height);

for (int i = 0; i < diagram.getPages().getCount(); i++)
{
final Page page = diagram.getPages().get(i);
if (page.getBackground() == 1)
{
continue;
}
drawingPage = page;
break;
}
if (drawingPage == null)
{
throw new IllegalArgumentException(“No drawing page available in template” );
}
}

@Test
public void load2010Masters() throws Exception
{
initMasters(getClass().getResourceAsStream(“Miscellaneous_2010.vsx”));
}

@Test
public void load2013Masters() throws Exception
{
initMasters(getClass().getResourceAsStream(“Miscellaneous_2013.vsx”));
}

protected void initMasters( final InputStream stencil ) throws Exception {
final Diagram stencilDiagram = new Diagram( stencil );
final Iterator iterator = stencilDiagram.getMasters().iterator();
while( iterator.hasNext() ) {
final Master master = iterator.next();
if(“Theme Effects”.equals(master.getName())) {
diagram.getMasters().remove( master );
}
else {
master.setID(getNextId());
diagram.getMasters().add(master);
}
}
}

private int getNextId()
{
return shapeCount++;
}

public String replaceSpecialChars(final String string) {
return string.replaceAll( “<”, “" ).replaceAll( “>”, "” ).replaceAll( “&”, “" ).replaceAll( “”", "” ).replaceAll( “’”, “_” );
}

}

Best regards

Gerald Koch

Hi Gerald,


Thank you for contacting support and using Aspose.Diagram APIs. Please note, there is no way to load VSSX stencil format. We’ve logged this feature request in our issue tracking system as DIAGRAMJAVA-50216. Your post is also linked to this issue. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Note: As a workaround, please save VSSX format file in the VSS format.

Hi Gerald,


Thank you for being patient. We have a good news for you that the issue id DIAGRAMJAVA-50216 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the next version of Aspose.Diagram for Java 6.0.0. We’ll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMJAVA-50216) have been fixed in Aspose.Diagram for Java 6.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.