LibreOffice Module dbaccess (master) 1
xmlDataSourceInfo.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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
26namespace dbaxml
27{
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::xml::sax;
30
32 ,sal_Int32 nElement
33 ,const Reference< XFastAttributeList > & _xAttrList) :
34 SvXMLImportContext( rImport )
35{
36 PropertyValue aProperty;
37 bool bAutoEnabled = false;
38 bool bFoundField = false,bFoundThousand = false, bFoundCharset = false;
39 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
40 {
41 aProperty.Name.clear();
42
43 switch( aIter.getToken() & TOKEN_MASK )
44 {
46 aProperty.Name = PROPERTY_AUTOINCREMENTCREATION;
47 bAutoEnabled = true;
48 break;
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);
73 }
74 if ( !aProperty.Name.isEmpty() )
75 {
76 aProperty.Value <<= aIter.toString();
77 rImport.addInfo(aProperty);
78 }
79 }
80 if ( bAutoEnabled )
81 {
82 aProperty.Name = INFO_AUTORETRIEVEENABLED;
83 aProperty.Value <<= true;
84 rImport.addInfo(aProperty);
85 }
86 if ( !rImport.isNewFormat() )
87 return;
88
89 if ( (nElement & TOKEN_MASK) == XML_DELIMITER )
90 {
91 if ( !bFoundField )
92 {
93 aProperty.Name = INFO_FIELDDELIMITER;
94 aProperty.Value <<= OUString(";");
95 rImport.addInfo(aProperty);
96 }
97 if ( !bFoundThousand )
98 {
99 aProperty.Name = INFO_THOUSANDSDELIMITER;
100 aProperty.Value <<= OUString(",");
101 rImport.addInfo(aProperty);
102 }
103 }
104 if ( (nElement & TOKEN_MASK) == XML_FONT_CHARSET && !bFoundCharset )
105 {
106 aProperty.Name = INFO_CHARSET;
107 aProperty.Value <<= OUString("utf8");
108 rImport.addInfo(aProperty);
109 }
110}
111
113{
114
115}
116
117} // namespace dbaxml
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool isNewFormat() const
Definition: xmlfilter.hxx:115
void addInfo(const css::beans::PropertyValue &_rInfo)
add an Info to the sequence which will be appended to the data source
Definition: xmlfilter.hxx:108
virtual ~OXMLDataSourceInfo() override
OXMLDataSourceInfo(ODBFilter &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &_xAttrList)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_ROW_RETRIEVING_STATEMENT
XML_DELIMITER
XML_DECIMAL
XML_ENCODING
XML_THOUSAND
XML_STRING
XML_ADDITIONAL_COLUMN_STATEMENT
XML_FONT_CHARSET
XML_FIELD
constexpr OUStringLiteral INFO_AUTORETRIEVEVALUE
Definition: strings.hxx:217
constexpr OUStringLiteral INFO_DECIMALDELIMITER
Definition: strings.hxx:212
constexpr OUStringLiteral INFO_TEXTDELIMITER
Definition: strings.hxx:211
constexpr OUStringLiteral INFO_AUTORETRIEVEENABLED
Definition: strings.hxx:218
constexpr OUStringLiteral INFO_CHARSET
Definition: strings.hxx:208
constexpr OUStringLiteral INFO_FIELDDELIMITER
Definition: strings.hxx:210
constexpr OUStringLiteral INFO_THOUSANDSDELIMITER
Definition: strings.hxx:213
constexpr OUStringLiteral PROPERTY_AUTOINCREMENTCREATION(u"AutoIncrementCreation")
#define XMLOFF_WARN_UNKNOWN(area, rIter)
constexpr sal_Int32 TOKEN_MASK