Branch data 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 "xmlConnectionResource.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 <tools/debug.hxx>
28 : : #include <tools/diagnose_ex.h>
29 : :
30 : : namespace dbaxml
31 : : {
32 : : using namespace ::com::sun::star::uno;
33 : : using namespace ::com::sun::star::xml::sax;
34 : : DBG_NAME(OXMLConnectionResource)
35 : :
36 : 0 : OXMLConnectionResource::OXMLConnectionResource( ODBFilter& rImport,
37 : : sal_uInt16 nPrfx, const ::rtl::OUString& _sLocalName,
38 : : const Reference< XAttributeList > & _xAttrList) :
39 : 0 : SvXMLImportContext( rImport, nPrfx, _sLocalName )
40 : : {
41 : : DBG_CTOR(OXMLConnectionResource,NULL);
42 : :
43 : : OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
44 : 0 : const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
45 [ # # ]: 0 : const SvXMLTokenMap& rTokenMap = rImport.GetComponentElemTokenMap();
46 : :
47 [ # # ]: 0 : Reference<XPropertySet> xDataSource = rImport.getDataSource();
48 : :
49 : 0 : PropertyValue aProperty;
50 : :
51 [ # # ][ # # ]: 0 : const sal_Int16 nLength = (xDataSource.is() && _xAttrList.is()) ? _xAttrList->getLength() : 0;
[ # # ][ # # ]
52 [ # # ]: 0 : for(sal_Int16 i = 0; i < nLength; ++i)
53 : : {
54 : 0 : ::rtl::OUString sLocalName;
55 [ # # ][ # # ]: 0 : const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
56 [ # # ]: 0 : const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
57 [ # # ][ # # ]: 0 : const rtl::OUString sValue = _xAttrList->getValueByIndex( i );
58 : :
59 : 0 : aProperty.Name = ::rtl::OUString();
60 : 0 : aProperty.Value = Any();
61 : :
62 [ # # # # : 0 : switch( rTokenMap.Get( nPrefix, sLocalName ) )
# ][ # # ]
63 : : {
64 : : case XML_TOK_HREF:
65 : : try
66 : : {
67 [ # # ][ # # ]: 0 : xDataSource->setPropertyValue(PROPERTY_URL,makeAny(sValue));
[ # # ][ # # ]
[ # # ]
68 : : }
69 [ # # ]: 0 : catch(const Exception&)
70 : : {
71 : : DBG_UNHANDLED_EXCEPTION();
72 : : }
73 : 0 : break;
74 : : case XML_TOK_TYPE:
75 [ # # ]: 0 : aProperty.Name = PROPERTY_TYPE;
76 : 0 : break;
77 : : case XML_TOK_SHOW:
78 [ # # ]: 0 : aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Show"));
79 : 0 : break;
80 : : case XML_TOK_ACTUATE:
81 [ # # ]: 0 : aProperty.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Actuate"));
82 : 0 : break;
83 : : }
84 [ # # ]: 0 : if ( !aProperty.Name.isEmpty() )
85 : : {
86 [ # # ]: 0 : if ( !aProperty.Value.hasValue() )
87 [ # # ]: 0 : aProperty.Value <<= sValue;
88 [ # # ]: 0 : rImport.addInfo(aProperty);
89 : : }
90 : 0 : }
91 : 0 : }
92 : : // -----------------------------------------------------------------------------
93 : :
94 : 0 : OXMLConnectionResource::~OXMLConnectionResource()
95 : : {
96 : :
97 : : DBG_DTOR(OXMLConnectionResource,NULL);
98 [ # # ]: 0 : }
99 : : // -----------------------------------------------------------------------------
100 : : //----------------------------------------------------------------------------
101 : : } // namespace dbaxml
102 : : // -----------------------------------------------------------------------------
103 : :
104 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|