diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-10-08 06:32:36 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-10-08 06:32:36 +0000 |
commit | 8e09c619e3537f37d96d13c37f008087a2911a4d (patch) | |
tree | 72fa3e89f016391523eec2f71507d394d6eeca64 | |
parent | #92786# refcount (diff) | |
download | core-8e09c619e3537f37d96d13c37f008087a2911a4d.tar.gz core-8e09c619e3537f37d96d13c37f008087a2911a4d.zip |
#92786# refcount implemented for connectiondata and sqlexception catched
9 files changed, 90 insertions, 73 deletions
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx index caf33b2f0dcb..f6a52cf564a4 100644 --- a/dbaccess/source/ui/querydesign/JoinTableView.cxx +++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinTableView.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: oj $ $Date: 2001-08-27 14:24:23 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1175,15 +1175,22 @@ BOOL OJoinTableView::IsAddAllowed() if (m_pView->getController()->isReadOnly()) return FALSE; - Reference< XConnection> xConnection = m_pView->getController()->getConnection(); - if(!xConnection.is()) - return FALSE; - // nicht wenn schon zuviele Tabellen - Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() ); - - sal_Int32 nMax = xMetaData->getMaxTablesInSelect(); - if (nMax && nMax <= (sal_Int32)m_aTableMap.size()) + try + { + Reference< XConnection> xConnection = m_pView->getController()->getConnection(); + if(!xConnection.is()) + return FALSE; + // nicht wenn schon zuviele Tabellen + Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() ); + + sal_Int32 nMax = xMetaData->getMaxTablesInSelect(); + if (nMax && nMax <= (sal_Int32)m_aTableMap.size()) + return FALSE; + } + catch(SQLException&) + { return FALSE; + } // nicht wenn keine Joins moeglich // if (!GetDatabase()->IsCapable(SDB_CAP_JOIN) && nMax <= GetTabWinCount()) @@ -1208,7 +1215,7 @@ void OJoinTableView::Command(const CommandEvent& rEvt) return; } - if( !m_vTableConnection.size() ) + if( m_vTableConnection.empty() ) return; DeselectConn(GetSelectedConn()); diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx index 2c03323bae1c..ce3536a12d4d 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableConnectionData.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-10-05 06:49:18 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,7 +121,7 @@ OQueryTableConnectionData::~OQueryTableConnectionData() } //------------------------------------------------------------------------ -OConnectionLineData* OQueryTableConnectionData::CreateLineDataObj() +OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj() { DBG_CHKTHIS(OQueryTableConnectionData,NULL); // keine Spezialisierung bei den LineDatas, also eine Instanz der Standard-Klasse @@ -129,7 +129,7 @@ OConnectionLineData* OQueryTableConnectionData::CreateLineDataObj() } //------------------------------------------------------------------------ -OConnectionLineData* OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) +OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) { DBG_CHKTHIS(OQueryTableConnectionData,NULL); return new OConnectionLineData( rConnLineData ); diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx index db292323ecf0..afea3b370b72 100644 --- a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx +++ b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx @@ -2,9 +2,9 @@ * * $RCSfile: QTableConnectionData.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-10-05 06:49:18 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,8 +97,8 @@ namespace dbaui protected: // fuer das Anlegen und Duplizieren von Lines vom eigenen Typ - virtual OConnectionLineData* CreateLineDataObj(); - virtual OConnectionLineData* CreateLineDataObj( const OConnectionLineData& rConnLineData ); + virtual OConnectionLineDataRef CreateLineDataObj(); + virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData ); public: TYPEINFO(); diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 77c366d038eb..9cf21ffab95c 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryDesignView.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: oj $ $Date: 2001-10-05 06:49:18 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -599,20 +599,20 @@ extern ::rtl::OUString ConvertAlias(const ::rtl::OUString& rName); return aErg; } //------------------------------------------------------------------------------ -::rtl::OUString OQueryDesignView::BuildJoinCriteria(::std::vector<OConnectionLineData*>* pLineDataList,OQueryTableConnectionData* pData) +::rtl::OUString OQueryDesignView::BuildJoinCriteria(OConnectionLineDataVec* pLineDataList,OQueryTableConnectionData* pData) { ::rtl::OUString aCondition; Reference< XConnection> xConnection = static_cast<OQueryController*>(getController())->getConnection(); if(!xConnection.is()) return aCondition; - ::std::vector<OConnectionLineData*>::iterator aIter = pLineDataList->begin(); + OConnectionLineDataVec::iterator aIter = pLineDataList->begin(); Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString(); for(;aIter != pLineDataList->end();++aIter) { - OConnectionLineData* pLineData = *aIter; + OConnectionLineDataRef pLineData = *aIter; if(pLineData->IsValid()) { if(aCondition.getLength()) @@ -1624,8 +1624,8 @@ int OQueryDesignView::ComparsionPredicate(const ::connectivity::OSQLParseNode * static_cast<OQueryTableWindow*>(aDragRight->GetTabWindow()))); if(pConn) { - ::std::vector<OConnectionLineData*>* pLineDataList = pConn->GetData()->GetConnLineDataList(); - ::std::vector<OConnectionLineData*>::iterator aIter = pLineDataList->begin(); + OConnectionLineDataVec* pLineDataList = pConn->GetData()->GetConnLineDataList(); + OConnectionLineDataVec::iterator aIter = pLineDataList->begin(); for(;aIter != pLineDataList->end();++aIter) { if((*aIter)->GetSourceFieldName() == aDragLeft->GetField() || diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index ff41ffe33a67..028f614ef239 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: SelectionBrowseBox.cxx,v $ * - * $Revision: 1.33 $ + * $Revision: 1.34 $ * - * last change: $Author: oj $ $Date: 2001-10-05 06:49:18 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -294,14 +294,23 @@ void OSelectionBrowseBox::Init() m_nVisibleCount++; } RowInserted(0, m_nVisibleCount, sal_False); - Reference< XConnection> xConnection = static_cast<OQueryController*>(getDesignView()->getController())->getConnection(); - if(xConnection.is()) + try { - Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); - m_nMaxColumns = xMetaData->getMaxColumnsInSelect(); + Reference< XConnection> xConnection = static_cast<OQueryController*>(getDesignView()->getController())->getConnection(); + if(xConnection.is()) + { + Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData(); + m_nMaxColumns = xMetaData->getMaxColumnsInSelect(); + + } + else + m_nMaxColumns = 0; } - else + catch(const SQLException&) + { + OSL_ENSURE(0,"Catched Exception when asking for database metadata options!"); m_nMaxColumns = 0; + } } //------------------------------------------------------------------------------ diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx index 775760cd16d5..1f17a87d6e7b 100644 --- a/dbaccess/source/ui/querydesign/TableConnection.cxx +++ b/dbaccess/source/ui/querydesign/TableConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableConnection.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-08-27 06:57:23 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -119,8 +119,8 @@ void OTableConnection::Init() { ////////////////////////////////////////////////////////////////////// // Linienliste mit Defaults initialisieren - ::std::vector<OConnectionLineData*>* pLineData = GetData()->GetConnLineDataList(); - ::std::vector<OConnectionLineData*>::const_iterator aIter = pLineData->begin(); + OConnectionLineDataVec* pLineData = GetData()->GetConnLineDataList(); + OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); for(;aIter != pLineData->end();++aIter) { OConnectionLine* pConnLine = new OConnectionLine(this, *aIter); diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx index c50a59c5b82c..4f8485005679 100644 --- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx +++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableConnectionData.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-02-05 16:17:40 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -106,10 +106,7 @@ void OTableConnectionData::Init() void OTableConnectionData::Init(const String& rSourceWinName, const String& rDestWinName, const String& rConnName) { // erst mal alle LineDatas loeschen - for(::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin();aIter != m_vConnLineData.end();++aIter) - delete *aIter; - - m_vConnLineData.clear(); + OConnectionLineDataVec().swap(m_vConnLineData); // dann die Strings m_aSourceWinName = rSourceWinName; m_aDestWinName = rDestWinName; @@ -155,9 +152,9 @@ OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionDat ResetConnLines(FALSE); // und kopieren - ::std::vector<OConnectionLineData*>* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList(); + OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList(); - ::std::vector<OConnectionLineData*>::const_iterator aIter = pLineData->begin(); + OConnectionLineDataVec::const_iterator aIter = pLineData->begin(); for(;aIter != pLineData->end();++aIter) m_vConnLineData.push_back(new OConnectionLineData(**aIter)); @@ -174,7 +171,7 @@ BOOL OTableConnectionData::SetConnLine( USHORT nIndex, const String& rSourceFiel if (m_vConnLineData.size() == nIndex) return AppendConnLine(rSourceFieldName, rDestFieldName); - OConnectionLineData* pConnLineData = m_vConnLineData[nIndex]; + OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex]; DBG_ASSERT(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt"); pConnLineData->SetSourceFieldName( rSourceFieldName ); @@ -186,7 +183,7 @@ BOOL OTableConnectionData::SetConnLine( USHORT nIndex, const String& rSourceFiel //------------------------------------------------------------------------ BOOL OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName ) { - ::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin(); + OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); for(;aIter != m_vConnLineData.end();++aIter) { if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName) @@ -194,8 +191,8 @@ BOOL OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldNa } if(aIter == m_vConnLineData.end()) { - OConnectionLineData* pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName); - if (!pNew) + OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName); + if (!pNew.isValid()) return FALSE; m_vConnLineData.push_back(pNew); @@ -206,9 +203,7 @@ BOOL OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldNa //------------------------------------------------------------------------ void OTableConnectionData::ResetConnLines( BOOL bUseDefaults ) { - for(::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin();aIter != m_vConnLineData.end();++aIter) - delete *aIter; - m_vConnLineData.clear(); + OConnectionLineDataVec().swap(m_vConnLineData); if (bUseDefaults) { @@ -218,13 +213,13 @@ void OTableConnectionData::ResetConnLines( BOOL bUseDefaults ) } //------------------------------------------------------------------------ -OConnectionLineData* OTableConnectionData::CreateLineDataObj() +OConnectionLineDataRef OTableConnectionData::CreateLineDataObj() { return new OConnectionLineData(); } //------------------------------------------------------------------------ -OConnectionLineData* OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) +OConnectionLineDataRef OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) { return new OConnectionLineData( rConnLineData ); } diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index b45435ebb322..b60becd1a8a6 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -2,9 +2,9 @@ * * $RCSfile: querycontroller.cxx,v $ * - * $Revision: 1.60 $ + * $Revision: 1.61 $ * - * last change: $Author: oj $ $Date: 2001-10-05 06:49:18 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -558,9 +558,11 @@ void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) m_bDesign = sal_False; if(m_bCreateView) { - String aMessage(ModuleRes(RID_STR_CONNECTION_LOST)); - ODataView* pWindow = getView(); - InfoBox(pWindow, aMessage).Execute(); + { + String aMessage(ModuleRes(RID_STR_CONNECTION_LOST)); + ODataView* pWindow = getView(); + InfoBox(pWindow, aMessage).Execute(); + } throw SQLException(); } } @@ -701,11 +703,18 @@ void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) xProp->setPropertyValue(PROPERTY_TITLE,makeAny(sName)); } } - catch(SQLException&) + catch(SQLException& e) { OSL_ENSURE(sal_False, "OQueryController::initialize: caught an exception!"); + // we caught an exception so we switch to text only mode + { + m_bDesign = sal_False; + getContainer()->initialize(); + ODataView* pWindow = getView(); + OSQLMessageBox(pWindow,e).Execute(); + } + throw; } - } // ----------------------------------------------------------------------------- void OQueryController::setQueryComposer() diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 3da972e886a9..bea03079a7c5 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: RTableConnectionData.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ + * last change: $Author: oj $ $Date: 2001-10-08 07:32:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -224,7 +224,7 @@ void ORelationTableConnectionData::ChangeOrientation() ////////////////////////////////////////////////////////////////////// // Source- und DestFieldName der Linien austauschen ::rtl::OUString sTempString; - ::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin(); + OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); for(;aIter != m_vConnLineData.end();++aIter) { sTempString = (*aIter)->GetSourceFieldName(); @@ -313,7 +313,7 @@ BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet for(;pKeyBegin != pKeyEnd;++pKeyBegin) { - ::std::vector<OConnectionLineData*>::const_iterator aIter = m_vConnLineData.begin(); + OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin(); for(;aIter != m_vConnLineData.end();++aIter) { if( (*aIter)->IsValid() ) @@ -354,13 +354,13 @@ BOOL ORelationTableConnectionData::IsConnectionPossible() } //------------------------------------------------------------------------ -OConnectionLineData* ORelationTableConnectionData::CreateLineDataObj() +OConnectionLineDataRef ORelationTableConnectionData::CreateLineDataObj() { return new OConnectionLineData(); } //------------------------------------------------------------------------ -OConnectionLineData* ORelationTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) +OConnectionLineDataRef ORelationTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData ) { return new OConnectionLineData( rConnLineData ); } @@ -468,7 +468,7 @@ BOOL ORelationTableConnectionData::Update() Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY); Reference<XAppend> xColumnAppend(xColumns,UNO_QUERY); - ::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin(); + OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin(); for(;aIter != m_vConnLineData.end();++aIter) { if((*aIter)->GetSourceFieldName().getLength() && (*aIter)->GetDestFieldName().getLength()) @@ -518,10 +518,7 @@ BOOL ORelationTableConnectionData::Update() if(xColSup.is()) { // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated - ::std::vector<OConnectionLineData*>::iterator aIter = m_vConnLineData.begin(); - for(;aIter != m_vConnLineData.end();++aIter) - delete *aIter; - m_vConnLineData.clear(); + OConnectionLineDataVec().swap(m_vConnLineData); Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); @@ -533,7 +530,7 @@ BOOL ORelationTableConnectionData::Update() xColumns->getByName(*pBegin) >>= xColumn; if (xColumn.is()) { - OConnectionLineData* pNewData = CreateLineDataObj(); + OConnectionLineDataRef pNewData = CreateLineDataObj(); ::rtl::OUString sName,sRelatedColumn; |