diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-06-28 13:26:45 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-06-28 13:26:45 +0000 |
commit | 2e91342770e3d84129070b1b92379a90d97cebb4 (patch) | |
tree | fe64fea49be4718ea3be22b4b1dc723411a3c724 | |
parent | d7b87b4a40a20d2d1a542518febe44dc9809b275 (diff) |
#88787# assure that the noone access objects thaould already be disposed
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/JoinTableView.hxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/RTableConnectionData.hxx | 16 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/RelationController.hxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/TableWindow.hxx | 23 | ||||
-rw-r--r-- | dbaccess/source/ui/relationdesign/RTableConnectionData.cxx | 78 | ||||
-rw-r--r-- | dbaccess/source/ui/relationdesign/RelationController.cxx | 121 | ||||
-rw-r--r-- | dbaccess/source/ui/relationdesign/RelationDesignView.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/relationdesign/RelationTableView.cxx | 129 |
9 files changed, 280 insertions, 122 deletions
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index 15aac49941296..c57f24e6feb2f 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: brwctrlr.cxx,v $ * - * $Revision: 1.37 $ + * $Revision: 1.38 $ * - * last change: $Author: rt $ $Date: 2001-06-22 10:24:09 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:26:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1474,6 +1474,8 @@ FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) case ID_BROWSER_ORDERCRIT: case ID_BROWSER_FILTERCRIT: + if (!m_xParser.is()) + break; // we are not in the handle column aReturn.bEnabled = getBrowserView()->getVclControl()->GetCurColumnId() != 0; // a native statement can't be filtered or sorted diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx b/dbaccess/source/ui/inc/JoinTableView.hxx index f4dafa6d1600f..08211a0ea74e2 100644 --- a/dbaccess/source/ui/inc/JoinTableView.hxx +++ b/dbaccess/source/ui/inc/JoinTableView.hxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinTableView.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-04-30 13:03:02 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:26:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -196,12 +196,15 @@ namespace dbaui OTableWindowMap* GetTabWinMap() { return &m_aTableMap; } const OTableWindowMap* GetTabWinMap() const { return &m_aTableMap; } ::std::vector<OTableConnection*>* GetTabConnList() { return &m_vTableConnection; } - // ::std::vector<OTableConnection*>* GetTabConnList() const { return &m_vTableConnection; } BOOL ExistsAConn(const OTableWindow* pFromWin) const; OTableConnection* GetTabConn(OTableWindow* pLhs,OTableWindow* pRhs, OTableConnection* _rpFirstAfter = NULL); + // clears the window map and connection vector without destroying it + // that means teh data of the windows and connection will be untouched + void clearLayoutInformation(); + // set the focus to that tab win which most recently had it (or to the first available one) void GrabTabWinFocus(); diff --git a/dbaccess/source/ui/inc/RTableConnectionData.hxx b/dbaccess/source/ui/inc/RTableConnectionData.hxx index e8f5cd44b1eb8..fdfc78873b032 100644 --- a/dbaccess/source/ui/inc/RTableConnectionData.hxx +++ b/dbaccess/source/ui/inc/RTableConnectionData.hxx @@ -2,9 +2,9 @@ * * $RCSfile: RTableConnectionData.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-02-28 10:07:39 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:26:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,9 @@ #ifndef DBAUI_ENUMTYPES_HXX #include "QEnumTypes.hxx" #endif +#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ +#include <unotools/eventlisteneradapter.hxx> +#endif namespace dbaui { @@ -83,8 +86,10 @@ namespace dbaui class OConnectionLineData; //================================================================== - class ORelationTableConnectionData : public OTableConnectionData + class ORelationTableConnectionData : public OTableConnectionData, + public ::utl::OEventListenerAdapter { + ::osl::Mutex m_aMutex; ::rtl::OUString m_sDatabaseName; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xTables; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xSource; @@ -98,6 +103,8 @@ namespace dbaui BOOL checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable,EConnectionSide _eEConnectionSide) const; BOOL IsSourcePrimKey() const { return checkPrimaryKey(m_xSource,JTCS_FROM); } BOOL IsDestPrimKey() const { return checkPrimaryKey(m_xDest,JTCS_TO); } + void addListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxComponent); + void removeListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxComponent); protected: virtual OConnectionLineData* CreateLineDataObj(); @@ -139,6 +146,9 @@ namespace dbaui BOOL IsConnectionPossible(); void ChangeOrientation(); BOOL DropRelation(); + + // OEventListenerAdapter + virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); }; } diff --git a/dbaccess/source/ui/inc/RelationController.hxx b/dbaccess/source/ui/inc/RelationController.hxx index c17bf97dd60b6..99f058ae0aec4 100644 --- a/dbaccess/source/ui/inc/RelationController.hxx +++ b/dbaccess/source/ui/inc/RelationController.hxx @@ -2,9 +2,9 @@ * * $RCSfile: RelationController.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: fs $ $Date: 2001-06-21 17:43:46 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:26:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,6 +93,10 @@ namespace dbaui ORelationDesignView* getRelationView() { return static_cast<ORelationDesignView*>(m_pView); } void loadData(); sal_Bool existsTable(const ::rtl::OUString& _rComposedTableName) const; + // ask the user if the design should be saved when it is modified + short saveModified(); + // load the window positions out of the datasource + void loadLayoutInformation(); public: ORelationController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM); diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx index bc8ff4444ee6d..8587b13315932 100644 --- a/dbaccess/source/ui/inc/TableWindow.hxx +++ b/dbaccess/source/ui/inc/TableWindow.hxx @@ -2,9 +2,9 @@ * * $RCSfile: TableWindow.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-02-28 10:07:01 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:26:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,6 +82,9 @@ #ifndef _SV_WINDOW_HXX #include <vcl/window.hxx> #endif +#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ +#include <unotools/eventlisteneradapter.hxx> +#endif class SvLBoxEntry; namespace dbaui @@ -98,10 +101,13 @@ namespace dbaui class OJoinDesignView; class OJoinTableView; - class OTableWindow : public Window + class OTableWindow : public Window, + public ::utl::OEventListenerAdapter { friend class OTableWindowTitle; friend class OTableWindowListBox; + + mutable ::osl::Mutex m_aMutex; protected: // und die Tabelle selber (brauche ich, da ich sie locken will, solange das Fenster lebt) OTableWindowTitle m_aTitle; @@ -138,10 +144,6 @@ namespace dbaui virtual void OnEntryDoubleClicked(SvLBoxEntry* pEntry) { } // wird aus dem DoubleClickHdl der ListBox heraus aufgerufen - // die unterliegende Tabellendefinition (un)locken - // void LockTable() { if (m_xTableDef.Is()) m_xTableDef->AddUsage(); } - // void UnlockTable() { if (m_xTableDef.Is()) m_xTableDef->ReleaseUsage(); } - public: TYPEINFO(); OTableWindow( Window* pParent, OTableWindowData* pTabWinData); @@ -168,8 +170,8 @@ namespace dbaui ::rtl::OUString GetComposedName() const { return m_pData->GetComposedName(); } OTableWindowListBox* GetListBox() const { return m_pListBox; } OTableWindowData* GetData() const { return m_pData; } - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> GetOriginalColumns() const { return m_xColumns; } - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> GetTable() const { return m_xTable; } + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> GetOriginalColumns() const { ::osl::MutexGuard aGuard( m_aMutex ); return m_xColumns; } + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> GetTable() const { ::osl::MutexGuard aGuard( m_aMutex ); return m_xTable; } UINT16 GetSizingFlags() const { return m_nSizingFlags; } @@ -184,6 +186,9 @@ namespace dbaui BOOL ExistsAConn() const; virtual void EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields); + + // OEventListenerAdapter + virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); }; } #endif //DBAUI_TABLEWINDOW_HXX diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 6cfae08b065bc..3da972e886a95 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.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-21 12:57:05 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,6 +100,7 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; DBG_NAME(ORelationTableConnectionData); //======================================================================== @@ -125,6 +126,9 @@ ORelationTableConnectionData::ORelationTableConnectionData( const Reference< XNa ,m_xTables(_xTables) { DBG_CTOR(ORelationTableConnectionData,NULL); + Reference<XComponent> xComponent(m_xTables,UNO_QUERY); + if(xComponent.is()) + startComponentListening(xComponent); } //------------------------------------------------------------------------ @@ -140,11 +144,20 @@ ORelationTableConnectionData::ORelationTableConnectionData( const Reference< XNa ,m_xTables(_xTables) { DBG_CTOR(ORelationTableConnectionData,NULL); + + ::osl::MutexGuard aGuard( m_aMutex ); + + OSL_ENSURE(m_xTables.is(),"ORelationTableConnectionData::ORelationTableConnectionData No Tables!"); + addListening(m_xTables); + SetCardinality(); - if(m_xTables->hasByName(rSourceWinName)) + if(m_xTables.is() && m_xTables->hasByName(rSourceWinName)) m_xTables->getByName(rSourceWinName) >>= m_xSource; - if(m_xTables->hasByName(rDestWinName)) + if(m_xTables.is() && m_xTables->hasByName(rDestWinName)) m_xTables->getByName(rDestWinName) >>= m_xDest; + + addListening(m_xSource); + addListening(m_xDest); } //------------------------------------------------------------------------ @@ -159,12 +172,17 @@ ORelationTableConnectionData::ORelationTableConnectionData( const ORelationTable ORelationTableConnectionData::~ORelationTableConnectionData() { DBG_DTOR(ORelationTableConnectionData,NULL); + + removeListening(m_xDest); + removeListening(m_xSource); + removeListening(m_xTables); } //------------------------------------------------------------------------ BOOL ORelationTableConnectionData::DropRelation() { DBG_CHKTHIS(ORelationTableConnectionData,NULL); + ::osl::MutexGuard aGuard( m_aMutex ); //////////////////////////////////////////////////////////// // Relation loeschen Reference<XKeysSupplier> xSup(m_xSource,UNO_QUERY); @@ -220,6 +238,8 @@ void ORelationTableConnectionData::ChangeOrientation() m_aSourceWinName = m_aDestWinName; m_aDestWinName = sTempString; + ::osl::MutexGuard aGuard( m_aMutex ); + Reference<XPropertySet> xTemp; xTemp = m_xSource; m_xSource = m_xDest; @@ -229,17 +249,30 @@ void ORelationTableConnectionData::ChangeOrientation() //------------------------------------------------------------------------ void ORelationTableConnectionData::SetSourceWinName( const String& rSourceWinName ) { + ::osl::MutexGuard aGuard( m_aMutex ); + OTableConnectionData::SetSourceWinName(rSourceWinName); if(m_xTables->hasByName(rSourceWinName)) + { + removeListening(m_xDest); m_xTables->getByName(rSourceWinName) >>= m_xSource; + addListening(m_xDest); + } } //------------------------------------------------------------------------ void ORelationTableConnectionData::SetDestWinName( const String& rDestWinName ) { + ::osl::MutexGuard aGuard( m_aMutex ); + OTableConnectionData::SetDestWinName(rDestWinName); + if(m_xTables->hasByName(rDestWinName)) + { + removeListening(m_xDest); m_xTables->getByName(rDestWinName) >>= m_xDest; + addListening(m_xDest); + } } //------------------------------------------------------------------------ @@ -304,6 +337,8 @@ BOOL ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet BOOL ORelationTableConnectionData::IsConnectionPossible() { DBG_CHKTHIS(ORelationTableConnectionData,NULL); + ::osl::MutexGuard aGuard( m_aMutex ); + if( !m_xSource.is() || !m_xDest.is() ) return FALSE; @@ -348,18 +383,28 @@ ORelationTableConnectionData& ORelationTableConnectionData::operator=( const ORe m_nDeleteRules = rConnData.GetDeleteRules(); m_nCardinality = rConnData.GetCardinality(); - // m_sDatabaseName = rConnData.getTablesName(); + + ::osl::MutexGuard aGuard( m_aMutex ); + + removeListening(m_xDest); + removeListening(m_xSource); + removeListening(m_xTables); m_xTables = rConnData.getTables(); m_xSource = rConnData.getSource(); m_xDest = rConnData.getDest(); + addListening(m_xDest); + addListening(m_xSource); + addListening(m_xTables); + return *this; } //------------------------------------------------------------------------ BOOL ORelationTableConnectionData::Update() { + ::osl::MutexGuard aGuard( m_aMutex ); //////////////////////////////////////////////////////////// // Alte Relation loeschen { @@ -510,4 +555,27 @@ BOOL ORelationTableConnectionData::Update() return TRUE; } // ----------------------------------------------------------------------------- +void ORelationTableConnectionData::addListening(const Reference<XInterface>& _rxComponent) +{ + Reference<XComponent> xComponent(_rxComponent,UNO_QUERY); + if(xComponent.is()) + startComponentListening(xComponent); +} +// ----------------------------------------------------------------------------- +void ORelationTableConnectionData::removeListening(const Reference<XInterface>& _rxComponent) +{ + Reference<XComponent> xComponent(_rxComponent,UNO_QUERY); + if(xComponent.is()) + stopComponentListening(xComponent); +} +// ----------------------------------------------------------------------------- +void ORelationTableConnectionData::_disposing( const ::com::sun::star::lang::EventObject& _rSource ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + // it doesn't matter which one was disposed + m_xTables = NULL; + m_xSource = NULL; + m_xDest = NULL; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index fd2325145c245..b0f7bf58a0fed 100644 --- a/dbaccess/source/ui/relationdesign/RelationController.cxx +++ b/dbaccess/source/ui/relationdesign/RelationController.cxx @@ -2,9 +2,9 @@ * * $RCSfile: RelationController.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: fs $ $Date: 2001-06-21 17:45:04 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -181,6 +181,9 @@ #ifndef _COM_SUN_STAR_UTIL_XFLUSHABLE_HPP_ #include <com/sun/star/util/XFlushable.hpp> #endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif extern "C" void SAL_CALL createRegistryInfo_ORelationControl() { @@ -234,16 +237,19 @@ Reference< XInterface > SAL_CALL ORelationController::Create(const Reference<XMu { return *(new ORelationController(_rxFactory)); } +DBG_NAME(ORelationController); // ----------------------------------------------------------------------------- ORelationController::ORelationController(const Reference< XMultiServiceFactory >& _rM) : OJoinController(_rM) ,m_bRelationsPossible(sal_True) { + DBG_CTOR(ORelationController,NULL); InvalidateAll(); } // ----------------------------------------------------------------------------- ORelationController::~ORelationController() { + DBG_DTOR(ORelationController,NULL); } // ----------------------------------------------------------------------------- FeatureState ORelationController::GetState(sal_uInt16 _nId) @@ -256,9 +262,12 @@ FeatureState ORelationController::GetState(sal_uInt16 _nId) aReturn.aState = ::cppu::bool2any(m_bEditable); break; case ID_REALTION_ADD_RELATION: - aReturn.bEnabled = m_vTableData.size() > 1; + aReturn.bEnabled = m_vTableData.size() > 1 && m_xConnection.is() && m_bEditable; aReturn.aState = ::cppu::bool2any(sal_False); break; + case ID_BROWSER_SAVEDOC: + aReturn.bEnabled = m_xDataSource.is() && m_bModified; + break; default: aReturn = OJoinController::GetState(_nId); break; @@ -277,9 +286,8 @@ void ORelationController::Execute(sal_uInt16 _nId) // create the output stream try { - Sequence< sal_Int8 > aOutputSeq; - if(m_xDataSource->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION)) + if(m_xDataSource.is() && m_xDataSource->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION)) { Reference< XOutputStream> xOutStreamHelper = new OSequenceOutputStream(aOutputSeq); Reference< XObjectOutputStream> xOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")),UNO_QUERY); @@ -305,6 +313,30 @@ void ORelationController::Execute(sal_uInt16 _nId) case ID_REALTION_ADD_RELATION: static_cast<ORelationTableView*>(static_cast<ORelationDesignView*>(m_pView)->getTableView())->AddNewRelation(); break; + case ID_BROWSER_EDITDOC: + if(m_bEditable) + { // the state should be changed to not editable + switch (saveModified()) + { + case RET_CANCEL: + // don't change anything here so return + return; + break; + case RET_NO: + loadLayoutInformation(); + getView()->initialize(); + getView()->Invalidate(INVALIDATE_NOERASE); + setModified(sal_False); // and we are not modified yet + break; + default: + break; + } + } + OJoinController::Execute(_nId); + InvalidateAll(); + return; + break; + // run through default: OJoinController::Execute(_nId); return; @@ -393,36 +425,13 @@ void SAL_CALL ORelationController::initialize( const Sequence< Any >& aArguments if(xSup.is()) m_xTables = xSup->getTables(); // load the layoutInformation - try - { - OSL_ENSURE(m_xDataSource.is(),"We need a datasource from our connection!"); - if(m_xDataSource.is()) - { - Sequence< sal_Int8 > aInputSequence; - if(m_xDataSource->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION)) - { - m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aInputSequence; - { - Reference< XInputStream> xInStreamHelper = new SequenceInputStream(aInputSequence);; // used for wrapping sequence to xinput - Reference< XObjectInputStream> xInStream = Reference< XObjectInputStream >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")),UNO_QUERY); - Reference< XInputStream> xMarkInStream = Reference< XInputStream >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")),UNO_QUERY); - Reference< XActiveDataSink >(xMarkInStream,UNO_QUERY)->setInputStream(xInStreamHelper); - Reference< XActiveDataSink > xInDataSource(xInStream, UNO_QUERY); - OSL_ENSURE(xInDataSource.is(),"Couldn't create com.sun.star.io.ObjectInputStream!"); - xInDataSource->setInputStream(xMarkInStream); - Load(xInStream); - } - } - } - } - catch(Exception&) - { - } + loadLayoutInformation(); try { loadData(); getView()->initialize(); // show the windows and fill with our informations + getView()->Invalidate(INVALIDATE_NOERASE); getUndoMgr()->Clear(); // clear all undo redo things setModified(sal_False); // and we are not modified yet // set the title of the beamer @@ -454,21 +463,20 @@ sal_Bool ORelationController::Construct(Window* pParent) // ----------------------------------------------------------------------------- sal_Bool SAL_CALL ORelationController::suspend(sal_Bool bSuspend) throw( RuntimeException ) { - if(m_xConnection.is() && m_bModified) + return saveModified() != RET_CANCEL; +} +// ----------------------------------------------------------------------------- +short ORelationController::saveModified() +{ + short nSaved = RET_YES; + if(m_xDataSource.is() && m_bModified) { QueryBox aQry(getView(), ModuleRes(RELATION_DESIGN_SAVEMODIFIED)); - switch (aQry.Execute()) - { - case RET_YES: - Execute(ID_BROWSER_SAVEDOC); - break; - case RET_CANCEL: - return sal_False; - default: - break; - } + nSaved = aQry.Execute(); + if(nSaved == RET_YES) + Execute(ID_BROWSER_SAVEDOC); } - return sal_True; + return nSaved; } // ----------------------------------------------------------------------------- void ORelationController::AddSupportedFeatures() @@ -604,4 +612,31 @@ String ORelationController::getMenu() const return String::CreateFromInt32(RID_RELATION_DESIGN_MAIN_MENU); } // ----------------------------------------------------------------------------- - +void ORelationController::loadLayoutInformation() +{ + try + { + OSL_ENSURE(m_xDataSource.is(),"We need a datasource from our connection!"); + if(m_xDataSource.is()) + { + Sequence< sal_Int8 > aInputSequence; + if(m_xDataSource->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION)) + { + m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aInputSequence; + { + Reference< XInputStream> xInStreamHelper = new SequenceInputStream(aInputSequence);; // used for wrapping sequence to xinput + Reference< XObjectInputStream> xInStream = Reference< XObjectInputStream >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")),UNO_QUERY); + Reference< XInputStream> xMarkInStream = Reference< XInputStream >(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")),UNO_QUERY); + Reference< XActiveDataSink >(xMarkInStream,UNO_QUERY)->setInputStream(xInStreamHelper); + Reference< XActiveDataSink > xInDataSource(xInStream, UNO_QUERY); + OSL_ENSURE(xInDataSource.is(),"Couldn't create com.sun.star.io.ObjectInputStream!"); + xInDataSource->setInputStream(xMarkInStream); + Load(xInStream); + } + } + } + } + catch(Exception&) + { + } +} diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx index a925c6a5cf1d1..5f28e4104a4f5 100644 --- a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: RelationDesignView.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-03-21 13:51:10 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,6 +121,9 @@ #ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" #endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif using namespace ::dbaui; using namespace ::com::sun::star::uno; @@ -130,14 +133,16 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; +DBG_NAME(ORelationDesignView); ORelationDesignView::ORelationDesignView(Window* _pParent, ORelationController* _pController,const Reference< XMultiServiceFactory >& _rFactory) :OJoinDesignView(_pParent,_pController,_rFactory) { - + DBG_CTOR(ORelationDesignView,NULL); } // ----------------------------------------------------------------------------- ORelationDesignView::~ORelationDesignView() { + DBG_DTOR(ORelationDesignView,NULL); } // ------------------------------------------------------------------------- void ORelationDesignView::Construct(const Reference< ::com::sun::star::awt::XControlModel >& xModel) @@ -148,6 +153,7 @@ void ORelationDesignView::Construct(const Reference< ::com::sun::star::awt::XCon // ----------------------------------------------------------------------------- void ORelationDesignView::initialize() { + m_pTableView->clearLayoutInformation(); m_pTableView->ReSync(); OJoinDesignView::initialize(); diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx index df1a1c14290ef..4c1b7d6ab31b7 100644 --- a/dbaccess/source/ui/relationdesign/RelationTableView.cxx +++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: RelationTableView.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-03-23 09:08:27 $ + * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -236,12 +236,21 @@ BOOL ORelationTableView::IsAddAllowed() { DBG_CHKTHIS(ORelationTableView,NULL); - Reference<XConnection> xConnection = m_pView->getController()->getConnection(); - if(!xConnection.is()) - return FALSE; - Reference < XDatabaseMetaData > xMetaData( m_pView->getController()->getConnection()->getMetaData() ); + BOOL bAllowed = !m_pView->getController()->isReadOnly(); + if(bAllowed) + { + Reference<XConnection> xConnection = m_pView->getController()->getConnection(); + if(!xConnection.is()) + bAllowed = FALSE; + else + { + Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() ); + OSL_ENSURE(xMetaData.is(),"ORelationTableView::IsAddAllowed: The metadata is null!"); - return xMetaData->supportsIntegrityEnhancementFacility(); + bAllowed = xMetaData.is() && xMetaData->supportsIntegrityEnhancementFacility(); + } + } + return bAllowed; } //------------------------------------------------------------------------ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) @@ -265,10 +274,14 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const return; } } - // Datenobjekt in DocShell einfuegen - ORelationTableConnectionData* pTabConnData = new ORelationTableConnectionData(Reference<XTablesSupplier>(getDesignView()->getController()->getConnection(),UNO_QUERY)->getTables(), - jxdSource.pListBox->GetTabWin()->GetWinName(), - jxdDest.pListBox->GetTabWin()->GetWinName()); + // insert table connection into view + Reference<XTablesSupplier> xTablesSup(getDesignView()->getController()->getConnection(),UNO_QUERY); + ORelationTableConnectionData* pTabConnData = NULL; + OSL_ENSURE(xTablesSup.is(),"ORelationTableView::AddConnection no TablesSupplier"); + if(xTablesSup.is()) + pTabConnData = new ORelationTableConnectionData(xTablesSup->getTables(), + jxdSource.pListBox->GetTabWin()->GetWinName(), + jxdDest.pListBox->GetTabWin()->GetWinName()); // die Namen der betroffenen Felder String aSourceFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry); @@ -282,13 +295,16 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const { OSL_ENSURE(aPkeys.size()==1,"There can't be more than one pkey!"); Reference< XNameAccess> xColumns = pSourceWin->GetOriginalColumns(); - Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); - const ::rtl::OUString* pBegin = aNames.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); - for(;pBegin != pEnd;++pBegin) + if(xColumns.is()) { - if((*aPkeys.begin())->hasByName(*pBegin)) - pTabConnData->SetConnLine( nSourceKeys++, *pBegin, String() ); + Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aNames.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if((*aPkeys.begin())->hasByName(*pBegin)) + pTabConnData->SetConnLine( nSourceKeys++, *pBegin, String() ); + } } } @@ -335,55 +351,63 @@ void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const void ORelationTableView::ConnDoubleClicked( OTableConnection* pConnection ) { DBG_CHKTHIS(ORelationTableView,NULL); - ORelationTableConnectionData* pRelTabConnData = (ORelationTableConnectionData*)((ORelationTableConnection*)pConnection)->GetData(); - ORelationDialog aRelDlg( this, pRelTabConnData ); - switch (aRelDlg.Execute()) + Reference<XConnection> xConnection = getDesignView()->getController()->getConnection(); + if(xConnection.is()) { - case RET_OK: - // successfully updated - pConnection->UpdateLineList(); - // The connection references 1 ConnData and n ConnLines, each ConnData references n LineDatas, each Line exactly 1 LineData - // As the Dialog and the ConnData->Update may have changed the LineDatas we have to restore the consistent state - break; - - case RET_NO: - // tried at least one update, but did not succeed -> the original connection is lost - RemoveConnection( pConnection ); - break; - - case RET_CANCEL: - // no break, as nothing happened and we don't need the code below - return; + ORelationTableConnectionData* pRelTabConnData = (ORelationTableConnectionData*)((ORelationTableConnection*)pConnection)->GetData(); + ORelationDialog aRelDlg( this, pRelTabConnData ); + switch (aRelDlg.Execute()) + { + case RET_OK: + // successfully updated + pConnection->UpdateLineList(); + // The connection references 1 ConnData and n ConnLines, each ConnData references n LineDatas, each Line exactly 1 LineData + // As the Dialog and the ConnData->Update may have changed the LineDatas we have to restore the consistent state + break; + + case RET_NO: + // tried at least one update, but did not succeed -> the original connection is lost + RemoveConnection( pConnection ); + break; + + case RET_CANCEL: + // no break, as nothing happened and we don't need the code below + return; - } + } - Invalidate(INVALIDATE_NOCHILDREN); + Invalidate(INVALIDATE_NOCHILDREN); + } } //------------------------------------------------------------------------------ void ORelationTableView::AddNewRelation() { DBG_CHKTHIS(ORelationTableView,NULL); - ORelationTableConnectionData* pNewConnData = new ORelationTableConnectionData(Reference<XTablesSupplier>(getDesignView()->getController()->getConnection(),UNO_QUERY)->getTables()); - ORelationDialog aRelDlg(this, pNewConnData, TRUE); - BOOL bSuccess = (aRelDlg.Execute() == RET_OK); - if (bSuccess) + Reference<XTablesSupplier> xTablesSup(getDesignView()->getController()->getConnection(),UNO_QUERY); + if(xTablesSup.is()) { -// bSuccess = pNewConnData->Update(); - // already updated by the dialog - // dem Dokument bekanntgeben - getDesignView()->getController()->getTableConnectionData()->push_back(pNewConnData); + ORelationTableConnectionData* pNewConnData = new ORelationTableConnectionData(xTablesSup->getTables()); + ORelationDialog aRelDlg(this, pNewConnData, TRUE); - // das reale Connection-Objekt (bis jetzt haben wir nur die Datas) - ORelationTableConnection* pTabConn = new ORelationTableConnection(this, pNewConnData); - GetTabConnList()->push_back(pTabConn); + BOOL bSuccess = (aRelDlg.Execute() == RET_OK); + if (bSuccess) + { + // already updated by the dialog + // dem Dokument bekanntgeben + getDesignView()->getController()->getTableConnectionData()->push_back(pNewConnData); - // neu zeichnen - Invalidate(INVALIDATE_NOCHILDREN); + // das reale Connection-Objekt (bis jetzt haben wir nur die Datas) + ORelationTableConnection* pTabConn = new ORelationTableConnection(this, pNewConnData); + GetTabConnList()->push_back(pTabConn); + + // neu zeichnen + Invalidate(INVALIDATE_NOCHILDREN); + } + else + delete pNewConnData; } - else - delete pNewConnData; } //------------------------------------------------------------------------------ @@ -403,6 +427,7 @@ BOOL ORelationTableView::RemoveConnection( OTableConnection* pConn ) } catch(Exception&) { + OSL_ENSURE(0,"ORelationTableView::RemoveConnection: Something other than SQLException occured!"); } return bErg; } |