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 : DBG_NAME(OXMLTableFilterList)
39 :
40 0 : OXMLTableFilterList::OXMLTableFilterList( SvXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName )
41 0 : :SvXMLImportContext( rImport, nPrfx, _sLocalName )
42 : {
43 : DBG_CTOR(OXMLTableFilterList,NULL);
44 :
45 0 : }
46 : // -----------------------------------------------------------------------------
47 :
48 0 : OXMLTableFilterList::~OXMLTableFilterList()
49 : {
50 : DBG_DTOR(OXMLTableFilterList,NULL);
51 0 : }
52 : // -----------------------------------------------------------------------------
53 :
54 0 : SvXMLImportContext* OXMLTableFilterList::CreateChildContext(
55 : sal_uInt16 nPrefix,
56 : const ::rtl::OUString& rLocalName,
57 : const Reference< XAttributeList > & /*xAttrList*/ )
58 : {
59 0 : SvXMLImportContext *pContext = 0;
60 :
61 0 : if ( XML_NAMESPACE_DB == nPrefix )
62 : {
63 0 : GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
64 0 : if ( IsXMLToken( rLocalName, XML_TABLE_FILTER_PATTERN ) )
65 0 : pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_True,*this);
66 0 : else if ( IsXMLToken( rLocalName, XML_TABLE_TYPE ) )
67 0 : pContext = new OXMLTableFilterPattern( GetImport(), nPrefix, rLocalName,sal_False,*this);
68 0 : else if ( IsXMLToken( rLocalName, XML_TABLE_INCLUDE_FILTER ) )
69 0 : pContext = new OXMLTableFilterList( GetImport(), nPrefix, rLocalName );
70 : }
71 :
72 0 : if( !pContext )
73 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
74 :
75 0 : return pContext;
76 : }
77 : // -----------------------------------------------------------------------------
78 0 : ODBFilter& OXMLTableFilterList::GetOwnImport()
79 : {
80 0 : return static_cast<ODBFilter&>(GetImport());
81 : }
82 :
83 : // -----------------------------------------------------------------------------
84 0 : void OXMLTableFilterList::EndElement()
85 : {
86 0 : Reference<XPropertySet> xDataSource(GetOwnImport().getDataSource());
87 0 : if ( xDataSource.is() )
88 : {
89 0 : if ( !m_aPatterns.empty() )
90 0 : xDataSource->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aPatterns.begin()),m_aPatterns.size())));
91 0 : if ( !m_aTypes.empty() )
92 0 : xDataSource->setPropertyValue(PROPERTY_TABLETYPEFILTER,makeAny(Sequence< ::rtl::OUString>(&(*m_aTypes.begin()),m_aTypes.size())));
93 0 : }
94 0 : }
95 : //----------------------------------------------------------------------------
96 : } // namespace dbaxml
97 : // -----------------------------------------------------------------------------
98 :
99 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|