diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-06-28 13:22:47 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-06-28 13:22:47 +0000 |
commit | d7b87b4a40a20d2d1a542518febe44dc9809b275 (patch) | |
tree | 3992ca0cc7c76350466b6d52f18ca59ba5274829 /dbaccess/source/ui/querydesign/QTableWindow.cxx | |
parent | 991d81d82d5033b22216d34220ded506b4d134ca (diff) |
#88787# assure that the noone access objects that could already be disposed
Diffstat (limited to 'dbaccess/source/ui/querydesign/QTableWindow.cxx')
-rw-r--r-- | dbaccess/source/ui/querydesign/QTableWindow.cxx | 105 |
1 files changed, 58 insertions, 47 deletions
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx index a7fef90b91c9..32c3cf95a825 100644 --- a/dbaccess/source/ui/querydesign/QTableWindow.cxx +++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableWindow.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: fs $ $Date: 2001-03-15 08:26:26 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:22:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -248,12 +248,16 @@ sal_Bool OQueryTableWindow::FillListBox() { Reference<XPropertySet> xProp; ::cppu::extractInterface(xProp,xKeyIndex->getByIndex(i)); - sal_Int32 nKeyType = 0; - xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; - if(KeyType::PRIMARY == nKeyType) + OSL_ENSURE(xProp.is(),"OQueryTableWindow::FillListBox Key isn't a XPropertySet!"); + if(xProp.is()) { - xColumnsSupplier = Reference<XColumnsSupplier>(xProp,UNO_QUERY); - break; + sal_Int32 nKeyType = 0; + xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType; + if(KeyType::PRIMARY == nKeyType) + { + xColumnsSupplier = Reference<XColumnsSupplier>(xProp,UNO_QUERY); + break; + } } } if(xColumnsSupplier.is()) @@ -268,29 +272,33 @@ sal_Bool OQueryTableWindow::FillListBox() pEntry->SetUserData( new OTableFieldInfo() ); } - Sequence< ::rtl::OUString> aColumns = GetOriginalColumns()->getElementNames(); - const ::rtl::OUString* pBegin = aColumns.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aColumns.getLength(); - - for (; pBegin != pEnd; ++pBegin) + if(GetOriginalColumns().is()) { - OTableFieldInfo* pInfo = new OTableFieldInfo(); - // is this column in the primary key - if (xPKeyColumns.is() && xPKeyColumns->hasByName(*pBegin)) - { - pEntry = m_pListBox->InsertEntry(*pBegin, aPrimKeyImage, aPrimKeyImage); - pInfo->SetKey(TAB_PRIMARY_FIELD); - } - else + Sequence< ::rtl::OUString> aColumns = GetOriginalColumns()->getElementNames(); + const ::rtl::OUString* pBegin = aColumns.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aColumns.getLength(); + + for (; pBegin != pEnd; ++pBegin) { - pEntry = m_pListBox->InsertEntry(*pBegin); - pInfo->SetKey(TAB_NORMAL_FIELD); + OTableFieldInfo* pInfo = new OTableFieldInfo(); + // is this column in the primary key + if (xPKeyColumns.is() && xPKeyColumns->hasByName(*pBegin)) + { + pEntry = m_pListBox->InsertEntry(*pBegin, aPrimKeyImage, aPrimKeyImage); + pInfo->SetKey(TAB_PRIMARY_FIELD); + } + else + { + pEntry = m_pListBox->InsertEntry(*pBegin); + pInfo->SetKey(TAB_NORMAL_FIELD); + } + Reference<XPropertySet> xColumn; + ::cppu::extractInterface(xColumn,GetOriginalColumns()->getByName(*pBegin)); + OSL_ENSURE(xColumn.is(),"No column!"); + if(xColumn.is()) + pInfo->SetDataType(::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_TYPE))); + pEntry->SetUserData( pInfo ); } - Reference<XPropertySet> xColumn; - ::cppu::extractInterface(xColumn,GetOriginalColumns()->getByName(*pBegin)); - OSL_ENSURE(xColumn.is(),"No column!"); - pInfo->SetDataType(::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_TYPE))); - pEntry->SetUserData( pInfo ); } return sal_True; } @@ -345,31 +353,34 @@ sal_Bool OQueryTableWindow::ExistsField(const ::rtl::OUString& strFieldName, OTa { DBG_ASSERT(m_pListBox != NULL, "OQueryTableWindow::ExistsField : habe keine ::com::sun::star::form::ListBox !"); Reference< XConnection> xConnection = getTableView()->getDesignView()->getController()->getConnection(); - if(!xConnection.is()) - return FALSE; - SvLBoxEntry* pEntry = m_pListBox->First(); - ::comphelper::UStringMixEqual bCase(xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); - - while (pEntry) + sal_Bool bExists = sal_False; + if(xConnection.is()) { - if (bCase(strFieldName,::rtl::OUString(m_pListBox->GetEntryText(pEntry)))) + SvLBoxEntry* pEntry = m_pListBox->First(); + ::comphelper::UStringMixEqual bCase(xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + + while (pEntry) { - OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData()); - DBG_ASSERT(pInf != NULL, "OQueryTableWindow::ExistsField : Feld hat keine FieldInfo !"); - - rInfo.SetTabWindow(this); - rInfo.SetField(strFieldName); - rInfo.SetTable(GetTableName()); - rInfo.SetAlias(GetAliasName()); - rInfo.SetDatabase(GetComposedName()); - rInfo.SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry)); - rInfo.SetDataType(pInf->GetDataType()); - return sal_True; + if (bCase(strFieldName,::rtl::OUString(m_pListBox->GetEntryText(pEntry)))) + { + OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData()); + DBG_ASSERT(pInf != NULL, "OQueryTableWindow::ExistsField : Feld hat keine FieldInfo !"); + + rInfo.SetTabWindow(this); + rInfo.SetField(strFieldName); + rInfo.SetTable(GetTableName()); + rInfo.SetAlias(GetAliasName()); + rInfo.SetDatabase(GetComposedName()); + rInfo.SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry)); + rInfo.SetDataType(pInf->GetDataType()); + bExists = sal_True; + break; + } + pEntry = m_pListBox->Next(pEntry); } - pEntry = m_pListBox->Next(pEntry); } - return sal_False; + return bExists; } //------------------------------------------------------------------------------ |