diff options
Diffstat (limited to 'dbaccess/source')
22 files changed, 269 insertions, 169 deletions
diff --git a/dbaccess/source/core/api/BookmarkSet.cxx b/dbaccess/source/core/api/BookmarkSet.cxx index 63d287df08bd..127ee83aaf2c 100644 --- a/dbaccess/source/core/api/BookmarkSet.cxx +++ b/dbaccess/source/core/api/BookmarkSet.cxx @@ -270,7 +270,10 @@ void OBookmarkSet::updateColumn(sal_Int32 nPos,Reference< XRowUpdate > _xParamet case DataType::LONGVARBINARY: _xParameter->updateBytes(nPos,_rValue); break; - + case DataType::BLOB: + case DataType::CLOB: + _xParameter->updateObject(nPos,_rValue.getAny()); + break; } } } diff --git a/dbaccess/source/core/api/CacheSet.cxx b/dbaccess/source/core/api/CacheSet.cxx index bbb080a52238..f7be322caa1a 100644 --- a/dbaccess/source/core/api/CacheSet.cxx +++ b/dbaccess/source/core/api/CacheSet.cxx @@ -515,88 +515,7 @@ void OCacheSet::setParameter(sal_Int32 nPos { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" ); sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind(); - if(!_rValue.isNull()) - { - - switch(nType) - { - case DataType::DECIMAL: - case DataType::NUMERIC: - _xParameter->setObjectWithInfo(nPos,_rValue.makeAny(),nType,_nScale); - break; - case DataType::CHAR: - case DataType::VARCHAR: - case DataType::LONGVARCHAR: - _xParameter->setString(nPos,_rValue); - break; - case DataType::BIGINT: - if ( _rValue.isSigned() ) - _xParameter->setLong(nPos,_rValue); - else - _xParameter->setString(nPos,_rValue); - break; - case DataType::BIT: - case DataType::BOOLEAN: - _xParameter->setBoolean(nPos,_rValue); - break; - case DataType::TINYINT: - if ( _rValue.isSigned() ) - _xParameter->setByte(nPos,_rValue); - else - _xParameter->setShort(nPos,_rValue); - break; - case DataType::SMALLINT: - if ( _rValue.isSigned() ) - _xParameter->setShort(nPos,_rValue); - else - _xParameter->setInt(nPos,_rValue); - break; - case DataType::INTEGER: - if ( _rValue.isSigned() ) - _xParameter->setInt(nPos,_rValue); - else - _xParameter->setLong(nPos,_rValue); - break; - case DataType::FLOAT: - _xParameter->setFloat(nPos,_rValue); - break; - case DataType::DOUBLE: - case DataType::REAL: - _xParameter->setDouble(nPos,_rValue); - break; - case DataType::DATE: - _xParameter->setDate(nPos,_rValue); - break; - case DataType::TIME: - _xParameter->setTime(nPos,_rValue); - break; - case DataType::TIMESTAMP: - _xParameter->setTimestamp(nPos,_rValue); - break; - case DataType::BINARY: - case DataType::VARBINARY: - case DataType::LONGVARBINARY: - _xParameter->setBytes(nPos,_rValue); - break; - case DataType::CLOB: - { - Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY); - _xParameter->setCharacterStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0)); - } - break; - case DataType::BLOB: - { - Reference<XInputStream> xStream(_rValue.getAny(),UNO_QUERY); - _xParameter->setBinaryStream(nPos,xStream,xStream.is() ? xStream->available() : sal_Int32(0)); - } - break; - case DataType::SQLNULL: - _xParameter->setNull(nPos,nType); - break; - } - } - else - _xParameter->setNull(nPos,nType); + ::dbtools::setObjectWithInfo(_xParameter,nPos,_rValue,nType,_nScale); } // ------------------------------------------------------------------------- void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition) diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 9cc2c6172cf4..845c392bc146 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -211,8 +211,33 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) Reference<XColumnsSupplier> xSup(m_xComposer,UNO_QUERY); Reference<XNameAccess> xSourceColumns = m_xTable->getColumns(); - ::dbaccess::getColumnPositions(xSup->getColumns(),xKeyColumns,m_sUpdateTableName,(*m_pKeyColumnNames)); - ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns,m_sUpdateTableName,(*m_pColumnNames)); + ::rtl::OUString sCatalog,sSchema,sTable; + + Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); + Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME); + aCatalog >>= sCatalog; + xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + + ::std::vector< ::rtl::OUString> aBestRowColumnNames; + Reference<XResultSet> xBestRes(xMeta->getBestRowIdentifier(aCatalog,sSchema,sTable,0,sal_False)); + Reference<XRow> xBestRow(xBestRes,uno::UNO_QUERY); + while ( xBestRes->next() ) + { + aBestRowColumnNames.push_back(xBestRow->getString(2)); + } + + Sequence< ::rtl::OUString> aBestColumnNames; + if ( aBestRowColumnNames.empty() ) + { + if ( xKeyColumns.is() ) + aBestColumnNames = xKeyColumns->getElementNames(); + } + else + aBestColumnNames = Sequence< ::rtl::OUString>(&aBestRowColumnNames[0],aBestRowColumnNames.size()); + + ::dbaccess::getColumnPositions(xSup->getColumns(),aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames)); + ::dbaccess::getColumnPositions(xSup->getColumns(),xSourceColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames)); SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin(); SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); @@ -235,16 +260,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); - ::rtl::OUString aQuote = getIdentifierQuoteString(); - - ::rtl::OUStringBuffer aFilter; - ::rtl::OUString sCatalog,sSchema,sTable; - - Reference<XPropertySet> xTableProp(m_xTable,UNO_QUERY); - xTableProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; - xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; - + const ::rtl::OUString aQuote = getIdentifierQuoteString(); m_aSelectComposedTableName = getComposedTableName(sCatalog,sSchema,sTable); ::rtl::OUString sComposedName; @@ -252,6 +268,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::dbtools::qualifiedNameComponents(xMetaData,m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); sComposedName = ::dbtools::composeTableName( xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation ); + ::rtl::OUStringBuffer aFilter; static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // create the where clause @@ -286,21 +303,20 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet) ::rtl::OUString sSelectTableName = ::dbtools::composeTableName( xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false ); Reference<XNameAccess > xSelectColumns = xSup->getColumns(); - ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns(),sSelectTableName,(*m_pForeignColumnNames)); + ::dbaccess::getColumnPositions(xSelectColumns,xSelColSup->getColumns()->getElementNames(),sSelectTableName,(*m_pForeignColumnNames)); - uno::Sequence< ::rtl::OUString> aSelectColumnNames = xSelectColumns->getElementNames(); - const ::rtl::OUString* pSelectColumnName = aSelectColumnNames.getConstArray(); - const ::rtl::OUString* pSelectColumnEnd = pSelectColumnName + aSelectColumnNames.getLength(); - for( ; pSelectColumnName != pSelectColumnEnd ; ++pSelectColumnName) + aPosEnd = (*m_pForeignColumnNames).end(); + for(aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter) { // look for columns not in the source columns to use them as filter as well - if ( !xSourceColumns->hasByName(*pSelectColumnName) ) + // if ( !xSourceColumns->hasByName(aPosIter->first) ) { + if ( aFilter.getLength() ) + aFilter.append(aAnd); + aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName)); aFilter.append(s_sDot); - aFilter.append(::dbtools::quoteName( aQuote,*pSelectColumnName)); + aFilter.append(::dbtools::quoteName( aQuote,aPosIter->first)); aFilter.append(s_sParam); - if ( (pSelectColumnName+1) != pSelectColumnEnd ) - aFilter.append(aAnd); } } break; @@ -499,7 +515,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); for(;aIter != aEnd;++aIter,++i) { - if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + //if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) { sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rOrginalRow->get())[aIter->second.nPosition].isNull()) @@ -594,7 +611,8 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); j = 0; - for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j) + aIter = m_pColumnNames->begin(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++j,++aIter) { setParameter(i,xParameter,(_rOrginalRow->get())[*aIdxColIter],(_rOrginalRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -826,7 +844,7 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit sal_Int32 i = 1; for(i = 1;aIter != aEnd;++aIter,++i) { - if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) + if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) { aSql.append(::dbtools::quoteName( aQuote,aIter->first)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) @@ -879,7 +897,8 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit // now we have to set the index values ::std::vector<sal_Int32>::iterator aIdxColIter = aIndexColumnPositions.begin(); ::std::vector<sal_Int32>::iterator aIdxColEnd = aIndexColumnPositions.end(); - for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i) + aIter = m_pColumnNames->begin(); + for(;aIdxColIter != aIdxColEnd;++aIdxColIter,++i,++aIter) { setParameter(i,xParameter,(_rDeleteRow->get())[*aIdxColIter],(_rDeleteRow->get())[*aIdxColIter].getTypeKind(),aIter->second.nScale); } @@ -1394,7 +1413,7 @@ sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) namespace dbaccess { void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, - const Reference<XNameAccess>& _rxColumns, + const Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, SelectColumnsMetaData& _rColumnNames) { @@ -1403,9 +1422,8 @@ namespace dbaccess const ::rtl::OUString* pSelBegin = aSelNames.getConstArray(); const ::rtl::OUString* pSelEnd = pSelBegin + aSelNames.getLength(); - Sequence< ::rtl::OUString> aColumnNames(_rxColumns->getElementNames()); - const ::rtl::OUString* pColumnIter = aColumnNames.getConstArray(); - const ::rtl::OUString* pColumnEnd = pColumnIter + aColumnNames.getLength(); + const ::rtl::OUString* pColumnIter = _aColumnNames.getConstArray(); + const ::rtl::OUString* pColumnEnd = pColumnIter + _aColumnNames.getLength(); ::comphelper::UStringMixLess aTmp(_rColumnNames.key_comp()); ::comphelper::UStringMixEqual bCase(static_cast< ::comphelper::UStringMixLess*>(&aTmp)->isCaseSensitive()); @@ -1439,7 +1457,7 @@ namespace dbaccess break; } } - pColumnIter = aColumnNames.getConstArray(); + pColumnIter = _aColumnNames.getConstArray(); } } } diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index 4193f60506d1..7a213d05b466 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -83,7 +83,7 @@ namespace dbaccess // the elements of _rxQueryColumns must have the properties PROPERTY_REALNAME and PROPERTY_TABLENAME void getColumnPositions(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxQueryColumns, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns, + const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aColumnNames, const ::rtl::OUString& _rsUpdateTableName, SelectColumnsMetaData& _rColumnNames /* out */); diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 8f84d073f83e..1a53f504a7b6 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -2838,7 +2838,8 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo m_aDataColumns.push_back(pColumn); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN)); - sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)); + sal_Int32 nFormatKey = 0; + xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey; if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is()) nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index a96de4b9fbe1..7dba4cd17cb3 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -168,6 +168,16 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference< XIndexAccess> xUpdateTableKeys; ::rtl::OUString aUpdateTableName = _rUpdateTableName; Reference< XConnection> xConnection; + // first we need a connection + Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY); + if(xStmt.is()) + xConnection = xStmt->getConnection(); + else + { + Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY); + xConnection = xPrepStmt->getConnection(); + } + OSL_ENSURE(xConnection.is(),"No connection!"); if(_xAnalyzer.is()) { try @@ -215,16 +225,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if(xColumnsSupplier.is()) { - // first we need a connection - Reference< XStatement> xStmt(_xRs->getStatement(),UNO_QUERY); - if(xStmt.is()) - xConnection = xStmt->getConnection(); - else - { - Reference< XPreparedStatement> xPrepStmt(_xRs->getStatement(),UNO_QUERY); - xConnection = xPrepStmt->getConnection(); - } - OSL_ENSURE(xConnection.is(),"No connection!"); + Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns(); Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY); @@ -233,7 +234,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference<XNameAccess> xSelColumns = xColSup->getColumns(); Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData(); SelectColumnsMetaData aColumnNames(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() ? true : false); - ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames); + ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames); bAllKeysFound = !aColumnNames.empty() && sal_Int32(aColumnNames.size()) == xColumns->getElementNames().getLength(); } } @@ -303,7 +304,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, Reference<XColumnsSupplier> xColSup(_xAnalyzer,UNO_QUERY); Reference<XNameAccess> xSelColumns = xColSup->getColumns(); Reference<XNameAccess> xColumns = m_aUpdateTable->getColumns(); - ::dbaccess::getColumnPositions(xSelColumns,xColumns,aUpdateTableName,aColumnNames); + ::dbaccess::getColumnPositions(xSelColumns,xColumns->getElementNames(),aUpdateTableName,aColumnNames); // check privileges m_nPrivileges = Privilege::SELECT; diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index c8a8f9ba01d1..0c2836d5ceec 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1530,6 +1530,27 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert aSQL.append( STR_LIKE ); aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); break; + case DataType::CLOB: + { + Reference< XClob > xClob(aValue,UNO_QUERY); + if ( xClob.is() ) + { + const ::sal_Int64 nLength = xClob->length(); + if ( sal_Int64(nLength + aSQL.getLength() + STR_LIKE.getLength() ) < sal_Int64(SAL_MAX_INT32) ) + { + aSQL.append( STR_LIKE ); + aSQL.appendAscii("'"); + aSQL.append( xClob->getSubString(1,(sal_Int32)nLength) ); + aSQL.appendAscii("'"); + } + } + else + { + aSQL.append( STR_LIKE ); + aSQL.append( DBTypeConversion::toSQLString( nType, aValue, sal_True, m_xTypeConverter ) ); + } + } + break; case DataType::VARBINARY: case DataType::BINARY: case DataType::LONGVARBINARY: diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 1ca1a737dfd2..d75411cb7997 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -985,13 +985,13 @@ void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu) rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT)); rMenu.InsertSeparator(nPos++); } // if (!IsReadOnlyDB()) -
- if ( GetSelectRowCount() > 0 )
- {
- rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++);
- rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY));
-
- rMenu.InsertSeparator(nPos++);
+ + if ( GetSelectRowCount() > 0 ) + { + rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++); + rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY)); + + rMenu.InsertSeparator(nPos++); } } @@ -1428,20 +1428,20 @@ void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos) } // ----------------------------------------------------------------------- -void SbaGridControl::CopySelectedRowsToClipboard()
-{
- DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" );
- implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
-{
- implTransferSelectedRows( nRowPos, false );
-}
-
-// -----------------------------------------------------------------------
-void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
+void SbaGridControl::CopySelectedRowsToClipboard() +{ + DBG_ASSERT( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" ); + implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true ); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::DoRowDrag( sal_Int16 nRowPos ) +{ + implTransferSelectedRows( nRowPos, false ); +} + +// ----------------------------------------------------------------------- +void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag ) { Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY); DBG_ASSERT(xDataSource.is(), "SbaGridControl::implTransferSelectedRows : invalid data source !"); @@ -1478,8 +1478,8 @@ void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfC ODataClipboard* pTransfer = new ODataClipboard(xDataSource, aSelectedRows,xRowSetClone, getServiceManager()); Reference< XTransferable > xEnsureDelete = pTransfer; - if ( _bTrueIfClipboardFalseIfDrag )
- pTransfer->CopyToClipboard( this );
+ if ( _bTrueIfClipboardFalseIfDrag ) + pTransfer->CopyToClipboard( this ); else pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK); } diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index d186dbb702c2..2a930f7fe573 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -634,6 +634,7 @@ sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun:: break; case DataType::LONGVARCHAR: + case DataType::CLOB: aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), makeAny( (sal_Bool)sal_True ) ) ); // NO break! case DataType::BINARY: diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 8c7f94a2ac39..e0f4e0de7666 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -1375,6 +1375,14 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) ActivateAggregate( tpFormat ); break; case DataType::BIT: + if ( pFieldType->aCreateParams.getLength() ) + { + DeactivateAggregate( tpFormat ); + DeactivateAggregate( tpTextLen ); + DeactivateAggregate( tpBoolDefault ); + break; + } + // run through case DataType::BOOLEAN: DeactivateAggregate( tpTextLen ); DeactivateAggregate( tpFormat ); @@ -1473,7 +1481,9 @@ void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) if( pBoolDefault ) { // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen - String sDef = BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault())); + ::rtl::OUString sValue; + pFieldDescr->GetControlDefault() >>= sValue; + String sDef = BoolStringUI(sValue); // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() ) diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx index b44daeba3beb..ee5a5235da68 100644 --- a/dbaccess/source/ui/inc/TypeInfo.hxx +++ b/dbaccess/source/ui/inc/TypeInfo.hxx @@ -83,6 +83,7 @@ const sal_uInt16 TYPE_BLOB = 27; const sal_uInt16 TYPE_CLOB = 28; const sal_uInt16 TYPE_REF = 29; const sal_uInt16 TYPE_OTHER = 30; +const sal_uInt16 TYPE_BIT = 31; class OTypeInfo { diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index 53b1105c6aba..2c679ba22da8 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -237,6 +237,12 @@ sal_Bool ORowSetImportExport::insertNewRow() case DataType::VARBINARY: aValue <<= m_xRow->getBytes(*aIter); break; + case DataType::BLOB: + aValue <<= m_xRow->getBlob(*aIter); + break; + case DataType::CLOB: + aValue <<= m_xRow->getClob(*aIter); + break; default: OSL_ENSURE(0,"Unknown type"); } diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 25a6299bae12..8d97d4829173 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -803,6 +803,12 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCo aName = _rsTypeNames.GetToken(TYPE_DATETIME); break; case DataType::BIT: + if ( pInfo->aCreateParams.getLength() ) + { + aName = _rsTypeNames.GetToken(TYPE_BIT); + break; + } + // run through case DataType::BOOLEAN: aName = _rsTypeNames.GetToken(TYPE_BOOL); break; @@ -1155,7 +1161,7 @@ sal_Bool callColumnFormatDialog(Window* _pParent, if (_bHasFormat) { // if the col is bound to a text field we have to disallow all non-text formats - if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType)) + if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType)) { bText = sal_True; pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True)); @@ -1622,6 +1628,10 @@ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rType if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) ) break; break; + case DataType::LONGVARCHAR: + if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) ) + break; + break; default: ; } // switch(_nDataType) diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 82fa7b7ec2bf..2b664c02f7e2 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -633,6 +633,22 @@ OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rD if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) ) bAllowViews = false; + if ( m_bInterConnectionCopy ) + { + Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData(); + ::rtl::OUString sCatalog; + ::rtl::OUString sSchema; + ::rtl::OUString sTable; + ::dbtools::qualifiedNameComponents( xSrcMeta, + m_sName, + sCatalog, + sSchema, + sTable, + ::dbtools::eInDataManipulation); + + m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,sal_False,::dbtools::eInTableDefinitions); + } + OCopyTable* pPage1( new OCopyTable( this ) ); pPage1->disallowUseHeaderLine(); if ( !bAllowViews ) @@ -1581,6 +1597,10 @@ TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool& if ( supportsType(DataType::LONGVARCHAR,nDefaultType) ) break; break; + case DataType::LONGVARCHAR: + if ( supportsType(DataType::CLOB,nDefaultType) ) + break; + break; default: nDefaultType = DataType::VARCHAR; } diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index e489a0c2a585..f7f08cd63df5 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -369,6 +369,7 @@ namespace case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: rNewValue = ::dbtools::quoteName(aQuote,rValue); break; case DataType::DECIMAL: @@ -382,6 +383,7 @@ namespace case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: rNewValue = rValue; break; case DataType::BIT: @@ -1385,6 +1387,9 @@ namespace // first extract the inner joins conditions GetInnerJoinCriteria(_pView,pNodeTmp); + // now simplify again, join are checked in ComparisonPredicate + ::connectivity::OSQLParseNode::absorptions(pNodeTmp); + pNodeTmp = pNode->getChild(1); // it could happen that pCondition is not more valid eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pNodeTmp, rLevel); @@ -1395,7 +1400,7 @@ namespace SqlParseError GetANDCriteria( OQueryDesignView* _pView, OSelectionBrowseBox* _pSelectionBrw, const ::connectivity::OSQLParseNode * pCondition, - const sal_uInt16 nLevel, + sal_uInt16& nLevel, sal_Bool bHaving, bool bAddOrOnOneLine); //------------------------------------------------------------------------------ @@ -1432,7 +1437,11 @@ namespace if ( SQL_ISRULE(pChild,search_condition) ) eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine); else - eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, bAddOrOnOneLine ? nLevel : nLevel++,bHaving, i == 0 ? false : bAddOrOnOneLine); + { + eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, nLevel,bHaving, i == 0 ? false : bAddOrOnOneLine); + if ( !bAddOrOnOneLine) + nLevel++; + } } } else @@ -1466,7 +1475,7 @@ namespace SqlParseError GetANDCriteria( OQueryDesignView* _pView, OSelectionBrowseBox* _pSelectionBrw, const ::connectivity::OSQLParseNode * pCondition, - const sal_uInt16 nLevel, + sal_uInt16& nLevel, sal_Bool bHaving, bool bAddOrOnOneLine) { @@ -1480,10 +1489,18 @@ namespace // Runde Klammern if (SQL_ISRULE(pCondition,boolean_primary)) { - sal_uInt16 nLevel2 = nLevel; // check if we have to put the or criteria on one line. - bool bMustAddOrOnOneLine = CheckOrCriteria(pCondition->getChild(1),NULL); - eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1), nLevel2,bHaving,bMustAddOrOnOneLine ); + const ::connectivity::OSQLParseNode* pSearchCondition = pCondition->getChild(1); + bool bMustAddOrOnOneLine = CheckOrCriteria(pSearchCondition,NULL); + if ( SQL_ISRULE( pSearchCondition, search_condition) ) // we have a or + { + _pSelectionBrw->DuplicateConditionLevel( nLevel); + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(0), nLevel,bHaving,bMustAddOrOnOneLine ); + ++nLevel; + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(2), nLevel,bHaving,bMustAddOrOnOneLine ); + } + else + eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition, nLevel,bHaving,bMustAddOrOnOneLine ); } // Das erste Element ist (wieder) eine AND-Verknuepfung else if ( SQL_ISRULE(pCondition,boolean_term) ) @@ -1579,10 +1596,32 @@ namespace _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine); } } + else + { + // Funktions-Bedingung parsen + ::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1); + Reference< XConnection> xConnection = rController.getConnection(); + Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + // the international doesn't matter I have a string + ::rtl::OUString sName; + pCondition->getChild(0)->parseNodeToPredicateStr(sName, + xConnection, + rController.getNumberFormatter(), + aLocale, + static_cast<sal_Char>(sDecimal.toChar()), + &rController.getParser().getContext()); + + OTableFieldDescRef aDragLeft = new OTableFieldDesc(); + aDragLeft->SetField(sName); + aDragLeft->SetFunctionType(FKT_OTHER); + + if ( bHaving ) + aDragLeft->SetGroupBy(sal_True); + _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine); + } } else if( SQL_ISRULEOR2(pCondition,existence_test,unique_test) ) { - // Funktions-Bedingung parsen ::rtl::OUString aCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,0); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 6b48bc528776..27ad175c071c 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -1207,6 +1207,7 @@ sal_Bool OSelectionBrowseBox::SaveModified() case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: if(aText.GetChar(0) != '\'' || aText.GetChar(aText.Len() -1) != '\'') { aText.SearchAndReplaceAll(String::CreateFromAscii("'"),String::CreateFromAscii("''")); @@ -1836,6 +1837,32 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt } } //------------------------------------------------------------------------------ +void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel) +{ + DBG_CHKTHIS(OSelectionBrowseBox,NULL); + const sal_uInt16 nNewLevel = nLevel +1; + OTableFields& rFields = getFields(); + OTableFields::iterator aIter = rFields.begin(); + OTableFields::iterator aEnd = rFields.end(); + for(;aIter != aEnd;++aIter) + { + OTableFieldDescRef pEntry = *aIter; + + ::rtl::OUString sValue = pEntry->GetCriteria(nLevel); + if ( sValue.getLength() ) + { + pEntry->SetCriteria( nNewLevel, sValue); + if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) ) + { + RowInserted( GetRowCount()-1, 1, TRUE ); + m_bVisibleRow.push_back(sal_True); + ++m_nVisibleCount; + } + m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True; + } // if (!pEntry->GetCriteria(nLevel).getLength() ) + } // for(;aIter != getFields().end();++aIter) +} +//------------------------------------------------------------------------------ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const String& rValue, const sal_uInt16 nLevel,bool _bAddOrOnOneLine ) { Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection(); diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx index 1d4a188dab9d..c92ce7caf7f0 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx @@ -132,6 +132,7 @@ namespace dbaui const String& rValue, const sal_uInt16 nLevel, bool _bAddOrOnOneLine ); + void DuplicateConditionLevel( const sal_uInt16 nLevel); void AddOrder(const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos); void ClearAll(); OTableFieldDescRef AppendNewCol( sal_uInt16 nCnt=1 ); diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx index 2f3a70890e92..785e29bb9a0c 100644 --- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx +++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx @@ -229,16 +229,17 @@ namespace dbaui Reference < XFrame > xBeamerFrame( m_pViewSwitch->getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")),UNO_QUERY ); m_xBeamer.set( xBeamerFrame ); + OSL_ENSURE(m_xBeamer.is(),"No frame created!"); + m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) ); // notify layout manager to not create internal toolbars Reference < XPropertySet > xPropSet( xBeamerFrame, UNO_QUERY ); try { const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )); - Reference < XPropertySet > xLMPropSet; + Reference < XPropertySet > xLMPropSet(xPropSet->getPropertyValue( aLayoutManager ),UNO_QUERY); - Any a = xPropSet->getPropertyValue( aLayoutManager ); - if ( a >>= xLMPropSet ) + if ( xLMPropSet.is() ) { const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" )); xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False )); @@ -248,8 +249,6 @@ namespace dbaui { } - OSL_ENSURE(m_xBeamer.is(),"No frame created!"); - m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) ); m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW); // append our frame diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 699a2db8404b..6e90ebed7e88 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -239,8 +239,19 @@ void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bF if ( bForce ) { sal_Int32 nPrec = DEFAULT_OTHER_PRECSION; - if ( GetPrecision() ) - nPrec = GetPrecision(); + switch ( _pType->nType ) + { + case DataType::BIT: + case DataType::BLOB: + case DataType::CLOB: + nPrec = _pType->nPrecision; + break; + default: + if ( GetPrecision() ) + nPrec = GetPrecision(); + break; + } + if ( _pType->nPrecision ) SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision)); if ( _pType->nMaximumScale ) diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 98f57b61fbdc..1eed02543cda 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -1390,7 +1390,7 @@ void OTableController::alterColumns() bNeedAppendKey = sal_True; } - if ( bNeedDropKey ) + if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() ) dropPrimaryKey(); if ( bNeedAppendKey ) diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index af911ec85c07..9fa0b0743ef4 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -56,7 +56,7 @@ String STR_TABLEDESIGN_DBFIELDTYPES { - Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER"; + Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)"; }; String STR_TABLEDESIGN_UNDO_PRIMKEY diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx index 26f859cf2045..ce79281f0cac 100644 --- a/dbaccess/source/ui/uno/copytablewizard.cxx +++ b/dbaccess/source/ui/uno/copytablewizard.cxx @@ -58,6 +58,8 @@ #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> #include <com/sun/star/sdbc/XParameters.hpp> #include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XBlob.hpp> +#include <com/sun/star/sdbc/XClob.hpp> #include <com/sun/star/sdbcx/XRowLocate.hpp> #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/sdb/SQLContext.hpp> @@ -127,6 +129,8 @@ namespace dbaui using ::com::sun::star::sdbc::XParameters; using ::com::sun::star::sdbc::XResultSet; using ::com::sun::star::sdbc::XRow; + using ::com::sun::star::sdbc::XBlob; + using ::com::sun::star::sdbc::XClob; using ::com::sun::star::sdbcx::XRowLocate; using ::com::sun::star::sdbc::XResultSetMetaDataSupplier; using ::com::sun::star::sdbc::XResultSetMetaData; @@ -1281,6 +1285,7 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: + case DataType::BIT: aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes ); break; @@ -1296,7 +1301,6 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou aTransfer.transferComplexValue( &XRow::getTimestamp, &XParameters::setTimestamp ); break; - case DataType::BIT: case DataType::BOOLEAN: aTransfer.transferValue( &XRow::getBoolean, &XParameters::setBoolean ); break; @@ -1313,6 +1317,14 @@ void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSou aTransfer.transferValue( &XRow::getInt, &XParameters::setInt ); break; + case DataType::BLOB: + aTransfer.transferComplexValue( &XRow::getBlob, &XParameters::setBlob ); + break; + + case DataType::CLOB: + aTransfer.transferComplexValue( &XRow::getClob, &XParameters::setClob ); + break; + default: { ::rtl::OUString aMessage( String( ModuleRes( STR_CTW_UNSUPPORTED_COLUMN_TYPE ) ) ); |