diff options
-rw-r--r-- | dbaccess/source/ui/dlg/dlgsave.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/FieldControls.hxx | 41 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/JoinController.hxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/RelationController.hxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/TableController.hxx | 7 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/browserids.hxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/dbu_resource.hrc | 10 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/querycontroller.hxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/JoinController.cxx | 5 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryViewSwitch.cxx | 8 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 146 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 102 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableFieldControl.cxx | 10 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/table.src | 37 |
14 files changed, 264 insertions, 134 deletions
diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx index e8cf90530ec1..8905154570ee 100644 --- a/dbaccess/source/ui/dlg/dlgsave.cxx +++ b/dbaccess/source/ui/dlg/dlgsave.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dlgsave.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-03-02 11:43:45 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -143,6 +143,7 @@ OSaveAsDlg::OSaveAsDlg( Window * pParent, break; case CommandType::TABLE: { + OSL_ENSURE(m_xMetaData.is(),"The metadata can not be null!"); if(m_aName.Search('.') != STRING_NOTFOUND) { ::rtl::OUString sCatalog,sSchema,sTable; @@ -213,6 +214,7 @@ IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton) sal_Bool bError = m_xNames->hasByName(m_aName); if(m_nType == CommandType::TABLE) { + OSL_ENSURE(m_xMetaData.is(),"The metadata can not be null!"); ::rtl::OUString sComposedName; ::dbtools::composeTableName(m_xMetaData,getCatalog(),getSchema(),m_aName,sComposedName,sal_False); bError = m_xNames->hasByName(sComposedName); diff --git a/dbaccess/source/ui/inc/FieldControls.hxx b/dbaccess/source/ui/inc/FieldControls.hxx index 70ceb79ee972..450398a56c52 100644 --- a/dbaccess/source/ui/inc/FieldControls.hxx +++ b/dbaccess/source/ui/inc/FieldControls.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FieldControls.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-02-14 14:36:47 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,9 +61,6 @@ #ifndef DBAUI_FIELDCONTROLS_HXX #define DBAUI_FIELDCONTROLS_HXX -#ifndef _SV_EDIT_HXX -#include <vcl/edit.hxx> -#endif #ifndef _SV_FIELD_HXX #include <vcl/field.hxx> #endif @@ -76,6 +73,10 @@ #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif +#ifndef DBAUI_SQLNAMEEDIT_HXX +#include "SqlNameEdit.hxx" +#endif + namespace dbaui { @@ -93,6 +94,36 @@ namespace dbaui virtual void SetSpecialReadOnly(BOOL _bReadOnly) = 0; }; //================================================================== + class OPropColumnEditCtrl : public OSQLNameEdit + ,public OSpecialReadOnly + { + short m_nPos; + String m_strHelpText; + public: + inline OPropColumnEditCtrl(Window* pParent, ::rtl::OUString& _rAllowedChars, INT32 nHelpId, short nPosition = -1, WinBits nWinStyle = 0); + + inline BOOL IsModified() { return GetText() != GetSavedValue(); } + + short GetPos() const { return m_nPos; } + String GetHelp() const { return m_strHelpText; } + + virtual void SetSpecialReadOnly(BOOL _bReadOnly) + { + SetReadOnly(_bReadOnly); + OSpecialReadOnly::SetSpecialReadOnly(_bReadOnly,this); + } + }; + inline OPropColumnEditCtrl::OPropColumnEditCtrl(Window* pParent, + ::rtl::OUString& _rAllowedChars, + INT32 nHelpId, + short nPosition, + WinBits nWinStyle) + :OSQLNameEdit(pParent, _rAllowedChars,nWinStyle) + ,m_nPos(nPosition) + { + m_strHelpText = String(ModuleRes(nHelpId)); + } + //================================================================== class OPropEditCtrl : public Edit ,public OSpecialReadOnly { diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx index 22141e62f7f0..da218d8704f7 100644 --- a/dbaccess/source/ui/inc/JoinController.hxx +++ b/dbaccess/source/ui/inc/JoinController.hxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinController.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-03-01 15:17:54 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,9 @@ #ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_ #include <com/sun/star/io/XObjectInputStream.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif #ifndef DBAUI_JOINTABLEVIEW_HXX #include "JoinTableView.hxx" #endif @@ -103,6 +106,7 @@ namespace dbaui Fraction m_aZoom; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource; ::rtl::OUString m_sDataSourceName; // is set in initialze diff --git a/dbaccess/source/ui/inc/RelationController.hxx b/dbaccess/source/ui/inc/RelationController.hxx index 5f6a65effddf..7f30f1bdd20c 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.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2001-03-01 13:27:03 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,9 +64,6 @@ #ifndef DBAUI_JOINCONTROLLER_HXX #include "JoinController.hxx" #endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ -#include <com/sun/star/beans/XPropertySet.hpp> -#endif #ifndef DBAUI_RELATIONDESIGNVIEW_HXX #include "RelationDesignView.hxx" #endif @@ -81,7 +78,6 @@ namespace dbaui class OTableWindow; class ORelationController : public OJoinController { - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xTables; protected: // all the features which should be handled by this class diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx index 2b06bf9d91bb..2aa7b8e236fc 100644 --- a/dbaccess/source/ui/inc/TableController.hxx +++ b/dbaccess/source/ui/inc/TableController.hxx @@ -2,9 +2,9 @@ * * $RCSfile: TableController.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-03-12 14:05:44 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,7 +95,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #endif - +class FixedText; namespace dbaui { class OTableRow; @@ -112,6 +112,7 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier + FixedText* m_pNoConnection; // set in toolbox when no connection is available ::rtl::OUString m_sDataSourceName; // is set in initialze ::rtl::OUString m_sCatalogName; // catalog for update data ::rtl::OUString m_sSchemaName; // schema for update data diff --git a/dbaccess/source/ui/inc/browserids.hxx b/dbaccess/source/ui/inc/browserids.hxx index dfdd670e4f53..b3fd86d3a90b 100644 --- a/dbaccess/source/ui/inc/browserids.hxx +++ b/dbaccess/source/ui/inc/browserids.hxx @@ -2,9 +2,9 @@ * * $RCSfile: browserids.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: fs $ $Date: 2001-03-01 10:33:23 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,7 @@ #define ID_TREE_QUERY_COPY 12 #define ID_TREE_TABLE_PASTE 13 #define ID_TREE_RELATION_DESIGN 14 +#define ID_TABLE_DESIGN_NO_CONNECTION 15 #define ID_BROWSER_QUERY_EXECUTE SID_FM_EXECUTE #define ID_BROWSER_CLEAR_QUERY SID_SBA_CLEAR_QUERY diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc index 08b14e7679b2..ede961eb1ce9 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.29 $ + * $Revision: 1.30 $ * - * last change: $Author: fs $ $Date: 2001-03-02 17:05:09 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -148,6 +148,7 @@ #define QUERY_BRW_DELETE_QUERY_CONFIRM RID_QUERYBOX_START + 3 #define QUERY_DESIGN_SAVEMODIFIED RID_QUERYBOX_START + 4 #define TABLE_DESIGN_SAVEMODIFIED RID_QUERYBOX_START + 5 +#define TABLE_QUERY_CONNECTION_LOST RID_QUERYBOX_START + 6 //======================================================================== // warning boxes @@ -346,6 +347,7 @@ #define STR_RELATIONDESIGN_NOT_AVAILABLE RID_STRING_START + 127 #define STR_OPENTABLES_WARNINGS RID_STRING_START + 128 #define STR_OPENTABLES_WARNINGS_DETAILS RID_STRING_START + 129 +#define STR_TABLEDESIGN_CONNECTION_MISSING RID_STRING_START + 130 //======================================================================== @@ -354,12 +356,16 @@ #define RSC_DATASOURCE_TYPES RID_UNTYPED_START + 1 #define RSC_CHARSETS RID_UNTYPED_START + 2 #define PB_FORMAT RID_UNTYPED_START + 3 +#define FIXED_NO_CONNECTION RID_UNTYPED_START + 4 #endif // _DBU_RESOURCE_HRC_ /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.29 2001/03/02 17:05:09 fs + * +RID_OPENTABLES_WARNINGS* + * * Revision 1.28 2001/03/01 15:22:17 oj * #84511# change message * diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx index 03ce6099210f..86e8d555314f 100644 --- a/dbaccess/source/ui/inc/querycontroller.hxx +++ b/dbaccess/source/ui/inc/querycontroller.hxx @@ -2,9 +2,9 @@ * * $RCSfile: querycontroller.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-03-01 15:17:54 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,6 +141,7 @@ namespace dbaui sal_Bool m_bViewFunction; // show the function row in the design view sal_Bool m_bEsacpeProcessing;// is true when we shouldn't parse the statement + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getQueries(); // creates the querycomposer void setQueryComposer(); diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx index b462e7ddba10..133fbd63d7dc 100644 --- a/dbaccess/source/ui/querydesign/JoinController.cxx +++ b/dbaccess/source/ui/querydesign/JoinController.cxx @@ -2,9 +2,9 @@ * * $RCSfile: JoinController.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-03-01 15:17:54 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -225,6 +225,7 @@ void OJoinController::disposing() ::comphelper::disposeComponent(m_xConnection); } m_xConnection = NULL; + m_xDataSource = NULL; } // ----------------------------------------------------------------------------- SfxUndoManager* OJoinController::getUndoMgr() diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx index 065d238dbafa..2f2c256d76f8 100644 --- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx +++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx @@ -2,9 +2,9 @@ * * $RCSfile: QueryViewSwitch.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-02-28 10:18:26 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -224,7 +224,7 @@ void OQueryViewSwitch::paste() // ----------------------------------------------------------------------------- void OQueryViewSwitch::switchView() { - m_pTextView->Show(!m_pTextView->IsVisible()); + m_pTextView->Show(!static_cast<OQueryController*>(m_pDesignView->getController())->isDesignMode()); ToolBox* pToolBox = m_pDesignView->getToolBox(); if(pToolBox && m_pTextView->IsVisible()) @@ -261,7 +261,7 @@ void OQueryViewSwitch::switchView() getAddTableDialog()->Update(); m_pDesignView->InitFromParseNode(); // only show the view when the data is inserted - m_pDesignView->Show(!m_pDesignView->IsVisible()); + m_pDesignView->Show(static_cast<OQueryController*>(m_pDesignView->getController())->isDesignMode()); } m_pDesignView->Resize(); } diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 6fe1e1784029..9649750ca2af 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.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-03-12 15:09:37 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,6 +115,9 @@ #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueriesSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_ +#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> +#endif #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> #endif @@ -280,12 +283,12 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) { FeatureState aReturn; // (disabled automatically) - aReturn.bEnabled = m_xConnection.is(); - if(!m_xConnection.is()) // so what should otherwise happen - { - aReturn.aState = ::cppu::bool2any(sal_False); - return aReturn; - } +// aReturn.bEnabled = m_xConnection.is(); +// if(!m_xConnection.is()) // so what should otherwise happen +// { +// aReturn.aState = ::cppu::bool2any(sal_False); +// return aReturn; +// } switch (_nId) { @@ -296,10 +299,10 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) aReturn.aState = ::cppu::bool2any(m_bEditable); break; case ID_BROWSER_SAVEASDOC: - aReturn.bEnabled = m_xConnection.is() && (!m_bDesign || (m_vTableFieldDesc.size() && m_vTableData.size())); + aReturn.bEnabled = (!m_bDesign || (m_vTableFieldDesc.size() && m_vTableData.size())); break; case ID_BROWSER_SAVEDOC: - aReturn.bEnabled = m_xConnection.is() && m_bModified && (!m_bDesign || (m_vTableFieldDesc.size() && m_vTableData.size())); + aReturn.bEnabled = m_bModified && (!m_bDesign || (m_vTableFieldDesc.size() && m_vTableData.size())); break; case SID_PRINTDOCDIRECT: break; @@ -312,7 +315,7 @@ FeatureState OQueryController::GetState(sal_uInt16 _nId) aReturn.bEnabled = m_bEditable; break; case ID_BROWSER_SQL: - aReturn.bEnabled = m_bEsacpeProcessing; + aReturn.bEnabled = m_bEsacpeProcessing && m_pSqlIterator; aReturn.aState = ::cppu::bool2any(m_bDesign); break; case ID_BROWSER_CLEAR_QUERY: @@ -355,13 +358,9 @@ void OQueryController::Execute(sal_uInt16 _nId) { OSL_ENSURE(m_bEditable,"Slot ID_BROWSER_SAVEDOC should not be enabled!"); - Reference<XQueriesSupplier> xQuerySup(m_xConnection,UNO_QUERY); - if(xQuerySup.is()) + Reference<XNameAccess> xQueries = getQueries(); + if(xQueries.is()) { - OSL_ENSURE(xQuerySup.is(),"Parent must be a datasource!"); - Reference<XNameAccess> xQueries(xQuerySup->getQueries(),UNO_QUERY); - OSL_ENSURE(xQueries.is(),"The queries can't be null!"); - // first we need a name for our query so ask the user sal_Bool bNew = 0 == m_sName.getLength(); bNew = bNew || (ID_BROWSER_SAVEASDOC == _nId); @@ -377,7 +376,7 @@ void OQueryController::Execute(sal_uInt16 _nId) aDefaultName = String(::dbtools::createUniqueName(xQueries,aName)); } - OSaveAsDlg aDlg(getView(),CommandType::QUERY,xQueries,m_xConnection->getMetaData(),aDefaultName,(ID_BROWSER_SAVEASDOC == _nId)); + OSaveAsDlg aDlg(getView(),CommandType::QUERY,xQueries,m_xConnection.is() ? m_xConnection->getMetaData() : NULL,aDefaultName,(ID_BROWSER_SAVEASDOC == _nId)); if(aDlg.Execute() == RET_OK) m_sName = aDlg.getName(); } @@ -393,7 +392,9 @@ void OQueryController::Execute(sal_uInt16 _nId) if(xQueries->hasByName(m_sName)) { Reference<XDrop> xNameCont(xQueries,UNO_QUERY); - xNameCont->dropByName(m_sName); + OSL_ENSURE(xNameCont.is(),"Can not drop query!"); + if(xNameCont.is()) + xNameCont->dropByName(m_sName); } Reference<XDataDescriptorFactory> xFact(xQueries,UNO_QUERY); @@ -433,14 +434,15 @@ void OQueryController::Execute(sal_uInt16 _nId) break; } } - else if(!m_bEsacpeProcessing && m_sStatement.getLength()) - sTranslatedStmt = m_sStatement; else if(!m_sStatement.getLength()) { ErrorBox aBox( getQueryView(), ModuleRes( ERR_QRY_NOSELECT ) ); aBox.Execute(); break; } + else + sTranslatedStmt = m_sStatement; + xQuery->setPropertyValue(PROPERTY_COMMAND,makeAny(sTranslatedStmt)); xQuery->setPropertyValue(CONFIGKEY_QRYDESCR_USE_ESCAPE_PROCESSING,::cppu::bool2any(m_bEsacpeProcessing)); xQuery->setPropertyValue(CONFIGKEY_QRYDESCR_UPDATE_TABLENAME,makeAny(m_sUpdateTableName)); @@ -501,7 +503,7 @@ void OQueryController::Execute(sal_uInt16 _nId) { ::rtl::OUString aErrorMsg; m_sStatement = m_pWindow->getView()->getStatement(); - if(!m_sStatement.getLength()) + if(!m_sStatement.getLength() && m_pSqlIterator) { // change the view of the data delete m_pSqlIterator->getParseTree(); @@ -606,7 +608,7 @@ void OQueryController::Execute(sal_uInt16 _nId) break; } } - else if(!m_bEsacpeProcessing) + else sTranslatedStmt = m_sStatement; if(m_sDataSourceName.getLength() && sTranslatedStmt.getLength()) { @@ -746,19 +748,28 @@ void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) if (!m_xConnection.is()) // we have no connection so what else should we do m_bDesign = sal_False; + // 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); + } + 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!"); + } // get command from the query if a query name was supplied if(m_sName.getLength()) { - Reference<XNameAccess> xNameAccess; - Reference<XQueriesSupplier> xSup(m_xConnection,UNO_QUERY); - if(xSup.is()) + Reference<XNameAccess> xQueries = getQueries(); + if(xQueries.is()) { - xNameAccess = xSup->getQueries(); - OSL_ENSURE(xNameAccess.is(),"no nameaccess for the queries!"); - Reference<XPropertySet> xProp; - if(xNameAccess->hasByName(m_sName) && ::cppu::extractInterface(xProp,xNameAccess->getByName(m_sName)) && xProp.is()) + if(xQueries->hasByName(m_sName) && ::cppu::extractInterface(xProp,xQueries->getByName(m_sName)) && xProp.is()) { xProp->getPropertyValue(PROPERTY_COMMAND) >>= m_sStatement; m_bEsacpeProcessing = ::cppu::any2bool(xProp->getPropertyValue(PROPERTY_USE_ESCAPE_PROCESSING)); @@ -787,13 +798,21 @@ void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) // m_pParseNode = pNode; if(pNode) { - delete m_pSqlIterator->getParseTree(); - m_pSqlIterator->setParseTree(pNode); - m_pSqlIterator->traverseAll(); - SQLWarning aWarning = m_pSqlIterator->getWarning(); - if(aWarning.Message.getLength()) + if(m_pSqlIterator) { - showError(SQLExceptionInfo(aWarning)); + delete m_pSqlIterator->getParseTree(); + m_pSqlIterator->setParseTree(pNode); + m_pSqlIterator->traverseAll(); + SQLWarning aWarning = m_pSqlIterator->getWarning(); + if(aWarning.Message.getLength()) + { + showError(SQLExceptionInfo(aWarning)); + m_bDesign = sal_False; + } + } + else + { + delete pNode; m_bDesign = sal_False; } } @@ -806,28 +825,21 @@ void SAL_CALL OQueryController::initialize( const Sequence< Any >& aArguments ) } } } + } else setQueryComposer(); - if(!m_xFormatter.is()) + if(!m_xFormatter.is() && m_xDataSource.is()) { - Reference< XChild> xChild(m_xConnection,UNO_QUERY); - if(xChild.is()) + Reference< XNumberFormatsSupplier> xSupplier; + ::cppu::extractInterface(xSupplier,m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER)); + if(xSupplier.is()) { - Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY); - if(xProp.is()) - { - Reference< XNumberFormatsSupplier> xSupplier; - ::cppu::extractInterface(xSupplier,xProp->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER)); - if(xSupplier.is()) - { - m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(getORB() - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); - m_xFormatter->attachNumberFormatsSupplier(xSupplier); - } - } - OSL_ENSURE(m_xFormatter.is(),"No NumberFormatter!"); + m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(getORB() + ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + m_xFormatter->attachNumberFormatsSupplier(xSupplier); } + OSL_ENSURE(m_xFormatter.is(),"No NumberFormatter!"); } m_pWindow->getView()->initialize(); getUndoMgr()->Clear(); @@ -964,7 +976,10 @@ void SAL_CALL OQueryController::disposing( const EventObject& Source ) throw(Run // ----------------------------------------------------------------------------- void OQueryController::createNewConnection(sal_Bool _bUI) { + delete m_pSqlIterator; + m_pSqlIterator = NULL; ::comphelper::disposeComponent(m_xComposer); + OJoinController::createNewConnection(_bUI); if (m_xConnection.is()) { @@ -974,6 +989,16 @@ void OQueryController::createNewConnection(sal_Bool _bUI) InvalidateFeature(ID_BROWSER_ADDTABLE); setQueryComposer(); } + else + { + if(m_bDesign) + { + m_bDesign = sal_False; + // don't call Execute(SQL) because this changes the sql statement + m_pWindow->switchView(); + } + InvalidateAll(); + } } // ----------------------------------------------------------------------------- void OQueryController::Save(const Reference< XObjectOutputStream>& _rxOut) @@ -1028,8 +1053,21 @@ OTableWindowData* OQueryController::createTableWindowData() { return new OQueryTableWindowData(); } - // ----------------------------------------------------------------------------- - +Reference<XNameAccess> OQueryController::getQueries() +{ + Reference<XNameAccess> xQueries; + Reference<XQueriesSupplier> xConSup(m_xConnection,UNO_QUERY); + if(xConSup.is()) + xQueries = xConSup->getQueries(); + else + { + Reference<XQueryDefinitionsSupplier> xSup(m_xDataSource,UNO_QUERY); + if(xSup.is()) + xQueries = xSup->getQueryDefinitions(); + } + return xQueries; +} +// ----------------------------------------------------------------------------- diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index c33a390863e1..512dfff08d73 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.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-03-12 14:47:40 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -140,12 +140,6 @@ #ifndef _COMPHELPER_STREAMSECTION_HXX_ #include <comphelper/streamsection.hxx> #endif -//#ifndef _COMPHELPER_BASIC_IO_HXX_ -//#include <comphelper/basicio.hxx> -//#endif -//#ifndef _COMPHELPER_SEQSTREAM_HXX -//#include <comphelper/seqstream.hxx> -//#endif #ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ #include <com/sun/star/io/XActiveDataSource.hpp> #endif @@ -235,6 +229,7 @@ OTableController::OTableController(const Reference< XMultiServiceFactory >& _rM) ,m_bOwnConnection(sal_False) ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES)) ,m_bNew(sal_True) + ,m_pNoConnection(NULL) { InvalidateAll(); } @@ -251,6 +246,7 @@ OTableController::~OTableController() void OTableController::disposing() { OGenericUnoController::disposing(); + delete m_pView; m_pView = NULL; @@ -276,6 +272,9 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) switch (_nId) { + case ID_TABLE_DESIGN_NO_CONNECTION: + aReturn.aState = ::cppu::bool2any(m_xConnection.is()); + break; case ID_BROWSER_EDITDOC: aReturn.aState = ::cppu::bool2any(m_bEditable); aReturn.bEnabled = m_bNew || m_bEditable; @@ -284,7 +283,7 @@ FeatureState OTableController::GetState(sal_uInt16 _nId) aReturn.bEnabled = m_xConnection.is(); break; case ID_BROWSER_SAVEDOC: - aReturn.bEnabled = m_xConnection.is() && m_bModified; + aReturn.bEnabled = m_bModified; break; case ID_BROWSER_CUT: aReturn.bEnabled = m_bEditable && static_cast<OTableDesignView*>(getView())->isCutAllowed(); @@ -308,6 +307,10 @@ void OTableController::Execute(sal_uInt16 _nId) { switch(_nId) { + case ID_TABLE_DESIGN_NO_CONNECTION: + if(!m_xConnection.is()) + createNewConnection(sal_False); // ask the user for a new connection + break; case ID_BROWSER_EDITDOC: m_bEditable = !m_bEditable; static_cast<OTableDesignView*>(getView())->setReadOnly(!m_bEditable); @@ -317,8 +320,8 @@ void OTableController::Execute(sal_uInt16 _nId) case ID_BROWSER_SAVEASDOC: case ID_BROWSER_SAVEDOC: { - OSL_ENSURE(m_bEditable,"Slot ID_BROWSER_SAVEDOC should not be enabled!"); - + if(!m_xConnection.is()) + createNewConnection(sal_True); // ask the user for a new connection Reference<XTablesSupplier> xTablesSup(m_xConnection,UNO_QUERY); if(xTablesSup.is()) { @@ -394,9 +397,8 @@ void OTableController::Execute(sal_uInt16 _nId) OSL_ENSURE(xAppend.is(),"No XAppend Interface!"); xAppend->appendByDescriptor(xTable); - if(xTables->hasByName(m_sName)) - xTables->getByName(m_sName) >>= m_xTable; - else + assignTable(); + if(!m_xTable.is()) // correct name and try again { // it can be that someone inserted new data for us ::rtl::OUString sCatalog,sSchema,sTable,sComposedName; @@ -405,17 +407,8 @@ void OTableController::Execute(sal_uInt16 _nId) xTable->getPropertyValue(PROPERTY_NAME) >>= sTable; ::dbtools::composeTableName(m_xConnection->getMetaData(),sCatalog,sSchema,sTable,sComposedName,sal_False); - if(xTables->hasByName(sComposedName)) - xTables->getByName(sComposedName) >>= m_xTable; - else - m_xTable = NULL; - } - // be notified when the table is in disposing - Reference< XComponent > xComponent(m_xTable, UNO_QUERY); - if (xComponent.is()) - { - Reference<XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); - xComponent->addEventListener(xEvtL); + m_sName = sComposedName; + assignTable(); } } else if(m_xTable.is()) @@ -451,6 +444,13 @@ void OTableController::Execute(sal_uInt16 _nId) showError(aInfo); } } + else + { + String aMessage(ModuleRes(STR_TABLEDESIGN_CONNECTION_MISSING)); + String sTitle(ModuleRes(STR_STAT_WARNING)); + OSQLMessageBox aMsg(getView(),sTitle,aMessage); + aMsg.Execute(); + } } break; case ID_BROWSER_CUT: @@ -480,8 +480,6 @@ void SAL_CALL OTableController::initialize( const Sequence< Any >& aArguments ) { OGenericUnoController::initialize(aArguments); - // m_pWindow->initialize(m_xCurrentFrame); - PropertyValue aValue; const Any* pBegin = aArguments.getConstArray(); const Any* pEnd = pBegin + aArguments.getLength(); @@ -521,8 +519,6 @@ void SAL_CALL OTableController::initialize( const Sequence< Any >& aArguments ) ODataView* pWindow = getView(); InfoBox(pWindow, aMessage).Execute(); } - dispose(); - return; } assignTable(); @@ -656,6 +652,7 @@ void SAL_CALL OTableController::disposing( const EventObject& Source ) throw(Run { m_bNew = sal_True; setModified(sal_True); + InvalidateAll(); } } else if(Reference<XPropertySet>(Source.Source,UNO_QUERY) == m_xTable) @@ -679,14 +676,29 @@ void OTableController::Load(const Reference< XObjectInputStream>& _rxIn) // ----------------------------------------------------------------------------- void OTableController::createNewConnection(sal_Bool _bUI) { - m_xConnection = NULL; - m_bOwnConnection = sal_False; + m_xConnection = NULL; + m_bOwnConnection = sal_False; - if (!_bUI || (RET_YES == QueryBox(getView(),ModuleRes(QUERY_CONNECTION_LOST)).Execute())) + if (!_bUI || (RET_YES == QueryBox(getView(),ModuleRes(TABLE_QUERY_CONNECTION_LOST)).Execute())) { m_xConnection = connect(m_sDataSourceName); m_bOwnConnection = m_xConnection.is(); } + ToolBox* pToolBox = getView()->getToolBox(); + if(pToolBox) + { + if(m_xConnection.is()) + { + pToolBox->RemoveItem(pToolBox->GetItemPos(ID_TABLE_DESIGN_NO_CONNECTION)-1); + pToolBox->HideItem(ID_TABLE_DESIGN_NO_CONNECTION); + } + else if(!pToolBox->IsItemVisible(ID_TABLE_DESIGN_NO_CONNECTION)) + { + + pToolBox->InsertSeparator(pToolBox->GetItemPos(ID_TABLE_DESIGN_NO_CONNECTION)); + pToolBox->ShowItem(ID_TABLE_DESIGN_NO_CONNECTION); + } + } } // ----------------------------------------------------------------------------- void OTableController::fillTypeInfo() @@ -947,10 +959,10 @@ void OTableController::loadData() m_vRowList.clear(); OTableRow* pTabEdRow = NULL; - Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData(); + Reference< XDatabaseMetaData> xMetaData = getConnection().is() ? getConnection()->getMetaData() : NULL; ////////////////////////////////////////////////////////////////////// // Datenstruktur mit Daten aus DatenDefinitionsObjekt fuellen - if(m_xTable.is()) + if(m_xTable.is() && xMetaData.is()) { Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY); OSL_ENSURE(xColSup.is(),"No XColumnsSupplier!"); @@ -962,7 +974,6 @@ void OTableController::loadData() // Bei Drop darf keine Zeile editierbar sein. // Bei Add duerfen nur die leeren Zeilen editierbar sein. // Bei Add und Drop koennen alle Zeilen editiert werden. - Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData(); sal_Bool bReadOldRow = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn(); Sequence< ::rtl::OUString> aColumns = xColumns->getElementNames(); const ::rtl::OUString* pBegin = aColumns.getConstArray(); @@ -1070,18 +1081,13 @@ void OTableController::loadData() OSL_ENSURE(aTypeIter != m_aTypeInfo.end(),"We have no type infomation!"); - sal_Bool bReadRow = m_xTable.is() && xMetaData->supportsAlterTableWithAddColumn(); + sal_Bool bReadRow = m_xTable.is() && xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn(); for(sal_Int32 i=m_vRowList.size(); i<128; i++ ) { pTabEdRow = new OTableRow(); pTabEdRow->SetReadOnly(bReadRow); - // pTabEdRow->SetFieldType( aTypeIter->second ); m_vRowList.push_back( pTabEdRow); } - - // da sich die FieldDescriptions geaendert haben und meine UI eventuell noch Referenzen darauf hat ... - // static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->DisplayData(0); - // static_cast<OTableDesignView*>(getView())->GetTabDescWin()->Init(); } // ----------------------------------------------------------------------------- Reference<XNameAccess> OTableController::getKeyColumns() const @@ -1118,7 +1124,9 @@ Reference<XNameAccess> OTableController::getKeyColumns() const // ----------------------------------------------------------------------------- void OTableController::checkColumns() throw(::com::sun::star::sdbc::SQLException) { - ::comphelper::UStringMixEqual bCase(m_xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + Reference< XDatabaseMetaData> xMetaData = m_xConnection.is() ? m_xConnection->getMetaData() : NULL; + + ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->storesMixedCaseQuotedIdentifiers() : sal_True); ::std::vector<OTableRow*>::const_iterator aIter = m_vRowList.begin(); for(;aIter != m_vRowList.end();++aIter) { @@ -1162,7 +1170,8 @@ void OTableController::alterColumns() sal_Bool bReload = sal_False; // refresh the data - ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aColumns(m_xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + Reference< XDatabaseMetaData> xMetaData = m_xConnection.is() ? m_xConnection->getMetaData() : NULL; + ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aColumns(xMetaData.is() ? xMetaData->storesMixedCaseQuotedIdentifiers() : sal_True); ::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin(); for(;aIter != m_vRowList.end();++aIter) { @@ -1392,6 +1401,12 @@ void OTableController::assignTable() m_xTable = xProp; Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY); m_bEditable = xAlter.is(); + if(!m_bEditable) + { + ::std::vector<OTableRow*>::iterator aIter = m_vRowList.begin(); + for(; aIter != m_vRowList.end(); ++aIter) + (*aIter)->SetReadOnly(sal_True); + } m_bNew = sal_False; // be notified when the table is in disposing Reference< XComponent > xComponent(m_xTable, UNO_QUERY); @@ -1400,6 +1415,7 @@ void OTableController::assignTable() Reference<XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); xComponent->addEventListener(xEvtL); } + InvalidateAll(); } } } diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx index 2935c8f02bbc..b385b35d7dc2 100644 --- a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx +++ b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TableFieldControl.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-02-14 14:26:39 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,6 +87,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; using namespace dbaui; //------------------------------------------------------------------ @@ -152,7 +153,10 @@ void OTableFieldControl::SetModified(BOOL bModified) // ----------------------------------------------------------------------------- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData() { - return GetCtrl()->GetView()->getController()->getConnection()->getMetaData(); + Reference<XConnection> xCon = GetCtrl()->GetView()->getController()->getConnection(); + if(!xCon.is()) + return NULL; + return xCon->getMetaData(); } // ----------------------------------------------------------------------------- Reference< XNumberFormatter > OTableFieldControl::GetFormatter() diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index 8638c258364b..37f31707d6dc 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.7 $ + * $Revision: 1.8 $ * - * last change: $Author: kz $ $Date: 2001-03-09 20:40:54 $ + * last change: $Author: oj $ $Date: 2001-03-14 10:35:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -934,6 +934,16 @@ ToolBox RID_BRW_TABLEDESIGN_TOOLBOX Text[ turkish ] = "Redo"; Text[ arabic ] = ""; }; + ToolBoxItem + { + Identifier = ID_TABLE_DESIGN_NO_CONNECTION; + HelpId = HID_TABLE_DESIGN_NO_CONNECTION ; + Hide = TRUE; + ItemImage = IMG_DATABASE; + + Text = "Keine Verbindung" ; + Text [ ENGLISH ] = "No connection" ; + }; }; }; String STR_DEFAULT_VALUE @@ -1567,8 +1577,27 @@ QueryBox TABLE_DESIGN_SAVEMODIFIED Message[ turkish ] = "The table has been changed.\nDo you want to save the changes?"; Message[ arabic ] = "The table has been changed.\nDo you want to save the changes?"; }; - - +QueryBox TABLE_QUERY_CONNECTION_LOST +{ + Buttons = WB_YES_NO ; + Message = "Die Verbindung zur Datenbank wurde gelscht! Ohne sie kann der Tabellenentwurf nur eingeschrnkt benutzt werden.\nSoll die Verbindung zur Datenbank wieder aufgebaut werden?" ; + Message [ English ] = "The connection to the database was lost! The tabledesign can only be used with limited functionality without a connection.\nReconnect?" ; + Message [ english_us ] = "The connection to the database was lost! The tabledesign can only be used with limited functionality without a connection.\nReconnect?" ; +}; +String STR_TABLEDESIGN_CONNECTION_MISSING +{ + Text = "Die Tabelle konnte nicht gespeichert werden, da keine Verbindung zur Datenbank hergestellt werden konnte."; + Text [ english_us ] = "The table couldn't be saved due to connection problems."; + Text [ english ] = "The table couldn't be saved due to connection problems."; +}; +FixedText FIXED_NO_CONNECTION +{ + Pos = MAP_APPFONT ( 0,0 ) ; + Size = MAP_APPFONT ( 120 , 10 ) ; + Text = "Keine Verbindung" ; + Text [ English ] = "no connection" ; + Text [ english_us ] = "no connection" ; +}; |