LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - DbAdminImpl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 7 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 _DBAUI_DBADMINIMPL_HXX_
      21                 :            : #define _DBAUI_DBADMINIMPL_HXX_
      22                 :            : 
      23                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      24                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      25                 :            : #include <com/sun/star/uno/XNamingService.hpp>
      26                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      27                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      28                 :            : #include <com/sun/star/sdbc/XConnection.hpp>
      29                 :            : #include <com/sun/star/sdbc/XDriver.hpp>
      30                 :            : #include <comphelper/stl_types.hxx>
      31                 :            : #include "dsntypes.hxx"
      32                 :            : #include <svl/itemset.hxx>
      33                 :            : #include <com/sun/star/frame/XModel.hpp>
      34                 :            : #include <svl/poolitem.hxx>
      35                 :            : 
      36                 :            : class Window;
      37                 :            : //.........................................................................
      38                 :            : namespace dbaui
      39                 :            : {
      40                 :            : //.........................................................................
      41                 :          0 :     class DataSourceInfoConverter
      42                 :            :     {
      43                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
      44                 :            :     public:
      45                 :          0 :         DataSourceInfoConverter(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory)
      46                 :          0 :             :m_xFactory(_xFactory)
      47                 :            :         {
      48                 :          0 :         }
      49                 :            :         void convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource);
      50                 :            :     };
      51                 :            :     class IItemSetHelper;
      52                 :            :     //========================================================================
      53                 :            :     //= ODbDataSourceAdministrationHelper
      54                 :            :     //========================================================================
      55                 :          0 :     class ODbDataSourceAdministrationHelper
      56                 :            :     {
      57                 :            :     public:
      58                 :            :         DECLARE_STL_MAP(sal_Int32, ::rtl::OUString, ::std::less< sal_Int32 >, MapInt2String);
      59                 :            : 
      60                 :            :     private:
      61                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
      62                 :            :                             m_xORB;                 /// service factory
      63                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
      64                 :            :                                 m_xDatabaseContext;     /// database context we're working in
      65                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService >
      66                 :            :                                 m_xDynamicContext;      /// just another interface of the context ...
      67                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xDatasource;
      68                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >         m_xModel;
      69                 :            : 
      70                 :            :         ::com::sun::star::uno::Any              m_aDataSourceOrName;
      71                 :            :         typedef ::std::set< ::rtl::OUString >   StringSet;
      72                 :            :         typedef StringSet::const_iterator       ConstStringSetIterator;
      73                 :            : 
      74                 :            : 
      75                 :            :         MapInt2String           m_aDirectPropTranslator;    /// translating property id's into names (direct properties of a data source)
      76                 :            :         MapInt2String           m_aIndirectPropTranslator;  /// translating property id's into names (indirect properties of a data source)
      77                 :            :         Window*                 m_pParent;
      78                 :            :         IItemSetHelper*         m_pItemSetHelper;
      79                 :            :     public:
      80                 :            : 
      81                 :            :         ODbDataSourceAdministrationHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
      82                 :            :                                         ,Window* _pParent
      83                 :            :                                         ,IItemSetHelper* _pItemSetHelper);
      84                 :            : 
      85                 :            :         /** translate the current dialog SfxItems into driver relevant PropertyValues
      86                 :            :             @see successfullyConnected
      87                 :            :         */
      88                 :            :         sal_Bool    getCurrentSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverParams);
      89                 :            : 
      90                 :            :         /** to be called if the settings got from getCurrentSettings have been used for successfully connecting
      91                 :            :             @see getCurrentSettings
      92                 :            :         */
      93                 :            :         void        successfullyConnected();
      94                 :            : 
      95                 :            :         /// clear the password in the current data source's item set
      96                 :            :         void        clearPassword();
      97                 :            : 
      98                 :          0 :         inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; }
      99                 :            : 
     100                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getDatabaseContext() const { return m_xDatabaseContext; }
     101                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService > getDynamicContext() const { return m_xDynamicContext; }
     102                 :            : 
     103                 :            :         /** creates a new connection. The caller is responsible to dispose it !!!!
     104                 :            :         */
     105                 :            :         ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool>      createConnection();
     106                 :            : 
     107                 :            :         /** return the corresponding driver for the selected URL
     108                 :            :         */
     109                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >         getDriver();
     110                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver >         getDriver(const ::rtl::OUString& _sURL);
     111                 :            : 
     112                 :            :         /** returns the data source the dialog is currently working with
     113                 :            :         */
     114                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   getCurrentDataSource();
     115                 :            :         // returns the Url of a database document
     116                 :            :         String              getDocumentUrl(SfxItemSet& _rDest);
     117                 :            : 
     118                 :            :         void setDataSourceOrName( const ::com::sun::star::uno::Any& _rDataSourceOrName );
     119                 :            : 
     120                 :            :         /** extracts the connection type from the given set<p/>
     121                 :            :             The connection type is determined by the value of the DSN item, analyzed by the TypeCollection item.
     122                 :            :         */
     123                 :            :         static ::rtl::OUString getDatasourceType( const SfxItemSet& _rSet );
     124                 :            : 
     125                 :            :         /** returns the connection URL
     126                 :            :             @return
     127                 :            :                 The connection URL
     128                 :            :         */
     129                 :            :         String getConnectionURL() const;
     130                 :            : 
     131                 :            :         /// fill the necessary information from the url line
     132                 :            :         void convertUrl(SfxItemSet& _rDest);
     133                 :            : 
     134                 :          0 :         const MapInt2String& getIndirectProperties() const { return m_aIndirectPropTranslator; }
     135                 :            : 
     136                 :            :         /** translates properties of an UNO data source into SfxItems
     137                 :            :             @param  _rxSource
     138                 :            :                 The data source
     139                 :            :             @param  _rDest
     140                 :            :                 The item set to fill.
     141                 :            :         */
     142                 :            :         void translateProperties(
     143                 :            :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSource,
     144                 :            :                 SfxItemSet& _rDest);
     145                 :            : 
     146                 :            :         /** translate SfxItems into properties of an UNO data source
     147                 :            :             @param  _rSource
     148                 :            :                 The item set to read from.
     149                 :            :             @param  _rxDest
     150                 :            :                 The data source to fill.
     151                 :            :         */
     152                 :            :         void translateProperties(
     153                 :            :                 const SfxItemSet& _rSource,
     154                 :            :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDest);
     155                 :            : 
     156                 :            :         sal_Bool saveChanges(const SfxItemSet& _rSource);
     157                 :            :     protected:
     158                 :            :         /** fill a data source info array with the settings from a given item set
     159                 :            :         */
     160                 :            :         void fillDatasourceInfo(const SfxItemSet& _rSource, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
     161                 :            : 
     162                 :            :         /// translate the given value into an SfxPoolItem, put this into the given set under the given id
     163                 :            :         void        implTranslateProperty(SfxItemSet& _rSet, sal_Int32  _nId, const ::com::sun::star::uno::Any& _rValue);
     164                 :            : 
     165                 :            :         /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>
     166                 :            :         ::com::sun::star::uno::Any implTranslateProperty(const SfxPoolItem* _pItem);
     167                 :            : 
     168                 :            :         /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>, set it (under the given name) on the given property set
     169                 :            :         void        implTranslateProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem);
     170                 :            : 
     171                 :            :         /** check if the data source described by the given set needs authentication<p/>
     172                 :            :             The return value depends on the data source type only.
     173                 :            :         */
     174                 :            :         sal_Bool            hasAuthentication(const SfxItemSet& _rSet) const;
     175                 :            : 
     176                 :            : #if OSL_DEBUG_LEVEL > 0
     177                 :            :         ::rtl::OString translatePropertyId( sal_Int32 _nId );
     178                 :            : #endif
     179                 :            :     };
     180                 :            : 
     181                 :            : //.........................................................................
     182                 :            : }   // namespace dbaui
     183                 :            : //.........................................................................
     184                 :            : 
     185                 :            : #endif // _DBAUI_DBADMINIMPL_HXX_
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10