1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef DBA_XMLFILTER_HXX 25 #define DBA_XMLFILTER_HXX 26 27 #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ 28 #include <com/sun/star/container/XNamed.hpp> 29 #endif 30 #ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ 31 #include <com/sun/star/document/XFilter.hpp> 32 #endif 33 #ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_ 34 #include <com/sun/star/document/XImporter.hpp> 35 #endif 36 #ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ 37 #include <com/sun/star/document/XExporter.hpp> 38 #endif 39 #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ 40 #include <com/sun/star/lang/XInitialization.hpp> 41 #endif 42 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 43 #include <com/sun/star/lang/XServiceInfo.hpp> 44 #endif 45 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 46 #include <com/sun/star/beans/XPropertySet.hpp> 47 #endif 48 #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ 49 #include <com/sun/star/lang/XComponent.hpp> 50 #endif 51 #ifndef _CPPUHELPER_IMPLBASE1_HXX_ 52 #include <cppuhelper/implbase1.hxx> 53 #endif 54 #ifndef _CPPUHELPER_IMPLBASE5_HXX_ 55 #include <cppuhelper/implbase5.hxx> 56 #endif 57 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 58 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 59 #endif 60 #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ 61 #include <com/sun/star/io/XActiveDataSource.hpp> 62 #endif 63 #ifndef _OSL_DIAGNOSE_H_ 64 #include <osl/diagnose.h> 65 #endif 66 #ifndef _UNOTOOLS_TEMPFILE_HXX 67 #include <unotools/tempfile.hxx> 68 #endif 69 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX 70 #include <unotools/localfilehelper.hxx> 71 #endif 72 #ifndef _UNTOOLS_UCBSTREAMHELPER_HXX 73 #include <unotools/ucbstreamhelper.hxx> 74 #endif 75 #ifndef _XMLOFF_XMLIMP_HXX 76 #include <xmloff/xmlimp.hxx> 77 #endif 78 #ifndef _DBASHARED_APITOOLS_HXX_ 79 #include "apitools.hxx" 80 #endif 81 #ifndef _COMPHELPER_STLTYPES_HXX_ 82 #include <comphelper/stl_types.hxx> 83 #endif 84 85 #include <memory> 86 87 namespace dbaxml 88 { 89 using namespace ::xmloff::token; 90 using namespace ::com::sun::star::uno; 91 using namespace ::com::sun::star::container; 92 using namespace ::com::sun::star::lang; 93 using namespace ::com::sun::star::beans; 94 using namespace ::com::sun::star::document; 95 using namespace ::com::sun::star::text; 96 using namespace ::com::sun::star::io; 97 using namespace ::com::sun::star::xml::sax; 98 99 // ------------- 100 // - ODBFilter - 101 // ------------- 102 class ODBFilter : public SvXMLImport 103 { 104 public: 105 DECLARE_STL_USTRINGACCESS_MAP(Sequence<PropertyValue>,TPropertyNameMap); 106 typedef ::std::vector< ::com::sun::star::beans::PropertyValue> TInfoSequence; 107 private: 108 TPropertyNameMap m_aQuerySettings; 109 TPropertyNameMap m_aTablesSettings; 110 TInfoSequence m_aInfoSequence; 111 Reference< XComponent > m_xSrcDoc; 112 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap; 113 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap; 114 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap; 115 mutable ::std::auto_ptr<SvXMLTokenMap> m_pLoginElemTokenMap; 116 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap; 117 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap; 118 mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap; 119 mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap; 120 mutable ::std::auto_ptr<SvXMLTokenMap> m_pQueryElemTokenMap; 121 mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnElemTokenMap; 122 123 mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper; 124 mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; 125 mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper; 126 Reference<XPropertySet> m_xDataSource; 127 sal_Int32 m_nPreviewMode; 128 bool m_bNewFormat; 129 130 sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException); 131 132 133 /** fills the map with the Properties 134 @param _rValue 135 The Any where the sequence resists in. 136 @param _rMap 137 The map to fill. 138 */ 139 void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap); 140 141 SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const ::rtl::OUString& rLocalName, 142 const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ); 143 SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName ); 144 145 protected: 146 // SvXMLImport 147 virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, 148 const ::rtl::OUString& rLocalName, 149 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 150 151 virtual ~ODBFilter() throw(); 152 public: 153 154 ODBFilter( const Reference< XMultiServiceFactory >& _rxMSF ); 155 156 // XFilter 157 virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException); 158 159 // XServiceInfo 160 DECLARE_SERVICE_INFO_STATIC( ); 161 162 // helper class 163 virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps); 164 virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps); 165 getORB()166 inline Reference< XMultiServiceFactory > getORB() { return getServiceFactory(); } getDataSource() const167 inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; } 168 getQuerySettings() const169 inline const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;} getTableSettings() const170 inline const TPropertyNameMap& getTableSettings() const { return m_aTablesSettings;} 171 172 const SvXMLTokenMap& GetDocElemTokenMap() const; 173 const SvXMLTokenMap& GetDatabaseElemTokenMap() const; 174 const SvXMLTokenMap& GetDataSourceElemTokenMap() const; 175 const SvXMLTokenMap& GetLoginElemTokenMap() const; 176 const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const; 177 const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const; 178 const SvXMLTokenMap& GetDocumentsElemTokenMap() const; 179 const SvXMLTokenMap& GetComponentElemTokenMap() const; 180 const SvXMLTokenMap& GetQueryElemTokenMap() const; 181 const SvXMLTokenMap& GetColumnElemTokenMap() const; 182 183 UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const; 184 UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const; 185 UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const; 186 187 /** add a Info to the sequence which will be appened to the data source 188 @param _rInfo The property to append. 189 */ addInfo(const::com::sun::star::beans::PropertyValue & _rInfo)190 inline void addInfo(const ::com::sun::star::beans::PropertyValue& _rInfo) 191 { 192 m_aInfoSequence.push_back(_rInfo); 193 } 194 195 void setPropertyInfo(); 196 197 const ::std::map< sal_uInt16,com::sun::star::beans::Property>& GetDataSourceInfoDefaulValueMap() const; 198 isNewFormat() const199 inline bool isNewFormat() const { return m_bNewFormat; } setNewFormat(bool _bNewFormat)200 inline void setNewFormat(bool _bNewFormat) { m_bNewFormat = _bNewFormat; } 201 }; 202 203 // ----------------------------------------------------------------------------- 204 } // dbaxml 205 // ----------------------------------------------------------------------------- 206 #endif // DBA_XMLFILTER_HXX 207