1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "xmlDataSourceInfo.hxx"
21 #include "xmlDataSource.hxx"
22 #include "xmlfilter.hxx"
23 #include <xmloff/xmltoken.hxx>
24 #include <xmloff/xmlnmspe.hxx>
25 #include <xmloff/nmspmap.hxx>
26 #include "xmlEnums.hxx"
27 #include <stringconstants.hxx>
28 #include <strings.hxx>
29 #include <com/sun/star/beans/PropertyValue.hpp>
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::xml::sax
;
37 OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter
& rImport
39 ,const OUString
& _sLocalName
40 ,const Reference
< XAttributeList
> & _xAttrList
41 ,const sal_uInt16 _nToken
) :
42 SvXMLImportContext( rImport
, nPrfx
, _sLocalName
)
45 OSL_ENSURE(_xAttrList
.is(),"Attribute list is NULL!");
46 const SvXMLNamespaceMap
& rMap
= rImport
.GetNamespaceMap();
47 const SvXMLTokenMap
& rTokenMap
= rImport
.GetDataSourceInfoElemTokenMap();
49 PropertyValue aProperty
;
50 sal_Int16 nLength
= (_xAttrList
.is()) ? _xAttrList
->getLength() : 0;
51 bool bAutoEnabled
= false;
52 bool bFoundField
= false,bFoundThousand
= false, bFoundCharset
= false;
53 for(sal_Int16 i
= 0; i
< nLength
; ++i
)
56 OUString sAttrName
= _xAttrList
->getNameByIndex( i
);
57 sal_uInt16 nPrefix
= rMap
.GetKeyByAttrName( sAttrName
,&sLocalName
);
58 OUString sValue
= _xAttrList
->getValueByIndex( i
);
60 aProperty
.Name
.clear();
62 sal_uInt16 nToken
= rTokenMap
.Get( nPrefix
, sLocalName
);
65 case XML_TOK_ADDITIONAL_COLUMN_STATEMENT
:
66 aProperty
.Name
= PROPERTY_AUTOINCREMENTCREATION
;
69 case XML_TOK_ROW_RETRIEVING_STATEMENT
:
70 aProperty
.Name
= INFO_AUTORETRIEVEVALUE
;
74 aProperty
.Name
= INFO_TEXTDELIMITER
;
77 aProperty
.Name
= INFO_FIELDDELIMITER
;
81 aProperty
.Name
= INFO_DECIMALDELIMITER
;
83 case XML_TOK_THOUSAND
:
84 aProperty
.Name
= INFO_THOUSANDSDELIMITER
;
85 bFoundThousand
= true;
87 case XML_TOK_ENCODING
:
88 aProperty
.Name
= INFO_CHARSET
;
92 if ( !aProperty
.Name
.isEmpty() )
94 aProperty
.Value
<<= sValue
;
95 rImport
.addInfo(aProperty
);
100 aProperty
.Name
= INFO_AUTORETRIEVEENABLED
;
101 aProperty
.Value
<<= true;
102 rImport
.addInfo(aProperty
);
104 if ( rImport
.isNewFormat() )
106 if ( XML_TOK_DELIMITER
== _nToken
)
110 aProperty
.Name
= INFO_FIELDDELIMITER
;
111 aProperty
.Value
<<= OUString(";");
112 rImport
.addInfo(aProperty
);
114 if ( !bFoundThousand
)
116 aProperty
.Name
= INFO_THOUSANDSDELIMITER
;
117 aProperty
.Value
<<= OUString(",");
118 rImport
.addInfo(aProperty
);
121 if ( XML_TOK_FONT_CHARSET
== _nToken
&& !bFoundCharset
)
123 aProperty
.Name
= INFO_CHARSET
;
124 aProperty
.Value
<<= OUString("utf8");
125 rImport
.addInfo(aProperty
);
130 OXMLDataSourceInfo::~OXMLDataSourceInfo()
135 } // namespace dbaxml
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */