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 "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 : : DBG_NAME(OXMLDatabaseDescription)
38 : :
39 : 14 : OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport,
40 : : sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName) :
41 : : SvXMLImportContext( rImport, nPrfx, _sLocalName )
42 : 14 : ,m_bFoundOne(false)
43 : : {
44 : : DBG_CTOR(OXMLDatabaseDescription,NULL);
45 : 14 : }
46 : : // -----------------------------------------------------------------------------
47 : :
48 : 14 : OXMLDatabaseDescription::~OXMLDatabaseDescription()
49 : : {
50 : :
51 : : DBG_DTOR(OXMLDatabaseDescription,NULL);
52 [ - + ]: 28 : }
53 : : // -----------------------------------------------------------------------------
54 : :
55 : 14 : SvXMLImportContext* OXMLDatabaseDescription::CreateChildContext(
56 : : sal_uInt16 nPrefix,
57 : : const ::rtl::OUString& rLocalName,
58 : : const Reference< XAttributeList > & xAttrList )
59 : : {
60 : 14 : SvXMLImportContext *pContext = 0;
61 : 14 : const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseDescriptionElemTokenMap();
62 : :
63 [ + - - ]: 14 : switch( rTokenMap.Get( nPrefix, rLocalName ) )
64 : : {
65 : : case XML_TOK_FILE_BASED_DATABASE:
66 [ + - ]: 14 : if ( !m_bFoundOne )
67 : : {
68 : 14 : m_bFoundOne = true;
69 : 14 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
70 [ + - ]: 14 : pContext = new OXMLFileBasedDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
71 : : }
72 : 14 : break;
73 : : case XML_TOK_SERVER_DATABASE:
74 [ # # ]: 0 : if ( !m_bFoundOne )
75 : : {
76 : 0 : m_bFoundOne = true;
77 : 0 : GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
78 [ # # ]: 0 : pContext = new OXMLServerDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
79 : : }
80 : 0 : break;
81 : : }
82 : :
83 [ - + ]: 14 : if( !pContext )
84 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
85 : :
86 : 14 : return pContext;
87 : : }
88 : : // -----------------------------------------------------------------------------
89 : 42 : ODBFilter& OXMLDatabaseDescription::GetOwnImport()
90 : : {
91 : 42 : return static_cast<ODBFilter&>(GetImport());
92 : : }
93 : : // -----------------------------------------------------------------------------
94 : : //----------------------------------------------------------------------------
95 : : } // namespace dbaxml
96 : : // -----------------------------------------------------------------------------
97 : :
98 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|