1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #ifndef DBAUI_WIZ_NAMEMATCHING_HXX 27cdf0e10cSrcweir #include "WNameMatch.hxx" 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 30cdf0e10cSrcweir #include <tools/debug.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef DBAUI_FIELDDESCRIPTIONS_HXX 33cdf0e10cSrcweir #include "FieldDescriptions.hxx" 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX 36cdf0e10cSrcweir #include "WCopyTable.hxx" 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 39cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _DBU_MISC_HRC_ 42cdf0e10cSrcweir #include "dbu_misc.hrc" 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef DBAUI_WIZARD_PAGES_HRC 45cdf0e10cSrcweir #include "WizardPages.hrc" 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _SV_SCRBAR_HXX 48cdf0e10cSrcweir #include <vcl/scrbar.hxx> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX 51cdf0e10cSrcweir #include "WCopyTable.hxx" 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ 54cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace ::dbaui; 58cdf0e10cSrcweir //======================================================================== 59cdf0e10cSrcweir // OWizColumnSelect 60cdf0e10cSrcweir DBG_NAME(OWizNameMatching) 61cdf0e10cSrcweir //======================================================================== 62cdf0e10cSrcweir OWizNameMatching::OWizNameMatching( Window* pParent) 63cdf0e10cSrcweir :OWizardPage( pParent, ModuleRes( TAB_WIZ_NAME_MATCHING ) ) 64cdf0e10cSrcweir ,m_FT_TABLE_LEFT( this, ModuleRes( FT_TABLE_LEFT ) ) 65cdf0e10cSrcweir ,m_FT_TABLE_RIGHT( this, ModuleRes( FT_TABLE_RIGHT ) ) 66cdf0e10cSrcweir ,m_CTRL_LEFT( this, ModuleRes( CTRL_LEFT ) ) 67cdf0e10cSrcweir ,m_CTRL_RIGHT( this, ModuleRes( CTRL_RIGHT ) ) 68cdf0e10cSrcweir ,m_ibColumn_up( this, ModuleRes( IB_COLUMN_UP ) ) 69cdf0e10cSrcweir ,m_ibColumn_down( this, ModuleRes( IB_COLUMN_DOWN ) ) 70cdf0e10cSrcweir ,m_ibColumn_up_right( this, ModuleRes( IB_COLUMN_UP_RIGHT ) ) 71cdf0e10cSrcweir ,m_ibColumn_down_right( this, ModuleRes( IB_COLUMN_DOWN_RIGHT ) ) 72cdf0e10cSrcweir ,m_pbAll( this, ModuleRes( PB_ALL ) ) 73cdf0e10cSrcweir ,m_pbNone( this, ModuleRes( PB_NONE ) ) 74cdf0e10cSrcweir 75cdf0e10cSrcweir { 76cdf0e10cSrcweir DBG_CTOR(OWizNameMatching,NULL); 77cdf0e10cSrcweir 78cdf0e10cSrcweir m_ibColumn_up.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl)); 79cdf0e10cSrcweir m_ibColumn_down.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl)); 80cdf0e10cSrcweir 81cdf0e10cSrcweir m_ibColumn_up_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl)); 82cdf0e10cSrcweir m_ibColumn_down_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl)); 83cdf0e10cSrcweir 84cdf0e10cSrcweir m_pbAll.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl)); 85cdf0e10cSrcweir m_pbNone.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl)); 86cdf0e10cSrcweir 87cdf0e10cSrcweir m_CTRL_LEFT.SetSelectHdl(LINK(this,OWizNameMatching,TableListClickHdl)); 88cdf0e10cSrcweir m_CTRL_RIGHT.SetSelectHdl(LINK(this,OWizNameMatching,TableListRightSelectHdl)); 89cdf0e10cSrcweir m_CTRL_RIGHT.EnableCheckButton( NULL ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir m_CTRL_LEFT.SetStyle( m_CTRL_LEFT.GetStyle() | WB_FORCE_MAKEVISIBLE ); 92cdf0e10cSrcweir m_CTRL_RIGHT.SetStyle( m_CTRL_RIGHT.GetStyle() | WB_FORCE_MAKEVISIBLE ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir m_sSourceText = m_FT_TABLE_LEFT.GetText(); 95cdf0e10cSrcweir m_sSourceText.AppendAscii("\n"); 96cdf0e10cSrcweir m_sDestText = m_FT_TABLE_RIGHT.GetText(); 97cdf0e10cSrcweir m_sDestText.AppendAscii("\n"); 98cdf0e10cSrcweir 99cdf0e10cSrcweir // set hiContrast 100cdf0e10cSrcweir m_ibColumn_up.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST); 101cdf0e10cSrcweir m_ibColumn_down.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST); 102cdf0e10cSrcweir m_ibColumn_up_right.SetModeImage(ModuleRes(IMG_SORTUP_H),BMP_COLOR_HIGHCONTRAST); 103cdf0e10cSrcweir m_ibColumn_down_right.SetModeImage(ModuleRes(IMG_SORTDOWN_H),BMP_COLOR_HIGHCONTRAST); 104cdf0e10cSrcweir 105cdf0e10cSrcweir FreeResource(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir // ----------------------------------------------------------------------- 108cdf0e10cSrcweir OWizNameMatching::~OWizNameMatching() 109cdf0e10cSrcweir { 110cdf0e10cSrcweir DBG_DTOR(OWizNameMatching,NULL); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir // ----------------------------------------------------------------------- 114cdf0e10cSrcweir void OWizNameMatching::Reset() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir // urspr"unglichen zustand wiederherstellen 117cdf0e10cSrcweir DBG_CHKTHIS(OWizNameMatching,NULL); 118cdf0e10cSrcweir // the left tree contains bitmaps so i need to resize the right one 119cdf0e10cSrcweir if(m_bFirstTime) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir m_CTRL_RIGHT.SetReadOnly(); // sets autoinc to readonly 122cdf0e10cSrcweir m_CTRL_RIGHT.SetEntryHeight(m_CTRL_LEFT.GetEntryHeight()); 123cdf0e10cSrcweir m_CTRL_RIGHT.SetIndent(m_CTRL_LEFT.GetIndent()); 124cdf0e10cSrcweir m_CTRL_RIGHT.SetSpaceBetweenEntries(m_CTRL_LEFT.GetSpaceBetweenEntries()); 125cdf0e10cSrcweir 126cdf0e10cSrcweir m_bFirstTime = sal_False; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir // m_CTRL_LEFT.Clear(); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir // ----------------------------------------------------------------------- 132cdf0e10cSrcweir void OWizNameMatching::ActivatePage( ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir DBG_CHKTHIS(OWizNameMatching,NULL); 135cdf0e10cSrcweir 136cdf0e10cSrcweir // set source table name 137cdf0e10cSrcweir String aName = m_sSourceText; 138cdf0e10cSrcweir aName += String(m_pParent->m_sSourceName); 139cdf0e10cSrcweir 140cdf0e10cSrcweir m_FT_TABLE_LEFT.SetText(aName); 141cdf0e10cSrcweir 142cdf0e10cSrcweir // set dest table name 143cdf0e10cSrcweir aName = m_sDestText; 144cdf0e10cSrcweir aName += String(m_pParent->m_sName); 145cdf0e10cSrcweir m_FT_TABLE_RIGHT.SetText(aName); 146cdf0e10cSrcweir 147cdf0e10cSrcweir 148cdf0e10cSrcweir m_CTRL_LEFT.FillListBox(*m_pParent->getSrcVector()); 149cdf0e10cSrcweir m_CTRL_RIGHT.FillListBox(*m_pParent->getDestVector()); 150cdf0e10cSrcweir 151cdf0e10cSrcweir m_ibColumn_up.Enable( m_CTRL_LEFT.GetEntryCount() > 1 ); 152cdf0e10cSrcweir m_ibColumn_down.Enable( m_CTRL_LEFT.GetEntryCount() > 1 ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir m_ibColumn_up_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 ); 155cdf0e10cSrcweir m_ibColumn_down_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir 158cdf0e10cSrcweir m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False); 159cdf0e10cSrcweir m_CTRL_LEFT.GrabFocus(); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir // ----------------------------------------------------------------------- 162cdf0e10cSrcweir sal_Bool OWizNameMatching::LeavePage() 163cdf0e10cSrcweir { 164cdf0e10cSrcweir DBG_CHKTHIS(OWizNameMatching,NULL); 165cdf0e10cSrcweir 166cdf0e10cSrcweir const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector(); 167cdf0e10cSrcweir 168cdf0e10cSrcweir m_pParent->m_vColumnPos.clear(); 169cdf0e10cSrcweir m_pParent->m_vColumnTypes.clear(); 170cdf0e10cSrcweir m_pParent->m_vColumnPos.resize( pSrcColumns->size(), ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) ); 171cdf0e10cSrcweir m_pParent->m_vColumnTypes.resize( pSrcColumns->size(), COLUMN_POSITION_NOT_FOUND ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir 174cdf0e10cSrcweir sal_Int32 nParamPos = 0; 175cdf0e10cSrcweir SvLBoxEntry* pLeftEntry = m_CTRL_LEFT.GetModel()->First(); 176cdf0e10cSrcweir SvLBoxEntry* pRightEntry = m_CTRL_RIGHT.GetModel()->First(); 177cdf0e10cSrcweir while(pLeftEntry && pRightEntry) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir OFieldDescription* pSrcField = static_cast<OFieldDescription*>(pLeftEntry->GetUserData()); 180cdf0e10cSrcweir DBG_ASSERT(pSrcField,"OWizNameMatching: OColumn can not be null!"); 181cdf0e10cSrcweir 182cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aSrcIter = pSrcColumns->begin(); 183cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aSrcEnd = pSrcColumns->end(); 184cdf0e10cSrcweir for(;aSrcIter != aSrcEnd && (*aSrcIter)->second != pSrcField;++aSrcIter) 185cdf0e10cSrcweir ; 186cdf0e10cSrcweir const sal_Int32 nPos = ::std::distance(pSrcColumns->begin(),aSrcIter); 187cdf0e10cSrcweir 188cdf0e10cSrcweir // sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pLeftEntry); 189cdf0e10cSrcweir if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir OFieldDescription* pDestField = static_cast<OFieldDescription*>(pRightEntry->GetUserData()); 192cdf0e10cSrcweir DBG_ASSERT(pDestField,"OWizNameMatching: OColumn can not be null!"); 193cdf0e10cSrcweir const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector(); 194cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin(); 195cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter) 198cdf0e10cSrcweir ; 199cdf0e10cSrcweir 200cdf0e10cSrcweir OSL_ENSURE((nPos) < static_cast<sal_Int32>(m_pParent->m_vColumnPos.size()),"m_pParent->m_vColumnPos: Illegal index for vector"); 201cdf0e10cSrcweir m_pParent->m_vColumnPos[nPos].first = ++nParamPos; 202cdf0e10cSrcweir m_pParent->m_vColumnPos[nPos].second = ::std::distance(pDestColumns->begin(),aDestIter) + 1; 203cdf0e10cSrcweir sal_Bool bNotConvert = sal_True; 204cdf0e10cSrcweir TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); 205cdf0e10cSrcweir sal_Int32 nType = ::com::sun::star::sdbc::DataType::VARCHAR; 206cdf0e10cSrcweir if ( pTypeInfo.get() ) 207cdf0e10cSrcweir nType = pTypeInfo->nType; 208cdf0e10cSrcweir m_pParent->m_vColumnTypes[nPos] = nType; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir else 211cdf0e10cSrcweir { 212cdf0e10cSrcweir m_pParent->m_vColumnPos[nPos].first = COLUMN_POSITION_NOT_FOUND; 213cdf0e10cSrcweir m_pParent->m_vColumnPos[nPos].second = COLUMN_POSITION_NOT_FOUND; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir pLeftEntry = m_CTRL_LEFT.GetModel()->Next(pLeftEntry); 217cdf0e10cSrcweir pRightEntry = m_CTRL_RIGHT.GetModel()->Next(pRightEntry); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir return sal_True; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir // ----------------------------------------------------------------------- 223cdf0e10cSrcweir String OWizNameMatching::GetTitle() const { return String(ModuleRes(STR_WIZ_NAME_MATCHING_TITEL)); } 224cdf0e10cSrcweir // ----------------------------------------------------------------------- 225cdf0e10cSrcweir IMPL_LINK( OWizNameMatching, ButtonClickHdl, Button *, pButton ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected(); 228cdf0e10cSrcweir if ( pEntry ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry); 231cdf0e10cSrcweir if(pButton == &m_ibColumn_up && nPos) 232cdf0e10cSrcweir --nPos; 233cdf0e10cSrcweir else if(pButton == &m_ibColumn_down) 234cdf0e10cSrcweir nPos += 2; 235cdf0e10cSrcweir 236cdf0e10cSrcweir m_CTRL_LEFT.ModelIsMoving(pEntry,NULL,nPos); 237cdf0e10cSrcweir m_CTRL_LEFT.GetModel()->Move(pEntry,NULL,nPos); 238cdf0e10cSrcweir m_CTRL_LEFT.ModelHasMoved(pEntry); 239cdf0e10cSrcweir 240cdf0e10cSrcweir long nThumbPos = m_CTRL_LEFT.GetVScroll()->GetThumbPos(); 241cdf0e10cSrcweir long nVisibleSize = m_CTRL_LEFT.GetVScroll()->GetVisibleSize(); 242cdf0e10cSrcweir 243cdf0e10cSrcweir if(pButton == &m_ibColumn_down && (nThumbPos+nVisibleSize+1) < nPos) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir m_CTRL_LEFT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN); 246cdf0e10cSrcweir // m_CTRL_LEFT.MakeVisible(pEntry,sal_True); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir TableListClickHdl(&m_CTRL_LEFT); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir 253cdf0e10cSrcweir return 0; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir //------------------------------------------------------------------------------ 256cdf0e10cSrcweir IMPL_LINK( OWizNameMatching, RightButtonClickHdl, Button *, pButton ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected(); 259cdf0e10cSrcweir if ( pEntry ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir sal_Int32 nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry); 262cdf0e10cSrcweir if(pButton == &m_ibColumn_up_right && nPos) 263cdf0e10cSrcweir --nPos; 264cdf0e10cSrcweir else if(pButton == &m_ibColumn_down_right) 265cdf0e10cSrcweir nPos += 2; 266cdf0e10cSrcweir 267cdf0e10cSrcweir m_CTRL_RIGHT.ModelIsMoving(pEntry,NULL,nPos); 268cdf0e10cSrcweir m_CTRL_RIGHT.GetModel()->Move(pEntry,NULL,nPos); 269cdf0e10cSrcweir m_CTRL_RIGHT.ModelHasMoved(pEntry); 270cdf0e10cSrcweir long nThumbPos = m_CTRL_RIGHT.GetVScroll()->GetThumbPos(); 271cdf0e10cSrcweir long nVisibleSize = m_CTRL_RIGHT.GetVScroll()->GetVisibleSize(); 272cdf0e10cSrcweir 273cdf0e10cSrcweir if(pButton == &m_ibColumn_down_right && (nThumbPos+nVisibleSize+1) < nPos) 274cdf0e10cSrcweir m_CTRL_RIGHT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN); 275cdf0e10cSrcweir TableListRightSelectHdl(&m_CTRL_RIGHT); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir return 0; 278cdf0e10cSrcweir } 279cdf0e10cSrcweir //------------------------------------------------------------------------------ 280cdf0e10cSrcweir IMPL_LINK( OWizNameMatching, TableListClickHdl, void*, /*NOTINTERESTEDIN*/ ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected(); 283cdf0e10cSrcweir if(pEntry) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir sal_uLong nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry); 286cdf0e10cSrcweir SvLBoxEntry* pOldEntry = m_CTRL_RIGHT.FirstSelected(); 287cdf0e10cSrcweir if(pOldEntry && nPos != m_CTRL_RIGHT.GetModel()->GetAbsPos(pOldEntry)) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if(pOldEntry) 290cdf0e10cSrcweir m_CTRL_RIGHT.Select(pOldEntry,sal_False); 291cdf0e10cSrcweir pOldEntry = m_CTRL_RIGHT.GetEntry(nPos); 292cdf0e10cSrcweir if(pOldEntry) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir sal_uLong nNewPos = m_CTRL_LEFT.GetModel()->GetAbsPos(m_CTRL_LEFT.GetFirstEntryInView()); 295cdf0e10cSrcweir if ( nNewPos - nPos == 1 ) 296cdf0e10cSrcweir --nNewPos; 297cdf0e10cSrcweir m_CTRL_RIGHT.MakeVisible(m_CTRL_RIGHT.GetEntry(nNewPos),sal_True); 298cdf0e10cSrcweir m_CTRL_RIGHT.Select(pOldEntry,sal_True); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir } 301cdf0e10cSrcweir else if(!pOldEntry) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir pOldEntry = m_CTRL_RIGHT.GetEntry(nPos); 304cdf0e10cSrcweir if(pOldEntry) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir m_CTRL_RIGHT.Select(pOldEntry,sal_True); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir return 0; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir //------------------------------------------------------------------------------ 314cdf0e10cSrcweir IMPL_LINK( OWizNameMatching, TableListRightSelectHdl, void*, /*NOTINTERESTEDIN*/ ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected(); 317cdf0e10cSrcweir if(pEntry) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir sal_uLong nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry); 320cdf0e10cSrcweir SvLBoxEntry* pOldEntry = m_CTRL_LEFT.FirstSelected(); 321cdf0e10cSrcweir if(pOldEntry && nPos != m_CTRL_LEFT.GetModel()->GetAbsPos(pOldEntry)) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir if(pOldEntry) 324cdf0e10cSrcweir m_CTRL_LEFT.Select(pOldEntry,sal_False); 325cdf0e10cSrcweir pOldEntry = m_CTRL_LEFT.GetEntry(nPos); 326cdf0e10cSrcweir if(pOldEntry) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir sal_uLong nNewPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(m_CTRL_RIGHT.GetFirstEntryInView()); 329cdf0e10cSrcweir if ( nNewPos - nPos == 1 ) 330cdf0e10cSrcweir nNewPos--; 331cdf0e10cSrcweir m_CTRL_LEFT.MakeVisible(m_CTRL_LEFT.GetEntry(nNewPos),sal_True); 332cdf0e10cSrcweir m_CTRL_LEFT.Select(pOldEntry,sal_True); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir } 335cdf0e10cSrcweir else if(!pOldEntry) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir pOldEntry = m_CTRL_LEFT.GetEntry(nPos); 338cdf0e10cSrcweir if(pOldEntry) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir m_CTRL_LEFT.Select(pOldEntry,sal_True); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir return 0; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir // ----------------------------------------------------------------------- 348cdf0e10cSrcweir IMPL_LINK( OWizNameMatching, AllNoneClickHdl, Button *, pButton ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir sal_Bool bAll = pButton == &m_pbAll; 351cdf0e10cSrcweir SvLBoxEntry* pEntry = m_CTRL_LEFT.First(); 352cdf0e10cSrcweir while(pEntry) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir m_CTRL_LEFT.SetCheckButtonState( pEntry, bAll ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED); 355cdf0e10cSrcweir pEntry = m_CTRL_LEFT.Next(pEntry); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir return 0; 359cdf0e10cSrcweir } 360cdf0e10cSrcweir // ----------------------------------------------------------------------- 361cdf0e10cSrcweir //======================================================================== 362cdf0e10cSrcweir // class OColumnString 363cdf0e10cSrcweir //======================================================================== 364cdf0e10cSrcweir class OColumnString : public SvLBoxString 365cdf0e10cSrcweir { 366cdf0e10cSrcweir sal_Bool m_bReadOnly; 367cdf0e10cSrcweir public: 368cdf0e10cSrcweir OColumnString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr,sal_Bool _RO) 369cdf0e10cSrcweir :SvLBoxString(pEntry,nFlags,rStr) 370cdf0e10cSrcweir ,m_bReadOnly(_RO) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry); 375cdf0e10cSrcweir //virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData); 376cdf0e10cSrcweir }; 377cdf0e10cSrcweir 378cdf0e10cSrcweir 379cdf0e10cSrcweir 380cdf0e10cSrcweir //------------------------------------------------------------------------ 381cdf0e10cSrcweir /* 382cdf0e10cSrcweir void OColumnString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir SvLBoxString::InitViewData(pView,pEntry,pViewData); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir */ 387cdf0e10cSrcweir //------------------------------------------------------------------------ 388cdf0e10cSrcweir void OColumnString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir if(m_bReadOnly) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir const StyleSettings& rStyleSettings = rDev.GetSettings().GetStyleSettings(); 393cdf0e10cSrcweir rDev.SetTextColor( rStyleSettings.GetDisableColor() ); 394cdf0e10cSrcweir rDev.SetTextFillColor( rStyleSettings.GetFieldColor() ); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir rDev.DrawText( rPos, GetText() ); 397cdf0e10cSrcweir } 398cdf0e10cSrcweir //======================================================================== 399cdf0e10cSrcweir OColumnTreeBox::OColumnTreeBox( Window* pParent, const ResId& rResId ) 400cdf0e10cSrcweir : OMarkableTreeListBox(pParent,NULL,rResId) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir SetDragDropMode( 0 ); 403cdf0e10cSrcweir EnableInplaceEditing( sal_False ); 404cdf0e10cSrcweir SetStyle(GetStyle() | WB_BORDER | WB_HASBUTTONS | WB_HSCROLL); 405cdf0e10cSrcweir SetSelectionMode( SINGLE_SELECTION ); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir //------------------------------------------------------------------------ 408cdf0e10cSrcweir void OColumnTreeBox::InitEntry(SvLBoxEntry* pEntry, const String& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir DBTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); 411cdf0e10cSrcweir SvLBoxString* pString = new OColumnString(pEntry, 0, rStr,sal_False); 412cdf0e10cSrcweir if (pString) 413cdf0e10cSrcweir pEntry->ReplaceItem( pString, pEntry->ItemCount() - 1 ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir //------------------------------------------------------------------------ 416cdf0e10cSrcweir sal_Bool OColumnTreeBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir if(bSelect) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir OFieldDescription* pColumn = static_cast<OFieldDescription*>(pEntry->GetUserData()); 421cdf0e10cSrcweir if(!(pColumn->IsAutoIncrement() && m_bReadOnly)) 422cdf0e10cSrcweir bSelect = DBTreeListBox::Select( pEntry,bSelect ); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir else 425cdf0e10cSrcweir bSelect = DBTreeListBox::Select( pEntry,bSelect ); 426cdf0e10cSrcweir return bSelect; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir //------------------------------------------------------------------------ 429cdf0e10cSrcweir void OColumnTreeBox::FillListBox( const ODatabaseExport::TColumnVector& _rList) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir Clear(); 432cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aIter = _rList.begin(); 433cdf0e10cSrcweir ODatabaseExport::TColumnVector::const_iterator aEnd = _rList.end(); 434cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir SvLBoxEntry* pEntry = InsertEntry((*aIter)->first,0,sal_False,LIST_APPEND,(*aIter)->second); 437cdf0e10cSrcweir SvButtonState eState = !(m_bReadOnly && (*aIter)->second->IsAutoIncrement()) ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED; 438cdf0e10cSrcweir SetCheckButtonState( pEntry, eState ); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir } 441cdf0e10cSrcweir // ----------------------------------------------------------------------------- 442cdf0e10cSrcweir 443cdf0e10cSrcweir 444cdf0e10cSrcweir 445cdf0e10cSrcweir 446cdf0e10cSrcweir 447