Package com.sun.star.frame

Examples of com.sun.star.frame.XStorable


        if (objectDocumentToStore == null) {
            Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module);
        }

        // Getting an object that will offer a simple way to store a document to a URL.
        XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);
        if (xstorable == null) {
            Debug.logError("Could not get XStorable object from UnoRuntime.queryInterface", module);
        }

        // Preparing properties for converting the document
        String filterName = getFilterNameFromMimeType(outputMimeType);
        propertyvalue = new PropertyValue[4];

        propertyvalue[0] = new PropertyValue();
        propertyvalue[0].Name = "OutputStream";
        OpenOfficeByteArrayOutputStream os = new OpenOfficeByteArrayOutputStream();
        propertyvalue[0].Value = os;
        // Setting the filter name
        propertyvalue[1] = new PropertyValue();
        propertyvalue[1].Name = "FilterName";
        propertyvalue[1].Value = filterName;
        // Setting the flag for overwriting
        propertyvalue[3] = new PropertyValue();
        propertyvalue[3].Name = "Overwrite";
        propertyvalue[3].Value = Boolean.TRUE;
        // For PDFs
        propertyvalue[2] = new PropertyValue();
        propertyvalue[2].Name = "CompressionMode";
        propertyvalue[2].Value = "1";

        xstorable.storeToURL("private:stream", propertyvalue);
        //xstorable.storeToURL("file:///home/byersa/testdoc1_file.pdf", propertyvalue);

        // Getting the method dispose() for closing the document
        XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xstorable);
View Full Code Here


            // Loading the wanted document
            Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue);

            // Getting an object that will offer a simple way to store a document to a URL.
            XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);

            // Preparing properties for comparing the document
            propertyvalue = new PropertyValue[ 1 ];
            // Setting the flag for overwriting
            propertyvalue[ 0 ] = new PropertyValue();
            propertyvalue[ 0 ].Name = "URL";
            propertyvalue[ 0 ].Value = stringOriginalFile;
            // Setting the filter name
            //propertyvalue[ 1 ] = new PropertyValue();
            //propertyvalue[ 1 ].Name = "FilterName";
            //propertyvalue[ 1 ].Value = context.get("convertFilterName");
            XFrame frame = desktop.getCurrentFrame();
            //XFrame frame = (XFrame) UnoRuntime.queryInterface(XFrame.class, desktop);
            Object dispatchHelperObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.DispatchHelper", xcomponentcontext);
            XDispatchHelper dispatchHelper = (XDispatchHelper) UnoRuntime.queryInterface(XDispatchHelper.class, dispatchHelperObj);
            XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame);
            dispatchHelper.executeDispatch(dispatchProvider, ".uno:CompareDocuments", "", 0, propertyvalue);

            // Preparing properties for storing the document
            propertyvalue = new PropertyValue[ 1 ];
            // Setting the flag for overwriting
            propertyvalue[ 0 ] = new PropertyValue();
            propertyvalue[ 0 ].Name = "Overwrite";
            propertyvalue[ 0 ].Value = Boolean.valueOf(true);
            // Setting the filter name
            //propertyvalue[ 1 ] = new PropertyValue();
            //propertyvalue[ 1 ].Name = "FilterName";
            //propertyvalue[ 1 ].Value = context.get("convertFilterName");

            Debug.logInfo("stringOutFile: "+stringOutFile, module);
            // Storing and converting the document
            xstorable.storeToURL(stringOutFile, propertyvalue);

            // Getting the method dispose() for closing the document
            XComponent xcomponent = (XComponent) UnoRuntime.queryInterface(XComponent.class,
            xstorable);
View Full Code Here

    /** Load a document with arguments (text purposes)
     */
    protected void storeDocComponent(XComponent xDoc, String storeUrl) throws java.lang.Exception {
       
        XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, xDoc);
        PropertyValue[] storeProps = new PropertyValue[1];
        storeProps[0] = new PropertyValue();
        storeProps[0].Name = "FilterName";
        storeProps[0].Value = "MS Word 97";       

        xStorable.storeAsURL(storeUrl, storeProps);          
    }
View Full Code Here

          Object objectDocumentToStore =
          DocumentConverter.xcomponentloader.loadComponentFromURL(
          stringUrl, "_blank", 0, new PropertyValue[0] );
         
          // Getting an object that will offer a simple way to store a document to a URL.
          XStorable xstorable =
          ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
          objectDocumentToStore );
         
          // Preparing properties for converting the document
          PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
          // Setting the flag for overwriting
          propertyvalue[ 0 ] = new PropertyValue();
          propertyvalue[ 0 ].Name = "Overwrite";
          propertyvalue[ 0 ].Value = new Boolean(true);
          // Setting the filter name
          propertyvalue[ 1 ] = new PropertyValue();
          propertyvalue[ 1 ].Name = "FilterName";
          propertyvalue[ 1 ].Value = DocumentConverter.stringConvertType;
         
          // Appending the favoured extension to the origin document name
          int index = stringUrl.lastIndexOf('.');
          if (index >= 0)
              stringUrl = stringUrl.substring(0, index + 1);
          stringUrl = stringUrl + DocumentConverter.stringExtension;
         
          // Storing and converting the document
          xstorable.storeAsURL( stringUrl, propertyvalue );
         
          // Getting the method dispose() for closing the document
          XComponent xcomponent =
          ( XComponent ) UnoRuntime.queryInterface( XComponent.class,
          xstorable );
