Package com.sun.star.lang

Examples of com.sun.star.lang.XServiceInfo


      // Creating an instance of the minimal component
      Object objectMinimalComponent =
      xmulticomponentfactory.createInstanceWithContext(
      "org.OpenOffice.MinimalComponent", xcomponentcontext );
     
      XServiceInfo xserviceinfoMinimalComponent = ( XServiceInfo )
      UnoRuntime.queryInterface( XServiceInfo.class,
      objectMinimalComponent );
     
      System.out.println( "\nXServiceInfo is used to get the implementation name:\n    -> " +
                          xserviceinfoMinimalComponent.getImplementationName() +
                          "\nOk");
     
      // Removing the XSingleServiceFactory of the minimal Component from the container
      xsetMultiServiceFactory.remove( xsingleservicefactoryMinimalComponent );
     
View Full Code Here


        // format table headers and table borders
        // we need to distinguish text and sheet tables:
        // property name for cell colors is different in text and sheet cells
        // we want to apply TableBorder to whole text table, but only to sheet cells with content
        XServiceInfo xServiceInfo = (XServiceInfo)UnoRuntime.queryInterface(
            XServiceInfo.class, xCellRange);
        if (xServiceInfo.supportsService("com.sun.star.sheet.Spreadsheet")) {
            backColorPropertyName = "CellBackColor";
            xSelectedCells = xCellRange.getCellRangeByName("A1:B2");
            xTableProps = (XPropertySet)UnoRuntime.queryInterface(
                XPropertySet.class, xSelectedCells);
        }
        else if (xServiceInfo.supportsService("com.sun.star.text.TextTable")) {
            backColorPropertyName = "BackColor";
            xTableProps = (XPropertySet)UnoRuntime.queryInterface(
                XPropertySet.class, xCellRange);
        }
        // set cell background color
