diff options
61 files changed, 1322 insertions, 6078 deletions
diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 7e9b2df14981..7dbc59e0cde8 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -63,6 +63,11 @@ namespace com } } +namespace rtl +{ + class OUStringBuffer; +} + namespace connectivity { class OSQLParser; @@ -337,7 +342,8 @@ namespace connectivity #if OSL_DEBUG_LEVEL > 0 // zeigt den ParseTree mit tabs und linefeeds - void showParseTree(::rtl::OUString& rString, sal_uInt32 nLevel=0); + void showParseTree( ::rtl::OUString& rString ) const; + void showParseTree( ::rtl::OUStringBuffer& _inout_rBuf, sal_uInt32 nLevel ) const; #endif // GetNodeType gibt den Knotentyp zurueck diff --git a/connectivity/inc/connectivity/warningscontainer.hxx b/connectivity/inc/connectivity/warningscontainer.hxx new file mode 100644 index 000000000000..6a6f473c87ed --- /dev/null +++ b/connectivity/inc/connectivity/warningscontainer.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * 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: warnings.hxx,v $ + * $Revision: 1.6 $ + * + * 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. + * + ************************************************************************/ + +#ifndef DBTOOLS_WARNINGSCONTAINER_HXX +#define DBTOOLS_WARNINGSCONTAINER_HXX + +/** ==== begin UNO includes === **/ +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +/** ==== end UNO includes === **/ + +#include "connectivity/dbtoolsdllapi.hxx" + +//......................................................................... +namespace dbtools +{ +//......................................................................... + + //===================================================================== + //= IWarningsContainer + //===================================================================== + class SAL_NO_VTABLE IWarningsContainer + { + public: + virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning) = 0; + virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning) = 0; + virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext) = 0; + }; + + //==================================================================== + //= WarningsContainer + //==================================================================== + /** helper class for implementing XWarningsSupplier, which mixes own warnings with + warnings obtained from an external instance + */ + class OOO_DLLPUBLIC_DBTOOLS WarningsContainer : public IWarningsContainer + { + private: + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier > m_xExternalWarnings; + ::com::sun::star::uno::Any m_aOwnWarnings; + + public: + WarningsContainer() { } + WarningsContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings ) + :m_xExternalWarnings( _rxExternalWarnings ) + { + } + virtual ~WarningsContainer(); + + void setExternalWarnings( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings ) + { + m_xExternalWarnings = _rxExternalWarnings; + } + + // convenience + /** appends an SQLWarning instance to the chain + @param _rWarning + the warning message + @param _pAsciiSQLState + the SQLState of the warning + @param _rxContext + the context of the warning + */ + void appendWarning( + const ::rtl::OUString& _rWarning, + const sal_Char* _pAsciiSQLState, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext ); + + // IWarningsContainer + virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning); + virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning); + virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext); + + // XWarningsSupplier equivalents + ::com::sun::star::uno::Any SAL_CALL getWarnings( ) const; + void SAL_CALL clearWarnings( ); + }; + +//......................................................................... +} // namespace dbtools +//......................................................................... + +#endif // DBTOOLS_WARNINGSCONTAINER_HXX diff --git a/connectivity/prj/build.lst b/connectivity/prj/build.lst index e7f761db0b6f..4a35e4af2120 100644 --- a/connectivity/prj/build.lst +++ b/connectivity/prj/build.lst @@ -13,7 +13,6 @@ cn connectivity\source\drivers\mozab\bootstrap nmake - all cn_mozab_boo cn connectivity\source\drivers\mozab nmake - all cn_mozab cn_mozab_bootstrap cn_dbtools cn_inc NULL cn connectivity\source\drivers\kab nmake - u cn_kab cn_dbtools cn_inc NULL cn connectivity\source\drivers\macab nmake - u cn_macab cn_dbtools cn_inc NULL -cn connectivity\source\drivers\evoab nmake - u cn_evoab cn_dbtools cn_file cn_inc NULL cn connectivity\source\drivers\evoab2 nmake - u cn_evoab2 cn_dbtools cn_file cn_inc NULL cn connectivity\source\drivers\calc nmake - all cn_calc cn_file cn_inc NULL cn connectivity\source\drivers\odbcbase nmake - all cn_odbcbase cn_dbtools cn_inc NULL diff --git a/connectivity/prj/d.lst b/connectivity/prj/d.lst index 3aa644a2c62b..36d93ca2c35b 100644 --- a/connectivity/prj/d.lst +++ b/connectivity/prj/d.lst @@ -16,7 +16,6 @@ ..\source\drivers\odbc\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\drivers\mozab\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\drivers\evoab2\*.xml %_DEST%\xml%_EXT%\*.xml -..\source\drivers\evoab\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\drivers\calc\*.xml %_DEST%\xml%_EXT%\*.xml ..\source\drivers\mysql\*.xml %_DEST%\xml%_EXT%\*.xml ..\%__SRC%\class\*.jar %_DEST%\bin%_EXT%\*.jar diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 67c4907b2de5..cc842f56e008 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -752,6 +752,7 @@ void collectColumnInformation(const Reference< XConnection>& _xConnection, Reference< XResultSetMetaData > xMeta( xSuppMeta->getMetaData(), UNO_QUERY_THROW ); sal_Int32 nCount = xMeta->getColumnCount(); + OSL_ENSURE( nCount != 0, "::dbtools::collectColumnInformation: result set has empty (column-less) meta data!" ); for (sal_Int32 i=1; i <= nCount ; ++i) { _rInfo.insert(ColumnInformationMap::value_type(xMeta->getColumnName(i), diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index 5b8287f6c826..a9c942ec9cb2 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -85,7 +85,8 @@ EXCEPTIONSFILES=\ $(SLO)$/filtermanager.obj \ $(SLO)$/parameters.obj \ $(SLO)$/ParamterSubstitution.obj \ - $(SLO)$/formattedcolumnvalue.obj + $(SLO)$/formattedcolumnvalue.obj \ + $(SLO)$/warningscontainer.obj SLOFILES=\ $(EXCEPTIONSFILES) \ diff --git a/connectivity/source/commontools/warningscontainer.cxx b/connectivity/source/commontools/warningscontainer.cxx new file mode 100644 index 000000000000..c3cf42b94fb7 --- /dev/null +++ b/connectivity/source/commontools/warningscontainer.cxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * 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: warnings.cxx,v $ + * $Revision: 1.5 $ + * + * 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_connectivity.hxx" + +#include "connectivity/warningscontainer.hxx" +#include "connectivity/dbexception.hxx" + +#include <osl/diagnose.h> + +//........................................................................ +namespace dbtools +{ +//........................................................................ + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdbc; + using namespace ::com::sun::star::sdb; + + //==================================================================== + //= WarningsContainer + //==================================================================== + //-------------------------------------------------------------------- + static void lcl_concatWarnings( Any& _rChainLeft, const Any& _rChainRight ) + { + if ( !_rChainLeft.hasValue() ) + _rChainLeft = _rChainRight; + else + { + // to travel the chain by reference (and not by value), we need the getValue ... + // looks like a hack, but the meaning of getValue is documented, and it's the only chance for reference-traveling .... + + OSL_ENSURE( SQLExceptionInfo( _rChainLeft ).isValid(), + "lcl_concatWarnings: invalid warnings chain (this will crash)!" ); + + const SQLException* pChainTravel = static_cast< const SQLException* >( _rChainLeft.getValue() ); + SQLExceptionIteratorHelper aReferenceIterHelper( *pChainTravel ); + while ( aReferenceIterHelper.hasMoreElements() ) + pChainTravel = aReferenceIterHelper.next(); + + // reached the end of the chain, and pChainTravel points to the last element + const_cast< SQLException* >( pChainTravel )->NextException = _rChainRight; + } + } + + //-------------------------------------------------------------------- + WarningsContainer::~WarningsContainer() + { + } + + //-------------------------------------------------------------------- + void WarningsContainer::appendWarning(const SQLException& _rWarning) + { + lcl_concatWarnings( m_aOwnWarnings, makeAny( _rWarning ) ); + } + + //-------------------------------------------------------------------- + void WarningsContainer::appendWarning( const SQLContext& _rContext ) + { + lcl_concatWarnings( m_aOwnWarnings, makeAny( _rContext )); + } + + //-------------------------------------------------------------------- + void WarningsContainer::appendWarning(const SQLWarning& _rWarning) + { + lcl_concatWarnings( m_aOwnWarnings, makeAny( _rWarning ) ); + } + + //-------------------------------------------------------------------- + Any SAL_CALL WarningsContainer::getWarnings( ) const + { + Any aAllWarnings; + if ( m_xExternalWarnings.is() ) + aAllWarnings = m_xExternalWarnings->getWarnings(); + + if ( m_aOwnWarnings.hasValue() ) + lcl_concatWarnings( aAllWarnings, m_aOwnWarnings ); + + return aAllWarnings; + } + + //-------------------------------------------------------------------- + void SAL_CALL WarningsContainer::clearWarnings( ) + { + if ( m_xExternalWarnings.is() ) + m_xExternalWarnings->clearWarnings(); + m_aOwnWarnings.clear(); + } + + //-------------------------------------------------------------------- + void WarningsContainer::appendWarning( const ::rtl::OUString& _rWarning, const sal_Char* _pAsciiSQLState, const Reference< XInterface >& _rxContext ) + { + appendWarning( SQLWarning( _rWarning, _rxContext, ::rtl::OUString::createFromAscii( _pAsciiSQLState ), 0, Any() ) ); + } + +//........................................................................ +} // namespace dbtools +//........................................................................ diff --git a/connectivity/source/drivers/evoab/LCatalog.cxx b/connectivity/source/drivers/evoab/LCatalog.cxx deleted file mode 100644 index 713af210ac38..000000000000 --- a/connectivity/source/drivers/evoab/LCatalog.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************* - * - * 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: LCatalog.cxx,v $ - * $Revision: 1.5 $ - * - * 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_connectivity.hxx" - - -#include "LCatalog.hxx" -#include "LConnection.hxx" -#include "LTables.hxx" -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; - -// ------------------------------------------------------------------------- -using namespace connectivity::evoab; -// ------------------------------------------------------------------------- -OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) : file::OFileCatalog(_pCon) -{ -} -// ------------------------------------------------------------------------- -void OEvoabCatalog::refreshTables() -{ - TStringVector aVector; - Sequence< ::rtl::OUString > aTypes; - Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), - ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); - - if(xResult.is()) - { - Reference< XRow > xRow(xResult,UNO_QUERY); - while(xResult->next()) - aVector.push_back(xRow->getString(3)); - } - if(m_pTables) - m_pTables->reFill(aVector); - else - m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector); -} -// ----------------------------------------------------------------------------- - - - diff --git a/connectivity/source/drivers/evoab/LCatalog.hxx b/connectivity/source/drivers/evoab/LCatalog.hxx deleted file mode 100644 index e539db3a8fc3..000000000000 --- a/connectivity/source/drivers/evoab/LCatalog.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * 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: LCatalog.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LCATALOG_HXX_ -#define _CONNECTIVITY_EVOAB_LCATALOG_HXX_ - -#include "file/FCatalog.hxx" - -namespace connectivity -{ - namespace evoab - { - class OEvoabConnection; - class OEvoabCatalog : public file::OFileCatalog - { - public: - virtual void refreshTables(); - - public: - OEvoabCatalog(OEvoabConnection* _pCon); - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LCATALOG_HXX_ - diff --git a/connectivity/source/drivers/evoab/LColumnAlias.cxx b/connectivity/source/drivers/evoab/LColumnAlias.cxx deleted file mode 100644 index 30b94e2e20c9..000000000000 --- a/connectivity/source/drivers/evoab/LColumnAlias.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/************************************************************************* - * - * 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: LColumnAlias.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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "LColumnAlias.hxx" -#include "LDriver.hxx" -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include "LConfigAccess.hxx" - -using namespace ::connectivity; -using namespace ::connectivity::evoab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; - -static const ::rtl::OUString sProgrammaticNames[] = -{ - ::rtl::OUString::createFromAscii("FirstName"), - ::rtl::OUString::createFromAscii("LastName"), - ::rtl::OUString::createFromAscii("DisplayName"), - ::rtl::OUString::createFromAscii("NickName"), - ::rtl::OUString::createFromAscii("PrimaryEmail"), - ::rtl::OUString::createFromAscii("SecondEmail"), - ::rtl::OUString::createFromAscii("PreferMailFormat"), - ::rtl::OUString::createFromAscii("WorkPhone"), - ::rtl::OUString::createFromAscii("HomePhone"), - ::rtl::OUString::createFromAscii("FaxNumber"), - ::rtl::OUString::createFromAscii("PagerNumber"), - ::rtl::OUString::createFromAscii("CellularNumber"), - ::rtl::OUString::createFromAscii("HomeAddress"), - ::rtl::OUString::createFromAscii("HomeAddress2"), - ::rtl::OUString::createFromAscii("HomeCity"), - ::rtl::OUString::createFromAscii("HomeState"), - ::rtl::OUString::createFromAscii("HomeZipCode"), - ::rtl::OUString::createFromAscii("HomeCountry"), - ::rtl::OUString::createFromAscii("WorkAddress"), - ::rtl::OUString::createFromAscii("WorkAddress2"), - ::rtl::OUString::createFromAscii("WorkCity"), - ::rtl::OUString::createFromAscii("WorkState"), - ::rtl::OUString::createFromAscii("WorkZipCode"), - ::rtl::OUString::createFromAscii("WorkCountry"), - ::rtl::OUString::createFromAscii("JobTitle"), - ::rtl::OUString::createFromAscii("Department"), - ::rtl::OUString::createFromAscii("Company"), - ::rtl::OUString::createFromAscii("WebPage1"), - ::rtl::OUString::createFromAscii("WebPage2"), - ::rtl::OUString::createFromAscii("BirthYear"), - ::rtl::OUString::createFromAscii("BirthMonth"), - ::rtl::OUString::createFromAscii("BirthDay"), - ::rtl::OUString::createFromAscii("Notes") -}; -//------------------------------------------------------------------------------ -OColumnAlias::OColumnAlias() -{ - // Initialise m_aAlias with the default values from sProgrammaticNames. - initialise(); - - // Initialise m_aAlias map with the default values from sProgrammaticNames. - setAliasMap(); -} -//------------------------------------------------------------------ -OColumnAlias::~OColumnAlias() -{ -} -//------------------------------------------------------------------ -void OColumnAlias::initialise() -{ - m_aAlias.reserve( END - FIRSTNAME + 1 ); - for (sal_Int32 i(FIRSTNAME); i < END; ++i) - { - m_aAlias.push_back(sProgrammaticNames[i]); - m_aHeadLineNames.push_back(sProgrammaticNames[i]); - } - - return; -} -//------------------------------------------------------------------ -void OColumnAlias::setAlias(const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory >& _rxORB) -{ - OSL_TRACE("OColumnAlias::setAlias()entered"); - - // open our driver settings config node - - // the config path for our own driver's settings - Reference< XPropertySet > xEvoDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() ); - //Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, mozab::OConnection::getDriverImplementationName() ); - Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver") ); - if ( xEvoDriverNode.is() && xMozDriverNode.is() ) - { - try - { - //============================================================= - Reference< XNameAccess > xEvoAliasesNode; - Reference< XNameAccess > xMozAliasesNode; - xEvoDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xEvoAliasesNode; - xMozDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xMozAliasesNode; - OSL_ENSURE( xEvoAliasesNode.is(), "OColumnAlias::setAlias: missing the evolution aliases node!" ); - OSL_ENSURE( xMozAliasesNode.is(), "OColumnAlias::setAlias: missing the mozilla aliases node!" ); - - // this is a set of string nodes - Sequence< ::rtl::OUString > aColumnProgrammaticNames; - //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getElementNames()"); - if ( xEvoAliasesNode.is() ) - aColumnProgrammaticNames = xEvoAliasesNode->getElementNames(); - //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getElementNames()"); - - //============================================================= - // travel through all the set elements - const ::rtl::OUString* pProgrammaticNames = aColumnProgrammaticNames.getConstArray(); - const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aColumnProgrammaticNames.getLength(); - ::rtl::OUString sAssignedAlias; - ::rtl::OUString sHeadLineName; - - for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames ) - { - //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammaticNames = %s\n", ((OUtoCStr(*pProgrammaticNames)) ? (OUtoCStr(*pProgrammaticNames)):("NULL")) ); - OSL_ENSURE( m_aAliasMap.end() != m_aAliasMap.find( *pProgrammaticNames ), - "OColumnAlias::setAlias: found an invalid programmtic name!" ); - // if this asserts, somebody stored a programmatic name in the configuration - // which is not allowed (i.e. not in the list of known programmatics). - //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getByName()"); - -#if OSL_DEBUG_LEVEL > 0 - sal_Bool bExtractionSuccess = -#endif - xMozAliasesNode->getByName( *pProgrammaticNames) >>= sAssignedAlias; - OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid mozilla config data!" ); -#if OSL_DEBUG_LEVEL > 0 - bExtractionSuccess = -#endif - xEvoAliasesNode->getByName( *pProgrammaticNames) >>= sHeadLineName; - OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid evolution config data!" ); - //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getByName()"); - - // normalize in case the config data is corrupted - // (what we really don't need is an empty alias ...) - if ( 0 == sAssignedAlias.getLength() ) - sAssignedAlias = *pProgrammaticNames; - if ( 0 == sHeadLineName.getLength() ) - sHeadLineName = *pProgrammaticNames; - //OSL_TRACE("OColumnAlias::setAlias()::sAssignedAlias = %s\n", ((OUtoCStr(sAssignedAlias)) ? (OUtoCStr(sAssignedAlias)):("NULL")) ); - //OSL_TRACE("OColumnAlias::setAlias()::sHeadLineName = %s\n", ((OUtoCStr(sHeadLineName)) ? (OUtoCStr(sHeadLineName)):("NULL")) ); - - //============================================================= - // check the value - // look up the programmatic indicated by pProgrammaticNames in the known programmatics - const ::rtl::OUString* pProgrammatic = sProgrammaticNames + FIRSTNAME; - const ::rtl::OUString* pProgrammaticEnd = sProgrammaticNames + END; - - OSL_ENSURE( (sal_Int32)m_aAlias.size() == pProgrammaticEnd - pProgrammatic, - "OColumnAlias::setAlias: aliases vector not yet initialized!" ); - - // the destination where we want to remember the alias - ::std::vector< ::rtl::OUString >::iterator aAlias = m_aAlias.begin(); - ::std::vector< ::rtl::OUString >::iterator aHeadLineName = m_aHeadLineNames.begin(); - - for ( ; pProgrammatic < pProgrammaticEnd; ++pProgrammatic, ++aAlias, ++aHeadLineName ) - { - //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammatic = %s\n", ((OUtoCStr(*pProgrammatic)) ? (OUtoCStr(*pProgrammatic)):("NULL")) ); - if ( pProgrammaticNames->equals( *pProgrammatic ) ) - { - // add alias to the vector - *aAlias = sAssignedAlias; - *aHeadLineName = sHeadLineName; - break; - } - } - } - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "OColumnAlias::setAlias: could not read my driver's configuration data!" ); - } - } - - // Initialise m_aAliasMap. - setAliasMap(); - - return; -} -//------------------------------------------------------------------ -const ::std::vector< ::rtl::OUString> & OColumnAlias::getAlias() const -{ - return m_aAlias; -} -//------------------------------------------------------------------ -const ::std::map< ::rtl::OUString, ::rtl::OUString> & OColumnAlias::getAliasMap() const -{ - return m_aAliasMap; -} -//------------------------------------------------------------------ -void OColumnAlias::setAliasMap() -{ - // Fill the map with the values of m_aAlias - // and the sProgrammaticNames array. - for (sal_Int32 i(FIRSTNAME); i < END; ++i) { - m_aAliasMap[m_aAlias[i]] = m_aHeadLineNames[i]; - //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAlias[i] = %s\n", ((OUtoCStr(m_aAlias[i])) ? (OUtoCStr(m_aAlias[i])):("NULL")) ); - //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAliasMap[m_aAlias[i]] = %s\n", ((OUtoCStr(m_aAliasMap[m_aAlias[i]])) ? (OUtoCStr(m_aAliasMap[m_aAlias[i]])):("NULL")) ); - } - - return; -} -//------------------------------------------------------------------ diff --git a/connectivity/source/drivers/evoab/LColumnAlias.hxx b/connectivity/source/drivers/evoab/LColumnAlias.hxx deleted file mode 100644 index c91931d121bf..000000000000 --- a/connectivity/source/drivers/evoab/LColumnAlias.hxx +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************* - * - * 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: LColumnAlias.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ -#define _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ - -#include <unotools/confignode.hxx> - -#include <osl/mutex.hxx> -#include <vector> -#include <map> - -namespace connectivity -{ - namespace evoab - { - typedef enum { - FIRSTNAME = 0, - LASTNAME, - DISPLAYNAME, - NICKNAME, - PRIMARYEMAIL, - SECONDEMAIL, - PREFERMAILFORMAT, - WORKPHONE, - HOMEPHONE, - FAXNUMBER, - PAGERNUMBER, - CELLULARNUMBER, - HOMEADDRESS, - HOMEADDRESS2, - HOMECITY, - HOMESTATE, - HOMEZIPCODE, - HOMECOUNTRY, - WORKADDRESS, - WORKADDRESS2, - WORKCITY, - WORKSTATE, - WORKZIPCODE, - WORKCOUNTRY, - JOBTITLE, - DEPARTMENT, - COMPANY, - WEBPAGE1, - WEBPAGE2, - BIRTHYEAR, - BIRTHMONTH, - BIRTHDAY, - NOTES, - END - } ProgrammaticName; - - class OColumnAlias - { - /** - * m_Alias holds aliases for the evolution addressbook - * column names. This member gets initialised during - * creation of the connection to the driver. - * m_aAlias initialises m_aAliasMap which then can be - * used to find the corresponding programmatic name - * when an alias is used as a query attribute. Mozilla - * expects programmatic names from its clients. - * - * m_aAlias: vector of aliases used to initialise m_aAliasMap. - * m_AliasMap: map of {alias, programmaticname} pairs. - * - */ - private: - ::std::vector< ::rtl::OUString> m_aAlias; - ::std::vector< ::rtl::OUString> m_aHeadLineNames; - ::std::map< ::rtl::OUString, ::rtl::OUString> m_aAliasMap; - protected: - ::osl::Mutex m_aMutex; - public: - void initialise(void); - const ::std::vector< ::rtl::OUString> & getAlias(void) const; - const ::std::map< ::rtl::OUString, ::rtl::OUString> & getAliasMap(void) const; - void setAlias(const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory > &); - private: - void setAliasMap(void); - public: - OColumnAlias(void); - ~OColumnAlias(void); - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_ diff --git a/connectivity/source/drivers/evoab/LColumns.cxx b/connectivity/source/drivers/evoab/LColumns.cxx deleted file mode 100644 index 9608c8efd384..000000000000 --- a/connectivity/source/drivers/evoab/LColumns.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************* - * - * 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: LColumns.cxx,v $ - * $Revision: 1.6 $ - * - * 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_connectivity.hxx" - -#include "LColumns.hxx" -#include "LTable.hxx" -#include "connectivity/sdbcx/VColumn.hxx" - -using namespace connectivity::evoab; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; - - -sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName) -{ - - OEvoabTable* pTable = (OEvoabTable*)m_pTable; - ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns(); - OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); - sdbcx::ObjectType xRet; - if(aIter != aCols->get().end()) - xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); - return xRet; -} -// ------------------------------------------------------------------------- - - diff --git a/connectivity/source/drivers/evoab/LColumns.hxx b/connectivity/source/drivers/evoab/LColumns.hxx deleted file mode 100644 index 457f319ca7b1..000000000000 --- a/connectivity/source/drivers/evoab/LColumns.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * 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: LColumns.hxx,v $ - * $Revision: 1.5 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ -#define _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ - -#include "file/FColumns.hxx" - -namespace connectivity -{ - namespace evoab - { - class OEvoabColumns : public file::OColumns - { - protected: - virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); - public: - OEvoabColumns(file::OFileTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector - ) : file::OColumns(_pTable,_rMutex,_rVector) - {} - - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_ - diff --git a/connectivity/source/drivers/evoab/LConfigAccess.cxx b/connectivity/source/drivers/evoab/LConfigAccess.cxx deleted file mode 100644 index 9df502d35d70..000000000000 --- a/connectivity/source/drivers/evoab/LConfigAccess.cxx +++ /dev/null @@ -1,164 +0,0 @@ -/************************************************************************* - * - * 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: LConfigAccess.cxx,v $ - * $Revision: 1.6 $ - * - * 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_connectivity.hxx" -#include "LConfigAccess.hxx" -#include "LDriver.hxx" -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#include "LDebug.hxx" -#endif - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; - -//......................................................................... -namespace connectivity -{ - namespace evoab - { - //----------------------------------------------------------------- - Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName ) - { - OSL_TRACE("createDriverConfigNode()entered"); - - Reference< XPropertySet > xNode; - try - { - //============================================================= - // create the config provider - Reference< XMultiServiceFactory > xConfigProvider( - _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ), - UNO_QUERY - ); - OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" ); - - if ( xConfigProvider.is() ) - { - ::rtl::OUString sCompleteNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Office.DataAccess/DriverSettings/" ); - sCompleteNodePath += _sDriverImplementationName; - //sCompleteNodePath += OEvoabConnection::getDriverImplementationName(); - //sCompleteNodePath += ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver"); - EVO_TRACE_STRING("createDriverConfigNode()::sCompleteNodePath = %s\n", sCompleteNodePath ); - - //========================================================= - // arguments for creating the config access - Sequence< Any > aArguments(2); - // the path to the node to open - aArguments[0] <<= PropertyValue( - ::rtl::OUString::createFromAscii( "nodepath"), - 0, - makeAny( sCompleteNodePath ), - PropertyState_DIRECT_VALUE - ); - // the depth: -1 means unlimited - aArguments[1] <<= PropertyValue( - ::rtl::OUString::createFromAscii( "depth"), - 0, - makeAny( (sal_Int32)-1 ), - PropertyState_DIRECT_VALUE - ); - - //========================================================= - // create the access - Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments( - ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ), - aArguments - ); - OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" ); - - xNode = xNode.query( xAccess ); - } - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "createDriverConfigNode: caught an exception while accessing the driver's config node!" ); - } - - // outta here - return xNode; - } - - //----------------------------------------------------------------- - namespace - { - // a private helper to accessing the point where we store the reference - // to the factory - Reference< XMultiServiceFactory >& accessFactoryStorage( ) - { - static Reference< XMultiServiceFactory > xEvoabServiceFactory; - return xEvoabServiceFactory; - } - } - - //----------------------------------------------------------------- - void setEvoabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory ) - { - accessFactoryStorage( ) = _rxFactory; - } - - //----------------------------------------------------------------- - const Reference< XMultiServiceFactory >& getEvoabServiceFactory( ) - { - return accessFactoryStorage( ); - } - - //----------------------------------------------------------------- - ::rtl::OUString getFullPathExportingCommand( Reference< XMultiServiceFactory > _rxORB ) - { - ::rtl::OUString sFullPathExportingCommand; - - //Reference< XMultiServiceFactory > xFactory = getEvoabServiceFactory(); - //OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" ); - OSL_ENSURE( _rxORB.is(), "getFullPathExportingCommand: invalid service factory!" ); - if ( _rxORB.is() ) - { - try - { - Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() ); - Reference< XPropertySet > xEvoPrefsNode; - if ( xDriverNode.is() ) - xDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii( "EvolutionPreferences" ) ) >>= xEvoPrefsNode; - OSL_ENSURE( xEvoPrefsNode.is(), "getFullPathExportingCommand: could not access the node for the evolution preferences!" ); - if ( xEvoPrefsNode.is() ) - xEvoPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii( "FullPathExportingCommand" ) ) >>= sFullPathExportingCommand; - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "getFullPathExportingCommand: caught an exception!" ); - } - } - return sFullPathExportingCommand; - } - } -} - -//......................................................................... diff --git a/connectivity/source/drivers/evoab/LConfigAccess.hxx b/connectivity/source/drivers/evoab/LConfigAccess.hxx deleted file mode 100644 index 9df43ef3226b..000000000000 --- a/connectivity/source/drivers/evoab/LConfigAccess.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************* - * - * 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: LConfigAccess.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ -#define _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ - -// This is the extended version (for use on the SO side of the driver) of MConfigAccess -// (which is for use on the mozilla side only) - -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -namespace connectivity -{ - namespace evoab - { - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > - createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName ); - ::rtl::OUString getFullPathExportingCommand( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB ); - } -} -#endif // _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_ diff --git a/connectivity/source/drivers/evoab/LConnection.cxx b/connectivity/source/drivers/evoab/LConnection.cxx deleted file mode 100644 index 383354d8ff5f..000000000000 --- a/connectivity/source/drivers/evoab/LConnection.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/************************************************************************* - * - * 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: LConnection.cxx,v $ - * $Revision: 1.12.56.1 $ - * - * 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_connectivity.hxx" -#include "LConnection.hxx" -#include "LDatabaseMetaData.hxx" -#include "LCatalog.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <tools/urlobj.hxx> -#include "LPreparedStatement.hxx" -#include "LStatement.hxx" -#include <comphelper/extract.hxx> -#include <connectivity/dbcharset.hxx> -#include <connectivity/dbexception.hxx> -#include <comphelper/processfactory.hxx> -#include <vos/process.hxx> -#include <tools/debug.hxx> -#include "LDebug.hxx" -#include "diagnose_ex.h" -#include <comphelper/sequence.hxx> -#include <connectivity/dbexception.hxx> -#include "resource/common_res.hrc" - -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace vos; - -typedef connectivity::file::OConnection OConnection_B; - -//------------------------------------------------------------------------------ -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; - -::rtl::OUString implGetExceptionMsg( Exception& e, const ::rtl::OUString& aExceptionType_ ) -{ - ::rtl::OUString aExceptionType = aExceptionType_; - if( aExceptionType.getLength() == 0 ) - aExceptionType = ::rtl::OUString( ::rtl::OUString::createFromAscii("Unknown" ) ); - - ::rtl::OUString aTypeLine( ::rtl::OUString::createFromAscii("\nType: " ) ); - aTypeLine += aExceptionType; - - ::rtl::OUString aMessageLine( ::rtl::OUString::createFromAscii("\nMessage: " ) ); - aMessageLine += ::rtl::OUString( e.Message ); - - ::rtl::OUString aMsg(aTypeLine); - aMsg += aMessageLine; - return aMsg; -} - - // Exception type unknown -::rtl::OUString implGetExceptionMsg( Exception& e ) -{ - ::rtl::OUString aMsg = implGetExceptionMsg( e, ::rtl::OUString() ); - return aMsg; -} - -// -------------------------------------------------------------------------------- -OEvoabConnection::OEvoabConnection(OEvoabDriver* _pDriver) : OConnection(_pDriver) - ,m_bHeaderLine(sal_True) - ,m_cFieldDelimiter(',') - ,m_cStringDelimiter('"') - ,m_cDecimalDelimiter('.') - ,m_cThousandDelimiter(' ') -{ - // Initialise m_aColumnAlias. - m_aColumnAlias.setAlias(_pDriver->getFactory()); -} -//----------------------------------------------------------------------------- -OEvoabConnection::~OEvoabConnection() -{ -} - -// XServiceInfo -// -------------------------------------------------------------------------------- -IMPLEMENT_SERVICE_INFO(OEvoabConnection, "com.sun.star.sdbc.drivers.evoab.Connection", "com.sun.star.sdbc.Connection") - -//----------------------------------------------------------------------------- -void OEvoabConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) -{ - osl_incrementInterlockedCount( &m_refCount ); - EVO_TRACE_STRING("OEvoabConnection::construct()::url = %s\n", url ); - - - ::rtl::OUString aCLICommand = getDriver()->getEvoab_CLI_EffectiveCommand(); - ::rtl::OUString aWorkingDirPath = getDriver()->getWorkingDirPath(); - ::rtl::OUString aArg1 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS()); - ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX()); - aArg2 += aWorkingDirPath; - aArg2 += getDriver()->getEvoFolderListFileName(); - OArgumentList aArgs(2,&aArg1,&aArg2); - - EVO_TRACE_STRING("OEvoabConnection::construct()::aCLICommand = %s\n", aCLICommand ); - EVO_TRACE_STRING("OEvoabConnection::construct()::aWorkingDirPath = %s\n", aWorkingDirPath ); - EVO_TRACE_STRING("OEvoabConnection::construct()::aArg1 = %s\n", aArg1 ); - EVO_TRACE_STRING("OEvoabConnection::construct()::aArg2 = %s\n", aArg2 ); - OProcess aApp( aCLICommand,aWorkingDirPath); - OSL_VERIFY_EQUALS( - aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs), - OProcess::E_None, - "Error at execute evolution-addressbook-export to get VCards"); - - - Sequence<PropertyValue> aDriverParam; - ::std::vector<PropertyValue> aParam; - - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("EnableSQL92Check"), 0, Any(), PropertyState_DIRECT_VALUE)); - ::dbtools::OCharsetMap aLookupIanaName; - ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(RTL_TEXTENCODING_UTF8); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("CharSet"), 0, - makeAny((*aLookup).getIanaName()), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("Extension"), 0, makeAny(getDriver()->getFileExt()), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("HeaderLine"), 0, makeAny(m_bHeaderLine), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("FieldDelimiter"), 0, makeAny(::rtl::OUString(&m_cFieldDelimiter,1)), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("StringDelimiter"), 0, makeAny(::rtl::OUString(&m_cStringDelimiter,1)), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("DecimalDelimiter"), 0, makeAny(::rtl::OUString(&m_cDecimalDelimiter,1)), PropertyState_DIRECT_VALUE)); - aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("ThousandDelimiter"), 0, makeAny(::rtl::OUString(&m_cThousandDelimiter,1)), PropertyState_DIRECT_VALUE)); - - // build a new parameter sequence from the original parameters, appended by the new parameters from above - PropertyValue *pParams = aParam.empty() ? 0 : &aParam[0]; - aDriverParam = ::comphelper::concatSequences( - info, - Sequence< PropertyValue >( pParams, aParam.size() ) - ); - - // transform "sdbc:address:evolution" part of URL to "sdbc:flat:file:///..." - // - sal_Int32 nLen = url.indexOf(':'); - nLen = url.indexOf(':',nLen+1); - ::rtl::OUString aAddrbookURI(url.copy(nLen+1)); - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - ::rtl::OUString aAddrbookScheme; - if ( nLen == -1 ) - { - // There isn't any subschema: - but could be just subschema - if ( aAddrbookURI.getLength() > 0 ) - { - aAddrbookScheme= aAddrbookURI; - } - else - { - OSL_TRACE( "No subschema given!!!\n"); - throwGenericSQLException(STR_URI_SYNTAX_ERROR ,*this); - } - } - else - { - aAddrbookScheme = aAddrbookURI.copy(0, nLen); - } - - EVO_TRACE_STRING("OEvoabConnection::construct()::URI = %s\n", aAddrbookURI ); - EVO_TRACE_STRING("OEvoabConnection::construct()::Scheme = %s\n", aAddrbookScheme ); - - // - // Now we have a URI convert it to a Evolution CLI flat file URI - // - // The Mapping being used is: - // - // * for Evolution - // "sdbc:address:evolution:" -> "sdbc:flat:file:///(file path generated) - - rtl::OUString aEvoFlatURI; - if ( aAddrbookScheme.compareToAscii( OEvoabDriver::getSDBC_SCHEME_EVOLUTION() ) == 0 ) - { - aEvoFlatURI = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "sdbc:flat:" )); - } - - - aEvoFlatURI += getDriver()->getWorkingDirURL(); - EVO_TRACE_STRING("OEvoabConnection::construct()::m_aEvoFlatURI = %s\n", aEvoFlatURI ); - //setURL(aEvoFlatURI); - m_aEvoFlatURI = aEvoFlatURI; - - osl_decrementInterlockedCount( &m_refCount ); - OConnection::construct(aEvoFlatURI,aDriverParam); -} -// -------------------------------------------------------------------------------- -Reference< XDatabaseMetaData > SAL_CALL OEvoabConnection::getMetaData( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_B::rBHelper.bDisposed); - - - Reference< XDatabaseMetaData > xMetaData = m_xMetaData; - if(!xMetaData.is()) - { - xMetaData = new OEvoabDatabaseMetaData(this); - m_xMetaData = xMetaData; - } - - return xMetaData; -} -//------------------------------------------------------------------------------ -::com::sun::star::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XTablesSupplier > xTab = m_xCatalog; - if(!xTab.is()) - { - OEvoabCatalog *pCat = new OEvoabCatalog(this); - xTab = pCat; - m_xCatalog = xTab; - } - return xTab; -} -// -------------------------------------------------------------------------------- -Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_B::rBHelper.bDisposed); - - OEvoabStatement* pStmt = new OEvoabStatement(this); - - Reference< XStatement > xStmt = pStmt; - m_aStatements.push_back(WeakReferenceHelper(*pStmt)); - return xStmt; -} -// -------------------------------------------------------------------------------- -Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OConnection_B::rBHelper.bDisposed); - - - OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement(this); - Reference< XPreparedStatement > xStmt = pStmt; - pStmt->construct(sql); - - m_aStatements.push_back(WeakReferenceHelper(*pStmt)); - return xStmt; -} -// -------------------------------------------------------------------------------- -Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this ); - return NULL; -} -// ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LConnection.hxx b/connectivity/source/drivers/evoab/LConnection.hxx deleted file mode 100644 index e0cd79eb8f78..000000000000 --- a/connectivity/source/drivers/evoab/LConnection.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************* - * - * 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: LConnection.hxx,v $ - * $Revision: 1.5 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ -#define _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ - -#include "LDriver.hxx" -#include "file/FConnection.hxx" -#include "LColumnAlias.hxx" - -namespace connectivity -{ - namespace evoab - { - class OEvoabConnection : public file::OConnection - { - private: - OColumnAlias m_aColumnAlias; - sal_Bool m_bHeaderLine; // column names in first row - sal_Unicode m_cFieldDelimiter; // look at the name - sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter - sal_Unicode m_cDecimalDelimiter; // Dezimal-delimiter (Dezimalpoint) - sal_Unicode m_cThousandDelimiter; // - rtl::OUString m_aEvoFlatURI; - - public: - OEvoabConnection(OEvoabDriver* _pDriver); - virtual ~OEvoabConnection(); - - virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); - - // own methods - inline const OEvoabDriver* getDriver() const { return static_cast< const OEvoabDriver* >( m_pDriver ); } - inline sal_Bool isHeaderLine() const { return m_bHeaderLine; } - inline sal_Unicode getFieldDelimiter() const { return m_cFieldDelimiter; } - inline sal_Unicode getStringDelimiter() const { return m_cStringDelimiter; } - inline sal_Unicode getDecimalDelimiter() const { return m_cDecimalDelimiter; } - inline sal_Unicode getThousandDelimiter() const { return m_cThousandDelimiter;} - const OColumnAlias& getColumnAlias() const { return m_aColumnAlias; } - - // XServiceInfo - DECLARE_SERVICE_INFO(); - - // XConnection - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog(); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LCONNECTION_HXX_ diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx deleted file mode 100644 index 5a0f80781d2a..000000000000 --- a/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx +++ /dev/null @@ -1,394 +0,0 @@ -/************************************************************************* - * - * 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: LDatabaseMetaData.cxx,v $ - * $Revision: 1.8 $ - * - * 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_connectivity.hxx" -#include "LDatabaseMetaData.hxx" -#include "LConnection.hxx" -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/beans/XFastPropertySet.hpp> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/sdbcx/XIndexesSupplier.hpp> -#include <com/sun/star/ucb/XContentAccess.hpp> -#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ -#include <com/sun/star/sdbc/XRow.hpp> -#endif -#include <tools/urlobj.hxx> -#include "FDatabaseMetaDataResultSet.hxx" -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <comphelper/extract.hxx> -#include <comphelper/types.hxx> -#include "LFolderList.hxx" -#include "connectivity/CommonTools.hxx" -#include <vos/process.hxx> -#include <osl/process.h> -#include <tools/debug.hxx> -#include <map> -#include <vector> - -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#include "LDebug.hxx" -#endif -#include "diagnose_ex.h" - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::evoab; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::ucb; -using namespace osl; -using namespace vos; - -namespace connectivity -{ - namespace evoab - { - static sal_Int32 const s_nCOLUMN_SIZE = 256; - static sal_Int32 const s_nDECIMAL_DIGITS = 0; - static sal_Int32 const s_nNULLABLE = 1; - static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535; - } -} - -OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon) -{ -} -// ------------------------------------------------------------------------- -OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData() -{ -} -// ------------------------------------------------------------------------- -Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo); - Reference< XResultSet > xRef = pResult; - static ODatabaseMetaDataResultSet::ORows aRows; - if(aRows.empty()) - { - ODatabaseMetaDataResultSet::ORow aRow; - - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"))); - aRow.push_back(new ORowSetValueDecorator(DataType::CHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); - aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); - - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")); - aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRows.push_back(aRow); - - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR")); - aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32)65535); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); - aRow[2] = new ORowSetValueDecorator(DataType::DATE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)10); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME")); - aRow[2] = new ORowSetValueDecorator(DataType::TIME); - aRow[3] = new ORowSetValueDecorator((sal_Int32)8); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); - aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP); - aRow[3] = new ORowSetValueDecorator((sal_Int32)19); - aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL")); - aRow[2] = new ORowSetValueDecorator(DataType::BIT); - aRow[3] = ODatabaseMetaDataResultSet::get1Value(); - aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL")); - aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); - aRow[15] = new ORowSetValueDecorator((sal_Int32)15); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE")); - aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); - aRow[15] = ODatabaseMetaDataResultSet::get0Value(); - aRows.push_back(aRow); - - aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC")); - aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); - aRow[15] = new ORowSetValueDecorator((sal_Int32)20); - aRows.push_back(aRow); - } - - pResult->setRows(aRows); - return xRef; -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( - const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern, - const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) -{ - OSL_TRACE("OEvoabDatabaseMetaData::getColumns()::Entered\n"); - EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::schemaPattern = %s\n", schemaPattern ); - EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::tableNamePattern = %s\n", tableNamePattern ); - EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::columnNamePattern = %s\n", columnNamePattern ); - - ::osl::MutexGuard aGuard( m_aMutex ); - - Reference< XTablesSupplier > xTables = m_pConnection->createCatalog(); - if(!xTables.is()) - throw SQLException(); - - Reference< XNameAccess> xNames = xTables->getTables(); - if(!xNames.is()) - throw SQLException(); - - ODatabaseMetaDataResultSet::ORows aRows; - ODatabaseMetaDataResultSet::ORow aRow(19); - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); - Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames()); - const ::rtl::OUString* pTabBegin = aTabNames.getConstArray(); - const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength(); - for(;pTabBegin != pTabEnd;++pTabBegin) - { - if(match(tableNamePattern,*pTabBegin,'\0')) - { - Reference< XColumnsSupplier> xTable; - ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin)); - aRow[3] = new ORowSetValueDecorator(*pTabBegin); - - Reference< XNameAccess> xColumns = xTable->getColumns(); - if(!xColumns.is()) - throw SQLException(); - - Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames()); - - const ::rtl::OUString* pBegin = aColNames.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); - Reference< XPropertySet> xColumn; - for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i) - { - if(match(columnNamePattern,*pBegin,'\0')) - { - aRow[4] = new ORowSetValueDecorator(*pBegin); - - ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); - OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); - aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); - aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); - aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); - aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); - aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); - aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); - - switch((sal_Int32)aRow[5]->getValue()) - { - case DataType::CHAR: - case DataType::VARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)254); - break; - case DataType::LONGVARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); - break; - default: - aRow[16] = new ORowSetValueDecorator((sal_Int32)0); - } - aRow[17] = new ORowSetValueDecorator(i); - switch(sal_Int32(aRow[11]->getValue())) - { - case ColumnValue::NO_NULLS: - aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); - break; - case ColumnValue::NULLABLE: - aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES")); - break; - default: - aRow[18] = new ORowSetValueDecorator(::rtl::OUString()); - } - aRows.push_back(aRow); - } - } - } - } - - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns); - Reference< XResultSet > xRef = pResult; - pResult->setRows(aRows); - - return xRef; -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:flat:")) + m_pConnection->getURL(); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables( - const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, - const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables); - Reference< XResultSet > xRef = pResult; - - // check if any type is given - // when no types are given then we have to return all tables e.g. TABLE - - static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE")); - - sal_Bool bTableFound = sal_True; - sal_Int32 nLength = types.getLength(); - if(nLength) - { - bTableFound = sal_False; - - const ::rtl::OUString* pBegin = types.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + nLength; - for(;pBegin != pEnd;++pBegin) - { - if(*pBegin == aTable) - { - bTableFound = sal_True; - break; - } - } - } - if(!bTableFound) - return xRef; - - OEvoabConnection* pOEvoabConnection = (OEvoabConnection*)m_pConnection; - OEvoabFolderList* pFolderList = new OEvoabFolderList( pOEvoabConnection ); - - - ODatabaseMetaDataResultSet::ORows aRows; - sal_Bool bMoreData = sal_True; - ::rtl::OUString aName, aLocation; - sal_Int32 nCardsCount; - - pFolderList->initializeRow(3); - bMoreData = pFolderList->first(); - OSL_TRACE("OEvoabDatabaseMetaData::getTables()::first %d\n",bMoreData ); - do - { - if(bMoreData) - bMoreData = pFolderList->getRow(); - if(bMoreData) - { - aLocation = pFolderList->getString(1); - aName = pFolderList->getString(2); - nCardsCount = pFolderList->getInt(3); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aLocation = %s\n", aLocation ); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aName = %s\n", aName ); - OSL_TRACE("OEvoabDatabaseMetaData::getTables()::nCardsCount = %d\n", nCardsCount); - - ODatabaseMetaDataResultSet::ORow aRow(3); - aRow.reserve(6); - aRow.push_back(new ORowSetValueDecorator(aName)); - aRow.push_back(new ORowSetValueDecorator(aTable)); - aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRows.push_back(aRow); - - ::rtl::OUString aWorkingDir = pOEvoabConnection->getDriver()->getWorkingDirPath(); - ::rtl::OUString aCLICommand = pOEvoabConnection->getDriver()->getEvoab_CLI_EffectiveCommand(); - ::rtl::OUString aArg1 = aLocation; - ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX()); - aArg2 += aWorkingDir; - aArg2 += aName; - aArg2 += ::rtl::OUString::createFromAscii("."); - aArg2 += ::rtl::OUString(pOEvoabConnection->getExtension()); - ::rtl::OUString aArg3 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FORMAT()); - - OArgumentList aArgs(3,&aArg1,&aArg2,&aArg3); - - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aCLICommand = %s\n", aCLICommand ); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aWorkingDir = %s\n", aWorkingDir ); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg1 = %s\n", aArg1 ); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg2 = %s\n", aArg2 ); - EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg3 = %s\n", aArg3 ); - - OProcess aApp( aCLICommand,aWorkingDir); - OSL_VERIFY_EQUALS( - aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs), - OProcess::E_None, - "Error at execute evolution-addressbook-exporter to get VCards" ); - - bMoreData = pFolderList->next(); - } - } - while ( bMoreData ); - - delete pFolderList; - pFolderList = NULL; - - pResult->setRows(aRows); - - return xRef; -} diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx deleted file mode 100644 index bad565d68e54..000000000000 --- a/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * - * 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: LDatabaseMetaData.hxx,v $ - * $Revision: 1.5 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ -#define _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ - -#include "file/FDatabaseMetaData.hxx" -#include "FDatabaseMetaDataResultSet.hxx" - -namespace connectivity -{ - namespace evoab - { - //************************************************************** - //************ Class: java.sql.DatabaseMetaDataDate - //************************************************************** - - class OEvoabDatabaseMetaData : public file::ODatabaseMetaData - { - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); - virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - protected: - virtual ~OEvoabDatabaseMetaData(); - public: - OEvoabDatabaseMetaData(file::OConnection* _pCon); - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_ - diff --git a/connectivity/source/drivers/evoab/LDebug.cxx b/connectivity/source/drivers/evoab/LDebug.cxx deleted file mode 100644 index 64b39f7cea03..000000000000 --- a/connectivity/source/drivers/evoab/LDebug.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************* - * - * 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: LDebug.cxx,v $ - * $Revision: 1.5 $ - * - * 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_connectivity.hxx" - -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#include "LDebug.hxx" -#endif -#include <osl/diagnose.h> - -void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString ) -{ - ::rtl::OString sByteStringMessage( _rAsciiString.getStr(), _rAsciiString.getLength(), RTL_TEXTENCODING_ASCII_US ); - if ( !sByteStringMessage.getLength() ) - sByteStringMessage = "<empty>"; - OSL_TRACE( _pFormat, sByteStringMessage.getStr() ); -} diff --git a/connectivity/source/drivers/evoab/LDebug.hxx b/connectivity/source/drivers/evoab/LDebug.hxx deleted file mode 100644 index dc8a64ef796c..000000000000 --- a/connectivity/source/drivers/evoab/LDebug.hxx +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************* - * - * 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: LDebug.hxx,v $ - * $Revision: 1.5 $ - * - * 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. - * - ************************************************************************/ - -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#define CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX - -#include <rtl/ustring.hxx> - -#ifdef _DEBUG - void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString ); - - #define EVO_TRACE_STRING( pFormat, rAsciiString ) evo_traceStringMessage( pFormat, rAsciiString ) -#else - #define EVO_TRACE_STRING( pFormat, rAsciiString ) (void)(0) -#endif - - -#endif // CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX diff --git a/connectivity/source/drivers/evoab/LDriver.cxx b/connectivity/source/drivers/evoab/LDriver.cxx deleted file mode 100644 index 379dfba4b21e..000000000000 --- a/connectivity/source/drivers/evoab/LDriver.cxx +++ /dev/null @@ -1,508 +0,0 @@ -/************************************************************************* - * - * 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: LDriver.cxx,v $ - * $Revision: 1.10.42.1 $ - * - * 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_connectivity.hxx" -#include "LDriver.hxx" -#include "LConnection.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include "connectivity/dbexception.hxx" -#include "LConfigAccess.hxx" -#include <osl/file.hxx> -#include "osl/security.hxx" -#include <comphelper/processfactory.hxx> -#include <com/sun/star/ucb/XCommandEnvironment.hpp> -#include <ucbhelper/content.hxx> -#include <tools/debug.hxx> -#include "resource/common_res.hrc" -#include "resource/sharedresources.hxx" -#include "LDebug.hxx" - -using namespace osl; -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::ucb; - -// -------------------------------------------------------------------------------- -OEvoabDriver::OEvoabDriver(const Reference< XMultiServiceFactory >& _rxFactory) : OFileDriver(_rxFactory) - ,m_aTempDir(NULL, sal_True) - ,m_aFolderListName(::rtl::OUString::createFromAscii(getEVOAB_FOLDERLIST_FILE_NAME())) - ,m_aVersionName(::rtl::OUString::createFromAscii(getEVOAB_VERSION_FILE_NAME())) - ,m_aFileExt(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(getEVOAB_META_FILE_EXT()))) - ,m_bWorkingDirCreated(sal_False) - ,m_eSupportedEvoVersion( eUnknown ) -{ - m_aEvoab_CLI_FullPathCommand = getFullPathExportingCommand(_rxFactory); - - if ( m_aEvoab_CLI_FullPathCommand.getLength() == 0 ) - m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii(getEVOAB_CLI_FULLPATHCOMMAND()); - if ( m_aEvoab_CLI_FullPathCommand.copy(0,7) != ::rtl::OUString::createFromAscii("file://") && m_aEvoab_CLI_FullPathCommand.copy(0,1) == ::rtl::OUString::createFromAscii("/")) - m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii("file://") + m_aEvoab_CLI_FullPathCommand; - m_aEvoab_CLI_EffectiveCommand = m_aEvoab_CLI_FullPathCommand; - m_aTempDir.EnableKillingFile(); - - EVO_TRACE_STRING("OEvoabDriver::OEvoabDriver()::m_aEvoab_CLI_FullPathCommand = %s", m_aEvoab_CLI_FullPathCommand ); -} -// static ServiceInfo -//------------------------------------------------------------------------------ -rtl::OUString OEvoabDriver::getImplementationName_Static( ) throw(RuntimeException) -{ - return rtl::OUString::createFromAscii(EVOAB_DRIVER_IMPL_NAME); -} - -//------------------------------------------------------------------ -::rtl::OUString SAL_CALL OEvoabDriver::getImplementationName( ) throw(RuntimeException) -{ - return getImplementationName_Static(); -} - -//------------------------------------------------------------------ -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::evoab::OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) -{ - return *(new OEvoabDriver(_rxFactory)); -} -// -------------------------------------------------------------------------------- -Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - if (ODriver_BASE::rBHelper.bDisposed) - throw DisposedException(); - - if ( ! acceptsURL(url) ) - return NULL; - - OEvoabConnection* pCon = new OEvoabConnection(this); - pCon->construct(url,info); - Reference< XConnection > xCon = pCon; - m_xConnections.push_back(WeakReferenceHelper(*pCon)); - - return xCon; -} -// -------------------------------------------------------------------------------- -namespace -{ - ::rtl::OUString lcl_translateProcessErrorMessage( oslProcessError nProcErr) - { - ::rtl::OUString sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" not executed!.")); - switch (nProcErr) - { - case osl_Process_E_None: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed sucessful!")); - break; - case osl_Process_E_NotFound: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: not found!")); - break; - case osl_Process_E_NoPermission: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: has no permission!")); - break; - case osl_Process_E_TimedOut: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: time out!")); - break; - case osl_Process_E_Unknown: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: unkown reason!")); - break; - case osl_Process_E_InvalidError: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: invalid error!")); - break; - default: - sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: other reason!")); - } - return sProcErr; - } - oslProcessError lcl_execute( const ::rtl::OUString& _rCommand, ::rtl::OUString& _rArgument, - const ::rtl::OUString& _rWorkingDir, oslProcessOption _nOptions, oslFileHandle& /*[out]*/ _hStdOut ) - { - oslProcessError nError = osl_Process_E_None; - - EVO_TRACE_STRING("LDriver.cxx::lcl_execute: command : %s", _rCommand ); - EVO_TRACE_STRING("LDriver.cxx::lcl_execute: argument : %s", _rArgument ); - EVO_TRACE_STRING("LDriver.cxx::lcl_execute: working dir: %s", _rWorkingDir ); - - oslProcess hProcess( 0 ); - - nError = osl_executeProcess_WithRedirectedIO( - _rCommand.pData, - &_rArgument.pData, - 1, - _nOptions, - 0, - _rWorkingDir.pData, - 0, - 0, - &hProcess, - NULL, - &_hStdOut, - NULL - ); - ::rtl::OUString sError = _rCommand + lcl_translateProcessErrorMessage( nError); - EVO_TRACE_STRING( "%s", sError ); - - if ( nError == osl_Process_E_None ) - { - TimeValue aFiveSeconds; - aFiveSeconds.Seconds = 5; - aFiveSeconds.Nanosec = 0; - oslProcessError nWaitForProcessError = osl_joinProcessWithTimeout( hProcess, &aFiveSeconds ); - if ( osl_Process_E_None != nWaitForProcessError ) - { - nError = nWaitForProcessError; - // TODO: kill the running process? - } - osl_freeProcessHandle( hProcess ); - } - return nError; - } -} - -// -------------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const ::rtl::OUString& url ) - throw(SQLException, RuntimeException) -{ - sal_Bool bRet; - bRet = sal_False; - // here we have to look if we support this url format - if(acceptsURL_Stat(url)) - { - if ( m_eSupportedEvoVersion != eUnknown ) - return m_eSupportedEvoVersion == eTrue ? sal_True : sal_False; - - if(!m_bWorkingDirCreated) - { - String sTempDirURL = getTempDirURL(); - //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::sTempDirURL = %s", sTempDirURL ); - - ::rtl::OUString aTempDirURL(sTempDirURL); - m_aWorkingDirURL = aTempDirURL; - m_bWorkingDirCreated = sal_True; - } - - ::rtl::OUString aCLICommand = getEvoab_CLI_EffectiveCommand(); - ::rtl::OUString aWorkingDirURL = getWorkingDirURL(); - ::rtl::OUString aArgVersion = ::rtl::OUString::createFromAscii(getEVOAB_CLI_ARG_VERSION()); - - oslFileHandle hStdout = NULL; - oslProcessError nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, 0, hStdout ); - if(nProcErr != osl_Process_E_None) - { - if(doesEvoab_CLI_HavePath()) - aCLICommand = getEvoab_CLI_Command(); - else - aCLICommand = getEvoab_CLI_Path() + getEvoab_CLI_Command(); - nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, osl_Process_SEARCHPATH | osl_Process_HIDDEN, hStdout ); - if ( nProcErr == osl_Process_E_None ) - m_aEvoab_CLI_EffectiveCommand = aCLICommand; - } - - if ( hStdout != NULL ) - { - OSL_ASSERT( hStdout ); - sal_Char pBuffer[256]; - sal_uInt64 nBytesRead; - oslFileError nFileErr = osl_File_E_None; - nFileErr = osl_readFile( hStdout, pBuffer, 256, &nBytesRead); - if ( nFileErr != osl_File_E_None ) - { - ::rtl::OUString sErr = translateFileErrorMessage( nFileErr); - OSL_ENSURE(false, ::rtl::OUStringToOString( sErr, RTL_TEXTENCODING_ASCII_US ).getStr()); - } - ::rtl::OUString aVersionInfo; - if ( nFileErr == osl_File_E_None && nBytesRead > 0 && nBytesRead <= 256) - { - OSL_TRACE("OEvoabDriver::acceptsURL()::osl_readFile(),nBytesRead = %u",nBytesRead); - aVersionInfo = - ::rtl::OUString( ( const sal_Char * )pBuffer, - (sal_Int32)nBytesRead, - RTL_TEXTENCODING_UTF8 ); - EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aVersionInfo = %s", aVersionInfo ); - sal_Int32 nIndex = 0; - sal_Bool bNumRetrieved = sal_False; - ::rtl::OUString aToken; - sal_Int32 aVer[4]; - sal_Int32 i; - for ( i = 0; i < 4; i++ ) - aVer[i] = 0; - do - { - aToken = aVersionInfo.getToken( 0, ' ', nIndex ); - //OSL_TRACE("OEvoabDriver::acceptsURL()::Token:%d", nIndex ); - //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aToken = %s", aToken ); - if( aToken.toChar() >= '0' && aToken.toChar() <= '9' ) - { - bNumRetrieved = sal_True; - sal_Int32 nIndex1 = 0; - ::rtl::OUString aNum; - for(i = 0; i < 4 ; i++) - { - if( nIndex1 >= 0 ) - { - aNum = aToken.getToken( 0, '.', nIndex1); - aVer[i] = aNum.toInt32(); - OSL_TRACE("OEvoabDriver::acceptsURL()::Ver[%u]=%u", i, aVer[i] ); - } - } - } - } - while ( nIndex >= 0 && !bNumRetrieved ); - - if((aVer[0]>1)||(aVer[0]==1 && aVer[1]>3)||(aVer[0]==1 && aVer[1]==3 && aVer[2]>2)||(aVer[0]==1 && aVer[1]==3 && aVer[2]==2 && aVer[3]>=99)) - bRet = sal_True; - else - bRet = sal_False; - } - else - bRet = sal_False; - - osl_closeFile( hStdout ); - } - m_eSupportedEvoVersion = bRet ? eTrue : eFalse; - } - EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::return, return value = %s", ::rtl::OUString::valueOf(bRet) ); - return bRet; -} - - -// -------------------------------------------------------------------------------- -sal_Bool OEvoabDriver::acceptsURL_Stat( const ::rtl::OUString& url ) -{ - - EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", url ); - // Skip 'sdbc:address: part of URL - // - sal_Int32 nLen = url.indexOf(':'); - nLen = url.indexOf(':',nLen+1); - ::rtl::OUString aAddrbookURI(url.copy(nLen+1)); - - // Get Scheme - nLen = aAddrbookURI.indexOf(':'); - ::rtl::OUString aAddrbookScheme; - if ( nLen == -1 ) - { - // There isn't any subschema: - but could be just subschema - if ( aAddrbookURI.getLength() > 0 ) - aAddrbookScheme= aAddrbookURI; - else if(url == ::rtl::OUString::createFromAscii("sdbc:address:") ) - return sal_True; // special case here - else - return sal_False; - } - else - aAddrbookScheme = aAddrbookURI.copy(0, nLen); - - - EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::URI = %s", aAddrbookURI ); - EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", aAddrbookScheme ); - - return aAddrbookScheme.compareToAscii( getSDBC_SCHEME_EVOLUTION() ) == 0 ; -} -// ------------------------------------------------------------------------- -const rtl::OUString OEvoabDriver::getEvoab_CLI_Command() const -{ - rtl::OUString aEvoab_CLI_Command; - sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/'); - - if ( nLen == -1 ) - aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand; - else - aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand.copy(nLen+1); - - EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Command()::aEvoab_CLI_Command = %s", aEvoab_CLI_Command ); - - return aEvoab_CLI_Command; -} -// ------------------------------------------------------------------------- -const rtl::OUString OEvoabDriver::getEvoab_CLI_Path() const -{ - rtl::OUString aEvoab_CLI_Path; - sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/'); - - if ( nLen == -1 ) - { - rtl::OUString aDefault_CLI_FullPathCommand; - aDefault_CLI_FullPathCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND())); - sal_Int32 nLength = aDefault_CLI_FullPathCommand.lastIndexOf('/'); - aEvoab_CLI_Path = aDefault_CLI_FullPathCommand.copy(0, nLength+1); - } - else - aEvoab_CLI_Path = m_aEvoab_CLI_FullPathCommand.copy(0, nLen+1); - EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Path()::aEvoab_CLI_Path = %s", aEvoab_CLI_Path ); - - return aEvoab_CLI_Path; -} -// ------------------------------------------------------------------------- -const rtl::OUString OEvoabDriver::getWorkingDirPath() const -{ - ::rtl::OUString aWorkingDirPath; - if(m_bWorkingDirCreated) - osl::File::getSystemPathFromFileURL( m_aWorkingDirURL, aWorkingDirPath ); - return aWorkingDirPath; -} -// ------------------------------------------------------------------------- -const String OEvoabDriver::getEvoFolderListFileURL() const -{ - - ::rtl::OUString aEvoFolderListFileURL; - aEvoFolderListFileURL = getWorkingDirURL() + getEvoFolderListFileName(); - - EVO_TRACE_STRING("OEvoabDriver::getEvoFolderListFileURL(): aEvoFolderListFileURL = %s", aEvoFolderListFileURL ); - return aEvoFolderListFileURL.getStr(); -} - -// ------------------------------------------------------------------------- -String OEvoabDriver::getTempDirURL() const -{ - ::rtl::OUString aTempDirURL; - aTempDirURL = m_aTempDir.GetURL(); - if((aTempDirURL.lastIndexOf( '/')) != (aTempDirURL.getLength( ) - 1)) - aTempDirURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); - - EVO_TRACE_STRING("OEvoabDriver::getTempDirURL(): aTempDirURL = %s", aTempDirURL ); - return aTempDirURL.getStr(); -} -//------------------------------------------------------------------------- -sal_Bool OEvoabDriver::fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir) const -{ - ::ucbhelper::Content aCheckExistence; - sal_Bool bExists = sal_False; - try - { - aCheckExistence = ::ucbhelper::Content(_rURL, Reference< XCommandEnvironment >()); - if(_bIsDir) - bExists = aCheckExistence.isFolder(); - else - bExists = aCheckExistence.isDocument(); - } - catch(const Exception&) { } - return bExists; -} - -// ----------------------------------------------------------------------------- -const sal_Char* OEvoabDriver::getSDBC_SCHEME_EVOLUTION() -{ - static const sal_Char* SDBC_SCHEME_EVOLUTION = EVOAB_EVOLUTION_SCHEMA; - return SDBC_SCHEME_EVOLUTION; -} -const sal_Char* OEvoabDriver::getEVOAB_FOLDERLIST_FILE_NAME() -{ - static const sal_Char* EVOAB_FOLDERLIST_FILE_NAME = "FolderList"; - return EVOAB_FOLDERLIST_FILE_NAME; -} -const sal_Char* OEvoabDriver::getEVOAB_VERSION_FILE_NAME() -{ - static const sal_Char* EVOAB_VERSION_FILE_NAME = "EvoVersion"; - return EVOAB_VERSION_FILE_NAME; -} -const sal_Char* OEvoabDriver::getEVOAB_META_FILE_EXT() -{ - static const sal_Char* EVOAB_META_FILE_EXT = "csv"; - return EVOAB_META_FILE_EXT; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND() -{ - static const sal_Char* EVOAB_CLI_FULLPATHCOMMAND = "file:///home/evoab/extra/share/evolution/*/tools/evolution-addressbook-export"; - return EVOAB_CLI_FULLPATHCOMMAND; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS() -{ - static const sal_Char* EVOAB_CLI_ARG_LIST_FOLDERS = "-l"; - return EVOAB_CLI_ARG_LIST_FOLDERS; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX() -{ - static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX = "--output="; - return EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FORMAT() -{ - static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FORMAT = "--format=csv"; - return EVOAB_CLI_ARG_OUTPUT_FORMAT; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_VERSION() -{ - static const sal_Char* EVOAB_CLI_ARG_VERSION = "--version"; - return EVOAB_CLI_ARG_VERSION; -} -const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_REDIRECT() -{ - static const sal_Char* EVOAB_CLI_ARG_OUTPUT_REDIRECT = ">"; - return EVOAB_CLI_ARG_OUTPUT_REDIRECT; -} -rtl::OUString OEvoabDriver::translateFileErrorMessage( oslFileError nFileErr) -{ - ::rtl::OUString sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" no file operation!.")); - switch (nFileErr) - { - case osl_File_E_None: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation succeeded!")); - break; - case osl_File_E_INVAL: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: the format of the parameters was not valid!")); - break; - case osl_File_E_INTR: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: function call was interrupted!")); - break; - case osl_File_E_IO: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: I/O errors!")); - break; - case osl_File_E_ISDIR: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: is a directory!")); - break; - case osl_File_E_BADF: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad file!")); - break; - case osl_File_E_FAULT: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad address!")); - break; - case osl_File_E_AGAIN: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: operation would block!")); - break; - case osl_File_E_NOLINK: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: link has been severed!")); - break; - default: - sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: other reason!")); - } - return sFileErr; -} -// ----------------------------------------------------------------------------- -Sequence< DriverPropertyInfo > SAL_CALL OEvoabDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) -{ - if ( !acceptsURL(url) ) - { - ::connectivity::SharedResources aResources; - const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); - ::dbtools::throwGenericSQLException(sMessage ,*this); - } // if ( !acceptsURL(url) ) - return Sequence< DriverPropertyInfo >(); -} diff --git a/connectivity/source/drivers/evoab/LDriver.hxx b/connectivity/source/drivers/evoab/LDriver.hxx deleted file mode 100644 index bf45c93d9531..000000000000 --- a/connectivity/source/drivers/evoab/LDriver.hxx +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************* - * - * 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: LDriver.hxx,v $ - * $Revision: 1.6 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LDRIVER_HXX_ -#define _CONNECTIVITY_EVOAB_LDRIVER_HXX_ - -#include <cppuhelper/compbase2.hxx> -#include "connectivity/CommonTools.hxx" -#include "file/FDriver.hxx" -#include <unotools/tempfile.hxx> -#include <osl/file.h> -#include <osl/process.h> - -#define EVOAB_EVOLUTION_SCHEMA "evolution" -#define EVOAB_LDAP_SCHEMA "ldap" -#define EVOAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.evoab.OEvoabDriver" - -namespace connectivity -{ - namespace evoab - { - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ); - - class OEvoabDriver : public file::OFileDriver - { - private: - enum MaybeVoidBool - { - eUnknown, - eTrue, - eFalse - }; - ::utl::TempFile m_aTempDir; - rtl::OUString m_aFolderListName; - rtl::OUString m_aVersionName; - rtl::OUString m_aFileExt; - rtl::OUString m_aWorkingDirURL; - rtl::OUString m_aEvoab_CLI_EffectiveCommand; - rtl::OUString m_aEvoab_CLI_FullPathCommand; - sal_Bool m_bWorkingDirCreated; - MaybeVoidBool m_eSupportedEvoVersion; - - sal_Bool fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir=sal_False) const; - - public: - OEvoabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); - - inline rtl::OUString getEvoFolderListName() const { return m_aFolderListName;} - inline rtl::OUString getFileExt() const { return m_aFileExt;} - inline rtl::OUString getEvoFolderListFileName() const { return m_aFolderListName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;} - inline rtl::OUString getEvoVersionFileName() const { return m_aVersionName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;} - inline rtl::OUString getWorkingDirURL() const { return m_aWorkingDirURL;} - inline rtl::OUString getEvoab_CLI_FullPathCommand() const { return m_aEvoab_CLI_FullPathCommand;} - inline rtl::OUString getEvoab_CLI_EffectiveCommand() const { return m_aEvoab_CLI_EffectiveCommand;} - inline sal_Bool doesEvoab_CLI_HavePath() const { return m_aEvoab_CLI_FullPathCommand.lastIndexOf('/')!=-1;} - const rtl::OUString getEvoab_CLI_Command() const; - const rtl::OUString getEvoab_CLI_Path() const; - const rtl::OUString getWorkingDirPath() const; - const String getEvoFolderListFileURL() const; - String getTempDirURL() const; - - // XInterface - ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); - // XDriver - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - - // static methods - static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException); - static sal_Bool acceptsURL_Stat( const ::rtl::OUString& url ); - static ::rtl::OUString translateProcessErrorMessage( oslProcessError nProcErr); - static ::rtl::OUString translateFileErrorMessage( oslFileError nFileErr); - static const sal_Char* getSDBC_SCHEME_EVOLUTION(); - static const sal_Char* getEVOAB_FOLDERLIST_FILE_NAME(); - static const sal_Char* getEVOAB_VERSION_FILE_NAME(); - static const sal_Char* getEVOAB_META_FILE_EXT(); - static const sal_Char* getEVOAB_CLI_FULLPATHCOMMAND(); - static const sal_Char* getEVOAB_CLI_ARG_LIST_FOLDERS(); - static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX(); - static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FORMAT(); - static const sal_Char* getEVOAB_CLI_ARG_VERSION(); - static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_REDIRECT(); - - }; - } - -} -#endif //_CONNECTIVITY_EVOAB_LDRIVER_HXX_ diff --git a/connectivity/source/drivers/evoab/LFolderList.cxx b/connectivity/source/drivers/evoab/LFolderList.cxx deleted file mode 100644 index a3c031c05c05..000000000000 --- a/connectivity/source/drivers/evoab/LFolderList.cxx +++ /dev/null @@ -1,566 +0,0 @@ -/************************************************************************* - * - * 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: LFolderList.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_connectivity.hxx" - -#include <ctype.h> -#include <algorithm> -#include "LFolderList.hxx" -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <svtools/converter.hxx> -#include "LConnection.hxx" -#include "LColumns.hxx" -#include <osl/thread.h> -#include <tools/config.hxx> -#include <comphelper/sequence.hxx> -#include <svtools/zforlist.hxx> -#include <rtl/math.hxx> -#include <stdio.h> //sprintf -#include <comphelper/extract.hxx> -#include <comphelper/numbers.hxx> -#include "LDriver.hxx" -#include <com/sun/star/util/NumberFormat.hpp> -#include <unotools/configmgr.hxx> -#include <i18npool/mslangid.hxx> -#include "connectivity/dbconversion.hxx" -#include <comphelper/types.hxx> -#include <unotools/ucbstreamhelper.hxx> -#include <tools/debug.hxx> -#include "connectivity/dbexception.hxx" -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#include "LDebug.hxx" -#endif -#include <svtools/syslocale.hxx> - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::cppu; -using namespace utl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -// ------------------------------------------------------------------------- -void OEvoabFolderList::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) -{ - BOOL bRead = TRUE; - - QuotedTokenizedString aHeaderLine; - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - - // read first row - QuotedTokenizedString aFirstLine; - bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); - - while(bRead && !aFirstLine.Len()) - { - bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); - } - // use first row as headerline because we need the number of columns - aHeaderLine = aFirstLine; - - // column count - xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - - if(!m_aColumns.isValid()) - m_aColumns = new OSQLColumns(); - else - m_aColumns->get().clear(); - - m_aTypes.clear(); - m_aPrecisions.clear(); - m_aScales.clear(); - // reserve some space - m_aColumns->get().reserve(nFieldCount); - m_aTypes.reserve(nFieldCount); - m_aPrecisions.reserve(nFieldCount); - m_aScales.reserve(nFieldCount); - - sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); - CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale); - // read description - sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); - sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); - String aColumnName; - ::rtl::OUString aTypeName; - ::comphelper::UStringMixEqual aCase(bCase); - xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens - xub_StrLen nStartPosFirstLine2 = 0; - for (xub_StrLen i = 0; i < nFieldCount; i++) - { - - // no column name so ... - aColumnName = 'C'; - aColumnName += String::CreateFromInt32(i+1); - - sal_Int32 eType; - UINT16 nPrecision = 0; - UINT16 nScale = 0; - - BOOL bNumeric = FALSE; - ULONG nIndex = 0; - - // first without fielddelimiter - String aField; - aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0'); - if (aField.Len() == 0 || - (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0))) - { - bNumeric = FALSE; - } - else - { - String aField2; - if ( pConnection->getStringDelimiter() != '\0' ) - aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - else - aField2 = aField; - - if (aField2.Len() == 0) - { - bNumeric = FALSE; - } - else - { - bNumeric = TRUE; - xub_StrLen nDot = 0; - for (xub_StrLen j = 0; j < aField2.Len(); j++) - { - sal_Unicode c = aField2.GetChar(j); - // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? - if ((!cDecimalDelimiter || c != cDecimalDelimiter) && - (!cThousandDelimiter || c != cThousandDelimiter) && - !aCharClass.isDigit(aField2,j)) - { - bNumeric = FALSE; - break; - } - if (cDecimalDelimiter && c == cDecimalDelimiter) - { - nPrecision = 15; // we have an decimal value - nScale = 2; - nDot++; - } - } - - if (nDot > 1) // if there is more than one dot it isn't a number - bNumeric = FALSE; - if (bNumeric && cThousandDelimiter) - { - // Ist der Trenner richtig angegeben? - String aValue = aField2.GetToken(0,cDecimalDelimiter); - for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4) - { - sal_Unicode c = aValue.GetChar(j); - // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? - if (c == cThousandDelimiter && j) - continue; - else - { - bNumeric = FALSE; - break; - } - } - } - - // jetzt koennte es noch ein Datumsfeld sein - if (!bNumeric) - { - try - { - nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2); - } - catch(Exception&) - { - } - } - } - } - - sal_Int32 nFlags = 0; - if (bNumeric) - { - if (cDecimalDelimiter) - { - if(nPrecision) - { - eType = DataType::DECIMAL; - aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); - } - else - { - eType = DataType::DOUBLE; - aTypeName = ::rtl::OUString::createFromAscii("DOUBLE"); - } - } - else - eType = DataType::INTEGER; - nFlags = ColumnSearch::BASIC; - } - else - { - - switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex)) - { - case NUMBERFORMAT_DATE: - eType = DataType::DATE; - aTypeName = ::rtl::OUString::createFromAscii("DATE"); - break; - case NUMBERFORMAT_DATETIME: - eType = DataType::TIMESTAMP; - aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP"); - break; - case NUMBERFORMAT_TIME: - eType = DataType::TIME; - aTypeName = ::rtl::OUString::createFromAscii("TIME"); - break; - default: - eType = DataType::VARCHAR; - nPrecision = 0; // nyi: Daten koennen aber laenger sein! - nScale = 0; - aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); - }; - nFlags |= ColumnSearch::CHAR; - } - - // check if the columname already exists - String aAlias(aColumnName); - OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); - sal_Int32 nExprCnt = 0; - while(aFind != m_aColumns->get().end()) - { - (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt); - aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); - } - - sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(), - ColumnValue::NULLABLE, - nPrecision, - nScale, - eType, - sal_False, - sal_False, - sal_False, - bCase); - Reference< XPropertySet> xCol = pColumn; - m_aColumns->get().push_back(xCol); - m_aTypes.push_back(eType); - m_aPrecisions.push_back(nPrecision); - m_aScales.push_back(nScale); - } - m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); -} -// ------------------------------------------------------------------------- -DBG_NAME( OEvoabFolderList ); -OEvoabFolderList::OEvoabFolderList(OEvoabConnection* _pConnection) - :m_nFilePos(0) - ,m_pFileStream(NULL) - ,m_pConnection(_pConnection) - ,m_bIsNull(sal_False) -{ - DBG_CTOR( OEvoabFolderList, NULL ); - m_aColumns = new OSQLColumns(); - - construct(); -} -// ----------------------------------------------------------------------------- -void OEvoabFolderList::construct() -{ - SvtSysLocale aLocale; - ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale()); - Sequence< ::com::sun::star::uno::Any > aArg(1); - aArg[0] <<= aAppLocale; - - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY); - m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY); - m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier); - - INetURLObject aURL; - aURL.SetURL(m_pConnection->getDriver()->getEvoFolderListFileURL()); - - String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); - - EVO_TRACE_STRING("OJ::construct()::aFileName = %s\n", aFileName ); - m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); - - if(!m_pFileStream) - m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE); - - if(m_pFileStream) - { - m_pFileStream->Seek(STREAM_SEEK_TO_END); - sal_Int32 nSize = m_pFileStream->Tell(); - m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); - - // Buffersize abhaengig von der Filegroesse - m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 : - nSize > 100000 ? 16384 : - nSize > 10000 ? 4096 : 1024); - OSL_TRACE("OEvoabFolderList::construct()::m_pFileStream->Tell() = %d\n", nSize ); - - fillColumns(aAppLocale); - } -} - - -//------------------------------------------------------------------ -sal_Bool OEvoabFolderList::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols) -{ - (_rRow->get())[0] = m_nFilePos; // the "bookmark" - - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - // Felder: - xub_StrLen nStartPos = 0; - String aStr; - OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); - for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i) - { - m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - //OSL_TRACE("OEvoabFolderList::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) ); - - if (aStr.Len() == 0) - (_rRow->get())[i+1].setNull(); - else - { - // length depending on the data type - sal_Int32 nType = m_aTypes[i]; - switch(nType) - { - case DataType::TIMESTAMP: - case DataType::DATE: - case DataType::TIME: - { - double nRes = 0.0; - try - { - nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr); - Reference<XPropertySet> xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY); - com::sun::star::util::Date aDate; - xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate; - - switch(nType) - { - case DataType::DATE: - (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); - break; - case DataType::TIMESTAMP: - (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); - break; - default: - (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); - } - } - catch(Exception&) - { - (_rRow->get())[i+1].setNull(); - } - } break; - case DataType::DOUBLE: - case DataType::INTEGER: - case DataType::DECIMAL: // #99178# OJ - case DataType::NUMERIC: - { - sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); - sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); - String aStrConverted; - - OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER || - !cDecimalDelimiter && nType == DataType::INTEGER, - "FalscherTyp"); - - // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln: - for (xub_StrLen j = 0; j < aStr.Len(); ++j) - { - if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter) - aStrConverted += '.'; - else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it - break; // #99189# OJ - else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter) - { - // weglassen - } - else - aStrConverted += aStr.GetChar(j) ; - } - double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL); - - // #99178# OJ - if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType ) - (_rRow->get())[i+1] = String::CreateFromDouble(nVal); - else - (_rRow->get())[i+1] = nVal; - } break; - - default: - { - // Wert als String in Variable der Row uebernehmen - (_rRow->get())[i+1] = aStr; - } - break; - } - } - } - return sal_True; -} - - -//------------------------------------------------------------------ -sal_Bool OEvoabFolderList::seekRow(IResultSetHelper::Movement eCursorPosition) -{ - //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - if ( !m_pFileStream ) - return sal_False; - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - // ---------------------------------------------------------- - // Positionierung vorbereiten: - //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - switch(eCursorPosition) - { - case IResultSetHelper::FIRST: - m_nFilePos = 0; - // run through - - case IResultSetHelper::NEXT: - m_pFileStream->Seek(m_nFilePos); - - if (m_pFileStream->IsEof()) - { - OSL_TRACE( "OEvoabFolderList::seekRow: EOF /before/ reading the line." ); - return sal_False; - } - - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - { - OSL_TRACE( "OEvoabFolderList::seekRow: EOF /after/ reading the line." ); - if ( !m_aCurrentLine.Len() ) - { - OSL_TRACE( "OEvoabFolderList::seekRow: empty line read." ); - return sal_False; - } - } - m_nFilePos = m_pFileStream->Tell(); - break; - - default: - OSL_ENSURE( sal_False, "OEvoabFolderList::seekRow: unsupported positioning!" ); - break; - } - - //OSL_TRACE("OEvoabFolderList::seekRow()::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - return sal_True; -} -// ----------------------------------------------------------------------------- -SvStream* OEvoabFolderList::createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode) -{ - utl::UcbLockBytesHandler* p_null_dummy=NULL; - SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, p_null_dummy); - if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode())) - { - delete pReturn; - pReturn = NULL; - } - return pReturn; -} -// ----------------------------------------------------------------------------- -const ORowSetValue& OEvoabFolderList::getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException) -{ - checkIndex( _nColumnIndex ); - - m_bIsNull = (m_aRow->get())[_nColumnIndex].isNull(); - return (m_aRow->get())[_nColumnIndex]; -} -// ----------------------------------------------------------------------------- -void OEvoabFolderList::checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException) -{ - if ( _nColumnIndex <= 0 || _nColumnIndex >= (sal_Int32)m_aRow->get().size() ) { -// ::dbtools::throwInvalidIndexException(); - ; - } -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL OEvoabFolderList::getString( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException) -{ - return getValue(_nColumnIndex); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL OEvoabFolderList::getInt( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException) -{ - return getValue( _nColumnIndex ); -} -// ----------------------------------------------------------------------------- -void OEvoabFolderList::initializeRow(sal_Int32 _nColumnCount) -{ - if(!m_aRow.isValid()) - { - m_aRow = new OValueVector(_nColumnCount); - (m_aRow->get())[0].setBound(sal_True); - ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False)); - } - //OSL_TRACE("OEvoabFolderList::initializeRow()::_nColumnCount = %d\n", _nColumnCount); - -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL OEvoabFolderList::first( ) throw(SQLException, RuntimeException) -{ - sal_Bool bSuccess = seekRow(IResultSetHelper::FIRST); - - EVO_TRACE_STRING("OEvoabFolderList::first(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) ); - return bSuccess; -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL OEvoabFolderList::next( ) throw(SQLException, RuntimeException) -{ - sal_Bool bSuccess = seekRow(IResultSetHelper::NEXT); - - EVO_TRACE_STRING("OEvoabFolderList::next(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) ); - return bSuccess; -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL OEvoabFolderList::getRow( ) throw(SQLException, RuntimeException) -{ - sal_Bool bRet = fetchRow(m_aRow,getTableColumns().getBody()); - EVO_TRACE_STRING("OEvoabFolderList::getRow()::fetchRow() = %s\n", ::rtl::OUString::valueOf(bRet) ); - - return bRet; -} diff --git a/connectivity/source/drivers/evoab/LFolderList.hxx b/connectivity/source/drivers/evoab/LFolderList.hxx deleted file mode 100644 index baa2a3b05e86..000000000000 --- a/connectivity/source/drivers/evoab/LFolderList.hxx +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************* - * - * 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: LFolderList.hxx,v $ - * $Revision: 1.6 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ -#define _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ - -#include "connectivity/sdbcx/VColumn.hxx" -#include "connectivity/CommonTools.hxx" -#include <tools/urlobj.hxx> -#include "LTable.hxx" -#include "TResultSetHelper.hxx" - - -namespace connectivity -{ - namespace evoab - { - //================================================================== - // Ableitung von String mit ueberladenen GetToken/GetTokenCount-Methoden - // Speziell fuer FLAT FILE-Format: Strings koennen gequotet sein - //================================================================== - - class OEvoabConnection; - - class OEvoabFolderList - { - // maps a row postion to a file position - ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset - ::std::vector<sal_Int32> m_aPrecisions; // same as aboth - ::std::vector<sal_Int32> m_aScales; - QuotedTokenizedString m_aCurrentLine; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter; - sal_Int32 m_nFilePos; // aktuelle IResultSetHelper::Movement - SvStream* m_pFileStream; - OEvoabConnection* m_pConnection; - ::vos::ORef<OSQLColumns> m_aColumns; - OValueRow m_aRow; - sal_Bool m_bIsNull; - - private: - void fillColumns(const ::com::sun::star::lang::Locale& _aLocale); - BOOL CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo); - - sal_Bool fetchRow(OValueRow _rRow,const OSQLColumns& _rCols); - sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition); - - public: - - OEvoabFolderList( OEvoabConnection* _pConnection); - - OEvoabConnection* getConnection() const { return m_pConnection;} - ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;} - void construct(); // can throw any exception - static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode); - void initializeRow(sal_Int32 _nColumnCount); - void checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException); - const ORowSetValue& getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException); - ::rtl::OUString SAL_CALL getString( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Int32 SAL_CALL getInt( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_ - diff --git a/connectivity/source/drivers/evoab/LNoException.cxx b/connectivity/source/drivers/evoab/LNoException.cxx deleted file mode 100644 index 183ab75559f4..000000000000 --- a/connectivity/source/drivers/evoab/LNoException.cxx +++ /dev/null @@ -1,327 +0,0 @@ -/************************************************************************* - * - * 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: LNoException.cxx,v $ - * $Revision: 1.6 $ - * - * 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_connectivity.hxx" -#include "LTable.hxx" -#include "LConnection.hxx" - -using namespace connectivity; -using namespace connectivity::evoab; - -//------------------------------------------------------------------ -xub_StrLen OEvoabString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const -{ - if ( !Len() ) - return 0; - - xub_StrLen nTokCount = 1; - BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token? - BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String? - - // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen - for( xub_StrLen i = 0; i < Len(); i++ ) - { - if (bStart) - { - bStart = FALSE; - // Erstes Zeichen ein String-Delimiter? - if ((*this).GetChar(i) == cStrDel) - { - bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings! - continue; // dieses Zeichen ueberlesen! - } - } - - if (bInString) { - // Wenn jetzt das String-Delimiter-Zeichen auftritt ... - if ( (*this).GetChar(i) == cStrDel ) - { - if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) - { - // Verdoppeltes String-Delimiter-Zeichen: - i++; // kein String-Ende, naechstes Zeichen ueberlesen. - } - else - { - // String-Ende - bInString = FALSE; - } - } - } else { - // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount - if ( (*this).GetChar(i) == cTok ) - { - nTokCount++; - bStart = TRUE; - } - } - } - //OSL_TRACE("OEvoabString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) ); - - return nTokCount; -} - -//------------------------------------------------------------------ -void OEvoabString::GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel ) const -{ - _rStr.Erase(); - xub_StrLen nLen = Len(); - if ( nLen ) - { - BOOL bInString = (nStartPos < nLen) && ((*this).GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String? - - // Erstes Zeichen ein String-Delimiter? - if (bInString ) - ++nStartPos; // dieses Zeichen ueberlesen! - // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen - for( xub_StrLen i = nStartPos; i < nLen; ++i ) - { - if (bInString) - { - // Wenn jetzt das String-Delimiter-Zeichen auftritt ... - if ( (*this).GetChar(i) == cStrDel ) - { - if ((i+1 < nLen) && ((*this).GetChar(i+1) == cStrDel)) - { - // Verdoppeltes String-Delimiter-Zeichen: - ++i; // kein String-Ende, naechstes Zeichen ueberlesen. - - _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String - } - else - { - // String-Ende - bInString = FALSE; - } - } - else - { - _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String - } - - } - else - { - // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok - if ( (*this).GetChar(i) == cTok ) - { - // Vorzeitiger Abbruch der Schleife moeglich, denn - // wir haben, was wir wollten. - nStartPos = i+1; - break; - } - else - { - _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String - } - } - } - } -} -// ----------------------------------------------------------------------------- -void OEvoabTable::refreshIndexes() -{ -} -// ----------------------------------------------------------------------------- -sal_Bool OEvoabTable::checkHeaderLine() -{ - if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine()) - { - BOOL bRead2; - do - { - bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding()); - } - while(bRead2 && !m_aCurrentLine.Len()); - - m_nFilePos = m_pFileStream->Tell(); - if (m_pFileStream->IsEof()) - return sal_False; - } - return sal_True; -} -//------------------------------------------------------------------ -sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) -{ - //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - if ( !m_pFileStream ) - return sal_False; - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - // ---------------------------------------------------------- - // Positionierung vorbereiten: - //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - m_nFilePos = nCurPos; - - switch(eCursorPosition) - { - case IResultSetHelper::FIRST: - m_nFilePos = 0; - m_nRowPos = 1; - // run through - case IResultSetHelper::NEXT: - if(eCursorPosition != IResultSetHelper::FIRST) - ++m_nRowPos; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - - m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos)); - - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - nCurPos = m_pFileStream->Tell(); - break; - case IResultSetHelper::PRIOR: - --m_nRowPos; - if(m_nRowPos > 0) - { - m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - m_nRowPos = 0; - - break; - - break; - case IResultSetHelper::LAST: - if(m_nMaxRowCount) - { - m_nFilePos = m_aRowToFilePos.rbegin()->second; - m_nRowPos = m_aRowToFilePos.rbegin()->first; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - { - while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row - // now I know all - seekRow(IResultSetHelper::PRIOR,1,nCurPos); - } - break; - case IResultSetHelper::RELATIVE: - if(nOffset > 0) - { - for(sal_Int32 i = 0;i<nOffset;++i) - seekRow(IResultSetHelper::NEXT,1,nCurPos); - } - else if(nOffset < 0) - { - for(sal_Int32 i = nOffset;i;++i) - seekRow(IResultSetHelper::PRIOR,1,nCurPos); - } - break; - case IResultSetHelper::ABSOLUTE: - { - if(nOffset < 0) - nOffset = m_nRowPos + nOffset; - ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset); - if(aIter != m_aRowToFilePos.end()) - { - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table - { - m_nRowPos = m_nMaxRowCount; - return sal_False; - } - else - { - aIter = m_aRowToFilePos.upper_bound(nOffset); - if(aIter == m_aRowToFilePos.end()) - { - m_nRowPos = m_aRowToFilePos.rbegin()->first; - nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; - while(m_nRowPos != nOffset) - seekRow(IResultSetHelper::NEXT,1,nCurPos); - } - else - { - --aIter; - m_nRowPos = aIter->first; - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - } - } - - break; - case IResultSetHelper::BOOKMARK: - m_pFileStream->Seek(nOffset); - if (m_pFileStream->IsEof()) - return sal_False; - - m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - break; - } - - //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - return sal_True; -} -// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.cxx b/connectivity/source/drivers/evoab/LPreparedStatement.cxx deleted file mode 100644 index fa4269fdce4d..000000000000 --- a/connectivity/source/drivers/evoab/LPreparedStatement.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * - * 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: LPreparedStatement.cxx,v $ - * $Revision: 1.5 $ - * - * 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_connectivity.hxx" -#include "LPreparedStatement.hxx" -#include "LResultSet.hxx" - -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::com::sun::star::uno; -// ------------------------------------------------------------------------- -OResultSet* OEvoabPreparedStatement::createResultSet() -{ - return new OEvoabResultSet(this,m_aSQLIterator); -} -// ------------------------------------------------------------------------- -IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbc.driver.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); - diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.hxx b/connectivity/source/drivers/evoab/LPreparedStatement.hxx deleted file mode 100644 index e4260ef3a994..000000000000 --- a/connectivity/source/drivers/evoab/LPreparedStatement.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************* - * - * 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: LPreparedStatement.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ -#define _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ - -#include "file/FPreparedStatement.hxx" - -namespace connectivity -{ - namespace evoab - { - class OConnection; - class OEvoabPreparedStatement : public file::OPreparedStatement - { - protected: - virtual file::OResultSet* createResultSet(); - public: - OEvoabPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){}; - DECLARE_SERVICE_INFO(); - }; - } -} - -#endif //_CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_ - diff --git a/connectivity/source/drivers/evoab/LResultSet.cxx b/connectivity/source/drivers/evoab/LResultSet.cxx deleted file mode 100644 index fd4959465710..000000000000 --- a/connectivity/source/drivers/evoab/LResultSet.cxx +++ /dev/null @@ -1,193 +0,0 @@ -/************************************************************************* - * - * 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: LResultSet.cxx,v $ - * $Revision: 1.8 $ - * - * 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_connectivity.hxx" -#include <com/sun/star/sdbcx/CompareBookmark.hpp> -#include <com/sun/star/sdbcx/XDeleteRows.hpp> -#include "LResultSet.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <comphelper/sequence.hxx> -#include <comphelper/types.hxx> - -using namespace ::comphelper; - -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::cppu; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::beans; -using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; -// using namespace com::sun::star::container; -// using namespace com::sun::star::util; -//------------------------------------------------------------------------------ -OEvoabResultSet::OEvoabResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator) - : file::OResultSet(pStmt,_aSQLIterator) - ,m_bBookmarkable(sal_True) -{ - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType()); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) -{ - return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.evoab.ResultSet"); -} -// ------------------------------------------------------------------------- -Sequence< ::rtl::OUString > SAL_CALL OEvoabResultSet::getSupportedServiceNames( ) throw( RuntimeException) -{ - Sequence< ::rtl::OUString > aSupported(2); - aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet"); - aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet"); - return aSupported; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException) -{ - Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); - const ::rtl::OUString* pSupported = aSupported.getConstArray(); - const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); - for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) - ; - - return pSupported != pEnd; -} -// ------------------------------------------------------------------------- -Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) -{ - if(rType == ::getCppuType((const Reference<XDeleteRows>*)0) || rType == ::getCppuType((const Reference<XResultSetUpdate>*)0) - || rType == ::getCppuType((const Reference<XRowUpdate>*)0)) - return Any(); - - Any aRet = OResultSet::queryInterface(rType); - return aRet.hasValue() ? aRet : OEvoabResultSet_BASE::queryInterface(rType); -} -// ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) -{ - Sequence< Type > aTypes = OResultSet::getTypes(); - ::std::vector<Type> aOwnTypes; - aOwnTypes.reserve(aTypes.getLength()); - const Type* pBegin = aTypes.getConstArray(); - const Type* pEnd = pBegin + aTypes.getLength(); - for(;pBegin != pEnd;++pBegin) - { - if(!(*pBegin == ::getCppuType((const Reference<XDeleteRows>*)0) || - *pBegin == ::getCppuType((const Reference<XResultSetUpdate>*)0) || - *pBegin == ::getCppuType((const Reference<XRowUpdate>*)0))) - { - aOwnTypes.push_back(*pBegin); - } - } - Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; - Sequence< Type > aRet(pTypes, aOwnTypes.size()); - return ::comphelper::concatSequences(aRet,OEvoabResultSet_BASE::getTypes()); -} - -// ------------------------------------------------------------------------- -// XRowLocate -Any SAL_CALL OEvoabResultSet::getBookmark( ) throw( SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; - - return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - - m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; - - Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False); - - return relative(rows); -} - -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL OEvoabResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException) -{ - return (lhs == rhs) ? 0 : 2; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException) -{ - return sal_True; -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL OEvoabResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) -{ - return comphelper::getINT32(bookmark); -} -// ------------------------------------------------------------------------- -IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const -{ - Sequence< Property > aProps; - describeProperties(aProps); - return new ::cppu::OPropertyArrayHelper(aProps); -} -// ------------------------------------------------------------------------- -IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() -{ - return *OEvoabResultSet_BASE3::getArrayHelper(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL OEvoabResultSet::acquire() throw() -{ - OEvoabResultSet_BASE2::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL OEvoabResultSet::release() throw() -{ - OEvoabResultSet_BASE2::release(); -} -// ----------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} -// ----------------------------------------------------------------------------- - diff --git a/connectivity/source/drivers/evoab/LResultSet.hxx b/connectivity/source/drivers/evoab/LResultSet.hxx deleted file mode 100644 index f93ba9364e5a..000000000000 --- a/connectivity/source/drivers/evoab/LResultSet.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************* - * - * 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: LResultSet.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LRESULTSET_HXX_ -#define _CONNECTIVITY_EVOAB_LRESULTSET_HXX_ - -#include "file/FResultSet.hxx" -#include <com/sun/star/sdbcx/XRowLocate.hpp> -#include <cppuhelper/implbase1.hxx> - -namespace connectivity -{ - namespace evoab - { - class OEvoabResultSet; - // these typedef's are only necessary for the compiler - typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XRowLocate> OEvoabResultSet_BASE; - typedef file::OResultSet OEvoabResultSet_BASE2; - typedef ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> OEvoabResultSet_BASE3; - - - class OEvoabResultSet : public OEvoabResultSet_BASE2, - public OEvoabResultSet_BASE, - public OEvoabResultSet_BASE3 - { - sal_Bool m_bBookmarkable; - protected: - // OPropertyArrayUsageHelper - virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; - // OPropertySetHelper - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - public: - DECLARE_SERVICE_INFO(); - - OEvoabResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); - - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - // XPropertySet - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - - // XRowLocate - virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; - } -} -#endif //_CONNECTIVITY_EVOAB_LRESULTSET_HXX_ - diff --git a/connectivity/source/drivers/evoab/LServices.cxx b/connectivity/source/drivers/evoab/LServices.cxx deleted file mode 100644 index bab5ae8cfce9..000000000000 --- a/connectivity/source/drivers/evoab/LServices.cxx +++ /dev/null @@ -1,178 +0,0 @@ -/************************************************************************* - * - * 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: LServices.cxx,v $ - * $Revision: 1.6 $ - * - * 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_connectivity.hxx" -#include "LDriver.hxx" -#include <cppuhelper/factory.hxx> -#include <osl/diagnose.h> - -using namespace connectivity::evoab; -using ::rtl::OUString; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::registry::XRegistryKey; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - -typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::cppu::ComponentInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames, - rtl_ModuleCount* _pT - ); - -//*************************************************************************************** -// -// Die vorgeschriebene C-Api muss erfuellt werden! -// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. -// - -//--------------------------------------------------------------------------------------- -void REGISTER_PROVIDER( - const OUString& aServiceImplName, - const Sequence< OUString>& Services, - const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) -{ - OUString aMainKeyName; - aMainKeyName = OUString::createFromAscii("/"); - aMainKeyName += aServiceImplName; - aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); - - Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); - OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !"); - - for (sal_Int32 i=0; i<Services.getLength(); ++i) - xNewKey->createKey(Services[i]); -} - - -//--------------------------------------------------------------------------------------- -struct ProviderRequest -{ - Reference< XSingleServiceFactory > xRet; - Reference< XMultiServiceFactory > const xServiceManager; - OUString const sImplementationName; - - ProviderRequest( - void* pServiceManager, - sal_Char const* pImplementationName - ) - : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) - , sImplementationName(OUString::createFromAscii(pImplementationName)) - { - } - - inline - sal_Bool CREATE_PROVIDER( - const OUString& Implname, - const Sequence< OUString > & Services, - ::cppu::ComponentInstantiation Factory, - createFactoryFunc creator - ) - { - if (!xRet.is() && (Implname == sImplementationName)) - try - { - xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); - } - catch(...) - { - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - -//--------------------------------------------------------------------------------------- - -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL -component_getImplementationEnvironment( - const sal_Char **ppEnvTypeName, - uno_Environment ** /*ppEnv*/ - ) -{ - *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; -} - -//--------------------------------------------------------------------------------------- -extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - void* /*pServiceManager*/, - void* pRegistryKey - ) -{ - if (pRegistryKey) - try - { - Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); - - REGISTER_PROVIDER( - OEvoabDriver::getImplementationName_Static(), - OEvoabDriver::getSupportedServiceNames_Static(), xKey); - - return sal_True; - } - catch (::com::sun::star::registry::InvalidRegistryException& ) - { - OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); - } - - return sal_False; -} - -//--------------------------------------------------------------------------------------- -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( - const sal_Char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = 0; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - OEvoabDriver::getImplementationName_Static(), - OEvoabDriver::getSupportedServiceNames_Static(), - OEvoabDriver_CreateInstance, ::cppu::createSingleFactory) - ; - - if(aReq.xRet.is()) - aReq.xRet->acquire(); - - pRet = aReq.getProvider(); - } - - return pRet; -}; - diff --git a/connectivity/source/drivers/evoab/LStatement.cxx b/connectivity/source/drivers/evoab/LStatement.cxx deleted file mode 100644 index 9ef945b1ccd4..000000000000 --- a/connectivity/source/drivers/evoab/LStatement.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * - * 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: LStatement.cxx,v $ - * $Revision: 1.5 $ - * - * 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_connectivity.hxx" -#include "LStatement.hxx" -#include "LResultSet.hxx" - -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace com::sun::star::uno; -// ------------------------------------------------------------------------- -OResultSet* OEvoabStatement::createResultSet() -{ - return new OEvoabResultSet(this,m_aSQLIterator); -} -// ------------------------------------------------------------------------- -IMPLEMENT_SERVICE_INFO(OEvoabStatement,"com.sun.star.sdbc.driver.evoab.Statement","com.sun.star.sdbc.Statement"); - diff --git a/connectivity/source/drivers/evoab/LStatement.hxx b/connectivity/source/drivers/evoab/LStatement.hxx deleted file mode 100644 index 9e8af7f7b273..000000000000 --- a/connectivity/source/drivers/evoab/LStatement.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * 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: LStatement.hxx,v $ - * $Revision: 1.4 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ -#define _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ - -#include "file/FStatement.hxx" - -namespace connectivity -{ - namespace evoab - { - class OConnection; - class OEvoabStatement : public file::OStatement - { - protected: - virtual file::OResultSet* createResultSet(); - public: - OEvoabStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} - DECLARE_SERVICE_INFO(); - }; - } -} - -#endif //_CONNECTIVITY_EVOAB_LSTATEMENT_HXX_ diff --git a/connectivity/source/drivers/evoab/LTable.cxx b/connectivity/source/drivers/evoab/LTable.cxx deleted file mode 100644 index cbb4bc53e9f4..000000000000 --- a/connectivity/source/drivers/evoab/LTable.cxx +++ /dev/null @@ -1,873 +0,0 @@ -/************************************************************************* - * - * 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: LTable.cxx,v $ - * $Revision: 1.18 $ - * - * 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_connectivity.hxx" - -#include <ctype.h> -#include "LTable.hxx" -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/ucb/XContentAccess.hpp> -#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_ -//#include <com/sun/star/sdbc/XRow.hpp> -#endif -#include <svtools/converter.hxx> -#include "LConnection.hxx" -#include "LColumns.hxx" -#include <osl/thread.h> -#include <tools/config.hxx> -#include <comphelper/sequence.hxx> -#include <svtools/zforlist.hxx> -#include <rtl/math.hxx> -#include <stdio.h> //sprintf -#include <comphelper/extract.hxx> -#include <comphelper/numbers.hxx> -#include "LDriver.hxx" -#include <com/sun/star/util/NumberFormat.hpp> -#include <unotools/configmgr.hxx> -#include <i18npool/mslangid.hxx> -#include "connectivity/dbconversion.hxx" -#include <comphelper/types.hxx> -#include <svtools/syslocale.hxx> -#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX -#include "LDebug.hxx" -#endif -#include <map> - -using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::cppu; -using namespace utl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::ucb; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -// ------------------------------------------------------------------------- -void OEvoabTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale) -{ - BOOL bRead = TRUE; - - QuotedTokenizedString aHeaderLine; - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - if (pConnection->isHeaderLine()) - { - while(bRead && !aHeaderLine.Len()) - { - bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,pConnection->getTextEncoding()); - } - } - - // read first row - QuotedTokenizedString aFirstLine; - bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); - - if (!pConnection->isHeaderLine() || !aHeaderLine.Len()) - { - while(bRead && !aFirstLine.Len()) - { - bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding()); - } - // use first row as headerline because we need the number of columns - aHeaderLine = aFirstLine; - } - // column count - xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - - if(!m_aColumns.isValid()) - m_aColumns = new OSQLColumns(); - else - m_aColumns->get().clear(); - - m_aTypes.clear(); - m_aPrecisions.clear(); - m_aScales.clear(); - // reserve some space - m_aColumnRawNames.reserve(nFieldCount); - m_aColumns->get().reserve(nFieldCount); - m_aTypes.reserve(nFieldCount); - m_aPrecisions.reserve(nFieldCount); - m_aScales.reserve(nFieldCount); - - sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); - CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale); - // read description - sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); - sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); - String aColumnName; - ::rtl::OUString aTypeName; - ::comphelper::UStringMixEqual aCase(bCase); - xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens - xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens - xub_StrLen nStartPosFirstLine2 = 0; - for (xub_StrLen i = 0; i < nFieldCount; i++) - { - if (pConnection->isHeaderLine()) - { - aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - } - else - { - // no column name so ... - aColumnName = 'C'; - aColumnName += String::CreateFromInt32(i+1); - } - //OSL_TRACE("OEvoabTable::aColumnName = %s\n", ((OUtoCStr(::rtl::OUString(aColumnName))) ? (OUtoCStr(::rtl::OUString(aColumnName))):("NULL")) ); - - sal_Int32 eType; - UINT16 nPrecision = 0; - UINT16 nScale = 0; - - BOOL bNumeric = FALSE; - ULONG nIndex = 0; - - // first without fielddelimiter - String aField; - aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0'); - //OSL_TRACE("OEvoabTable::aField = %s\n", ((OUtoCStr(::rtl::OUString(aField))) ? (OUtoCStr(::rtl::OUString(aField))):("NULL")) ); - - if (aField.Len() == 0 || - (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0))) - { - bNumeric = FALSE; - } - else - { - String aField2; - if ( pConnection->getStringDelimiter() != '\0' ) - aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - else - aField2 = aField; - - //OSL_TRACE("OEvoabTable::aField2 = %s\n", ((OUtoCStr(::rtl::OUString(aField2))) ? (OUtoCStr(::rtl::OUString(aField2))):("NULL")) ); - - if (aField2.Len() == 0) - { - bNumeric = FALSE; - } - else - { - bNumeric = TRUE; - xub_StrLen nDot = 0; - for (xub_StrLen j = 0; j < aField2.Len(); j++) - { - sal_Unicode c = aField2.GetChar(j); - // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? - if ((!cDecimalDelimiter || c != cDecimalDelimiter) && - (!cThousandDelimiter || c != cThousandDelimiter) && - !aCharClass.isDigit(aField2,j)) - { - bNumeric = FALSE; - break; - } - if (cDecimalDelimiter && c == cDecimalDelimiter) - { - nPrecision = 15; // we have an decimal value - nScale = 2; - nDot++; - } - } - - if (nDot > 1) // if there is more than one dot it isn't a number - bNumeric = FALSE; - if (bNumeric && cThousandDelimiter) - { - // Ist der Trenner richtig angegeben? - String aValue = aField2.GetToken(0,cDecimalDelimiter); - for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4) - { - sal_Unicode c = aValue.GetChar(j); - // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen? - if (c == cThousandDelimiter && j) - continue; - else - { - bNumeric = FALSE; - break; - } - } - } - - // jetzt koennte es noch ein Datumsfeld sein - if (!bNumeric) - { - try - { - nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2); - } - catch(Exception&) - { - } - } - } - } - - sal_Int32 nFlags = 0; - if (bNumeric) - { - if (cDecimalDelimiter) - { - if(nPrecision) - { - eType = DataType::DECIMAL; - aTypeName = ::rtl::OUString::createFromAscii("DECIMAL"); - } - else - { - eType = DataType::DOUBLE; - aTypeName = ::rtl::OUString::createFromAscii("DOUBLE"); - } - } - else - eType = DataType::INTEGER; - nFlags = ColumnSearch::BASIC; - } - else - { - - switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex)) - { - case NUMBERFORMAT_DATE: - eType = DataType::DATE; - aTypeName = ::rtl::OUString::createFromAscii("DATE"); - break; - case NUMBERFORMAT_DATETIME: - eType = DataType::TIMESTAMP; - aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP"); - break; - case NUMBERFORMAT_TIME: - eType = DataType::TIME; - aTypeName = ::rtl::OUString::createFromAscii("TIME"); - break; - default: - eType = DataType::VARCHAR; - nPrecision = 0; // nyi: Daten koennen aber laenger sein! - nScale = 0; - aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); - }; - nFlags |= ColumnSearch::CHAR; - } - - // check if the columname already exists - String aAlias(aColumnName); - OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); - sal_Int32 nExprCnt = 0; - while(aFind != m_aColumns->get().end()) - { - (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt); - aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase); - } - - m_aColumnRawNames.push_back(::rtl::OUString(aAlias)); - - //~ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(), - //~ ColumnValue::NULLABLE, - //~ nPrecision, - //~ nScale, - //~ eType, - //~ sal_False, - //~ sal_False, - //~ sal_False, - //~ bCase); - //~ Reference< XPropertySet> xCol = pColumn; - //~ m_aColumns->push_back(xCol); - m_aTypes.push_back(eType); - m_aPrecisions.push_back(nPrecision); - m_aScales.push_back(nScale); - } - setColumnAliases(); - m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); -} -// ------------------------------------------------------------------------- -OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection) : OEvoabTable_BASE(_pTables,_pConnection) -{ - -} -// ------------------------------------------------------------------------- -OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection, - const ::rtl::OUString& _Name, - const ::rtl::OUString& _Type, - const ::rtl::OUString& _Description , - const ::rtl::OUString& _SchemaName, - const ::rtl::OUString& _CatalogName - ) : OEvoabTable_BASE(_pTables,_pConnection,_Name, - _Type, - _Description, - _SchemaName, - _CatalogName) - ,m_nRowPos(0) - ,m_nMaxRowCount(0) -{ - //~ OSL_TRACE("OEvoabTable::(in constructor)_Name = %s\n", ((OUtoCStr(_Name)) ? (OUtoCStr(_Name)):("NULL")) ); - //~ OSL_TRACE("OEvoabTable::(in constructor)_Type = %s\n", ((OUtoCStr(_Type)) ? (OUtoCStr(_Type)):("NULL")) ); - //~ OSL_TRACE("OEvoabTable::(in constructor)_Description = %s\n", ((OUtoCStr(_Description)) ? (OUtoCStr(_Description)):("NULL")) ); - //~ OSL_TRACE("OEvoabTable::(in constructor)_SchemaName = %s\n", ((OUtoCStr(_SchemaName)) ? (OUtoCStr(_SchemaName)):("NULL")) ); - //~ OSL_TRACE("OEvoabTable::(in constructor)_CatalogName = %s\n", ((OUtoCStr(_CatalogName)) ? (OUtoCStr(_CatalogName)):("NULL")) ); -} -// ----------------------------------------------------------------------------- -void OEvoabTable::construct() -{ - SvtSysLocale aLocale; - ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale()); - Sequence< ::com::sun::star::uno::Any > aArg(1); - aArg[0] <<= aAppLocale; - - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY); - m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY); - m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier); - - INetURLObject aURL; - aURL.SetURL(getEntry()); - - if(aURL.getExtension() != rtl::OUString(m_pConnection->getExtension())) - aURL.setExtension(m_pConnection->getExtension()); - - String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE); - - m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE); - - if(!m_pFileStream) - m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE); - - if(m_pFileStream) - { - OSL_TRACE("OEvoabTable::construct()::m_pFileStream created\n" ); - m_pFileStream->Seek(STREAM_SEEK_TO_END); - sal_Int32 nSize = m_pFileStream->Tell(); - m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); - - // Buffersize abhaengig von der Filegroesse - m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 : - nSize > 100000 ? 16384 : - nSize > 10000 ? 4096 : 1024); - OSL_TRACE("OEvoabTable::construct()::m_pFileStream->Tell() = %d\n", nSize ); - - fillColumns(aAppLocale); - - refreshColumns(); - } -} -// ------------------------------------------------------------------------- -String OEvoabTable::getEntry() -{ - ::rtl::OUString sURL; - try - { - Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet(); - Reference< XRow> xRow(xDir,UNO_QUERY); - ::rtl::OUString sName; - ::rtl::OUString sExt; - - INetURLObject aURL; - xDir->beforeFirst(); - static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/")); - while(xDir->next()) - { - sName = xRow->getString(1); - aURL.SetSmartProtocol(INET_PROT_FILE); - String sUrl = m_pConnection->getURL() + s_sSeparator + sName; - aURL.SetSmartURL( sUrl ); - - // cut the extension - sExt = aURL.getExtension(); - - // name and extension have to coincide - if ( m_pConnection->matchesExtension( sExt ) ) - { - sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString()); - if ( sName == m_Name ) - { - Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY ); - sURL = xContentAccess->queryContentIdentifierString(); - break; - } - } - } - xDir->beforeFirst(); // move back to before first record - } - catch(Exception&) - { - OSL_ASSERT(0); - } - return sURL.getStr(); -} -// ------------------------------------------------------------------------- -void OEvoabTable::refreshColumns() -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - TStringVector aVector; - aVector.reserve(m_aColumns->get().size()); - - for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter) - aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName()); - - if(m_pColumns) - m_pColumns->reFill(aVector); - else - m_pColumns = new OEvoabColumns(this,m_aMutex,aVector); - - OSL_TRACE("OEvoabTable::refreshColumns()::end\n" ); -} - -// ------------------------------------------------------------------------- -void SAL_CALL OEvoabTable::disposing(void) -{ - OFileTable::disposing(); - ::osl::MutexGuard aGuard(m_aMutex); - m_aColumns = NULL; -} -// ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OEvoabTable::getTypes( ) throw(RuntimeException) -{ - Sequence< Type > aTypes = OTable_TYPEDEF::getTypes(); - ::std::vector<Type> aOwnTypes; - aOwnTypes.reserve(aTypes.getLength()); - const Type* pBegin = aTypes.getConstArray(); - const Type* pEnd = pBegin + aTypes.getLength(); - for(;pBegin != pEnd;++pBegin) - { - if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) || - *pBegin == ::getCppuType((const Reference<XRename>*)0) || - *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) || - *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) || - *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))) - { - aOwnTypes.push_back(*pBegin); - } - } - Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0]; - return Sequence< Type >(pTypes, aOwnTypes.size()); -} - -// ------------------------------------------------------------------------- -Any SAL_CALL OEvoabTable::queryInterface( const Type & rType ) throw(RuntimeException) -{ - if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) || - rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) || - rType == ::getCppuType((const Reference<XRename>*)0) || - rType == ::getCppuType((const Reference<XAlterTable>*)0) || - rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)) - return Any(); - - Any aRet = OTable_TYPEDEF::queryInterface(rType); - return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); -} - -//-------------------------------------------------------------------------- -Sequence< sal_Int8 > OEvoabTable::getUnoTunnelImplementationId() -{ - static ::cppu::OImplementationId * pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -// com::sun::star::lang::XUnoTunnel -//------------------------------------------------------------------ -sal_Int64 OEvoabTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) -{ - return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - ? reinterpret_cast< sal_Int64 >( this ) - : OEvoabTable_BASE::getSomething(rId); -} -//------------------------------------------------------------------ -sal_Bool OEvoabTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData) -{ - *(_rRow->get())[0] = m_nFilePos; - - if (!bRetrieveData) - return TRUE; - - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - // Felder: - xub_StrLen nStartPos = 0; - String aStr; - OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin(); - for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i) - { - m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); - //OSL_TRACE("OEvoabTable::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) ); - - if (aStr.Len() == 0) - (_rRow->get())[i+1]->setNull(); - else - { - // Laengen je nach Datentyp: - sal_Int32 nLen, - nType = 0; - if(bIsTable) - { - nLen = m_aPrecisions[i]; - nType = m_aTypes[i]; - } - else - { - Reference< XPropertySet> xColumn = *aIter; - xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen; - xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; - } - switch(nType) - { - case DataType::TIMESTAMP: - case DataType::DATE: - case DataType::TIME: - { - double nRes = 0.0; - try - { - nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr); - Reference<XPropertySet> xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY); - com::sun::star::util::Date aDate; - xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate; - - switch(nType) - { - case DataType::DATE: - *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); - break; - case DataType::TIMESTAMP: - *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); - break; - default: - *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); - } - } - catch(Exception&) - { - (_rRow->get())[i+1]->setNull(); - } - } break; - case DataType::DOUBLE: - case DataType::INTEGER: - case DataType::DECIMAL: // #99178# OJ - case DataType::NUMERIC: - { - sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter(); - sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter(); - String aStrConverted; - - OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER || - !cDecimalDelimiter && nType == DataType::INTEGER, - "FalscherTyp"); - - // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln: - for (xub_StrLen j = 0; j < aStr.Len(); ++j) - { - if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter) - aStrConverted += '.'; - else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it - break; // #99189# OJ - else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter) - { - // weglassen - } - else - aStrConverted += aStr.GetChar(j) ; - } - double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL); - - // #99178# OJ - if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType ) - *(_rRow->get())[i+1] = ORowSetValue(String::CreateFromDouble(nVal)); - else - *(_rRow->get())[i+1] = nVal; - } break; - - default: - { - // Wert als String in Variable der Row uebernehmen - *(_rRow->get())[i+1] = ORowSetValue(aStr); - } - break; - } - } - } - return sal_True; -} -// ----------------------------------------------------------------------------- -sal_Bool OEvoabTable::setColumnAliases() -{ - - size_t nSize = m_aColumnRawNames.size(); - if(nSize == 0 || m_aPrecisions.size() != nSize || m_aScales.size() != nSize || m_aTypes.size() != nSize) - return sal_False; - m_aColumns->get().clear(); - m_aColumns->get().reserve(nSize); - ::rtl::OUString aColumnReadName; - ::rtl::OUString aColumnHeadlineName; - ::rtl::OUString aColumnDisplayName; - ::rtl::OUString aColumnFinalName; - String sColumnFinalName; - - const TStringVector& colAliasNames = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAlias(); - const ::std::map< ::rtl::OUString, ::rtl::OUString > & colMap = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAliasMap(); - ::osl::MutexGuard aGuard( m_aMutex ); - - for(size_t i = 0;i < nSize; ++i) - { - aColumnReadName = m_aColumnRawNames[i]; - //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnReadName = %s\n", ((OUtoCStr(aColumnReadName)) ? (OUtoCStr(aColumnReadName)):("NULL")) ); - sal_Bool bFound = sal_False; - for ( size_t j = 0; j < colAliasNames.size(); ++j ) - { - aColumnDisplayName = colAliasNames[j]; - - ::std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator aPos = colMap.find( aColumnDisplayName ); - if ( colMap.end() != aPos ) - { - aColumnHeadlineName = aPos->second; - EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", aColumnDisplayName ); - EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnHeadlineName= %s\n", aColumnHeadlineName ); - if(aColumnReadName == aColumnHeadlineName) - { - //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnHeadlineName = %s\n", ((OUtoCStr(aColumnHeadlineName)) ? (OUtoCStr(aColumnHeadlineName)):("NULL")) ); - //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", ((OUtoCStr(aColumnDisplayName)) ? (OUtoCStr(aColumnDisplayName)):("NULL")) ); - aColumnFinalName = aColumnDisplayName; - bFound = sal_True; - //OSL_TRACE("OEvoabTable::getColumnRows()::j = %d\n", j ); - - break; - } - } - else - OSL_ENSURE( sal_False, "OEvoabTable::setColumnAliases: did not find one of the aliases!" ); - } - if(!bFound) - aColumnFinalName = aColumnReadName; - sColumnFinalName = aColumnFinalName; - - sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); - ::rtl::OUString aTypeName; - aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); - sdbcx::OColumn* pColumn = new sdbcx::OColumn(sColumnFinalName,aTypeName,::rtl::OUString(), - ColumnValue::NULLABLE, - m_aPrecisions[i], - m_aScales[i], - m_aTypes[i], - sal_False, - sal_False, - sal_False, - bCase); - Reference< XPropertySet> xCol = pColumn; - m_aColumns->get().push_back(xCol); - } - return sal_True; -} -// ----------------------------------------------------------------------------- -void OEvoabTable::refreshIndexes() -{ -} -// ----------------------------------------------------------------------------- -sal_Bool OEvoabTable::checkHeaderLine() -{ - if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine()) - { - BOOL bRead2; - do - { - bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding()); - } - while(bRead2 && !m_aCurrentLine.Len()); - - m_nFilePos = m_pFileStream->Tell(); - if (m_pFileStream->IsEof()) - return sal_False; - } - return sal_True; -} -//------------------------------------------------------------------ -sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos) -{ - //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - if ( !m_pFileStream ) - return sal_False; - OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection; - // ---------------------------------------------------------- - // Positionierung vorbereiten: - //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - m_nFilePos = nCurPos; - - switch(eCursorPosition) - { - case IResultSetHelper::FIRST: - m_nFilePos = 0; - m_nRowPos = 1; - // run through - case IResultSetHelper::NEXT: - if(eCursorPosition != IResultSetHelper::FIRST) - ++m_nRowPos; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - - m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos)); - - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - { - m_nMaxRowCount = m_nRowPos; - return sal_False; - } - nCurPos = m_pFileStream->Tell(); - break; - case IResultSetHelper::PRIOR: - --m_nRowPos; - if(m_nRowPos > 0) - { - m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - m_nRowPos = 0; - - break; - case IResultSetHelper::LAST: - if(m_nMaxRowCount) - { - m_nFilePos = m_aRowToFilePos.rbegin()->second; - m_nRowPos = m_aRowToFilePos.rbegin()->first; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else - { - while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row - // now I know all - seekRow(IResultSetHelper::PRIOR,1,nCurPos); - } - break; - case IResultSetHelper::RELATIVE: - if(nOffset > 0) - { - for(sal_Int32 i = 0;i<nOffset;++i) - seekRow(IResultSetHelper::NEXT,1,nCurPos); - } - else if(nOffset < 0) - { - for(sal_Int32 i = nOffset;i;++i) - seekRow(IResultSetHelper::PRIOR,1,nCurPos); - } - break; - case IResultSetHelper::ABSOLUTE: - { - if(nOffset < 0) - nOffset = m_nRowPos + nOffset; - ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset); - if(aIter != m_aRowToFilePos.end()) - { - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table - { - m_nRowPos = m_nMaxRowCount; - return sal_False; - } - else - { - aIter = m_aRowToFilePos.upper_bound(nOffset); - if(aIter == m_aRowToFilePos.end()) - { - m_nRowPos = m_aRowToFilePos.rbegin()->first; - nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second; - while(m_nRowPos != nOffset) - seekRow(IResultSetHelper::NEXT,1,nCurPos); - } - else - { - --aIter; - m_nRowPos = aIter->first; - m_nFilePos = aIter->second; - m_pFileStream->Seek(m_nFilePos); - if (m_pFileStream->IsEof() || !checkHeaderLine()) - return sal_False; - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - } - } - } - - break; - case IResultSetHelper::BOOKMARK: - m_pFileStream->Seek(nOffset); - if (m_pFileStream->IsEof()) - return sal_False; - - m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG) - m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding()); - if (m_pFileStream->IsEof()) - return sal_False; - nCurPos = m_pFileStream->Tell(); - break; - } - - //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) ); - - return sal_True; -} -// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab/LTable.hxx b/connectivity/source/drivers/evoab/LTable.hxx deleted file mode 100644 index 360e4487cf09..000000000000 --- a/connectivity/source/drivers/evoab/LTable.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************* - * - * 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: LTable.hxx,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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LTABLE_HXX_ -#define _CONNECTIVITY_EVOAB_LTABLE_HXX_ - -#include "file/FTable.hxx" -#include "connectivity/sdbcx/VColumn.hxx" -#include "connectivity/CommonTools.hxx" -#include <tools/urlobj.hxx> -#include "file/quotedstring.hxx" -#include <vector> - -namespace connectivity -{ - namespace evoab - { - typedef file::OFileTable OEvoabTable_BASE; - class OEvoabConnection; - - typedef ::std::map< ::rtl::OUString, - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer; - - class OEvoabTable : public OEvoabTable_BASE - { - private: - // maps a row postion to a file position - ::std::map<sal_Int32,sal_Int32> m_aRowToFilePos; - ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset - ::std::vector<sal_Int32> m_aPrecisions; // same as aboth - ::std::vector<sal_Int32> m_aScales; - QuotedTokenizedString m_aCurrentLine; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter; - sal_Int32 m_nRowPos; - sal_Int32 m_nMaxRowCount; // will be set if stream is once eof - ::std::vector< ::rtl::OUString> m_aColumnRawNames; - sal_Bool setColumnAliases(); - void fillColumns(const ::com::sun::star::lang::Locale& _aLocale); - sal_Bool checkHeaderLine(); - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet> isUniqueByColumnName(const ::rtl::OUString& _rColName); - - public: - virtual void refreshColumns(); - virtual void refreshIndexes(); - - public: - // DECLARE_CTY_DEFAULTS( OFlatTable_BASE); - OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection); - OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection, - const ::rtl::OUString& _Name, - const ::rtl::OUString& _Type, - const ::rtl::OUString& _Description = ::rtl::OUString(), - const ::rtl::OUString& _SchemaName = ::rtl::OUString(), - const ::rtl::OUString& _CatalogName = ::rtl::OUString() - ); - - void construct(); // can throw any exception - - virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos); - virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData); - - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL disposing(void); - - // com::sun::star::lang::XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - - String getEntry(); - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LTABLE_HXX_ - diff --git a/connectivity/source/drivers/evoab/LTables.cxx b/connectivity/source/drivers/evoab/LTables.cxx deleted file mode 100644 index 7465c890f240..000000000000 --- a/connectivity/source/drivers/evoab/LTables.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* - * - * 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: LTables.cxx,v $ - * $Revision: 1.6 $ - * - * 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_connectivity.hxx" -#include "LTables.hxx" -#include "LTable.hxx" -#include <com/sun/star/sdbc/XRow.hpp> -#include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/ColumnValue.hpp> -#include <com/sun/star/sdbc/KeyRule.hpp> -#include <com/sun/star/sdbcx/KeyType.hpp> -#include "file/FCatalog.hxx" -#include "file/FConnection.hxx" -#include <comphelper/types.hxx> - -using namespace connectivity; -using namespace ::comphelper; -using namespace connectivity::evoab; -using namespace connectivity::file; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::container; -namespace starutil = ::com::sun::star::util; - -sdbcx::ObjectType OEvoabTables::createObject(const ::rtl::OUString& _rName) -{ - OEvoabTable* pRet = new OEvoabTable(this,(OEvoabConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), - _rName,::rtl::OUString::createFromAscii("TABLE")); - sdbcx::ObjectType xRet = pRet; - pRet->construct(); - return xRet; -} -// ------------------------------------------------------------------------- - diff --git a/connectivity/source/drivers/evoab/LTables.hxx b/connectivity/source/drivers/evoab/LTables.hxx deleted file mode 100644 index 3fcaaa7d8e58..000000000000 --- a/connectivity/source/drivers/evoab/LTables.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * 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: LTables.hxx,v $ - * $Revision: 1.5 $ - * - * 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. - * - ************************************************************************/ - -#ifndef _CONNECTIVITY_EVOAB_LTABLES_HXX_ -#define _CONNECTIVITY_EVOAB_LTABLES_HXX_ - -#include "file/FTables.hxx" - -namespace connectivity -{ - namespace evoab - { - // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx; - typedef file::OTables OEvoabTables_BASE; - - class OEvoabTables : public OEvoabTables_BASE - { - protected: - virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName); - public: - OEvoabTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, - const TStringVector &_rVector) : OEvoabTables_BASE(_rMetaData,_rParent,_rMutex,_rVector) - {} - }; - } -} -#endif // _CONNECTIVITY_EVOAB_LTABLES_HXX_ - diff --git a/connectivity/source/drivers/evoab/evoab.map b/connectivity/source/drivers/evoab/evoab.map deleted file mode 100644 index 00cf7191f143..000000000000 --- a/connectivity/source/drivers/evoab/evoab.map +++ /dev/null @@ -1,8 +0,0 @@ -EVOAB_1_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; diff --git a/connectivity/source/drivers/evoab/evoab.xml b/connectivity/source/drivers/evoab/evoab.xml deleted file mode 100644 index 8ed16719ae0e..000000000000 --- a/connectivity/source/drivers/evoab/evoab.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd"> -<module-description> - <module-name>file</module-name> - <component-description> - <author>Xibei(Berry) Jia</author> - <name>com.sun.star.comp.sdbc.evoab.OEvoabDriver</name> - <description>This library implements the database driver for evolution address book formats. -</description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="final"/> - <supported-service>com.sun.star.sdbc.Driver</supported-service> - <supported-service>com.sun.star.sdbcx.Driver</supported-service> - <service-dependency> ... </service-dependency> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <project-build-dependency>vos</project-build-dependency> - <runtime-module-dependency>file</runtime-module-dependency> - <runtime-module-dependency>cppuhelper</runtime-module-dependency> - <runtime-module-dependency>cppu</runtime-module-dependency> - <runtime-module-dependency>sal</runtime-module-dependency> - <runtime-module-dependency>vos</runtime-module-dependency> - <runtime-module-dependency>osl</runtime-module-dependency> - <runtime-module-dependency>svtools-light1</runtime-module-dependency> - <runtime-module-dependency>svtools</runtime-module-dependency> - <runtime-module-dependency>ucbhelper</runtime-module-dependency> - <runtime-module-dependency>dbtools</runtime-module-dependency> - <runtime-module-dependency>unotools</runtime-module-dependency> - <runtime-module-dependency>comphelper</runtime-module-dependency> -</module-description> diff --git a/connectivity/source/drivers/evoab/exports.dxp b/connectivity/source/drivers/evoab/exports.dxp deleted file mode 100644 index 9630d7e06768..000000000000 --- a/connectivity/source/drivers/evoab/exports.dxp +++ /dev/null @@ -1,3 +0,0 @@ -component_getImplementationEnvironment -component_writeInfo -component_getFactory diff --git a/connectivity/source/drivers/evoab/makefile.mk b/connectivity/source/drivers/evoab/makefile.mk deleted file mode 100644 index dc08137324c9..000000000000 --- a/connectivity/source/drivers/evoab/makefile.mk +++ /dev/null @@ -1,107 +0,0 @@ -#************************************************************************* -# -# 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: makefile.mk,v $ -# -# $Revision: 1.9 $ -# -# 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. -# -#************************************************************************* - -PRJ=..$/..$/.. -PRJINC=..$/.. -PRJNAME=connectivity -TARGET=evoab - -VISIBILITY_HIDDEN=TRUE - -# --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/version.mk - -.IF "$(GUI)"=="UNX" -# --- Files ------------------------------------- - -EXCEPTIONSFILES=\ - $(SLO)$/LResultSet.obj \ - $(SLO)$/LStatement.obj \ - $(SLO)$/LPreparedStatement.obj \ - $(SLO)$/LFolderList.obj \ - $(SLO)$/LConfigAccess.obj \ - $(SLO)$/LColumnAlias.obj \ - $(SLO)$/LTable.obj \ - $(SLO)$/LDatabaseMetaData.obj \ - $(SLO)$/LCatalog.obj \ - $(SLO)$/LColumns.obj \ - $(SLO)$/LTables.obj \ - $(SLO)$/LConnection.obj \ - $(SLO)$/LServices.obj \ - $(SLO)$/LDriver.obj - -SLOFILES=\ - $(EXCEPTIONSFILES) \ - $(SLO)$/LDebug.obj - - -SHL1VERSIONMAP=$(TARGET).map - - -# --- Library ----------------------------------- -#SHL1TARGET=$(TARGET)$(DLLPOSTFIX) -SHL1TARGET= $(EVOAB_TARGET)$(DLLPOSTFIX) -SHL1OBJS=$(SLOFILES) -SHL1STDLIBS=\ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(VOSLIB) \ - $(TOOLSLIB) \ - $(SVTOOLLIB) \ - $(UNOTOOLSLIB) \ - $(UCBHELPERLIB) \ - $(SALLIB) \ - $(DBTOOLSLIB) \ - $(DBFILELIB) \ - $(COMPHELPERLIB) - -.IF "$(DBFILELIB)" == "" -SHL1STDLIBS+= ifile.lib -.ENDIF - -SHL1DEPN= -SHL1IMPLIB= i$(TARGET) - -SHL1DEF= $(MISC)$/$(SHL1TARGET).def - -DEF1NAME= $(SHL1TARGET) - -.ENDIF -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - - diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx index d8dcb3616fb6..8de1f8f59c0c 100644 --- a/connectivity/source/drivers/evoab2/EApi.cxx +++ b/connectivity/source/drivers/evoab2/EApi.cxx @@ -69,6 +69,7 @@ typedef void (*SymbolFunc) (void); SYM_MAP( e_book_query_and ), SYM_MAP( e_book_query_or ), SYM_MAP( e_book_query_not ), + SYM_MAP( e_book_query_ref ), SYM_MAP( e_book_query_unref ), SYM_MAP( e_book_query_from_string ), SYM_MAP( e_book_query_to_string ), @@ -83,7 +84,7 @@ tryLink( oslModule &aModule, const char *pName ) for( guint i = 0; i < G_N_ELEMENTS( aApiMap ); i++ ) { SymbolFunc aMethod; - aMethod = (SymbolFunc) osl_getSymbol + aMethod = (SymbolFunc) osl_getFunctionSymbol ( aModule, rtl::OUString::createFromAscii ( aApiMap[ i ].sym_name ).pData ); if( !aMethod ) { diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h index ce969f38673a..34dfc8930949 100644 --- a/connectivity/source/drivers/evoab2/EApi.h +++ b/connectivity/source/drivers/evoab2/EApi.h @@ -124,6 +124,7 @@ EAPI_EXTERN EBookQuery* (*e_book_query_field_test) (EContactField field, EAPI_EXTERN EBookQuery* (*e_book_query_and) (int nqs, EBookQuery **qs, gboolean unref); EAPI_EXTERN EBookQuery* (*e_book_query_or) (int nqs, EBookQuery **qs, gboolean unref); EAPI_EXTERN EBookQuery* (*e_book_query_not) (EBookQuery *q, gboolean unref); +EAPI_EXTERN EBookQuery* (*e_book_query_ref) (EBookQuery *q); EAPI_EXTERN void (*e_book_query_unref) (EBookQuery *q); EAPI_EXTERN char* (*e_book_query_to_string) (EBookQuery *q); EAPI_EXTERN EBookQuery* (*e_book_query_from_string) (const char *query_string); diff --git a/connectivity/source/drivers/evoab2/NConnection.cxx b/connectivity/source/drivers/evoab2/NConnection.cxx index f999a49c7df0..b38ad6b9e629 100644 --- a/connectivity/source/drivers/evoab2/NConnection.cxx +++ b/connectivity/source/drivers/evoab2/NConnection.cxx @@ -82,11 +82,10 @@ using namespace ::com::sun::star::lang; } // -------------------------------------------------------------------------------- -OEvoabConnection::OEvoabConnection(OEvoabDriver* _pDriver) - :OSubComponent<OEvoabConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this) - ,m_pDriver(_pDriver) +OEvoabConnection::OEvoabConnection( OEvoabDriver& _rDriver ) + :OSubComponent<OEvoabConnection, OConnection_BASE>( (::cppu::OWeakObject*)(&_rDriver), this ) + ,m_rDriver(_rDriver) ,m_xCatalog(NULL) - ,m_aPassword() { } //----------------------------------------------------------------------------- @@ -98,8 +97,6 @@ OEvoabConnection::~OEvoabConnection() acquire(); close(); } - - m_pDriver = NULL; } //----------------------------------------------------------------------------- @@ -195,8 +192,9 @@ Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( con ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OConnection_BASE::rBHelper.bDisposed); - OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement(this, sql); + OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement( this ); Reference< XPreparedStatement > xStmt = pStmt; + pStmt->construct( sql ); m_aStatements.push_back(WeakReferenceHelper(*pStmt)); return xStmt; @@ -228,11 +226,11 @@ void SAL_CALL OEvoabConnection::close( ) throw(SQLException, RuntimeException) // XWarningsSupplier Any SAL_CALL OEvoabConnection::getWarnings( ) throw(SQLException, RuntimeException) { - return Any(); // when you collected some warnings -> return it + return m_aWarnings.getWarnings(); } void SAL_CALL OEvoabConnection::clearWarnings( ) throw(SQLException, RuntimeException) { - // you should clear your collected warnings here + m_aWarnings.clearWarnings(); } //------------------------------------------------------------------------------ diff --git a/connectivity/source/drivers/evoab2/NConnection.hxx b/connectivity/source/drivers/evoab2/NConnection.hxx index bcd3b3b61ce4..3ffa903e92cf 100644 --- a/connectivity/source/drivers/evoab2/NConnection.hxx +++ b/connectivity/source/drivers/evoab2/NConnection.hxx @@ -37,10 +37,12 @@ #include "OSubComponent.hxx" #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include "connectivity/CommonTools.hxx" +#include "connectivity/warningscontainer.hxx" #include "TConnection.hxx" #include <cppuhelper/weakref.hxx> #include <osl/module.h> #include "EApi.h" + namespace connectivity { namespace evoab @@ -57,35 +59,29 @@ namespace connectivity typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding - class OEvoabConnection : public OConnection_BASE, - public connectivity::OSubComponent<OEvoabConnection, OConnection_BASE> + class OEvoabConnection :public OConnection_BASE + ,public connectivity::OSubComponent<OEvoabConnection, OConnection_BASE> { - friend class connectivity::OSubComponent<OEvoabConnection, OConnection_BASE>; private: - OEvoabDriver *m_pDriver; - ::rtl::OUString m_pCurrentTableName; + const OEvoabDriver& m_rDriver; SDBCAddress::sdbc_address_type m_eSDBCAddressType; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > + m_xCatalog; + ::rtl::OString m_aPassword; + ::dbtools::WarningsContainer m_aWarnings; - protected: - - ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; - rtl::OString m_aPassword; - - - public: - OEvoabConnection(OEvoabDriver* _pDriver); virtual ~OEvoabConnection(); + public: + OEvoabConnection( OEvoabDriver& _rDriver ); virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); inline rtl::OString getPassword() { return m_aPassword; } inline void setPassword( rtl::OString aStr ) { m_aPassword = aStr; } - inline rtl::OUString& getCurrentTableName() {return m_pCurrentTableName;} - inline void setCurrentTableName(::rtl::OUString _name) {m_pCurrentTableName=_name;} // own methods - inline const OEvoabDriver* getDriver() const { return static_cast< const OEvoabDriver* >( m_pDriver ); } + inline const OEvoabDriver& getDriver() const { return m_rDriver; } SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;} void setSDBCAddressType(SDBCAddress::sdbc_address_type _eSDBCAddressType) {m_eSDBCAddressType = _eSDBCAddressType;} @@ -124,8 +120,6 @@ namespace connectivity // XWarningsSupplier virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - - }; } } diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 259d5bbbc0b0..9765a30359a0 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NDatabaseMetaData.cxx,v $ - * $Revision: 1.12 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -174,21 +171,24 @@ namespace connectivity return NULL; } - sal_Int32 - getFieldType( guint nCol ) + GType + getGFieldType( guint nCol ) { - sal_Int32 nType = DataType::VARCHAR; initFields(); + + sal_Int32 nType = G_TYPE_STRING; if ( nCol < nFields ) - { - if( ((GParamSpec *)pFields[nCol]->pField)->value_type == G_TYPE_STRING ) - nType = DataType::VARCHAR; - else - nType = DataType::BIT; - } + return ((GParamSpec *)pFields[nCol]->pField)->value_type; return nType; } + sal_Int32 + getFieldType( guint nCol ) + { + sal_Int32 nType = getGFieldType( nCol ); + return nType == G_TYPE_STRING ? DataType::VARCHAR : DataType::BIT; + } + guint findEvoabField(const rtl::OUString& aColName) { guint nRet = (guint)-1; @@ -271,9 +271,7 @@ OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData() } // ------------------------------------------------------------------------- -ODatabaseMetaDataResultSet::ORows& SAL_CALL OEvoabDatabaseMetaData::getColumnRows( - const ::rtl::OUString& /*tableNamePattern*/, - const ::rtl::OUString& columnNamePattern ) throw(SQLException) +ODatabaseMetaDataResultSet::ORows& OEvoabDatabaseMetaData::getColumnRows( const ::rtl::OUString& columnNamePattern ) { static ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORow aRow(19); @@ -322,7 +320,7 @@ ODatabaseMetaDataResultSet::ORows& SAL_CALL OEvoabDatabaseMetaData::getColumnRow aRow[5] = new ORowSetValueDecorator( static_cast<sal_Int16>( getFieldType( i ) ) ); aRow[6] = new ORowSetValueDecorator( getFieldTypeName( i ) ); - OSL_TRACE( " ColumnName = '%s'", g_param_spec_get_name( pFields[i]->pField ) ); + OSL_TRACE( "ColumnName = '%s'", g_param_spec_get_name( pFields[i]->pField ) ); // COLUMN_NAME aRow[4] = new ORowSetValueDecorator( getFieldName( i ) ); // ORDINAL_POSITION @@ -1019,18 +1017,9 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) throw static ::rtl::OUString sTableTypes[] = { ::rtl::OUString::createFromAscii("TABLE"), - //m_pConnection->getCurrentTableName(), - // // Currently we only support a 'TABLE' nothing more complex - // - // ::rtl::OUString::createFromAscii("VIEW"), - // ::rtl::OUString::createFromAscii("SYSTEM TABLE"), - // ::rtl::OUString::createFromAscii("GLOBAL TEMPORARY"), - // ::rtl::OUString::createFromAscii("LOCAL TEMPORARY"), - // ::rtl::OUString::createFromAscii("ALIAS"), - // ::rtl::OUString::createFromAscii("SYNONYM") }; - ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); + ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes); Reference< XResultSet > xRef = pResult; // here we fill the rows which should be visible when ask for data from the resultset returned here @@ -1043,7 +1032,6 @@ Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) throw aRow.push_back(new ORowSetValueDecorator(sTableTypes[i])); // bound row - ODatabaseMetaDataResultSet::ORow::iterator aIter = aRow.begin(); aRows.push_back(aRow); } // here we set the rows at the resultset @@ -1076,7 +1064,7 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -1099,14 +1087,14 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) } // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns( - const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern, + const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { // this returns an empty resultset where the column-names are already set // in special the metadata of the resultset already returns the right columns ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns ); Reference< XResultSet > xResultSet = pResultSet; - pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ) ); + pResultSet->setRows( getColumnRows( columnNamePattern ) ); return xResultSet; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx index 0432597e353a..d0e1803f3f5a 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NDatabaseMetaData.hxx,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -70,6 +67,7 @@ namespace connectivity const ColumnProperty *getField(guint n); guint getFieldCount() ; + GType getGFieldType(guint nCol) ; sal_Int32 getFieldType(guint nCol) ; rtl::OUString getFieldTypeName(guint nCol) ; rtl::OUString getFieldName(guint nCol) ; @@ -81,7 +79,7 @@ namespace connectivity { OEvoabConnection* m_pConnection; - ODatabaseMetaDataResultSet::ORows& SAL_CALL getColumnRows( const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw( ::com::sun::star::sdbc::SQLException ); + ODatabaseMetaDataResultSet::ORows& getColumnRows( const ::rtl::OUString& columnNamePattern ); protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw(); diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx index ccbb47ce963f..fc024fa293e5 100644 --- a/connectivity/source/drivers/evoab2/NDriver.cxx +++ b/connectivity/source/drivers/evoab2/NDriver.cxx @@ -147,7 +147,7 @@ Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& if ( ! acceptsURL(url) ) return NULL; - OEvoabConnection* pCon = new OEvoabConnection(this); + OEvoabConnection* pCon = new OEvoabConnection( *this ); pCon->construct(url,info); Reference< XConnection > xCon = pCon; m_xConnections.push_back(WeakReferenceHelper(*pCon)); diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx index 029349f834de..3efcdc740ebf 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NPreparedStatement.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -40,6 +37,7 @@ #include "propertyids.hxx" #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> +#include <tools/diagnose_ex.h> #include "resource/common_res.hrc" @@ -55,49 +53,67 @@ using namespace com::sun::star::util; IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); -OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection, const ::rtl::OUString& sql) - :OStatement_BASE2(_pConnection) - ,m_nNumParams(0) - ,m_sSqlStatement(sql) - ,m_bPrepared(sal_False) +OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection ) + :OCommonStatement(_pConnection) + ,m_sSqlStatement() + ,m_xMetaData() { } + +// ----------------------------------------------------------------------------- +void OEvoabPreparedStatement::construct( const ::rtl::OUString& _sql ) +{ + m_sSqlStatement = _sql; + + m_aQueryData = impl_getEBookQuery_throw( m_sSqlStatement ); + ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" ); + ENSURE_OR_THROW( m_aQueryData.xSelectColumns.isValid(), "no SelectColumn" ); + + // create our meta data + OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( m_aQueryData.sTable ); + m_xMetaData = pMeta; + pMeta->setEvoabFields( m_aQueryData.xSelectColumns ); +} + // ----------------------------------------------------------------------------- OEvoabPreparedStatement::~OEvoabPreparedStatement() { } + // ----------------------------------------------------------------------------- void SAL_CALL OEvoabPreparedStatement::acquire() throw() { - OStatement_BASE2::acquire(); + OCommonStatement::acquire(); } + // ----------------------------------------------------------------------------- void SAL_CALL OEvoabPreparedStatement::release() throw() { - OStatement_BASE2::release(); + OCommonStatement::release(); } + // ----------------------------------------------------------------------------- Any SAL_CALL OEvoabPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OStatement_BASE2::queryInterface(rType); + Any aRet = OCommonStatement::queryInterface(rType); if(!aRet.hasValue()) aRet = OPreparedStatement_BASE::queryInterface(rType); return aRet; } // ------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OEvoabPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +Sequence< Type > SAL_CALL OEvoabPreparedStatement::getTypes( ) throw(RuntimeException) { - return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OStatement_BASE2::getTypes()); + return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes()); } // ------------------------------------------------------------------------- Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - if(!m_xMetaData.is()) - m_xMetaData = new OEvoabResultSetMetaData(m_pConnection->getCurrentTableName()); + // the meta data should have been created at construction time + ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); return m_xMetaData; } // ------------------------------------------------------------------------- @@ -105,13 +121,13 @@ Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( void SAL_CALL OEvoabPreparedStatement::close( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); free_column_resources(); // Reset last warning message try { clearWarnings (); - OStatement_BASE2::close(); + OCommonStatement::close(); } catch (SQLException &) { // If we get an error, ignore @@ -123,11 +139,9 @@ void SAL_CALL OEvoabPreparedStatement::close( ) throw(SQLException, RuntimeExce sal_Bool SAL_CALL OEvoabPreparedStatement::execute( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - Reference< XResultSet> xRS = OStatement_Base::executeQuery( m_sSqlStatement ); - // same as in statement with the difference that this statement also can contain parameter + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + Reference< XResultSet> xRS = impl_executeQuery_throw( m_aQueryData ); return xRS.is(); } // ------------------------------------------------------------------------- @@ -135,9 +149,8 @@ sal_Bool SAL_CALL OEvoabPreparedStatement::execute( ) throw(SQLException, Runti sal_Int32 SAL_CALL OEvoabPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - // same as in statement with the difference that this statement also can contain parameter + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); return 0; } // ------------------------------------------------------------------------- @@ -151,19 +164,18 @@ void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, Reference< XConnection > SAL_CALL OEvoabPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - return (Reference< XConnection >)m_pConnection; + return impl_getConnection(); } // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); - Reference< XResultSet > rs = OStatement_Base::executeQuery( m_sSqlStatement ); - return rs; + return impl_executeQuery_throw( m_aQueryData ); } // ------------------------------------------------------------------------- @@ -268,7 +280,7 @@ void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, cons { if(!::dbtools::implSetObject(this,parameterIndex,x)) { - const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( + const ::rtl::OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution( STR_UNKNOWN_PARA_TYPE, "$position$", ::rtl::OUString::valueOf(parameterIndex) ) ); @@ -290,13 +302,13 @@ void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, c // ------------------------------------------------------------------------- -void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XParameters::setCharacterStream", *this ); } // ------------------------------------------------------------------------- -void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XParameters::setBinaryStream", *this ); } @@ -305,35 +317,18 @@ void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterInd void SAL_CALL OEvoabPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) { } -// ------------------------------------------------------------------------- -void OEvoabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) -{ - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - break; - case PROPERTY_ID_RESULTSETTYPE: - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_USEBOOKMARKS: - break; - default: - OStatement_Base::setFastPropertyValue_NoBroadcast(nHandle,rValue); - } -} // ----------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( ) throw(SQLException, RuntimeException) { return NULL; } // ----------------------------------------------------------------------------- -sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( ) throw(SQLException, RuntimeException) { return 0; } // ----------------------------------------------------------------------------- -sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( ) throw(SQLException, RuntimeException) { return sal_False; } diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx index b86e5a4db64b..a20ef1e7f084 100644 --- a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx +++ b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NPreparedStatement.hxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -53,8 +50,8 @@ namespace connectivity ::com::sun::star::sdbc::XMultipleResults, ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE; - class OEvoabPreparedStatement : public OStatement_BASE2, - public OPreparedStatement_BASE + class OEvoabPreparedStatement :public OCommonStatement + ,public OPreparedStatement_BASE { protected: struct Parameter @@ -74,25 +71,23 @@ namespace connectivity // Data attributes //==================================================================== - sal_Int32 m_nNumParams; // Number of parameter markers - // for the prepared statement - - ::rtl::OUString m_sSqlStatement; + // our SQL statement + ::rtl::OUString m_sSqlStatement; + // the EBookQuery we're working with + QueryData m_aQueryData; + // our meta data ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; - sal_Bool m_bPrepared; - protected: - virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) - throw (::com::sun::star::uno::Exception); virtual ~OEvoabPreparedStatement(); + public: - DECLARE_SERVICE_INFO(); - // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: - //OEvoabPreparedStatement( OEvoabConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql); - OEvoabPreparedStatement( OEvoabConnection* _pConnection, const ::rtl::OUString& sql); + OEvoabPreparedStatement( OEvoabConnection* _pConnection ); + void construct( const ::rtl::OUString& _sql ); + + protected: + DECLARE_SERVICE_INFO(); //XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire() throw(); @@ -137,7 +132,6 @@ namespace connectivity virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; } } diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index 0001f12ae158..8d2fcb837450 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NResultSet.cxx,v $ - * $Revision: 1.8.56.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,34 +27,42 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" -#include <comphelper/property.hxx> -#include <comphelper/sequence.hxx> -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/extract.hxx> + +#include "NDatabaseMetaData.hxx" +#include "NConnection.hxx" +#include "NResultSet.hxx" +#include "propertyids.hxx" +#include "resource/evoab2_res.hrc" +#include "TSortIndex.hxx" +#include <algorithm> + +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/FetchDirection.hpp> #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> + +#include <comphelper/componentcontext.hxx> +#include <comphelper/extract.hxx> +#include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> -#include <TSortIndex.hxx> +#include <connectivity/sqlerror.hxx> +#include <cppuhelper/typeprovider.hxx> #include <rtl/string.hxx> +#include <tools/diagnose_ex.h> +#include <svtools/syslocale.hxx> +#include <unotools/intlwrapper.hxx> + #include <vector> -#include <algorithm> -#include "NResultSet.hxx" -#include "NDatabaseMetaData.hxx" -#include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <cppuhelper/typeprovider.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include "propertyids.hxx" -#include <svtools/logindlg.hxx> -#include "resource/evoab2_res.hrc" + +namespace connectivity { namespace evoab { using namespace ::comphelper; -using namespace connectivity; -using namespace connectivity::evoab; -using namespace cppu; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; @@ -65,7 +70,7 @@ using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbcx; using namespace com::sun::star::container; using namespace com::sun::star::io; -using namespace ::com::sun::star::util; +namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition; //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) \ @@ -92,9 +97,9 @@ sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rSer } // ------------------------------------------------------------------------- -OEvoabResultSet::OEvoabResultSet(OStatement_Base* pStmt,OEvoabConnection *pConnection,OSQLParseTreeIterator& _aSQLIterator) - : OResultSet_BASE(m_aMutex) - ,OPropertySetHelper(OResultSet_BASE::rBHelper) +OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pConnection ) + :OResultSet_BASE(m_aMutex) + ,::comphelper::OPropertyContainer( OResultSet_BASE::rBHelper ) ,m_pStatement(pStmt) ,m_pConnection(pConnection) ,m_xMetaData(NULL) @@ -106,18 +111,24 @@ OEvoabResultSet::OEvoabResultSet(OStatement_Base* pStmt,OEvoabConnection *pConne ,m_pContacts(NULL) ,m_nIndex(-1) ,m_nLength(0) - ,m_aSQLIterator(_aSQLIterator) { -} + #define REGISTER_PROP( id, member ) \ + registerProperty( \ + OMetaConnection::getPropMap().getNameByIndex( id ), \ + id, \ + PropertyAttribute::READONLY, \ + &member, \ + ::getCppuType( &member ) \ + ); -// ------------------------------------------------------------------------- -OEvoabResultSet::~OEvoabResultSet() -{ + REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); + REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); + REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); + REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); } // ------------------------------------------------------------------------- - -void OEvoabResultSet::construct(void) +OEvoabResultSet::~OEvoabResultSet() { } @@ -188,11 +199,29 @@ static rtl::OString getUserName( EBook *pBook ) return aName; } +static ::rtl::OUString +valueToOUString( GValue& _rValue ) +{ + const char *pStr = g_value_get_string( &_rValue ); + rtl::OString aStr( pStr ? pStr : "" ); + ::rtl::OUString sResult( ::rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) ); + g_value_unset( &_rValue ); + return sResult; +} + +static bool +valueToBool( GValue& _rValue ) +{ + bool bResult = g_value_get_boolean( &_rValue ); + g_value_unset( &_rValue ); + return bResult; +} + static bool -executeQuery (EBook *pBook, EBookQuery *pQuery, GList **ppList, +executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList, rtl::OString &rPassword, GError **pError) { - ESource *pSource = e_book_get_source (pBook); + ESource *pSource = e_book_get_source( pBook ); bool bSuccess = false; bool bAuthSuccess = true; @@ -211,63 +240,6 @@ executeQuery (EBook *pBook, EBookQuery *pQuery, GList **ppList, return bSuccess; } -void OEvoabResultSet::construct( EBookQuery *pQuery, rtl::OString aTable, bool bIsWithoutWhere ) -{ - EBook *pBook = openBook( aTable ); - - if (pBook) - { - g_list_free(m_pContacts); - m_pContacts = NULL; - if( bIsWithoutWhere && !isLocal( pBook ) ) - { - OSL_TRACE( "large query on non-local book - ignored" ); - m_pConnection->throwGenericSQLException(STR_USE_WHERE_CRIT,*this); - } - else - { - OSL_TRACE( "Query without where ? '%d'", bIsWithoutWhere ); - rtl::OString aPassword = m_pConnection->getPassword(); - executeQuery( pBook, pQuery, &m_pContacts, aPassword, NULL ); - m_pConnection->setPassword( aPassword ); - } - m_nLength = g_list_length( m_pContacts ); - - OSL_TRACE( "Query return %d records", m_nLength ); - m_nIndex = -1; - } -} - -// ------------------------------------------------------------------------- -void OEvoabResultSet::disposing(void) -{ - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); - g_list_free(m_pContacts); - m_pContacts = NULL; - m_pStatement = NULL; - m_xMetaData = NULL; -} -// ------------------------------------------------------------------------- -Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; -} -// ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) -{ - OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); - - /* Dont know what is this yet */ - return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); -} - static int whichAddress(int value) { @@ -311,7 +283,7 @@ whichAddress(int value) * The search order is Work->Home->other(defaults). */ static EContactAddress * -getDefaultContactAddress(EContact *pContact,int *value) +getDefaultContactAddress( EContact *pContact,int *value ) { EContactAddress *ec = (EContactAddress *)e_contact_get(pContact,whichAddress(WORK_ADDR_LINE1)); if ( ec && (strlen(ec->street)>0) ) @@ -334,7 +306,7 @@ getDefaultContactAddress(EContact *pContact,int *value) } static EContactAddress* -getContactAddress(EContact *pContact, int * address_enum) +getContactAddress( EContact *pContact, int * address_enum ) { EContactAddress *ec = NULL; switch (*address_enum) { @@ -353,9 +325,8 @@ getContactAddress(EContact *pContact, int * address_enum) } static bool -handleSplitAddress(EContact *pContact,GValue *pStackValue,int value) +handleSplitAddress( EContact *pContact,GValue *pStackValue, int value ) { - EContactAddress *ec = getContactAddress(pContact,&value) ; if (ec==NULL) @@ -403,65 +374,232 @@ handleSplitAddress(EContact *pContact,GValue *pStackValue,int value) } -return false; + return false; } -// ------------------------------------------------------------------------- -// XRow Interface - -bool -OEvoabResultSet::getValue( sal_Int32 nColumnNum, GType nType, GValue *pStackValue) +static bool +getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue, bool& _out_rWasNull ) { - const ColumnProperty * pSpecs = evoab::getField (nColumnNum ); - if (!pSpecs) - return sal_False; - GParamSpec *pSpec = pSpecs->pField; - gboolean bIsSplittedColumn=pSpecs->bIsSplittedValue; - EContact *pContact = getCur(); + const ColumnProperty * pSpecs = evoab::getField( nColumnNum ); + if ( !pSpecs ) + return false; + + GParamSpec* pSpec = pSpecs->pField; + gboolean bIsSplittedColumn = pSpecs->bIsSplittedValue; - m_bWasNull = true; - if (!pSpec || !pContact) { + _out_rWasNull = true; + if ( !pSpec || !pContact) return false; - } - if (G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType) + + if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType ) { -#ifdef DEBUG - g_warning ("Wrong type (0x%x) (0x%x) '%s'", + + OSL_TRACE( "Wrong type (0x%x) (0x%x) '%s'", (int)G_PARAM_SPEC_VALUE_TYPE (pSpec), (int) nType, pSpec->name ? pSpec->name : "<noname>"); -#endif return false; } - g_value_init (pStackValue, nType); - if (bIsSplittedColumn) + + g_value_init( pStackValue, nType ); + if ( bIsSplittedColumn ) { const SplitEvoColumns* evo_addr( get_evo_addr() ); for (int i=0;i<OTHER_ZIP;i++) { if (0 == strcmp (g_param_spec_get_name ((GParamSpec *)pSpec), evo_addr[i].pColumnName)) { - m_bWasNull = handleSplitAddress (pContact, pStackValue, evo_addr[i].value); + _out_rWasNull = handleSplitAddress( pContact, pStackValue, evo_addr[i].value ); return true; } } } else { - g_object_get_property (G_OBJECT (pContact), + g_object_get_property( G_OBJECT (pContact), g_param_spec_get_name ((GParamSpec *) pSpec), - pStackValue); - if (G_VALUE_TYPE (pStackValue) != nType) + pStackValue ); + if ( G_VALUE_TYPE( pStackValue ) != nType ) { -#ifdef DEBUG - g_warning ("Fetched type mismatch"); -#endif - g_value_unset (pStackValue); + OSL_TRACE( "Fetched type mismatch" ); + g_value_unset( pStackValue ); return false; } } - m_bWasNull = false; + _out_rWasNull = false; return true; } +namespace +{ + struct ComparisonData + { + const SortDescriptor& rSortOrder; + IntlWrapper aIntlWrapper; + + ComparisonData( const SortDescriptor& _rSortOrder, const Reference< XMultiServiceFactory >& _rxFactory ) + :rSortOrder( _rSortOrder ) + ,aIntlWrapper( _rxFactory, SvtSysLocale().GetLocaleData().getLocale() ) + { + } + }; +} + +extern "C" +int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData ) +{ + EContact* lhs = static_cast< EContact* >( const_cast< gpointer >( _lhs ) ); + EContact* rhs = static_cast< EContact* >( const_cast< gpointer >( _rhs ) ); + + GValue aLhsValue = { 0, { { 0 } } }; + GValue aRhsValue = { 0, { { 0 } } }; + bool bLhsNull = true; + bool bRhsNull = true; + + ::rtl::OUString sLhs, sRhs; + bool bLhs(false), bRhs(false); + + const ComparisonData& rCompData = *static_cast< const ComparisonData* >( _userData ); + for ( SortDescriptor::const_iterator sortCol = rCompData.rSortOrder.begin(); + sortCol != rCompData.rSortOrder.end(); + ++sortCol + ) + { + sal_Int32 nField = sortCol->nField; + GType eFieldType = evoab::getGFieldType( nField ); + + bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull ) + && getValue( rhs, nField, eFieldType, &aRhsValue, bRhsNull ); + OSL_ENSURE( success, "CompareContacts: could not retrieve both values!" ); + if ( !success ) + return 0; + + if ( bLhsNull && !bRhsNull ) + return -1; + if ( !bLhsNull && bRhsNull ) + return 1; + if ( bLhsNull && bRhsNull ) + continue; + + if ( eFieldType == G_TYPE_STRING ) + { + sLhs = valueToOUString( aLhsValue ); + sRhs = valueToOUString( aRhsValue ); + sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs ); + if ( nCompResult != 0 ) + return nCompResult; + continue; + } + + bLhs = valueToBool( aLhsValue ); + bRhs = valueToBool( aRhsValue ); + if ( bLhs && !bRhs ) + return -1; + if ( !bLhs && bRhs ) + return 1; + continue; + } + + return 0; +} + +static GList* +sortContacts( GList* _pContactList, const ComparisonData& _rCompData ) +{ + OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" ); + ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" ); + + return g_list_sort_with_data( _pContactList, &CompareContacts, const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) ); +} + +// ------------------------------------------------------------------------- +void OEvoabResultSet::construct( const QueryData& _rData ) +{ + ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" ); + + EBook *pBook = openBook( ::rtl::OUStringToOString( _rData.sTable, RTL_TEXTENCODING_UTF8 ) ); + if ( !pBook ) + m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this ); + + g_list_free(m_pContacts); + m_pContacts = NULL; + bool bExecuteQuery = true; + switch ( _rData.eFilterType ) + { + case eFilterNone: + if ( !isLocal( pBook ) ) + { + SQLError aErrorFactory( m_pConnection->getDriver().getMSFactory() ); + SQLException aAsException = aErrorFactory.getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *this ); + m_aWarnings.appendWarning( SQLWarning( + aAsException.Message, + aAsException.Context, + aAsException.SQLState, + aAsException.ErrorCode, + aAsException.NextException + ) ); + bExecuteQuery = false; + } + break; + case eFilterAlwaysFalse: + bExecuteQuery = false; + break; + case eFilterOther: + bExecuteQuery = true; + break; + } + if ( bExecuteQuery ) + { + rtl::OString aPassword = m_pConnection->getPassword(); + executeQuery( pBook, _rData.getQuery(), &m_pContacts, aPassword, NULL ); + m_pConnection->setPassword( aPassword ); + + if ( m_pContacts && !_rData.aSortOrder.empty() ) + { + ComparisonData aCompData( _rData.aSortOrder, getConnection()->getDriver().getMSFactory() ); + m_pContacts = sortContacts( m_pContacts, aCompData ); + } + } + m_nLength = g_list_length( m_pContacts ); + OSL_TRACE( "Query return %d records", m_nLength ); + m_nIndex = -1; + + // create our meta data (need the EBookQuery for this) + OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( _rData.sTable ); + m_xMetaData = pMeta; + + pMeta->setEvoabFields( _rData.xSelectColumns ); +} + +// ------------------------------------------------------------------------- +void OEvoabResultSet::disposing(void) +{ + ::comphelper::OPropertyContainer::disposing(); + + ::osl::MutexGuard aGuard(m_aMutex); + g_list_free(m_pContacts); + m_pContacts = NULL; + m_pStatement = NULL; + m_xMetaData = NULL; +} +// ------------------------------------------------------------------------- +Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType); + if(!aRet.hasValue()) + aRet = OResultSet_BASE::queryInterface(rType); + return aRet; +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException) +{ + return ::comphelper::concatSequences( + OResultSet_BASE::getTypes(), + ::comphelper::OPropertyContainer::getTypes() + ); +} + +// ------------------------------------------------------------------------- +// XRow Interface + /** * getString: * @nColumnNum: The column index from the table. @@ -475,17 +613,12 @@ OEvoabResultSet::getValue( sal_Int32 nColumnNum, GType nType, GValue *pStackValu checkDisposed(OResultSet_BASE::rBHelper.bDisposed); rtl::OUString aResult; if ( m_xMetaData.is()) - { - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); - sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); - GValue aValue = {0, {{0}}}; - if (getValue (nFieldNumber, G_TYPE_STRING, &aValue)) - { - const char *pStr = g_value_get_string (&aValue); - rtl::OString aStr (pStr ? pStr : ""); - aResult = rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ); - g_value_unset (&aValue); - } + { + OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); + sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); + GValue aValue = { 0, { { 0 } } }; + if ( getValue( getCur(), nFieldNumber, G_TYPE_STRING, &aValue, m_bWasNull ) ) + aResult = valueToOUString( aValue ); } return aResult; } @@ -497,15 +630,12 @@ sal_Bool SAL_CALL OEvoabResultSet::getBoolean( sal_Int32 nColumnNum ) throw(SQLE sal_Bool bResult = sal_False; if ( m_xMetaData.is()) - { - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); - sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); - GValue aValue = {0, {{0}}}; - if (getValue (nFieldNumber, G_TYPE_BOOLEAN, &aValue)) - { - bResult = g_value_get_boolean (&aValue); - g_value_unset (&aValue); - } + { + OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get(); + sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum); + GValue aValue = { 0, { { 0 } } }; + if ( getValue( getCur(), nFieldNumber, G_TYPE_BOOLEAN, &aValue, m_bWasNull ) ) + bResult = valueToBool( aValue ); } return bResult ? sal_True : sal_False; } @@ -558,7 +688,7 @@ sal_Int16 SAL_CALL OEvoabResultSet::getShort( sal_Int32 /*nColumnNum*/ ) throw(S return ::com::sun::star::util::Time(); } // ------------------------------------------------------------------------- -DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) +util::DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) { ::dbtools::throwFunctionNotSupportedException( "XRow::getTimestamp", *this ); return ::com::sun::star::util::DateTime(); @@ -620,9 +750,8 @@ Reference< XResultSetMetaData > SAL_CALL OEvoabResultSet::getMetaData( ) throw( ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - OSL_TRACE("OEvoabResultSet::getMetaData"); - if(!m_xMetaData.is()) - m_xMetaData = new OEvoabResultSetMetaData(m_pConnection->getCurrentTableName()); + // the meta data should have been created at construction time + ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" ); return m_xMetaData; } // XResultSetMetaDataSupplier Interface Ends @@ -829,12 +958,13 @@ void SAL_CALL OEvoabResultSet::close( ) throw(SQLException, RuntimeException) void SAL_CALL OEvoabResultSet::clearWarnings( ) throw(SQLException, RuntimeException) { OSL_TRACE("In/Out: OEvoabResultSet::clearWarnings" ); + m_aWarnings.clearWarnings(); } // ------------------------------------------------------------------------- Any SAL_CALL OEvoabResultSet::getWarnings( ) throw(SQLException, RuntimeException) { OSL_TRACE("In/Out: OEvoabResultSet::getWarnings" ); - return Any(); + return m_aWarnings.getWarnings(); } // ------------------------------------------------------------------------- //XColumnLocate Interface @@ -857,93 +987,17 @@ sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const ::rtl::OUString& columnNam //XColumnLocate interface ends // ------------------------------------------------------------------------- -IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const +::cppu::IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const { - Sequence< Property > aProps(6); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); - DECL_PROP0(FETCHDIRECTION, sal_Int32); - DECL_PROP0(FETCHSIZE, sal_Int32); - DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY); - DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); - DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); - - return new OPropertyArrayHelper(aProps); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); } // ------------------------------------------------------------------------- -IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() +::cppu::IPropertyArrayHelper & OEvoabResultSet::getInfoHelper() { return *const_cast<OEvoabResultSet*>(this)->getArrayHelper(); } -// ------------------------------------------------------------------------- -sal_Bool OEvoabResultSet::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 nHandle, - const Any& /*rValue*/ ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw ::com::sun::star::lang::IllegalArgumentException(); - break; - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - default: - ; - } - return sal_False; -} -// ------------------------------------------------------------------------- -void OEvoabResultSet::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& /*rValue*/) throw (Exception) -{ - switch(nHandle) - { - case PROPERTY_ID_ISBOOKMARKABLE: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw Exception(); - break; - case PROPERTY_ID_FETCHDIRECTION: - break; - case PROPERTY_ID_FETCHSIZE: - break; - default: - ; - } -} -// ------------------------------------------------------------------------- -void OEvoabResultSet::getFastPropertyValue( - Any& rValue, - sal_Int32 nHandle - ) const -{ - - switch(nHandle) - { - case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= (sal_Int32)m_nResultSetConcurrency; - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= m_nResultSetType; - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= m_nFetchDirection; - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= m_nFetchSize; - break; - } - -} // ----------------------------------------------------------------------------- void SAL_CALL OEvoabResultSet::acquire() throw() { @@ -961,3 +1015,5 @@ OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeExce return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); } // ----------------------------------------------------------------------------- + +} } // connectivity::evoab diff --git a/connectivity/source/drivers/evoab2/NResultSet.hxx b/connectivity/source/drivers/evoab2/NResultSet.hxx index 927db78f319f..b01928ab19e7 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.hxx +++ b/connectivity/source/drivers/evoab2/NResultSet.hxx @@ -42,12 +42,12 @@ #include <com/sun/star/sdbc/XRowUpdate.hpp> #include <com/sun/star/sdbcx/XRowLocate.hpp> #include <com/sun/star/sdbcx/XDeleteRows.hpp> -#ifndef _CPPUHELPER_COMPBASE12_HXX_ #include <cppuhelper/compbase8.hxx> -#endif #include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> #include "connectivity/CommonTools.hxx" #include "connectivity/FValue.hxx" +#include "connectivity/warningscontainer.hxx" #include "NStatement.hxx" #include "OSubComponent.hxx" #include "NResultSetMetaData.hxx" @@ -56,76 +56,61 @@ namespace connectivity { namespace evoab { - typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::sdbc::XResultSet, - ::com::sun::star::sdbc::XRow, - ::com::sun::star::sdbc::XResultSetMetaDataSupplier, - ::com::sun::star::util::XCancellable, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable, - ::com::sun::star::sdbc::XColumnLocate, - ::com::sun::star::lang::XServiceInfo> OResultSet_BASE; - - - class OEvoabResultSet : public comphelper::OBaseMutex, - public OResultSet_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> + typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::sdbc::XResultSet + , ::com::sun::star::sdbc::XRow + , ::com::sun::star::sdbc::XResultSetMetaDataSupplier + , ::com::sun::star::util::XCancellable + , ::com::sun::star::sdbc::XWarningsSupplier + , ::com::sun::star::sdbc::XCloseable + , ::com::sun::star::sdbc::XColumnLocate + , ::com::sun::star::lang::XServiceInfo + > OResultSet_BASE; + + + class OEvoabResultSet :public comphelper::OBaseMutex + ,public OResultSet_BASE + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> { protected: - OStatement_Base *m_pStatement; - OEvoabConnection *m_pConnection; - ::com::sun::star::uno::WeakReferenceHelper m_aStatement; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; + OCommonStatement* m_pStatement; + OEvoabConnection* m_pConnection; + ::com::sun::star::uno::WeakReferenceHelper m_aStatement; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData; + ::dbtools::WarningsContainer m_aWarnings; - sal_Bool m_bWasNull; + bool m_bWasNull; + // <properties> sal_Int32 m_nFetchSize; sal_Int32 m_nResultSetType; sal_Int32 m_nFetchDirection; sal_Int32 m_nResultSetConcurrency; + // </properties> // Data & iteration GList *m_pContacts; sal_Int32 m_nIndex; sal_Int32 m_nLength; - connectivity::OSQLParseTreeIterator& m_aSQLIterator; EContact *getCur() { gpointer pData = g_list_nth_data (m_pContacts, m_nIndex); return pData ? E_CONTACT (pData) : NULL; } - bool getValue( sal_Int32 nColumnIndex, GType nType, GValue *pStackValue); // OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const; - // you can't delete objects of this type virtual ~OEvoabResultSet(); public: DECLARE_SERVICE_INFO(); - OEvoabResultSet(OStatement_Base *pStmt, OEvoabConnection *pConnection,OSQLParseTreeIterator& _aSQLIterator); - virtual void construct(void); - void construct( EBookQuery *pQuery, rtl::OString aTable, bool bIsWithoutWhere ); + OEvoabResultSet( OCommonStatement *pStmt, OEvoabConnection *pConnection ); + void construct( const QueryData& _rData ); OEvoabConnection * getConnection() { return m_pConnection; } diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx index f8b79f01a561..b36a86fb96b0 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NResultSetMetaData.cxx,v $ - * $Revision: 1.7.56.2 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -177,7 +174,7 @@ sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ // ------------------------------------------------------------------------- sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) { - return sal_False; + return sal_True; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/evoab2/NServices.cxx b/connectivity/source/drivers/evoab2/NServices.cxx index bbecf7a0c9a2..efa9b6d56c72 100644 --- a/connectivity/source/drivers/evoab2/NServices.cxx +++ b/connectivity/source/drivers/evoab2/NServices.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NServices.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -117,7 +114,7 @@ struct ProviderRequest //--------------------------------------------------------------------------------------- -extern "C" void SAL_CALL component_getImplementationEnvironment( +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char **ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) @@ -126,7 +123,7 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( } //--------------------------------------------------------------------------------------- -extern "C" sal_Bool SAL_CALL component_writeInfo( +extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey ) @@ -151,7 +148,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( } //--------------------------------------------------------------------------------------- -extern "C" void* SAL_CALL component_getFactory( +extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, void* pServiceManager, void* /*pRegistryKey*/) diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx index 76f9f0885033..6cc1ceb11f03 100644 --- a/connectivity/source/drivers/evoab2/NStatement.cxx +++ b/connectivity/source/drivers/evoab2/NStatement.cxx @@ -1,4 +1,4 @@ - /************************************************************************* +/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: NStatement.cxx,v $ - * $Revision: 1.12.2.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -42,12 +39,16 @@ #include "propertyids.hxx" #include "NStatement.hxx" #include "NConnection.hxx" +#include "NDatabaseMetaData.hxx" #include "NResultSet.hxx" #include "NDebug.hxx" +#include "resource/evoab2_res.hrc" #include <resource/common_res.hrc> #include <connectivity/dbexception.hxx> +#include <tools/diagnose_ex.h> + +namespace connectivity { namespace evoab { -using namespace connectivity::evoab; //------------------------------------------------------------------------------ using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -58,25 +59,53 @@ using namespace com::sun::star::container; using namespace com::sun::star::io; using namespace com::sun::star::util; //------------------------------------------------------------------------------ -OStatement_Base::OStatement_Base(OEvoabConnection* _pConnection) - : OStatement_BASE(m_aMutex) - , OPropertySetHelper(OStatement_BASE::rBHelper) +OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection) + : OCommonStatement_IBase(m_aMutex) + , ::comphelper::OPropertyContainer(OCommonStatement_IBase::rBHelper) + , OStatement_CBase( (::cppu::OWeakObject*)_pConnection, this ) , m_xResultSet(NULL) , m_pResultSet(NULL) , m_pConnection(_pConnection) - , m_aParser(_pConnection->getDriver()->getMSFactory()) + , m_aParser(_pConnection->getDriver().getMSFactory()) , m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) , m_pParseTree(NULL) - , rBHelper(OStatement_BASE::rBHelper) + , m_nMaxFieldSize(0) + , m_nMaxRows(0) + , m_nQueryTimeOut(0) + , m_nFetchSize(0) + , m_nResultSetType(ResultSetType::FORWARD_ONLY) + , m_nFetchDirection(FetchDirection::FORWARD) + , m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) + , m_bEscapeProcessing(sal_True) + , rBHelper(OCommonStatement_IBase::rBHelper) { m_pConnection->acquire(); + +#define REGISTER_PROP( id, member ) \ + registerProperty( \ + OMetaConnection::getPropMap().getNameByIndex( id ), \ + id, \ + 0, \ + &member, \ + ::getCppuType( &member ) \ + ); + + REGISTER_PROP( PROPERTY_ID_CURSORNAME, m_aCursorName ); + REGISTER_PROP( PROPERTY_ID_MAXFIELDSIZE, m_nMaxFieldSize ); + REGISTER_PROP( PROPERTY_ID_MAXROWS, m_nMaxRows ); + REGISTER_PROP( PROPERTY_ID_QUERYTIMEOUT, m_nQueryTimeOut ); + REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize ); + REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType ); + REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection ); + REGISTER_PROP( PROPERTY_ID_ESCAPEPROCESSING, m_bEscapeProcessing ); + REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency ); } // ----------------------------------------------------------------------------- -OStatement_Base::~OStatement_Base() +OCommonStatement::~OCommonStatement() { } //------------------------------------------------------------------------------ -void OStatement_Base::disposeResultSet() +void OCommonStatement::disposeResultSet() { // free the cursor if alive Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY); @@ -85,7 +114,7 @@ void OStatement_Base::disposeResultSet() m_xResultSet = Reference< XResultSet>(); } //------------------------------------------------------------------------------ -void OStatement_BASE2::disposing() +void OCommonStatement::disposing() { ::osl::MutexGuard aGuard(m_aMutex); @@ -96,55 +125,50 @@ void OStatement_BASE2::disposing() m_pConnection = NULL; dispose_ChildImpl(); - OStatement_Base::disposing(); -} -//----------------------------------------------------------------------------- -void SAL_CALL OStatement_BASE2::release() throw() -{ - relase_ChildImpl(); + OCommonStatement_IBase::disposing(); } //----------------------------------------------------------------------------- -Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) +Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OStatement_BASE::queryInterface(rType); + Any aRet = OCommonStatement_IBase::queryInterface(rType); if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); + aRet = ::comphelper::OPropertyContainer::queryInterface(rType); return aRet; } // ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) +Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException) { ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), ::getCppuType( (const Reference< XFastPropertySet > *)0 ), ::getCppuType( (const Reference< XPropertySet > *)0 )); - return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes()); + return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBase::getTypes()); } // ------------------------------------------------------------------------- -//void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException) +//void SAL_CALL OCommonStatement::cancel( ) throw(RuntimeException) //{ //::osl::MutexGuard aGuard( m_aMutex ); -//checkDisposed(OStatement_BASE::rBHelper.bDisposed); +//checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); //// cancel the current sql statement //} // ------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException) +void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException) { { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); } dispose(); } // ------------------------------------------------------------------------- -void OStatement_Base::reset() throw (SQLException) +void OCommonStatement::reset() throw (SQLException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); clearWarnings (); @@ -153,10 +177,10 @@ void OStatement_Base::reset() throw (SQLException) clearMyResultSet(); } -void OStatement_Base::clearMyResultSet () throw (SQLException) +void OCommonStatement::clearMyResultSet () throw (SQLException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); try { @@ -170,48 +194,105 @@ void OStatement_Base::clearMyResultSet () throw (SQLException) } EBookQuery * -OStatement_Base::createTrue() +OCommonStatement::createTrue() { // Not the world's most efficient unconditional true but ... return e_book_query_from_string("(exists \"full_name\")"); } EBookQuery * -OStatement_Base::createTest( const ::rtl::OUString &aColumnName, +OCommonStatement::createTest( const ::rtl::OUString &aColumnName, EBookQueryTest eTest, - const ::rtl::OUString &aMatch, - bool bGeneric ) + const ::rtl::OUString &aMatch ) { - rtl::OString sMatch = rtl::OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); - rtl::OString sColumnName = rtl::OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); - if ( bGeneric && (aColumnName.equalsAscii("0") || - aColumnName.equalsAscii("1"))) - { - if( aMatch.equals( aColumnName ) ) - return createTrue(); - else - return NULL; - } + ::rtl::OString sMatch = rtl::OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 ); + ::rtl::OString sColumnName = rtl::OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 ); return e_book_query_field_test( e_contact_field_id( sColumnName ), eTest, sMatch ); } // ------------------------------------------------------------------------- -sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) + +::rtl::OUString OCommonStatement::impl_getColumnRefColumnName_throw( const OSQLParseNode& _rColumnRef ) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + ENSURE_OR_THROW( SQL_ISRULE( &_rColumnRef, column_ref ), "internal error: only column_refs supported as LHS" ); + + ::rtl::OUString sColumnName; + switch ( _rColumnRef.count() ) + { + case 3: // SQL_TOKEN_NAME '.' column_val + { + const OSQLParseNode* pPunct = _rColumnRef.getChild( 1 ); + const OSQLParseNode* pColVal = _rColumnRef.getChild( 2 ); + if ( SQL_ISPUNCTUATION( pPunct, "." ) + && ( pColVal->count() == 1 ) + ) + { + sColumnName = pColVal->getChild( 0 )->getTokenValue(); + } + } + break; + + case 1: // column + { + sColumnName = _rColumnRef.getChild( 0 )->getTokenValue(); + } + break; + } + + if ( !sColumnName.getLength() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + return sColumnName; +} + +// ------------------------------------------------------------------------- +void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort ) +{ + ENSURE_OR_THROW( _pOrderByClause, "NULL node" ); + ENSURE_OR_THROW( SQL_ISRULE( _pOrderByClause, opt_order_by_clause ), "wrong node type" ); + + _out_rSort.clear(); + + const OSQLParseNode* pOrderList = _pOrderByClause->getByRule( OSQLParseNode::ordering_spec_commalist ); + ENSURE_OR_THROW( pOrderList, "unexpected parse tree structure" ); - executeQuery( sql ); - return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT; + for ( sal_uInt32 i=0; i<pOrderList->count(); ++i ) + { + const OSQLParseNode* pOrderBy = pOrderList->getChild(i); + if ( !pOrderBy || !SQL_ISRULE( pOrderBy, ordering_spec ) ) + continue; + const OSQLParseNode* pColumnRef = pOrderBy->count() == 2 ? pOrderBy->getChild(0) : NULL; + const OSQLParseNode* pAscDesc = pOrderBy->count() == 2 ? pOrderBy->getChild(1) : NULL; + ENSURE_OR_THROW( + ( pColumnRef != NULL ) + && ( pAscDesc != NULL ) + && SQL_ISRULE( pAscDesc, opt_asc_desc ) + && ( pAscDesc->count() < 2 ), + "ordering_spec structure error" ); + + // column name -> column field + if ( !SQL_ISRULE( pColumnRef, column_ref ) ) + m_pConnection->throwGenericSQLException( STR_SORT_BY_COL_ONLY, *this ); + const ::rtl::OUString sColumnName( impl_getColumnRefColumnName_throw( *pColumnRef ) ); + guint nField = evoab::findEvoabField( sColumnName ); + // ascending/descending? + bool bAscending = true; + if ( ( pAscDesc->count() == 1 ) + && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC ) + ) + bAscending = false; + + _out_rSort.push_back( FieldSort( nField, bAscending ) ); + } } -EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) throw(SQLException, RuntimeException) +// ------------------------------------------------------------------------- +EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree ) { EBookQuery *pResult = NULL; - if (!parseTree) - return NULL; + ENSURE_OR_THROW( parseTree, "invalid parse tree" ); // Nested brackets if( parseTree->count() == 3 && @@ -226,83 +307,87 @@ EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) thr SQL_ISRULE( parseTree, boolean_term ) ) && parseTree->count() == 3 ) { + ENSURE_OR_THROW( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) + || SQL_ISTOKEN( parseTree->getChild( 1 ), AND ), + "unexpected search_condition structure" ); + EBookQuery *pArgs[2]; pArgs[0] = whereAnalysis( parseTree->getChild( 0 ) ); pArgs[1] = whereAnalysis( parseTree->getChild( 2 ) ); if( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) ) - pResult = e_book_query_or( 2, pArgs, TRUE ); - else if( SQL_ISTOKEN( parseTree->getChild( 1 ), AND ) ) - pResult = e_book_query_and( 2, pArgs, TRUE ); + pResult = e_book_query_or( 2, pArgs, TRUE ); else - { - OSL_ASSERT("analyseSQL: Error in Parse Tree"); - e_book_query_unref( pArgs[ 0 ] ); - e_book_query_unref( pArgs[ 1 ] ); - return NULL; - } + pResult = e_book_query_and( 2, pArgs, TRUE ); } // SQL =, != else if( SQL_ISRULE( parseTree, comparison_predicate ) ) { OSQLParseNode *pPrec = parseTree->getChild( 1 ); - if( parseTree->count() != 3 ) + ENSURE_OR_THROW( parseTree->count() == 3, "unexpected comparison_predicate structure" ); + + OSQLParseNode* pLHS = parseTree->getChild( 0 ); + OSQLParseNode* pRHS = parseTree->getChild( 2 ); + + if ( ( !( SQL_ISRULE( pLHS, column_ref ) ) // on the LHS, we accept a column or a constant int value + && ( pLHS->getNodeType() != SQL_NODE_INTNUM ) + ) + || ( ( pRHS->getNodeType() != SQL_NODE_STRING ) // on the RHS, certain literals are acceptable + && ( pRHS->getNodeType() != SQL_NODE_INTNUM ) + && ( pRHS->getNodeType() != SQL_NODE_APPROXNUM ) + && !( SQL_ISTOKEN( pRHS, TRUE ) ) + && !( SQL_ISTOKEN( pRHS, FALSE ) ) + ) + || ( ( pLHS->getNodeType() == SQL_NODE_INTNUM ) // an int on LHS requires an int on RHS + && ( pRHS->getNodeType() != SQL_NODE_INTNUM ) + ) + ) { - OSL_ASSERT("analyseSQL: Error in Parse Tree"); - return NULL; + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); } - if( !( SQL_ISRULE( parseTree->getChild( 0 ), column_ref) || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_STRING || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_INTNUM || - parseTree->getChild( 2 )->getNodeType() == SQL_NODE_APPROXNUM || - SQL_ISTOKEN( parseTree->getChild( 2 ), TRUE ) || - SQL_ISTOKEN( parseTree->getChild( 2 ), FALSE ) || - SQL_ISRULE( parseTree->getChild( 2 ), parameter ) || - // odbc date - (SQL_ISRULE( parseTree->getChild( 2 ), set_fct_spec ) && - SQL_ISPUNCTUATION( parseTree->getChild( 2 )->getChild( 0 ), "{" ) ) ) ) - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - if (pPrec->getNodeType() != SQL_NODE_EQUAL && pPrec->getNodeType() != SQL_NODE_NOTEQUAL) - m_pConnection->throwGenericSQLException(STR_OPERATOR_TOO_COMPLEX,*this); - - rtl::OUString aMatchString; - rtl::OUString aColumnName; - if( SQL_ISRULE( parseTree->getChild( 0 ), column_ref ) ) + if ( ( pPrec->getNodeType() != SQL_NODE_EQUAL ) + && ( pPrec->getNodeType() != SQL_NODE_NOTEQUAL ) + ) { - aColumnName = parseTree->getChild( 0 )->getChild( 0 )->getTokenValue(); - - if( parseTree->getChild( 2 )->isToken() ) - aMatchString = parseTree->getChild( 2 )->getTokenValue(); - else - aMatchString = parseTree->getChild( 2 )->getChild( 0 )->getTokenValue(); + m_pConnection->throwGenericSQLException( STR_OPERATOR_TOO_COMPLEX, *this ); } - else + + // recognize the special "0 = 1" condition + if ( ( pLHS->getNodeType() == SQL_NODE_INTNUM ) + && ( pRHS->getNodeType() == SQL_NODE_INTNUM ) + && ( pPrec->getNodeType() == SQL_NODE_EQUAL ) + ) { - aColumnName = parseTree->getChild( 0 )->getTokenValue(); - aMatchString = parseTree->getChild( 2 )->getTokenValue(); + const sal_Int32 nLHS = pLHS->getTokenValue().toInt64(); + const sal_Int32 nRHS = pRHS->getTokenValue().toInt64(); + return ( nLHS == nRHS ) ? createTrue() : NULL; } - pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString, true ); + ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *pLHS ) ); + + ::rtl::OUString aMatchString; + if ( pRHS->isToken() ) + aMatchString = pRHS->getTokenValue(); + else + aMatchString = pRHS->getChild( 0 )->getTokenValue(); + + pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString ); - if (pResult && pPrec->getNodeType() == SQL_NODE_NOTEQUAL) + if ( pResult && ( pPrec->getNodeType() == SQL_NODE_NOTEQUAL ) ) pResult = e_book_query_not( pResult, TRUE ); } // SQL like else if( SQL_ISRULE( parseTree, like_predicate ) ) { - if( parseTree->count() < 4 ) - { - OSL_ASSERT( "analyseSQL: Error in parsing LIKE predicate" ); - return NULL; - } + ENSURE_OR_THROW( parseTree->count() >= 4, "unexpected like_predicate structure" ); if( ! SQL_ISRULE( parseTree->getChild( 0 ), column_ref) ) m_pConnection->throwGenericSQLException(STR_QUERY_INVALID_LIKE_COLUMN,*this); - OSQLParseNode *pColumn = parseTree->getChild( 0 ); // Match Item + ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *parseTree->getChild( 0 ) ) ); + OSQLParseNode *pAtom = parseTree->getChild( parseTree->count() - 2 ); // Match String bool bNotLike = parseTree->count() == 5; @@ -318,62 +403,54 @@ EBookQuery *OStatement_Base::whereAnalysis( const OSQLParseNode* parseTree ) thr const sal_Unicode WILDCARD = '%'; - rtl::OUString aColumnName; rtl::OUString aMatchString; + aMatchString = pAtom->getTokenValue(); - if( SQL_ISRULE( pColumn, column_ref )) + // Determine where '%' character is... + if( aMatchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) ) { - aColumnName = parseTree->getChild(0)->getChild(0)->getTokenValue(); - aMatchString = pAtom->getTokenValue(); - - // Determine where '%' character is... - if( aMatchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) ) - { - // String containing only a '%' and nothing else matches everything - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, - rtl::OUString::createFromAscii( "" ) ); - } - else if( aMatchString.indexOf( WILDCARD ) == -1 ) - { // Simple string , eg. "to match" "contains in evo" - EVO_TRACE_STRING( "Plain contains '%s'", aMatchString ); - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString ); - if( pResult && bNotLike ) - pResult = e_book_query_not( pResult, TRUE ); - } - else if( bNotLike ) - { - // We currently can't handle a 'NOT LIKE' when there are '%' - m_pConnection->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this); - } - else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) ) - { // One occurance of '%' matches... - if ( aMatchString.indexOf ( WILDCARD ) == 0 ) - pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) ); - else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 ) - pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) ); - else - m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this); - - if( pResult && bNotLike ) - pResult = e_book_query_not( pResult, TRUE ); - } - else if( aMatchString.getLength() >= 3 && - aMatchString.indexOf ( WILDCARD ) == 0 && - aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) { - // one '%' at the start and another at the end - pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) ); - } + // String containing only a '%' and nothing else matches everything + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, + rtl::OUString::createFromAscii( "" ) ); + } + else if( aMatchString.indexOf( WILDCARD ) == -1 ) + { // Simple string , eg. "to match" "contains in evo" + EVO_TRACE_STRING( "Plain contains '%s'", aMatchString ); + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString ); + if( pResult && bNotLike ) + pResult = e_book_query_not( pResult, TRUE ); + } + else if( bNotLike ) + { + // We currently can't handle a 'NOT LIKE' when there are '%' + m_pConnection->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this); + } + else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) ) + { // One occurance of '%' matches... + if ( aMatchString.indexOf ( WILDCARD ) == 0 ) + pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) ); + else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 ) + pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) ); else - m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD_MANY,*this); + m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this); + + if( pResult && bNotLike ) + pResult = e_book_query_not( pResult, TRUE ); + } + else if( aMatchString.getLength() >= 3 && + aMatchString.indexOf ( WILDCARD ) == 0 && + aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) { + // one '%' at the start and another at the end + pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) ); } else - OSL_ASSERT( "Serious internal error" ); + m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD_MANY,*this); } return pResult; } -rtl::OUString OStatement_Base::getTableName() +rtl::OUString OCommonStatement::getTableName() { ::rtl::OUString aTableName; @@ -398,235 +475,207 @@ rtl::OUString OStatement_Base::getTableName() OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName); } else - OSL_ASSERT( "odd table layout" ); + OSL_ENSURE( false, "odd table layout" ); } else - OSL_ASSERT( "unusual table layout" ); + OSL_ENSURE( false, "unusual table layout" ); } return aTableName; } -EBookQuery *OStatement_Base::parseSql( const rtl::OUString& sql, - rtl::OString &rTable, - bool &bIsWithoutWhere ) - throw ( SQLException, RuntimeException ) +void OCommonStatement::parseSql( const rtl::OUString& sql, QueryData& _out_rQueryData ) { - ::rtl::OUString aErr; + EVO_TRACE_STRING( "parsing %s", sql ); + _out_rQueryData.eFilterType = eFilterOther; + + ::rtl::OUString aErr; m_pParseTree = m_aParser.parseTree( aErr, sql ); m_aSQLIterator.setParseTree( m_pParseTree ); m_aSQLIterator.traverseAll(); - const OSQLTables aTables = m_aSQLIterator.getTables(); - rTable = rtl::OUStringToOString( getTableName(), RTL_TEXTENCODING_UTF8 ); - m_pConnection->setCurrentTableName(getTableName()); - const OSQLParseNode* pParseTree = m_aSQLIterator.getWhereTree(); - if ( pParseTree && SQL_ISRULE( pParseTree, where_clause ) ) - return whereAnalysis( pParseTree->getChild( 1 ) ); - else + _out_rQueryData.sTable = getTableName(); + + // to be sorted? + const OSQLParseNode* pOrderByClause = m_aSQLIterator.getOrderTree(); + if ( pOrderByClause ) { - bIsWithoutWhere = true; - return createTrue(); + #if OSL_DEBUG_LEVEL > 0 + ::rtl::OUString sTreeDebug; + pOrderByClause->showParseTree( sTreeDebug ); + EVO_TRACE_STRING( "found order-by tree:\n%s", sTreeDebug ); + #endif + orderByAnalysis( pOrderByClause, _out_rQueryData.aSortOrder ); } -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - - EVO_TRACE_STRING( "NConnection::executeQuery(%s)\n", sql ); - - OEvoabResultSet* pResult = createResultSet(); - Reference< XResultSet > xRS = pResult; - -#ifdef DEBUG - g_message( "Parse SQL '%s'\n", - (const sal_Char *)OUStringToOString( sql, RTL_TEXTENCODING_UTF8 ) ); -#endif - - rtl::OString aTable; - bool bIsWithoutWhere = false; - EBookQuery *pQuery = parseSql( sql, aTable, bIsWithoutWhere ); - -#ifdef DEBUG - char *pSexpr = pQuery ? e_book_query_to_string( pQuery ) : g_strdup( "<map failed>" ); - g_message( "Parsed SQL to sexpr '%s'\n", pSexpr ); - g_free( pSexpr ); -#endif - ::vos::ORef<connectivity::OSQLColumns> xColumns; - if (pQuery) + const OSQLParseNode* pWhereClause = m_aSQLIterator.getWhereTree(); + if ( pWhereClause && SQL_ISRULE( pWhereClause, where_clause ) ) { - pResult->construct( pQuery, aTable, bIsWithoutWhere ); - e_book_query_unref( pQuery ); - xColumns = m_aSQLIterator.getSelectColumns(); - if (!xColumns.isValid()) - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) pResult->getMetaData().get(); - pMeta->setEvoabFields(xColumns); + #if OSL_DEBUG_LEVEL > 0 + ::rtl::OUString sTreeDebug; + pWhereClause->showParseTree( sTreeDebug ); + EVO_TRACE_STRING( "found where tree:\n%s", sTreeDebug ); + #endif + EBookQuery* pQuery = whereAnalysis( pWhereClause->getChild( 1 ) ); + if ( !pQuery ) + { + _out_rQueryData.eFilterType = eFilterAlwaysFalse; + pQuery = createTrue(); + } + _out_rQueryData.setQuery( pQuery ); + } + else + { + _out_rQueryData.eFilterType = eFilterNone; + _out_rQueryData.setQuery( createTrue() ); } - m_xResultSet = xRS; - - return xRS; -} -// ------------------------------------------------------------------------- -OEvoabResultSet* OStatement_Base::createResultSet() -{ - return new OEvoabResultSet(this,m_pConnection,m_aSQLIterator); } // ------------------------------------------------------------------------- -Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException) +Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); // just return our connection here - return (Reference< XConnection >)m_pConnection; -} -// ------------------------------------------------------------------------- -Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this)); - if(!aRet.hasValue()) - aRet = OStatement_Base::queryInterface(rType); - return aRet; -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); - ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); - // the return values gives information about how many rows are affected by executing the sql statement - return 0; + return impl_getConnection(); } // ------------------------------------------------------------------------- -Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) +Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); return makeAny(SQLWarning()); } // ------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) +void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OStatement_BASE::rBHelper.bDisposed); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); } // ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const +::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const { - // this properties are define by the service statement - // they must in alphabetic order - Sequence< Property > aProps(10); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - DECL_PROP0(CURSORNAME, ::rtl::OUString); - DECL_BOOL_PROP0(ESCAPEPROCESSING); - DECL_PROP0(FETCHDIRECTION,sal_Int32); - DECL_PROP0(FETCHSIZE, sal_Int32); - DECL_PROP0(MAXFIELDSIZE,sal_Int32); - DECL_PROP0(MAXROWS, sal_Int32); - DECL_PROP0(QUERYTIMEOUT,sal_Int32); - DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); - DECL_PROP0(RESULTSETTYPE,sal_Int32); - DECL_BOOL_PROP0(USEBOOKMARKS); - - return new ::cppu::OPropertyArrayHelper(aProps); + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); } - // ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper() +::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper() { - return *const_cast<OStatement_Base*>(this)->getArrayHelper(); + return *const_cast< OCommonStatement* >( this )->getArrayHelper(); } -// ------------------------------------------------------------------------- -sal_Bool OStatement_Base::convertFastPropertyValue( - Any & /*rConvertedValue*/, - Any & /*rOldValue*/, - sal_Int32 /*nHandle*/, - const Any& /*rValue*/ ) - throw (::com::sun::star::lang::IllegalArgumentException) + +// ----------------------------------------------------------------------------- +void SAL_CALL OCommonStatement::acquire() throw() { - sal_Bool bModified = sal_False; - // here we have to try to convert - return bModified; + OCommonStatement_IBase::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL OCommonStatement::release() throw() +{ + relase_ChildImpl(); } + // ------------------------------------------------------------------------- -void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) throw (Exception) +QueryData OCommonStatement::impl_getEBookQuery_throw( const ::rtl::OUString& _rSql ) { - // set the value to what ever is nescessary - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } + QueryData aData; + parseSql( _rSql, aData ); + +#ifdef DEBUG + char *pSexpr = aData.getQuery() ? e_book_query_to_string( aData.getQuery() ) : g_strdup( "<map failed>" ); + g_message( "Parsed SQL to sexpr '%s'\n", pSexpr ); + g_free( pSexpr ); +#endif + + if ( !aData.getQuery() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + // a postcondition of this method is that we properly determined the SELECT columns + aData.xSelectColumns = m_aSQLIterator.getSelectColumns(); + if ( !aData.xSelectColumns.isValid() ) + m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this ); + + return aData; } + // ------------------------------------------------------------------------- -void OStatement_Base::getFastPropertyValue(Any& /*rValue*/,sal_Int32 nHandle) const +Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const QueryData& _rQueryData ) { - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - case PROPERTY_ID_MAXFIELDSIZE: - case PROPERTY_ID_MAXROWS: - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - case PROPERTY_ID_FETCHDIRECTION: - case PROPERTY_ID_FETCHSIZE: - case PROPERTY_ID_ESCAPEPROCESSING: - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } + // create result set + OEvoabResultSet* pResult = new OEvoabResultSet( this, m_pConnection ); + Reference< XResultSet > xRS = pResult; + pResult->construct( _rQueryData ); + + // done + m_xResultSet = xRS; + return xRS; } + // ------------------------------------------------------------------------- -IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement"); -// ----------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::acquire() throw() +Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const ::rtl::OUString& _rSql ) { - OStatement_BASE::acquire(); + EVO_TRACE_STRING( "OCommonStatement::impl_executeQuery_throw(%s)\n", _rSql ); + +#ifdef DEBUG + g_message( "Parse SQL '%s'\n", + (const sal_Char *)OUStringToOString( _rSql, RTL_TEXTENCODING_UTF8 ) ); +#endif + + return impl_executeQuery_throw( impl_getEBookQuery_throw( _rSql ) ); } + // ----------------------------------------------------------------------------- -void SAL_CALL OStatement_Base::release() throw() +Reference< XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException) { - OStatement_BASE::release(); + return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); } + +// ============================================================================= +// = OStatement +// ============================================================================= +// ----------------------------------------------------------------------------- +IMPLEMENT_SERVICE_INFO( OStatement, "com.sun.star.comp.sdbcx.evoab.OStatement", "com.sun.star.sdbc.Statement" ); + +// ----------------------------------------------------------------------------- +IMPLEMENT_FORWARD_XINTERFACE2( OStatement, OCommonStatement, OStatement_IBase ) + // ----------------------------------------------------------------------------- -void SAL_CALL OStatement::acquire() throw() +IMPLEMENT_FORWARD_XTYPEPROVIDER2( OStatement, OCommonStatement, OStatement_IBase ) + +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OStatement::execute( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) { - OStatement_BASE2::acquire(); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + + Reference< XResultSet > xRS = impl_executeQuery_throw( _sql ); + return xRS.is(); } -// ----------------------------------------------------------------------------- -void SAL_CALL OStatement::release() throw() + +// ------------------------------------------------------------------------- +Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException) { - OStatement_BASE2::release(); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + + return impl_executeQuery_throw( _sql ); } + // ----------------------------------------------------------------------------- -Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException) +sal_Int32 SAL_CALL OStatement::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) { - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed); + ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this ); + return 0; } -// ----------------------------------------------------------------------------- +} } // namespace ::connectivity::evoab diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx b/connectivity/source/drivers/evoab2/NStatement.hxx index cfab28883bad..ef3b2af4dbcf 100644 --- a/connectivity/source/drivers/evoab2/NStatement.hxx +++ b/connectivity/source/drivers/evoab2/NStatement.hxx @@ -37,52 +37,149 @@ #include <com/sun/star/sdbc/XCloseable.hpp> #include <com/sun/star/sdbc/SQLWarning.hpp> #include <comphelper/proparrhlp.hxx> -#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase2.hxx> #include <comphelper/uno3.hxx> #include "connectivity/CommonTools.hxx" -#ifndef INCLUDED_LIST -#include <list> -#define INCLUDED_LIST -#endif #include <com/sun/star/lang/XServiceInfo.hpp> #include <comphelper/broadcasthelper.hxx> #include "connectivity/sqliterator.hxx" -#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_ #include "connectivity/sqlparse.hxx" -#endif #include <connectivity/FValue.hxx> #include "OSubComponent.hxx" #include <com/sun/star/util/XCancellable.hpp> #include <cppuhelper/compbase5.hxx> +#include <comphelper/propertycontainer.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> + #include "EApi.h" + +#include <list> + namespace connectivity { namespace evoab { class OEvoabResultSet; class OEvoabConnection; - typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XStatement, - ::com::sun::star::sdbc::XWarningsSupplier, - ::com::sun::star::sdbc::XCloseable> OStatement_BASE; + typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::sdbc::XWarningsSupplier + , ::com::sun::star::sdbc::XCloseable + > OCommonStatement_IBase; + + struct FieldSort + { + sal_Int32 nField; + bool bAscending; + + FieldSort() : nField(0), bAscending( true ) { } + FieldSort( const sal_Int32 _nField, const bool _bAscending ) : nField( _nField ), bAscending( _bAscending ) { } + }; + typedef ::std::vector< FieldSort > SortDescriptor; + + enum QueryFilterType + { + eFilterAlwaysFalse, + eFilterNone, + eFilterOther + }; + + struct QueryData + { + private: + EBookQuery* pQuery; + + public: + ::rtl::OUString sTable; + QueryFilterType eFilterType; + ::vos::ORef< ::connectivity::OSQLColumns > xSelectColumns; + SortDescriptor aSortOrder; + + QueryData() + :pQuery( NULL ) + ,sTable() + ,eFilterType( eFilterOther ) + ,xSelectColumns() + ,aSortOrder() + { + } + + QueryData( const QueryData& _rhs ) + :pQuery( NULL ) + ,sTable() + ,eFilterType( eFilterType ) + ,xSelectColumns() + ,aSortOrder() + { + *this = _rhs; + } + + QueryData& operator=( const QueryData& _rhs ) + { + if ( this == &_rhs ) + return *this; + + setQuery( _rhs.pQuery ); + sTable = _rhs.sTable; + eFilterType = _rhs.eFilterType; + xSelectColumns = _rhs.xSelectColumns; + aSortOrder = _rhs.aSortOrder; + + return *this; + } + + ~QueryData() + { + setQuery( NULL ); + } + + EBookQuery* getQuery() const { return pQuery; } + + void setQuery( EBookQuery* _pQuery ) + { + if ( pQuery ) + e_book_query_unref( pQuery ); + pQuery = _pQuery; + if ( pQuery ) + e_book_query_ref( pQuery ); + } + }; //************************************************************** - //************ Class: OStatement_Base + //************ Class: OCommonStatement // is a base class for the normal statement and for the prepared statement //************************************************************** - class OStatement_Base : public comphelper::OBaseMutex, - public OStatement_BASE, - public ::cppu::OPropertySetHelper, - public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base> + class OCommonStatement; + typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase; + class OCommonStatement :public comphelper::OBaseMutex + ,public OCommonStatement_IBase + ,public ::comphelper::OPropertyContainer + ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement > + ,public OStatement_CBase { - protected: + friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >; + + private: ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created OEvoabResultSet *m_pResultSet; OEvoabConnection *m_pConnection; connectivity::OSQLParser m_aParser; connectivity::OSQLParseTreeIterator m_aSQLIterator; connectivity::OSQLParseNode *m_pParseTree; + + // <properties> + ::rtl::OUString m_aCursorName; + sal_Int32 m_nMaxFieldSize; + sal_Int32 m_nMaxRows; + sal_Int32 m_nQueryTimeOut; + sal_Int32 m_nFetchSize; + sal_Int32 m_nResultSetType; + sal_Int32 m_nFetchDirection; + sal_Int32 m_nResultSetConcurrency; + sal_Bool m_bEscapeProcessing; + // </properties> + + ::cppu::OBroadcastHelper& rBHelper; + protected: void disposeResultSet(); @@ -91,48 +188,33 @@ namespace connectivity virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - virtual sal_Bool SAL_CALL convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException); - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); - virtual void SAL_CALL getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle) const; - virtual ~OStatement_Base(); - protected: - /* Driver Internal Methods */ - OEvoabResultSet *createResultSet(); + virtual ~OCommonStatement(); + protected: void reset () throw( ::com::sun::star::sdbc::SQLException); void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); - EBookQuery *parseSql( const ::rtl::OUString& sql, ::rtl::OString &rTable, bool &bIsWithoutWhere ) - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - EBookQuery *whereAnalysis( const OSQLParseNode* parseTree ) - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + void parseSql( const ::rtl::OUString& sql, QueryData& _out_rQueryData ); + EBookQuery *whereAnalysis( const OSQLParseNode* parseTree ); + void orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort ); rtl::OUString getTableName(); EBookQuery *createTrue(); EBookQuery *createTest( const ::rtl::OUString &aColumnName, EBookQueryTest eTest, - const ::rtl::OUString &aMatch, - bool bGeneric = false ); + const ::rtl::OUString &aMatch ); public: // other methods OEvoabConnection* getOwnConnection() const { return m_pConnection;} - ::cppu::OBroadcastHelper& rBHelper; - OStatement_Base(OEvoabConnection* _pConnection ); - using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + + protected: + OCommonStatement( OEvoabConnection* _pConnection ); // OComponentHelper - virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} + virtual void SAL_CALL disposing(void); // XInterface virtual void SAL_CALL release() throw(); virtual void SAL_CALL acquire() throw(); @@ -143,46 +225,66 @@ namespace connectivity // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); - // XStatement - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + // XWarningsSupplier virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XCloseable virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - }; + protected: + /** will return the EBookQuery representing the stamement's WHERE condition, or throw - class OStatement_BASE2 : public OStatement_Base, - public ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE> + Also, all statement dependent members (such as the parser/iterator) will be inited afterwards. + */ + QueryData + impl_getEBookQuery_throw( const ::rtl::OUString& _rSql ); - { - friend class OSubComponent<OStatement_BASE2, OStatement_BASE>; - public: - OStatement_BASE2(OEvoabConnection* _pConnection ) : OStatement_Base(_pConnection ), - ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){} - // OComponentHelper - virtual void SAL_CALL disposing(void); - // XInterface - virtual void SAL_CALL release() throw(); + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + impl_executeQuery_throw( const ::rtl::OUString& _rSql ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > + impl_executeQuery_throw( const QueryData& _rData ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > + impl_getConnection() { return ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >( (::com::sun::star::sdbc::XConnection*)m_pConnection ); } + + ::rtl::OUString + impl_getColumnRefColumnName_throw( const ::connectivity::OSQLParseNode& _rColumnRef ); }; - class OStatement : public OStatement_BASE2, - public ::com::sun::star::lang::XServiceInfo + typedef ::cppu::ImplHelper2 < ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::sdbc::XStatement + > OStatement_IBase; + class OStatement :public OCommonStatement + ,public OStatement_IBase { protected: virtual ~OStatement(){} + public: - // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: - OStatement( OEvoabConnection* _pConnection) : OStatement_BASE2( _pConnection){} - DECLARE_SERVICE_INFO(); + OStatement( OEvoabConnection* _pConnection) + :OCommonStatement( _pConnection) + { + } + // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL acquire() throw(); virtual void SAL_CALL release() throw(); + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + + // XServiceInfo + DECLARE_SERVICE_INFO(); + + // XStatement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; }; } } diff --git a/connectivity/source/drivers/evoab2/makefile.mk b/connectivity/source/drivers/evoab2/makefile.mk index 3e59c8ecb442..a911bd262516 100644 --- a/connectivity/source/drivers/evoab2/makefile.mk +++ b/connectivity/source/drivers/evoab2/makefile.mk @@ -6,10 +6,6 @@ # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.8 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify @@ -42,18 +38,18 @@ dummy: .ELSE # --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/version.mk +PKGCONFIG_MODULES=gtk+-2.0 +.INCLUDE : pkg_config.mk + CFLAGS+=$(GOBJECT_CFLAGS) # --- Files ------------------------------------- -EXCEPTIONSFILES=\ +SLOFILES=\ $(SLO)$/NDriver.obj \ $(SLO)$/NTable.obj \ $(SLO)$/NColumns.obj \ @@ -66,13 +62,9 @@ EXCEPTIONSFILES=\ $(SLO)$/NServices.obj \ $(SLO)$/NResultSet.obj \ $(SLO)$/NResultSetMetaData.obj \ - $(SLO)$/EApi.obj - -SLOFILES=\ - $(EXCEPTIONSFILES) \ + $(SLO)$/EApi.obj \ $(SLO)$/NDebug.obj - SHL1VERSIONMAP=$(TARGET).map @@ -100,6 +92,15 @@ SHL1STDLIBS+= ifile.lib .ENDIF SHL1STDLIBS+=$(GOBJECT_LIBS) + +SHL1STDLIBS+=$(PKGCONFIG_LIBS:s/ -lpangoxft-1.0//) +# hack for faked SO environment +.IF "$(PKGCONFIG_ROOT)"!="" +SHL1SONAME+=-z nodefs +SHL1NOCHECK=TRUE +.ENDIF # "$(PKGCONFIG_ROOT)"!="" + + SHL1DEPN= SHL1IMPLIB= i$(TARGET) diff --git a/connectivity/source/inc/resource/evoab2_res.hrc b/connectivity/source/inc/resource/evoab2_res.hrc index 5313df877d67..b44908a55601 100644 --- a/connectivity/source/inc/resource/evoab2_res.hrc +++ b/connectivity/source/inc/resource/evoab2_res.hrc @@ -38,7 +38,8 @@ // = the calc driver's resource strings // ============================================================================ -#define STR_USE_WHERE_CRIT ( STR_EVOAB2_BASE + 0 ) +#define STR_CANNOT_OPEN_BOOK ( STR_EVOAB2_BASE + 0 ) +#define STR_SORT_BY_COL_ONLY ( STR_EVOAB2_BASE + 1 ) #endif // CONNECTIVITY_RESOURCE_CALC_HRC diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 23aba56aec44..5710d747a5f9 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -76,6 +76,7 @@ #include <algorithm> #include <functional> #include <rtl/logfile.hxx> +#include <rtl/ustrbuf.hxx> using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::util; @@ -2232,89 +2233,128 @@ void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition) } } } -#if OSL_DEBUG_LEVEL > 1 +#if OSL_DEBUG_LEVEL > 0 // ----------------------------------------------------------------------------- -void OSQLParseNode::showParseTree(::rtl::OUString& rString, sal_uInt32 nLevel) +void OSQLParseNode::showParseTree( ::rtl::OUString& rString ) const +{ + ::rtl::OUStringBuffer aBuf; + showParseTree( aBuf, 0 ); + rString = aBuf.makeStringAndClear(); +} + +// ----------------------------------------------------------------------------- +void OSQLParseNode::showParseTree( ::rtl::OUStringBuffer& _inout_rBuffer, sal_uInt32 nLevel ) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseNode::showParseTree" ); - if (!isToken()) + for ( sal_uInt32 j=0; j<nLevel; ++j) + _inout_rBuffer.appendAscii( " " ); + + if ( !isToken() ) { - for (sal_uInt32 j=0; j<nLevel; j++) {rString+= ::rtl::OUString::createFromAscii("\t");}; // Regelnamen als rule: ... - rString+= ::rtl::OUString::createFromAscii("RULE_ID:\t "); - rString += ::rtl::OUString::valueOf( (sal_Int32)getRuleID()); - rString+= ::rtl::OUString::createFromAscii("("); - rString += OSQLParser::RuleIDToStr(getRuleID()); - rString+= ::rtl::OUString::createFromAscii(")"); - rString+= ::rtl::OUString::createFromAscii("\n"); + _inout_rBuffer.appendAscii( "RULE_ID: " ); + _inout_rBuffer.append( (sal_Int32)getRuleID() ); + _inout_rBuffer.append( sal_Unicode( '(' ) ); + _inout_rBuffer.append( OSQLParser::RuleIDToStr( getRuleID() ) ); + _inout_rBuffer.append( sal_Unicode( ')' ) ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); // hol dir den ersten Subtree - for (OSQLParseNodes::const_iterator i = m_aChildren.begin(); - i != m_aChildren.end(); i++) - (*i)->showParseTree(rString, nLevel+1); + for ( OSQLParseNodes::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); + ++i + ) + (*i)->showParseTree( _inout_rBuffer, nLevel+1 ); } else { // ein Token gefunden - // tabs fuer das Einruecken entsprechend nLevel - for (sal_uInt32 j=0; j<nLevel; j++) {rString+= ::rtl::OUString::createFromAscii("\t");}; - - switch (m_eNodeType) { + switch (m_eNodeType) + { case SQL_NODE_KEYWORD: - {rString+= ::rtl::OUString::createFromAscii("SQL_KEYWORD:\t"); - ::rtl::OString sT = OSQLParser::TokenIDToStr(getTokenID()); - rString += ::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8); - rString+= ::rtl::OUString::createFromAscii("\n"); - break;} + _inout_rBuffer.appendAscii( "SQL_KEYWORD: " ); + _inout_rBuffer.append( ::rtl::OStringToOUString( OSQLParser::TokenIDToStr( getTokenID() ), RTL_TEXTENCODING_UTF8 ) ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_COMPARISON: - {rString+= ::rtl::OUString::createFromAscii("SQL_COMPARISON:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString+= ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} + _inout_rBuffer.appendAscii( "SQL_COMPARISON: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_NAME: - {rString+= ::rtl::OUString::createFromAscii("SQL_NAME:\t"); - rString+= ::rtl::OUString::createFromAscii("\""); - rString += m_aNodeValue; - rString+= ::rtl::OUString::createFromAscii("\""); - rString+= ::rtl::OUString::createFromAscii("\n"); - break;} + _inout_rBuffer.appendAscii( "SQL_NAME: " ); + _inout_rBuffer.append( sal_Unicode( '"' ) ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '"' ) ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_STRING: - {rString += ::rtl::OUString::createFromAscii("SQL_STRING:\t'"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("'\n"); - break;} + _inout_rBuffer.appendAscii( "SQL_STRING: " ); + _inout_rBuffer.append( sal_Unicode( '\'' ) ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\'' ) ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_INTNUM: - {rString += ::rtl::OUString::createFromAscii("SQL_INTNUM:\t"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("\n"); - break;} + _inout_rBuffer.appendAscii( "SQL_INTNUM: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_APPROXNUM: - {rString += ::rtl::OUString::createFromAscii("SQL_APPROXNUM:\t"); - rString += m_aNodeValue; - rString += ::rtl::OUString::createFromAscii("\n"); - break;} + _inout_rBuffer.appendAscii( "SQL_APPROXNUM: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_PUNCTUATION: - {rString += ::rtl::OUString::createFromAscii("SQL_PUNCTUATION:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString += ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} + _inout_rBuffer.appendAscii( "SQL_PUNCTUATION: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; case SQL_NODE_AMMSC: - {rString += ::rtl::OUString::createFromAscii("SQL_AMMSC:\t"); - rString += m_aNodeValue; // haenge Nodevalue an - rString += ::rtl::OUString::createFromAscii("\n"); // und beginne neu Zeile - break;} + _inout_rBuffer.appendAscii( "SQL_AMMSC: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; + + case SQL_NODE_EQUAL: + case SQL_NODE_LESS: + case SQL_NODE_GREAT: + case SQL_NODE_LESSEQ: + case SQL_NODE_GREATEQ: + case SQL_NODE_NOTEQUAL: + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; + + case SQL_NODE_ACCESS_DATE: + _inout_rBuffer.appendAscii( "SQL_ACCESS_DATE: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; + + case SQL_NODE_DATE: + _inout_rBuffer.appendAscii( "SQL_DATE: " ); + _inout_rBuffer.append( m_aNodeValue ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; + + case SQL_NODE_CONCAT: + _inout_rBuffer.appendAscii( "||" ); + _inout_rBuffer.append( sal_Unicode( '\n' ) ); + break; default: - OSL_ASSERT("OSQLParser::ShowParseTree: unzulaessiger NodeType"); + OSL_TRACE( "-- %i", int( m_eNodeType ) ); + OSL_ENSURE( false, "OSQLParser::ShowParseTree: unzulaessiger NodeType" ); } } } diff --git a/connectivity/source/resource/conn_error_message.src b/connectivity/source/resource/conn_error_message.src index 48d60d424cc5..a558cd7bea50 100644 --- a/connectivity/source/resource/conn_error_message.src +++ b/connectivity/source/resource/conn_error_message.src @@ -73,6 +73,7 @@ String 256 + 2*303 + 0 Text [ en-US ] = "The name '$1$' is already in use in the database."; }; +// DB_NOT_CONNECTED = 304 String 256 + 2*304 + 0 { Text [ en-US ] = "No connection to the database exists."; @@ -87,3 +88,15 @@ String 256 + 2*500 + 0 { Text [ en-US ] = "No $1$ exists."; }; + +// DATA_CANNOT_SELECT_UNFILTERED = 550 +String 256 + 2*550 + 0 +{ + Text [ en-US ] = "Unable to display the complete table content. Please apply a filter."; +}; + +String 256 + 2*550 + 1 +{ + Text = "IM001"; +}; + diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index a455aae269c2..c9e54b740252 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -480,9 +480,14 @@ String STR_INVALID_DBASE_FILE // Evoab2 -String STR_USE_WHERE_CRIT +String STR_CANNOT_OPEN_BOOK { - Text [ en-US ] = "Use the SQL query with \"where clause\" or \"criteria\", to get the results."; + Text [ en-US ] = "Cannot open Evolution address book."; +}; + +String STR_SORT_BY_COL_ONLY +{ + Text [ en-US ] = "Can only sort by table columns."; }; // File |