Hi,
I am having a problem trying to achieve required styling for paragraphs added to our presentations.
This is my goal:
- I need to add a bulleted paragraph
- If there is a master slide styling defined for various levels of bulleted paragraphs, I need to use that
- If there is not a master slide styling available with bullets, I need to add a default symbol bullet to my paragraph.
Now, see the attached para-styling.pttx file. It has 3 shapes. One with master slide styles defined, and 2 without. With these 2 without master slide styling, one has a paragraph with a bullet, one has a paragraph without a bullet.
Now see the code snippet below. I am adding 2 paragraphs to each shape. For the first one, I set only the depth. For the second one, I set also the bullet style.
The problem I am having is that when I am trying to find out if my added paragraph has a bullet, I get a “Not Defined” as a bullet type for either a paragraph with a bullet or without. Similarly, indent, left <span style=“font-size:10.0pt;font-family:“Tahoma”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-ansi-language:
EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>margin <!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–> and other paragraph styling properties come out as NaN.
So when you run the following code, you can see, that when the first paragraph is added, it is added as a bulleted one in the first shape, not bulleted one in the second shape and bulleted one in the third shape. I am happy with the output for the first and third shape, but I need to have a bullet in my second shape as well.
So when I try to set a bullet type to a paragraph, as I do for my last paragraph added, I do get bullets in all my shapes, however, styling on the bullet in the first shape is not taken from the master slide styles anymore, it is overridden, which is not desired outcome.
So the question: is there a way for me to find out if the paragraph I added to a shape has a bullet from the master slide styles or I need to manually assign a bullet type.
Here is the code snippet used:
FileInputStream fileInput = new FileInputStream( “c:/para-styling.pptx”);
Presentation pres = new Presentation( fileInput );
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape aShp = null;
ITextFrame txtFrm = null;
Integer i = 0;
while( i < slide.getShapes().size() )
{
aShp = (IAutoShape) slide.getShapes().get_Item(i);
txtFrm = aShp.getTextFrame();
i = i + 1;
Paragraph originalPara = (Paragraph) txtFrm.getParagraphs().get_Item(0);
String longText = "This is a long line. This is a long line. This is a long line. ";
Paragraph para2 = new Paragraph( originalPara );
para2.getParagraphFormat().setDepth((short) 1);
para2.setText(longText);
txtFrm.getParagraphs().add(para2);
Paragraph para3 = new Paragraph( originalPara );
para3.getParagraphFormat().getBullet().setType(BulletType.Symbol);
para3.getParagraphFormat().setDepth((short) 1);
para3.setText(longText);
txtFrm.getParagraphs().add(para3);
}
FileOutputStream fileOutput = new FileOutputStream( “c:/output.pptx”);
pres.save( fileOutput, SaveFormat.PPTX );
Thanks!
Natasa
PS: we are using Aspose Slides for Java 14.6.0