View Full Code Here

      propertyvalue[ 0 ].Name = "Hidden";
      propertyvalue[ 0 ].Value = new Boolean(true);
     
      Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(
      sLoadUrl.toString(), "_blank", 0, propertyvalue );
      XStorable xstorable =
      ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
      objectDocumentToStore );

      propertyvalue = new PropertyValue[ 2 ];
      propertyvalue[ 0 ] = new PropertyValue();
      propertyvalue[ 0 ].Name = "Overwrite";
      propertyvalue[ 0 ].Value = new Boolean(true);
      propertyvalue[ 1 ] = new PropertyValue();
      propertyvalue[ 1 ].Name = "FilterName";
      propertyvalue[ 1 ].Value = "swriter: StarOffice XML (Writer)";
      xstorable.storeAsURL( sSaveUrl.toString(), propertyvalue );

      System.out.println("\ndocument \"" + sLoadUrl + "\" saved under \"" + sSaveUrl + "\"\n");
     
      XCloseable xCloseable = ( XCloseable ) UnoRuntime.queryInterface(
          XCloseable.class, objectDocumentToStore );
View Full Code Here

      Object objectDocumentToStore =
      xcomponentloader.loadComponentFromURL(
      stringUrl, "_blank", 0, propertyvalue );
     
      // Getting an object that will offer a simple way to store a document to a URL.
      XStorable xstorable =
      ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
      objectDocumentToStore );
     
      // Preparing properties for converting the document
      propertyvalue = new PropertyValue[ 2 ];
      // Setting the flag for overwriting
      propertyvalue[ 0 ] = new PropertyValue();
      propertyvalue[ 0 ].Name = "Overwrite";
      propertyvalue[ 0 ].Value = new Boolean(true);
      // Setting the filter name
      propertyvalue[ 1 ] = new PropertyValue();
      propertyvalue[ 1 ].Name = "FilterName";
      propertyvalue[ 1 ].Value = stringConvertType;
     
      // Appending the favoured extension to the origin document name
      stringConvertedFile = stringUrl + "." + stringExtension;
     
      // Storing and converting the document
      xstorable.storeAsURL( stringConvertedFile, propertyvalue );
     
      // Getting the method dispose() for closing the document
      XComponent xcomponent =
      ( XComponent ) UnoRuntime.queryInterface( XComponent.class,
      xstorable );
View Full Code Here

  {
    if (isDocumentLoaded() == false)
      throw new java.io.IOException("The document has not been loaded.");
//    else if (mDocumentURL.startsWith("private:") == true)
//      throw new java.io.IOException("The document URL has not been defined.");
    XStorable  storable  = (XStorable)UnoRuntime.queryInterface(
      XStorable.class, mFrame.getController().getModel());
    try {
      storable.store();
    } catch (com.sun.star.io.IOException exp) {
      throw new java.io.IOException(exp.getMessage());
    }
  }
