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 "xmlTableFilterList.hxx"
21 : #include "xmlTableFilterPattern.hxx"
22 : #include "xmlEnums.hxx"
23 : #include <xmloff/xmltoken.hxx>
24 : #include <xmloff/xmlnmspe.hxx>
25 : #include <xmloff/nmspmap.hxx>
26 : #include "xmlstrings.hrc"
27 : #include <com/sun/star/beans/XPropertySet.hpp>
28 : #include <xmloff/xmlimp.hxx>
29 : #include "xmlfilter.hxx"
30 : #include <tools/debug.hxx>
31 :
32 : namespace dbaxml
33 : {
34 : using namespace ::xmloff::token;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::beans;
37 : using namespace ::com::sun::star::xml::sax;
38 :
39 32 : OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& _sLocalName )
40 32 : :SvXMLImportContext( rImport, nPrfx, _sLocalName )
41 : {
42 :
43 32 : }
44 :
45 64 : OXMLTableFilterList::~OXMLTableFilterList()
46 : {
47 64 : }
48 :
49 32 : SvXMLImportContext* OXMLTableFilterList::CreateChildContext(
50 : sal_uInt16 nPrefix,
51 : const OUString& rLocalName,
52 : const Reference< XAttributeList > & /*xAttrList*/ )
53 : {
54 32 : SvXMLImportContext *pContext = 0;
55 :
56 32 : if ( XML_NAMESPACE_DB == nPrefix )
57 : {
58 32 : GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
59 32 : if ( IsXMLToken( rLocalName, XML_TABLE_FILTER_PATTERN ) )
60 16 : pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,true,*this);
61 16 : else if ( IsXMLToken( rLocalName, XML_TABLE_TYPE ) )
62 0 : pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,false,*this);
63 16 : else if ( IsXMLToken( rLocalName, XML_TABLE_INCLUDE_FILTER ) )
64 16 : pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName );
65 : }
66 :
67 32 : if( !pContext )
68 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
69 :
70 32 : return pContext;
71 : }
72 :
73 32 : ODBFilter& OXMLTableFilterList::GetOwnImport()
74 : {
75 32 : return static_cast<ODBFilter&>(GetImport());
76 : }
77 :
78 32 : void OXMLTableFilterList::EndElement()
79 : {
80 32 : Reference<XPropertySet> xDataSource(GetOwnImport().getDataSource());
81 32 : if ( xDataSource.is() )
82 : {
83 32 : if ( !m_aPatterns.empty() )
84 16 : xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(Sequence< OUString>(&(*m_aPatterns.begin()),m_aPatterns.size())));
85 32 : if ( !m_aTypes.empty() )
86 0 : xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,makeAny(Sequence< OUString>(&(*m_aTypes.begin()),m_aTypes.size())));
87 32 : }
88 32 : }
89 :
90 : } // namespace dbaxml
91 :
92 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|