tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / filter / xml / xmlDatabase.cxx
blob2f629caff37ead4dbcebf020a17063ebd59b5fa9
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/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>
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 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 )
60 case XML_DATA_SOURCE:
61 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
62 pContext = new OXMLDataSource( GetOwnImport(), xAttrList, OXMLDataSource::eDataSource );
63 break;
64 case XML_FORMS:
66 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
67 Any aValue;
68 OUString sService;
69 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Forms",aValue);
70 aValue >>= sService;
71 if ( sService.isEmpty() )
73 Reference<XFormDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
74 if ( xSup.is() )
75 pContext = new OXMLDocuments( GetOwnImport(), xSup->getFormDocuments(),SERVICE_NAME_FORM_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
78 break;
79 case XML_REPORTS:
81 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
82 Any aValue;
83 OUString sService;
84 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"Reports",aValue);
85 aValue >>= sService;
86 if ( sService.isEmpty() )
88 Reference<XReportDocumentsSupplier> xSup(GetOwnImport().GetModel(),UNO_QUERY);
89 if ( xSup.is() )
90 pContext = new OXMLDocuments( GetOwnImport(), xSup->getReportDocuments(),SERVICE_NAME_REPORT_COLLECTION,SERVICE_SDB_DOCUMENTDEFINITION);
93 break;
94 case XML_QUERIES:
96 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
97 Any aValue;
98 OUString sService;
99 dbtools::getDataSourceSetting(GetOwnImport().getDataSource(),"CommandDefinitions",aValue);
100 aValue >>= sService;
101 if ( sService.isEmpty() )
103 Reference<XQueryDefinitionsSupplier> xSup(GetOwnImport().getDataSource(),UNO_QUERY);
104 if ( xSup.is() )
105 pContext = new OXMLDocuments( GetOwnImport(), xSup->getQueryDefinitions(),SERVICE_NAME_QUERY_COLLECTION);
108 break;
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);
114 if ( xSup.is() )
115 pContext = new OXMLDocuments( GetOwnImport(), xSup->getTables());
117 break;
120 return pContext;
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: */