View Full Code Here

  {
    if (mFrame == null)
      throw new java.io.IOException("no document loaded");

    XModel xModel = mFrame.getController().getModel();
    XStorable xStorable =
      (XStorable)UnoRuntime.queryInterface(XStorable.class, xModel);

    File tmpFile = File.createTempFile("officebean", "tmp");

    try {
      String tmpFileName = "file:///" + tmpFile.getAbsolutePath();
      xStorable.storeToURL(tmpFileName, new PropertyValue[0]);

      byte[] buffer = new byte[1024];
      InputStream in = new FileInputStream(tmpFile);

      int len = 0;
View Full Code Here

        } catch (Exception e) {
            log.println("Nothing to be removed - OK");
        }

        // registering source in DatabaseContext
        XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class, xDBDoc);
        String aFile = utils.getOfficeTemp ((XMultiServiceFactory) Param.getMSF ())+"DataSource.odb";    
        try{
            store.storeAsURL(aFile,new PropertyValue[]{});
        } catch (IOException e){
            log.println("Could not store datasource 'aFile'" );
            e.printStackTrace ();
            throw new StatusException("Could not save ", e) ;
        } catch (Exception e){
View Full Code Here

        Object oDBContext = null;
        Object oDBSource = null;
        Object newQuery = null;
        Object toolkit = null;
        XStorable store = null;       

        try {
            oDBContext = ((XMultiServiceFactory) Param.getMSF())
                              .createInstance("com.sun.star.sdb.DatabaseContext");
            oDBSource = ((XMultiServiceFactory) Param.getMSF())
                             .createInstance("com.sun.star.sdb.DataSource");
            newQuery = ((XMultiServiceFactory) Param.getMSF())
                            .createInstance("com.sun.star.sdb.QueryDefinition");
            toolkit = ((XMultiServiceFactory) Param.getMSF())
                           .createInstance("com.sun.star.awt.Toolkit");
        } catch (com.sun.star.uno.Exception e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed("Couldn't create instance"));
        }

        String mysqlURL = (String) Param.get("mysql.url");

        if (mysqlURL == null) {
            throw new StatusException(Status.failed(
                                              "Couldn't get 'mysql.url' from ini-file"));
        }

        user = (String) Param.get("jdbc.user");
        password = (String) Param.get("jdbc.password");

        if ((user == null) || (password == null)) {
            throw new StatusException(Status.failed(
                                              "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file"));
        }

        PropertyValue[] info = new PropertyValue[2];
        info[0] = new PropertyValue();
        info[0].Name = "user";
        info[0].Value = user;
        info[1] = new PropertyValue();
        info[1].Name = "password";
        info[1].Value = password;

        XPropertySet propSetDBSource = (XPropertySet) UnoRuntime.queryInterface(
                                               XPropertySet.class, oDBSource);

        try {
            propSetDBSource.setPropertyValue("URL", mysqlURL);
            propSetDBSource.setPropertyValue("Info", info);
        } catch (com.sun.star.lang.WrappedTargetException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.beans.PropertyVetoException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.beans.UnknownPropertyException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        }

        try {
            log.println ("writing database file ...");
            XDocumentDataSource xDDS = (XDocumentDataSource)
            UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource);
            store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
                    xDDS.getDatabaseDocument());
            aFile = utils.getOfficeTemp ((XMultiServiceFactory) Param.getMSF ())+"TableWindow.odb";
            log.println("... filename will be "+aFile);
            store.storeAsURL(aFile,new PropertyValue[]{});
            log.println("... done");
        } catch (com.sun.star.uno.Exception e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed("Couldn't register object"));
        }

        isolConnection = (XIsolatedConnection) UnoRuntime.queryInterface(
                                                     XIsolatedConnection.class,
                                                     oDBSource);

        XConnection connection = null;
        XStatement statement = null;

        final String tbl_name1 = "tst_table1";
        final String tbl_name2 = "tst_table2";
        final String col_name1 = "id1";
        final String col_name2 = "id2";

        try {
            connection = isolConnection.getIsolatedConnection(user, password);
            statement = connection.createStatement();
            statement.executeUpdate("drop table if exists " + tbl_name1);
            statement.executeUpdate("drop table if exists " + tbl_name2);
            statement.executeUpdate("create table " + tbl_name1 + " (" +
                                    col_name1 + " int)");
            statement.executeUpdate("create table " + tbl_name2 + " (" +
                                    col_name2 + " int)");
        } catch (com.sun.star.sdbc.SQLException e) {
            try {
                shortWait();
                connection = isolConnection.getIsolatedConnection(user,
                                                                  password);
                statement = connection.createStatement();
                statement.executeUpdate("drop table if exists " + tbl_name1);
                statement.executeUpdate("drop table if exists " + tbl_name2);
                statement.executeUpdate("create table " + tbl_name1 + " (" +
                                        col_name1 + " int)");
                statement.executeUpdate("create table " + tbl_name2 + " (" +
                                        col_name2 + " int)");
            } catch (com.sun.star.sdbc.SQLException e2) {
                e2.printStackTrace(log);
                throw new StatusException(Status.failed("SQLException"));
            }
        }

        XQueryDefinitionsSupplier querySuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(
                                                       XQueryDefinitionsSupplier.class,
                                                       oDBSource);

        XNameAccess defContainer = querySuppl.getQueryDefinitions();

        XPropertySet queryProp = (XPropertySet) UnoRuntime.queryInterface(
                                         XPropertySet.class, newQuery);

        try {
            final String query = "select * from " + tbl_name1 + ", " +
                                 tbl_name2 + " where " + tbl_name1 + "." +
                                 col_name1 + "=" + tbl_name2 + "." +
                                 col_name2;
            queryProp.setPropertyValue("Command", query);
        } catch (com.sun.star.lang.WrappedTargetException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.lang.IllegalArgumentException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.beans.PropertyVetoException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        } catch (com.sun.star.beans.UnknownPropertyException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed(
                                              "Couldn't set property value"));
        }

        XNameContainer queryContainer = (XNameContainer) UnoRuntime.queryInterface(
                                                XNameContainer.class,
                                                defContainer);

        try {
            queryContainer.insertByName("Query1", newQuery);
            store.store();
            connection.close ();
        } catch (com.sun.star.lang.WrappedTargetException e) {
            e.printStackTrace(log);
            throw new StatusException(Status.failed("Couldn't insert query"));
        } catch (com.sun.star.container.ElementExistException e) {
View Full Code Here

TOP

Related Classes of com.sun.star.frame.XStorable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.