bump product version to 5.0.4.1
[LibreOffice.git] / dbaccess / source / filter / xml / xmlDatabase.cxx
blob967ee8744cf41e410e80b2f413a45d14f09c3733
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
35 namespace dbaxml
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(
55 sal_uInt16 nPrefix,
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 );
67 break;
68 case XML_TOK_FORMS:
70 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
71 Any aValue;
72 OUString sService;
73 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue);
74 aValue >>= sService;
75 if ( sService.isEmpty() )
77 Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
78 if ( xSup.is() )
79 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
82 break;
83 case XML_TOK_REPORTS:
85 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
86 Any aValue;
87 OUString sService;
88 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
89 aValue >>= sService;
90 if ( sService.isEmpty() )
92 Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
93 if ( xSup.is() )
94 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
97 break;
98 case XML_TOK_QUERIES:
100 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
101 Any aValue;
102 OUString sService;
103 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
104 aValue >>= sService;
105 if ( sService.isEmpty() )
107 Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
108 if ( xSup.is() )
109 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
112 break;
113 case XML_TOK_TABLES:
114 case XML_TOK_SCHEMA_DEFINITION:
116 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
117 Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
118 if ( xSup.is() )
119 pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
121 break;
124 if( !pContext )
125 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
127 return pContext;
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: */