setBulletAutoNumber does not work, always get error - PowerPoint found a problem with content...

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

setBulletAutoNumber does not work, always get error - PowerPoint found a problem with content...

paoim101084
Hi,

I have problem with setBulletAutoNumber, I always get error when I open that
powerpoint slide.

Here is the error:
PowerPoint found a problem with content... PowerPoint can attempt to repair
the presentation.
If you trust the source of this presentation, click Repair.

Here is what I did:
import java.awt.geom.Rectangle2D;
import java.io.FileOutputStream;

import org.apache.poi.sl.usermodel.AutoNumberingScheme;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.poi.xslf.usermodel.XSLFTextRun;
import org.apache.poi.xslf.usermodel.XSLFTextShape;

public class ArabicBulletDemo {

        private static String[] getDummyData(int rows) {
                String[] data = new String[rows + 1];
                for (int row = 0; row < rows; row++) {
                        data[row] = "Numbered List Item " + (row + 1);
                }
                return data;
        }

        private static Rectangle2D getNextAnchor(Rectangle2D anchor) {
                return new Rectangle2D.Double(anchor.getX(), anchor.getMaxY(),
anchor.getWidth(), anchor.getHeight());
        }

        private static XSLFTextShape createTextBox(XSLFSlide slide, Rectangle2D
anchor) {
                XSLFTextShape textShape = slide.createTextBox();
                textShape.setAnchor(anchor);
                return textShape;
        }

        private static void diplayBullet(XSLFTextShape shape, String text, int
start) {
                XSLFTextParagraph p = shape.addNewTextParagraph();
                int startAlphabet = start;
                if (start < 0)
                        startAlphabet = 1;
                p.setTextAlign(TextAlign.LEFT);
                p.setIndent(-40d);
                p.setBullet(true);
                p.setIndentLevel(0);
                p.setBulletAutoNumber(AutoNumberingScheme.arabicParenRight,
startAlphabet);
                XSLFTextRun r = p.addNewTextRun();
                r.setText(text);
        }

        public static void main(String[] args) throws Exception {
                String data[] = getDummyData(10);

                try (XMLSlideShow ppt = new XMLSlideShow()) {
                        XSLFSlide slide = ppt.createSlide();

                        int x = 50, y = 40;
                        Rectangle2D anchor = new Rectangle2D.Double(x, y,
ppt.getPageSize().getWidth() - (x * 2), y);

                        for (int r = 0; r < data.length; r++) {
                                XSLFTextShape shape = createTextBox(slide, anchor);
                                diplayBullet(shape, data[r], (r + 1));
                                anchor = getNextAnchor(shape.getAnchor());
                        }

                        try (FileOutputStream fos = new
FileOutputStream("output/ArabicBulletDemo.pptx")) {
                                ppt.write(fos);
                        }
                }
        }
}

You can look at attachment files.
<http://apache-poi.1045710.n5.nabble.com/file/t340639/setBulletAutoNumber_error.png>
<http://apache-poi.1045710.n5.nabble.com/file/t340639/setBulletAutoNumber_error_1.png>


Note: if I don't use:
p.setBulletAutoNumber(AutoNumberingScheme.arabicParenRight, startAlphabet);
It will work as default bullet.


Could you help to have a look for that issue?

Thanks



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setBulletAutoNumber does not work, always get error - PowerPoint found a problem with content...

pj.fanning
Thanks for the report. Could you raise an issue in
https://bz.apache.org/bugzilla/ ?



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setBulletAutoNumber does not work, always get error - PowerPoint found a problem with content...

paoim101084
I don't have account to create bugzilla yet.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]