Tag: cws_src680_dba30
User: fs      
Date: 06/05/08 04:27:21

Modified:
 /dba/dbaccess/source/ui/misc/
  WCopyTable.cxx

Log:
 RESYNC: (1.42-1.44); FILE MERGED

File Changes:

Directory: /dba/dbaccess/source/ui/misc/
========================================

File [changed]: WCopyTable.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/WCopyTable.cxx?r1=1.41.16.3&r2=1.41.16.4
Delta lines:  +71 -5
--------------------
--- WCopyTable.cxx      21 Mar 2006 18:39:26 -0000      1.41.16.3
+++ WCopyTable.cxx      8 May 2006 11:27:18 -0000       1.41.16.4
@@ -102,6 +102,9 @@
 #ifndef DBAUI_TOOLS_HXX
 #include "UITools.hxx"
 #endif
+#ifndef DBAUI_WIZARD_CPAGE_HXX
+#include "WCPage.hxx"
+#endif
 #ifndef _SV_WAITOBJ_HXX
 #include <vcl/waitobj.hxx>
 #endif
@@ -179,11 +182,18 @@
                                m_sSourceName = 
::dbtools::composeTableName(m_xConnection->getMetaData(),m_xSourceObject,sal_False,::dbtools::eInDataManipulation);
                        else
                                _xSourceObject->getPropertyValue(PROPERTY_NAME) 
>>= m_sSourceName;
+            if ( m_xSourceConnection == m_xConnection )
+            {
+                Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY_THROW);
+                m_sName = 
::dbtools::createUniqueName(xSup->getTables(),m_sSourceName,sal_False);
+            }
+            else
                        m_sName = m_sSourceName;
                }
        }
-       catch(Exception)
+       catch(const Exception&)
        {
+        m_sName = m_sSourceName;
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -210,12 +220,17 @@
        ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
        ,m_xFactory(_rM)
        ,m_sName(_rDefaultName)
-       ,m_vSourceVec(_rSourceColVec)
        ,m_xSourceConnection(_xConnection) // in this case source connection 
and dest connection are the same
        ,m_bDeleteSourceColumns(sal_False)
 {
        DBG_CTOR(OCopyTableWizard,NULL);
        construct();
+    ODatabaseExport::TColumnVector::const_iterator aIter = 
_rSourceColVec.begin();
+    ODatabaseExport::TColumnVector::const_iterator aEnd = _rSourceColVec.end();
+    for (; aIter != aEnd ; ++aIter)
+    {
+        m_vSourceVec.push_back(m_vSourceColumns.find((*aIter)->first));
+    }
 }
 // 
-----------------------------------------------------------------------------
 void OCopyTableWizard::construct()
@@ -430,6 +445,50 @@
                                                return 0;
                                        }
                                }
+                if ( m_xConnection.is() )
+                   {
+                    sal_Bool bPKeyAllowed = sal_False;
+                    try
+                    {
+                               Reference< XDatabaseMetaData >  
xMetaData(m_xConnection->getMetaData());
+                               bPKeyAllowed = 
xMetaData->supportsCoreSQLGrammar();
+                    }
+                    catch(const Exception&)
+                    {
+                        OSL_ENSURE(0,"Exception caught while asking for 
supportsCoreSQLGrammar!");
+                    }
+                    if ( bPKeyAllowed )
+                    {
+                        ODatabaseExport::TColumns::iterator aFind = 
::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end()
+                            
,::std::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::std::select2nd<ODatabaseExport::TColumns::value_type>()));
+                        if ( aFind == m_vDestColumns.end() )
+                        {
+                            String 
sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+                                       String 
sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+                                       OSQLMessageBox aBox(this, sTitle,sMsg, 
WB_YES_NO_CANCEL | WB_DEF_YES);
+
+                                       INT16 nReturn = aBox.Execute();
+
+                                       switch(nReturn )
+                            {
+                                case RET_YES:
+                                {
+                                    OCopyTable* pPage = 
reinterpret_cast<OCopyTable*>(GetPage(0));
+                                    m_bCreatePrimaryColumn = sal_True;
+                                    m_aKeyName = pPage->GetKeyName();
+                                    sal_Int32 nBreakPos = 0;
+                                                   CheckColumns(nBreakPos);
+                                    break;
+                                }
+                                case RET_CANCEL:
+                                    ShowPage(3);
+                                    return 0;
+                                default:
+                                    ;
+                            }
+                        }
+                    }
+                }
                                break;
                        }
                        case WIZARD_APPEND_DATA:
@@ -723,8 +782,9 @@
                        // now only the settings are missing
                        if(xColumns->hasByName(pField->GetName()))
                        {
-                               xColumns->getByName(pField->GetName()) >>= 
xColumn;
-                               if(xColumn.is())
+                xColumn.set(xColumns->getByName(pField->GetName()),UNO_QUERY);
+                OSL_ENSURE(xColumn.is(),"OCopyTableWizard::appendColumns: 
Column is NULL!");
+                               if ( xColumn.is() )
                                        pField->copyColumnSettingsTo(xColumn);
                        }
                        else
@@ -1004,6 +1064,11 @@
        return sAlias;
 }
 // 
-----------------------------------------------------------------------------
+void OCopyTableWizard::removeColumnNameFromNameMap(const ::rtl::OUString& 
_sName)
+{
+    m_mNameMapping.erase(_sName);
+}
+// 
-----------------------------------------------------------------------------
 sal_Bool OCopyTableWizard::supportsType(sal_Int32 _nDataType,sal_Int32& 
_rNewDataType)
 {
        DBG_CHKTHIS(OCopyTableWizard,NULL);
@@ -1138,3 +1203,4 @@
        aMsg.Execute();
 }
 // 
-----------------------------------------------------------------------------
+




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to