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_XMLTABLEFILTERLIST_HXX
27 #include "xmlTableFilterList.hxx"
28 #endif
29 #ifndef DBA_XMLTABLEFILTERPATTERN_HXX
30 #include "xmlTableFilterPattern.hxx"
31 #endif
32 #ifndef DBA_XMLENUMS_HXX
33 #include "xmlEnums.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 #ifndef _XMLOFF_XMLTOKEN_HXX
45 #include <xmloff/xmltoken.hxx>
46 #endif
47 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
48 #include "xmlstrings.hrc"
49 #endif
50 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
51 #include <com/sun/star/beans/XPropertySet.hpp>
52 #endif
53 #ifndef _XMLOFF_XMLIMP_HXX
54 #include <xmloff/xmlimp.hxx>
55 #endif
56 #ifndef DBA_XMLFILTER_HXX
57 #include "xmlfilter.hxx"
58 #endif
59 #ifndef _TOOLS_DEBUG_HXX
60 #include <tools/debug.hxx>
61 #endif
62
63 namespace dbaxml
64 {
65 using namespace ::xmloff::token;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::beans;
68 using namespace ::com::sun::star::xml::sax;
DBG_NAME(OXMLTableFilterList)69 DBG_NAME(OXMLTableFilterList)
70
71 OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName )
72 :SvXMLImportContext( rImport, nPrfx, _sLocalName )
73 {
74 DBG_CTOR(OXMLTableFilterList,NULL);
75
76 }
77 // -----------------------------------------------------------------------------
78
~OXMLTableFilterList()79 OXMLTableFilterList::~OXMLTableFilterList()
80 {
81 DBG_DTOR(OXMLTableFilterList,NULL);
82 }
83 // -----------------------------------------------------------------------------
84
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const Reference<XAttributeList> &)85 SvXMLImportContext* OXMLTableFilterList::CreateChildContext(
86 sal_uInt16 nPrefix,
87 const ::rtl::OUString& rLocalName,
88 const Reference< XAttributeList > & /*xAttrList*/ )
89 {
90 SvXMLImportContext *pContext = 0;
91
92 if ( XML_NAMESPACE_DB == nPrefix )
93 {
94 GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
95 if ( IsXMLToken( rLocalName, XML_TABLE_FILTER_PATTERN ) )
96 pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_True,*this);
97 else if ( IsXMLToken( rLocalName, XML_TABLE_TYPE ) )
98 pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_False,*this);
99 else if ( IsXMLToken( rLocalName, XML_TABLE_INCLUDE_FILTER ) )
100 pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName );
101 }
102
103 if( !pContext )
104 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
105
106 return pContext;
107 }
108 // -----------------------------------------------------------------------------
GetOwnImport()109 ODBFilter& OXMLTableFilterList::GetOwnImport()
110 {
111 return static_cast<ODBFilter&>(GetImport());
112 }
113
114 // -----------------------------------------------------------------------------
EndElement()115 void OXMLTableFilterList::EndElement()
116 {
117 Reference<XPropertySet> xDataSource(GetOwnImport().getDataSource());
118 if ( xDataSource.is() )
119 {
120 if ( !m_aPatterns.empty() )
121 xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aPatterns.begin()),m_aPatterns.size())));
122 if ( !m_aTypes.empty() )
123 xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aTypes.begin()),m_aTypes.size())));
124 }
125 }
126 //----------------------------------------------------------------------------
127 } // namespace dbaxml
128 // -----------------------------------------------------------------------------
129