tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / dbaccess / source / filter / xml / xmlDataSourceInfo.cxx
blobc1400970181a9275d8fe7296d58dbf1bd10d7375
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>
26 namespace dbaxml
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::xml::sax;
31 OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter& rImport
32 ,sal_Int32 nElement
33 ,const Reference< XFastAttributeList > & _xAttrList) :
34 SvXMLImportContext( rImport )
36 PropertyValue aProperty;
37 bool bAutoEnabled = false;
38 bool bFoundField = false,bFoundThousand = false, bFoundCharset = false;
39 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
41 aProperty.Name.clear();
43 switch( aIter.getToken() & TOKEN_MASK )
45 case XML_ADDITIONAL_COLUMN_STATEMENT:
46 aProperty.Name = PROPERTY_AUTOINCREMENTCREATION;
47 bAutoEnabled = true;
48 break;
49 case XML_ROW_RETRIEVING_STATEMENT:
50 aProperty.Name = INFO_AUTORETRIEVEVALUE;
51 bAutoEnabled = true;
52 break;
53 case XML_STRING:
54 aProperty.Name = INFO_TEXTDELIMITER;
55 break;
56 case XML_FIELD:
57 aProperty.Name = INFO_FIELDDELIMITER;
58 bFoundField = true;
59 break;
60 case XML_DECIMAL:
61 aProperty.Name = INFO_DECIMALDELIMITER;
62 break;
63 case XML_THOUSAND:
64 aProperty.Name = INFO_THOUSANDSDELIMITER;
65 bFoundThousand = true;
66 break;
67 case XML_ENCODING:
68 aProperty.Name = INFO_CHARSET;
69 bFoundCharset = true;
70 break;
71 default:
72 XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
74 if ( !aProperty.Name.isEmpty() )
76 aProperty.Value <<= aIter.toString();
77 rImport.addInfo(aProperty);
80 if ( bAutoEnabled )
82 aProperty.Name = INFO_AUTORETRIEVEENABLED;
83 aProperty.Value <<= true;
84 rImport.addInfo(aProperty);
86 if ( !rImport.isNewFormat() )
87 return;
89 if ( (nElement & TOKEN_MASK) == XML_DELIMITER )
91 if ( !bFoundField )
93 aProperty.Name = INFO_FIELDDELIMITER;
94 aProperty.Value <<= u";"_ustr;
95 rImport.addInfo(aProperty);
97 if ( !bFoundThousand )
99 aProperty.Name = INFO_THOUSANDSDELIMITER;
100 aProperty.Value <<= u","_ustr;
101 rImport.addInfo(aProperty);
104 if ( (nElement & TOKEN_MASK) == XML_FONT_CHARSET && !bFoundCharset )
106 aProperty.Name = INFO_CHARSET;
107 aProperty.Value <<= u"utf8"_ustr;
108 rImport.addInfo(aProperty);
112 OXMLDataSourceInfo::~OXMLDataSourceInfo()
117 } // namespace dbaxml
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */