OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Spreadsheet : How to speed up images insert

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Calambo
General User
General User


Joined: 06 Jan 2004
Posts: 31
Location: Paris

PostPosted: Wed Apr 14, 2004 1:50 am    Post subject: Spreadsheet : How to speed up images insert Reply with quote

I have a java program that fill a spreasheet with elements from a database. It's not very fast, and i try to speed up the all process.
For text data, i can use a data array to fill the value in one step, but the main lack of speed is when i insert images in cell (for exemple 30mn to insert 5000 images), and i can't find a way to speed up.

This is my code :

Code:

XColumnRowRange range = (XColumnRowRange) UnoRuntime.queryInterface(
   XColumnRowRange.class, spreadsheet);
XTableRows rows = range.getRows();
XTableColumns columns = range.getColumns();
XPropertySet props;

for (int rowNumber=0; rowNumber<rowSize; rowNumber++) {
   try {
      XCell cell = spreadsheet.getCellByPosition(colNumber, rowNumber+1);
      XMultiServiceFactory xCalcFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
         XMultiServiceFactory.class, document);
      try {
         Object shape = xCalcFactory.createInstance(
            "com.sun.star.drawing.GraphicObjectShape");
         XPropertySet shapeProperties = (XPropertySet)UnoRuntime.queryInterface(
            XPropertySet.class, shape);
         XShape xShape = (XShape)UnoRuntime.queryInterface(
            XShape.class, shape);

         String imagePath = myImagePath;
         File image = new File(imagePath);
         if (image.exists()) {
            shapeProperties.setPropertyValue("GraphicURL", "file:///" + imagePath);
            drawPage.add(xShape);

            /* Change the size of the bitmap */
            try {
               XBitmap bitmap = (XBitmap) UnoRuntime.queryInterface(
                  XBitmap.class, shapeProperties.getPropertyValue("GraphicObjectFillBitmap"));
               xShape.setPosition(new Point(colSize+50, rowSize+50));
               int width = (int) bitmap.getSize().Width;
               int height = (int) bitmap.getSize().Height;
               if (width < height) {
                  width = 2000 * width / height;
                  height = 2000;
               } else {
                  height = 2000 * height / width;
                  width = 2000;
               }
            } catch (com.sun.star.beans.UnknownPropertyException e) {
            } catch (com.sun.star.beans.PropertyVetoException e) {
            } catch (Exception e) {
            }
         }
      } catch (com.sun.star.beans.UnknownPropertyException e) {
      } catch (com.sun.star.beans.PropertyVetoException e) {
      } catch (com.sun.star.uno.Exception e) {
      }
   } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
   }
}


After a few tests, I have found that the lines that takes very long time is :
Object shape = xCalcFactory.createInstance("com.sun.star.drawing.GraphicObjectShape"); and
XBitmap bitmap = (XBitmap) UnoRuntime.queryInterface(XBitmap.class, shapeProperties.getPropertyValue("GraphicObjectFillBitmap"));

Is there something I can change to speed up the insert ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group