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/ProgressBarHelper.hxx>
24 #include "xmlDataSource.hxx"
25 #include "xmlDocuments.hxx"
26 #include "xmlEnums.hxx"
27 #include <com/sun/star/frame/XModel.hpp>
28 #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
29 #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
30 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
31 #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
32 #include <strings.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 SvXMLImportContext( rImport
)
48 OXMLDatabase::~OXMLDatabase()
53 css::uno::Reference
< css::xml::sax::XFastContextHandler
> OXMLDatabase::createFastChildContext(
54 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& xAttrList
)
56 SvXMLImportContext
*pContext
= nullptr;
58 switch( nElement
& TOKEN_MASK
)
61 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
62 pContext
= new OXMLDataSource( GetOwnImport(), xAttrList
, OXMLDataSource::eDataSource
);
66 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
69 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue
);
71 if ( sService
.isEmpty() )
73 Reference
<XFormDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
75 pContext
= new OXMLDocuments( GetOwnImport(), xSup
->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
81 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
84 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue
);
86 if ( sService
.isEmpty() )
88 Reference
<XReportDocumentsSupplier
> xSup(GetOwnImport().GetModel(),UNO_QUERY
);
90 pContext
= new OXMLDocuments( GetOwnImport(), xSup
->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION
,SERVICE_SDB_DOCUMENTDEFINITION
);
96 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
99 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue
);
101 if ( sService
.isEmpty() )
103 Reference
<XQueryDefinitionsSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
105 pContext
= new OXMLDocuments( GetOwnImport(), xSup
->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION
);
109 case XML_TABLE_REPRESENTATIONS
:
110 case XML_SCHEMA_DEFINITION
:
112 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP
);
113 Reference
<XTablesSupplier
> xSup(GetOwnImport().getDataSource(),UNO_QUERY
);
115 pContext
= new OXMLDocuments( GetOwnImport(), xSup
->getTables());
123 ODBFilter
& OXMLDatabase::GetOwnImport()
125 return static_cast<ODBFilter
&>(GetImport());
128 void OXMLDatabase::endFastElement(sal_Int32
)
130 GetOwnImport().setPropertyInfo();
133 } // namespace dbaxml
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */