LCOV - code coverage report
Current view: top level - include/connectivity - virtualdbtools.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 8 12 66.7 %
Date: 2014-11-03 Functions: 8 16 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_CONNECTIVITY_VIRTUALDBTOOLS_HXX
      21             : #define INCLUDED_CONNECTIVITY_VIRTUALDBTOOLS_HXX
      22             : 
      23             : #include <config_features.h>
      24             : 
      25             : #include <rtl/ref.hxx>
      26             : #include <rtl/ustring.hxx>
      27             : #include <com/sun/star/uno/Reference.hxx>
      28             : #include <com/sun/star/util/Date.hpp>
      29             : #include <com/sun/star/sdbc/SQLException.hpp>
      30             : #include <com/sun/star/uno/Sequence.hxx>
      31             : 
      32             : #include <vector>
      33             : #include <memory>
      34             : #include <connectivity/dbtoolsdllapi.hxx>
      35             : #include <salhelper/simplereferenceobject.hxx>
      36             : 
      37             : 
      38             : //= forward declarations
      39             : 
      40             : namespace com {
      41             :     namespace sun {
      42             :         namespace star {
      43             :             namespace util {
      44             :                 class XNumberFormatter;
      45             :                 class XNumberFormatTypes;
      46             :                 class XNumberFormatsSupplier;
      47             :             }
      48             :             namespace beans {
      49             :                 class XPropertySet;
      50             :             }
      51             :             namespace lang {
      52             :                 class XMultiServiceFactory;
      53             :                 class XComponent;
      54             :                 class WrappedTargetException;
      55             :                 struct Locale;
      56             :             }
      57             :             namespace sdbc {
      58             :                 class XDatabaseMetaData;
      59             :                 class XConnection;
      60             :                 class XRowSet;
      61             :                 class XDataSource;
      62             :             }
      63             :             namespace sdb {
      64             :                 class XColumn;
      65             :                 class SQLContext;
      66             :             }
      67             :             namespace uno {
      68             :                 class XComponentContext;
      69             :             }
      70             :             namespace container {
      71             :                 class XNameAccess;
      72             :             }
      73             :         }
      74             :     }
      75             : }
      76             : 
      77             : namespace dbtools {
      78             :     class SQLExceptionInfo;
      79             :     class FormattedColumnValue;
      80             : }
      81             : 
      82             : 
      83             : //= entry into this library
      84             : 
      85             : /** this is the entry point for the load-on-call usage of the DBTOOLS
      86             :     library.
      87             :     <p>When you need one of the simple objects in this library, load the lib
      88             :     and call this method. The returned pointer is a pointer to an IDataAccessToolsFactory
      89             :     instance, which is acquired <em>once</em>.</p>
      90             :     @return
      91             :         a pointer to an object implementing the IDataAccessToolsFactory interface,
      92             :         acquired exactly <em>once</em>.
      93             : */
      94             : #if HAVE_FEATURE_DESKTOP
      95             : extern "C" OOO_DLLPUBLIC_DBTOOLS void* SAL_CALL createDataAccessToolsFactory();
      96             : #endif
      97             : 
      98             : //=
      99             : 
     100             : 
     101             : namespace connectivity
     102             : {
     103             : 
     104             : 
     105             :     class IParseContext;
     106             : 
     107             :     namespace simple
     108             :     {
     109             : 
     110             : 
     111             :         typedef void* (SAL_CALL * createDataAccessToolsFactoryFunction)( );
     112             : 
     113             : 
     114             :         //= IDataAccessTools
     115             : 
     116         474 :         class OOO_DLLPUBLIC_DBTOOLS IDataAccessTools : public virtual salhelper::SimpleReferenceObject
     117             :         {
     118             :         public:
     119             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
     120             :                 const OUString& _rDataSourceName,
     121             :                 const OUString& _rUser,
     122             :                 const OUString& _rPwd,
     123             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
     124             :             ) const = 0;
     125             : 
     126             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
     127             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
     128             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
     129             :                 bool _bSetAsActiveConnection
     130             :             ) const = 0;
     131             : 
     132             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getRowSetConnection(
     133             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet)
     134             :                 const = 0;
     135             : 
     136             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
     137             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
     138             :                 bool _bAllowDefault
     139             :             ) const = 0;
     140             : 
     141             :             virtual sal_Int32 getDefaultNumberFormat(
     142             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
     143             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _rxTypes,
     144             :                 const ::com::sun::star::lang::Locale& _rLocale
     145             :             ) const = 0;
     146             : 
     147             :             virtual void TransferFormComponentProperties(
     148             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
     149             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
     150             :                 const ::com::sun::star::lang::Locale& _rLocale
     151             :             ) const = 0;
     152             : 
     153             :             virtual OUString quoteName(
     154             :                 const OUString& _rQuote,
     155             :                 const OUString& _rName
     156             :             ) const = 0;
     157             : 
     158             :             virtual OUString composeTableNameForSelect(
     159             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     160             :                 const OUString& _rCatalog,
     161             :                 const OUString& _rSchema,
     162             :                 const OUString& _rName
     163             :             ) const = 0;
     164             : 
     165             :             virtual OUString composeTableNameForSelect(
     166             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     167             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
     168             :             ) const = 0;
     169             : 
     170             :             virtual ::com::sun::star::sdb::SQLContext prependContextInfo(
     171             :                 ::com::sun::star::sdbc::SQLException& _rException,
     172             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
     173             :                 const OUString& _rContextDescription,
     174             :                 const OUString& _rContextDetails
     175             :             ) const = 0;
     176             : 
     177             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > getDataSource(
     178             :                 const OUString& _rsRegisteredName,
     179             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
     180             :             ) const = 0;
     181             : 
     182             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
     183             :                 getFieldsByCommandDescriptor(
     184             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     185             :                     const sal_Int32 _nCommandType,
     186             :                     const OUString& _rCommand,
     187             :                     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
     188             :                     ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
     189             :                 ) = 0;
     190             : 
     191             :             virtual ::com::sun::star::uno::Sequence< OUString >
     192             :                 getFieldNamesByCommandDescriptor(
     193             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     194             :                     const sal_Int32 _nCommandType,
     195             :                     const OUString& _rCommand,
     196             :                     ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL
     197             :                 ) = 0;
     198             : 
     199             :             /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
     200             :                 @param      _rxCursorSet    the property set
     201             :             */
     202             :             virtual bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
     203             : 
     204             :             /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
     205             :                 @param      _rxCursorSet    the property set
     206             :             */
     207             :             virtual bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
     208             : 
     209             :             /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
     210             :                 @param      _rxCursorSet    the property set
     211             :             */
     212             :             virtual bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet) const = 0;
     213             : 
     214             :             /** determines whether the given component is part of a document which is an embedded database
     215             :                 document (such as a form)
     216             :             */
     217             :             virtual bool isEmbeddedInDatabase(
     218             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
     219             :                 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
     220             :             ) = 0;
     221             : 
     222             :         protected:
     223         474 :             virtual ~IDataAccessTools() {}
     224             :         };
     225             : 
     226             : 
     227             :         //= IDataAccessCharSet
     228             : 
     229             :         /** simple wrapper for the OCharsetMap
     230             :         */
     231           2 :         class OOO_DLLPUBLIC_DBTOOLS IDataAccessCharSet :
     232             :             public salhelper::SimpleReferenceObject
     233             :         {
     234             :             // to be extended if necessary ....
     235             :         public:
     236             :             /** enumerates all supported char sets
     237             :             @return the number of charsets supported
     238             :             */
     239             :             virtual sal_Int32   getSupportedTextEncodings(
     240             :                 ::std::vector< rtl_TextEncoding >& /* [out] */ _rEncs
     241             :             ) const = 0;
     242             : 
     243             :         protected:
     244           2 :             virtual ~IDataAccessCharSet() {}
     245             :         };
     246             : 
     247             : 
     248             :         //= IDataAccessTypeConversion
     249             : 
     250         474 :         class OOO_DLLPUBLIC_DBTOOLS IDataAccessTypeConversion :
     251             :             public virtual salhelper::SimpleReferenceObject
     252             :         {
     253             :         public:
     254             :             virtual ::com::sun::star::util::Date getStandardDate() const = 0;
     255             : 
     256             :             virtual double getValue(
     257             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
     258             :                 const ::com::sun::star::util::Date& rNullDate ) const = 0;
     259             : 
     260             :             virtual OUString getFormattedValue(
     261             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
     262             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
     263             :                 const ::com::sun::star::util::Date& _rNullDate,
     264             :                 sal_Int32 _nKey,
     265             :                 sal_Int16 _nKeyType) const = 0;
     266             : 
     267             :             virtual OUString getFormattedValue(
     268             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
     269             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter>& _rxFormatter,
     270             :                 const ::com::sun::star::lang::Locale& _rLocale,
     271             :                 const ::com::sun::star::util::Date& _rNullDate
     272             :             ) const = 0;
     273             : 
     274             :         protected:
     275         474 :             virtual ~IDataAccessTypeConversion() {}
     276             :         };
     277             : 
     278             : 
     279             :         //= ISQLParseNode
     280             : 
     281             :         /** a simple version of the OSQLParseNode, with all methods being virtual
     282             :         */
     283           0 :         class OOO_DLLPUBLIC_DBTOOLS ISQLParseNode : public salhelper::SimpleReferenceObject
     284             :         {
     285             :         public:
     286             :             virtual void parseNodeToStr(OUString& _rString,
     287             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     288             :                 const IParseContext* _pContext
     289             :             ) const = 0;
     290             : 
     291             :             virtual void parseNodeToPredicateStr(OUString& _rString,
     292             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
     293             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
     294             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
     295             :                 const OUString &_sPredicateTableAlias,
     296             :                 const ::com::sun::star::lang::Locale& _rIntl,
     297             :                 const sal_Char _cDecSeparator,
     298             :                 const IParseContext* _pContext
     299             :             ) const = 0;
     300             : 
     301             :         protected:
     302           0 :             virtual ~ISQLParseNode() {}
     303             :         };
     304             : 
     305             : 
     306             :         //= ISQLParser
     307             : 
     308             :         /** a simple version of the OSQLParser, with all methods being virtual
     309             :         */
     310           0 :         class OOO_DLLPUBLIC_DBTOOLS ISQLParser : public salhelper::SimpleReferenceObject
     311             :         {
     312             :         public:
     313             :             virtual ::rtl::Reference< ISQLParseNode > predicateTree(
     314             :                 OUString& rErrorMessage,
     315             :                 const OUString& rStatement,
     316             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
     317             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
     318             :             ) const = 0;
     319             : 
     320             :             virtual const IParseContext& getContext() const = 0;
     321             : 
     322             :         protected:
     323           0 :             virtual ~ISQLParser() {}
     324             :         };
     325             : 
     326             : 
     327             :         //= IDataAccessToolsFactory
     328             : 
     329             :         /** the main factory for runtime-loadable tools in the DBTOOLS library
     330             :         */
     331         474 :         class OOO_DLLPUBLIC_DBTOOLS IDataAccessToolsFactory :
     332             :             public salhelper::SimpleReferenceObject
     333             :         {
     334             :         public:
     335             :             /// creates a simple version of the class OSQLParser
     336             :             virtual ::rtl::Reference< ISQLParser > createSQLParser(
     337             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
     338             :                 const IParseContext* _pContext
     339             :                 ) const = 0;
     340             : 
     341             :             /// creates a helper for charset related functionality (OCharsetMap)
     342             :             virtual ::rtl::Reference< IDataAccessCharSet > createCharsetHelper( ) const = 0;
     343             : 
     344             :             /// creates a simple version of the DBTypeConversion helper
     345             :             virtual ::rtl::Reference< IDataAccessTypeConversion > getTypeConversionHelper() = 0;
     346             : 
     347             :             /// creates a helper which can be used to access the static methods in dbtools.hxx
     348             :             virtual ::rtl::Reference< IDataAccessTools > getDataAccessTools() = 0;
     349             : 
     350             :             virtual ::std::unique_ptr< ::dbtools::FormattedColumnValue >  createFormattedColumnValue(
     351             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
     352             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet,
     353             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn
     354             :             ) = 0;
     355             : 
     356             :         protected:
     357         474 :             virtual ~IDataAccessToolsFactory() {}
     358             :         };
     359             : 
     360             : 
     361             :     }   //  namespace simple
     362             : 
     363             : 
     364             : 
     365             : }   // namespace connectivity
     366             : 
     367             : 
     368             : #endif // INCLUDED_CONNECTIVITY_VIRTUALDBTOOLS_HXX
     369             : 
     370             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10