You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Jeff Lavezzo <JE...@saic.com> on 2010/03/11 20:16:40 UTC

ApachePOI HSLF powerpoint merging text color problem

Hi All,

This question is mostly directed at Yegor Kozlov and Nick Burch since they
wrote most of the classes involved.

I've rewritten the Groovy code I emailed out before in Java in case that
helps anyone. It's attached.

Everything works great. I was very pleased that the old emails floating
around the Internet saying that POI couldn't merge slideshows were
out-of-date. EXCEPT when you get to line 85 of my class. The RichTextRuns
report that their font.color property is white. Running this through a
debugger drops me all the way into the SlideMaster's text runs to find
that white color. Setting the color against the RichTextRun has no effect
on the final outcome. I tried looping through the Slide's MasterSheet's
TextRuns' RichTextRuns and setting the font.color there before starting
the merge but that throws a null pointer exception in
TextRun.ensureStyleAtomPresent() at this line:
runAtomsParent.addChildAfter(_styleAtom, addAfter);

Unlike things like font.name or the list of Pictures which are stored at
the SlideShow level and referenced other places, the font.color is
specifically set for the RichTextRun. Is it possible that when the
SlideShow is written out that this property isn't referenced?  I'm really
at a loss to figure this out much further.

Sincerely,

Jeff Lavezzo

Re: ApachePOI HSLF powerpoint merging text color problem

Posted by mikki <mi...@mail.ru>.
Hi Jeff.

May I help you. This code split ppt file. But lot functionaly lost. TextBox
use one font. When font count in TextBox greatest one merge result undefined
(50% default font used).



package pptmerge;

import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.hslf.*;
import org.apache.poi.hslf.model.*;
import org.apache.poi.hssf.usermodel.HSSFSimpleShape;

import java.io.*;
import java.util.regex.*;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Dimension;
import sample.util.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2010</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class PPTmerge {

    private static Logger1 log=null;
    private static String LogFileName="";
    private static final String[] USAGE_MESSAGE = {
    "Usage: java PPTMerge.jar <pptfile1> [pptfile2] [pptfile3] ...",
    ""};

    public PPTmerge() {
    }

    private static String GetLogFileName(String[] args){

        String  strFile = null;
        String filename = null;
        File LogDir = null;

        try {
            File jarFile = new File(PPTmerge.class.
                                    getProtectionDomain().getCodeSource().
                                    getLocation().toURI());
            filename = jarFile.getParent();
            if (jarFile.getParent().length()==0){
                filename += "log";
            }else{
                filename += "/log";
            }
            LogDir=new File(filename);
            if (!LogDir.isDirectory()){
                LogDir.mkdir();
            }
            if (args.length==0){
                filename += "/" + jarFile.getName();
            }else{
                filename += "/" + new File(args[0]).getName();
            }
            if (filename.lastIndexOf(".")==-1){
                strFile=filename+".LOG";
            }else{
               
strFile=filename.substring(0,filename.lastIndexOf("."))+".LOG";
            }
        }catch(Exception ex){
            System.err.println("Error! Unable get program name : " +
ex.toString());
        }
        return strFile;
    }

    private static String GetResultFileName(String file[]){

        String ret="";

        try{

            File file1 = new File(file[0]);
            String[] Array1 = Pattern.compile("_").split(file1.getName());

            switch (file.length){
                case 0 :
                    break;
                case 1 :
                	if (file1.getParent()!=null){
                		ret=file1.getParent() + "/";
                	}else{
                		ret="";
                	}
                    for (int j=0; j < Array1.length-1; j++){
                        if (j>0){
                            ret += "_";
                        }
                        ret += Array1[j];
                    }
                    if (ret.toUpperCase().lastIndexOf(".PPT") == -1){
                        ret += ".PPT";
                    }
                    break;
                default :
                    File file2 = new File(file[1]);
                    String[] Array2 =
Pattern.compile("_").split(file2.getName());
                    for (int i=0; i < Array1.length; i++){
                        if (Array1[i].compareTo(Array2[i])!=0){
                            if (i==0){
                               ret=file[0];
                            }else{
                            	if (file1.getParent()!=null){
                            		ret=file1.getParent() + "/";
                            	}else{
                            		ret="";
                            	}
                                for (int j=0; j < i; j++){
                                    if (j>0){
                                        ret += "_";
                                    }
                                    ret += Array1[j];
                                }
                                if (ret.toUpperCase().lastIndexOf(".PPT") ==
-1){
                                    ret += ".PPT";
                                }
                            }
                        }
                    }
            }
        }catch (Exception e){
            log.writeln("Error! Get merged ppt name ! ");
            e.printStackTrace(log.pw);
            System.err.println("Error! Get merged ppt name ! ");
            e.printStackTrace();
        }
        return ret;
    }

    public static String concatenateFiles( String file[] ) {

        String filename = "";

        try {
            filename = GetResultFileName(file);
            if (filename.length()==0){
                //Error! Get merged ppt name
                filename = file[0];
            }
            SlideShow write_SlideShow = new SlideShow( new HSLFSlideShow(
file[0] ) );
            // Get page size
            Dimension write_pgsize = write_SlideShow.getPageSize();

            for (int  i = 1; i < file.length; i++) {
                SlideShow read_SlideShow = new SlideShow( new HSLFSlideShow(
file[i] ) );
                // Add Font 
                for (int k=0; k < read_SlideShow.getNumberOfFonts(); k++){
                    PPFont rf=read_SlideShow.getFont(k);
                    int j=0;
                    for (j=0; j < write_SlideShow.getNumberOfFonts(); j++){
                        if (rf.equals(write_SlideShow.getFont(j))){
                            break;
                        }
                    }
                    if (j>=write_SlideShow.getNumberOfFonts()){
                        write_SlideShow.addFont(rf);
                    }
                }
                // Get page size
                Dimension read_pgsize = read_SlideShow.getPageSize();
                Slide read_slides[] = read_SlideShow.getSlides();
                // Get Slide number
                int slnum=0;
                for ( Slide sld : read_slides ) {
                    Slide write_slide = write_SlideShow.createSlide();
                    Shape shapes[] = sld.getShapes();

                    for ( Shape shape : shapes ) {
                        try {
                            if (shape instanceof Picture) {
                                Picture pict = (Picture) shape;
                                PictureData pictData =
pict.getPictureData();

                                int idx =
write_SlideShow.addPicture(pictData.
                                        getData(), pictData.getType());

                                Picture p = new Picture(idx);
                                Rectangle write_rt = shape.getAnchor();
                                write_rt.x = write_rt.x * write_pgsize.width
/
                                             read_pgsize.width;
                                write_rt.width = write_rt.width *
                                                 write_pgsize.width /
                                                 read_pgsize.width;
                                write_rt.y = write_rt.y *
write_pgsize.height /
                                             read_pgsize.height;
                                write_rt.height = write_rt.height *
                                                  write_pgsize.height /
                                                  read_pgsize.height;
                                p.setAnchor(write_rt);
                                write_slide.addShape(p);
                            } else if (shape instanceof TextBox) {
                                TextBox read_tb = (TextBox) shape;
                                TextBox write_tb = new TextBox();
                                Rectangle write_rt = shape.getAnchor();
                                write_rt.x = write_rt.x * write_pgsize.width
/
                                             read_pgsize.width;
                                write_rt.width = write_rt.width *
                                                 write_pgsize.width /
                                                 read_pgsize.width;
                                write_rt.y = write_rt.y *
write_pgsize.height /
                                             read_pgsize.height;
                                write_rt.height = write_rt.height *
                                                  write_pgsize.height /
                                                  read_pgsize.height;
                                write_tb.setAnchor(write_rt);

                                write_tb.setText(read_tb.getText());

                                if (read_tb.getHyperlink() != null) {
                                    int link_id =
write_SlideShow.addHyperlink(
                                            read_tb.getHyperlink());
                                    write_tb.setHyperlink(link_id,
                                           
read_tb.getHyperlink().getStartIndex(),
                                           
read_tb.getHyperlink().getEndIndex());
                                }

                               
write_tb.setFillColor(read_tb.getFillColor());
                                write_tb.setHorizontalAlignment(read_tb.
                                        getHorizontalAlignment());
                                write_tb.setVerticalAlignment(read_tb.
                                        getVerticalAlignment());
                                write_tb.setWordWrap(read_tb.getWordWrap());

                               
write_tb.setMarginLeft(read_tb.getMarginLeft());
                               
write_tb.setMarginTop(read_tb.getMarginTop());
                               
write_tb.setMarginRight(read_tb.getMarginRight());
                               
write_tb.setMarginBottom(read_tb.getMarginBottom());

                                RichTextRun read_rtx = read_tb.getTextRun().
                                        getRichTextRuns()[0];
                                RichTextRun write_rtx =
write_tb.getTextRun().
                                        getRichTextRuns()[0];

                                write_rtx.setBold(read_rtx.isBold());
                                write_rtx.setItalic(read_rtx.isItalic());
                               
write_rtx.setShadowed(read_rtx.isShadowed());
                               
write_rtx.setUnderlined(read_rtx.isUnderlined());

                               
write_rtx.setFontName(read_rtx.getFontName());
                               
write_rtx.setFontSize(read_rtx.getFontSize());
                               
write_rtx.setFontColor(read_rtx.getFontColor());

                                write_slide.addShape(write_tb);
                            } else if (shape instanceof Line) {
                                Line read_line = (Line) shape;
                                Line write_line = new Line();
                                // Позиционирование
                                Rectangle write_rt = shape.getAnchor();
                                write_rt.x = write_rt.x * write_pgsize.width
/
                                             read_pgsize.width;
                                write_rt.width = write_rt.width *
                                                 write_pgsize.width /
                                                 read_pgsize.width;
                                write_rt.y = write_rt.y *
write_pgsize.height /
                                             read_pgsize.height;
                                write_rt.height = write_rt.height *
                                                  write_pgsize.height /
                                                  read_pgsize.height;
                                write_line.setAnchor(write_rt);

                               
write_line.setFillColor(read_line.getFillColor());
                               
write_line.setLineColor(read_line.getLineColor());
                               
write_line.setLineDashing(read_line.getLineDashing());
                               
write_line.setLineStyle(read_line.getLineStyle());
                               
write_line.setLineWidth(read_line.getLineWidth());
                               
write_line.setRotation(read_line.getRotation());
                                
                                // Hyperlink
                                if (read_line.getHyperlink() != null) {
                                    Hyperlink
read_hl=read_line.getHyperlink();
                                    Hyperlink write_hl = new Hyperlink();
                                    write_hl.setTitle(read_hl.getTitle());
                                   
write_hl.setAddress(read_hl.getAddress());
                                    write_hl.setType(read_hl.getType());
                                    write_SlideShow.addHyperlink(write_hl);
                                    write_line.setHyperlink(write_hl);
                                }

                                write_slide.addShape(write_line);
                            } else if (shape instanceof Table) {
                                Table read_table = (Table) shape;
                                Table write_table = new Table(read_table.
                                        getNumberOfRows(),
                                                   
read_table.getNumberOfColumns());
                                // Position
                                Rectangle write_rt = shape.getAnchor();
                                write_rt.x = write_rt.x * write_pgsize.width
/
                                             read_pgsize.width;
                                write_rt.width = write_rt.width *
                                                 write_pgsize.width /
                                                 read_pgsize.width;
                                write_rt.y = write_rt.y *
write_pgsize.height /
                                             read_pgsize.height;
                                write_rt.height = write_rt.height *
                                                  write_pgsize.height /
                                                  read_pgsize.height;
                                write_table.setAnchor(write_rt);
                                for (int row = 0; row <
read_table.getNumberOfRows();
                                               row++) {
                                    for (int col = 0;
                                                   col <
read_table.getNumberOfColumns();
                                                   col++) {
                                        TableCell read_cell =
read_table.getCell(
                                                row, col);
                                        if (read_cell != null) {
                                            TableCell write_cell =
write_table.
                                                    getCell(row, col);
                                            // Cell 
                                            if (read_cell.getText() != null)
{
                                               
write_cell.setText(read_cell.
                                                        getText());
                                            }
                                            // Hyperlink
                                            if (read_cell.getHyperlink() !=
null) {
                                                int link_id =
write_SlideShow.addHyperlink(
                                                       
read_cell.getHyperlink());
                                               
write_cell.setHyperlink(link_id,
                                                       
read_cell.getHyperlink().getStartIndex(),
                                                       
read_cell.getHyperlink().getEndIndex());
                                            }
                                            // Font
                                            RichTextRun read_rtx =
read_cell.
                                                   
getTextRun().getRichTextRuns()[
                                                    0];
                                            RichTextRun write_rtx =
write_cell.
                                                   
getTextRun().getRichTextRuns()[
                                                    0];
                                           
write_rtx.setBold(read_rtx.isBold());
                                           
write_rtx.setItalic(read_rtx.isItalic());
                                            write_rtx.setShadowed(read_rtx.
                                                    isShadowed());
                                           
write_rtx.setUnderlined(read_rtx.
                                                    isUnderlined());
                                            write_rtx.setFontName(read_rtx.
                                                    getFontName());
                                            write_rtx.setFontSize(read_rtx.
                                                    getFontSize());
                                            write_rtx.setFontColor(read_rtx.
                                                    getFontColor());
                                            // Size
                                            write_rt =
read_cell.getAnchor();
                                            write_rt.x = write_rt.x *
                                                    write_pgsize.width /
                                                    read_pgsize.width;
                                            write_rt.width = write_rt.width
*
                                                    write_pgsize.width /
                                                    read_pgsize.width;
                                            write_rt.y = write_rt.y *
                                                    write_pgsize.height /
                                                    read_pgsize.height;
                                            write_rt.height =
write_rt.height *
                                                    write_pgsize.height /
                                                    read_pgsize.height;
                                            write_cell.setAnchor(write_rt);
                                            // Border
                                            // Left
                                            Line borderLeft = write_table.
                                                    createBorder();
                                            if (read_cell.getBorderLeft() !=
null) {

                                               
borderLeft.setLineColor(read_cell.
                                                        getBorderLeft().
                                                        getLineColor());
                                               
borderLeft.setLineStyle(read_cell.
                                                        getBorderLeft().
                                                        getLineStyle());
                                               
borderLeft.setLineWidth(read_cell.
                                                        getBorderLeft().
                                                        getLineWidth());
                                               
borderLeft.setLineDashing(read_cell.
                                                        getBorderLeft().
                                                        getLineDashing());
                                            } else {
                                               
borderLeft.setLineColor(Color.BLACK);
                                                borderLeft.setLineStyle(
                                                        HSSFSimpleShape.
                                                        LINESTYLE_SOLID);
                                            }
                                           
write_cell.setBorderLeft(borderLeft);
                                            // Top
                                            Line borderTop = write_table.
                                                    createBorder();
                                            if (read_cell.getBorderTop() !=
null) {

                                               
borderTop.setLineColor(read_cell.
                                                       
getBorderTop().getLineColor());
                                               
borderTop.setLineStyle(read_cell.
                                                       
getBorderTop().getLineStyle());
                                               
borderTop.setLineWidth(read_cell.
                                                       
getBorderTop().getLineWidth());
                                               
borderTop.setLineDashing(read_cell.
                                                        getBorderTop().
                                                        getLineDashing());
                                            } else {
                                               
borderTop.setLineColor(Color.BLACK);
                                                borderTop.setLineStyle(
                                                        HSSFSimpleShape.
                                                        LINESTYLE_SOLID);
                                            }
                                           
write_cell.setBorderTop(borderTop);
                                            // Right
                                            Line borderRight = write_table.
                                                    createBorder();
                                            if (read_cell.getBorderRight()
!= null) {

                                               
borderRight.setLineColor(read_cell.
                                                        getBorderRight().
                                                        getLineColor());
                                               
borderRight.setLineStyle(read_cell.
                                                        getBorderRight().
                                                        getLineStyle());
                                               
borderRight.setLineWidth(read_cell.
                                                        getBorderRight().
                                                        getLineWidth());
                                                borderRight.setLineDashing(
                                                        read_cell.
                                                        getBorderRight().
                                                        getLineDashing());
                                            } else {
                                               
borderRight.setLineColor(Color.
                                                        BLACK);
                                                borderRight.setLineStyle(
                                                        HSSFSimpleShape.
                                                        LINESTYLE_SOLID);
                                            }
                                           
write_cell.setBorderRight(borderRight);
                                            // Bottom
                                            Line borderBottom = write_table.
                                                    createBorder();
                                            if (read_cell.getBorderBottom()
!= null) {

                                               
borderBottom.setLineColor(read_cell.
                                                        getBorderBottom().
                                                        getLineColor());
                                               
borderBottom.setLineStyle(read_cell.
                                                        getBorderBottom().
                                                        getLineStyle());
                                               
borderBottom.setLineWidth(read_cell.
                                                        getBorderBottom().
                                                        getLineWidth());
                                                borderBottom.setLineDashing(
                                                        read_cell.
                                                        getBorderBottom().
                                                        getLineDashing());
                                            } else {
                                               
borderBottom.setLineColor(Color.
                                                        BLACK);
                                                borderBottom.setLineStyle(
                                                        HSSFSimpleShape.
                                                        LINESTYLE_SOLID);
                                            }
                                           
write_cell.setBorderBottom(borderBottom);
                                            // Fill
                                           
write_cell.setFillColor(read_cell.
                                                    getFillColor());
                                            // Text orientation
                                           
write_cell.setHorizontalAlignment(
                                                    read_cell.
                                                   
getHorizontalAlignment());
                                            write_cell.setVerticalAlignment(
                                                   
read_cell.getVerticalAlignment());
                                           
write_cell.setMarginLeft(read_cell.
                                                    getMarginLeft());
                                           
write_cell.setMarginTop(read_cell.
                                                    getMarginTop());
                                           
write_cell.setMarginRight(read_cell.
                                                    getMarginRight());
                                           
write_cell.setMarginBottom(read_cell.
                                                    getMarginBottom());
                                           
write_cell.setWordWrap(read_cell.
                                                    getWordWrap());
                                        }
                                    }
                                }
                                write_slide.addShape(write_table);
                            } else if (shape instanceof AutoShape) {
                                AutoShape read_shape = (AutoShape) shape;
                                AutoShape write_shape = new
AutoShape(read_shape.
                                        getShapeType());
                                //
                               
write_shape.setLineColor(read_shape.getLineColor());
                                write_shape.setLineDashing(read_shape.
                                        getLineDashing());
                               
write_shape.setLineStyle(read_shape.getLineStyle());
                               
write_shape.setLineWidth(read_shape.getLineWidth());
                               
write_shape.setRotation(read_shape.getRotation());
                                // Text
                                if (read_shape.getText() != null) {
                                   
write_shape.setText(read_shape.getText());
                                    // Font
                                    RichTextRun read_rtx =
read_shape.getTextRun().
                                            getRichTextRuns()[0];
                                    RichTextRun write_rtx =
write_shape.getTextRun().
                                            getRichTextRuns()[0];
                                    write_rtx.setBold(read_rtx.isBold());
                                   
write_rtx.setItalic(read_rtx.isItalic());
                                   
write_rtx.setShadowed(read_rtx.isShadowed());
                                   
write_rtx.setUnderlined(read_rtx.isUnderlined());
                                   
write_rtx.setFontName(read_rtx.getFontName());
                                   
write_rtx.setFontSize(read_rtx.getFontSize());
                                   
write_rtx.setFontColor(read_rtx.getFontColor());
                                    // Text position
                                   
write_shape.setHorizontalAlignment(read_shape.
                                            getHorizontalAlignment());
                                   
write_shape.setVerticalAlignment(read_shape.
                                            getVerticalAlignment());
                                    write_shape.setMarginLeft(read_shape.
                                            getMarginLeft());
                                    write_shape.setMarginTop(read_shape.
                                            getMarginTop());
                                    write_shape.setMarginRight(read_shape.
                                            getMarginRight());
                                    write_shape.setMarginBottom(read_shape.
                                            getMarginBottom());
                                   
write_shape.setWordWrap(read_shape.getWordWrap());
                                }
                                // Hyperlink
                                if (read_shape.getHyperlink() != null) {
                                    int link_id =
write_SlideShow.addHyperlink(
                                            read_shape.getHyperlink());
                                    write_shape.setHyperlink(link_id,
                                           
read_shape.getHyperlink().getStartIndex(),
                                           
read_shape.getHyperlink().getEndIndex());
                                }
                                // Fill
                               
write_shape.setFillColor(read_shape.getFillColor());
                                // Size
                                Rectangle write_rt = shape.getAnchor();
                                if (write_rt != null) {
                                    write_rt.x = write_rt.x *
write_pgsize.width /
                                                 read_pgsize.width;
                                    write_rt.width = write_rt.width *
                                                     write_pgsize.width /
                                                     read_pgsize.width;
                                    write_rt.y = write_rt.y *
write_pgsize.height /
                                                 read_pgsize.height;
                                    write_rt.height = write_rt.height *
                                                      write_pgsize.height /
                                                      read_pgsize.height;
                                    if ((write_rt.width != 0) &&
                                        (write_rt.height != 0)) {
                                        try {
                                            write_shape.setAnchor(write_rt);
                                        } catch (Exception e) {
                                            log.writeln("Error setAnchor!
File [" +
                                                    file[i] + "]. Slide N ["
+
                                                    slnum + "]");
                                            e.printStackTrace(log.pw);
                                        }
                                    }
                                }
                                try {
                                    write_slide.addShape(write_shape);
                                } catch (Exception e) {
                                    log.writeln(
                                            "Error write AutoShape ! File ["
+
                                                    file[i] + "]. Slide N ["
+
                                                    slnum + "]");
                                    e.printStackTrace(log.pw);
                                }
                                //}else if (shape instanceof SimpleShape){
                                //SimpleShape read_shape =
(SimpleShape)shape;
                                //SimpleShape write_shape = new
SimpleShape(read_shape.getShapeType());
                            } else {
                                //
                                //HSSFPatriarch patriarch =
write_SlideShow.createDrawingPatriarch();
                                //    a = new HSSFClientAnchor( 0, 0, 1023,
255, (short) 1, 0, (short) 1, 0 );
                                //    HSSFSimpleShape write_shape =
patriarch.createSimpleShape(a1);
                               
//shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
                                //
                                // Hyperlink
                                if (shape.getHyperlink() != null) {
                                   
write_SlideShow.addHyperlink(shape.getHyperlink());
                                }
                                
                                Rectangle write_rt = shape.getAnchor();
                                if (write_rt != null) {
                                    write_rt.x = write_rt.x *
write_pgsize.width /
                                                 read_pgsize.width;
                                    write_rt.width = write_rt.width *
                                                     write_pgsize.width /
                                                     read_pgsize.width;
                                    write_rt.y = write_rt.y *
write_pgsize.height /
                                                 read_pgsize.height;
                                    write_rt.height = write_rt.height *
                                                      write_pgsize.height /
                                                      read_pgsize.height;
                                    if ((write_rt.width != 0) &&
                                        (write_rt.height != 0)) {
                                        try {
                                            shape.setAnchor(write_rt);
                                        } catch (Exception e) {
                                            log.writeln("Error setAnchor!
File [" +
                                                    file[i] + "]. Slide N ["
+
                                                    slnum + "]");
                                            e.printStackTrace(log.pw);
                                        }
                                    }
                                }
                                try {
                                    write_slide.addShape(shape);
                                } catch (Exception e) {
                                    log.writeln("Error addShape! File [" +
                                                    file[i] + "]. Slide N ["
+
                                                    slnum + "]");
                                    e.printStackTrace(log.pw);
                                }
                            }
                        }catch(Exception e){
                            e.printStackTrace(log.pw);
                            e.printStackTrace();
                        }
                    }
                }
            }
            FileOutputStream out = new FileOutputStream( filename );
            write_SlideShow.write( out );
            out.close();
        }
        catch ( Exception e ) {
            e.printStackTrace();
            return null;
        }
        return filename;
    }

    /**
     * Prints out a message.
     *
     * @param msg the message to be printed.
     */
    private static void printMessage(String[] msg) {
      for (String s : msg) {
        System.out.println(s);
      }
    }

    public static void main(String[] args) {

        SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
        boolean help = parser.containsKey("help", "h");
        if (help || (args.length<1)){
            printMessage(USAGE_MESSAGE);
            System.exit(1);
        }
        LogFileName=GetLogFileName(args);
        log = new Logger1(LogFileName);
        log.start();
        if (log.isWindows){
               // Setup console output
               try {
                   String consoleEnc = System.getProperty(
                           "console.encoding", log.defaultEncoding);
                   System.setOut(new CodepagePrintStream(System.out,
                           consoleEnc));
                   System.setErr(new CodepagePrintStream(System.err,
                           consoleEnc));
               } catch (UnsupportedEncodingException e) {
                   log.stop();
                   System.out.println("Error! Unable to setup console
codepage : " + e.toString());
                   return;
               }
        }
        if (concatenateFiles(args) == null){
            System.out.println("Some error found");
            log.writeln("Some error found");
            log.stop();
            System.exit(1);
        }else{
            System.out.println("All Ok");
            log.writeln("All Ok");
            log.stop();
            System.exit(0);
        }
    }
}

Good Like.
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/ApachePOI-HSLF-powerpoint-merging-text-color-problem-tp2297755p2848055.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: ApachePOI HSLF powerpoint merging text color problem

Posted by Yegor Kozlov <ye...@dinom.ru>.
Hi Jeff,

Can you upload the "template" and "merger" ppt files? I would like to debug your code and need sample data.

Ideally, can you create an issue in Bugzilla and attach to it MergeSlideshows.java and sample PPTs.

Would you like to contribute your code to HSLF examples?

Regards,
Yegor

> Hi All,
> 
> This question is mostly directed at Yegor Kozlov and Nick Burch since they
> wrote most of the classes involved.
> 
> I've rewritten the Groovy code I emailed out before in Java in case that
> helps anyone. It's attached.
> 
> Everything works great. I was very pleased that the old emails floating
> around the Internet saying that POI couldn't merge slideshows were
> out-of-date. EXCEPT when you get to line 85 of my class. The RichTextRuns
> report that their font.color property is white. Running this through a
> debugger drops me all the way into the SlideMaster's text runs to find
> that white color. Setting the color against the RichTextRun has no effect
> on the final outcome. I tried looping through the Slide's MasterSheet's
> TextRuns' RichTextRuns and setting the font.color there before starting
> the merge but that throws a null pointer exception in
> TextRun.ensureStyleAtomPresent() at this line:
> runAtomsParent.addChildAfter(_styleAtom, addAfter);
> 
> Unlike things like font.name or the list of Pictures which are stored at
> the SlideShow level and referenced other places, the font.color is
> specifically set for the RichTextRun. Is it possible that when the
> SlideShow is written out that this property isn't referenced?  I'm really
> at a loss to figure this out much further.
> 
> Sincerely,
> 
> Jeff Lavezzo
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org