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_dbaxml.hxx"
26 #ifndef DBA_XMLDOCUMENTS_HXX
27 #include "xmlDocuments.hxx"
28 #endif
29 #ifndef DBA_XMLFILTER_HXX
30 #include "xmlfilter.hxx"
31 #endif
32 #ifndef _XMLOFF_XMLTOKEN_HXX
33 #include <xmloff/xmltoken.hxx>
34 #endif
35 #ifndef _XMLOFF_XMLNMSPE_HXX
36 #include <xmloff/xmlnmspe.hxx>
37 #endif
38 #ifndef DBA_XMLQUERY_HXX
39 #include "xmlQuery.hxx"
40 #endif
41 #ifndef DBA_XMLTABLE_HXX
42 #include "xmlTable.hxx"
43 #endif
44 #ifndef DBA_XMLCOMPONENT_HXX
45 #include "xmlComponent.hxx"
46 #endif
47 #ifndef DBA_XMLHIERARCHYCOLLECTION_HXX
48 #include "xmlHierarchyCollection.hxx"
49 #endif
50 #ifndef DBA_XMLENUMS_HXX
51 #include "xmlEnums.hxx"
52 #endif
53 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
54 #include "xmlstrings.hrc"
55 #endif
56 #ifndef _TOOLS_DEBUG_HXX
57 #include <tools/debug.hxx>
58 #endif
59 
60 namespace dbaxml
61 {
62 	using namespace ::com::sun::star::uno;
63 	using namespace ::com::sun::star::container;
64 	using namespace ::com::sun::star::xml::sax;
DBG_NAME(OXMLDocuments)65 DBG_NAME(OXMLDocuments)
66 
67 OXMLDocuments::OXMLDocuments( ODBFilter& rImport
68 				,sal_uInt16 nPrfx
69 				, const ::rtl::OUString& rLName
70 				,const Reference< XNameAccess >& _xContainer
71 				,const ::rtl::OUString& _sCollectionServiceName
72 				,const ::rtl::OUString& _sComponentServiceName) :
73 	SvXMLImportContext( rImport, nPrfx, rLName )
74 		,m_xContainer(_xContainer)
75 		,m_sCollectionServiceName(_sCollectionServiceName)
76 		,m_sComponentServiceName(_sComponentServiceName)
77 {
78     DBG_CTOR(OXMLDocuments,NULL);
79 
80 }
81 // -----------------------------------------------------------------------------
OXMLDocuments(ODBFilter & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const Reference<XNameAccess> & _xContainer,const::rtl::OUString & _sCollectionServiceName)82 OXMLDocuments::OXMLDocuments( ODBFilter& rImport
83 				,sal_uInt16 nPrfx
84 				, const ::rtl::OUString& rLName
85 				,const Reference< XNameAccess >& _xContainer
86 				,const ::rtl::OUString& _sCollectionServiceName
87 				) :
88 	SvXMLImportContext( rImport, nPrfx, rLName )
89 		,m_xContainer(_xContainer)
90 		,m_sCollectionServiceName(_sCollectionServiceName)
91 {
92     DBG_CTOR(OXMLDocuments,NULL);
93 }
94 // -----------------------------------------------------------------------------
95 
~OXMLDocuments()96 OXMLDocuments::~OXMLDocuments()
97 {
98 
99     DBG_DTOR(OXMLDocuments,NULL);
100 }
101 // -----------------------------------------------------------------------------
102 
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> & xAttrList)103 SvXMLImportContext* OXMLDocuments::CreateChildContext(
104 		sal_uInt16 nPrefix,
105 		const ::rtl::OUString& rLocalName,
106 		const Reference< XAttributeList > & xAttrList )
107 {
108 	SvXMLImportContext *pContext = 0;
109 	const SvXMLTokenMap&	rTokenMap	= GetOwnImport().GetDocumentsElemTokenMap();
110 
111 	switch( rTokenMap.Get( nPrefix, rLocalName ) )
112 	{
113 		case XML_TOK_TABLE:
114 			GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
115 			pContext = new OXMLTable( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,SERVICE_SDB_TABLEDEFINITION);
116 			break;
117 		case XML_TOK_QUERY:
118 			GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
119 			pContext = new OXMLQuery( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer );
120 			break;
121 		case XML_TOK_COMPONENT:
122 			GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
123 			pContext = new OXMLComponent( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sComponentServiceName );
124 			break;
125 		//	case XML_TOK_QUERY_COLLECTION:
126 		case XML_TOK_COMPONENT_COLLECTION:
127 			GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
128 			pContext = new OXMLHierarchyCollection( GetOwnImport(), nPrefix, rLocalName,xAttrList,m_xContainer,m_sCollectionServiceName,m_sComponentServiceName );
129 			break;
130 	}
131 
132 	if( !pContext )
133 		pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
134 
135 
136 	return pContext;
137 }
138 // -----------------------------------------------------------------------------
GetOwnImport()139 ODBFilter& OXMLDocuments::GetOwnImport()
140 {
141 	return static_cast<ODBFilter&>(GetImport());
142 }
143 // -----------------------------------------------------------------------------
144 //----------------------------------------------------------------------------
145 } // namespace dbaxml
146 // -----------------------------------------------------------------------------
147