1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlDatabase.cxx,v $
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"
36 #ifndef DBA_XMLFILTER_HXX
37 #include "xmlfilter.hxx"
39 #ifndef _XMLOFF_XMLTOKEN_HXX
40 #include <xmloff/xmltoken.hxx>
42 #ifndef _XMLOFF_XMLNMSPE_HXX
43 #include <xmloff/xmlnmspe.hxx>
45 #ifndef DBA_XMLDATASOURCE_HXX
46 #include "xmlDataSource.hxx"
48 #ifndef DBA_XMLDOCUMENTS_HXX
49 #include "xmlDocuments.hxx"
51 #ifndef DBA_XMLENUMS_HXX
52 #include "xmlEnums.hxx"
54 #ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_
55 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
57 #ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_
58 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
60 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
61 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
63 #ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
64 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
66 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
67 #include "xmlstrings.hrc"
69 #ifndef _TOOLS_DEBUG_HXX
70 #include <tools/debug.hxx>
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(
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
);
113 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
114 Reference
<XFormDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
116 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
119 case XML_TOK_REPORTS
:
121 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
122 Reference
<XReportDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
124 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
127 case XML_TOK_QUERIES
:
129 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
130 Reference
<XQueryDefinitionsSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
132 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION
);
136 case XML_TOK_SCHEMA_DEFINITION
:
138 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
139 Reference
<XTablesSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
141 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getTables());
147 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
152 // -----------------------------------------------------------------------------
153 ODBFilter
& OXMLDatabase::GetOwnImport()
155 return static_cast<ODBFilter
&>(GetImport());
157 // -----------------------------------------------------------------------------
158 void OXMLDatabase::EndElement()
160 GetOwnImport().setPropertyInfo();
163 //----------------------------------------------------------------------------
164 } // namespace dbaxml
165 // -----------------------------------------------------------------------------