Update ooo320-m1
[ooovba.git] / dbaccess / source / filter / xml / xmlfilter.hxx
blobdb9ee817c6c18e5cac943b61a48bdc93b1bdcb4f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlfilter.hxx,v $
10 * $Revision: 1.8.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef DBA_XMLFILTER_HXX
32 #define DBA_XMLFILTER_HXX
34 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
35 #include <com/sun/star/container/XNamed.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
38 #include <com/sun/star/document/XFilter.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
41 #include <com/sun/star/document/XImporter.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_
44 #include <com/sun/star/document/XExporter.hpp>
45 #endif
46 #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
47 #include <com/sun/star/lang/XInitialization.hpp>
48 #endif
49 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #endif
52 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
53 #include <com/sun/star/beans/XPropertySet.hpp>
54 #endif
55 #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
56 #include <com/sun/star/lang/XComponent.hpp>
57 #endif
58 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
59 #include <cppuhelper/implbase1.hxx>
60 #endif
61 #ifndef _CPPUHELPER_IMPLBASE5_HXX_
62 #include <cppuhelper/implbase5.hxx>
63 #endif
64 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
65 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
66 #endif
67 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
68 #include <com/sun/star/io/XActiveDataSource.hpp>
69 #endif
70 #ifndef _OSL_DIAGNOSE_H_
71 #include <osl/diagnose.h>
72 #endif
73 #ifndef _UNOTOOLS_TEMPFILE_HXX
74 #include <unotools/tempfile.hxx>
75 #endif
76 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
77 #include <unotools/localfilehelper.hxx>
78 #endif
79 #ifndef _UNTOOLS_UCBSTREAMHELPER_HXX
80 #include <unotools/ucbstreamhelper.hxx>
81 #endif
82 #ifndef _XMLOFF_XMLIMP_HXX
83 #include <xmloff/xmlimp.hxx>
84 #endif
85 #ifndef _DBASHARED_APITOOLS_HXX_
86 #include "apitools.hxx"
87 #endif
88 #ifndef _COMPHELPER_STLTYPES_HXX_
89 #include <comphelper/stl_types.hxx>
90 #endif
92 #include <memory>
94 namespace dbaxml
96 using namespace ::xmloff::token;
97 using namespace ::com::sun::star::uno;
98 using namespace ::com::sun::star::container;
99 using namespace ::com::sun::star::lang;
100 using namespace ::com::sun::star::beans;
101 using namespace ::com::sun::star::document;
102 using namespace ::com::sun::star::text;
103 using namespace ::com::sun::star::io;
104 using namespace ::com::sun::star::xml::sax;
106 // -------------
107 // - ODBFilter -
108 // -------------
109 class ODBFilter : public SvXMLImport
111 public:
112 DECLARE_STL_USTRINGACCESS_MAP(Sequence<PropertyValue>,TPropertyNameMap);
113 typedef ::std::vector< ::com::sun::star::beans::PropertyValue> TInfoSequence;
114 private:
115 TPropertyNameMap m_aQuerySettings;
116 TPropertyNameMap m_aTablesSettings;
117 TInfoSequence m_aInfoSequence;
118 Reference< XComponent > m_xSrcDoc;
119 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
120 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap;
121 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap;
122 mutable ::std::auto_ptr<SvXMLTokenMap> m_pLoginElemTokenMap;
123 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap;
124 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap;
125 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap;
126 mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
127 mutable ::std::auto_ptr<SvXMLTokenMap> m_pQueryElemTokenMap;
128 mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnElemTokenMap;
130 mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
131 mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
132 mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
133 Reference<XPropertySet> m_xDataSource;
134 sal_Int32 m_nPreviewMode;
135 bool m_bNewFormat;
137 sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
140 /** fills the map with the Properties
141 @param _rValue
142 The Any where the sequence resists in.
143 @param _rMap
144 The map to fill.
146 void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap);
148 SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const ::rtl::OUString& rLocalName,
149 const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle );
150 SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName );
152 protected:
153 // SvXMLImport
154 virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
155 const ::rtl::OUString& rLocalName,
156 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
158 virtual ~ODBFilter() throw();
159 public:
161 ODBFilter( const Reference< XMultiServiceFactory >& _rxMSF );
163 // XFilter
164 virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException);
166 // XServiceInfo
167 DECLARE_SERVICE_INFO_STATIC( );
169 // helper class
170 virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
171 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
173 inline Reference< XMultiServiceFactory > getORB() { return getServiceFactory(); }
174 inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; }
176 inline const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;}
177 inline const TPropertyNameMap& getTableSettings() const { return m_aTablesSettings;}
179 const SvXMLTokenMap& GetDocElemTokenMap() const;
180 const SvXMLTokenMap& GetDatabaseElemTokenMap() const;
181 const SvXMLTokenMap& GetDataSourceElemTokenMap() const;
182 const SvXMLTokenMap& GetLoginElemTokenMap() const;
183 const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const;
184 const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const;
185 const SvXMLTokenMap& GetDocumentsElemTokenMap() const;
186 const SvXMLTokenMap& GetComponentElemTokenMap() const;
187 const SvXMLTokenMap& GetQueryElemTokenMap() const;
188 const SvXMLTokenMap& GetColumnElemTokenMap() const;
190 UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
191 UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
192 UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
194 /** add a Info to the sequence which will be appened to the data source
195 @param _rInfo The property to append.
197 inline void addInfo(const ::com::sun::star::beans::PropertyValue& _rInfo)
199 m_aInfoSequence.push_back(_rInfo);
202 void setPropertyInfo();
204 const ::std::map< sal_uInt16,com::sun::star::beans::Property>& GetDataSourceInfoDefaulValueMap() const;
206 inline bool isNewFormat() const { return m_bNewFormat; }
207 inline void setNewFormat(bool _bNewFormat) { m_bNewFormat = _bNewFormat; }
210 // -----------------------------------------------------------------------------
211 } // dbaxml
212 // -----------------------------------------------------------------------------
213 #endif // DBA_XMLFILTER_HXX