LibreOffice Module dbaccess (master) 1
xmlQuery.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 "xmlQuery.hxx"
21#include "xmlfilter.hxx"
22#include <xmloff/xmltoken.hxx>
24#include "xmlEnums.hxx"
25#include <strings.hxx>
27
28namespace dbaxml
29{
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::beans;
32 using namespace ::com::sun::star::container;
33 using namespace ::com::sun::star::xml::sax;
34
35
37 ,const Reference< XFastAttributeList > & _xAttrList
38 ,const css::uno::Reference< css::container::XNameAccess >& _xParentContainer
39 ) :
40 OXMLTable( rImport, _xAttrList,_xParentContainer, "com.sun.star.sdb.CommandDefinition" )
41 ,m_bEscapeProcessing(true)
42{
43 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
44 {
45 switch( aIter.getToken() & TOKEN_MASK )
46 {
47 case XML_COMMAND:
48 m_sCommand = aIter.toString();
49 break;
51 m_bEscapeProcessing = aIter.toView() == "true";
52 break;
53 default:
54 XMLOFF_WARN_UNKNOWN("dbaccess", aIter);
55 }
56 }
57}
58
60{
61
62}
63
64css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLQuery::createFastChildContext(
65 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
66{
67 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext = OXMLTable::createFastChildContext(nElement,xAttrList );
68 if (!xContext)
69 {
70 switch( nElement & TOKEN_MASK )
71 {
73 {
74 GetOwnImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
75 OUString s1;
77 break;
78 }
79 }
80 }
81
82 return xContext;
83}
84
85void OXMLQuery::setProperties(Reference< XPropertySet > & _xProp )
86{
87 try
88 {
89 if ( _xProp.is() )
90 {
92
93 _xProp->setPropertyValue(PROPERTY_COMMAND,Any(m_sCommand));
94 _xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,Any(m_bEscapeProcessing));
95
96 if ( !m_sTable.isEmpty() )
97 _xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,Any(m_sTable));
98 if ( !m_sCatalog.isEmpty() )
99 _xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,Any(m_sCatalog));
100 if ( !m_sSchema.isEmpty() )
101 _xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,Any(m_sSchema));
102
104 ODBFilter::TPropertyNameMap::const_iterator aFind = rSettings.find(m_sName);
105 if ( aFind != rSettings.end() )
106 _xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,Any(aFind->second));
107 }
108 }
109 catch(Exception&)
110 {
111 TOOLS_WARN_EXCEPTION( "dbaccess", "OXMLTable::EndElement");
112 }
113}
114
115} // namespace dbaxml
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const TPropertyNameMap & getQuerySettings() const
Definition: xmlfilter.hxx:99
std::map< OUString, Sequence< PropertyValue > > TPropertyNameMap
Definition: xmlfilter.hxx:51
bool m_bEscapeProcessing
Definition: xmlQuery.hxx:30
OUString m_sCommand
Definition: xmlQuery.hxx:28
virtual ~OXMLQuery() override
Definition: xmlQuery.cxx:59
virtual void setProperties(css::uno::Reference< css::beans::XPropertySet > &_xProp) override
Definition: xmlQuery.cxx:85
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: xmlQuery.cxx:64
OUString m_sTable
Definition: xmlQuery.hxx:29
OXMLQuery(ODBFilter &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const css::uno::Reference< css::container::XNameAccess > &_xParentContainer)
Definition: xmlQuery.cxx:36
OUString m_sCatalog
Definition: xmlTable.hxx:37
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: xmlTable.cxx:95
static void fillAttributes(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, OUString &_rsCommand, OUString &_rsTableName, OUString &_rsTableSchema, OUString &_rsTableCatalog)
Definition: xmlTable.cxx:194
OUString m_sName
Definition: xmlTable.hxx:35
OUString m_sSchema
Definition: xmlTable.hxx:36
ODBFilter & GetOwnImport()
Definition: xmlTable.cxx:134
virtual void setProperties(css::uno::Reference< css::beans::XPropertySet > &_xProp)
Definition: xmlTable.cxx:139
#define TOOLS_WARN_EXCEPTION(area, stream)
@ Exception
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_COMMAND
XML_ESCAPE_PROCESSING
XML_UPDATE_TABLE
constexpr OUStringLiteral PROPERTY_COMMAND(u"Command")
constexpr OUStringLiteral PROPERTY_UPDATE_TABLENAME(u"UpdateTableName")
constexpr OUStringLiteral PROPERTY_UPDATE_SCHEMANAME(u"UpdateSchemaName")
constexpr OUStringLiteral PROPERTY_ESCAPE_PROCESSING(u"EscapeProcessing")
constexpr OUStringLiteral PROPERTY_UPDATE_CATALOGNAME(u"UpdateCatalogName")
constexpr OUStringLiteral PROPERTY_LAYOUTINFORMATION(u"LayoutInformation")
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:21
#define XMLOFF_WARN_UNKNOWN(area, rIter)
constexpr sal_Int32 TOKEN_MASK