From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- connectivity/workben/iniParser/main.cxx | 160 ++++++++++++++ connectivity/workben/iniParser/makefile.mk | 52 +++++ connectivity/workben/little/main.cxx | 101 +++++++++ connectivity/workben/little/makefile.mk | 50 +++++ connectivity/workben/skeleton/SResultSet.hxx | 235 +++++++++++++++++++++ .../workben/skeleton/how_to_write_a_driver.txt | 69 ++++++ 6 files changed, 667 insertions(+) create mode 100644 connectivity/workben/iniParser/main.cxx create mode 100644 connectivity/workben/iniParser/makefile.mk create mode 100644 connectivity/workben/little/main.cxx create mode 100644 connectivity/workben/little/makefile.mk create mode 100644 connectivity/workben/skeleton/SResultSet.hxx create mode 100644 connectivity/workben/skeleton/how_to_write_a_driver.txt (limited to 'connectivity/workben') diff --git a/connectivity/workben/iniParser/main.cxx b/connectivity/workben/iniParser/main.cxx new file mode 100644 index 000000000..c4746fcee --- /dev/null +++ b/connectivity/workben/iniParser/main.cxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +#include +#include + + +struct ini_NameValue +{ + OUString sName; + OUString sValue; + + inline ini_NameValue() + {} + inline ini_NameValue( + OUString const & name, OUString const & value ) + : sName( name ), + sValue( value ) + {} +}; + +typedef std::vector< + ini_NameValue +> NameValueVector; + +struct ini_Section +{ + OUString sName; + NameValueVector vVector; +}; +typedef std::mapIniSectionMap; + + +class IniParser +{ + IniSectionMap mAllSection; +public: + IniSectionMap * getAllSection(){return &mAllSection;}; + ini_Section * getSection(OUString const & secName) + { + if (mAllSection.find(secName) != mAllSection.end()) + return &mAllSection[secName]; + return NULL; + } + explicit IniParser(OUString const & rIniName) throw(css::io::IOException ) + { + OUString curDirPth; + OUString iniUrl; + osl_getProcessWorkingDir( &curDirPth.pData ); + if (osl_getAbsoluteFileURL( curDirPth.pData, rIniName.pData, &iniUrl.pData )) + throw css::io::IOException(); + + + oslFileHandle handle=NULL; + if (iniUrl.getLength() && + osl_File_E_None == osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read)) + { + rtl::ByteSequence seq; + sal_uInt64 nSize = 0; + + osl_getFileSize(handle, &nSize); + OUString sectionName( "no name section" ); + while (true) + { + sal_uInt64 nPos; + if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize) + break; + if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq)) + break; + OString line( (const char *) seq.getConstArray(), seq.getLength() ); + sal_Int32 nIndex = line.indexOf('='); + if (nIndex >= 1) + { + ini_Section *aSection = &mAllSection[sectionName]; + struct ini_NameValue nameValue; + nameValue.sName = OStringToOUString( + line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US ); + nameValue.sValue = OStringToOUString( + line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 ); + + aSection->vVector.push_back(nameValue); + + } + else + { + sal_Int32 nIndexStart = line.indexOf('['); + sal_Int32 nIndexEnd = line.indexOf(']'); + if ( nIndexEnd > nIndexStart && nIndexStart >=0) + { + sectionName = OStringToOUString( + line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US ); + if (!sectionName.getLength()) + sectionName = "no name section"; + + ini_Section *aSection = &mAllSection[sectionName]; + aSection->sName = sectionName; + } + } + } + osl_closeFile(handle); + } +#if OSL_DEBUG_LEVEL > 1 + else + { + SAL_WARN("connectivity", "couldn't open file: " << iniUrl ); + throw css::io::IOException(); + } +#endif + } +#if OSL_DEBUG_LEVEL > 1 + void Dump() + { + for(auto& rEntry : mAllSection) + { + ini_Section *aSection = &rEntry.second; + for(const auto& rValue : aSection->vVector) + { + SAL_WARN("connectivity", + " section=" << aSection->sName << " name=" << rValue.sName << " value=" << rValue.sValue ); + + } + } + + } +#endif + +}; + +int main( int argc, char * argv[] ) +{ + + IniParser parser(OUString("test.ini")); + parser.Dump(); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/workben/iniParser/makefile.mk b/connectivity/workben/iniParser/makefile.mk new file mode 100644 index 000000000..ffca14a54 --- /dev/null +++ b/connectivity/workben/iniParser/makefile.mk @@ -0,0 +1,52 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +PRJ=..$/.. + +PRJNAME=connectivity +TARGET=iniparser +TARGETTYPE=CUI +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +OBJFILES= $(OBJ)$/main.obj + + +APPSTDLIBS=$(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(UCBHELPERLIB) \ + $(DBTOOLSLIB) \ + $(COMPHELPERLIB) + + +# ... cfgapi .............................. + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJFILES) +APP1STDLIBS = $(APPSTDLIBS) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/connectivity/workben/little/main.cxx b/connectivity/workben/little/main.cxx new file mode 100644 index 000000000..c70f463b8 --- /dev/null +++ b/connectivity/workben/little/main.cxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace connectivity; +using namespace com::sun::star::sdbc; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; +using namespace cppu; + + +void main( int argc, char * argv[] ) +{ + css::uno::Reference< css::sdbc::XConnection> m_xConnection; + css::uno::Reference< css::sdbc::XDriver> m_xDriver; + + try{ + Reference< css::lang::XMultiServiceFactory > xFac = + createRegistryServiceFactory(OUString("g:\\office50\\program\\applicat.rdb"),OUString()); + if(!xFac.is()) + return; + + m_xDriver.set(xFac->createInstance("com.sun.star.sdbc.driver.dbase.Driver"),UNO_QUERY); + if(m_xDriver.is()) + { + + Sequence aValue; + // aValue.getArray()[0] = PropertyValue( OUString("user"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE); + // aValue.getArray()[1] = PropertyValue( OUString("password"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE); + + m_xConnection = m_xDriver->connect(OUString("sdbc:dbase:g:\\"),aValue); + if(m_xConnection.is()) + { + Reference xStmt = m_xConnection->createStatement(); + if(xStmt.is()) + { + Reference xRes = xStmt->executeQuery(OUString("SELECT * FROM Tele")); + if(xRes.is()) + { + OUString aPat( "%s\t" ); + Reference xRow(xRes,UNO_QUERY); + Reference xMeta = Reference(xRes,UNO_QUERY)->getMetaData(); + for(sal_Int32 i=1;igetColumnCount();++i) + { + wprintf(aPat.getStr(), xMeta->getColumnName(i).getStr()); + } + printf("----------------------------------------------------------------------\n"); + while(xRes->next()) + { + for(sal_Int32 j=1;jgetColumnCount();++j) + wprintf(aPat.getStr(), xRow->getString(j).getStr()); + printf("\n"); + } + } + } + } + + } + } + catch(...) + { + printf("Exception thrown!\n"); + + } + sal_Int32 d; + scanf("%d",&d); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/workben/little/makefile.mk b/connectivity/workben/little/makefile.mk new file mode 100644 index 000000000..75fcccf50 --- /dev/null +++ b/connectivity/workben/little/makefile.mk @@ -0,0 +1,50 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +PRJ=..\.. + +PRJNAME=connectivity +TARGET=little +TARGETTYPE=CUI +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +OBJFILES= $(OBJ)$/main.obj + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJFILES) +APPSTDLIBS=$(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SLB)$/sql.lib + + +# ... cfgapi .............................. +APP1STDLIBS = $(APPSTDLIBS) + +APP1STDLIBS+=$(STDLIBCPP) + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/connectivity/workben/skeleton/SResultSet.hxx b/connectivity/workben/skeleton/SResultSet.hxx new file mode 100644 index 000000000..514aec2df --- /dev/null +++ b/connectivity/workben/skeleton/SResultSet.hxx @@ -0,0 +1,235 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SStatement.hxx" +#include +#include + +namespace connectivity::skeleton + { + + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, + css::sdbc::XRow, + css::sdbc::XResultSetMetaDataSupplier, + css::util::XCancellable, + css::sdbc::XWarningsSupplier, + css::sdbc::XResultSetUpdate, + css::sdbc::XRowUpdate, + css::sdbcx::XRowLocate, + css::sdbcx::XDeleteRows, + css::sdbc::XCloseable, + css::sdbc::XColumnLocate, + css::lang::XServiceInfo> OResultSet_BASE; + + + typedef sal_Int64 TVoidPtr; + typedef std::allocator< TVoidPtr > TVoidAlloc; + typedef std::vector TVoidVector; + + class OResultSet : public cppu::BaseMutex, + public OResultSet_BASE, + public ::cppu::OPropertySetHelper, + public ::comphelper::OPropertyArrayUsageHelper + { + protected: + TVoidVector m_aBindVector; + std::vector m_aLengthVector; + std::vector m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time + std::vector< ORowSetValue> m_aRow; // only used when SQLGetData can't be called in any order + OStatement_Base* m_pStatement; + css::uno::WeakReferenceHelper m_aStatement; + css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData; + rtl_TextEncoding m_nTextEncoding; + sal_Int32 m_nRowPos; + sal_Int32 m_nLastColumnPos; // used for m_aRow just to know where we are + sal_Bool m_bWasNull; + sal_Bool m_bBOF; // before first record + sal_Bool m_bEOF; // after last record + sal_Bool m_bLastRecord; + sal_Bool m_bFreeHandle; + sal_Bool m_bInserting; + sal_Bool m_bFetchData; // true when SQLGetaData can be called in any order or when fetching data for m_aRow + + sal_Bool isBookmarkable() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + sal_Int32 getResultSetConcurrency() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + sal_Int32 getResultSetType() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + sal_Int32 getFetchDirection() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + sal_Int32 getFetchSize() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + OUString getCursorName() const throw(css::sdbc::SQLException, css::uno::RuntimeException); + + void setFetchDirection(sal_Int32 _par0) throw(css::sdbc::SQLException, css::uno::RuntimeException); + void setFetchSize(sal_Int32 _par0) throw(css::sdbc::SQLException, css::uno::RuntimeException); + + + void fillRow(sal_Int32 _nToColumn); + void allocBuffer(sal_Bool _bAllocRow); + void releaseBuffer(); + + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) + throw (css::lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) + throw (css::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, + sal_Int32 nHandle + ) const; + + // you can't delete objects of this type + virtual ~OResultSet(); + public: + DECLARE_SERVICE_INFO(); + + OResultSet( OStatement_Base* pStmt); + + + css::uno::Reference< css::uno::XInterface > operator *() + { + return css::uno::Reference< css::uno::XInterface >(*(OResultSet_BASE*)this); + } + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing(); + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(css::uno::RuntimeException); + virtual void SAL_CALL acquire() throw(css::uno::RuntimeException); + virtual void SAL_CALL release() throw(css::uno::RuntimeException); + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) throw(css::uno::RuntimeException); + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(css::uno::RuntimeException); + // XResultSet + virtual sal_Bool SAL_CALL next( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAfterLast( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isFirst( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL isLast( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL beforeFirst( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL afterLast( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL first( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL last( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL previous( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL refreshRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowUpdated( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowInserted( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL rowDeleted( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XRow + virtual sal_Bool SAL_CALL wasNull( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XResultSetMetaDataSupplier + virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XCancellable + virtual void SAL_CALL cancel( ) throw(css::uno::RuntimeException); + // XCloseable + virtual void SAL_CALL close( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XWarningsSupplier + virtual css::uno::Any SAL_CALL getWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL clearWarnings( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL deleteRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL cancelRowUpdates( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL moveToInsertRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL moveToCurrentRow( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 >& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const css::util::Date& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const css::util::Time& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const css::uno::Any& x ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const css::uno::Any& x, sal_Int32 scale ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XRowLocate + virtual css::uno::Any SAL_CALL getBookmark( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveToBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL moveRelativeToBookmark( const css::uno::Any& bookmark, sal_Int32 rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL compareBookmarks( const css::uno::Any& first, const css::uno::Any& second ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL hashBookmark( const css::uno::Any& bookmark ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + // XDeleteRows + virtual css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const css::uno::Sequence< css::uno::Any >& rows ) throw(css::sdbc::SQLException, css::uno::RuntimeException); + }; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/workben/skeleton/how_to_write_a_driver.txt b/connectivity/workben/skeleton/how_to_write_a_driver.txt new file mode 100644 index 000000000..e336f3664 --- /dev/null +++ b/connectivity/workben/skeleton/how_to_write_a_driver.txt @@ -0,0 +1,69 @@ +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This file incorporates work covered by the following license notice: +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to you under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.apache.org/licenses/LICENSE-2.0 . +# + +How to write my own sdbc driver + +all example files can be found in connectivity/workben/skeleton + +Pre implementation steps +- copy all files from connectivity/workben/skeleton into your new created directory under + connectivity/source/drivers and rename the first char of the files to one which isn't used so far + ( please have a look at the other drivers ) +- search all occurrences of skeleton and replace them to a name which you prefer + +1. Implement a class called driver or modify the existing skeleton -> have a look at SDriver.?xx +2. Implement a class called connection -> have a look at SConnection.?xx +3. Have a look at the DatabaseMetaData -> see SDatabaseMetaData.cxx + The methods which should be implemented at least are + - getTableTypes + - getTables + - getTypeInfo + - getColumns + +4. You need a statement to show/access some data -> have a look at SStatement.cxx + -> especially executeQuery() + +5. The ResultSet: without you see nothing -> look at SResultSet.cxx +6. The ResultSetMetaData needed to get some information about what are waiting for us + -> look at SResultSetMetaData.cxx + +7. The prepared statement is the last class we have to implement now + -> you have to allow statements like "SELECT * FROM table WHERE id = ?" + + +8. insert entry in version.mk +# ----------------------------SKELETON settings-----------------------------------# +# target +SKELETON_TARGET=skeleton + +# the major +SKELETON_MAJOR=2 +# the minor +SKELETON_MINOR=0 +# the micro +SKELETON_MICRO=0 + +# this is a c++ compatible library +SKELETON_CPP=1 + +SKELETON=$(SKELETON_TARGET_TARGET)_$(CMPEXT) + + +9. copy dll to program dir of office and register the dll + +10. congratulations you have now implement your own driver :-) -- cgit v1.2.3