To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=111454
                 Issue #|111454
                 Summary|Problem Storing newly instantiated XDataSource (Base) 
                        |Object
               Component|api
                 Version|OOO320m12
                Platform|Macintosh
                     URL|
              OS/Version|Mac OS X, 10.6
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P2
            Subcomponent|code
             Assigned to|jsc
             Reported by|keithmcfarlane





------- Additional comments from keithmcfarl...@openoffice.org Fri May  7 
12:26:32 +0000 2010 -------
Contrary to the manual, it is not possible to access the XStorable and XModel 
interfaces from a newly creared 
XDataSource object. This makes it impossible (so far as I can tell) to create 
an in-memory database URL for an 
API created Database instance. IT LOOKS AS IF THE MANUAL IS IN ERROR. BUT CAN 
ANYONE SUPPLY A VIABLE 
MEANS OF CREATING A NEW XDatabaseContext in OO3.2 API. IT MAY BE THAT THIS 
MATTER REPRESENTS  A BUG 
in 3.2?! Certainly I had no luck in obtaining an XConnection object from a 
newly created (empty) database obect. 
It's my goal to create tables, populate same and stream the resulting XStorable 
OutputStream tvia a (reporting) 
servlet under Glassfish...


 The following code should illustrate the problem:

        XDesktop xDesktop; XComponentContext xContext; Object object;
        xComponentLoader = ( XComponentLoader ) UnoRuntime . queryInterface
          ( XComponentLoader.class, xDesktop );
         PropertyValue [ ] xDeskProps = new PropertyValue [ 1 ];
         xDeskProps [ 0 ] = new PropertyValue ( );
         xDeskProps [ 0 ] . Name  = "Hidden";
         xDeskProps [ 0 ] . Value = false;
         xComponent = xComponentLoader . loadComponentFromURL
          ( "private:factory/sdatabase", "_blank", FrameSearchFlag .CREATE, 
xDeskProps );
         XOfficeDatabaseDocument xDocument = ( XOfficeDatabaseDocument )  
          UnoRuntime  . queryInterface ( XOfficeDatabaseDocument.class, 
xComponent );

        // Sequence as per 

         XMultiComponentFactory factory = xContext . getServiceManager ( );
         XMultiServiceFactory xx = ( XMultiServiceFactory ) UnoRuntime . 
queryInterface
          ( XMultiServiceFactory.class, factory );
        
         object = xx . createInstance  ( "com.sun.star.sdbc.DriverManager" );

         XDriverManager xDriverManager = ( XDriverManager ) UnoRuntime . 
queryInterface
          ( XDriverManager.class, object );

         object = xx . createInstance  ( "com.sun.star.sdb.DatabaseContext" );
         
         XSingleServiceFactory single = ( XSingleServiceFactory ) UnoRuntime . 
queryInterface
          ( XSingleServiceFactory.class, object );

         object = single.createInstance ( );

         xDataSource = ( XDataSource ) UnoRuntime . queryInterface
          ( XDataSource.class, object );

         XNamingService service = ( XNamingService ) UnoRuntime . queryInterface
          (XNamingService.class, single );
         XStorable store = ( XStorable ) UnoRuntime . queryInterface
          ( XStorable.class, xDataSource );
         XModel model = ( XModel ) UnoRuntime . queryInterface
          ( XModel.class, xDataSource );

       // Both store & model are null!


 Notes: (i) I first successfully creat a new instance of an 
XOffficeDatabaseDocument, as per the standard user-
application) the next step is to create and then to register a new (in memory) 
DataSource. To do this (as per 
Sun's, "OpenOffice.org 3.1 Developer's Guide"per DG pp 1201-2, hereinafter the 
DG) I first access the "global 
service manager" and proceed as indicated (around a dozen lines only!). 

(ii) Note that the XServiceManager object referred to in the DG is deprecated 
in 3.2, and that the 
getServiceManager returns an XMultiComponentFactory instead. I was able to 
"cast" the 
XMultiComponentFactory to the older XMultiServiceFactory and implement the code 
example exactly thereafter. 
My problem is that attempting to "cast" the (non-null) xDataSource to either 
XStorable or XModel results in a 
null object. THE MANUAL CLEARLY EXPECTS THESE TO BE NON-NULL. However reference 
to the documentation 
on the XDataSource indicates that the interfaces XStorable and XModel are not 
"exported" by XDataSource 
interface. 

 (iii) In line with the deprecation advice, I have recast this code to use the 
supported interfaces 
XMultiComponentFactory and XSingleComponentFactory. The only changes are that 
the createInstance methods 
are replaced by createInstanceWithContext. The result is exactly the same, 
however. I need to cast the 
XDataSource object to an interface supporting XStorable (and ideally XModel). 
Might be this will assist you in 
finding a solution... ?

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@api.openoffice.org
For additional commands, e-mail: issues-h...@api.openoffice.org


---------------------------------------------------------------------
To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org
For additional commands, e-mail: allbugs-h...@openoffice.org

Reply via email to