diff options
author | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-15 09:16:51 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-15 09:16:51 +0100 |
commit | 339674ed2f3f8452cc107e01608a0a6fb12eec0d (patch) | |
tree | 2a76239239eeba0480e9d9718549603fdb577e07 /dbaccess/source/ui/tabledesign | |
parent | b7c07c7d44a28db1e59a33eb9312e77b59d2bb87 (diff) | |
parent | d5f5c68072d28e3a784a714a3ed88f3455af680d (diff) |
dba33b: merge m69
Diffstat (limited to 'dbaccess/source/ui/tabledesign')
-rw-r--r-- | dbaccess/source/ui/tabledesign/FieldDescriptions.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TableController.cxx | 217 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/table.src | 2 |
4 files changed, 84 insertions, 165 deletions
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index 8540b4b8d..e78cc2303 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -239,8 +239,19 @@ void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bF if ( bForce ) { sal_Int32 nPrec = DEFAULT_OTHER_PRECSION; - if ( GetPrecision() ) - nPrec = GetPrecision(); + switch ( _pType->nType ) + { + case DataType::BIT: + case DataType::BLOB: + case DataType::CLOB: + nPrec = _pType->nPrecision; + break; + default: + if ( GetPrecision() ) + nPrec = GetPrecision(); + break; + } + if ( _pType->nPrecision ) SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision)); if ( _pType->nMaximumScale ) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 53022b5ad..bcdd42a38 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -1534,19 +1534,8 @@ sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ ) return sal_False; OTableController& rController = GetView()->getController(); - try - { - Reference<XConnection> xCon = rController.getConnection(); - - Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>(); - if(!xMetaData.is() || !xMetaData->supportsCoreSQLGrammar()) - return sal_False; // no primary keys allowed - - } - catch(SQLException&) - { - OSL_ASSERT(!"supportsCoreSQLGrammar"); - } + if ( !rController.getSdbMetaData().supportsPrimaryKeys() ) + return sal_False; Reference<XPropertySet> xTable = rController.getTable(); ////////////////////////////////////////////////////////////// diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index f236eb112..f0e0f7c13 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -30,143 +30,62 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBUI_TABLECONTROLLER_HXX -#include "TableController.hxx" -#endif -#ifndef _DBAU_REGHELPER_HXX_ +#include "FieldDescriptions.hxx" +#include "TEditControl.hxx" +#include "TableController.hxx" +#include "TableDesignView.hxx" +#include "TableRow.hxx" +#include "TypeInfo.hxx" +#include "UITools.hxx" +#include "browserids.hxx" #include "dbu_reghelper.hxx" -#endif -#ifndef _STRING_HXX -#include <tools/string.hxx> -#endif -#include <tools/diagnose_ex.h> -#ifndef _SFXSIDS_HRC -#include <sfx2/sfxsids.hrc> -#endif -#ifndef _DBU_TBL_HRC_ #include "dbu_tbl.hrc" -#endif -#ifndef DBACCESS_UI_BROWSER_ID_HXX -#include "browserids.hxx" -#endif -#ifndef _COMPHELPER_TYPES_HXX_ -#include <comphelper/types.hxx> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX #include "defaultobjectnamecheck.hxx" -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ -#include <connectivity/dbtools.hxx> -#endif -#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_ -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#endif -#ifndef _COMPHELPER_EXTRACT_HXX_ -#include <comphelper/extract.hxx> -#endif -#ifndef DBAUI_DLGSAVE_HXX #include "dlgsave.hxx" -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ +#include "dsmeta.hxx" +#include "indexdialog.hxx" +#include "sqlmessage.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ -#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ -#include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ -#include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XALTERTABLE_HPP_ -#include <com/sun/star/sdbcx/XAlterTable.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ -#include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XTitleChangeListener.hpp> +#include <com/sun/star/frame/XUntitledNumbers.hpp> +#include <com/sun/star/io/XActiveDataSink.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/SQLContext.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ -#include <com/sun/star/sdbc/SQLWarning.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ #include <com/sun/star/sdbc/ColumnValue.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/SQLWarning.hpp> #include <com/sun/star/sdbc/XRow.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#include <com/sun/star/sdbcx/XAlterTable.hpp> +#include <com/sun/star/sdbcx/XAppend.hpp> +#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> +#include <com/sun/star/sdbcx/XDrop.hpp> #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> -#endif -#include <com/sun/star/frame/XTitleChangeListener.hpp> -#ifndef _DBHELPER_DBEXCEPTION_HXX_ -#include <connectivity/dbexception.hxx> -#endif -#ifndef _COM_SUN_STAR_UI_XEXECUTABLEDIALOG_HPP_ +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#endif -#include <com/sun/star/frame/XUntitledNumbers.hpp> -#ifndef _COMPHELPER_STREAMSECTION_HXX_ +/** === end UNO includes === **/ + +#include <comphelper/extract.hxx> #include <comphelper/streamsection.hxx> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_ -#include <com/sun/star/io/XActiveDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_ -#include <com/sun/star/io/XActiveDataSink.hpp> -#endif -#ifndef DBAUI_TABLEDESIGNVIEW_HXX -#include "TableDesignView.hxx" -#endif -#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ -#include <com/sun/star/sdb/CommandType.hpp> -#endif -#ifndef DBAUI_FIELDDESCRIPTIONS_HXX -#include "FieldDescriptions.hxx" -#endif -#ifndef DBAUI_TABLEROW_HXX -#include "TableRow.hxx" -#endif -#ifndef DBAUI_TYPEINFO_HXX -#include "TypeInfo.hxx" -#endif -#ifndef DBAUI_TABLEEDITORCONTROL_HXX -#include "TEditControl.hxx" -#endif -#ifndef _DBAUI_SQLMESSAGE_HXX_ -#include "sqlmessage.hxx" -#endif -#ifndef _SV_MSGBOX_HXX +#include <comphelper/types.hxx> +#include <connectivity/dbexception.hxx> +#include <connectivity/dbtools.hxx> +#include <connectivity/dbmetadata.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <sfx2/sfxsids.hrc> +#include <tools/diagnose_ex.h> +#include <tools/string.hxx> #include <vcl/msgbox.hxx> -#endif -#ifndef _DBAUI_INDEXDIALOG_HXX_ -#include "indexdialog.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif -#include <boost/mem_fn.hpp> -#ifndef _CPPUHELPER_EXC_HLP_HXX_ -#include <cppuhelper/exc_hlp.hxx> -#endif -#include "dsmeta.hxx" +#include <boost/mem_fn.hpp> #include <boost/bind.hpp> + #include <algorithm> #include <functional> @@ -1089,7 +1008,8 @@ sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star:: { sal_Bool bOk = sal_True; sal_Bool bFoundPKey = sal_False; - Reference< XDatabaseMetaData> xMetaData = getMetaData( ); + Reference< XDatabaseMetaData > xMetaData = getMetaData( ); + DatabaseMetaData aMetaData( getConnection() ); ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True); ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin(); @@ -1115,39 +1035,38 @@ sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star:: } } } - if(!bFoundPKey) + if ( _bNew && !bFoundPKey && aMetaData.supportsPrimaryKeys() ) { - if(_bNew && xMetaData.is() && xMetaData->supportsCoreSQLGrammar()) - { - String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); - String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); - OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); + String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD)); + String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY)); + OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES); - INT16 nReturn = aBox.Execute(); + switch ( aBox.Execute() ) + { + case RET_YES: + { + ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow()); + TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo); + if ( !pTypeInfo.get() ) + break; - if (nReturn == RET_YES) - { - ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow()); - TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo); - - if ( pTypeInfo.get() ) - { - pNewRow->SetFieldType( pTypeInfo ); - OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr(); + pNewRow->SetFieldType( pTypeInfo ); + OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr(); - pActFieldDescr->SetAutoIncrement(sal_False); // #95927# pTypeInfo->bAutoIncrement - pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); + pActFieldDescr->SetAutoIncrement(sal_False); // #95927# pTypeInfo->bAutoIncrement + pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); - pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("ID") )); - pActFieldDescr->SetPrimaryKey( sal_True ); - m_vRowList.insert(m_vRowList.begin(),pNewRow); + pActFieldDescr->SetName( createUniqueName(::rtl::OUString::createFromAscii("ID") )); + pActFieldDescr->SetPrimaryKey( sal_True ); + m_vRowList.insert(m_vRowList.begin(),pNewRow); - static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate(); - static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0); - } // if ( pTypeInfo.get() ) - } - else if (nReturn == RET_CANCEL) - bOk = sal_False; + static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate(); + static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0); + } + break; + case RET_CANCEL: + bOk = sal_False; + break; } } return bOk; @@ -1471,7 +1390,7 @@ void OTableController::alterColumns() bNeedAppendKey = sal_True; } - if ( bNeedDropKey ) + if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() ) dropPrimaryKey(); if ( bNeedAppendKey ) diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index 17daa1fb5..e084ff76e 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -56,7 +56,7 @@ String STR_TABLEDESIGN_DBFIELDTYPES { - Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER"; + Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)"; }; String STR_TABLEDESIGN_UNDO_PRIMKEY |