Branch data 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 : 14 : OXMLDatabase::OXMLDatabase( ODBFilter& rImport,
44 : : sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
45 : 14 : SvXMLImportContext( rImport, nPrfx, rLName )
46 : : {
47 : : DBG_CTOR(OXMLDatabase,NULL);
48 : :
49 : 14 : }
50 : : // -----------------------------------------------------------------------------
51 : :
52 : 14 : OXMLDatabase::~OXMLDatabase()
53 : : {
54 : :
55 : : DBG_DTOR(OXMLDatabase,NULL);
56 [ - + ]: 28 : }
57 : : // -----------------------------------------------------------------------------
58 : :
59 : 26 : SvXMLImportContext* OXMLDatabase::CreateChildContext(
60 : : sal_uInt16 nPrefix,
61 : : const ::rtl::OUString& rLocalName,
62 : : const Reference< XAttributeList > & xAttrList )
63 : : {
64 : 26 : SvXMLImportContext *pContext = 0;
65 : 26 : const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseElemTokenMap();
66 : :
67 [ + - - - : 26 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
+ - ]
68 : : {
69 : : case XML_TOK_DATASOURCE:
70 : 14 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
71 [ + - ]: 14 : pContext = new OXMLDataSource( GetOwnImport(), nPrefix, rLocalName, xAttrList, OXMLDataSource::eDataSource );
72 : 14 : 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 [ + - ][ + - ]: 12 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
122 [ + - ][ + - ]: 12 : Reference<XTablesSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
123 [ + - ]: 12 : if ( xSup.is() )
124 [ + - ][ + - ]: 12 : pContext = new OXMLDocuments( GetOwnImport(), nPrefix, rLocalName,xSup->getTables());
[ + - ][ + - ]
125 : : }
126 : 12 : break;
127 : : }
128 : :
129 [ - + ]: 26 : if( !pContext )
130 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
131 : :
132 : :
133 : 26 : return pContext;
134 : : }
135 : : // -----------------------------------------------------------------------------
136 : 104 : ODBFilter& OXMLDatabase::GetOwnImport()
137 : : {
138 : 104 : return static_cast<ODBFilter&>(GetImport());
139 : : }
140 : : // -----------------------------------------------------------------------------
141 : 14 : void OXMLDatabase::EndElement()
142 : : {
143 : 14 : GetOwnImport().setPropertyInfo();
144 : 14 : }
145 : :
146 : : //----------------------------------------------------------------------------
147 : : } // namespace dbaxml
148 : : // -----------------------------------------------------------------------------
149 : :
150 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|