summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2001-06-29 10:56:58 +0000
committerOcke Janssen <oj@openoffice.org>2001-06-29 10:56:58 +0000
commit49195a8f878db97bc0cc2213b614f8ed4f8d812c (patch)
tree12f9318ceeff0b54d7d2e2873e66b4b4ea1e7cc2 /dbaccess/source/ui
parent6eb52909093fc0074248eb1d1bf3adce4dc1334d (diff)
#87998# correct some values of db types
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r--dbaccess/source/ui/inc/TypeInfo.hxx18
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx93
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx33
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx71
4 files changed, 121 insertions, 94 deletions
diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx
index d1355131575c..4c6754e00a20 100644
--- a/dbaccess/source/ui/inc/TypeInfo.hxx
+++ b/dbaccess/source/ui/inc/TypeInfo.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: TypeInfo.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: oj $ $Date: 2001-03-02 15:42:27 $
+ * last change: $Author: oj $ $Date: 2001-06-29 11:56:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -161,6 +161,20 @@ const sal_uInt16 TYPE_OTHER = 30;
typedef ::std::multimap<sal_Int32,OTypeInfo*> OTypeInfoMap;
+ /** return the most suitable typeinfo for a requested type
+ @param _rTypeInfo contains a map of type to typeinfo
+ @param _nType the requested type
+ @param _sTypeName the typename
+ @param _nPrecision the precision
+ @param _nScale the scale
+ @param _brForceToType true when type was found which has some differenes
+ */
+ const OTypeInfo* getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ sal_Int32 _nType,
+ const ::rtl::OUString& _sTypeName,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool& _brForceToType);
}
#endif // DBAUI_TYPEINFO_HXX
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 28952ddd9b62..7e44639d9573 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.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: fs $ $Date: 2001-06-15 09:43:22 $
+ * last change: $Author: oj $ $Date: 2001-06-29 11:56:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -107,12 +107,25 @@
#ifndef _VCL_STDTEXT_HXX
#include <vcl/stdtext.hxx>
#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef DBAUI_TYPEINFO_HXX
+#include "TypeInfo.hxx"
+#endif
// .........................................................................
namespace dbaui
{
// .........................................................................
using namespace ::dbtools;
+using namespace ::comphelper;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::sdbcx;
@@ -125,6 +138,7 @@ using namespace ::com::sun::star::util;
using namespace ::com::sun::star::ui::dialogs;
+
// -----------------------------------------------------------------------------
void composeTableName( const Reference< XDatabaseMetaData >& _rxMetaData,
const Reference< XPropertySet >& _rxTable,
@@ -264,8 +278,81 @@ void showError(const SQLExceptionInfo& _rInfo,Window* _pParent,const Reference<
return vRet;
}
-// -----------------------------------------------------------------------------
+const OTypeInfo* getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ sal_Int32 _nType,
+ const ::rtl::OUString& _sTypeName,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool& _brForceToType)
+{
+ const OTypeInfo* pTypeInfo = NULL;
+ _brForceToType = sal_False;
+ // search for type
+ ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
+ OTypeInfoMap::const_iterator aIter = aPair.first;
+ if(aIter != _rTypeInfo.end()) // compare with end is correct here
+ {
+ for(;aIter != aPair.second;++aIter)
+ {
+ // search the best matching type
+ #ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
+ sal_Int32 nDBTypePrecision = aIter->second->nPrecision;
+ sal_Int32 nDBTypeScale = aIter->second->nMaximumScale;
+ #endif
+ if ( ( !_sTypeName.getLength()
+ || (aIter->second->aTypeName == _sTypeName)
+ )
+ && (aIter->second->nPrecision >= _nPrecision)
+ && (aIter->second->nMaximumScale >= _nScale)
+ )
+ break;
+ }
+
+ if (aIter == aPair.second)
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+ if ( (aIter->second->aLocalTypeName == _sTypeName)
+ && (aIter->second->nPrecision >= _nPrecision)
+ && (aIter->second->nMaximumScale >= _nScale)
+ )
+ {
+ OSL_ENSURE(sal_False,
+ ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
+ += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString("\" (expected type name ")
+ += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString(" matches the type's local name).")).getStr());
+ break;
+ }
+ }
+ }
+
+ if (aIter == aPair.second)
+ { // no match for the names, no match for the local names
+ // -> drop the precision and the scale restriction, accept any type with the property
+ // type id (nType)
+
+ OSL_ENSURE(sal_False,
+ ( ::rtl::OString("getTypeInfoFromType: did not find a matching type")
+ += ::rtl::OString(" (expected type name: ")
+ += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString(")! Defaulting to the first matching type.")).getStr());
+
+ pTypeInfo = aPair.first->second;
+ _brForceToType = sal_True;
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else
+ OSL_ENSURE(sal_False, "getTypeInfoFromType: no type info found for this type!");
+
+ return pTypeInfo;
+}
// .........................................................................
}
// .........................................................................
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index c0ab46ab704b..5719ea159108 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WCopyTable.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: fme $ $Date: 2001-06-21 15:26:43 $
+ * last change: $Author: oj $ $Date: 2001-06-29 11:56:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -693,37 +693,24 @@ void OCopyTableWizard::loadData()
pActFieldDescr = new OFieldDescription();
// search for type
- ::std::pair<OTypeInfoMap::iterator, OTypeInfoMap::iterator> aPair = m_aTypeInfo.equal_range(nType);
- OTypeInfoMap::iterator aIter = aPair.first;
- if(aIter == m_aTypeInfo.end())
- { // type not in destination database
- aPair = m_aTypeInfo.equal_range(DataType::VARCHAR);
- }
- for(;aIter != aPair.second;++aIter)
- {
- // search the best matching type
- if( aIter->second->aTypeName == sTypeName &&
- aIter->second->nPrecision >= nPrecision &&
- aIter->second->nMaximumScale >= nScale)
- break;
- }
+ sal_Bool bForce;
+ const OTypeInfo* pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,nPrecision,nScale,bForce);
- OTypeInfo* pType = aIter->second;
- pActFieldDescr->SetType(pType);
- switch(pType->nType)
+ pActFieldDescr->SetType(pTypeInfo);
+ switch(pTypeInfo->nType)
{
case DataType::CHAR:
case DataType::VARCHAR:
- pActFieldDescr->SetPrecision(::std::min<sal_Int32>(sal_Int32(50),pType->nPrecision));
+ pActFieldDescr->SetPrecision(::std::min<sal_Int32>(sal_Int32(50),pTypeInfo->nPrecision));
break;
default:
- if(pType->nPrecision && pType->nMaximumScale)
+ if(pTypeInfo->nPrecision && pTypeInfo->nMaximumScale)
{
pActFieldDescr->SetPrecision(5);
pActFieldDescr->SetScale(0);
}
- else if(pType->nPrecision)
- pActFieldDescr->SetPrecision(::std::min<sal_Int32>(sal_Int32(16),pType->nPrecision));
+ else if(pTypeInfo->nPrecision)
+ pActFieldDescr->SetPrecision(::std::min<sal_Int32>(sal_Int32(16),pTypeInfo->nPrecision));
}
pActFieldDescr->SetName(sName);
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index e25a292a7705..d37573c59654 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.39 $
+ * $Revision: 1.40 $
*
- * last change: $Author: oj $ $Date: 2001-06-29 11:21:10 $
+ * last change: $Author: oj $ $Date: 2001-06-29 11:53:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1172,70 +1172,9 @@ void OTableController::loadData()
pTabEdRow = new OTableRow();
pTabEdRow->SetReadOnly(!bIsAlterAllowed);
// search for type
- ::std::pair<OTypeInfoMap::iterator, OTypeInfoMap::iterator> aPair = m_aTypeInfo.equal_range(nType);
- OTypeInfoMap::iterator aIter = aPair.first;
- if(aIter == m_aTypeInfo.end()) // compare with end is correct here
- {
- OSL_ENSURE(sal_False, "OTableController::loadData: no type info found for this type!");
- continue;
- }
-
- for(;aIter != aPair.second;++aIter)
- {
- // search the best matching type
-#ifdef DBG_UTIL
- ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
- sal_Int32 nDBTypePrecision = aIter->second->nPrecision;
- sal_Int32 nDBTypeScale = aIter->second->nMaximumScale;
-#endif
- if ( ( !sTypeName.getLength()
- || (aIter->second->aTypeName == sTypeName)
- )
- && (aIter->second->nPrecision >= nPrecision)
- && (aIter->second->nMaximumScale >= nScale)
- )
- break;
- }
-
- if (aIter == aPair.second)
- {
- for(aIter = aPair.first; aIter != aPair.second; ++aIter)
- {
- // search the best matching type (now comparing the local names)
- if ( (aIter->second->aLocalTypeName == sTypeName)
- && (aIter->second->nPrecision >= nPrecision)
- && (aIter->second->nMaximumScale >= nScale)
- )
- {
- OSL_ENSURE(sal_False,
- ( ::rtl::OString("OTableController::loadData: assuming column type ")
- += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
- += ::rtl::OString(" for column \"")
- += ::rtl::OString(sName.getStr(), sName.getLength(), gsl_getSystemTextEncoding())
- += ::rtl::OString("\" (expected type name ")
- += ::rtl::OString(sTypeName.getStr(), sTypeName.getLength(), gsl_getSystemTextEncoding())
- += ::rtl::OString(" matches the type's local name).")).getStr());
- break;
- }
- }
- }
-
- if (aIter == aPair.second)
- { // no match for the names, no match for the local names
- // -> drop the precision and the scale restriction, accept any type with the property
- // type id (nType)
-
- OSL_ENSURE(sal_False,
- ( ::rtl::OString("OTableController::loadData: did not find a matching type for column \"")
- += ::rtl::OString(sName.getStr(), sName.getLength(), gsl_getSystemTextEncoding())
- += ::rtl::OString("\" (expected type name: ")
- += ::rtl::OString(sTypeName.getStr(), sTypeName.getLength(), gsl_getSystemTextEncoding())
- += ::rtl::OString(")! Defaulting to the first matching type.")).getStr());
-
- pTabEdRow->SetFieldType( aPair.first->second, sal_True );
- }
- else
- pTabEdRow->SetFieldType( aIter->second );
+ sal_Bool bForce;
+ const OTypeInfo* pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,nPrecision,nScale,bForce);
+ pTabEdRow->SetFieldType( pTypeInfo, bForce );
pActFieldDescr = pTabEdRow->GetActFieldDescr();
OSL_ENSURE(pActFieldDescr, "OTableController::loadData: invalid field description generated by the table row!");