diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-08-08 07:24:54 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-08-08 07:24:54 +0000 |
commit | 13d51127f4a4d80c9d0a8a1b3c3558f1b067876e (patch) | |
tree | 4d7cc11a73e773ea729d13ba06f2d4ec381083be /dbaccess/source/ui | |
parent | #88431# commitURL: use the pure (untranslated) URL (diff) | |
download | core-13d51127f4a4d80c9d0a8a1b3c3558f1b067876e.tar.gz core-13d51127f4a4d80c9d0a8a1b3c3558f1b067876e.zip |
#90723# some corrections for appending data
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r-- | dbaccess/source/ui/inc/WCopyTable.hxx | 11 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/WNameMatch.hxx | 14 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCPage.cxx | 34 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WCopyTable.cxx | 44 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/WNameMatch.cxx | 57 |
5 files changed, 89 insertions, 71 deletions
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx index 9c66706a9da9..b31259395720 100644 --- a/dbaccess/source/ui/inc/WCopyTable.hxx +++ b/dbaccess/source/ui/inc/WCopyTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: WCopyTable.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-07-02 13:22:02 $ + * last change: $Author: oj $ $Date: 2001-08-08 08:24:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -143,9 +143,11 @@ namespace dbaui DECL_LINK( ImplOKHdl , OKButton* ); DECL_LINK( ImplActivateHdl, WizardDialog* ); void CheckColumns(); - void loadData(); + void loadData( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xTable, + ODatabaseExport::TColumns& _rColumns, + ODatabaseExport::TColumnVector& _rColVector); void construct(); - ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getKeyColumns() const; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getKeyColumns(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xTable) const; // need for table creation void appendColumns(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup,const ODatabaseExport::TColumnVector* _pVec,sal_Bool _bKeyColumns=sal_False); void appendKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup,const ODatabaseExport::TColumnVector* _pVec); @@ -168,6 +170,7 @@ namespace dbaui ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory; ::com::sun::star::lang::Locale m_aLocale; ::rtl::OUString m_sName; // for a table the name is composed + ::rtl::OUString m_sSourceName; ::rtl::OUString m_aKeyName; public: enum Wizard_Create_Style diff --git a/dbaccess/source/ui/inc/WNameMatch.hxx b/dbaccess/source/ui/inc/WNameMatch.hxx index 064bfe0fea9e..fde1c198bc43 100644 --- a/dbaccess/source/ui/inc/WNameMatch.hxx +++ b/dbaccess/source/ui/inc/WNameMatch.hxx @@ -2,9 +2,9 @@ * * $RCSfile: WNameMatch.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fme $ $Date: 2001-06-21 15:21:14 $ + * last change: $Author: oj $ $Date: 2001-08-08 08:24:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,12 +110,14 @@ namespace dbaui FixedText m_FT_TABLE_RIGHT; OColumnTreeBox m_CTRL_LEFT; // left side OColumnTreeBox m_CTRL_RIGHT; // right side - ImageButton m_ibColumn_up; - ImageButton m_ibColumn_down; - ImageButton m_ibColumn_up_right; - ImageButton m_ibColumn_down_right; + ImageButton m_ibColumn_up; + ImageButton m_ibColumn_down; + ImageButton m_ibColumn_up_right; + ImageButton m_ibColumn_down_right; PushButton m_pbAll; PushButton m_pbNone; + String m_sSourceText; + String m_sDestText; sal_Bool m_bAttrsChanged; diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 1246599d9a4a..3d25f3e21359 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: WCPage.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-07-20 13:33:58 $ + * last change: $Author: oj $ $Date: 2001-08-08 08:24:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -267,7 +267,7 @@ sal_Bool OCopyTable::LeavePage() m_pParent->m_bCreatePrimaryColumn = (m_bPKeyAllowed && m_aCB_PrimaryColumn.IsEnabled()) ? m_aCB_PrimaryColumn.IsChecked() : sal_False; m_pParent->m_aKeyName = m_edKeyName.GetText(); - // a table that comes from a html or rtf import already has a name that is valid in the db + // first check if the table already exists in the database if( m_pParent->getCreateStyle() != OCopyTableWizard::WIZARD_APPEND_DATA ) { Reference<XTablesSupplier > xSup(m_pParent->m_xConnection,UNO_QUERY); @@ -285,23 +285,25 @@ sal_Bool OCopyTable::LeavePage() } if(!m_edTableName.GetSavedValue().Equals(m_edTableName.GetText())) - { // table exist and name has changed + { // table exists and name has changed if(m_pParent->getCreateStyle() == OCopyTableWizard::WIZARD_APPEND_DATA) { m_pParent->clearDestColumns(); - m_pParent->m_xSourceObject = NULL; + // m_pParent->m_xSourceObject = NULL; + m_pParent->m_xDestObject = NULL; Reference<XTablesSupplier > xSup(m_pParent->m_xConnection,UNO_QUERY); Reference<XNameAccess> xTables; if(xSup.is()) xTables = xSup->getTables(); if(xTables.is() && xTables->hasByName(m_edTableName.GetText())) { - xTables->getByName(m_edTableName.GetText()) >>= m_pParent->m_xSourceObject; - m_pParent->loadData(); + // set new destination + xTables->getByName(m_edTableName.GetText()) >>= m_pParent->m_xDestObject; + m_pParent->loadData(m_pParent->m_xDestObject,m_pParent->m_vDestColumns,m_pParent->m_aDestVec); // #90027# - m_pParent->CheckColumns(); + // m_pParent->CheckColumns(); } - if(!m_pParent->m_xSourceObject.is()) + if(!m_pParent->m_xDestObject.is()) { ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute(); return sal_False; @@ -309,7 +311,7 @@ sal_Bool OCopyTable::LeavePage() } else if(m_eOldStyle == OCopyTableWizard::WIZARD_APPEND_DATA) { - m_pParent->m_xSourceObject = NULL; + m_pParent->m_xDestObject = NULL; m_edTableName.SaveValue(); return LeavePage(); } @@ -321,20 +323,22 @@ sal_Bool OCopyTable::LeavePage() case OCopyTableWizard::WIZARD_APPEND_DATA: { m_pParent->clearDestColumns(); - m_pParent->m_xSourceObject = NULL; + // m_pParent->m_xSourceObject = NULL; + m_pParent->m_xDestObject = NULL; Reference<XTablesSupplier > xSup(m_pParent->m_xConnection,UNO_QUERY); Reference<XNameAccess> xTables; if(xSup.is()) xTables = xSup->getTables(); if(xTables.is() && xTables->hasByName(m_edTableName.GetText())) { - xTables->getByName(m_edTableName.GetText()) >>= m_pParent->m_xSourceObject; - m_pParent->loadData(); + xTables->getByName(m_edTableName.GetText()) >>= m_pParent->m_xDestObject; + m_pParent->loadData(m_pParent->m_xDestObject,m_pParent->m_vDestColumns,m_pParent->m_aDestVec); + // m_pParent->loadData(); // #90027# - m_pParent->CheckColumns(); + // m_pParent->CheckColumns(); } - if(!m_pParent->m_xSourceObject.is()) + if(!m_pParent->m_xDestObject.is()) { ErrorBox(this, ModuleRes(ERROR_INVALID_TABLE_NAME)).Execute(); m_edTableName.GrabFocus(); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 169c1fe9080e..21380203ba02 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.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-26 14:12:01 $ + * last change: $Author: oj $ $Date: 2001-08-08 08:24:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,12 +179,13 @@ OCopyTableWizard::OCopyTableWizard(Window * pParent, m_xSourceObject->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; m_xSourceObject->getPropertyValue(PROPERTY_NAME) >>= sTable; - ::dbtools::composeTableName(m_xConnection->getMetaData(),sCatalog,sSchema,sTable,m_sName,sal_False); + ::dbtools::composeTableName(m_xConnection->getMetaData(),sCatalog,sSchema,sTable,m_sSourceName,sal_False); } else - _xSourceObject->getPropertyValue(PROPERTY_NAME) >>= m_sName; + _xSourceObject->getPropertyValue(PROPERTY_NAME) >>= m_sSourceName; + m_sName = m_sSourceName; } - loadData(); // create the field description + loadData(m_xSourceObject,m_vSourceColumns,m_vSourceVec); // create the field description } // ----------------------------------------------------------------------------- @@ -320,7 +321,7 @@ void OCopyTableWizard::CheckColumns() Reference< XDatabaseMetaData > xMetaData(m_xConnection->getMetaData()); sal_Bool bPKeyAllowed = xMetaData->supportsCoreSQLGrammar(); - if(m_vDestColumns.size()) + if(!m_vDestColumns.empty()) { // we have dest columns so look for the column matching ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin(); for(;aSrcIter != m_vSourceVec.end();++aSrcIter) @@ -504,25 +505,26 @@ void OCopyTableWizard::insertColumn(sal_Int32 _nPos,OFieldDescription* _pField) m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first); } // ----------------------------------------------------------------------------- -void OCopyTableWizard::loadData() +void OCopyTableWizard::loadData(const Reference<XPropertySet>& _xTable, + ODatabaseExport::TColumns& _rColumns, + ODatabaseExport::TColumnVector& _rColVector) { - ODatabaseExport::TColumns::iterator aIter = m_vSourceColumns.begin(); + ODatabaseExport::TColumns::iterator aIter = _rColumns.begin(); - for(;aIter != m_vSourceColumns.end();++aIter) + for(;aIter != _rColumns.end();++aIter) delete aIter->second; - m_vSourceVec.clear(); - m_vSourceColumns.clear(); + _rColVector.clear(); + _rColumns.clear(); OSL_ENSURE(m_xConnection.is(),"OCopyTableWizard::CheckColumns: No connection!"); if(m_xConnection.is()) { - Reference< XDatabaseMetaData> xMetaData = m_xConnection->getMetaData(); ////////////////////////////////////////////////////////////////////// // Datenstruktur mit Daten aus DatenDefinitionsObjekt fuellen - if(m_xSourceObject.is()) + if(_xTable.is()) { - Reference<XColumnsSupplier> xColSup(m_xSourceObject,UNO_QUERY); + Reference<XColumnsSupplier> xColSup(_xTable,UNO_QUERY); OSL_ENSURE(xColSup.is(),"No XColumnsSupplier!"); Reference<XNameAccess> xColumns = xColSup->getColumns(); OFieldDescription* pActFieldDescr = NULL; @@ -583,12 +585,10 @@ void OCopyTableWizard::loadData() pActFieldDescr->SetPrecision(::std::min<sal_Int32>(nPrec,pTypeInfo->nPrecision)); } } - - m_vSourceColumns[pActFieldDescr->GetName()] = pActFieldDescr; - m_vSourceVec.push_back(m_vSourceColumns.insert(ODatabaseExport::TColumns::value_type(pActFieldDescr->GetName(),pActFieldDescr)).first); + _rColVector.push_back(_rColumns.insert(ODatabaseExport::TColumns::value_type(pActFieldDescr->GetName(),pActFieldDescr)).first); } // fill the primary key information - Reference<XNameAccess> xKeyColumns = getKeyColumns(); + Reference<XNameAccess> xKeyColumns = getKeyColumns(_xTable); if(xKeyColumns.is()) { Sequence< ::rtl::OUString> aKeyColumns = xKeyColumns->getElementNames(); @@ -597,8 +597,8 @@ void OCopyTableWizard::loadData() for(;pKeyBegin != pKeyEnd;++pKeyBegin) { - ODatabaseExport::TColumns::iterator aIter = m_vSourceColumns.find(*pKeyBegin); - if(aIter != m_vSourceColumns.end()) + ODatabaseExport::TColumns::iterator aIter = _rColumns.find(*pKeyBegin); + if(aIter != _rColumns.end()) aIter->second->SetPrimaryKey(sal_True); } } @@ -617,11 +617,11 @@ void OCopyTableWizard::clearDestColumns() m_vDestColumns.clear(); } // ----------------------------------------------------------------------------- -Reference<XNameAccess> OCopyTableWizard::getKeyColumns() const +Reference<XNameAccess> OCopyTableWizard::getKeyColumns(const Reference<XPropertySet>& _xTable) const { // use keys and indexes for excat postioning // first the keys - Reference<XKeysSupplier> xKeySup(m_xSourceObject,UNO_QUERY); + Reference<XKeysSupplier> xKeySup(_xTable,UNO_QUERY); Reference<XIndexAccess> xKeys; if(xKeySup.is()) xKeys = xKeySup->getKeys(); diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 7e04a31b0c7d..b494bb72b5bf 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -2,9 +2,9 @@ * * $RCSfile: WNameMatch.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: fme $ $Date: 2001-06-21 15:26:43 $ + * last change: $Author: oj $ $Date: 2001-08-08 08:24:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,6 +126,11 @@ OWizNameMatching::OWizNameMatching( Window* pParent) m_CTRL_LEFT.SetWindowBits( WB_FORCE_MAKEVISIBLE ); m_CTRL_RIGHT.SetWindowBits( WB_FORCE_MAKEVISIBLE ); + m_sSourceText = m_FT_TABLE_LEFT.GetText(); + m_sSourceText.AppendAscii("\n"); + m_sDestText = m_FT_TABLE_RIGHT.GetText(); + m_sDestText.AppendAscii("\n"); + FreeResource(); } // ----------------------------------------------------------------------- @@ -139,7 +144,18 @@ void OWizNameMatching::Reset() { // urspr"unglichen zustand wiederherstellen DBG_CHKTHIS(OWizNameMatching,NULL); - m_bFirstTime = sal_False; + // the left tree contains bitmaps so i need to resize the right one + if(m_bFirstTime) + { + m_CTRL_RIGHT.SetReadOnly(); // sets autoinc to readonly + m_CTRL_RIGHT.SetEntryHeight(m_CTRL_LEFT.GetEntryHeight()); + m_CTRL_RIGHT.SetIndent(m_CTRL_LEFT.GetIndent()); + m_CTRL_RIGHT.SetSpaceBetweenEntries(m_CTRL_LEFT.GetSpaceBetweenEntries()); + + m_bFirstTime = sal_False; + } + + // m_CTRL_LEFT.Clear(); } // ----------------------------------------------------------------------- void OWizNameMatching::ActivatePage( ) @@ -147,28 +163,21 @@ void OWizNameMatching::ActivatePage( ) DBG_CHKTHIS(OWizNameMatching,NULL); // set source table name - String aName = m_FT_TABLE_LEFT.GetText(); - aName.AppendAscii("\n"); + String aName = m_sSourceText; + aName += String(m_pParent->m_sSourceName); - aName += String(m_pParent->m_sName); m_FT_TABLE_LEFT.SetText(aName); // set dest table name - aName = m_FT_TABLE_RIGHT.GetText(); - aName.AppendAscii("\n"); - - // aName += ; + aName = m_sDestText; + aName += String(m_pParent->m_sName); m_FT_TABLE_RIGHT.SetText(aName); - m_CTRL_RIGHT.SetReadOnly(); // sets autoinc to readonly - m_CTRL_LEFT.FillListBox(*m_pParent->getSrcVector()); - // the left tree contains bitmaps so i need to resize the right one - m_CTRL_RIGHT.SetEntryHeight(m_CTRL_LEFT.GetEntryHeight()); - m_CTRL_RIGHT.SetIndent(m_CTRL_LEFT.GetIndent()); - m_CTRL_RIGHT.SetSpaceBetweenEntries(m_CTRL_LEFT.GetSpaceBetweenEntries()); + m_CTRL_LEFT.FillListBox(*m_pParent->getSrcVector()); m_CTRL_RIGHT.FillListBox(*m_pParent->getDestVector()); + m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False); m_CTRL_LEFT.GrabFocus(); } @@ -178,12 +187,12 @@ sal_Bool OWizNameMatching::LeavePage() DBG_CHKTHIS(OWizNameMatching,NULL); const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector(); - ODatabaseExport::TColumnVector::const_iterator aIter = pSrcColumns->begin(); - for(;aIter != pSrcColumns->end();++aIter) - { - m_pParent->m_vColumnPos.push_back(CONTAINER_ENTRY_NOTFOUND); - m_pParent->m_vColumnTypes.push_back(0); - } + + m_pParent->m_vColumnPos.clear(); + m_pParent->m_vColumnTypes.clear(); + m_pParent->m_vColumnPos.resize(pSrcColumns->size(),CONTAINER_ENTRY_NOTFOUND); + m_pParent->m_vColumnTypes.resize(pSrcColumns->size(),CONTAINER_ENTRY_NOTFOUND); + const ODatabaseExport::TColumns* pDestColumns = m_pParent->getSourceColumns(); @@ -200,13 +209,13 @@ sal_Bool OWizNameMatching::LeavePage() sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pLeftEntry); if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED) { - const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); + const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin(); for(;aDestIter != pDestColumns->end();++aDestIter) if((*aDestIter)->second == pDestField) break; - m_pParent->m_vColumnPos[nPos] = pSrcColumns->end() - aDestIter; + m_pParent->m_vColumnPos[nPos] = pDestColumns->end() - aDestIter; m_pParent->m_vColumnTypes[nPos] = pDestField->GetType(); } else |