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>
25 #include <sal/log.hxx>
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::xml::sax
;
32 OXMLDataSourceInfo::OXMLDataSourceInfo( ODBFilter
& rImport
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
;
52 case XML_ROW_RETRIEVING_STATEMENT
:
53 aProperty
.Name
= INFO_AUTORETRIEVEVALUE
;
57 aProperty
.Name
= INFO_TEXTDELIMITER
;
60 aProperty
.Name
= INFO_FIELDDELIMITER
;
64 aProperty
.Name
= INFO_DECIMALDELIMITER
;
67 aProperty
.Name
= INFO_THOUSANDSDELIMITER
;
68 bFoundThousand
= true;
71 aProperty
.Name
= INFO_CHARSET
;
75 XMLOFF_WARN_UNKNOWN("dbaccess", aIter
);
77 if ( !aProperty
.Name
.isEmpty() )
79 aProperty
.Value
<<= sValue
;
80 rImport
.addInfo(aProperty
);
85 aProperty
.Name
= INFO_AUTORETRIEVEENABLED
;
86 aProperty
.Value
<<= true;
87 rImport
.addInfo(aProperty
);
89 if ( !rImport
.isNewFormat() )
92 if ( (nElement
& TOKEN_MASK
) == XML_DELIMITER
)
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: */