|
@@ -14,24 +14,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.util.HashMap;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
-import org.apache.commons.io.IOUtils;
|
|
|
|
|
|
import com.artofsolving.jodconverter.DocumentConverter;
|
|
|
-import com.artofsolving.jodconverter.DocumentFormat;
|
|
|
import com.artofsolving.jodconverter.DocumentFormatRegistry;
|
|
|
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
|
|
|
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException;
|
|
|
import com.artofsolving.jodconverter.openoffice.converter.StreamOpenOfficeDocumentConverter;
|
|
|
+import com.sun.star.awt.Point;
|
|
|
import com.sun.star.beans.PropertyValue;
|
|
|
import com.sun.star.container.XNamed;
|
|
|
import com.sun.star.document.XExporter;
|
|
@@ -39,10 +32,12 @@ import com.sun.star.document.XFilter;
|
|
|
import com.sun.star.drawing.XDrawPage;
|
|
|
import com.sun.star.drawing.XDrawPages;
|
|
|
import com.sun.star.drawing.XDrawPagesSupplier;
|
|
|
+import com.sun.star.drawing.XShape;
|
|
|
+import com.sun.star.drawing.XShapes;
|
|
|
import com.sun.star.frame.XComponentLoader;
|
|
|
import com.sun.star.lang.XComponent;
|
|
|
import com.sun.star.lang.XMultiComponentFactory;
|
|
|
-import com.sun.star.ucb.XFileIdentifierConverter;
|
|
|
+import com.sun.star.text.XText;
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
|
|
|
|
@@ -60,7 +55,7 @@ import com.sun.star.uno.UnoRuntime;
|
|
|
*/
|
|
|
public class OogieDocumentConverter extends AbstractDokeosDocumentConverter {
|
|
|
|
|
|
- public OogieDocumentConverter(OpenOfficeConnection connection, int width, int height) {
|
|
|
+ public OogieDocumentConverter(OpenOfficeConnection connection, int width, int height) {
|
|
|
super(connection, width, height);
|
|
|
}
|
|
|
|
|
@@ -100,6 +95,7 @@ public class OogieDocumentConverter extends AbstractDokeosDocumentConverter {
|
|
|
filterDatas[1].Name = "PixelHeight";
|
|
|
filterDatas[1].Value = new Integer(this.height);
|
|
|
filterDatas[2].Name = "LogicalWidth";
|
|
|
+
|
|
|
filterDatas[2].Value = new Integer(2000);
|
|
|
filterDatas[3].Name = "LogicalHeight";
|
|
|
filterDatas[3].Value = new Integer(2000);
|
|
@@ -110,20 +106,74 @@ public class OogieDocumentConverter extends AbstractDokeosDocumentConverter {
|
|
|
|
|
|
XDrawPages pages = pagesSupplier.getDrawPages();
|
|
|
int nbPages = pages.getCount();
|
|
|
-
|
|
|
+ String[] slidenames = new String[nbPages];
|
|
|
+ Arrays.fill(slidenames,"");
|
|
|
|
|
|
for (int i = 0; i < nbPages; i++) {
|
|
|
|
|
|
XDrawPage page = (XDrawPage) UnoRuntime.queryInterface(
|
|
|
com.sun.star.drawing.XDrawPage.class, pages
|
|
|
.getByIndex(i));
|
|
|
+ XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, page);
|
|
|
+ int top = 0;
|
|
|
+ String slidename = "";
|
|
|
+ for (int j = 0; j < xShapes.getCount(); j++) {
|
|
|
+ XShape firstXshape = (XShape)UnoRuntime.queryInterface(XShape.class, xShapes.getByIndex(j));
|
|
|
+ Point pos = firstXshape.getPosition();
|
|
|
+ if(pos.Y < top || top==0)
|
|
|
+ {
|
|
|
+ XText xText = (XText)UnoRuntime.queryInterface( XText.class, firstXshape );
|
|
|
+ if(xText!=null && xText.getString().length()>0)
|
|
|
+ {
|
|
|
+ top = pos.Y;
|
|
|
+ slidename = xText.getString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page);
|
|
|
+ if(slidename.length()==0)
|
|
|
+ {
|
|
|
+ slidename = "slide"+(i+1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int nbSpaces = 0;
|
|
|
+ String formatedSlidename = "";
|
|
|
+ slidename = slidename.replaceAll(" ", "_");
|
|
|
+ slidename = slidename.replaceAll("\n", "_");
|
|
|
+ slidename = slidename.replaceAll("__", "_");
|
|
|
+ slidename = slidename.replaceAll("\\W", "_");
|
|
|
+ slidename = slidename.replaceAll("__", "_");
|
|
|
+
|
|
|
+ for(int j=0 ; j<slidename.length() ; j++)
|
|
|
+ {
|
|
|
+ char currentChar = slidename.charAt(j);
|
|
|
+ if(currentChar==' ')
|
|
|
+ {
|
|
|
+ nbSpaces++;
|
|
|
+ }
|
|
|
+ if(nbSpaces == 4)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ formatedSlidename += slidename.charAt(j);
|
|
|
+ }
|
|
|
+ slidename = formatedSlidename.toLowerCase();
|
|
|
+ slidename = StringOperation.sansAccent(slidename);
|
|
|
+ }
|
|
|
+ int j=1;
|
|
|
+ String slidenamebackup = slidename;
|
|
|
+ Arrays.sort(slidenames);
|
|
|
+ while(Arrays.binarySearch(slidenames, slidename)>=0)
|
|
|
+ {
|
|
|
+ j++;
|
|
|
+ slidename = slidenamebackup+j;
|
|
|
+ }
|
|
|
+ slidenames[i] = slidename;
|
|
|
|
|
|
- xPageName.setName("slide"+(i+1));
|
|
|
- if(!xPageName.getName().equals("slide"+(i+1)) && !xPageName.getName().equals("page"+(i+1)))
|
|
|
- xPageName.setName((i+1)+"-"+xPageName.getName());
|
|
|
+ XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page);
|
|
|
|
|
|
+ xPageName.setName(slidename);
|
|
|
|
|
|
XMultiComponentFactory localServiceManager = ((DokeosSocketOfficeConnection)this.openOfficeConnection).getServiceManager();
|
|
|
Object GraphicExportFilter = localServiceManager
|
|
@@ -164,3 +214,6 @@ public class OogieDocumentConverter extends AbstractDokeosDocumentConverter {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|