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 "xmlDatabaseDescription.hxx"
21 : #include "xmlLogin.hxx"
22 : #include "xmlfilter.hxx"
23 : #include <xmloff/xmltoken.hxx>
24 : #include <xmloff/xmlnmspe.hxx>
25 : #include <xmloff/nmspmap.hxx>
26 : #include "xmlEnums.hxx"
27 : #include "xmlFileBasedDatabase.hxx"
28 : #include "xmlServerDatabase.hxx"
29 : #include "xmlstrings.hrc"
30 : #include <tools/debug.hxx>
31 : #include <tools/diagnose_ex.h>
32 :
33 : namespace dbaxml
34 : {
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::xml::sax;
37 :
38 9 : OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport,
39 : sal_uInt16 nPrfx, const OUString& _sLocalName) :
40 : SvXMLImportContext( rImport, nPrfx, _sLocalName )
41 9 : ,m_bFoundOne(false)
42 : {
43 9 : }
44 :
45 18 : OXMLDatabaseDescription::~OXMLDatabaseDescription()
46 : {
47 :
48 18 : }
49 :
50 9 : SvXMLImportContext* OXMLDatabaseDescription::CreateChildContext(
51 : sal_uInt16 nPrefix,
52 : const OUString& rLocalName,
53 : const Reference< XAttributeList > & xAttrList )
54 : {
55 9 : SvXMLImportContext *pContext = 0;
56 9 : const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseDescriptionElemTokenMap();
57 :
58 9 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
59 : {
60 : case XML_TOK_FILE_BASED_DATABASE:
61 9 : if ( !m_bFoundOne )
62 : {
63 9 : m_bFoundOne = true;
64 9 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
65 9 : pContext = new OXMLFileBasedDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
66 : }
67 9 : break;
68 : case XML_TOK_SERVER_DATABASE:
69 0 : if ( !m_bFoundOne )
70 : {
71 0 : m_bFoundOne = true;
72 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
73 0 : pContext = new OXMLServerDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
74 : }
75 0 : break;
76 : }
77 :
78 9 : if( !pContext )
79 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
80 :
81 9 : return pContext;
82 : }
83 :
84 27 : ODBFilter& OXMLDatabaseDescription::GetOwnImport()
85 : {
86 27 : return static_cast<ODBFilter&>(GetImport());
87 : }
88 :
89 : } // namespace dbaxml
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|