1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "xmlDatabase.hxx"
21 #include "xmlfilter.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include <xmloff/xmlnmspe.hxx>
24 #include "xmlDataSource.hxx"
25 #include "xmlDocuments.hxx"
26 #include "xmlEnums.hxx"
27 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
28 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
29 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
30 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
31 #include "xmlstrings.hrc"
32 #include <tools/debug.hxx>
33 #include <connectivity/dbtools.hxx>
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::sdb
;
39 using namespace ::com::sun::star::sdbcx
;
40 using namespace ::com::sun::star::xml::sax
;
42 OXMLDatabase::OXMLDatabase( ODBFilter
& rImport
,
43 sal_uInt16 nPrfx
, const OUString
& rLName
) :
44 SvXMLImportContext( rImport
, nPrfx
, rLName
)
49 OXMLDatabase::~OXMLDatabase()
54 SvXMLImportContext
* OXMLDatabase::CreateChildContext(
56 const OUString
& rLocalName
,
57 const Reference
< XAttributeList
> & xAttrList
)
59 SvXMLImportContext
*pContext
= 0;
60 const SvXMLTokenMap
& rTokenMap
= GetOwnImport().GetDatabaseElemTokenMap();
62 switch( rTokenMap
.Get( nPrefix
, rLocalName
) )
64 case XML_TOK_DATASOURCE
:
65 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
66 pContext
= new OXMLDataSource( GetOwnImport(), nPrefix
, rLocalName
, xAttrList
, OXMLDataSource::eDataSource
);
70 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
73 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue
);
75 if ( sService
.isEmpty() )
77 Reference
<XFormDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
79 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
85 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
88 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue
);
90 if ( sService
.isEmpty() )
92 Reference
<XReportDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
94 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
100 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
103 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue
);
105 if ( sService
.isEmpty() )
107 Reference
<XQueryDefinitionsSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
109 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION
);
114 case XML_TOK_SCHEMA_DEFINITION
:
116 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
117 Reference
<XTablesSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
119 pContext
= new OXMLDocuments( GetOwnImport(), nPrefix
, rLocalName
,xSup
->getTables());
125 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
130 ODBFilter
& OXMLDatabase::GetOwnImport()
132 return static_cast<ODBFilter
&>(GetImport());
135 void OXMLDatabase::EndElement()
137 GetOwnImport().setPropertyInfo();
140 } // namespace dbaxml
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */