Update ooo320-m1
[ooovba.git] / dbaccess / source / filter / xml / xmlConnectionResource.cxx
blobdbf5c58be663c4e9a935a1cd1e7dcba959d7c147
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlConnectionResource.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBA_XMLCONNECTIONRESOURCE_HXX_INCLUDED
34 #include "xmlConnectionResource.hxx"
35 #endif
36 #ifndef DBA_XMLFILTER_HXX
37 #include "xmlfilter.hxx"
38 #endif
39 #ifndef _XMLOFF_XMLTOKEN_HXX
40 #include <xmloff/xmltoken.hxx>
41 #endif
42 #ifndef _XMLOFF_XMLNMSPE_HXX
43 #include <xmloff/xmlnmspe.hxx>
44 #endif
45 #ifndef _XMLOFF_NMSPMAP_HXX
46 #include <xmloff/nmspmap.hxx>
47 #endif
48 #ifndef DBA_XMLENUMS_HXX
49 #include "xmlEnums.hxx"
50 #endif
51 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
52 #include "xmlstrings.hrc"
53 #endif
54 #ifndef _TOOLS_DEBUG_HXX
55 #include <tools/debug.hxx>
56 #endif
57 #ifndef TOOLS_DIAGNOSE_EX_H
58 #include <tools/diagnose_ex.h>
59 #endif
61 namespace dbaxml
63 using namespace ::com::sun::star::uno;
64 using namespace ::com::sun::star::xml::sax;
65 DBG_NAME(OXMLConnectionResource)
67 OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
68 sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
69 const Reference< XAttributeList > & _xAttrList) :
70 SvXMLImportContext( rImport, nPrfx, _sLocalName )
72 DBG_CTOR(OXMLConnectionResource,NULL);
74 OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
75 const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
76 const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap();
78 Reference<XPropertySet> xDataSource = rImport.getDataSource();
80 PropertyValue aProperty;
82 const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
83 for(sal_Int16 i = 0; i < nLength; ++i)
85 ::rtl::OUString sLocalName;
86 const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
87 const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
88 const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
90 aProperty.Name = ::rtl::OUString();
91 aProperty.Value = Any();
93 switch( rTokenMap.Get( nPrefix, sLocalName ) )
95 case XML_TOK_HREF:
96 try
98 xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
100 catch(Exception)
102 DBG_UNHANDLED_EXCEPTION();
104 break;
105 case XML_TOK_TYPE:
106 aProperty.Name = PROPERTY_TYPE;
107 break;
108 case XML_TOK_SHOW:
109 aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Show"));
110 break;
111 case XML_TOK_ACTUATE:
112 aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Actuate"));
113 break;
115 if ( aProperty.Name.getLength() )
117 if ( !aProperty.Value.hasValue() )
118 aProperty.Value <<= sValue;
119 rImport.addInfo(aProperty);
123 // -----------------------------------------------------------------------------
125 OXMLConnectionResource::~OXMLConnectionResource()
128 DBG_DTOR(OXMLConnectionResource,NULL);
130 // -----------------------------------------------------------------------------
131 //----------------------------------------------------------------------------
132 } // namespace dbaxml
133 // -----------------------------------------------------------------------------