1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 #ifndef DBA_XMLDATABASEDESCRIPTION_HXX_INCLUDED
27 #include "xmlDatabaseDescription.hxx"
28 #endif
29 #ifndef DBA_XMLLOGIN_HXX
30 #include "xmlLogin.hxx"
31 #endif
32 #ifndef DBA_XMLFILTER_HXX
33 #include "xmlfilter.hxx"
34 #endif
35 #ifndef _XMLOFF_XMLTOKEN_HXX
36 #include <xmloff/xmltoken.hxx>
37 #endif
38 #ifndef _XMLOFF_XMLNMSPE_HXX
39 #include <xmloff/xmlnmspe.hxx>
40 #endif
41 #ifndef _XMLOFF_NMSPMAP_HXX
42 #include <xmloff/nmspmap.hxx>
43 #endif
44 #include "xmlEnums.hxx"
45 #include "xmlFileBasedDatabase.hxx"
46 #include "xmlServerDatabase.hxx"
47 #include "xmlstrings.hrc"
48 #ifndef _TOOLS_DEBUG_HXX
49 #include <tools/debug.hxx>
50 #endif
51 #ifndef TOOLS_DIAGNOSE_EX_H
52 #include <tools/diagnose_ex.h>
53 #endif
54
55 namespace dbaxml
56 {
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::xml::sax;
DBG_NAME(OXMLDatabaseDescription)59 DBG_NAME(OXMLDatabaseDescription)
60
61 OXMLDatabaseDescription::OXMLDatabaseDescription( ODBFilter& rImport,
62 sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName) :
63 SvXMLImportContext( rImport, nPrfx, _sLocalName )
64 ,m_bFoundOne(false)
65 {
66 DBG_CTOR(OXMLDatabaseDescription,NULL);
67 }
68 // -----------------------------------------------------------------------------
69
~OXMLDatabaseDescription()70 OXMLDatabaseDescription::~OXMLDatabaseDescription()
71 {
72
73 DBG_DTOR(OXMLDatabaseDescription,NULL);
74 }
75 // -----------------------------------------------------------------------------
76
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> & xAttrList)77 SvXMLImportContext* OXMLDatabaseDescription::CreateChildContext(
78 sal_uInt16 nPrefix,
79 const ::rtl::OUString& rLocalName,
80 const Reference< XAttributeList > & xAttrList )
81 {
82 SvXMLImportContext *pContext = 0;
83 const SvXMLTokenMap& rTokenMap = GetOwnImport().GetDatabaseDescriptionElemTokenMap();
84
85 switch( rTokenMap.Get( nPrefix, rLocalName ) )
86 {
87 case XML_TOK_FILE_BASED_DATABASE:
88 if ( !m_bFoundOne )
89 {
90 m_bFoundOne = true;
91 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
92 pContext = new OXMLFileBasedDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
93 }
94 break;
95 case XML_TOK_SERVER_DATABASE:
96 if ( !m_bFoundOne )
97 {
98 m_bFoundOne = true;
99 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
100 pContext = new OXMLServerDatabase( GetOwnImport(), nPrefix, rLocalName,xAttrList );
101 }
102 break;
103 }
104
105 if( !pContext )
106 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
107
108 return pContext;
109 }
110 // -----------------------------------------------------------------------------
GetOwnImport()111 ODBFilter& OXMLDatabaseDescription::GetOwnImport()
112 {
113 return static_cast<ODBFilter&>(GetImport());
114 }
115 // -----------------------------------------------------------------------------
116 //----------------------------------------------------------------------------
117 } // namespace dbaxml
118 // -----------------------------------------------------------------------------
119