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 "xmlfilter.hxx"
22 #include <xmloff/xmltoken.hxx>
23 #include <strings.hxx>
24 #include <com/sun/star/beans/PropertyValue.hpp>
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star::xml::sax
;
31 OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter
& rImport
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
;
49 case XML_ROW_RETRIEVING_STATEMENT
:
50 aProperty
.Name
= INFO_AUTORETRIEVEVALUE
;
54 aProperty
.Name
= INFO_TEXTDELIMITER
;
57 aProperty
.Name
= INFO_FIELDDELIMITER
;
61 aProperty
.Name
= INFO_DECIMALDELIMITER
;
64 aProperty
.Name
= INFO_THOUSANDSDELIMITER
;
65 bFoundThousand
= true;
68 aProperty
.Name
= INFO_CHARSET
;
72 XMLOFF_WARN_UNKNOWN("dbaccess", aIter
);
74 if ( !aProperty
.Name
.isEmpty() )
76 aProperty
.Value
<<= aIter
.toString();
77 rImport
.addInfo(aProperty
);
82 aProperty
.Name
= INFO_AUTORETRIEVEENABLED
;
83 aProperty
.Value
<<= true;
84 rImport
.addInfo(aProperty
);
86 if ( !rImport
.isNewFormat() )
89 if ( (nElement
& TOKEN_MASK
) == XML_DELIMITER
)
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: */