Kopieren von Absatz und Portion in PPTX

Kopieren eines Absatzes

Die Eigenschaften des Absatzes können in der ParagraphFormat-Instanz der Paragraph-Klasse zugegriffen werden. Wir müssen alle Eigenschaften des Quellabsatzes in den Zielabsatz kopieren. Im folgenden Beispiel wird die Methode CopyParagraph vorgestellt, die den zu kopierenden Absatz als Argument übernimmt. Sie kopiert alle Eigenschaften des Quellabsatzes in einen temporären Absatz und gibt denselben zurück. Der Zielabsatz erhält die kopierten Werte.

public static void main(String[] args){
//Function Call
IParagraph newPara=CopyParagraph(SourcePara);
}
//Function Definition
public static IParagraph CopyParagraph(IParagraph par)
{
Paragraph temp = new Paragraph();
// use CreateParagraphFormatData !!!
IParagraphFormatEffectiveData paraData = par.createParagraphFormatEffective();
// use ParagraphFormat to set values
temp.getParagraphFormat().setAlignment(paraData.getAlignment());
temp.getParagraphFormat().setDefaultTabSize(paraData.getDefaultTabSize());
temp.getParagraphFormat().setMarginLeft(paraData.getMarginLeft());
temp.getParagraphFormat().setMarginRight(paraData.getMarginRight());
temp.getParagraphFormat().setFontAlignment(paraData.getFontAlignment());
temp.getParagraphFormat().setIndent(paraData.getIndent());
temp.getParagraphFormat().setDepth(paraData.getDepth());
temp.getParagraphFormat().setSpaceAfter(paraData.getSpaceAfter());
temp.getParagraphFormat().setSpaceBefore(paraData.getSpaceBefore());
temp.getParagraphFormat().setSpaceWithin(paraData.getSpaceWithin());
temp.getParagraphFormat().getBullet().setChar(paraData.getBullet().getChar());
temp.getParagraphFormat().getBullet().setHeight(paraData.getBullet().getHeight());
temp.getParagraphFormat().getBullet().setFont(paraData.getBullet().getFont());
temp.getParagraphFormat().getBullet().setNumberedBulletStyle(paraData.getBullet().getNumberedBulletStyle());
temp.getParagraphFormat().setFontAlignment(paraData.getFontAlignment());
return temp;
}

Kopieren einer Portion

Die Eigenschaften der Portion können in der PortionFormat-Instanz der Portion-Klasse zugegriffen werden. Wir müssen alle Eigenschaften der Quellportion in die Zielportion kopieren. Im folgenden Beispiel wird die Methode CopyPortion vorgestellt, die die zu kopierende Portion als Argument übernimmt. Sie kopiert alle Eigenschaften der Quellportion in eine temporäre Portion und gibt denselben zurück. Die Zielportion erhält die kopierten Werte.

public static void main(String[] args){
//Function Call
IPortion newPortion=CopyPortion(SourcePortion);
}
//Function Definition
public static IPortion CopyPortion(IPortion por)
{
Portion temp = new Portion();
//use CreatePortionFormatData!!!
IPortionFormatEffectiveData portData = por.createPortionFormatEffective();
// use PortionFormat to set values
temp.getPortionFormat().setAlternativeLanguageId(portData.getAlternativeLanguageId());
temp.getPortionFormat().setBookmarkId(portData.getBookmarkId());
temp.getPortionFormat().setEscapement(portData.getEscapement());
temp.getPortionFormat().getFillFormat().setFillType(por.getPortionFormat().getFillFormat().getFillType());
temp.getPortionFormat().getFillFormat().getSolidFillColor().setColor(portData.getFillFormat().getSolidFillColor());
if(portData.getFontBold() == true)
temp.getPortionFormat().setFontBold(NullableBool.True);
else
temp.getPortionFormat().setFontBold(NullableBool.False);
temp.getPortionFormat().setFontHeight(portData.getFontHeight());
if(portData.getFontItalic() == true)
temp.getPortionFormat().setFontItalic(NullableBool.True);
else
temp.getPortionFormat().setFontItalic(NullableBool.False);
temp.getPortionFormat().setFontUnderline(portData.getFontUnderline());
temp.getPortionFormat().getUnderlineFillFormat().setFillType(portData.getUnderlineFillFormat().getFillType());
temp.getPortionFormat().getUnderlineFillFormat().getSolidFillColor().setColor(portData.getUnderlineFillFormat().getSolidFillColor());
if(portData.isHardUnderlineFill() == true)
temp.getPortionFormat().isHardUnderlineFill(NullableBool.True);
else
temp.getPortionFormat().isHardUnderlineFill(NullableBool.False);
if(portData.isHardUnderlineLine() == true)
temp.getPortionFormat().isHardUnderlineLine(NullableBool.True);
else
temp.getPortionFormat().isHardUnderlineLine(NullableBool.False);
if(portData.getKumimoji() == true)
temp.getPortionFormat().setKumimoji(NullableBool.True);
else
temp.getPortionFormat().setKumimoji(NullableBool.False);
temp.getPortionFormat().setKerningMinimalSize(portData.getKerningMinimalSize());
temp.getPortionFormat().setLanguageId(portData.getLanguageId());
temp.getPortionFormat().setLatinFont(portData.getLatinFont());
temp.getPortionFormat().setEastAsianFont(portData.getEastAsianFont());
temp.getPortionFormat().setComplexScriptFont(portData.getComplexScriptFont());
temp.getPortionFormat().setSymbolFont(portData.getSymbolFont());
temp.getPortionFormat().setTextCapType(portData.getTextCapType());
temp.getPortionFormat().setSpacing(portData.getSpacing());
temp.getPortionFormat().setStrikethroughType(portData.getStrikethroughType());
if(portData.getProofDisabled() == true)
temp.getPortionFormat().setProofDisabled(NullableBool.True);
else
temp.getPortionFormat().setProofDisabled(NullableBool.False);
if(portData.getNormaliseHeight() == true)
temp.getPortionFormat().setNormaliseHeight(NullableBool.True);
else
temp.getPortionFormat().setNormaliseHeight(NullableBool.False);
temp.getPortionFormat().setHyperlinkMouseOver(portData.getHyperlinkMouseOver());
temp.getPortionFormat().setHyperlinkClick(por.getPortionFormat().getHyperlinkClick());
temp.getPortionFormat().getHighlightColor().setColor(portData.getHighlightColor());
return temp;
}