bump product version to 5.0.4.1
[LibreOffice.git] / dbaccess / source / filter / xml / xmlQuery.cxx
blobff1d3ad5017606509f505d1dd5f1aee59b28875f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "xmlQuery.hxx"
21 #include "xmlfilter.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include <xmloff/xmlnmspe.hxx>
24 #include <xmloff/nmspmap.hxx>
25 #include "xmlEnums.hxx"
26 #include "xmlstrings.hrc"
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <tools/debug.hxx>
32 namespace dbaxml
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::beans;
36 using namespace ::com::sun::star::container;
37 using namespace ::com::sun::star::xml::sax;
40 OXMLQuery::OXMLQuery( ODBFilter& rImport
41 ,sal_uInt16 nPrfx
42 ,const OUString& _sLocalName
43 ,const Reference< XAttributeList > & _xAttrList
44 ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xParentContainer
45 ) :
46 OXMLTable( rImport, nPrfx, _sLocalName,_xAttrList,_xParentContainer, "com.sun.star.sdb.CommandDefinition" )
47 ,m_bEscapeProcessing(true)
50 OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
51 const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
52 const SvXMLTokenMap& rTokenMap = rImport.GetQueryElemTokenMap();
54 sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
55 for(sal_Int16 i = 0; i < nLength; ++i)
57 OUString sLocalName;
58 OUString sAttrName = _xAttrList->getNameByIndex( i );
59 sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
60 OUString sValue = _xAttrList->getValueByIndex( i );
62 switch( rTokenMap.Get( nPrefix, sLocalName ) )
64 case XML_TOK_COMMAND:
65 m_sCommand = sValue;
66 break;
67 case XML_TOK_ESCAPE_PROCESSING:
68 m_bEscapeProcessing = sValue == "true";
69 break;
74 OXMLQuery::~OXMLQuery()
79 SvXMLImportContext* OXMLQuery::CreateChildContext(
80 sal_uInt16 nPrefix,
81 const OUString& rLocalName,
82 const Reference< XAttributeList > & xAttrList )
84 SvXMLImportContext* pContext = OXMLTable::CreateChildContext(nPrefix, rLocalName,xAttrList );
85 if ( !pContext )
87 const SvXMLTokenMap& rTokenMap = GetOwnImport().GetQueryElemTokenMap();
89 switch( rTokenMap.Get( nPrefix, rLocalName ) )
91 case XML_TOK_UPDATE_TABLE:
93 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
94 OUString s1;
95 fillAttributes(nPrefix, rLocalName,xAttrList,s1,m_sTable,m_sSchema,m_sCatalog);
97 break;
101 if( !pContext )
102 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
104 return pContext;
107 void OXMLQuery::setProperties(Reference< XPropertySet > & _xProp )
111 if ( _xProp.is() )
113 OXMLTable::setProperties(_xProp);
115 _xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(m_sCommand));
116 _xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,makeAny(m_bEscapeProcessing));
118 if ( !m_sTable.isEmpty() )
119 _xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(m_sTable));
120 if ( !m_sCatalog.isEmpty() )
121 _xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(m_sCatalog));
122 if ( !m_sSchema.isEmpty() )
123 _xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(m_sSchema));
125 const ODBFilter::TPropertyNameMap& rSettings = GetOwnImport().getQuerySettings();
126 ODBFilter::TPropertyNameMap::const_iterator aFind = rSettings.find(m_sName);
127 if ( aFind != rSettings.end() )
128 _xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aFind->second));
131 catch(Exception&)
133 OSL_FAIL("OXMLTable::EndElement -> exception catched");
137 } // namespace dbaxml
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */