Update ooo320-m1
[ooovba.git] / dbaccess / source / filter / xml / xmlDatabase.cxx
blob33586879ce624fca18a3812429fd650c1429745e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlDatabase.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBA_XMLDATABASE_HXX
34 #include "xmlDatabase.hxx"
35 #endif
36 #ifndef DBA_XMLFILTER_HXX
37 #include "xmlfilter.hxx"
38 #endif
39 #ifndef _XMLOFF_XMLTOKEN_HXX
40 #include <xmloff/xmltoken.hxx>
41 #endif
42 #ifndef _XMLOFF_XMLNMSPE_HXX
43 #include <xmloff/xmlnmspe.hxx>
44 #endif
45 #ifndef DBA_XMLDATASOURCE_HXX
46 #include "xmlDataSource.hxx"
47 #endif
48 #ifndef DBA_XMLDOCUMENTS_HXX
49 #include "xmlDocuments.hxx"
50 #endif
51 #ifndef DBA_XMLENUMS_HXX
52 #include "xmlEnums.hxx"
53 #endif
54 #ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_
55 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
56 #endif
57 #ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_
58 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
59 #endif
60 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
61 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
62 #endif
63 #ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
64 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
65 #endif
66 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
67 #include "xmlstrings.hrc"
68 #endif
69 #ifndef _TOOLS_DEBUG_HXX
70 #include <tools/debug.hxx>
71 #endif
73 namespace dbaxml
75 using namespace ::com::sun::star::uno;
76 using namespace ::com::sun::star::sdb;
77 using namespace ::com::sun::star::sdbcx;
78 using namespace ::com::sun::star::xml::sax;
79 DBG_NAME(OXMLDatabase)
81 OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
82 sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
83 SvXMLImportContext( rImport, nPrfx, rLName )
85 DBG_CTOR(OXMLDatabase,NULL);
88 // -----------------------------------------------------------------------------
90 OXMLDatabase::~OXMLDatabase()
93 DBG_DTOR(OXMLDatabase,NULL);
95 // -----------------------------------------------------------------------------
97 SvXMLImportContext* OXMLDatabase::CreateChildContext(
98 sal_uInt16 nPrefix,
99 const ::rtl::OUString& rLocalName,
100 const Reference< XAttributeList > & xAttrList )
102 SvXMLImportContext *pContext = 0;
103 const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseElemTokenMap();
105 switch( rTokenMap.Get( nPrefix, rLocalName ) )
107 case XML_TOK_DATASOURCE:
108 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
109 pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
110 break;
111 case XML_TOK_FORMS:
113 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
114 Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
115 if ( xSup.is() )
116 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
118 break;
119 case XML_TOK_REPORTS:
121 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
122 Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
123 if ( xSup.is() )
124 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
126 break;
127 case XML_TOK_QUERIES:
129 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
130 Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
131 if ( xSup.is() )
132 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
134 break;
135 case XML_TOK_TABLES:
136 case XML_TOK_SCHEMA_DEFINITION:
138 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
139 Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
140 if ( xSup.is() )
141 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
143 break;
146 if( !pContext )
147 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
150 return pContext;
152 // -----------------------------------------------------------------------------
153 ODBFilter& OXMLDatabase::GetOwnImport()
155 return static_cast<ODBFilter&>(GetImport());
157 // -----------------------------------------------------------------------------
158 void OXMLDatabase::EndElement()
160 GetOwnImport().setPropertyInfo();
163 //----------------------------------------------------------------------------
164 } // namespace dbaxml
165 // -----------------------------------------------------------------------------