<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: dsmeta.cxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2008-01-30 08:53:14 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#include "dsmeta.hxx"

/** === begin UNO includes === **/
/** === end UNO includes === **/

#include <map>

//........................................................................
namespace dbaui
{
//........................................................................

    /** === begin UNO using === **/
    /** === end UNO using === **/

    struct InitAdvanced : public AdvancedSettingsSupport
    {
        // strange ctor, but makes instantiating this class more readable (see below)
        InitAdvanced( short _Generated, short _SQL, short _Append, short _As, short _Outer, short _Priv, short _Param,
                      short _Version, short _Catalog, short _Schema, short _Index, short _DOS, short _Required, short _Bool,short _IgnoreCur )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _Generated != 0 );
            bUseSQL92NamingConstraints     = ( _SQL       != 0 );
            bAppendTableAliasInSelect      = ( _Append    != 0 );
            bUseKeywordAsBeforeAlias       = ( _As        != 0 );
            bUseBracketedOuterJoinSyntax   = ( _Outer     != 0 );
            bIgnoreDriverPrivileges        = ( _Priv      != 0 );
            bParameterNameSubstitution     = ( _Param     != 0 );
            bDisplayVersionColumns         = ( _Version   != 0 );
            bUseCatalogInSelect            = ( _Catalog   != 0 );
            bUseSchemaInSelect             = ( _Schema    != 0 );
            bUseIndexDirectionKeyword      = ( _Index     != 0 );
            bUseDOSLineEnds                = ( _DOS       != 0 );
            bBooleanComparisonMode         = ( _Bool      != 0 );
            bFormsCheckRequiredFields      = ( _Required  != 0 );
            bIgnoreCurrency                = ( _IgnoreCur != 0 );
        }

        enum Special { All, None };

        InitAdvanced( Special _eType )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _eType == All );
            bUseSQL92NamingConstraints     = ( _eType == All );
            bAppendTableAliasInSelect      = ( _eType == All );
            bUseKeywordAsBeforeAlias       = ( _eType == All );
            bUseBracketedOuterJoinSyntax   = ( _eType == All );
            bIgnoreDriverPrivileges        = ( _eType == All );
            bParameterNameSubstitution     = ( _eType == All );
            bDisplayVersionColumns         = ( _eType == All );
            bUseCatalogInSelect            = ( _eType == All );
            bUseSchemaInSelect             = ( _eType == All );
            bUseIndexDirectionKeyword      = ( _eType == All );
            bUseDOSLineEnds                = ( _eType == All );
            bBooleanComparisonMode         = ( _eType == All );
            bFormsCheckRequiredFields      = ( _eType == All );
            bIgnoreCurrency                = false; // Oracle special
        }
    };

    struct FeatureSupport
    {
        // authentication mode of the data source
        AuthenticationMode      eAuthentication;

        FeatureSupport()
            :eAuthentication( AuthUserPwd )
        {
        }

        FeatureSupport( AuthenticationMode _Auth )
            :eAuthentication( _Auth )
        {
        }
    };

    //====================================================================
    //= global tables
    //====================================================================
    //--------------------------------------------------------------------
    static const AdvancedSettingsSupport& getAdvancedSettingsSupport( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, AdvancedSettingsSupport >    AdvancedSupport;

        static AdvancedSupport s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_ODBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_JDBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_ORACLE_JDBC         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADABAS              ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_CALC                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_DBASE               ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
            s_aSupport[ DST_FLAT                ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            s_aSupport[ DST_JDBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ODBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADO                 ] = InitAdvanced( 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 );
            s_aSupport[ DST_MOZILLA             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_THUNDERBIRD         ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_LDAP                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOK             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOKEXP          ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION           ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_KAB                 ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_MSACCESS_2007       ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = InitAdvanced( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 );
            s_aSupport[ DST_USERDEFINE1         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE2         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE3         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE4         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE5         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE6         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE7         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE8         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE9         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE10        ] = InitAdvanced( InitAdvanced::All );

            s_aSupport[ DST_ORACLE_JDBC         ].bIgnoreCurrency = true;
        }
        return s_aSupport[ _eType ];
    }

    //--------------------------------------------------------------------
    static AuthenticationMode getAuthenticationMode( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, FeatureSupport >    Supported;

        static Supported s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MYSQL_ODBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_JDBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ORACLE_JDBC         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADABAS              ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_CALC                ] = FeatureSupport( AuthPwd     );
            s_aSupport[ DST_DBASE               ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_FLAT                ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_JDBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ODBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADO                 ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MOZILLA             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_THUNDERBIRD         ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_LDAP                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_OUTLOOK             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_OUTLOOKEXP          ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION           ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_KAB                 ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MSACCESS_2007       ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_USERDEFINE1         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE2         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE3         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE4         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE5         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE6         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE7         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE8         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE9         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE10        ] = FeatureSupport( AuthUserPwd );
        }
        return s_aSupport[ _eType ].eAuthentication;
    }

    //====================================================================
    //= DataSourceMetaData_Impl
    //====================================================================
    class DataSourceMetaData_Impl
    {
    public:
        DataSourceMetaData_Impl( DATASOURCE_TYPE _eType );

        inline DATASOURCE_TYPE getType() const { return m_eType; }

    private:
        DATASOURCE_TYPE m_eType;
    };

    //--------------------------------------------------------------------
    DataSourceMetaData_Impl::DataSourceMetaData_Impl( DATASOURCE_TYPE _eType )
        :m_eType( _eType )
    {
    }

    //====================================================================
    //= DataSourceMetaData
    //====================================================================
    //--------------------------------------------------------------------
    DataSourceMetaData::DataSourceMetaData( DATASOURCE_TYPE _eType )
        :m_pImpl( new DataSourceMetaData_Impl( _eType ) )
    {
    }

    //--------------------------------------------------------------------
    DataSourceMetaData::~DataSourceMetaData()
    {
    }

    //--------------------------------------------------------------------
    DATASOURCE_TYPE DataSourceMetaData::getType() const
    {
        return m_pImpl->getType();
    }

    //--------------------------------------------------------------------
    const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const
    {
        return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode DataSourceMetaData::getAuthentication() const
    {
        return getAuthenticationMode( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode  DataSourceMetaData::getAuthentication( DATASOURCE_TYPE _eType )
    {
        return getAuthenticationMode( _eType );
    }

//........................................................................
} // namespace dbaui
//........................................................................
<commit_msg>INTEGRATION: CWS dba30a (1.5.12); FILE MERGED 2008/02/20 21:31:56 fs 1.5.12.2: remove unused code Issue number:  #i86284# Submitted by:  cmc@openoffice.org Reviewed by:   fs@openoffice.org 2008/02/14 08:37:49 oj 1.5.12.1: #i86088# add url handling for sdbc:mysqlc:<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: dsmeta.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: kz $ $Date: 2008-03-05 17:05:29 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#include "dsmeta.hxx"

/** === begin UNO includes === **/
/** === end UNO includes === **/

#include <map>

//........................................................................
namespace dbaui
{
//........................................................................

    /** === begin UNO using === **/
    /** === end UNO using === **/

    struct InitAdvanced : public AdvancedSettingsSupport
    {
        // strange ctor, but makes instantiating this class more readable (see below)
        InitAdvanced( short _Generated, short _SQL, short _Append, short _As, short _Outer, short _Priv, short _Param,
                      short _Version, short _Catalog, short _Schema, short _Index, short _DOS, short _Required, short _Bool,short _IgnoreCur )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _Generated != 0 );
            bUseSQL92NamingConstraints     = ( _SQL       != 0 );
            bAppendTableAliasInSelect      = ( _Append    != 0 );
            bUseKeywordAsBeforeAlias       = ( _As        != 0 );
            bUseBracketedOuterJoinSyntax   = ( _Outer     != 0 );
            bIgnoreDriverPrivileges        = ( _Priv      != 0 );
            bParameterNameSubstitution     = ( _Param     != 0 );
            bDisplayVersionColumns         = ( _Version   != 0 );
            bUseCatalogInSelect            = ( _Catalog   != 0 );
            bUseSchemaInSelect             = ( _Schema    != 0 );
            bUseIndexDirectionKeyword      = ( _Index     != 0 );
            bUseDOSLineEnds                = ( _DOS       != 0 );
            bBooleanComparisonMode         = ( _Bool      != 0 );
            bFormsCheckRequiredFields      = ( _Required  != 0 );
            bIgnoreCurrency                = ( _IgnoreCur != 0 );
        }

        enum Special { All, None };

        InitAdvanced( Special _eType )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _eType == All );
            bUseSQL92NamingConstraints     = ( _eType == All );
            bAppendTableAliasInSelect      = ( _eType == All );
            bUseKeywordAsBeforeAlias       = ( _eType == All );
            bUseBracketedOuterJoinSyntax   = ( _eType == All );
            bIgnoreDriverPrivileges        = ( _eType == All );
            bParameterNameSubstitution     = ( _eType == All );
            bDisplayVersionColumns         = ( _eType == All );
            bUseCatalogInSelect            = ( _eType == All );
            bUseSchemaInSelect             = ( _eType == All );
            bUseIndexDirectionKeyword      = ( _eType == All );
            bUseDOSLineEnds                = ( _eType == All );
            bBooleanComparisonMode         = ( _eType == All );
            bFormsCheckRequiredFields      = ( _eType == All );
            bIgnoreCurrency                = false; // Oracle special
        }
    };

    struct FeatureSupport
    {
        // authentication mode of the data source
        AuthenticationMode      eAuthentication;

        FeatureSupport()
            :eAuthentication( AuthUserPwd )
        {
        }

        FeatureSupport( AuthenticationMode _Auth )
            :eAuthentication( _Auth )
        {
        }
    };

    //====================================================================
    //= global tables
    //====================================================================
    //--------------------------------------------------------------------
    static const AdvancedSettingsSupport& getAdvancedSettingsSupport( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, AdvancedSettingsSupport >    AdvancedSupport;

        static AdvancedSupport s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_ODBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_JDBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_NATIVE        ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_ORACLE_JDBC         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADABAS              ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_CALC                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_DBASE               ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
            s_aSupport[ DST_FLAT                ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            s_aSupport[ DST_JDBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ODBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADO                 ] = InitAdvanced( 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 );
            s_aSupport[ DST_MOZILLA             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_THUNDERBIRD         ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_LDAP                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOK             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOKEXP          ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION           ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_KAB                 ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_MSACCESS_2007       ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = InitAdvanced( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 );
            s_aSupport[ DST_USERDEFINE1         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE2         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE3         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE4         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE5         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE6         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE7         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE8         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE9         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE10        ] = InitAdvanced( InitAdvanced::All );

            s_aSupport[ DST_ORACLE_JDBC         ].bIgnoreCurrency = true;
        }
        return s_aSupport[ _eType ];
    }

    //--------------------------------------------------------------------
    static AuthenticationMode getAuthenticationMode( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, FeatureSupport >    Supported;

        static Supported s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MYSQL_NATIVE        ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_ODBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_JDBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ORACLE_JDBC         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADABAS              ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_CALC                ] = FeatureSupport( AuthPwd     );
            s_aSupport[ DST_DBASE               ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_FLAT                ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_JDBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ODBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADO                 ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MOZILLA             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_THUNDERBIRD         ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_LDAP                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_OUTLOOK             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_OUTLOOKEXP          ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION           ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_KAB                 ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MSACCESS_2007       ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_USERDEFINE1         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE2         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE3         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE4         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE5         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE6         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE7         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE8         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE9         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE10        ] = FeatureSupport( AuthUserPwd );
        }
        return s_aSupport[ _eType ].eAuthentication;
    }

    //====================================================================
    //= DataSourceMetaData_Impl
    //====================================================================
    class DataSourceMetaData_Impl
    {
    public:
        DataSourceMetaData_Impl( DATASOURCE_TYPE _eType );

        inline DATASOURCE_TYPE getType() const { return m_eType; }

    private:
        DATASOURCE_TYPE m_eType;
    };

    //--------------------------------------------------------------------
    DataSourceMetaData_Impl::DataSourceMetaData_Impl( DATASOURCE_TYPE _eType )
        :m_eType( _eType )
    {
    }

    //====================================================================
    //= DataSourceMetaData
    //====================================================================
    //--------------------------------------------------------------------
    DataSourceMetaData::DataSourceMetaData( DATASOURCE_TYPE _eType )
        :m_pImpl( new DataSourceMetaData_Impl( _eType ) )
    {
    }

    //--------------------------------------------------------------------
    DataSourceMetaData::~DataSourceMetaData()
    {
    }

    //--------------------------------------------------------------------
    const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const
    {
        return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode DataSourceMetaData::getAuthentication() const
    {
        return getAuthenticationMode( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode  DataSourceMetaData::getAuthentication( DATASOURCE_TYPE _eType )
    {
        return getAuthenticationMode( _eType );
    }

//........................................................................
} // namespace dbaui
//........................................................................
<|endoftext|>


<commit_before>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dptabdat.cxx,v $
 * $Revision: 1.14 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"

// INCLUDE ---------------------------------------------------------------

#include <rtl/math.hxx>
#include <tools/debug.hxx>
#include <tools/date.hxx>
#include <unotools/transliterationwrapper.hxx>
#include <unotools/collatorwrapper.hxx>

#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>

#include "dptabdat.hxx"
#include "global.hxx"
#include "dpcachetable.hxx"
#include "dptabres.hxx"

using namespace ::com::sun::star;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Any;
using ::std::vector;
using ::std::set;
using ::std::hash_map;

// -----------------------------------------------------------------------

BOOL ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
{
    //! pass Transliteration?
    //! inline?
    return bHasValue ? ( r.bHasValue && rtl::math::approxEqual( fValue, r.fValue ) ) :
                       ( !r.bHasValue &&
                        ScGlobal::pTransliteration->isEqual( aString, r.aString ) );
}

size_t ScDPItemData::Hash() const
{
    if ( bHasValue )
        return (size_t) rtl::math::approxFloor( fValue );
    else
        // If we do unicode safe case insensitive hash we can drop
        // ScDPItemData::operator== and use ::IsCasInsEqual
        return rtl_ustr_hashCode_WithLength( aString.GetBuffer(), aString.Len() );
}

BOOL ScDPItemData::operator==( const ScDPItemData& r ) const
{
    if ( bHasValue )
    {
        if ( r.bHasValue )
            return rtl::math::approxEqual( fValue, r.fValue );
        else
            return FALSE;
    }
    else if ( r.bHasValue )
        return FALSE;
    else
        // need exact equality until we have a safe case insensitive string hash
        return aString == r.aString;
}

sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
                                 const ScDPItemData& rB )
{
    if ( rA.bHasValue )
    {
        if ( rB.bHasValue )
        {
            if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
                return 0;
            else if ( rA.fValue < rB.fValue )
                return -1;
            else
                return 1;
        }
        else
            return -1;           // values first
    }
    else if ( rB.bHasValue )
        return 1;                // values first
    else
        return ScGlobal::pCollator->compareString( rA.aString, rB.aString );
}

// ---------------------------------------------------------------------------

ScDPTableData::CalcInfo::CalcInfo() :
    bRepeatIfEmpty(false)
{
}

// ---------------------------------------------------------------------------

ScDPTableData::ScDPTableData()
{
    nLastDateVal = nLastHier = nLastLevel = nLastRet = -1;      // invalid

    //! reset before new calculation (in case the base date is changed)
}

ScDPTableData::~ScDPTableData()
{
}

long ScDPTableData::GetDatePart( long nDateVal, long nHierarchy, long nLevel )
{
    if ( nDateVal == nLastDateVal && nHierarchy == nLastHier && nLevel == nLastLevel )
        return nLastRet;

    Date aDate( 30,12,1899 );                   //! get from source data (and cache here)
    aDate += nDateVal;

    long nRet = 0;
    switch (nHierarchy)
    {
        case SC_DAPI_HIERARCHY_QUARTER:
            switch (nLevel)
            {
                case 0: nRet = aDate.GetYear();                 break;
                case 1: nRet = (aDate.GetMonth()-1) / 3 + 1;    break;
                case 2: nRet = aDate.GetMonth();                break;
                case 3: nRet = aDate.GetDay();                  break;
                default:
                    DBG_ERROR("GetDatePart: wrong level");
            }
            break;
        case SC_DAPI_HIERARCHY_WEEK:
            switch (nLevel)
            {
                //! use settings for different definitions
                case 0: nRet = aDate.GetYear();                 break;      //!...
                case 1: nRet = aDate.GetWeekOfYear();           break;
                case 2: nRet = (long)aDate.GetDayOfWeek();      break;
                default:
                    DBG_ERROR("GetDatePart: wrong level");
            }
            break;
        default:
            DBG_ERROR("GetDatePart: wrong hierarchy");
    }

    nLastDateVal = nDateVal;
    nLastHier    = nHierarchy;
    nLastLevel   = nLevel;
    nLastRet     = nRet;

    return nRet;
}

bool ScDPTableData::IsRepeatIfEmpty()
{
    return false;
}

void ScDPTableData::CreateCacheTable()
{
    fprintf(stdout, "ScDPTableData::CreateCacheTable: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::FilterCacheTable(const vector<ScDPDimension*>& rPageDims)
{
    fprintf(stdout, "ScDPTableData::FilterCacheTable: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>&, Sequence< Sequence<Any> >&)
{
    fprintf(stdout, "ScDPTableData::GetDrillDownData: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
{
    fprintf(stdout, "ScDPTableData::CalcResults: un-implemented...\n");fflush(stdout);
}

UINT32 ScDPTableData::GetNumberFormat(long)
{
    return 0;           // default format
}

BOOL ScDPTableData::IsBaseForGroup(long) const
{
    return FALSE;       // always false
}

long ScDPTableData::GetGroupBase(long) const
{
    return -1;          // always none
}

BOOL ScDPTableData::IsNumOrDateGroup(long) const
{
    return FALSE;       // always false
}

BOOL ScDPTableData::IsInGroup( const ScDPItemData&, long,
                               const ScDPItemData&, long ) const
{
    DBG_ERROR("IsInGroup shouldn't be called for non-group data");
    return FALSE;
}

BOOL ScDPTableData::HasCommonElement( const ScDPItemData&, long,
                                      const ScDPItemData&, long ) const
{
    DBG_ERROR("HasCommonElement shouldn't be called for non-group data");
    return FALSE;
}

void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable,
                                        const CalcInfo& rInfo, CalcRowData& rData)
{
    // column dimensions
    GetItemData(rCacheTable, nRow, rInfo.aColLevelDims, rData.aColData);

    // row dimensions
    GetItemData(rCacheTable, nRow, rInfo.aRowLevelDims, rData.aRowData);

    // page dimensions
    GetItemData(rCacheTable, nRow, rInfo.aPageDims, rData.aPageData);

    sal_Int32 n = rInfo.aDataSrcCols.size();
    for (sal_Int32 i = 0; i < n; ++i)
    {
        long nDim = rInfo.aDataSrcCols[i];
        rData.aValues.push_back( ScDPValueData() );
        ScDPValueData& rVal = rData.aValues.back();
        const ScDPCacheTable::Cell* pCell = rCacheTable.getCell(nDim, nRow);
        if (pCell)
        {
            rVal.fValue = pCell->mbNumeric ? pCell->mfValue : 0.0;
            rVal.nType = pCell->mnType;
        }
        else
            rVal.Set(0.0, SC_VALTYPE_EMPTY);
    }
}

void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow)
{
    if (!bAutoShow)
    {
        rInfo.pColRoot->LateInitFrom(rInfo.aColDims, rInfo.aColLevels, rData.aColData, 0, *rInfo.pInitState);
        rInfo.pRowRoot->LateInitFrom(rInfo.aRowDims, rInfo.aRowLevels, rData.aRowData, 0, *rInfo.pInitState);
    }

    if ( ( !rInfo.pColRoot->GetChildDimension() || rInfo.pColRoot->GetChildDimension()->IsValidEntry(rData.aColData) ) &&
         ( !rInfo.pRowRoot->GetChildDimension() || rInfo.pRowRoot->GetChildDimension()->IsValidEntry(rData.aRowData) ) )
    {
        //! single process method with ColMembers, RowMembers and data !!!
        if (rInfo.pColRoot->GetChildDimension())
        {
            vector<ScDPItemData> aEmptyData;
            rInfo.pColRoot->GetChildDimension()->ProcessData(rData.aColData, NULL, aEmptyData, rData.aValues);
        }

        rInfo.pRowRoot->ProcessData(rData.aRowData, rInfo.pColRoot->GetChildDimension(),
                                    rData.aColData, rData.aValues);
    }
}

void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow)
{
    sal_Int32 nRowSize = rCacheTable.getRowSize();
    for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
    {
        if (!rCacheTable.isRowActive(nRow))
            continue;

        CalcRowData aData;
        FillRowDataFromCacheTable(nRow, rCacheTable, rInfo, aData);
        ProcessRowData(rInfo, aData, bAutoShow);
    }
}

void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
                                const vector<long>& rDims, vector<ScDPItemData>& rItemData)
{
    sal_Int32 nDimSize = rDims.size();
    for (sal_Int32 i = 0; i < nDimSize; ++i)
    {
        long nDim = rDims[i];
        rItemData.push_back( ScDPItemData() );
        ScDPItemData& rData = rItemData.back();
        if (getIsDataLayoutDimension(nDim))
        {
            rData.SetString(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("x")));
            continue;
        }

        const ScDPCacheTable::Cell* pCell = rCacheTable.getCell(nDim, nRow, IsRepeatIfEmpty());
        if (!pCell || pCell->mnType == SC_VALTYPE_EMPTY)
            continue;

        const String* pString = ScSharedString::getString(pCell->mnStrId);
        if (!pString)
            continue;

        rData.aString = *pString;
        rData.bHasValue = false;
        if (pCell->mbNumeric)
        {
            rData.bHasValue = true;
            rData.fValue = pCell->mfValue;
        }
    }
}

// -----------------------------------------------------------------------

<commit_msg>#i10000# warning fixed<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dptabdat.cxx,v $
 * $Revision: 1.15 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"

// INCLUDE ---------------------------------------------------------------

#include <rtl/math.hxx>
#include <tools/debug.hxx>
#include <tools/date.hxx>
#include <unotools/transliterationwrapper.hxx>
#include <unotools/collatorwrapper.hxx>

#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>

#include "dptabdat.hxx"
#include "global.hxx"
#include "dpcachetable.hxx"
#include "dptabres.hxx"

using namespace ::com::sun::star;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Any;
using ::std::vector;
using ::std::set;
using ::std::hash_map;

// -----------------------------------------------------------------------

BOOL ScDPItemData::IsCaseInsEqual( const ScDPItemData& r ) const
{
    //! pass Transliteration?
    //! inline?
    return bHasValue ? ( r.bHasValue && rtl::math::approxEqual( fValue, r.fValue ) ) :
                       ( !r.bHasValue &&
                        ScGlobal::pTransliteration->isEqual( aString, r.aString ) );
}

size_t ScDPItemData::Hash() const
{
    if ( bHasValue )
        return (size_t) rtl::math::approxFloor( fValue );
    else
        // If we do unicode safe case insensitive hash we can drop
        // ScDPItemData::operator== and use ::IsCasInsEqual
        return rtl_ustr_hashCode_WithLength( aString.GetBuffer(), aString.Len() );
}

BOOL ScDPItemData::operator==( const ScDPItemData& r ) const
{
    if ( bHasValue )
    {
        if ( r.bHasValue )
            return rtl::math::approxEqual( fValue, r.fValue );
        else
            return FALSE;
    }
    else if ( r.bHasValue )
        return FALSE;
    else
        // need exact equality until we have a safe case insensitive string hash
        return aString == r.aString;
}

sal_Int32 ScDPItemData::Compare( const ScDPItemData& rA,
                                 const ScDPItemData& rB )
{
    if ( rA.bHasValue )
    {
        if ( rB.bHasValue )
        {
            if ( rtl::math::approxEqual( rA.fValue, rB.fValue ) )
                return 0;
            else if ( rA.fValue < rB.fValue )
                return -1;
            else
                return 1;
        }
        else
            return -1;           // values first
    }
    else if ( rB.bHasValue )
        return 1;                // values first
    else
        return ScGlobal::pCollator->compareString( rA.aString, rB.aString );
}

// ---------------------------------------------------------------------------

ScDPTableData::CalcInfo::CalcInfo() :
    bRepeatIfEmpty(false)
{
}

// ---------------------------------------------------------------------------

ScDPTableData::ScDPTableData()
{
    nLastDateVal = nLastHier = nLastLevel = nLastRet = -1;      // invalid

    //! reset before new calculation (in case the base date is changed)
}

ScDPTableData::~ScDPTableData()
{
}

long ScDPTableData::GetDatePart( long nDateVal, long nHierarchy, long nLevel )
{
    if ( nDateVal == nLastDateVal && nHierarchy == nLastHier && nLevel == nLastLevel )
        return nLastRet;

    Date aDate( 30,12,1899 );                   //! get from source data (and cache here)
    aDate += nDateVal;

    long nRet = 0;
    switch (nHierarchy)
    {
        case SC_DAPI_HIERARCHY_QUARTER:
            switch (nLevel)
            {
                case 0: nRet = aDate.GetYear();                 break;
                case 1: nRet = (aDate.GetMonth()-1) / 3 + 1;    break;
                case 2: nRet = aDate.GetMonth();                break;
                case 3: nRet = aDate.GetDay();                  break;
                default:
                    DBG_ERROR("GetDatePart: wrong level");
            }
            break;
        case SC_DAPI_HIERARCHY_WEEK:
            switch (nLevel)
            {
                //! use settings for different definitions
                case 0: nRet = aDate.GetYear();                 break;      //!...
                case 1: nRet = aDate.GetWeekOfYear();           break;
                case 2: nRet = (long)aDate.GetDayOfWeek();      break;
                default:
                    DBG_ERROR("GetDatePart: wrong level");
            }
            break;
        default:
            DBG_ERROR("GetDatePart: wrong hierarchy");
    }

    nLastDateVal = nDateVal;
    nLastHier    = nHierarchy;
    nLastLevel   = nLevel;
    nLastRet     = nRet;

    return nRet;
}

bool ScDPTableData::IsRepeatIfEmpty()
{
    return false;
}

void ScDPTableData::CreateCacheTable()
{
    fprintf(stdout, "ScDPTableData::CreateCacheTable: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::FilterCacheTable(const vector<ScDPDimension*>&)
{
    fprintf(stdout, "ScDPTableData::FilterCacheTable: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>&, Sequence< Sequence<Any> >&)
{
    fprintf(stdout, "ScDPTableData::GetDrillDownData: un-implemented...\n");fflush(stdout);
}

void ScDPTableData::CalcResults(CalcInfo&, bool)
{
    fprintf(stdout, "ScDPTableData::CalcResults: un-implemented...\n");fflush(stdout);
}

UINT32 ScDPTableData::GetNumberFormat(long)
{
    return 0;           // default format
}

BOOL ScDPTableData::IsBaseForGroup(long) const
{
    return FALSE;       // always false
}

long ScDPTableData::GetGroupBase(long) const
{
    return -1;          // always none
}

BOOL ScDPTableData::IsNumOrDateGroup(long) const
{
    return FALSE;       // always false
}

BOOL ScDPTableData::IsInGroup( const ScDPItemData&, long,
                               const ScDPItemData&, long ) const
{
    DBG_ERROR("IsInGroup shouldn't be called for non-group data");
    return FALSE;
}

BOOL ScDPTableData::HasCommonElement( const ScDPItemData&, long,
                                      const ScDPItemData&, long ) const
{
    DBG_ERROR("HasCommonElement shouldn't be called for non-group data");
    return FALSE;
}

void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable,
                                        const CalcInfo& rInfo, CalcRowData& rData)
{
    // column dimensions
    GetItemData(rCacheTable, nRow, rInfo.aColLevelDims, rData.aColData);

    // row dimensions
    GetItemData(rCacheTable, nRow, rInfo.aRowLevelDims, rData.aRowData);

    // page dimensions
    GetItemData(rCacheTable, nRow, rInfo.aPageDims, rData.aPageData);

    sal_Int32 n = rInfo.aDataSrcCols.size();
    for (sal_Int32 i = 0; i < n; ++i)
    {
        long nDim = rInfo.aDataSrcCols[i];
        rData.aValues.push_back( ScDPValueData() );
        ScDPValueData& rVal = rData.aValues.back();
        const ScDPCacheTable::Cell* pCell = rCacheTable.getCell(nDim, nRow);
        if (pCell)
        {
            rVal.fValue = pCell->mbNumeric ? pCell->mfValue : 0.0;
            rVal.nType = pCell->mnType;
        }
        else
            rVal.Set(0.0, SC_VALTYPE_EMPTY);
    }
}

void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow)
{
    if (!bAutoShow)
    {
        rInfo.pColRoot->LateInitFrom(rInfo.aColDims, rInfo.aColLevels, rData.aColData, 0, *rInfo.pInitState);
        rInfo.pRowRoot->LateInitFrom(rInfo.aRowDims, rInfo.aRowLevels, rData.aRowData, 0, *rInfo.pInitState);
    }

    if ( ( !rInfo.pColRoot->GetChildDimension() || rInfo.pColRoot->GetChildDimension()->IsValidEntry(rData.aColData) ) &&
         ( !rInfo.pRowRoot->GetChildDimension() || rInfo.pRowRoot->GetChildDimension()->IsValidEntry(rData.aRowData) ) )
    {
        //! single process method with ColMembers, RowMembers and data !!!
        if (rInfo.pColRoot->GetChildDimension())
        {
            vector<ScDPItemData> aEmptyData;
            rInfo.pColRoot->GetChildDimension()->ProcessData(rData.aColData, NULL, aEmptyData, rData.aValues);
        }

        rInfo.pRowRoot->ProcessData(rData.aRowData, rInfo.pColRoot->GetChildDimension(),
                                    rData.aColData, rData.aValues);
    }
}

void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow)
{
    sal_Int32 nRowSize = rCacheTable.getRowSize();
    for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
    {
        if (!rCacheTable.isRowActive(nRow))
            continue;

        CalcRowData aData;
        FillRowDataFromCacheTable(nRow, rCacheTable, rInfo, aData);
        ProcessRowData(rInfo, aData, bAutoShow);
    }
}

void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
                                const vector<long>& rDims, vector<ScDPItemData>& rItemData)
{
    sal_Int32 nDimSize = rDims.size();
    for (sal_Int32 i = 0; i < nDimSize; ++i)
    {
        long nDim = rDims[i];
        rItemData.push_back( ScDPItemData() );
        ScDPItemData& rData = rItemData.back();
        if (getIsDataLayoutDimension(nDim))
        {
            rData.SetString(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("x")));
            continue;
        }

        const ScDPCacheTable::Cell* pCell = rCacheTable.getCell(nDim, nRow, IsRepeatIfEmpty());
        if (!pCell || pCell->mnType == SC_VALTYPE_EMPTY)
            continue;

        const String* pString = ScSharedString::getString(pCell->mnStrId);
        if (!pString)
            continue;

        rData.aString = *pString;
        rData.bHasValue = false;
        if (pCell->mbNumeric)
        {
            rData.bHasValue = true;
            rData.fValue = pCell->mfValue;
        }
    }
}

// -----------------------------------------------------------------------

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: dsmeta.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: kz $ $Date: 2008-03-05 17:05:29 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#include "dsmeta.hxx"

/** === begin UNO includes === **/
/** === end UNO includes === **/

#include <map>

//........................................................................
namespace dbaui
{
//........................................................................

    /** === begin UNO using === **/
    /** === end UNO using === **/

    struct InitAdvanced : public AdvancedSettingsSupport
    {
        // strange ctor, but makes instantiating this class more readable (see below)
        InitAdvanced( short _Generated, short _SQL, short _Append, short _As, short _Outer, short _Priv, short _Param,
                      short _Version, short _Catalog, short _Schema, short _Index, short _DOS, short _Required, short _Bool,short _IgnoreCur )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _Generated != 0 );
            bUseSQL92NamingConstraints     = ( _SQL       != 0 );
            bAppendTableAliasInSelect      = ( _Append    != 0 );
            bUseKeywordAsBeforeAlias       = ( _As        != 0 );
            bUseBracketedOuterJoinSyntax   = ( _Outer     != 0 );
            bIgnoreDriverPrivileges        = ( _Priv      != 0 );
            bParameterNameSubstitution     = ( _Param     != 0 );
            bDisplayVersionColumns         = ( _Version   != 0 );
            bUseCatalogInSelect            = ( _Catalog   != 0 );
            bUseSchemaInSelect             = ( _Schema    != 0 );
            bUseIndexDirectionKeyword      = ( _Index     != 0 );
            bUseDOSLineEnds                = ( _DOS       != 0 );
            bBooleanComparisonMode         = ( _Bool      != 0 );
            bFormsCheckRequiredFields      = ( _Required  != 0 );
            bIgnoreCurrency                = ( _IgnoreCur != 0 );
        }

        enum Special { All, None };

        InitAdvanced( Special _eType )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _eType == All );
            bUseSQL92NamingConstraints     = ( _eType == All );
            bAppendTableAliasInSelect      = ( _eType == All );
            bUseKeywordAsBeforeAlias       = ( _eType == All );
            bUseBracketedOuterJoinSyntax   = ( _eType == All );
            bIgnoreDriverPrivileges        = ( _eType == All );
            bParameterNameSubstitution     = ( _eType == All );
            bDisplayVersionColumns         = ( _eType == All );
            bUseCatalogInSelect            = ( _eType == All );
            bUseSchemaInSelect             = ( _eType == All );
            bUseIndexDirectionKeyword      = ( _eType == All );
            bUseDOSLineEnds                = ( _eType == All );
            bBooleanComparisonMode         = ( _eType == All );
            bFormsCheckRequiredFields      = ( _eType == All );
            bIgnoreCurrency                = false; // Oracle special
        }
    };

    struct FeatureSupport
    {
        // authentication mode of the data source
        AuthenticationMode      eAuthentication;

        FeatureSupport()
            :eAuthentication( AuthUserPwd )
        {
        }

        FeatureSupport( AuthenticationMode _Auth )
            :eAuthentication( _Auth )
        {
        }
    };

    //====================================================================
    //= global tables
    //====================================================================
    //--------------------------------------------------------------------
    static const AdvancedSettingsSupport& getAdvancedSettingsSupport( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, AdvancedSettingsSupport >    AdvancedSupport;

        static AdvancedSupport s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_ODBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_JDBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_NATIVE        ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_ORACLE_JDBC         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADABAS              ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_CALC                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_DBASE               ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
            s_aSupport[ DST_FLAT                ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            s_aSupport[ DST_JDBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ODBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADO                 ] = InitAdvanced( 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 );
            s_aSupport[ DST_MOZILLA             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_THUNDERBIRD         ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_LDAP                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOK             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOKEXP          ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION           ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_KAB                 ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_MSACCESS_2007       ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = InitAdvanced( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 );
            s_aSupport[ DST_USERDEFINE1         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE2         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE3         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE4         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE5         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE6         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE7         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE8         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE9         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE10        ] = InitAdvanced( InitAdvanced::All );

            s_aSupport[ DST_ORACLE_JDBC         ].bIgnoreCurrency = true;
        }
        return s_aSupport[ _eType ];
    }

    //--------------------------------------------------------------------
    static AuthenticationMode getAuthenticationMode( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, FeatureSupport >    Supported;

        static Supported s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MYSQL_NATIVE        ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_ODBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_JDBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ORACLE_JDBC         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADABAS              ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_CALC                ] = FeatureSupport( AuthPwd     );
            s_aSupport[ DST_DBASE               ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_FLAT                ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_JDBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ODBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADO                 ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MOZILLA             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_THUNDERBIRD         ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_LDAP                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_OUTLOOK             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_OUTLOOKEXP          ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION           ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_KAB                 ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MSACCESS_2007       ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_USERDEFINE1         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE2         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE3         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE4         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE5         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE6         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE7         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE8         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE9         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE10        ] = FeatureSupport( AuthUserPwd );
        }
        return s_aSupport[ _eType ].eAuthentication;
    }

    //====================================================================
    //= DataSourceMetaData_Impl
    //====================================================================
    class DataSourceMetaData_Impl
    {
    public:
        DataSourceMetaData_Impl( DATASOURCE_TYPE _eType );

        inline DATASOURCE_TYPE getType() const { return m_eType; }

    private:
        DATASOURCE_TYPE m_eType;
    };

    //--------------------------------------------------------------------
    DataSourceMetaData_Impl::DataSourceMetaData_Impl( DATASOURCE_TYPE _eType )
        :m_eType( _eType )
    {
    }

    //====================================================================
    //= DataSourceMetaData
    //====================================================================
    //--------------------------------------------------------------------
    DataSourceMetaData::DataSourceMetaData( DATASOURCE_TYPE _eType )
        :m_pImpl( new DataSourceMetaData_Impl( _eType ) )
    {
    }

    //--------------------------------------------------------------------
    DataSourceMetaData::~DataSourceMetaData()
    {
    }

    //--------------------------------------------------------------------
    const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const
    {
        return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode DataSourceMetaData::getAuthentication() const
    {
        return getAuthenticationMode( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode  DataSourceMetaData::getAuthentication( DATASOURCE_TYPE _eType )
    {
        return getAuthenticationMode( _eType );
    }

//........................................................................
} // namespace dbaui
//........................................................................
<commit_msg>INTEGRATION: CWS changefileheader (1.6.12); FILE MERGED 2008/03/31 13:27:54 rt 1.6.12.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: dsmeta.cxx,v $
 * $Revision: 1.7 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#include "dsmeta.hxx"

/** === begin UNO includes === **/
/** === end UNO includes === **/

#include <map>

//........................................................................
namespace dbaui
{
//........................................................................

    /** === begin UNO using === **/
    /** === end UNO using === **/

    struct InitAdvanced : public AdvancedSettingsSupport
    {
        // strange ctor, but makes instantiating this class more readable (see below)
        InitAdvanced( short _Generated, short _SQL, short _Append, short _As, short _Outer, short _Priv, short _Param,
                      short _Version, short _Catalog, short _Schema, short _Index, short _DOS, short _Required, short _Bool,short _IgnoreCur )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _Generated != 0 );
            bUseSQL92NamingConstraints     = ( _SQL       != 0 );
            bAppendTableAliasInSelect      = ( _Append    != 0 );
            bUseKeywordAsBeforeAlias       = ( _As        != 0 );
            bUseBracketedOuterJoinSyntax   = ( _Outer     != 0 );
            bIgnoreDriverPrivileges        = ( _Priv      != 0 );
            bParameterNameSubstitution     = ( _Param     != 0 );
            bDisplayVersionColumns         = ( _Version   != 0 );
            bUseCatalogInSelect            = ( _Catalog   != 0 );
            bUseSchemaInSelect             = ( _Schema    != 0 );
            bUseIndexDirectionKeyword      = ( _Index     != 0 );
            bUseDOSLineEnds                = ( _DOS       != 0 );
            bBooleanComparisonMode         = ( _Bool      != 0 );
            bFormsCheckRequiredFields      = ( _Required  != 0 );
            bIgnoreCurrency                = ( _IgnoreCur != 0 );
        }

        enum Special { All, None };

        InitAdvanced( Special _eType )
            :AdvancedSettingsSupport()
        {
            bGeneratedValues               = ( _eType == All );
            bUseSQL92NamingConstraints     = ( _eType == All );
            bAppendTableAliasInSelect      = ( _eType == All );
            bUseKeywordAsBeforeAlias       = ( _eType == All );
            bUseBracketedOuterJoinSyntax   = ( _eType == All );
            bIgnoreDriverPrivileges        = ( _eType == All );
            bParameterNameSubstitution     = ( _eType == All );
            bDisplayVersionColumns         = ( _eType == All );
            bUseCatalogInSelect            = ( _eType == All );
            bUseSchemaInSelect             = ( _eType == All );
            bUseIndexDirectionKeyword      = ( _eType == All );
            bUseDOSLineEnds                = ( _eType == All );
            bBooleanComparisonMode         = ( _eType == All );
            bFormsCheckRequiredFields      = ( _eType == All );
            bIgnoreCurrency                = false; // Oracle special
        }
    };

    struct FeatureSupport
    {
        // authentication mode of the data source
        AuthenticationMode      eAuthentication;

        FeatureSupport()
            :eAuthentication( AuthUserPwd )
        {
        }

        FeatureSupport( AuthenticationMode _Auth )
            :eAuthentication( _Auth )
        {
        }
    };

    //====================================================================
    //= global tables
    //====================================================================
    //--------------------------------------------------------------------
    static const AdvancedSettingsSupport& getAdvancedSettingsSupport( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, AdvancedSettingsSupport >    AdvancedSupport;

        static AdvancedSupport s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_ODBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_JDBC          ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_MYSQL_NATIVE        ] = InitAdvanced( 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_ORACLE_JDBC         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADABAS              ] = InitAdvanced( 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_CALC                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_DBASE               ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
            s_aSupport[ DST_FLAT                ] = InitAdvanced( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
            s_aSupport[ DST_JDBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ODBC                ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_ADO                 ] = InitAdvanced( 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 );
            s_aSupport[ DST_MOZILLA             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_THUNDERBIRD         ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_LDAP                ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOK             ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_OUTLOOKEXP          ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION           ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_KAB                 ] = InitAdvanced( InitAdvanced::None );
            s_aSupport[ DST_MSACCESS_2007       ] = InitAdvanced( 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = InitAdvanced( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 );
            s_aSupport[ DST_USERDEFINE1         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE2         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE3         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE4         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE5         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE6         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE7         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE8         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE9         ] = InitAdvanced( InitAdvanced::All );
            s_aSupport[ DST_USERDEFINE10        ] = InitAdvanced( InitAdvanced::All );

            s_aSupport[ DST_ORACLE_JDBC         ].bIgnoreCurrency = true;
        }
        return s_aSupport[ _eType ];
    }

    //--------------------------------------------------------------------
    static AuthenticationMode getAuthenticationMode( DATASOURCE_TYPE _eType )
    {
        typedef ::std::map< DATASOURCE_TYPE, FeatureSupport >    Supported;

        static Supported s_aSupport;
        if ( s_aSupport.empty() )
        {
            s_aSupport[ DST_MSACCESS            ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MYSQL_NATIVE        ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_ODBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MYSQL_JDBC          ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ORACLE_JDBC         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADABAS              ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_CALC                ] = FeatureSupport( AuthPwd     );
            s_aSupport[ DST_DBASE               ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_FLAT                ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_JDBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ODBC                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_ADO                 ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_MOZILLA             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_THUNDERBIRD         ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_LDAP                ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_OUTLOOK             ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_OUTLOOKEXP          ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION           ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_GROUPWISE ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EVOLUTION_LDAP      ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_KAB                 ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_MSACCESS_2007       ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_EMBEDDED_HSQLDB     ] = FeatureSupport( AuthNone    );
            s_aSupport[ DST_USERDEFINE1         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE2         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE3         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE4         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE5         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE6         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE7         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE8         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE9         ] = FeatureSupport( AuthUserPwd );
            s_aSupport[ DST_USERDEFINE10        ] = FeatureSupport( AuthUserPwd );
        }
        return s_aSupport[ _eType ].eAuthentication;
    }

    //====================================================================
    //= DataSourceMetaData_Impl
    //====================================================================
    class DataSourceMetaData_Impl
    {
    public:
        DataSourceMetaData_Impl( DATASOURCE_TYPE _eType );

        inline DATASOURCE_TYPE getType() const { return m_eType; }

    private:
        DATASOURCE_TYPE m_eType;
    };

    //--------------------------------------------------------------------
    DataSourceMetaData_Impl::DataSourceMetaData_Impl( DATASOURCE_TYPE _eType )
        :m_eType( _eType )
    {
    }

    //====================================================================
    //= DataSourceMetaData
    //====================================================================
    //--------------------------------------------------------------------
    DataSourceMetaData::DataSourceMetaData( DATASOURCE_TYPE _eType )
        :m_pImpl( new DataSourceMetaData_Impl( _eType ) )
    {
    }

    //--------------------------------------------------------------------
    DataSourceMetaData::~DataSourceMetaData()
    {
    }

    //--------------------------------------------------------------------
    const AdvancedSettingsSupport& DataSourceMetaData::getAdvancedSettingsSupport() const
    {
        return ::dbaui::getAdvancedSettingsSupport( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode DataSourceMetaData::getAuthentication() const
    {
        return getAuthenticationMode( m_pImpl->getType() );
    }

    //--------------------------------------------------------------------
    AuthenticationMode  DataSourceMetaData::getAuthentication( DATASOURCE_TYPE _eType )
    {
        return getAuthenticationMode( _eType );
    }

//........................................................................
} // namespace dbaui
//........................................................................
<|endoftext|>


<commit_before>
#include "ffmpegvideoread.h"
#include <thread>
#include <iostream>
#include <exception>

namespace sgraph{

//stream_ffmpegi::stream_ffmpegi(uint8_t * data[4], enum AVPixelFormat pix_fmt) : sgstream()
//{
	/**av_image_fill_pointers 	(data,pix_fmt,height,
		this->ptr,
		const int  	linesizes[4]
	) 	*/

//}

ffmpegvideoread::ffmpegvideoread(double freq, int64_t blocking, std::string sourcepath, std::string sourceprovider): sgactor(freq, blocking)
{
	this->sourcepath=sourcepath;
	this->sourceprovider=sourceprovider;
}

void ffmpegvideoread::enter(const std::vector<sgstreamspec*> &in,const std::vector<std::string> &out)
{
	int errorno;
	ffmpeg::av_register_all();
	//needed?
	ffmpeg::avcodec_register_all();

	if (in.size()!=0 || out.size()!=1)
		throw(sgraph::sgraphStreamException("invalid amount of in- or outstreams"));

	ffmpeg::AVInputFormat *input_device_format=NULL;
	if (this->sourceprovider!="")
	{
		//needed?
		ffmpeg::avdevice_register_all();
		input_device_format = ffmpeg::av_input_video_device_next(input_device_format);
		while (input_device_format!=NULL)
		{
			if(strcmp(this->sourceprovider.c_str(), input_device_format->name)==0)
				break;
			input_device_format = ffmpeg::av_input_video_device_next(input_device_format);
		}

		if (input_device_format==NULL)
		{
			throw(sgraphException("Error: finding video input format failed"));
		}
	}

	errorno =  ffmpeg::avformat_open_input (&this->form_context, this->sourcepath.c_str(), NULL, NULL);
	if (errorno<0)
	{
		throw(sgraphException("Error: opening video file failed"));
	}
	ffmpeg::av_dump_format(this->form_context, 0, this->sourcepath.c_str(), 0);

	this->video_stream_index = ffmpeg::av_find_best_stream(this->form_context, ffmpeg::AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
	if(this->video_stream_index < 0)
	{
		throw(sgraphException("Error: no videostream found"));
	}
	this->cod_context = this->form_context->streams[this->video_stream_index]->codec;
	//av_opt_set_int(this->codec, "refcounted_frames", 1, 0);
	this->codec = ffmpeg::avcodec_find_decoder(this->cod_context->codec_id);
	if (this->codec == NULL) {
		throw(sgraphException("Error: unsupported codec"));
	}

	// init the video decoder
	errorno = ffmpeg::avcodec_open2(this->cod_context, this->codec, NULL);
	if (errorno < 0) {
		throw(sgraphException("Error: codec could not be opened"));
	}

	this->getManager()->updateStreamspec(out[0], new spec_ffmpegi(this->cod_context, 4));

	ffmpeg::av_init_packet(&this->packet);
	this->frame = ffmpeg::av_frame_alloc();
	this->intern_thread=new std::thread(sgactor::thread_wrapper, this);
}
void ffmpegvideoread::run(const std::vector<std::shared_ptr<sgstream>> )
{
	//this->packet.data=0;
	//this->packet.size=0;
	if (ffmpeg::av_read_frame(this->form_context, &this->packet)<0)
		return;
	// dismiss wrong packets
	std::cout << "read1\n";
	while(packet.stream_index!=this->video_stream_index)
	{
		if (ffmpeg::av_read_frame(this->form_context, &this->packet)<0)
			return;
	}
	std::cout << "read2\n";

	//this->input_device_format->read_packet(this->form_context, this->packet);
	//av_read_frame(&this->contex, &packet)
	ffmpeg::avcodec_decode_video2(this->cod_context, this->origframe, &this->got_frame, &this->packet);
	if (this->got_frame==0)
		return;
	int size = ffmpeg::av_image_get_buffer_size(ffmpeg::AV_PIX_FMT_RGBA64, this->origframe->width, this->origframe->height, 0);
	std::cout << size << std::endl;
	uint8_t *buffer=(uint8_t*)calloc(sizeof(uint8_t),size);
	ffmpeg::sws_scale(sws_ctx, (uint8_t const * const *)this->frame->data,
			 this->frame->linesize, 0, this->cod_context->height,
			 pFrameRGB->data, pFrameRGB->linesize)
	ffmpeg::av_image_copy_to_buffer(buffer,size, this->frame->data, this->frame->linesize, ffmpeg::AV_PIX_FMT_RGBA64, this->frame->width, this->frame->height, 0);
	this->streamsout[0]->updateStream(new stream_data(buffer, size));
	//this->packet.data=0;
	//this->packet.size=0;

}
void ffmpegvideoread::leave()
{

	//if (this->input_device_format)
	//	av_freep (this->input_device_format);
	// Close the codec
	// Close the video file
	ffmpeg::av_frame_free(&this->origframe);
	ffmpeg::av_frame_free(&this->convertframe);
	ffmpeg::av_free_packet(&this->packet);

	ffmpeg::avcodec_close (this->cod_context);
	this->cod_context = 0;

	ffmpeg::avformat_close_input (&this->form_context);
	this->form_context = 0;

}

ffmpegvideoread::~ffmpegvideoread()
{

	//if (this->input_device_format)
	//	av_freep (this->input_device_format);
	// Close the codec
	if (this->cod_context)
		ffmpeg::avcodec_close (this->cod_context);
	// Close the video file
	if (this->form_context)
		ffmpeg::avformat_close_input (&this->form_context);

}

}
<commit_msg>fix build<commit_after>
#include "ffmpegvideoread.h"
#include <thread>
#include <iostream>
#include <exception>

namespace sgraph{

//stream_ffmpegi::stream_ffmpegi(uint8_t * data[4], enum AVPixelFormat pix_fmt) : sgstream()
//{
	/**av_image_fill_pointers 	(data,pix_fmt,height,
		this->ptr,
		const int  	linesizes[4]
	) 	*/

//}

ffmpegvideoread::ffmpegvideoread(double freq, int64_t blocking, std::string sourcepath, std::string sourceprovider): sgactor(freq, blocking)
{
	this->sourcepath=sourcepath;
	this->sourceprovider=sourceprovider;
}

void ffmpegvideoread::enter(const std::vector<sgstreamspec*> &in,const std::vector<std::string> &out)
{
	int errorno;
	ffmpeg::av_register_all();
	//needed?
	ffmpeg::avcodec_register_all();

	if (in.size()!=0 || out.size()!=1)
		throw(sgraph::sgraphStreamException("invalid amount of in- or outstreams"));

	ffmpeg::AVInputFormat *input_device_format=NULL;
	if (this->sourceprovider!="")
	{
		//needed?
		ffmpeg::avdevice_register_all();
		input_device_format = ffmpeg::av_input_video_device_next(input_device_format);
		while (input_device_format!=NULL)
		{
			if(strcmp(this->sourceprovider.c_str(), input_device_format->name)==0)
				break;
			input_device_format = ffmpeg::av_input_video_device_next(input_device_format);
		}

		if (input_device_format==NULL)
		{
			throw(sgraphException("Error: finding video input format failed"));
		}
	}

	errorno =  ffmpeg::avformat_open_input (&this->form_context, this->sourcepath.c_str(), NULL, NULL);
	if (errorno<0)
	{
		throw(sgraphException("Error: opening video file failed"));
	}
	ffmpeg::av_dump_format(this->form_context, 0, this->sourcepath.c_str(), 0);

	this->video_stream_index = ffmpeg::av_find_best_stream(this->form_context, ffmpeg::AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
	if(this->video_stream_index < 0)
	{
		throw(sgraphException("Error: no videostream found"));
	}
	this->cod_context = this->form_context->streams[this->video_stream_index]->codec;
	//av_opt_set_int(this->codec, "refcounted_frames", 1, 0);
	this->codec = ffmpeg::avcodec_find_decoder(this->cod_context->codec_id);
	if (this->codec == NULL) {
		throw(sgraphException("Error: unsupported codec"));
	}

	// init the video decoder
	errorno = ffmpeg::avcodec_open2(this->cod_context, this->codec, NULL);
	if (errorno < 0) {
		throw(sgraphException("Error: codec could not be opened"));
	}

	this->getManager()->updateStreamspec(out[0], new spec_ffmpegi(this->cod_context, 4));

	ffmpeg::av_init_packet(&this->packet);
	this->origframe = ffmpeg::av_frame_alloc();
	this->convertframe = ffmpeg::av_frame_alloc();
	this->intern_thread=new std::thread(sgactor::thread_wrapper, this);
}
void ffmpegvideoread::run(const std::vector<std::shared_ptr<sgstream>> )
{
	//this->packet.data=0;
	//this->packet.size=0;
	if (ffmpeg::av_read_frame(this->form_context, &this->packet)<0)
		return;
	// dismiss wrong packets
	//std::cout << "read1\n";
	while(packet.stream_index!=this->video_stream_index)
	{
		if (ffmpeg::av_read_frame(this->form_context, &this->packet)<0)
			return;
	}
	//std::cout << "read2\n";

	//this->input_device_format->read_packet(this->form_context, this->packet);
	//av_read_frame(&this->contex, &packet)
	ffmpeg::avcodec_decode_video2(this->cod_context, this->origframe, &this->got_frame, &this->packet);
	if (this->got_frame==0)
		return;
	int size = ffmpeg::av_image_get_buffer_size(ffmpeg::AV_PIX_FMT_RGBA64, this->origframe->width, this->origframe->height, 0);
	//std::cout << size << std::endl;
	//uint8_t *buffer=(uint8_t*)calloc(sizeof(uint8_t),size);
	//ffmpeg::sws_scale(sws_ctx, (uint8_t const * const *)this->origframe->data,
	//		 this->convertframe->linesize, 0, this->cod_context->height,
	//		 pFrameRGB->data, pFrameRGB->linesize)
	//ffmpeg::av_image_copy_to_buffer(buffer,size, this->convertframe->data, this->convertframe->linesize, ffmpeg::AV_PIX_FMT_RGBA64, this->convertframe->width, this->convertframe->height, 0);
	//this->streamsout[0]->updateStream(new stream_data(buffer, size));
	//this->packet.data=0;
	//this->packet.size=0;

}
void ffmpegvideoread::leave()
{

	//if (this->input_device_format)
	//	av_freep (this->input_device_format);
	// Close the codec
	// Close the video file
	ffmpeg::av_frame_free(&this->origframe);
	ffmpeg::av_frame_free(&this->convertframe);
	ffmpeg::av_free_packet(&this->packet);

	ffmpeg::avcodec_close (this->cod_context);
	this->cod_context = 0;

	ffmpeg::avformat_close_input (&this->form_context);
	this->form_context = 0;

}

ffmpegvideoread::~ffmpegvideoread()
{

	//if (this->input_device_format)
	//	av_freep (this->input_device_format);
	// Close the codec
	if (this->cod_context)
		ffmpeg::avcodec_close (this->cod_context);
	// Close the video file
	if (this->form_context)
		ffmpeg::avformat_close_input (&this->form_context);

}

}
<|endoftext|>


<commit_before><commit_msg>oculusDK2 Plugin<commit_after><|endoftext|>