Package com.sun.star.frame

Examples of com.sun.star.frame.XStorable


       
        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 ())+"JoinView.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"));
View Full Code Here


            xDSProps.setPropertyValue("URL", "sdbc:dbase:file:///.") ;
           
            XDocumentDataSource xDDS = (XDocumentDataSource)
            UnoRuntime.queryInterface(XDocumentDataSource.class, oInterface);
            XStorable store = (XStorable) UnoRuntime.queryInterface(XStorable.class,
            xDDS.getDatabaseDocument ());
            String aFile = utils.getOfficeTemp ((XMultiServiceFactory) Param.getMSF ())+"DatabaseContext.odb";
            log.println("store to '" + aFile + "'");
            store.storeAsURL(aFile,new PropertyValue[]{});           
           
            tEnv.addObjRelation("XNamingService.RegisterObject", oInterface) ;

            tEnv.addObjRelation("INSTANCE", oInterface);
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())+"ConnectionLine.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);
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

                    lProperties[1].Name  = "Overwrite";
                    lProperties[1].Value = new Boolean( true );

                    sTemp2Url = Helper.CreateTempFile( m_xContext );

                    XStorable xStore = ( com.sun.star.frame.XStorable )UnoRuntime.queryInterface ( XStorable.class, m_xModel );
                    if ( xStore == null )
                        throw new com.sun.star.uno.RuntimeException();

                    xStore.storeToURL( sTemp2Url, lProperties );
                    String sWikiCode = Helper.EachLine( sTemp2Url );

                    if ( aArticle.setArticle( sWikiCode, aSendDialog.m_sWikiComment, aSendDialog.m_bWikiMinorEdit ) )
                    {
                        bResult = true;
View Full Code Here

    public boolean storeDatabaseDocumentToTempPath(XComponent _xcomponent, String _storename){
    try{
        XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
        XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
        String storepath = FileAccess.getOfficePath(xMSF, "Temp", xSimpleFileAccess) + "/" + _storename;
        XStorable xStoreable = (XStorable) UnoRuntime.queryInterface(XStorable.class, _xcomponent);
        PropertyValue[] oStoreProperties = new PropertyValue[1];
        oStoreProperties[0] = Properties.createProperty("FilterName", "writer8");
        storepath += ".odt";
        xStoreable.storeAsURL(storepath, oStoreProperties);
        return true;
    } catch (Exception e) {
        e.printStackTrace(System.out);
        return false;
    }}
View Full Code Here

            showProperty(aFiltername);
            boolean bWorked = true;
           
            try
            {
                XStorable store =
                    (XStorable) UnoRuntime.queryInterface(
                        XStorable.class, _xComponent
                        );
                store.storeToURL(_sDestinationName, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
            }
            catch (com.sun.star.io.IOException e)
            {
                GlobalLogWriter.get().println("IO Exception caught.");
                GlobalLogWriter.get().println("Message: " + e.getMessage());
View Full Code Here

                if (_sOutputURL != null)
                {
                    if (_aGTA.isStoreAllowed())
                    {
                        // store the document in an other directory
                        XStorable aStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, _aDoc);
                        if (aStorable != null)
                        {
                            PropertyValue [] szEmptyArgs = new PropertyValue [0];
                           
                            GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document.");
                            _aGTA.getPerformance().startTime(PerformanceContainer.Store);
                            aStorable.storeAsURL(_sOutputURL, szEmptyArgs);
                            _aGTA.getPerformance().stopTime(PerformanceContainer.Store);

                            GlobalLogWriter.get().println(DateHelper.getDateTimeForHumanreadableLog() + " Store document done.");
                            TimeHelper.waitInSeconds(2, "After store as URL to:" + _sOutputURL);
                            GlobalLogWriter.get().println("Reload stored file test.");
View Full Code Here

            XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface( XServiceInfo.class, aDoc );
            // String sFilter = getFilterName_forExcel(xServiceInfo);
            // System.out.println("Filter is " + sFilter);

            // store the document in an other directory
            XStorable xStorable = (XStorable) UnoRuntime.queryInterface( XStorable.class, aDoc);
            if (xStorable == null)
            {
                GlobalLogWriter.get().println("com.sun.star.frame.XStorable is null");
                return;
            }
               
            String sFilterName = _aGTA.getExportFilterName();

            // check how many Properties should initialize
            int nPropertyCount = 0;
            // if (sFilterName != null && sFilterName.length() > 0)
            // {
            //     nPropertyCount ++;
            // }
           
            // initialize PropertyArray
            // PropertyValue [] aStoreProps = new PropertyValue[ nPropertyCount ];
            // int nPropertyIndex = 0;
            ArrayList aPropertyList = new ArrayList();
           
            String sExtension = "";

            if (sFilterName != null && sFilterName.length() > 0)
            {
                String sInternalFilterName = getInternalFilterName(sFilterName, xMSF);
                String sServiceName = getServiceNameFromFilterName(sFilterName, xMSF);
                   
                GlobalLogWriter.get().println("Filter detection:");
                // check if service name from file filter is the same as from the loaded document
                boolean bServiceFailed = false;
                if (sServiceName == null || sInternalFilterName == null)
                {
                    GlobalLogWriter.get().println("Given FilterName '" + sFilterName + "' seems to be unknown.");
                    bServiceFailed = true;
                }
                if (! xServiceInfo.supportsService(sServiceName))
                {
                    GlobalLogWriter.get().println("Service from FilterName '" + sServiceName + "' is not supported by loaded document.");
                    bServiceFailed = true;
                }
                if (bServiceFailed == true)
                {
                    GlobalLogWriter.get().println("Please check '" + PropertyName.DOC_CONVERTER_EXPORT_FILTER_NAME + "' in the property file.");
                    return;
                }

                if (sInternalFilterName != null && sInternalFilterName.length() > 0)
                {
                    // get the FileExtension, by the filter name, if we don't get a file extension
                    // we assume the is also no right filter name.
                    sExtension = getFileExtension(sInternalFilterName, xMSF);
                    if (sExtension == null)
                    {
                        GlobalLogWriter.get().println("Can't found an extension for filtername, take it from the source.");
                    }
                }

                PropertyValue Arg = new PropertyValue();
                Arg.Name = "FilterName";
                Arg.Value = sFilterName;
                // aStoreProps[nPropertyIndex ++] = Arg;
                aPropertyList.add(Arg);
                showProperty(Arg);
                GlobalLogWriter.get().println("FilterName is set to: " + sFilterName);
            }
                           
            String sOutputURL = "";
            try
            {
                // create the new filename with the extension, which is ok to the file format
                String sInputFileBasename = FileHelper.getBasename(_sInputFile);
                // System.out.println("InputFileBasename " + sInputFileBasename);
                String sInputFileNameNoSuffix = FileHelper.getNameNoSuffix(sInputFileBasename);
                // System.out.println("InputFilename no suffix " + sInputFileNameNoSuffix);
                String fs = System.getProperty("file.separator");
                String sOutputFile = _sOutputPath;
                if (! sOutputFile.endsWith(fs))
                {
                    sOutputFile += fs;
                }
                if (sExtension != null && sExtension.length() > 0)
                {
                    sOutputFile += sInputFileNameNoSuffix + "." + sExtension;
                }
                else
                {
                    sOutputFile += sInputFileBasename;
                }
                               
                if (FileHelper.exists(sOutputFile) && _aGTA.getOverwrite() == false)
                {
                    GlobalLogWriter.get().println("File already exist, don't overwrite. Set " + PropertyName.DOC_COMPARATOR_OVERWRITE_REFERENCE + "=true to force overwrite.");
                    return;
                }

                sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputFile);
                   
                GlobalLogWriter.get().println("Store document as '" + sOutputURL + "'");
                xStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList));
                GlobalLogWriter.get().println("Document stored.");
            }
            catch (com.sun.star.io.IOException e)
            {
                GlobalLogWriter.get().println("Can't store document '" + sOutputURL + "'. Message is :'" + e.getMessage() + "'");
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.