#106092# check column names
This commit is contained in:
parent
a84ac55f32
commit
6912006750
6 changed files with 87 additions and 22 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: FieldDescControl.hxx,v $
|
||||
*
|
||||
* $Revision: 1.7 $
|
||||
* $Revision: 1.8 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-09-24 09:18:56 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:19:22 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -213,6 +213,8 @@ namespace dbaui
|
|||
String BoolStringPersistent(const String& rUIString) const;
|
||||
String BoolStringUI(const String& rPersistentString) const;
|
||||
|
||||
const OPropColumnEditCtrl* getColumnCtrl() const { return m_pColumnName; }
|
||||
|
||||
public:
|
||||
OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
|
||||
OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: WCopyTable.hxx,v $
|
||||
*
|
||||
* $Revision: 1.13 $
|
||||
* $Revision: 1.14 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-11-14 07:58:31 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:19:22 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -282,7 +282,13 @@ namespace dbaui
|
|||
@return
|
||||
<TRUE/> if I need to set the autoincrement value by myself otherwise <FALSE/>
|
||||
*/
|
||||
sal_Bool isAutoincrementEnabled() const;
|
||||
sal_Bool isAutoincrementEnabled() const;
|
||||
|
||||
/** returns the name of the primary key
|
||||
@return
|
||||
The name of teh primary key.
|
||||
*/
|
||||
::rtl::OUString getPrimaryKeyName() const { return m_aKeyName; }
|
||||
|
||||
const OTypeInfo* getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; }
|
||||
const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; }
|
||||
|
@ -318,6 +324,8 @@ namespace dbaui
|
|||
const ::rtl::OUString& _sExtraChars,
|
||||
sal_Int32 _nMaxNameLen);
|
||||
const OTypeInfo* convertType(const OTypeInfo* _pType);
|
||||
|
||||
::rtl::OUString createUniqueName(const ::rtl::OUString& _sName);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: DExport.cxx,v $
|
||||
*
|
||||
* $Revision: 1.18 $
|
||||
* $Revision: 1.19 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-11-14 07:57:00 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:17:06 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -604,7 +604,7 @@ void ODatabaseExport::CreateDefaultColumn(const ::rtl::OUString& _rColumnName)
|
|||
{
|
||||
aAlias = aAlias.copy(0,::std::min<sal_Int32>( nMaxNameLen-1, aAlias.getLength() ));
|
||||
|
||||
sal_Int32 nPos = 1;
|
||||
sal_Int32 nPos = 0;
|
||||
sal_Int32 nCount = 2;
|
||||
while(m_aDestColumns.find(sName) != m_aDestColumns.end())
|
||||
{
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: WCPage.cxx,v $
|
||||
*
|
||||
* $Revision: 1.18 $
|
||||
* $Revision: 1.19 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-11-14 07:57:01 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:17:06 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -216,7 +216,7 @@ OCopyTable::OCopyTable( Window * pParent, EImportMode atWhat, sal_Bool bIsView,
|
|||
m_edKeyName.Enable(sal_False);
|
||||
|
||||
::rtl::OUString sKeyName(::rtl::OUString::createFromAscii("ID"));
|
||||
sKeyName = ::dbtools::createUniqueName(m_pParent->m_xSourceColumns,sKeyName,sal_False);
|
||||
sKeyName = m_pParent->createUniqueName(sKeyName);
|
||||
m_edKeyName.SetText(sKeyName);
|
||||
|
||||
sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
|
||||
|
@ -320,7 +320,7 @@ sal_Bool OCopyTable::LeavePage()
|
|||
|
||||
// now we have to check if the name of the primary key already exists
|
||||
if ( m_pParent->m_bCreatePrimaryColumn
|
||||
&& m_pParent->m_aKeyName != ::dbtools::createUniqueName(m_pParent->m_xSourceColumns,m_pParent->m_aKeyName,sal_False) )
|
||||
&& m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
|
||||
{
|
||||
String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
|
||||
aInfoString += String(' ');
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: WCopyTable.cxx,v $
|
||||
*
|
||||
* $Revision: 1.28 $
|
||||
* $Revision: 1.29 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-11-14 07:57:01 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:17:06 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -1061,3 +1061,23 @@ const OTypeInfo* OCopyTableWizard::convertType(const OTypeInfo* _pType)
|
|||
return pType;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
::rtl::OUString OCopyTableWizard::createUniqueName(const ::rtl::OUString& _sName)
|
||||
{
|
||||
::rtl::OUString sName = _sName;
|
||||
if ( m_xSourceColumns.is() )
|
||||
sName = ::dbtools::createUniqueName(m_xSourceColumns,sName,sal_False);
|
||||
else
|
||||
{
|
||||
if ( m_vSourceColumns.find(sName) != m_vSourceColumns.end())
|
||||
{
|
||||
sal_Int32 nPos = 0;
|
||||
while(m_vSourceColumns.find(sName) != m_vSourceColumns.end())
|
||||
{
|
||||
sName = _sName;
|
||||
sName += ::rtl::OUString::valueOf(++nPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sName;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: WTypeSelect.cxx,v $
|
||||
*
|
||||
* $Revision: 1.16 $
|
||||
* $Revision: 1.17 $
|
||||
*
|
||||
* last change: $Author: oj $ $Date: 2002-11-14 07:57:01 $
|
||||
* last change: $Author: oj $ $Date: 2002-12-10 09:17:06 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -97,6 +97,9 @@
|
|||
#ifndef _DBAUI_SQLMESSAGE_HXX_
|
||||
#include "sqlmessage.hxx"
|
||||
#endif
|
||||
#ifndef DBAUI_FIELDCONTROLS_HXX
|
||||
#include "FieldControls.hxx"
|
||||
#endif
|
||||
|
||||
using namespace ::dbaui;
|
||||
using namespace ::com::sun::star::uno;
|
||||
|
@ -156,36 +159,67 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
|
|||
MultiListBox &aListBox = ((OWizTypeSelect*)GetParent())->m_lbColumnNames;
|
||||
|
||||
sal_uInt16 nPos = aListBox.GetEntryPos(String(pActFieldDescr->GetName()));
|
||||
OSL_ENSURE(nPos != LISTBOX_ENTRY_NOTFOUND,"Columnname could not be found in the listbox");
|
||||
pActFieldDescr = static_cast<OFieldDescription*>(aListBox.GetEntryData(nPos));
|
||||
if ( !pActFieldDescr )
|
||||
return;
|
||||
|
||||
::rtl::OUString sName = pActFieldDescr->GetName();
|
||||
SaveData(pActFieldDescr);
|
||||
::rtl::OUString sNewName;
|
||||
const OPropColumnEditCtrl* pColumnName = getColumnCtrl();
|
||||
if ( pColumnName )
|
||||
sNewName = pColumnName->GetText();
|
||||
|
||||
switch(nColId)
|
||||
{
|
||||
case FIELD_PRPOERTY_COLUMNNAME:
|
||||
{
|
||||
OCopyTableWizard* pWiz = static_cast<OCopyTableWizard*>(GetParent()->GetParent());
|
||||
// first we have to check if this name already exists
|
||||
if ( aListBox.GetEntryPos(String(pActFieldDescr->GetName())) != LISTBOX_ENTRY_NOTFOUND )
|
||||
sal_Bool bDoubleName = sal_False;
|
||||
sal_Bool bCase = sal_True;
|
||||
if ( getMetaData().is() && !getMetaData()->storesMixedCaseQuotedIdentifiers() )
|
||||
{
|
||||
bCase = sal_False;
|
||||
sal_Int32 nCount = aListBox.GetEntryCount();
|
||||
for (sal_Int32 i=0 ; !bDoubleName && i < nCount ; ++i)
|
||||
{
|
||||
::rtl::OUString sEntry(aListBox.GetEntry(i));
|
||||
bDoubleName = sNewName.equalsIgnoreAsciiCase(sEntry);
|
||||
}
|
||||
if ( !bDoubleName && pWiz->isAutoincrementEnabled() )
|
||||
bDoubleName = sNewName.equalsIgnoreAsciiCase(pWiz->getPrimaryKeyName());
|
||||
|
||||
}
|
||||
else
|
||||
bDoubleName = ((aListBox.GetEntryPos(String(pActFieldDescr->GetName())) != LISTBOX_ENTRY_NOTFOUND)
|
||||
|| ( pWiz->isAutoincrementEnabled()
|
||||
&& pWiz->getPrimaryKeyName() == pActFieldDescr->GetName()) );
|
||||
|
||||
if ( bDoubleName )
|
||||
{
|
||||
String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
|
||||
strMessage.SearchAndReplaceAscii("$column$", pActFieldDescr->GetName());
|
||||
strMessage.SearchAndReplaceAscii("$column$", sNewName);
|
||||
String sTitle(ModuleRes(STR_STAT_WARNING));
|
||||
OSQLMessageBox aMsg(this,sTitle,strMessage,WB_OK | WB_DEF_OK,OSQLMessageBox::Error);
|
||||
aMsg.Execute();
|
||||
pActFieldDescr->SetName(sName);
|
||||
DisplayData(pActFieldDescr);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
|
||||
pActFieldDescr->SetName(sNewName);
|
||||
|
||||
// now we change the name
|
||||
OCopyTableWizard::TNameMapping::iterator aIter = ((OWizTypeSelect*)GetParent())->m_pParent->m_mNameMapping.begin();
|
||||
OCopyTableWizard::TNameMapping::iterator aEnd = ((OWizTypeSelect*)GetParent())->m_pParent->m_mNameMapping.end();
|
||||
|
||||
::comphelper::UStringMixEqual aCase(bCase);
|
||||
for(;aIter != aEnd;++aIter)
|
||||
{
|
||||
if ( aIter->second == sName )
|
||||
if ( aCase(aIter->second,sName) )
|
||||
{
|
||||
aIter->second = pActFieldDescr->GetName();
|
||||
aIter->second = sNewName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +230,7 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
|
|||
}
|
||||
break;
|
||||
}
|
||||
SaveData(pActFieldDescr);
|
||||
}
|
||||
// -----------------------------------------------------------------------
|
||||
void OWizTypeSelectControl::SetModified(sal_Bool bModified) {}
|
||||
|
|
Loading…
Reference in a new issue