Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
34 :
35 : namespace dbaxml
36 : {
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;
41 : DBG_NAME(OXMLDatabase)
42 :
43 0 : OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
44 : sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
45 0 : SvXMLImportContext( rImport, nPrfx, rLName )
46 : {
47 : DBG_CTOR(OXMLDatabase,NULL);
48 :
49 0 : }
50 : // -----------------------------------------------------------------------------
51 :
52 0 : OXMLDatabase::~OXMLDatabase()
53 : {
54 :
55 : DBG_DTOR(OXMLDatabase,NULL);
56 0 : }
57 : // -----------------------------------------------------------------------------
58 :
59 0 : SvXMLImportContext* OXMLDatabase::CreateChildContext(
60 : sal_uInt16 nPrefix,
61 : const ::rtl::OUString& rLocalName,
62 : const Reference< XAttributeList > & xAttrList )
63 : {
64 0 : SvXMLImportContext *pContext = 0;
65 0 : const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseElemTokenMap();
66 :
67 0 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
68 : {
69 : case XML_TOK_DATASOURCE:
70 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
71 0 : pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
72 0 : break;
73 : case XML_TOK_FORMS:
74 : {
75 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
76 0 : Any aValue;
77 0 : ::rtl::OUString sService;
78 0 : dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue);
79 0 : aValue >>= sService;
80 0 : if ( sService.isEmpty() )
81 : {
82 0 : Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
83 0 : if ( xSup.is() )
84 0 : pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
85 0 : }
86 : }
87 0 : break;
88 : case XML_TOK_REPORTS:
89 : {
90 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
91 0 : Any aValue;
92 0 : ::rtl::OUString sService;
93 0 : dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
94 0 : aValue >>= sService;
95 0 : if ( sService.isEmpty() )
96 : {
97 0 : Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
98 0 : if ( xSup.is() )
99 0 : pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
100 0 : }
101 : }
102 0 : break;
103 : case XML_TOK_QUERIES:
104 : {
105 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
106 0 : Any aValue;
107 0 : ::rtl::OUString sService;
108 0 : dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
109 0 : aValue >>= sService;
110 0 : if ( sService.isEmpty() )
111 : {
112 0 : Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
113 0 : if ( xSup.is() )
114 0 : pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
115 0 : }
116 : }
117 0 : break;
118 : case XML_TOK_TABLES:
119 : case XML_TOK_SCHEMA_DEFINITION:
120 : {
121 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
122 0 : Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
123 0 : if ( xSup.is() )
124 0 : pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
125 : }
126 0 : break;
127 : }
128 :
129 0 : if( !pContext )
130 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
131 :
132 :
133 0 : return pContext;
134 : }
135 : // -----------------------------------------------------------------------------
136 0 : ODBFilter& OXMLDatabase::GetOwnImport()
137 : {
138 0 : return static_cast<ODBFilter&>(GetImport());
139 : }
140 : // -----------------------------------------------------------------------------
141 0 : void OXMLDatabase::EndElement()
142 : {
143 0 : GetOwnImport().setPropertyInfo();
144 0 : }
145 :
146 : //----------------------------------------------------------------------------
147 : } // namespace dbaxml
148 : // -----------------------------------------------------------------------------
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|