Package com.sun.star.container

Examples of com.sun.star.container.XEnumerationAccess


                    // The service 'com.sun.star.text.Text' supports the XEnumerationAccess interface to
                    // provide an enumeration
                    // of the paragraphs contained by the text the service refers to.

                    // Here, we access this interface
                    XEnumerationAccess xParaAccess = (XEnumerationAccess) UnoRuntime.queryInterface(
                            XEnumerationAccess.class, mxDocText );
                    // Call the XEnumerationAccess's only method to access the actual Enumeration
                    XEnumeration xParaEnum = xParaAccess.createEnumeration();

                    // While there are paragraphs, do things to them
                    while ( xParaEnum.hasMoreElements() )
                    {
                            // Get a reference to the next paragraphs XServiceInfo interface. TextTables
View Full Code Here


                XIntrospectionAccess xIntrospectionAccessObject = xIntrospection.inspect( a );
               
                if ( xIntrospectionAccessObject != null ) {
                   
                    //  get the enumeration access
                    XEnumerationAccess xEnumerationAccess = ( XEnumerationAccess ) UnoRuntime.queryInterface( XEnumerationAccess.class, xIntrospectionAccessObject.queryAdapter( new Type( XEnumerationAccess.class ) ) );
                    if ( xEnumerationAccess != null ) {
                        //  get the enumeration
                        XEnumeration xEnumeration = xEnumerationAccess.createEnumeration();
                       
                        //  create a node for the enumeration category
                        DefaultMutableTreeNode childEnumeration = new DefaultMutableTreeNode( "Enumeration" );
                       
                        while ( xEnumeration.hasMoreElements() ) {
View Full Code Here

            // example for use of XEnumerationAccess
            XCellRangesQuery xCellQuery = (XCellRangesQuery)UnoRuntime.queryInterface(
                XCellRangesQuery.class, sheet);
            XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells(
                (short)com.sun.star.sheet.CellFlags.FORMULA);
            XEnumerationAccess xFormulas = xFormulaCells.getCells();
            XEnumeration xFormulaEnum = xFormulas.createEnumeration();
           
            while (xFormulaEnum.hasMoreElements()) {
                Object formulaCell = xFormulaEnum.nextElement();
                xCell = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);
                XCellAddressable xCellAddress = (XCellAddressable)UnoRuntime.queryInterface(
View Full Code Here

           
            // Begin section 'The structure of text documents' of the Tutorial
           
            XEnumeration xParagraphEnumeration = null;
            XTextContent xTextElement = null;
            XEnumerationAccess xParaEnumerationAccess = null;
            XEnumeration xPortionEnumeration = null;
            XEnumeration xTextPortionEnum;
           
            System.out.println("create an enumeration of all paragraphs");
            // create an enumeration access of all paragraphs of a document
            XEnumerationAccess xEnumerationAccess = (XEnumerationAccess) UnoRuntime.queryInterface(
                XEnumerationAccess.class, xText );
            xParagraphEnumeration = xEnumerationAccess.createEnumeration();
           
            // Loop through all paragraphs of the document
            while ( xParagraphEnumeration.hasMoreElements() ) {
                xTextElement = (XTextContent) UnoRuntime.queryInterface(
                    XTextContent.class, xParagraphEnumeration.nextElement());
View Full Code Here

           
            // Begin section 'The structure of text documents' of the Tutorial
           
            XEnumeration xParagraphEnumeration = null;
            XTextContent xTextElement = null;
            XEnumerationAccess xParaEnumerationAccess = null;
            XEnumeration xPortionEnumeration = null;
            XEnumeration xTextPortionEnum;
           
            System.out.println("create an enumeration of all paragraphs");
            // create an enumeration access of all paragraphs of a document
            XEnumerationAccess xEnumerationAccess = (XEnumerationAccess) UnoRuntime.queryInterface(
                XEnumerationAccess.class, xText );
            xParagraphEnumeration = xEnumerationAccess.createEnumeration();
           
            // Loop through all paragraphs of the document
            while ( xParagraphEnumeration.hasMoreElements() ) {
                xTextElement = (XTextContent) UnoRuntime.queryInterface(
                    XTextContent.class, xParagraphEnumeration.nextElement());
View Full Code Here

            // you have to use the FormatSupplier interface to get the CellFormat enumeration
            XCellFormatRangesSupplier xCellFormatSupplier = (XCellFormatRangesSupplier)
                UnoRuntime.queryInterface(XCellFormatRangesSupplier.class, xSheet );
           
            // getCellFormatRanges() has the interfaces for the enumeration
            XEnumerationAccess xEnumerationAccess = (XEnumerationAccess)
                UnoRuntime.queryInterface( XEnumerationAccess.class,
                                           xCellFormatSupplier.getCellFormatRanges() );
            XEnumeration xRanges = xEnumerationAccess.createEnumeration();
           
            while( xRanges.hasMoreElements() ) {
                // the enumeration returns a cellrange
                XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(
                    XCellRange.class, xRanges.nextElement());
               
                // the PropertySet the get and set the properties from the cellrange
                XPropertySet xCellProp = ( XPropertySet ) UnoRuntime.queryInterface(
                    XPropertySet.class, xCellRange );
               
                // getPropertyValue returns an Object, you have to cast it to type that you need
                Object oNumberObject = xCellProp.getPropertyValue( "NumberFormat" );
                int iNumberFormat = ((Integer) oNumberObject).intValue();
               
                // get the properties from the cellrange numberformat
                XPropertySet xFormat = (XPropertySet) xNumberFormats.getByKey( iNumberFormat );
               
                short fType = ((Short) xFormat.getPropertyValue("Type")).shortValue();
                String sCurrencySymbol = ((String) xFormat.getPropertyValue("CurrencySymbol")).toString();
               
                // change the numberformat only on cellranges with a currency numberformat
                if( ( (fType & com.sun.star.util.NumberFormat.CURRENCY) > 0) &&
                    ( sCurrencySymbol.compareTo( sOldSymbol ) == 0 ) ) {
                    AnyConverter aAnyConv = new AnyConverter();
                    boolean bThousandSep = aAnyConv.toBoolean(
                        xFormat.getPropertyValue("ThousandsSeparator"));
                    boolean bNegativeRed = aAnyConv.toBoolean(xFormat.getPropertyValue("NegativeRed"));
                    short fDecimals = aAnyConv.toShort(xFormat.getPropertyValue("Decimals"));
                    short fLeadingZeros = aAnyConv.toShort(xFormat.getPropertyValue("LeadingZeros"));
                    Locale oLocale = (Locale) aAnyConv.toObject(
                       new com.sun.star.uno.Type(Locale.class),xFormat.getPropertyValue("Locale"));
                   
                    // create a new numberformat string
                    String sNew = xNumberFormats.generateFormat( iSimpleKey, oLocale, bThousandSep, bNegativeRed, fDecimals, fLeadingZeros );
                    // get the NumberKey from the numberformat
                    int iNewNumberFormat = NumberFormat( xNumberFormats, sNew, oLocale );
                   
                    // set the new numberformat to the cellrange DM->EUR
                    xCellProp.setPropertyValue( "NumberFormat", new Integer( iNewNumberFormat ) );
                   
                    // interate over all cells from the cellrange with an content and use the DM/EUR factor
                    XCellRangesQuery xCellRangesQuery = (XCellRangesQuery) UnoRuntime.queryInterface(
                        com.sun.star.sheet.XCellRangesQuery.class, xCellRange );
                    XSheetCellRanges xSheetCellRanges = xCellRangesQuery.queryContentCells(
                        (short) com.sun.star.sheet.CellFlags.VALUE );
                   
                    if( xSheetCellRanges.getCount() > 0 ) {
                        XEnumerationAccess xCellEnumerationAccess = xSheetCellRanges.getCells();
                        XEnumeration xCellEnumeration = xCellEnumerationAccess.createEnumeration();
                       
                        while( xCellEnumeration.hasMoreElements() ) {
                            XCell xCell = (XCell) UnoRuntime.queryInterface(
                                XCell.class, xCellEnumeration.nextElement());
                            xCell.setValue( (double) xCell.getValue() / fFactor );
View Full Code Here

        if (!dbRanges.hasByName("dbRange")) {
            dbRanges.addNewByName("dbRange", aRange);
        }

        oObj = dbRanges;
        XEnumerationAccess ea = (XEnumerationAccess)
                    UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);

        oObj = ea.createEnumeration();

        log.println("ImplementationName: "+util.utils.getImplName(oObj));
        // creating test environment
        TestEnvironment tEnv = new TestEnvironment( oObj );
View Full Code Here

                                                    throws StatusException {

        XInterface oObj = null;
        // create testobject here

        XEnumerationAccess xEA = null ;
        try {
            SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory)tParam.getMSF()) ;
            XShape oShape = SOF.createShape
                (xDrawDoc,5000,3500,7500,5000,"Text");
            DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ;

            XSimpleText text = (XSimpleText) UnoRuntime.queryInterface
                (XSimpleText.class, oShape) ;

            XTextCursor cursor = text.createTextCursor() ;

            text.insertString(cursor, "Paragraph 1", false) ;
            text.insertControlCharacter(cursor,
                ControlCharacter.PARAGRAPH_BREAK, false) ;
            text.insertString(cursor, "Paragraph 2", false) ;
            text.insertControlCharacter(cursor,
                ControlCharacter.PARAGRAPH_BREAK, false) ;
            text.insertString(cursor, "Paragraph 3", false) ;
            text.insertControlCharacter(cursor,
                ControlCharacter.PARAGRAPH_BREAK, false) ;

            xEA = (XEnumerationAccess) UnoRuntime.queryInterface
                (XEnumerationAccess.class, text) ;

            oObj = xEA.createEnumeration() ;
        } catch (Exception e) {
            log.println("Can't create test object") ;
            e.printStackTrace(log) ;
            throw new StatusException("Unexpected exception", e);
        }
View Full Code Here

    /**
    * Prints full info about currently registered DataSource's.
    */
    public void printRegisteredDatabasesInfo(PrintWriter out) {
        XEnumerationAccess dbContEA = (XEnumerationAccess)
            UnoRuntime.queryInterface(XEnumerationAccess.class, dbContext) ;

        XEnumeration xEnum = dbContEA.createEnumeration() ;

        out.println("DatabaseContext registered DataSource's :") ;
        while (xEnum.hasMoreElements()) {
            try {
                DataSourceInfo inf = new DataSourceInfo(xEnum.nextElement()) ;
View Full Code Here

                            xProp.getPropertyValue("DefaultContext"));
            // get the type description manager
            Object o = xContext.getValueByName("/singletons/" +
                        "com.sun.star.reflection.theTypeDescriptionManager");
            // the manager contains all providers
            XEnumerationAccess aProviderAccess = (XEnumerationAccess)
                        UnoRuntime.queryInterface(XEnumerationAccess.class, o);
            // collect enumeration
            XEnumeration xProviderEnum;
            if (aProviderAccess.hasElements())
                xProviderEnum = aProviderAccess.createEnumeration();
            else
                throw new lib.StatusException(Status.failed(
                                        "No TypeDescriptionProvider given"));
            // take the first registry type description provider
            oInterface = xProviderEnum.nextElement();
View Full Code Here

TOP

Related Classes of com.sun.star.container.XEnumerationAccess

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.