Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / dbaccess / source / filter / xml / xmlfilter.hxx
blob5db692434af9ae681d396183799ef953074335d8
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 #ifndef INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLFILTER_HXX
21 #define INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLFILTER_HXX
23 #include <com/sun/star/container/XNamed.hpp>
24 #include <com/sun/star/document/XFilter.hpp>
25 #include <com/sun/star/document/XImporter.hpp>
26 #include <com/sun/star/document/XExporter.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/lang/XComponent.hpp>
31 #include <cppuhelper/implbase1.hxx>
32 #include <cppuhelper/implbase5.hxx>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/io/XActiveDataSource.hpp>
35 #include <osl/diagnose.h>
36 #include <unotools/tempfile.hxx>
37 #include <unotools/localfilehelper.hxx>
38 #include <unotools/ucbstreamhelper.hxx>
39 #include <xmloff/xmlimp.hxx>
41 #include <map>
42 #include <memory>
45 namespace dbaxml
48 using namespace ::xmloff::token;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::container;
51 using namespace ::com::sun::star::lang;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::document;
54 using namespace ::com::sun::star::text;
55 using namespace ::com::sun::star::io;
56 using namespace ::com::sun::star::xml::sax;
59 class ODBFilter : public SvXMLImport
61 public:
62 typedef std::map< OUString, Sequence<PropertyValue> > TPropertyNameMap;
63 typedef ::std::vector< css::beans::PropertyValue> TInfoSequence;
64 private:
65 TPropertyNameMap m_aQuerySettings;
66 TPropertyNameMap m_aTablesSettings;
67 TInfoSequence m_aInfoSequence;
69 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
70 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap;
71 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap;
72 mutable ::std::unique_ptr<SvXMLTokenMap> m_pLoginElemTokenMap;
73 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap;
74 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap;
75 mutable ::std::unique_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap;
76 mutable ::std::unique_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
77 mutable ::std::unique_ptr<SvXMLTokenMap> m_pQueryElemTokenMap;
78 mutable ::std::unique_ptr<SvXMLTokenMap> m_pColumnElemTokenMap;
80 mutable rtl::Reference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
81 mutable rtl::Reference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
82 mutable rtl::Reference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
83 Reference<XPropertySet> m_xDataSource;
84 bool m_bNewFormat;
86 bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException, std::exception);
88 /** fills the map with the Properties
89 @param _rValue
90 The Any where the sequence resists in.
91 @param _rMap
92 The map to fill.
94 static void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap);
96 SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const OUString& rLocalName,
97 const Reference< XAttributeList>& xAttrList, bool bIsAutoStyle );
98 SvXMLImportContext* CreateScriptContext( const OUString& rLocalName );
100 protected:
101 // SvXMLImport
102 virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
103 const OUString& rLocalName,
104 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList ) override;
106 virtual ~ODBFilter() throw();
107 public:
109 explicit ODBFilter( const Reference< XComponentContext >& _rxContext );
111 // XFilter
112 virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException, std::exception) override;
114 static OUString SAL_CALL getImplementationName_Static()
115 throw (css::uno::RuntimeException);
117 static css::uno::Sequence<OUString> SAL_CALL
118 getSupportedServiceNames_Static() throw (css::uno::RuntimeException);
120 static css::uno::Reference<css::uno::XInterface> SAL_CALL Create(
121 css::uno::Reference<css::lang::XMultiServiceFactory> const & _rxORB);
123 // helper class
124 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
125 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
127 const Reference<XPropertySet>& getDataSource() const { return m_xDataSource; }
129 inline const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;}
131 const SvXMLTokenMap& GetDocElemTokenMap() const;
132 const SvXMLTokenMap& GetDatabaseElemTokenMap() const;
133 const SvXMLTokenMap& GetDataSourceElemTokenMap() const;
134 const SvXMLTokenMap& GetLoginElemTokenMap() const;
135 const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const;
136 const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const;
137 const SvXMLTokenMap& GetDocumentsElemTokenMap() const;
138 const SvXMLTokenMap& GetComponentElemTokenMap() const;
139 const SvXMLTokenMap& GetQueryElemTokenMap() const;
140 const SvXMLTokenMap& GetColumnElemTokenMap() const;
142 rtl::Reference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
143 rtl::Reference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
144 rtl::Reference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
146 /** add a Info to the sequence which will be appended to the data source
147 @param _rInfo The property to append.
149 inline void addInfo(const css::beans::PropertyValue& _rInfo)
151 m_aInfoSequence.push_back(_rInfo);
154 void setPropertyInfo();
156 inline bool isNewFormat() const { return m_bNewFormat; }
157 inline void setNewFormat(bool _bNewFormat) { m_bNewFormat = _bNewFormat; }
160 } // namespace dbaxml
161 #endif // INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLFILTER_HXX
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */