nss: upgrade to release 3.73
[LibreOffice.git] / dbaccess / source / filter / xml / xmlDataSourceInfo.cxx
blobec1a42d6e9afdbbc2cb6b96ca614518664d678e1
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 "xmlDataSourceInfo.hxx"
21 #include "xmlfilter.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include <strings.hxx>
24 #include <com/sun/star/beans/PropertyValue.hpp>
25 #include <sal/log.hxx>
27 namespace dbaxml
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::xml::sax;
32 OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport
33 ,sal_Int32 nElement
34 ,const Reference< XFastAttributeList > & _xAttrList) :
35 SvXMLImportContext( rImport )
37 PropertyValue aProperty;
38 bool bAutoEnabled = false;
39 bool bFoundField = false,bFoundThousand = false, bFoundCharset = false;
40 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
42 OUString sValue = aIter.toString();
44 aProperty.Name.clear();
46 switch( aIter.getToken() & TOKEN_MASK )
48 case XML_ADDITIONAL_COLUMN_STATEMENT:
49 aProperty.Name = PROPERTY_AUTOINCREMENTCREATION;
50 bAutoEnabled = true;
51 break;
52 case XML_ROW_RETRIEVING_STATEMENT:
53 aProperty.Name = INFO_AUTORETRIEVEVALUE;
54 bAutoEnabled = true;
55 break;
56 case XML_STRING:
57 aProperty.Name = INFO_TEXTDELIMITER;
58 break;
59 case XML_FIELD:
60 aProperty.Name = INFO_FIELDDELIMITER;
61 bFoundField = true;
62 break;
63 case XML_DECIMAL:
64 aProperty.Name = INFO_DECIMALDELIMITER;
65 break;
66 case XML_THOUSAND:
67 aProperty.Name = INFO_THOUSANDSDELIMITER;
68 bFoundThousand = true;
69 break;
70 case XML_ENCODING:
71 aProperty.Name = INFO_CHARSET;
72 bFoundCharset = true;
73 break;
74 default:
75 XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
77 if ( !aProperty.Name.isEmpty() )
79 aProperty.Value <<= sValue;
80 rImport.addInfo(aProperty);
83 if ( bAutoEnabled )
85 aProperty.Name = INFO_AUTORETRIEVEENABLED;
86 aProperty.Value <<= true;
87 rImport.addInfo(aProperty);
89 if ( !rImport.isNewFormat() )
90 return;
92 if ( (nElement & TOKEN_MASK) == XML_DELIMITER )
94 if ( !bFoundField )
96 aProperty.Name = INFO_FIELDDELIMITER;
97 aProperty.Value <<= OUString(";");
98 rImport.addInfo(aProperty);
100 if ( !bFoundThousand )
102 aProperty.Name = INFO_THOUSANDSDELIMITER;
103 aProperty.Value <<= OUString(",");
104 rImport.addInfo(aProperty);
107 if ( (nElement & TOKEN_MASK) == XML_FONT_CHARSET && !bFoundCharset )
109 aProperty.Name = INFO_CHARSET;
110 aProperty.Value <<= OUString("utf8");
111 rImport.addInfo(aProperty);
115 OXMLDataSourceInfo::~OXMLDataSourceInfo()
120 } // namespace dbaxml
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */