Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / runner / util / db / DatabaseDocument.java
blob9022315fbfa4033345822b8ea7f6deaee5861fdc
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
27 package util.db;
29 import com.sun.star.beans.PropertyValue;
30 import com.sun.star.frame.XModel;
31 import com.sun.star.frame.XStorable;
32 import com.sun.star.io.IOException;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.sdb.XDocumentDataSource;
35 import com.sun.star.sdb.XOfficeDatabaseDocument;
36 import com.sun.star.uno.UnoRuntime;
38 /**
39 * encapsulates a css.sdb.DatabaseDocument
41 public class DatabaseDocument
43 protected DatabaseDocument( final XMultiServiceFactory _orb, final DataSource _dataSource )
45 m_orb = _orb;
46 m_dataSource = _dataSource;
48 XDocumentDataSource docDataSource = (XDocumentDataSource)UnoRuntime.queryInterface(
49 XDocumentDataSource.class, m_dataSource.getDataSource() );
50 m_databaseDocument = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(XOfficeDatabaseDocument.class,
51 docDataSource.getDatabaseDocument() );
53 m_model = (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
54 m_storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
57 public DataSource getDataSource()
59 return m_dataSource;
62 public XOfficeDatabaseDocument getDatabaseDocument()
64 return m_databaseDocument;
67 /**
68 * passes through to XModel.getURL.
70 public String getURL()
72 return m_model.getURL();
75 /**
76 * simplified version (taking no arguments except the target URL) of XStorage.storeAsURL
77 * @param _url
78 * specifies the location to where to store the document
80 public void storeAsURL( final String _url ) throws IOException
82 m_storeDoc.storeAsURL( _url, new PropertyValue[] { } );
85 private XMultiServiceFactory m_orb;
86 private DataSource m_dataSource;
87 private XOfficeDatabaseDocument m_databaseDocument;
88 private XModel m_model;
89 private XStorable m_storeDoc;