View Full Code Here

           
            // Loop through all paragraphs of the document
            while ( xParagraphEnumeration.hasMoreElements() ) {
                xTextElement = (XTextContent) UnoRuntime.queryInterface(
                    XTextContent.class, xParagraphEnumeration.nextElement());
                XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(
                    XServiceInfo.class, xTextElement );
               
                // check ifs the current paragraph really a paragraph or an anchor of a frame or picture
                if( xServiceInfo.supportsService("com.sun.star.text.Paragraph") ) {
                    XTextRange xTextRange = xTextElement.getAnchor();
                    System.out.println( "This is a Paragraph" );
                   
                    // create another enumeration to get all text portions of the paragraph
                    xParaEnumerationAccess = (XEnumerationAccess) UnoRuntime.queryInterface(
View Full Code Here

            ( XSelectionSupplier ) UnoRuntime.queryInterface(
            XSelectionSupplier.class, xcontroller );
           
            Object objectSelection = xselectionsupplier.getSelection();
           
            XServiceInfo xserviceinfo = ( XServiceInfo )
            UnoRuntime.queryInterface( XServiceInfo.class,
            objectSelection );
           
            if ( xserviceinfo.supportsService( "com.sun.star.text.TextRanges" )
            ) {
                XIndexAccess xindexaccess = ( XIndexAccess )
                UnoRuntime.queryInterface(
                XIndexAccess.class, objectSelection );
               
                for ( int intCounter = 0; intCounter < xindexaccess.getCount();
                intCounter++ ) {
                    XTextRange xtextrange = ( XTextRange )
                    UnoRuntime.queryInterface(
                    XTextRange.class, xindexaccess.getByIndex( intCounter ) );
                   
                    System.out.println( "You have selected a text range: \""
                    + xtextrange.getString() + "\"." );
                }
            }
           
            if ( xserviceinfo.supportsService(
            "com.sun.star.text.TextGraphicObject" )
            ) {
                System.out.println( "You have selected a graphics." );
            }
           
            if ( xserviceinfo.supportsService(
            "com.sun.star.text.TextTableCursor" )
            ) {
                System.out.println( "You have selected a text table." );
            }
           
View Full Code Here

        }

        try
        {
            // check the provider implementation
            XServiceInfo xProviderServices =
                (XServiceInfo) UnoRuntime.queryInterface( XServiceInfo.class, xProvider );

            if (xProviderServices == null ||
                !xProviderServices.supportsService("com.sun.star.configuration.ConfigurationProvider"))
            {
                System.out.println("WARNING: The provider is not a com.sun.star.configuration.ConfigurationProvider");
            }

            if (xProviderServices != null)
            {
                System.out.println("Using provider implementation: " + xProviderServices.getImplementationName());
            }

            return true;
        }
        catch (com.sun.star.uno.RuntimeException e)
View Full Code Here

        throws com.sun.star.uno.RuntimeException
    {
            if (object == null)
              throw new com.sun.star.uno.RuntimeException("The parameter must not been null");
           
            XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, object);

        return xServiceInfo != null && UnoRuntime.areSame(factoriesByImplNames.get(xServiceInfo.getImplementationName()), object);
       
    }
View Full Code Here

               com.sun.star.container.ElementExistException,
               com.sun.star.uno.RuntimeException
    {
        if (object == null) throw new com.sun.star.lang.IllegalArgumentException();
       
        XServiceInfo xServiceInfo =
                UnoRuntime.queryInterface(XServiceInfo.class, object);
       
        if (xServiceInfo == null)
            throw new com.sun.star.lang.IllegalArgumentException(
                "The given object does not implement the XServiceInfo interface."
            );
           
        if ( factoriesByImplNames.containsKey( xServiceInfo.getImplementationName() ) ) {
            throw new com.sun.star.container.ElementExistException(
                xServiceInfo.getImplementationName() + " already registred"
            );
        }
       
        DEBUG("add factory " + object.toString() + " for " + xServiceInfo.getImplementationName());
        factoriesByImplNames.put( xServiceInfo.getImplementationName(), object );
       
           
        String[] serviceNames = xServiceInfo.getSupportedServiceNames();
        java.util.Vector vec  ;
           
        for (int i=0; i<serviceNames.length; i++) {               
            if ( !factoriesByServiceNames.containsKey( serviceNames[i] ) ) {
              DEBUG("> no registered services found under " + serviceNames[i] + ": adding..." );
                factoriesByServiceNames.put(serviceNames[i], new java.util.Vector());
            }
               
            vec = (java.util.Vector) factoriesByServiceNames.get( serviceNames[i] );                                                 
           
            if ( vec.contains( object ) )
                System.err.println("The implementation " + xServiceInfo.getImplementationName() +
                    " already registered for the service " + serviceNames[i] + " - ignoring!");
            else               
                vec.addElement(object);
        }       
  }
View Full Code Here

        if (object == null)
            throw new com.sun.star.lang.IllegalArgumentException(
                    "The given object must not be null."
            );
       
        XServiceInfo xServiceInfo =
            UnoRuntime.queryInterface(XServiceInfo.class, object);
       
        if (xServiceInfo == null)
            throw new com.sun.star.lang.IllegalArgumentException(
                    "The given object does not implement the XServiceInfo interface."
            );
       
        XSingleServiceFactory xSingleServiceFactory =
            UnoRuntime.queryInterface(XSingleServiceFactory.class, object);
       
        if (xSingleServiceFactory == null)
            throw new com.sun.star.lang.IllegalArgumentException(
                    "The given object does not implement the XSingleServiceFactory interface."
            );
       
        if ( factoriesByImplNames.remove( xServiceInfo.getImplementationName() ) == null )
            throw new com.sun.star.container.NoSuchElementException(
                    xServiceInfo.getImplementationName() +
                    " is not registered as an implementation."
            );
       
        String[] serviceNames = xServiceInfo.getSupportedServiceNames();
       
        for ( int i=0; i<serviceNames.length; i++ ) {
            if ( factoriesByServiceNames.containsKey( serviceNames[i] ) ) {
                java.util.Vector vec = (java.util.Vector) factoriesByServiceNames.get(serviceNames[i]);
               
                if ( !vec.removeElement(object) )
                    System.err.println("The implementation " + xServiceInfo.getImplementationName() +
                        " is not registered for the service " + serviceNames[i] + " - ignoring!");
               
                if ( vec.isEmpty() ) // remove the vector if no implementations aviable for the service
                    factoriesByServiceNames.remove( serviceNames[i] );  
            }                   
View Full Code Here

    }
   
    //==============================================================================================
    static void service_info_test( Object inst )
    {
        XServiceInfo xInfo = UnoRuntime.queryInterface( XServiceInfo.class, inst );
       
        if (! xInfo.getImplementationName().equals( m_impl_name ))
        {
            System.err.println( "Factory_Test: err -- 1" );
            System.exit( 1 );
        }
        String supported_services [] = xInfo.getSupportedServiceNames();
        if (supported_services.length != m_supported_services.length)
        {
            System.err.println( "Factory_Test: err -- 2" );
            System.exit( 1 );
        }
        for ( int nPos = 0; nPos < supported_services.length; ++nPos )
        {
            if (! supported_services[ nPos ].equals( m_supported_services[ nPos ] ))
            {
                System.err.println( "Factory_Test: err -- 3" );
                System.exit( 1 );
            }
            if (! xInfo.supportsService( m_supported_services[ nPos ] ))
            {
                System.err.println( "Factory_Test: err -- 4" );
                System.exit( 1 );
            }
        }
View Full Code Here

    } // finished openDoc

    // query for XServiceInfo
    public Object queryXServiceInfo(Object oObj) {
        if (oObj != null) {
            XServiceInfo oInfo = (XServiceInfo) UnoRuntime.queryInterface(
                XServiceInfo.class, oObj);
            System.out.println("!!!! XServiceInfo n.a. !!!! ");
        } else {
            System.out.println("Object is empty!!!! ");
        }
View Full Code Here

TOP

Related Classes of com.sun.star.lang.XServiceInfo

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.