LCOV - code coverage report
Current view: top level - dbaccess/source/filter/xml - xmlExport.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 5 9 55.6 %
Date: 2015-06-13 12:38:46 Functions: 5 10 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLEXPORT_HXX
      21             : #define INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLEXPORT_HXX
      22             : 
      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/xmlexp.hxx>
      40             : #include <xmloff/xmlimp.hxx>
      41             : #include "dsntypes.hxx"
      42             : #include <comphelper/stl_types.hxx>
      43             : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      44             : 
      45             : #include <memory>
      46             : 
      47             : namespace dbaxml
      48             : {
      49             : using namespace ::xmloff::token;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::container;
      52             : using namespace ::com::sun::star::lang;
      53             : using namespace ::com::sun::star::beans;
      54             : using namespace ::com::sun::star::document;
      55             : using namespace ::com::sun::star::sdbcx;
      56             : using namespace ::com::sun::star::text;
      57             : using namespace ::com::sun::star::io;
      58             : using namespace ::com::sun::star::xml::sax;
      59             : // - ODBExport -
      60             : #define PROGRESS_BAR_STEP 20
      61             : 
      62             : class ODBExport : public SvXMLExport
      63             : {
      64             :     typedef ::std::map< ::xmloff::token::XMLTokenEnum, OUString> TSettingsMap;
      65             : 
      66             :     typedef ::std::pair< OUString ,OUString> TStringPair;
      67          96 :     struct TDelimiter
      68             :     {
      69             :         OUString sText;
      70             :         OUString sField;
      71             :         OUString sDecimal;
      72             :         OUString sThousand;
      73             :         bool            bUsed;
      74             : 
      75          96 :         TDelimiter() : bUsed( false ) { }
      76             :     };
      77             :     typedef ::std::map< Reference<XPropertySet> ,OUString >          TPropertyStyleMap;
      78             :     typedef ::std::map< Reference<XPropertySet> ,Reference<XPropertySet> >  TTableColumnMap;
      79             : 
      80           0 :     struct TypedPropertyValue
      81             :     {
      82             :         OUString               Name;
      83             :         ::com::sun::star::uno::Type   Type;
      84             :         ::com::sun::star::uno::Any    Value;
      85             : 
      86           0 :         TypedPropertyValue( const OUString& _name, const ::com::sun::star::uno::Type& _type, const ::com::sun::star::uno::Any& _value )
      87             :             :Name( _name )
      88             :             ,Type( _type )
      89           0 :             ,Value( _value )
      90             :         {
      91           0 :         }
      92             :     };
      93             : 
      94             :     ::std::unique_ptr< TStringPair >                  m_aAutoIncrement;
      95             :     ::std::unique_ptr< TDelimiter >                   m_aDelimiter;
      96             :     ::std::vector< TypedPropertyValue >             m_aDataSourceSettings;
      97             :     ::std::vector< XMLPropertyState >               m_aCurrentPropertyStates;
      98             :     TPropertyStyleMap                               m_aAutoStyleNames;
      99             :     TPropertyStyleMap                               m_aCellAutoStyleNames;
     100             :     TPropertyStyleMap                               m_aRowAutoStyleNames;
     101             :     TTableColumnMap                                 m_aTableDummyColumns;
     102             :     OUString                                 m_sCharSet;
     103             :     rtl::Reference < SvXMLExportPropertyMapper>       m_xExportHelper;
     104             :     rtl::Reference < SvXMLExportPropertyMapper>       m_xColumnExportHelper;
     105             :     rtl::Reference < SvXMLExportPropertyMapper>       m_xCellExportHelper;
     106             :     rtl::Reference < SvXMLExportPropertyMapper>       m_xRowExportHelper;
     107             : 
     108             :     mutable rtl::Reference < XMLPropertySetMapper >   m_xTableStylesPropertySetMapper;
     109             :     mutable rtl::Reference < XMLPropertySetMapper >   m_xColumnStylesPropertySetMapper;
     110             :     mutable rtl::Reference < XMLPropertySetMapper >   m_xCellStylesPropertySetMapper;
     111             :     mutable rtl::Reference < XMLPropertySetMapper >   m_xRowStylesPropertySetMapper;
     112             : 
     113             :     Reference<XPropertySet>                         m_xDataSource;
     114             :     ::dbaccess::ODsnTypeCollection                  m_aTypeCollection;
     115             :     bool                                        m_bAllreadyFilled;
     116             : 
     117             :     void                    exportDataSource();
     118             :     void                    exportConnectionData();
     119             :     void                    exportDriverSettings(const TSettingsMap& _aSettings);
     120             :     void                    exportApplicationConnectionSettings(const TSettingsMap& _aSettings);
     121             :     void                    exportLogin();
     122             :     void                    exportSequence(const Sequence< OUString>& _aValue
     123             :                                         ,::xmloff::token::XMLTokenEnum _eTokenFilter
     124             :                                         ,::xmloff::token::XMLTokenEnum _eTokenType);
     125             :     void                    exportDelimiter();
     126             :     void                    exportAutoIncrement();
     127             :     void                    exportCharSet();
     128             :     template< typename T > void exportDataSourceSettingsSequence(
     129             :         ::std::vector< TypedPropertyValue >::iterator const & in);
     130             :     void                    exportDataSourceSettings();
     131             :     void                    exportForms();
     132             :     void                    exportReports();
     133             :     void                    exportQueries(bool _bExportContext);
     134             :     void                    exportTables(bool _bExportContext);
     135             :     void                    exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt);
     136             :     void                    exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap);
     137             :     void                    exportCollection(const Reference< XNameAccess >& _xCollection
     138             :                                             ,enum ::xmloff::token::XMLTokenEnum _eComponents
     139             :                                             ,enum ::xmloff::token::XMLTokenEnum _eSubComponents
     140             :                                             ,bool _bExportContext
     141             :                                             ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc
     142             :                                             );
     143             :     void                    exportComponent(XPropertySet* _xProp);
     144             :     void                    exportQuery(XPropertySet* _xProp);
     145             :     void                    exportTable(XPropertySet* _xProp);
     146             :     void                    exportFilter(XPropertySet* _xProp
     147             :                                         ,const OUString& _sProp
     148             :                                         ,enum ::xmloff::token::XMLTokenEnum _eStatementType);
     149             :     void                    exportTableName(XPropertySet* _xProp,bool _bUpdate);
     150             :     void                    exportAutoStyle(XPropertySet* _xProp);
     151             :     void                    exportColumns(const Reference<XColumnsSupplier>& _xColSup);
     152             :     void                    collectComponentStyles();
     153             : 
     154             :     static OUString         implConvertAny(const Any& _rValue);
     155             : 
     156             :     rtl::Reference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
     157             : 
     158             : private:
     159             :                             ODBExport();
     160             : protected:
     161             : 
     162             :     virtual void                    _ExportStyles( bool bUsed ) SAL_OVERRIDE;
     163             :     virtual void                    _ExportAutoStyles() SAL_OVERRIDE;
     164             :     virtual void                    _ExportContent() SAL_OVERRIDE;
     165             :     virtual void                    _ExportMasterStyles() SAL_OVERRIDE;
     166             :     virtual void                    _ExportFontDecls() SAL_OVERRIDE;
     167             :     virtual sal_uInt32              exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) SAL_OVERRIDE;
     168             :     virtual SvXMLAutoStylePoolP*    CreateAutoStylePool() SAL_OVERRIDE;
     169             : 
     170             :     virtual void GetViewSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps) SAL_OVERRIDE;
     171             :     virtual void GetConfigurationSettings(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aProps) SAL_OVERRIDE;
     172             : 
     173         390 :     virtual                 ~ODBExport(){};
     174             : public:
     175             : 
     176          97 :     ODBExport(const Reference< XComponentContext >& _rxContext, OUString const & implementationName, SvXMLExportFlags nExportFlag = SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::PRETTY | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::SCRIPTS );
     177             : 
     178             :     static OUString SAL_CALL getImplementationName_Static()
     179             :         throw (css::uno::RuntimeException);
     180             : 
     181             :     static css::uno::Sequence<OUString> SAL_CALL
     182             :     getSupportedServiceNames_Static() throw (css::uno::RuntimeException);
     183             : 
     184             :     static css::uno::Reference<css::uno::XInterface> SAL_CALL Create(
     185             :         css::uno::Reference<css::lang::XMultiServiceFactory> const & _rxORB);
     186             : 
     187             :     rtl::Reference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
     188             :     rtl::Reference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
     189             : 
     190             :     // XExporter
     191             :     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, std::exception) SAL_OVERRIDE;
     192             : 
     193        1440 :     inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; }
     194             : };
     195             : 
     196             : } // dbaxml
     197             : #endif // INCLUDED_DBACCESS_SOURCE_FILTER_XML_XMLEXPORT_HXX
     198             : 
     199             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11