diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-07-18 07:51:19 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-07-18 07:51:19 +0000 |
commit | 8c5d7b3919a681258da9c01c61628d15951e525c (patch) | |
tree | 451fd6320def0e93843212c6d273bde85c267e4e /dbaccess | |
parent | 99286fceaeb7fbf2adba8498c680a3a4d45b6e30 (diff) |
#89772# set new configurationnode when datasource was renamed
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/inc/UITools.hxx | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/dbu_resource.hrc | 9 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 13 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/query.src | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 451 | ||||
-rw-r--r-- | dbaccess/source/ui/relationdesign/RelationController.cxx | 56 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 28 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/table.src | 11 |
8 files changed, 323 insertions, 265 deletions
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx index e08507a3d6b40..b3245f6327130 100644 --- a/dbaccess/source/ui/inc/UITools.hxx +++ b/dbaccess/source/ui/inc/UITools.hxx @@ -2,9 +2,9 @@ * * $RCSfile: UITools.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-07-16 07:50:32 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -157,6 +157,11 @@ namespace dbaui ::rtl::OUString createDefaultName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTables, const ::rtl::OUString& _sName); + + /** checks if the given name exists in the database context + */ + sal_Bool checkDataSourceAvailable( const ::rtl::OUString& _sDataSourceName, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory_xORB); // ......................................................................... } // ......................................................................... diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index c9851567e8492..252ae3ab06141 100644 --- a/dbaccess/source/ui/inc/dbu_resource.hrc +++ b/dbaccess/source/ui/inc/dbu_resource.hrc @@ -2,9 +2,9 @@ * * $RCSfile: dbu_resource.hrc,v $ * - * $Revision: 1.56 $ + * $Revision: 1.57 $ * - * last change: $Author: oj $ $Date: 2001-07-16 13:42:36 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:09 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -444,6 +444,8 @@ #define STR_QUERY_REL_DELETE_WINDOW RID_STRING_START + 182 #define STR_NO_TABLE_FORMAT_INSIDE RID_STRING_START + 183 #define STR_ERROR_PASSWORDS_NOT_IDENTICAL RID_STRING_START + 184 +#define STR_TABLEDESIGN_DATASOURCE_DELETED RID_STRING_START + 185 +#define STR_DATASOURCE_DELETED RID_STRING_START + 186 //======================================================================== // untyped resources @@ -458,6 +460,9 @@ /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.56 2001/07/16 13:42:36 oj + * #89650# check if table was created for html/rtf format + * * Revision 1.55 2001/07/09 06:56:48 oj * #88144# d&d for creating relations corrected * diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index e13bb94bd117d..25ddaa5c7b4be 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: UITools.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-16 07:53:20 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -555,6 +555,15 @@ void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDe } return sDefaultName; } +// ----------------------------------------------------------------------------- +sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) +{ + sal_Bool bRet = sal_False; + Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + if(xDataBaseContext.is()) + bRet = xDataBaseContext->hasByName(_sDataSourceName); + return bRet; +} // ......................................................................... } diff --git a/dbaccess/source/ui/querydesign/query.src b/dbaccess/source/ui/querydesign/query.src index fb998ac7aa59e..c3f65123da31e 100644 --- a/dbaccess/source/ui/querydesign/query.src +++ b/dbaccess/source/ui/querydesign/query.src @@ -2,9 +2,9 @@ * * $RCSfile: query.src,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: kz $ $Date: 2001-07-17 20:26:15 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2401,6 +2401,9 @@ Menu RID_QUERY_DESIGN_MAIN_MENU }; }; - - +String STR_DATASOURCE_DELETED +{ + Text = "Die zugehrige Datenquelle wurde gelscht. Es knnen keine dies bezglichen Daten gespeichert werden."; + Text [ ENGLISH ] = "The datasource was deleted. It is not possible to save datasource relevant data."; +}; diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 18b4417c3ca96..dfac0c67bbe5a 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.46 $ + * $Revision: 1.47 $ * - * last change: $Author: oj $ $Date: 2001-07-16 07:54:08 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -517,109 +517,107 @@ void OQueryController::Execute(sal_uInt16 _nId) void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException) { - OJoinController::initialize(aArguments); + OJoinController::initialize(aArguments); - // m_pWindow->initialize(m_xCurrentFrame); + PropertyValue aValue; + const Any* pBegin = aArguments.getConstArray(); + const Any* pEnd = pBegin + aArguments.getLength(); - PropertyValue aValue; - const Any* pBegin = aArguments.getConstArray(); - const Any* pEnd = pBegin + aArguments.getLength(); + for(;pBegin != pEnd;++pBegin) + { + if (!(*pBegin >>= aValue)) + continue; - for(;pBegin != pEnd;++pBegin) + if (0 == aValue.Name.compareToAscii(PROPERTY_ACTIVECONNECTION)) { - if (!(*pBegin >>= aValue)) - continue; - - if (0 == aValue.Name.compareToAscii(PROPERTY_ACTIVECONNECTION)) - { - ::cppu::extractInterface(m_xConnection,aValue.Value); - // be notified when connection is in disposing - Reference< XComponent > xComponent(m_xConnection, UNO_QUERY); - if (xComponent.is()) - { - Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); - xComponent->addEventListener(xEvtL); - } - } - else if(0 == aValue.Name.compareToAscii(PROPERTY_DATASOURCENAME)) - { - aValue.Value >>= m_sDataSourceName; - } - else if(0 == aValue.Name.compareToAscii(PROPERTY_CURRENTQUERY)) - { - aValue.Value >>= m_sName; - } - else if(0 == aValue.Name.compareToAscii(PROPERTY_QUERYDESIGNVIEW)) - { - m_bDesign = ::cppu::any2bool(aValue.Value); - } - else if(0 == aValue.Name.compareToAscii(PROPERTY_CREATEVIEW)) + ::cppu::extractInterface(m_xConnection,aValue.Value); + // be notified when connection is in disposing + Reference< XComponent > xComponent(m_xConnection, UNO_QUERY); + if (xComponent.is()) { - m_bCreateView = ::cppu::any2bool(aValue.Value); + Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); + xComponent->addEventListener(xEvtL); } } - - if (!m_xConnection.is()) - { // whoever instantiated us did not give us a connection to share. Okay, create an own one - createNewConnection(sal_False); + else if(0 == aValue.Name.compareToAscii(PROPERTY_DATASOURCENAME)) + { + aValue.Value >>= m_sDataSourceName; } - if (!m_xConnection.is()) - { // we have no connection so what else should we do - m_bDesign = sal_False; - if(m_bCreateView) - { - String aMessage(ModuleRes(RID_STR_CONNECTION_LOST)); - ODataView* pWindow = getView(); - InfoBox(pWindow, aMessage).Execute(); - throw SQLException(); - } + else if(0 == aValue.Name.compareToAscii(PROPERTY_CURRENTQUERY)) + { + aValue.Value >>= m_sName; } + else if(0 == aValue.Name.compareToAscii(PROPERTY_QUERYDESIGNVIEW)) + { + m_bDesign = ::cppu::any2bool(aValue.Value); + } + else if(0 == aValue.Name.compareToAscii(PROPERTY_CREATEVIEW)) + { + m_bCreateView = ::cppu::any2bool(aValue.Value); + } + } - // we need a datasource - if(m_xConnection.is()) + if (!m_xConnection.is()) + { // whoever instantiated us did not give us a connection to share. Okay, create an own one + createNewConnection(sal_False); + } + if (!m_xConnection.is()) + { // we have no connection so what else should we do + m_bDesign = sal_False; + if(m_bCreateView) { - Reference<XChild> xChild(m_xConnection,UNO_QUERY); - if(xChild.is()) - m_xDataSource = Reference< XPropertySet >(xChild->getParent(),UNO_QUERY); - // now we have to check if our database supports views - if(m_bCreateView) + String aMessage(ModuleRes(RID_STR_CONNECTION_LOST)); + ODataView* pWindow = getView(); + InfoBox(pWindow, aMessage).Execute(); + throw SQLException(); + } + } + + // we need a datasource + if(m_xConnection.is()) + { + Reference<XChild> xChild(m_xConnection,UNO_QUERY); + if(xChild.is()) + m_xDataSource = Reference< XPropertySet >(xChild->getParent(),UNO_QUERY); + // now we have to check if our database supports views + if(m_bCreateView) + { + static ::rtl::OUString sView = ::rtl::OUString::createFromAscii("VIEW"); + Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); + Reference<XResultSet> xRes = xMeta->getTableTypes(); + sal_Bool bFound = sal_False; + if(xRes.is()) { - static ::rtl::OUString sView = ::rtl::OUString::createFromAscii("VIEW"); - Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData(); - Reference<XResultSet> xRes = xMeta->getTableTypes(); - sal_Bool bFound = sal_False; - if(xRes.is()) + Reference<XRow> xRow(xRes,UNO_QUERY); + while(xRes->next()) { - Reference<XRow> xRow(xRes,UNO_QUERY); - while(xRes->next()) - { - ::rtl::OUString sValue = xRow->getString(1); - if(!xRow->wasNull() && sValue == sView) - bFound = sal_True; - } + ::rtl::OUString sValue = xRow->getString(1); + if(!xRow->wasNull() && sValue == sView) + bFound = sal_True; } - if(!bFound) - { // we can't create views so we ask if the user wants to create a query instead - m_bCreateView = sal_False; - sal_Bool bClose = sal_False; - { - String aTitle(ModuleRes(STR_QUERYDESIGN_NO_VIEW_SUPPORT)); - String aMessage(ModuleRes(STR_QUERYDESIGN_NO_VIEW_ASK)); - ODataView* pWindow = getView(); - OSQLMessageBox aDlg(pWindow,aTitle, aMessage,WB_YES_NO|WB_DEF_YES,OSQLMessageBox::Query); - bClose = aDlg.Execute() == RET_NO; - } - if(bClose) - throw Exception(); + } + if(!bFound) + { // we can't create views so we ask if the user wants to create a query instead + m_bCreateView = sal_False; + sal_Bool bClose = sal_False; + { + String aTitle(ModuleRes(STR_QUERYDESIGN_NO_VIEW_SUPPORT)); + String aMessage(ModuleRes(STR_QUERYDESIGN_NO_VIEW_ASK)); + ODataView* pWindow = getView(); + OSQLMessageBox aDlg(pWindow,aTitle, aMessage,WB_YES_NO|WB_DEF_YES,OSQLMessageBox::Query); + bClose = aDlg.Execute() == RET_NO; } + if(bClose) + throw Exception(); } } - else - { - Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); - xDatabaseContext->getByName(m_sDataSourceName) >>= m_xDataSource; - OSL_ENSURE(m_xDataSource.is(),"We need a datasource!"); - } + } + else + { + Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY); + xDatabaseContext->getByName(m_sDataSourceName) >>= m_xDataSource; + OSL_ENSURE(m_xDataSource.is(),"We need a datasource!"); + } try { // get command from the query if a query name was supplied @@ -1114,171 +1112,180 @@ void OQueryController::askForNewName(const Reference<XNameAccess>& _xElements,sa void OQueryController::doSaveAsDoc(sal_Bool _bSaveAs) { OSL_ENSURE(m_bEditable,"Slot ID_BROWSER_SAVEDOC should not be enabled!"); - - Reference<XNameAccess> xElements = getElements(); - if(xElements.is()) + if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_NAME)),getORB())) { - ::rtl::OUString sTranslatedStmt = translateStatement(); - - if(sTranslatedStmt.getLength()) + String aMessage(ModuleRes(STR_DATASOURCE_DELETED)); + String sTitle(ModuleRes(STR_STAT_WARNING)); + OSQLMessageBox aMsg(getView(),sTitle,aMessage); + aMsg.Execute(); + } + else + { + Reference<XNameAccess> xElements = getElements(); + if(xElements.is()) { - sal_Bool bNew = 0 == m_sName.getLength(); - bNew = bNew || _bSaveAs; - // first we need a name for our query so ask the user - askForNewName(xElements,_bSaveAs); + ::rtl::OUString sTranslatedStmt = translateStatement(); - // did we get a name - if(m_sName.getLength()) + if(sTranslatedStmt.getLength()) { - SQLExceptionInfo aInfo; - try + sal_Bool bNew = 0 == m_sName.getLength(); + bNew = bNew || _bSaveAs; + // first we need a name for our query so ask the user + askForNewName(xElements,_bSaveAs); + + // did we get a name + if(m_sName.getLength()) { - Reference<XPropertySet> xProp; - if(bNew || !xElements->hasByName(m_sName)) // just to make sure the query already exists + SQLExceptionInfo aInfo; + try { - if(xElements->hasByName(m_sName)) + Reference<XPropertySet> xProp; + if(bNew || !xElements->hasByName(m_sName)) // just to make sure the query already exists { - Reference<XDrop> xNameCont(xElements,UNO_QUERY); - OSL_ENSURE(xNameCont.is(),"Can not drop query!"); - if(xNameCont.is()) - xNameCont->dropByName(m_sName); - } + if(xElements->hasByName(m_sName)) + { + Reference<XDrop> xNameCont(xElements,UNO_QUERY); + OSL_ENSURE(xNameCont.is(),"Can not drop query!"); + if(xNameCont.is()) + xNameCont->dropByName(m_sName); + } - Reference<XDataDescriptorFactory> xFact(xElements,UNO_QUERY); - OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!"); - xProp = xFact->createDataDescriptor(); - OSL_ENSURE(xProp.is(),"OQueryController::Execute ID_BROWSER_SAVEDOC: Create query failed!"); - // to set the name is only allowed when the wuery is new - xProp->setPropertyValue(PROPERTY_NAME,makeAny(m_sName)); - } - else - { - xElements->getByName(m_sName) >>= xProp; - } + Reference<XDataDescriptorFactory> xFact(xElements,UNO_QUERY); + OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!"); + xProp = xFact->createDataDescriptor(); + OSL_ENSURE(xProp.is(),"OQueryController::Execute ID_BROWSER_SAVEDOC: Create query failed!"); + // to set the name is only allowed when the wuery is new + xProp->setPropertyValue(PROPERTY_NAME,makeAny(m_sName)); + } + else + { + xElements->getByName(m_sName) >>= xProp; + } - xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(sTranslatedStmt)); + xProp->setPropertyValue(PROPERTY_COMMAND,makeAny(sTranslatedStmt)); - // some properties are only valid for a query object - if(m_bCreateView) - { - xProp->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(m_sUpdateCatalogName)); - xProp->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(m_sUpdateSchemaName)); - } - else - { - xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(m_sUpdateTableName)); - xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(m_sUpdateCatalogName)); - xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(m_sUpdateSchemaName)); - xProp->setPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING,::cppu::bool2any(m_bEsacpeProcessing)); - - // now we save the layout information - // create the output stream - m_pWindow->getView()->SaveUIConfig(); - Sequence< sal_Int8 > aOutputSeq; + // some properties are only valid for a query object + if(m_bCreateView) { - Reference< XOutputStream> xOutStreamHelper = new OSequenceOutputStream(aOutputSeq); - Reference< XObjectOutputStream> xOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")),UNO_QUERY); - Reference< XOutputStream> xMarkOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")),UNO_QUERY); - Reference< XActiveDataSource >(xMarkOutStream,UNO_QUERY)->setOutputStream(xOutStreamHelper); - Reference< XActiveDataSource > xOutDataSource(xOutStream, UNO_QUERY); - OSL_ENSURE(xOutDataSource.is(),"Couldn't create com.sun.star.io.ObjectOutputStream!"); - xOutDataSource->setOutputStream(xMarkOutStream); - Save(xOutStream); + xProp->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(m_sUpdateCatalogName)); + xProp->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(m_sUpdateSchemaName)); } - xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aOutputSeq)); - } + else + { + xProp->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(m_sUpdateTableName)); + xProp->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(m_sUpdateCatalogName)); + xProp->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(m_sUpdateSchemaName)); + xProp->setPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING,::cppu::bool2any(m_bEsacpeProcessing)); - if(bNew) - { - Reference<XAppend> xAppend(xElements,UNO_QUERY); - OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); - xAppend->appendByDescriptor(xProp); + // now we save the layout information + // create the output stream + m_pWindow->getView()->SaveUIConfig(); + Sequence< sal_Int8 > aOutputSeq; + { + Reference< XOutputStream> xOutStreamHelper = new OSequenceOutputStream(aOutputSeq); + Reference< XObjectOutputStream> xOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")),UNO_QUERY); + Reference< XOutputStream> xMarkOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")),UNO_QUERY); + Reference< XActiveDataSource >(xMarkOutStream,UNO_QUERY)->setOutputStream(xOutStreamHelper); + Reference< XActiveDataSource > xOutDataSource(xOutStream, UNO_QUERY); + OSL_ENSURE(xOutDataSource.is(),"Couldn't create com.sun.star.io.ObjectOutputStream!"); + xOutDataSource->setOutputStream(xMarkOutStream); + Save(xOutStream); + } + xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aOutputSeq)); + } - if(m_bCreateView) + if(bNew) { - Reference<XPropertySet> xProp2; - if(xElements->hasByName(m_sName)) - xElements->getByName(m_sName) >>= xProp2; - if(!xProp2.is()) // correct name and try again - { - // it can be that someone inserted new data for us - ::rtl::OUString sCatalog,sSchema,sTable,sComposedName; - xProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; - xProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - xProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + Reference<XAppend> xAppend(xElements,UNO_QUERY); + OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); + xAppend->appendByDescriptor(xProp); - ::dbtools::composeTableName(m_xConnection->getMetaData(),sCatalog,sSchema,sTable,sComposedName,sal_False); - m_sName = sComposedName; - } - // now check if our datasource has set a tablefilter and if append the new table name to it - Reference< XChild> xChild(m_xConnection,UNO_QUERY); - if(xChild.is()) + if(m_bCreateView) { - Reference< XPropertySet> xDSProp(xChild->getParent(),UNO_QUERY); - if(xDSProp.is()) + Reference<XPropertySet> xProp2; + if(xElements->hasByName(m_sName)) + xElements->getByName(m_sName) >>= xProp2; + if(!xProp2.is()) // correct name and try again { - Sequence< ::rtl::OUString > aFilter; - xDSProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter; - // first check if we have something like SCHEMA.% - sal_Bool bHasToInsert = sal_True; - static ::rtl::OUString sPattern = ::rtl::OUString::createFromAscii("%"); - const ::rtl::OUString* pBegin = aFilter.getConstArray(); - const ::rtl::OUString* pEnd = pBegin + aFilter.getLength(); - for (;pBegin != pEnd; ++pBegin) + // it can be that someone inserted new data for us + ::rtl::OUString sCatalog,sSchema,sTable,sComposedName; + xProp->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; + xProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + xProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + + ::dbtools::composeTableName(m_xConnection->getMetaData(),sCatalog,sSchema,sTable,sComposedName,sal_False); + m_sName = sComposedName; + } + // now check if our datasource has set a tablefilter and if append the new table name to it + Reference< XChild> xChild(m_xConnection,UNO_QUERY); + if(xChild.is()) + { + Reference< XPropertySet> xDSProp(xChild->getParent(),UNO_QUERY); + if(xDSProp.is()) { - if(pBegin->indexOf('%') != -1) + Sequence< ::rtl::OUString > aFilter; + xDSProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter; + // first check if we have something like SCHEMA.% + sal_Bool bHasToInsert = sal_True; + static ::rtl::OUString sPattern = ::rtl::OUString::createFromAscii("%"); + const ::rtl::OUString* pBegin = aFilter.getConstArray(); + const ::rtl::OUString* pEnd = pBegin + aFilter.getLength(); + for (;pBegin != pEnd; ++pBegin) { - sal_Int32 nLen; - if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(m_sName,nLen)) - bHasToInsert = sal_False; - else if(pBegin->getLength() == 1) - bHasToInsert = sal_False; + if(pBegin->indexOf('%') != -1) + { + sal_Int32 nLen; + if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(m_sName,nLen)) + bHasToInsert = sal_False; + else if(pBegin->getLength() == 1) + bHasToInsert = sal_False; + } + } + if(bHasToInsert) + { + aFilter.realloc(aFilter.getLength()+1); + aFilter.getArray()[aFilter.getLength()-1] = m_sName; + xDSProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter)); + Reference<XFlushable> xFlush(xDSProp,UNO_QUERY); + if(xFlush.is()) + xFlush->flush(); } - } - if(bHasToInsert) - { - aFilter.realloc(aFilter.getLength()+1); - aFilter.getArray()[aFilter.getLength()-1] = m_sName; - xDSProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter)); - Reference<XFlushable> xFlush(xDSProp,UNO_QUERY); - if(xFlush.is()) - xFlush->flush(); } } } } + else + { + Reference<XFlushable> xFlush(xProp,UNO_QUERY); + if(xFlush.is()) + xFlush->flush(); + } + setModified(sal_False); } - else + catch(SQLContext& e) { - Reference<XFlushable> xFlush(xProp,UNO_QUERY); - if(xFlush.is()) - xFlush->flush(); + m_sName = ::rtl::OUString(); + aInfo = SQLExceptionInfo(e); } - setModified(sal_False); - } - catch(SQLContext& e) - { - m_sName = ::rtl::OUString(); - aInfo = SQLExceptionInfo(e); - } - catch(SQLWarning& e) - { - m_sName = ::rtl::OUString(); - aInfo = SQLExceptionInfo(e); - } - catch(SQLException& e) - { - m_sName = ::rtl::OUString(); - aInfo = SQLExceptionInfo(e); - } - catch(Exception&) - { - m_sName = ::rtl::OUString(); - OSL_ENSURE(0,"OQueryController::doSaveAsDoc: Query could not be inserted!"); + catch(SQLWarning& e) + { + m_sName = ::rtl::OUString(); + aInfo = SQLExceptionInfo(e); + } + catch(SQLException& e) + { + m_sName = ::rtl::OUString(); + aInfo = SQLExceptionInfo(e); + } + catch(Exception&) + { + m_sName = ::rtl::OUString(); + OSL_ENSURE(0,"OQueryController::doSaveAsDoc: Query could not be inserted!"); + } + showError(aInfo); } - showError(aInfo); } } } diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx index b0f7bf58a0fed..14c4e98bf1113 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.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-06-28 14:24:04 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -282,31 +282,41 @@ void ORelationController::Execute(sal_uInt16 _nId) case ID_BROWSER_SAVEDOC: { OSL_ENSURE(m_bEditable,"Slot ID_BROWSER_SAVEDOC should not be enabled!"); - // now we save the layout information - // create the output stream - try + if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_NAME)),getORB())) { - Sequence< sal_Int8 > aOutputSeq; - if(m_xDataSource.is() && m_xDataSource->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION)) + String aMessage(ModuleRes(STR_DATASOURCE_DELETED)); + String sTitle(ModuleRes(STR_STAT_WARNING)); + OSQLMessageBox aMsg(getView(),sTitle,aMessage); + aMsg.Execute(); + } + else + { + // now we save the layout information + // create the output stream + try { - Reference< XOutputStream> xOutStreamHelper = new OSequenceOutputStream(aOutputSeq); - Reference< XObjectOutputStream> xOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")),UNO_QUERY); - Reference< XOutputStream> xMarkOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")),UNO_QUERY); - Reference< XActiveDataSource >(xMarkOutStream,UNO_QUERY)->setOutputStream(xOutStreamHelper); - Reference< XActiveDataSource > xOutDataSource(xOutStream, UNO_QUERY); - OSL_ENSURE(xOutDataSource.is(),"Couldn't create com.sun.star.io.ObjectOutputStream!"); - xOutDataSource->setOutputStream(xMarkOutStream); - Save(xOutStream); + Sequence< sal_Int8 > aOutputSeq; + 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); + Reference< XOutputStream> xMarkOutStream(getORB()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")),UNO_QUERY); + Reference< XActiveDataSource >(xMarkOutStream,UNO_QUERY)->setOutputStream(xOutStreamHelper); + Reference< XActiveDataSource > xOutDataSource(xOutStream, UNO_QUERY); + OSL_ENSURE(xOutDataSource.is(),"Couldn't create com.sun.star.io.ObjectOutputStream!"); + xOutDataSource->setOutputStream(xMarkOutStream); + Save(xOutStream); - m_xDataSource->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aOutputSeq)); - Reference<XFlushable> xFlush(m_xDataSource,UNO_QUERY); - if(xFlush.is()) - xFlush->flush(); - setModified(sal_False); + m_xDataSource->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aOutputSeq)); + Reference<XFlushable> xFlush(m_xDataSource,UNO_QUERY); + if(xFlush.is()) + xFlush->flush(); + setModified(sal_False); + } + } + catch(Exception&) + { } - } - catch(Exception&) - { } } break; diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 955c5c2f83843..90d154b930d2d 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableController.cxx,v $ * - * $Revision: 1.44 $ + * $Revision: 1.45 $ * - * last change: $Author: oj $ $Date: 2001-07-16 07:55:35 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -517,6 +517,7 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs) Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY); if(xProp.is()) { + Sequence< ::rtl::OUString > aFilter; xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter; // first check if we have something like SCHEMA.% @@ -537,12 +538,23 @@ sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs) } if(bHasToInsert) { - aFilter.realloc(aFilter.getLength()+1); - aFilter.getArray()[aFilter.getLength()-1] = m_sName; - xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter)); - Reference<XFlushable> xFlush(xProp,UNO_QUERY); - if(xFlush.is()) - xFlush->flush(); + if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),getORB())) + { + String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED)); + String sTitle(ModuleRes(STR_STAT_WARNING)); + OSQLMessageBox aMsg(getView(),sTitle,aMessage); + aMsg.Execute(); + return sal_False; + } + else + { + aFilter.realloc(aFilter.getLength()+1); + aFilter.getArray()[aFilter.getLength()-1] = m_sName; + xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter)); + Reference<XFlushable> xFlush(xProp,UNO_QUERY); + if(xFlush.is()) + xFlush->flush(); + } } } } diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index dbfc457717d6c..649cea831d1ea 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -2,9 +2,9 @@ * * $RCSfile: table.src,v $ * - * $Revision: 1.32 $ + * $Revision: 1.33 $ * - * last change: $Author: kz $ $Date: 2001-07-17 20:26:29 $ + * last change: $Author: oj $ $Date: 2001-07-18 08:51:19 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1810,6 +1810,13 @@ String STR_TABLEDESIGN_CONNECTION_MISSING Text[ catalan ] = "The table couldn't be saved due to connection problems."; Text[ finnish ] = "Die Tabelle konnte nicht gespeichert werden, da keine Verbindung zur Datenbank hergestellt werden konnte."; }; +String STR_TABLEDESIGN_DATASOURCE_DELETED +{ + Text = "Der Tabellenfilter konnte nicht angepasst werden, da die Datenquelle gelscht wurde."; + Text [ english_us ] = "The table filter could not be saved because the datasource was deleted before."; + Text [ english ] = "The table filter could not be saved because the datasource was deleted before."; +}; + FixedText FIXED_NO_CONNECTION { Pos = MAP_APPFONT ( 0,0 ) ; |