1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef DBA_XMLEXPORT_HXX 25cdf0e10cSrcweir #define DBA_XMLEXPORT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ 28cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_ 31cdf0e10cSrcweir #include <com/sun/star/document/XFilter.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_ 34cdf0e10cSrcweir #include <com/sun/star/document/XImporter.hpp> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DOCUMENT_XEXPORTER_HPP_ 37cdf0e10cSrcweir #include <com/sun/star/document/XExporter.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ 40cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 43cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 46cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_ 49cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE1_HXX_ 52cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE5_HXX_ 55cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx> 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 58cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ 61cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #ifndef _OSL_DIAGNOSE_H_ 64cdf0e10cSrcweir #include <osl/diagnose.h> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _UNOTOOLS_TEMPFILE_HXX 67cdf0e10cSrcweir #include <unotools/tempfile.hxx> 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX 70cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef _UNTOOLS_UCBSTREAMHELPER_HXX 73cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #ifndef _XMLOFF_XMLEXP_HXX 76cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 77cdf0e10cSrcweir #endif 78cdf0e10cSrcweir #ifndef _XMLOFF_XMLIMP_HXX 79cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 80cdf0e10cSrcweir #endif 81cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_ 82cdf0e10cSrcweir #include "apitools.hxx" 83cdf0e10cSrcweir #endif 84cdf0e10cSrcweir #include "dsntypes.hxx" 85cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_ 86cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 87cdf0e10cSrcweir #endif 88cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ 89cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> 90cdf0e10cSrcweir #endif 91cdf0e10cSrcweir 92cdf0e10cSrcweir #include <memory> 93cdf0e10cSrcweir 94cdf0e10cSrcweir namespace dbaxml 95cdf0e10cSrcweir { 96cdf0e10cSrcweir using namespace ::xmloff::token; 97cdf0e10cSrcweir using namespace ::com::sun::star::uno; 98cdf0e10cSrcweir using namespace ::com::sun::star::container; 99cdf0e10cSrcweir using namespace ::com::sun::star::lang; 100cdf0e10cSrcweir using namespace ::com::sun::star::beans; 101cdf0e10cSrcweir using namespace ::com::sun::star::document; 102cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 103cdf0e10cSrcweir using namespace ::com::sun::star::text; 104cdf0e10cSrcweir using namespace ::com::sun::star::io; 105cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 106cdf0e10cSrcweir // ------------- 107cdf0e10cSrcweir // - ODBExport - 108cdf0e10cSrcweir // ------------- 109cdf0e10cSrcweir #define PROGRESS_BAR_STEP 20 110cdf0e10cSrcweir 111cdf0e10cSrcweir class ODBExport : public SvXMLExport 112cdf0e10cSrcweir { 113cdf0e10cSrcweir typedef ::std::map< ::xmloff::token::XMLTokenEnum, ::rtl::OUString> TSettingsMap; 114cdf0e10cSrcweir 115cdf0e10cSrcweir typedef ::std::pair< ::rtl::OUString ,::rtl::OUString> TStringPair; 116cdf0e10cSrcweir struct TDelimiter 117cdf0e10cSrcweir { 118cdf0e10cSrcweir ::rtl::OUString sText; 119cdf0e10cSrcweir ::rtl::OUString sField; 120cdf0e10cSrcweir ::rtl::OUString sDecimal; 121cdf0e10cSrcweir ::rtl::OUString sThousand; 122cdf0e10cSrcweir bool bUsed; 123cdf0e10cSrcweir TDelimiterdbaxml::ODBExport::TDelimiter124cdf0e10cSrcweir TDelimiter() : bUsed( false ) { } 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir typedef ::std::map< Reference<XPropertySet> ,::rtl::OUString > TPropertyStyleMap; 127cdf0e10cSrcweir typedef ::std::map< Reference<XPropertySet> ,Reference<XPropertySet> > TTableColumnMap; 128cdf0e10cSrcweir 129cdf0e10cSrcweir struct TypedPropertyValue 130cdf0e10cSrcweir { 131cdf0e10cSrcweir ::rtl::OUString Name; 132cdf0e10cSrcweir ::com::sun::star::uno::Type Type; 133cdf0e10cSrcweir ::com::sun::star::uno::Any Value; 134cdf0e10cSrcweir TypedPropertyValuedbaxml::ODBExport::TypedPropertyValue135cdf0e10cSrcweir TypedPropertyValue( const ::rtl::OUString& _name, const ::com::sun::star::uno::Type& _type, const ::com::sun::star::uno::Any& _value ) 136cdf0e10cSrcweir :Name( _name ) 137cdf0e10cSrcweir ,Type( _type ) 138cdf0e10cSrcweir ,Value( _value ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir } 141cdf0e10cSrcweir }; 142cdf0e10cSrcweir 143cdf0e10cSrcweir ::std::auto_ptr< TStringPair > m_aAutoIncrement; 144cdf0e10cSrcweir ::std::auto_ptr< TDelimiter > m_aDelimiter; 145cdf0e10cSrcweir ::std::vector< TypedPropertyValue > m_aDataSourceSettings; 146cdf0e10cSrcweir ::std::vector< XMLPropertyState > m_aCurrentPropertyStates; 147cdf0e10cSrcweir TPropertyStyleMap m_aAutoStyleNames; 148cdf0e10cSrcweir TPropertyStyleMap m_aCellAutoStyleNames; 149cdf0e10cSrcweir TPropertyStyleMap m_aRowAutoStyleNames; 150cdf0e10cSrcweir TTableColumnMap m_aTableDummyColumns; 151cdf0e10cSrcweir ::rtl::OUString m_sCharSet; 152cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper> m_xExportHelper; 153cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper> m_xColumnExportHelper; 154cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper> m_xCellExportHelper; 155cdf0e10cSrcweir UniReference < SvXMLExportPropertyMapper> m_xRowExportHelper; 156cdf0e10cSrcweir 157cdf0e10cSrcweir mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper; 158cdf0e10cSrcweir mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; 159cdf0e10cSrcweir mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper; 160cdf0e10cSrcweir mutable UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper; 161cdf0e10cSrcweir 162cdf0e10cSrcweir Reference<XPropertySet> m_xDataSource; 163cdf0e10cSrcweir ::dbaccess::ODsnTypeCollection m_aTypeCollection; 164cdf0e10cSrcweir sal_Bool m_bAllreadyFilled; 165cdf0e10cSrcweir 166cdf0e10cSrcweir void exportDataSource(); 167cdf0e10cSrcweir void exportConnectionData(); 168cdf0e10cSrcweir void exportDriverSettings(const TSettingsMap& _aSettings); 169cdf0e10cSrcweir void exportApplicationConnectionSettings(const TSettingsMap& _aSettings); 170cdf0e10cSrcweir void exportLogin(); 171cdf0e10cSrcweir void exportSequence(const Sequence< ::rtl::OUString>& _aValue 172cdf0e10cSrcweir ,::xmloff::token::XMLTokenEnum _eTokenFilter 173cdf0e10cSrcweir ,::xmloff::token::XMLTokenEnum _eTokenType); 174cdf0e10cSrcweir void exportDelimiter(); 175cdf0e10cSrcweir void exportAutoIncrement(); 176cdf0e10cSrcweir void exportCharSet(); 177cdf0e10cSrcweir void exportDataSourceSettings(); 178cdf0e10cSrcweir void exportForms(); 179cdf0e10cSrcweir void exportReports(); 180cdf0e10cSrcweir void exportQueries(sal_Bool _bExportContext); 181cdf0e10cSrcweir void exportTables(sal_Bool _bExportContext); 182cdf0e10cSrcweir void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt); 183cdf0e10cSrcweir void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap); 184cdf0e10cSrcweir void exportCollection(const Reference< XNameAccess >& _xCollection 185cdf0e10cSrcweir ,enum ::xmloff::token::XMLTokenEnum _eComponents 186cdf0e10cSrcweir ,enum ::xmloff::token::XMLTokenEnum _eSubComponents 187cdf0e10cSrcweir ,sal_Bool _bExportContext 188cdf0e10cSrcweir ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc 189cdf0e10cSrcweir ); 190cdf0e10cSrcweir void exportComponent(XPropertySet* _xProp); 191cdf0e10cSrcweir void exportQuery(XPropertySet* _xProp); 192cdf0e10cSrcweir void exportTable(XPropertySet* _xProp); 193cdf0e10cSrcweir void exportFilter(XPropertySet* _xProp 194cdf0e10cSrcweir ,const ::rtl::OUString& _sProp 195cdf0e10cSrcweir ,enum ::xmloff::token::XMLTokenEnum _eStatementType); 196cdf0e10cSrcweir void exportTableName(XPropertySet* _xProp,sal_Bool _bUpdate); 197cdf0e10cSrcweir void exportAutoStyle(XPropertySet* _xProp); 198cdf0e10cSrcweir void exportColumns(const Reference<XColumnsSupplier>& _xColSup); 199cdf0e10cSrcweir void collectComponentStyles(); 200cdf0e10cSrcweir 201cdf0e10cSrcweir ::rtl::OUString implConvertAny(const Any& _rValue); 202cdf0e10cSrcweir 203cdf0e10cSrcweir UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const; 204cdf0e10cSrcweir 205cdf0e10cSrcweir private: 206cdf0e10cSrcweir ODBExport(); 207cdf0e10cSrcweir protected: 208cdf0e10cSrcweir 209cdf0e10cSrcweir virtual void _ExportStyles( sal_Bool bUsed ); 210cdf0e10cSrcweir virtual void _ExportAutoStyles(); 211cdf0e10cSrcweir virtual void _ExportContent(); 212cdf0e10cSrcweir virtual void _ExportMasterStyles(); 213cdf0e10cSrcweir virtual void _ExportFontDecls(); 214cdf0e10cSrcweir virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ); 215cdf0e10cSrcweir virtual SvXMLAutoStylePoolP* CreateAutoStylePool(); 216cdf0e10cSrcweir 217cdf0e10cSrcweir virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); 218cdf0e10cSrcweir virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps); 219cdf0e10cSrcweir ~ODBExport()220cdf0e10cSrcweir virtual ~ODBExport(){}; 221cdf0e10cSrcweir public: 222cdf0e10cSrcweir 223cdf0e10cSrcweir ODBExport(const Reference< XMultiServiceFactory >& _rxMSF, sal_uInt16 nExportFlag = EXPORT_CONTENT | EXPORT_AUTOSTYLES | EXPORT_PRETTY | EXPORT_FONTDECLS | EXPORT_SCRIPTS ); 224cdf0e10cSrcweir // XServiceInfo 225cdf0e10cSrcweir DECLARE_SERVICE_INFO_STATIC( ); 226cdf0e10cSrcweir 227cdf0e10cSrcweir UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const; 228cdf0e10cSrcweir UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const; 229cdf0e10cSrcweir 230cdf0e10cSrcweir // XExporter 231cdf0e10cSrcweir virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 232cdf0e10cSrcweir getDataSource() const233cdf0e10cSrcweir inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; } 234cdf0e10cSrcweir }; 235cdf0e10cSrcweir 236cdf0e10cSrcweir // ----------------------------------------------------------------------------- 237cdf0e10cSrcweir } // dbaxml 238cdf0e10cSrcweir // ----------------------------------------------------------------------------- 239cdf0e10cSrcweir #endif // DBA_XMLEXPORT_HXX 240