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_XMLCONNECTIONDATA_HXX_INCLUDED
27 #include "xmlConnectionData.hxx"
28 #endif
29 #ifndef DBA_XMLLOGIN_HXX
30 #include "xmlLogin.hxx"
31 #endif
32 #ifndef DBA_XMLTABLEFILTERLIST_HXX
33 #include "xmlTableFilterList.hxx"
34 #endif
35 #ifndef DBA_XMLFILTER_HXX
36 #include "xmlfilter.hxx"
37 #endif
38 #ifndef _XMLOFF_XMLTOKEN_HXX
39 #include <xmloff/xmltoken.hxx>
40 #endif
41 #ifndef _XMLOFF_XMLNMSPE_HXX
42 #include <xmloff/xmlnmspe.hxx>
43 #endif
44 #ifndef _XMLOFF_NMSPMAP_HXX
45 #include <xmloff/nmspmap.hxx>
46 #endif
47 #include "xmlEnums.hxx"
48 #include "xmlDatabaseDescription.hxx"
49 #include "xmlConnectionResource.hxx"
50 #include "xmlstrings.hrc"
51 #ifndef _TOOLS_DEBUG_HXX
52 #include <tools/debug.hxx>
53 #endif
54 #ifndef TOOLS_DIAGNOSE_EX_H
55 #include <tools/diagnose_ex.h>
56 #endif
57 
58 namespace dbaxml
59 {
60 	using namespace ::com::sun::star::uno;
61 	using namespace ::com::sun::star::xml::sax;
DBG_NAME(OXMLConnectionData)62 DBG_NAME(OXMLConnectionData)
63 
64 OXMLConnectionData::OXMLConnectionData( ODBFilter& rImport,
65 				sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName) :
66 	SvXMLImportContext( rImport, nPrfx, _sLocalName )
67     ,m_bFoundOne(false)
68 {
69     rImport.setNewFormat(true);
70     DBG_CTOR(OXMLConnectionData,NULL);
71 }
72 // -----------------------------------------------------------------------------
73 
~OXMLConnectionData()74 OXMLConnectionData::~OXMLConnectionData()
75 {
76 
77     DBG_DTOR(OXMLConnectionData,NULL);
78 }
79 // -----------------------------------------------------------------------------
80 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> & xAttrList)81 SvXMLImportContext* OXMLConnectionData::CreateChildContext(
82 		sal_uInt16 nPrefix,
83 		const ::rtl::OUString& rLocalName,
84 		const Reference< XAttributeList > & xAttrList )
85 {
86 	SvXMLImportContext *pContext = 0;
87 	const SvXMLTokenMap&	rTokenMap	= GetOwnImport().GetDataSourceElemTokenMap();
88 
89 	switch( rTokenMap.Get( nPrefix, rLocalName ) )
90 	{
91 		case XML_TOK_LOGIN:
92 			GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
93 			pContext = new OXMLLogin( GetOwnImport(), nPrefix, rLocalName,xAttrList );
94 			break;
95         case XML_TOK_DATABASE_DESCRIPTION:
96             if ( !m_bFoundOne )
97             {
98                 m_bFoundOne = true;
99 			    GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
100 			    pContext = new OXMLDatabaseDescription( GetOwnImport(), nPrefix, rLocalName);
101             }
102 			break;
103         case XML_TOK_CONNECTION_RESOURCE:
104             if ( !m_bFoundOne )
105             {
106                 m_bFoundOne = true;
107 			    GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
108 			    pContext = new OXMLConnectionResource( GetOwnImport(), nPrefix, rLocalName,xAttrList );
109             }
110 			break;
111         case XML_TOK_COMPOUND_DATABASE:
112             if ( !m_bFoundOne )
113             {
114                 m_bFoundOne = true;
115                 OSL_ENSURE(0,"Not supported yet!");
116             }
117 			break;
118 	}
119 
120 	if( !pContext )
121 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
122 
123 	return pContext;
124 }
125 // -----------------------------------------------------------------------------
GetOwnImport()126 ODBFilter& OXMLConnectionData::GetOwnImport()
127 {
128 	return static_cast<ODBFilter&>(GetImport());
129 }
130 // -----------------------------------------------------------------------------
131 //----------------------------------------------------------------------------
132 } // namespace dbaxml
133 // -----------------------------------------------------------------------------
134