Examples of XNameContainer


Examples of com.sun.star.container.XNameContainer

    public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] _properties)
        {
            try
            {
                XNameContainer xNamedForms = getDoc().oFormHandler.getDocumentForms();
                Object oDBForm = Helper.getUnoObjectbyName(xNamedForms, ReportWizard.SOREPORTFORMNAME);
                boolean bgetConnection;
                String sQueryName = "";
                if (oDBForm != null)
                {
View Full Code Here

Examples of com.sun.star.container.XNameContainer

        catch(com.sun.star.uno.Exception e) {
            e.printStackTrace();
            failed(e.getMessage());
            return;
        }
        XNameContainer xCont = (XNameContainer)UnoRuntime.queryInterface(
                                                XNameContainer.class, oObj);

        assure("XNameContainer was queried but returned null.",
                                                        (xCont != null));
        PropertyValue[] prop1 = new PropertyValue[1];
        prop1[0] = new PropertyValue();
        prop1[0].Name  = "Jupp";
        prop1[0].Value = "GoodGuy";

        PropertyValue[] prop2 = new PropertyValue[1];
        prop2[0] = new PropertyValue();
        prop2[0].Name  = "Horst";
        prop2[0].Value = "BadGuy";

        try {
            Type t = xCont.getElementType();
            log.println("Insertable Type: " + t.getTypeName());
            assure("Initial container is not empty.", !xCont.hasElements());

            log.println("Insert a PropertyValue.");
            xCont.insertByName("prop1", prop1);
            PropertyValue[]ret = (PropertyValue[])xCont.getByName("prop1");
            assure("Got the wrong PropertyValue: " +
                                    ret[0].Name +  "  " +(String)ret[0].Value,
                                    ret[0].Name.equals(prop1[0].Name) &&
                                    ret[0].Value.equals(prop1[0].Value));
            log.println("Replace the PropertyValue.");
            xCont.replaceByName("prop1", prop2);
            ret = (PropertyValue[])xCont.getByName("prop1");
            assure("Got the wrong PropertyValue: " +
                                    ret[0].Name +  "  " +(String)ret[0].Value,
                                    ret[0].Name.equals(prop2[0].Name) &&
                                    ret[0].Value.equals(prop2[0].Value));
            log.println("Remove the PropertyValue.");
            xCont.removeByName("prop1");
            assure("Could not remove PropertyValue.", !xCont.hasElements());
            log.println("Insert again.");
            xCont.insertByName("prop1", prop1);
            xCont.insertByName("prop2", prop2);
            assure("Did not insert PropertyValue.", xCont.hasElements());
            String[] names = xCont.getElementNames();
            int count = 0;
            for (int i=0; i<names.length; i++) {
                if (names[i].equals("prop1") || names[i].equals("prop2"))
                    count++;
                else
                    failed("Got a wrong element name: "+names[i]);
            }
            if (count != 2)
                failed("Not all element names were returned.");

            try {
                log.println("Insert PropertyValue with an existing name.");
                xCont.insertByName("prop2", prop1);
                failed("ElementExistException was not thrown.");
            }
            catch(com.sun.star.lang.IllegalArgumentException e) {
                log.println("Wrong exception thrown.");
                failed(e.getMessage());
                e.printStackTrace();
            }
            catch(com.sun.star.container.ElementExistException e) {
                log.println("Expected exception thrown: "+e);
            }
            catch(com.sun.star.lang.WrappedTargetException e) {
                log.println("Wrong exception thrown.");
                failed(e.getMessage());
                e.printStackTrace();
            }

            try {
                log.println("Inserting a wrong argument.");
                xCont.insertByName("prop3", "Example String");
                failed("IllegalArgumentException was not thrown.");
            }
            catch(com.sun.star.lang.IllegalArgumentException e) {
                log.println("Expected exception thrown: "+e);
            }
            catch(com.sun.star.container.ElementExistException e) {
                log.println("Wrong exception thrown.");
                failed(e.getMessage());
                e.printStackTrace();
            }
            catch(com.sun.star.lang.WrappedTargetException e) {
                log.println("Wrong exception thrown.");
                failed(e.getMessage());
                e.printStackTrace();
            }

            try {
                log.println("Remove a non-existing element.");
                xCont.removeByName("prop3");
                failed("NoSuchElementException was not thrown.");
            }
            catch(com.sun.star.container.NoSuchElementException e) {
                log.println("Expected exception thrown: "+e);
            }
View Full Code Here

Examples of com.sun.star.container.XNameContainer

            XPropertySet.class, cancelButtonModel);
        buttonProps.setPropertyValue("Name", "Cancel");
        buttonProps.setPropertyValue("Label", "Cancel");
     
        // insert the control models into the dialog model
        XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface(
            XNameContainer.class, dialogModel);

        xNameCont.insertByName("PromptLabel", label);
        xNameCont.insertByName("Ok", okButtonModel);
        xNameCont.insertByName("Cancel", cancelButtonModel);

        // create the dialog control and set the model
        Object dialog = xMultiComponentFactory.createInstanceWithContext(
            "com.sun.star.awt.UnoControlDialog", xComponentContext);
        XControl xControl = (XControl) UnoRuntime.queryInterface(
View Full Code Here

Examples of com.sun.star.container.XNameContainer

            XPropertySet.class, cancelButtonModel);
        buttonProps.setPropertyValue("Name", "Cancel");
        buttonProps.setPropertyValue("Label", "Cancel");
     
        // insert the control models into the dialog model
        XNameContainer xNameCont = (XNameContainer)
            UnoRuntime.queryInterface(XNameContainer.class, dialogModel);

        xNameCont.insertByName("PromptLabel", label);
        xNameCont.insertByName("NameField", edit);
        xNameCont.insertByName("Ok", okButtonModel);
        xNameCont.insertByName("Cancel", cancelButtonModel);

        // create the dialog control and set the model
        Object dialog = xMultiComponentFactory.createInstanceWithContext(
            "com.sun.star.awt.UnoControlDialog", xComponentContext);
        XControl xControl = (XControl) UnoRuntime.queryInterface(
View Full Code Here

Examples of com.sun.star.container.XNameContainer

import com.sun.star.xml.AttributeData;

public class _UserDefinedAttributeSupplier extends lib.MultiPropertyTest {

    public void _UserDefinedAttributes() {
        XNameContainer uda = null;
        boolean res = false;
        try {           
            uda = (XNameContainer) AnyConverter.toObject(
                    new Type(XNameContainer.class),
                        oObj.getPropertyValue("UserDefinedAttributes"));
            AttributeData attr = new AttributeData();
            attr.Namespace = "http://www.sun.com/staroffice/apitest/Chartprop";
            attr.Type="CDATA";
            attr.Value="true";
            uda.insertByName("Chartprop:has-first-alien-attribute",attr);           
            String[] els = uda.getElementNames();           
            oObj.setPropertyValue("UserDefinedAttributes",uda);
            uda = (XNameContainer) AnyConverter.toObject(
                    new Type(XNameContainer.class),
                        oObj.getPropertyValue("UserDefinedAttributes"));
            els = uda.getElementNames();
            Object obj = uda.getByName("Chartprop:has-first-alien-attribute");
            res = true;
        } catch (com.sun.star.beans.UnknownPropertyException upe) {
            log.println("Don't know the Property 'UserDefinedAttributes'");
        } catch (com.sun.star.lang.WrappedTargetException wte) {
            log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
View Full Code Here

Examples of com.sun.star.container.XNameContainer

                } catch (java.lang.Exception e){
                    failed("could not get test object", CONTINUE);
                }
               
                xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oObj);
                XNameContainer xNC = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oObj);
                XNameReplace xNR = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class, oObj);
                XFlushable xFlush = (XFlushable) UnoRuntime.queryInterface(XFlushable.class, oObj);

                instance = (Object[]) xNA.getByName(filterName);
                PropertyValue[] props = (PropertyValue[]) instance;
               
                printPropertyValues(props);
               
                boolean isMandatory = ((Boolean) getPropertyValueValue(props, "Mandatory")).booleanValue();
                boolean isFinalized = ((Boolean) getPropertyValueValue(props, "Finalized")).booleanValue();
               
                // memory if every state is available
                mandantoryTrue |= isMandatory;
                mandantoryFalse |= !isMandatory;
               
                finalizedTrue |= isFinalized;
                finalizedFalse |= !isFinalized;
               
                //change the filter
                setPropertyValueValue((PropertyValue[])instance, "UIName", "dummy");
               
                // 1a.) try to change the filter in the container
                try{
                    xNR.replaceByName(filterName, instance);
                }catch (IllegalArgumentException e){
                    failed("could not replace filter properties ('" + filterName + "')", CONTINUE);
                }
               
                // 1b.) try to wirte the changed filter to the configuration.
                // This must result in a exception if the filter is finalized.
                boolean flushError = false;
                try{
                    xFlush.flush();
                } catch (WrappedTargetRuntimeException e){
                    flushError = true;
                    assure("Unexpected exception wihle flushing changed filter '"+ filterName + "'", isFinalized,CONTINUE);
                }
                assure("Expected exception was not thorwn while flushing changed filter '"+ filterName + "' Finalized:" + isFinalized,
                        !(flushError ^ isFinalized), CONTINUE);
               
               
               
                // 2a.) try to remove the filter from the container
                try{
                    xNC.removeByName(filterName);
                }catch (NoSuchElementException e){
                    failed("could not remove filter from container ('" + filterName + "')", CONTINUE);
                }
                // 1b.) try to wirte the changed filter to the configuration.
                // This must result in a exception if the filter is mandatory
View Full Code Here

Examples of com.sun.star.container.XNameContainer

        xPSetButton.setPropertyValue( "Name", _doNotRunButtonName );
        xPSetButton.setPropertyValue( "TabIndex", new Short( (short)0 ) );
        xPSetButton.setPropertyValue( "Label", _doNotRunMacro );
     
        // insert the control models into the dialog model
        XNameContainer xNameCont = ( XNameContainer )UnoRuntime.queryInterface(
            XNameContainer.class, dialogModel );
        xNameCont.insertByName( _runButtonName, runButtonModel );
        xNameCont.insertByName( _doNotRunButtonName, doNotRunButtonModel );

        if ( checkBoxDialog )
        {
            LogUtils.DEBUG("creating label & checkbox");
            // create the label model and set the properties
            Object label2Model = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlFixedTextModel" );
            XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, label2Model );
            xPSetLabel.setPropertyValue( "PositionX", new Integer( label2X ));
            xPSetLabel.setPropertyValue( "PositionY", new Integer( label2Y ));
            xPSetLabel.setPropertyValue( "Width", new Integer( label2W ));
            xPSetLabel.setPropertyValue( "Height", new Integer( label2H ));
            xPSetLabel.setPropertyValue( "Name", _label2Name );
            xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetLabel.setPropertyValue( "Label", _label2String );

            // create the label model and set the properties
            Object label3Model = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlFixedTextModel" );
            XPropertySet xPSetLabel3 = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, label3Model );
            xPSetLabel3.setPropertyValue( "PositionX", new Integer( label3X ));
            xPSetLabel3.setPropertyValue( "PositionY", new Integer( label3Y ));
            xPSetLabel3.setPropertyValue( "Width", new Integer( label3W ));
            xPSetLabel3.setPropertyValue( "Height", new Integer( label3H ));
            xPSetLabel3.setPropertyValue( "Name", _label3Name );
            xPSetLabel3.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetLabel3.setPropertyValue( "Label", _label3String );

            // create the label model and set the properties
            Object label4Model = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlFixedTextModel" );
            XPropertySet xPSetLabel4 = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, label4Model );
            xPSetLabel4.setPropertyValue( "PositionX", new Integer( label4X ));
            xPSetLabel4.setPropertyValue( "PositionY", new Integer( label4Y ));
            xPSetLabel4.setPropertyValue( "Width", new Integer( label4W ));
            xPSetLabel4.setPropertyValue( "Height", new Integer( label4H ));
            xPSetLabel4.setPropertyValue( "Name", _label4Name );
            xPSetLabel4.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetLabel4.setPropertyValue( "Label", _label4String );

            // create the checkbox model and set the properties
            Object checkBoxModel = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlCheckBoxModel" );
            XPropertySet xPSetCheckBox = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, checkBoxModel );
            xPSetCheckBox.setPropertyValue( "PositionX", new Integer( checkBoxX ));
            xPSetCheckBox.setPropertyValue( "PositionY", new Integer( checkBoxY ));
            xPSetCheckBox.setPropertyValue( "Width", new Integer( checkBoxW ));
            xPSetCheckBox.setPropertyValue( "Height", new Integer( checkBoxH ));
            xPSetCheckBox.setPropertyValue( "State", new Short((short)0) );
            xPSetCheckBox.setPropertyValue( "Name", _checkBoxName );
            xPSetCheckBox.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetCheckBox.setPropertyValue( "Label", new String(_checkBoxString +checkBoxPath) );

            // insert the control models into the dialog model
            xNameCont.insertByName( _label2Name, label2Model );
            xNameCont.insertByName( _label3Name, label3Model );
            xNameCont.insertByName( _label4Name, label4Model );
            xNameCont.insertByName( _checkBoxName, checkBoxModel );

            if ( extraPathLine == true )
            {
            // create the label model and set the properties
            Object label5Model = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlFixedTextModel" );
            XPropertySet xPSetLabel5 = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, label5Model );
            xPSetLabel5.setPropertyValue( "PositionX", new Integer( label5X ));
            xPSetLabel5.setPropertyValue( "PositionY", new Integer( label5Y ));
            xPSetLabel5.setPropertyValue( "Width", new Integer( label5W ));
            xPSetLabel5.setPropertyValue( "Height", new Integer( label5H ));
            xPSetLabel5.setPropertyValue( "Name", _label5Name );
            xPSetLabel5.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetLabel5.setPropertyValue( "Label", checkBoxPath2 );
            xNameCont.insertByName( _label5Name, label5Model );
            }
        }
        else
        {
            // create the label model and set the properties
            Object labelModel = xMultiServiceFactory.createInstance(
                "com.sun.star.awt.UnoControlFixedTextModel" );
            XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(
                XPropertySet.class, labelModel );
            xPSetLabel.setPropertyValue( "PositionX", new Integer( label1X ));
            xPSetLabel.setPropertyValue( "PositionY", new Integer( label1Y ));
            xPSetLabel.setPropertyValue( "Width", new Integer( label1W ));
            xPSetLabel.setPropertyValue( "Height", new Integer( label1H ));
            xPSetLabel.setPropertyValue( "Name", _label1Name );
            xPSetLabel.setPropertyValue( "TabIndex", new Short( (short)1 ) );
            xPSetLabel.setPropertyValue( "Label", _label1String );

            // insert the control models into the dialog model
            xNameCont.insertByName( _label1Name, labelModel );
        }
     
        // create the dialog control and set the model
        Object dialog = xMultiComponentFactory.createInstanceWithContext(
            "com.sun.star.awt.UnoControlDialog", _xComponentContext );
View Full Code Here

Examples of com.sun.star.container.XNameContainer

        if (oMyStyle == null)
            log.println("FAILED");
        else
            log.println("OK");
            XNameContainer oSFNC = (XNameContainer)
            UnoRuntime.queryInterface(XNameContainer.class, oSFNA);

        try {
            if ( oSFNC.hasByName("My Style") )
                oSFNC.removeByName("My Style");
            oSFNC.insertByName("My Style", oMyStyle);
        } catch ( com.sun.star.lang.WrappedTargetException e ) {
            e.printStackTrace(log);
            throw new StatusException( "Couldn't create environment ", e );
        } catch     ( com.sun.star.lang.IllegalArgumentException e ) {
            e.printStackTrace(log);
View Full Code Here

Examples of com.sun.star.container.XNameContainer

            XSingleServiceFactory xSSFQueryDefs = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, xQueryDefs);
            Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition"
            XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oQuery);
            String s = _oSQLQueryComposer.xQueryAnalyzer.getQuery();
            xPSet.setPropertyValue("Command", _oSQLQueryComposer.xQueryAnalyzer.getQuery());
            XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xQueryDefs);
            XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xQueryDefs);
            ConnectionTools.getObjectNames().checkNameForCreate(com.sun.star.sdb.CommandType.QUERY,_QueryName);
            xNameCont.insertByName(_QueryName, oQuery);
            return true;
        } catch( WrappedTargetException exception ) {
            SQLException sqlError = null;
            try { sqlError = (SQLException)exception.TargetException; }
            catch( ClassCastException castError ) { }
View Full Code Here

Examples of com.sun.star.container.XNameContainer

        if (oMyStyle == null)
            log.println("FAILED");
        else
            log.println("OK");
            XNameContainer oSFNC = (XNameContainer)
            UnoRuntime.queryInterface(XNameContainer.class, oSFNA);

        try {
            if ( oSFNC.hasByName("My Style") )
                oSFNC.removeByName("My Style");
            oSFNC.insertByName("My Style", oMyStyle);
        } catch ( com.sun.star.lang.WrappedTargetException e ) {
            e.printStackTrace(log);
            throw new StatusException( "Couldn't create environment ", e );
        } catch     ( com.sun.star.lang.IllegalArgumentException e ) {
            e.printStackTrace(log);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.