1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10*2a97ec55SAndrew Rist * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2a97ec55SAndrew Rist * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19*2a97ec55SAndrew Rist * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir #include "commonpagesdbp.hxx" 27cdf0e10cSrcweir #ifndef _EXTENSIONS_DBP_DBPRESID_HRC_ 28cdf0e10cSrcweir #include "dbpresid.hrc" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #include "componentmodule.hxx" 31cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32cdf0e10cSrcweir #include <com/sun/star/sdb/XCompletedConnection.hpp> 33cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 34cdf0e10cSrcweir #include <com/sun/star/sdb/XQueriesSupplier.hpp> 35cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 36cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp> 37cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp> 38cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 39cdf0e10cSrcweir #include <tools/debug.hxx> 40cdf0e10cSrcweir #include <svtools/localresaccess.hxx> 41cdf0e10cSrcweir #include <comphelper/interaction.hxx> 42cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 43cdf0e10cSrcweir #include <vcl/stdtext.hxx> 44cdf0e10cSrcweir #include <vcl/waitobj.hxx> 45cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 46cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 47cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx> 48cdf0e10cSrcweir #ifndef SVTOOLS_FILENOTATION_HXX_ 49cdf0e10cSrcweir #include <svl/filenotation.hxx> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir //......................................................................... 52cdf0e10cSrcweir namespace dbp 53cdf0e10cSrcweir { 54cdf0e10cSrcweir //......................................................................... 55cdf0e10cSrcweir 56cdf0e10cSrcweir using namespace ::com::sun::star::uno; 57cdf0e10cSrcweir using namespace ::com::sun::star::lang; 58cdf0e10cSrcweir using namespace ::com::sun::star::container; 59cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 60cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 61cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 62cdf0e10cSrcweir using namespace ::com::sun::star::task; 63cdf0e10cSrcweir using namespace ::comphelper; 64cdf0e10cSrcweir 65cdf0e10cSrcweir //===================================================================== 66cdf0e10cSrcweir //= OTableSelectionPage 67cdf0e10cSrcweir //===================================================================== 68cdf0e10cSrcweir //--------------------------------------------------------------------- OTableSelectionPage(OControlWizard * _pParent)69cdf0e10cSrcweir OTableSelectionPage::OTableSelectionPage(OControlWizard* _pParent) 70cdf0e10cSrcweir :OControlWizardPage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION)) 71cdf0e10cSrcweir ,m_aData (this, ModuleRes(FL_DATA)) 72cdf0e10cSrcweir ,m_aExplanation (this, ModuleRes(FT_EXPLANATION)) 73cdf0e10cSrcweir ,m_aDatasourceLabel (this, ModuleRes(FT_DATASOURCE)) 74cdf0e10cSrcweir ,m_aDatasource (this, ModuleRes(LB_DATASOURCE)) 75cdf0e10cSrcweir ,m_aSearchDatabase (this, ModuleRes(PB_FORMDATASOURCE)) 76cdf0e10cSrcweir ,m_aTableLabel (this, ModuleRes(FT_TABLE)) 77cdf0e10cSrcweir ,m_aTable (this, ModuleRes(LB_TABLE)) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir FreeResource(); 80cdf0e10cSrcweir 81cdf0e10cSrcweir implCollectDatasource(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir m_aDatasource.SetSelectHdl(LINK(this, OTableSelectionPage, OnListboxSelection)); 84cdf0e10cSrcweir m_aTable.SetSelectHdl(LINK(this, OTableSelectionPage, OnListboxSelection)); 85cdf0e10cSrcweir m_aTable.SetDoubleClickHdl(LINK(this, OTableSelectionPage, OnListboxDoubleClicked)); 86cdf0e10cSrcweir m_aSearchDatabase.SetClickHdl(LINK(this, OTableSelectionPage, OnSearchClicked)); 87cdf0e10cSrcweir 88cdf0e10cSrcweir m_aDatasource.SetDropDownLineCount(10); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir //--------------------------------------------------------------------- ActivatePage()92cdf0e10cSrcweir void OTableSelectionPage::ActivatePage() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir OControlWizardPage::ActivatePage(); 95cdf0e10cSrcweir m_aDatasource.GrabFocus(); 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir //--------------------------------------------------------------------- canAdvance() const99cdf0e10cSrcweir bool OTableSelectionPage::canAdvance() const 100cdf0e10cSrcweir { 101cdf0e10cSrcweir if (!OControlWizardPage::canAdvance()) 102cdf0e10cSrcweir return false; 103cdf0e10cSrcweir 104cdf0e10cSrcweir if (0 == m_aDatasource.GetSelectEntryCount()) 105cdf0e10cSrcweir return false; 106cdf0e10cSrcweir 107cdf0e10cSrcweir if (0 == m_aTable.GetSelectEntryCount()) 108cdf0e10cSrcweir return false; 109cdf0e10cSrcweir 110cdf0e10cSrcweir return sal_True; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir //--------------------------------------------------------------------- initializePage()114cdf0e10cSrcweir void OTableSelectionPage::initializePage() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir OControlWizardPage::initializePage(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir const OControlWizardContext& rContext = getContext(); 119cdf0e10cSrcweir try 120cdf0e10cSrcweir { 121cdf0e10cSrcweir ::rtl::OUString sDataSourceName; 122cdf0e10cSrcweir rContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSourceName; 123cdf0e10cSrcweir 124cdf0e10cSrcweir Reference< XConnection > xConnection; 125cdf0e10cSrcweir bool bEmbedded = ::dbtools::isEmbeddedInDatabase( rContext.xForm, xConnection ); 126cdf0e10cSrcweir if ( bEmbedded ) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir m_aDatasource.Hide(); 129cdf0e10cSrcweir m_aDatasourceLabel.Hide(); 130cdf0e10cSrcweir m_aSearchDatabase.Hide(); 131cdf0e10cSrcweir m_aTableLabel.SetPosPixel(m_aDatasourceLabel.GetPosPixel()); 132cdf0e10cSrcweir m_aTable.SetPosPixel(m_aDatasource.GetPosPixel()); 133cdf0e10cSrcweir m_aDatasource.InsertEntry(sDataSourceName); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir m_aDatasource.SelectEntry(sDataSourceName); 136cdf0e10cSrcweir 137cdf0e10cSrcweir implFillTables(xConnection); 138cdf0e10cSrcweir 139cdf0e10cSrcweir ::rtl::OUString sCommand; 140cdf0e10cSrcweir OSL_VERIFY( rContext.xForm->getPropertyValue( ::rtl::OUString::createFromAscii("Command") ) >>= sCommand ); 141cdf0e10cSrcweir sal_Int32 nCommandType = CommandType::TABLE; 142cdf0e10cSrcweir OSL_VERIFY( rContext.xForm->getPropertyValue( ::rtl::OUString::createFromAscii("CommandType") ) >>= nCommandType ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // search the entry of the given type with the given name 145cdf0e10cSrcweir XubString sLookup( sCommand ); 146cdf0e10cSrcweir for ( sal_uInt16 nLookup = 0; nLookup < m_aTable.GetEntryCount(); ++nLookup ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir if ( m_aTable.GetEntry( nLookup ) == sLookup ) 149cdf0e10cSrcweir if ( reinterpret_cast< sal_IntPtr >( m_aTable.GetEntryData( nLookup ) ) == nCommandType ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir m_aTable.SelectEntryPos( nLookup ); 152cdf0e10cSrcweir break; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir } 155cdf0e10cSrcweir } 156cdf0e10cSrcweir catch(Exception&) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::initializePage: caught an exception!"); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir //--------------------------------------------------------------------- commitPage(::svt::WizardTypes::CommitPageReason _eReason)163cdf0e10cSrcweir sal_Bool OTableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir if (!OControlWizardPage::commitPage(_eReason)) 166cdf0e10cSrcweir return sal_False; 167cdf0e10cSrcweir 168cdf0e10cSrcweir const OControlWizardContext& rContext = getContext(); 169cdf0e10cSrcweir try 170cdf0e10cSrcweir { 171cdf0e10cSrcweir Reference< XConnection > xOldConn; 172cdf0e10cSrcweir if ( !rContext.bEmbedded ) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir xOldConn = getFormConnection(); 175cdf0e10cSrcweir 176cdf0e10cSrcweir ::rtl::OUString sDataSource = m_aDatasource.GetSelectEntry(); 177cdf0e10cSrcweir rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("DataSourceName"), makeAny( sDataSource ) ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir ::rtl::OUString sCommand = m_aTable.GetSelectEntry(); 180cdf0e10cSrcweir sal_Int32 nCommandType = reinterpret_cast< sal_IntPtr >( m_aTable.GetEntryData( m_aTable.GetSelectEntryPos() ) ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("Command"), makeAny( sCommand ) ); 183cdf0e10cSrcweir rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("CommandType"), makeAny( nCommandType ) ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir if ( !rContext.bEmbedded ) 186cdf0e10cSrcweir setFormConnection( xOldConn, sal_False ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if (!updateContext()) 189cdf0e10cSrcweir return sal_False; 190cdf0e10cSrcweir } 191cdf0e10cSrcweir catch(Exception&) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::commitPage: caught an exception!"); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir return sal_True; 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir //--------------------------------------------------------------------- 200cdf0e10cSrcweir IMPL_LINK( OTableSelectionPage, OnSearchClicked, PushButton*, /*_pButton*/ ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK); 203cdf0e10cSrcweir aFileDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)"); 206cdf0e10cSrcweir const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType); 207cdf0e10cSrcweir OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!"); 208cdf0e10cSrcweir if ( pFilter ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension()); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir if (0 == aFileDlg.Execute()) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir String sDataSourceName = aFileDlg.GetPath(); 216cdf0e10cSrcweir ::svt::OFileNotation aFileNotation(sDataSourceName); 217cdf0e10cSrcweir sDataSourceName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM); 218cdf0e10cSrcweir m_aDatasource.InsertEntry(sDataSourceName); 219cdf0e10cSrcweir m_aDatasource.SelectEntry(sDataSourceName); 220cdf0e10cSrcweir LINK(this, OTableSelectionPage, OnListboxSelection).Call(&m_aDatasource); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir return 0L; 223cdf0e10cSrcweir } 224cdf0e10cSrcweir //--------------------------------------------------------------------- IMPL_LINK(OTableSelectionPage,OnListboxDoubleClicked,ListBox *,_pBox)225cdf0e10cSrcweir IMPL_LINK( OTableSelectionPage, OnListboxDoubleClicked, ListBox*, _pBox ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir if (_pBox->GetSelectEntryCount()) 228cdf0e10cSrcweir getDialog()->travelNext(); 229cdf0e10cSrcweir return 0L; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir //--------------------------------------------------------------------- IMPL_LINK(OTableSelectionPage,OnListboxSelection,ListBox *,_pBox)233cdf0e10cSrcweir IMPL_LINK( OTableSelectionPage, OnListboxSelection, ListBox*, _pBox ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir if (&m_aDatasource == _pBox) 236cdf0e10cSrcweir { // new data source selected 237cdf0e10cSrcweir implFillTables(); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir else 240cdf0e10cSrcweir { 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir updateDialogTravelUI(); 244cdf0e10cSrcweir 245cdf0e10cSrcweir return 0L; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir //--------------------------------------------------------------------- 249cdf0e10cSrcweir namespace 250cdf0e10cSrcweir { lcl_fillEntries(ListBox & _rListBox,const Sequence<::rtl::OUString> & _rNames,const Image & _rImage,sal_Int32 _nCommandType)251cdf0e10cSrcweir void lcl_fillEntries( ListBox& _rListBox, const Sequence< ::rtl::OUString >& _rNames, const Image& _rImage, sal_Int32 _nCommandType ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir const ::rtl::OUString* pNames = _rNames.getConstArray(); 254cdf0e10cSrcweir const ::rtl::OUString* pNamesEnd = _rNames.getConstArray() + _rNames.getLength(); 255cdf0e10cSrcweir sal_uInt16 nPos = 0; 256cdf0e10cSrcweir while ( pNames != pNamesEnd ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir nPos = _rListBox.InsertEntry( *pNames++, _rImage ); 259cdf0e10cSrcweir _rListBox.SetEntryData( nPos, reinterpret_cast< void* >( _nCommandType ) ); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir //--------------------------------------------------------------------- implFillTables(const Reference<XConnection> & _rxConn)265cdf0e10cSrcweir void OTableSelectionPage::implFillTables(const Reference< XConnection >& _rxConn) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir m_aTable.Clear(); 268cdf0e10cSrcweir 269cdf0e10cSrcweir WaitObject aWaitCursor(this); 270cdf0e10cSrcweir 271cdf0e10cSrcweir // will be the table tables of the selected data source 272cdf0e10cSrcweir Sequence< ::rtl::OUString > aTableNames; 273cdf0e10cSrcweir Sequence< ::rtl::OUString > aQueryNames; 274cdf0e10cSrcweir 275cdf0e10cSrcweir // connect to the data source 276cdf0e10cSrcweir Any aSQLException; 277cdf0e10cSrcweir Reference< XConnection > xConn = _rxConn; 278cdf0e10cSrcweir if ( !xConn.is() ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir if (!m_xDSContext.is()) 281cdf0e10cSrcweir return; 282cdf0e10cSrcweir // connect to the data source 283cdf0e10cSrcweir try 284cdf0e10cSrcweir { 285cdf0e10cSrcweir ::rtl::OUString sCurrentDatasource = m_aDatasource.GetSelectEntry(); 286cdf0e10cSrcweir if (sCurrentDatasource.getLength()) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir // obtain the DS object 289cdf0e10cSrcweir Reference< XCompletedConnection > xDatasource; 290cdf0e10cSrcweir // check if I know this one otherwise transform it into a file URL 291cdf0e10cSrcweir if ( !m_xDSContext->hasByName(sCurrentDatasource) ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir ::svt::OFileNotation aFileNotation(sCurrentDatasource); 294cdf0e10cSrcweir sCurrentDatasource = aFileNotation.get(::svt::OFileNotation::N_URL); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir if (m_xDSContext->getByName(sCurrentDatasource) >>= xDatasource) 298cdf0e10cSrcweir { // connect 299cdf0e10cSrcweir // get the default SDB interaction handler 300cdf0e10cSrcweir Reference< XInteractionHandler > xHandler = getDialog()->getInteractionHandler(this); 301cdf0e10cSrcweir if (!xHandler.is() ) 302cdf0e10cSrcweir return; 303cdf0e10cSrcweir xConn = xDatasource->connectWithCompletion(xHandler); 304cdf0e10cSrcweir setFormConnection( xConn ); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir else 307cdf0e10cSrcweir { 308cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::implFillTables: invalid data source object returned by the context"); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir } 311cdf0e10cSrcweir } 312cdf0e10cSrcweir catch(SQLContext& e) { aSQLException <<= e; } 313cdf0e10cSrcweir catch(SQLWarning& e) { aSQLException <<= e; } 314cdf0e10cSrcweir catch(SQLException& e) { aSQLException <<= e; } 315cdf0e10cSrcweir catch (Exception&) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::implFillTables: could not fill the table list!"); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir // will be the table tables of the selected data source 322cdf0e10cSrcweir if ( xConn.is() ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir try 325cdf0e10cSrcweir { 326cdf0e10cSrcweir // get the tables 327cdf0e10cSrcweir Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY); 328cdf0e10cSrcweir if ( xSupplTables.is() ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir Reference< XNameAccess > xTables(xSupplTables->getTables(), UNO_QUERY); 331cdf0e10cSrcweir if (xTables.is()) 332cdf0e10cSrcweir aTableNames = xTables->getElementNames(); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir // and the queries 336cdf0e10cSrcweir Reference< XQueriesSupplier > xSuppQueries( xConn, UNO_QUERY ); 337cdf0e10cSrcweir if ( xSuppQueries.is() ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY ); 340cdf0e10cSrcweir if ( xQueries.is() ) 341cdf0e10cSrcweir aQueryNames = xQueries->getElementNames(); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir catch(SQLContext& e) { aSQLException <<= e; } 345cdf0e10cSrcweir catch(SQLWarning& e) { aSQLException <<= e; } 346cdf0e10cSrcweir catch(SQLException& e) { aSQLException <<= e; } 347cdf0e10cSrcweir catch (Exception&) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::implFillTables: could not fill the table list!"); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir 354cdf0e10cSrcweir if ( aSQLException.hasValue() ) 355cdf0e10cSrcweir { // an SQLException (or derivee) was thrown ... 356cdf0e10cSrcweir Reference< XInteractionRequest > xRequest = new OInteractionRequest(aSQLException); 357cdf0e10cSrcweir try 358cdf0e10cSrcweir { 359cdf0e10cSrcweir // get the default SDB interaction handler 360cdf0e10cSrcweir Reference< XInteractionHandler > xHandler = getDialog()->getInteractionHandler(this); 361cdf0e10cSrcweir if ( xHandler.is() ) 362cdf0e10cSrcweir xHandler->handle(xRequest); 363cdf0e10cSrcweir } 364cdf0e10cSrcweir catch(Exception&) { } 365cdf0e10cSrcweir return; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir Image aTableImage, aQueryImage; 369cdf0e10cSrcweir { 370cdf0e10cSrcweir ::svt::OLocalResourceAccess aLocalResAccess( ModuleRes( RID_PAGE_TABLESELECTION ), RSC_TABPAGE ); 371cdf0e10cSrcweir 372cdf0e10cSrcweir bool bIsHiContrast = m_aTable.GetSettings().GetStyleSettings().GetHighContrastMode(); 373cdf0e10cSrcweir aTableImage = Image( ModuleRes( bIsHiContrast ? IMG_TABLE_HC : IMG_TABLE ) ); 374cdf0e10cSrcweir aQueryImage = Image( ModuleRes( bIsHiContrast ? IMG_QUERY_HC : IMG_QUERY ) ); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir lcl_fillEntries( m_aTable, aTableNames, aTableImage, CommandType::TABLE ); 377cdf0e10cSrcweir lcl_fillEntries( m_aTable, aQueryNames, aQueryImage, CommandType::QUERY ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir //--------------------------------------------------------------------- implCollectDatasource()381cdf0e10cSrcweir void OTableSelectionPage::implCollectDatasource() 382cdf0e10cSrcweir { 383cdf0e10cSrcweir try 384cdf0e10cSrcweir { 385cdf0e10cSrcweir m_xDSContext = getContext().xDatasourceContext; 386cdf0e10cSrcweir if (m_xDSContext.is()) 387cdf0e10cSrcweir fillListBox(m_aDatasource, m_xDSContext->getElementNames()); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir catch (Exception&) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir DBG_ERROR("OTableSelectionPage::implCollectDatasource: could not collect the data source names!"); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir //===================================================================== 396cdf0e10cSrcweir //= OMaybeListSelectionPage 397cdf0e10cSrcweir //===================================================================== 398cdf0e10cSrcweir //--------------------------------------------------------------------- OMaybeListSelectionPage(OControlWizard * _pParent,const ResId & _rId)399cdf0e10cSrcweir OMaybeListSelectionPage::OMaybeListSelectionPage( OControlWizard* _pParent, const ResId& _rId ) 400cdf0e10cSrcweir :OControlWizardPage(_pParent, _rId) 401cdf0e10cSrcweir ,m_pYes(NULL) 402cdf0e10cSrcweir ,m_pNo(NULL) 403cdf0e10cSrcweir ,m_pList(NULL) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir //--------------------------------------------------------------------- announceControls(RadioButton & _rYesButton,RadioButton & _rNoButton,ListBox & _rSelection)408cdf0e10cSrcweir void OMaybeListSelectionPage::announceControls(RadioButton& _rYesButton, RadioButton& _rNoButton, ListBox& _rSelection) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir m_pYes = &_rYesButton; 411cdf0e10cSrcweir m_pNo = &_rNoButton; 412cdf0e10cSrcweir m_pList = &_rSelection; 413cdf0e10cSrcweir 414cdf0e10cSrcweir m_pYes->SetClickHdl(LINK(this, OMaybeListSelectionPage, OnRadioSelected)); 415cdf0e10cSrcweir m_pNo->SetClickHdl(LINK(this, OMaybeListSelectionPage, OnRadioSelected)); 416cdf0e10cSrcweir implEnableWindows(); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir //--------------------------------------------------------------------- 420cdf0e10cSrcweir IMPL_LINK( OMaybeListSelectionPage, OnRadioSelected, RadioButton*, /*NOTINTERESTEDIN*/ ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir implEnableWindows(); 423cdf0e10cSrcweir return 0L; 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir //--------------------------------------------------------------------- implInitialize(const String & _rSelection)427cdf0e10cSrcweir void OMaybeListSelectionPage::implInitialize(const String& _rSelection) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir DBG_ASSERT(m_pYes, "OMaybeListSelectionPage::implInitialize: no controls announced!"); 430cdf0e10cSrcweir sal_Bool bIsSelection = (0 != _rSelection.Len()); 431cdf0e10cSrcweir m_pYes->Check(bIsSelection); 432cdf0e10cSrcweir m_pNo->Check(!bIsSelection); 433cdf0e10cSrcweir m_pList->Enable(bIsSelection); 434cdf0e10cSrcweir 435cdf0e10cSrcweir m_pList->SelectEntry(bIsSelection ? _rSelection : String()); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir //--------------------------------------------------------------------- implCommit(String & _rSelection)439cdf0e10cSrcweir void OMaybeListSelectionPage::implCommit(String& _rSelection) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir _rSelection = m_pYes->IsChecked() ? m_pList->GetSelectEntry() : String(); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir //--------------------------------------------------------------------- implEnableWindows()445cdf0e10cSrcweir void OMaybeListSelectionPage::implEnableWindows() 446cdf0e10cSrcweir { 447cdf0e10cSrcweir m_pList->Enable(m_pYes->IsChecked()); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir //--------------------------------------------------------------------- ActivatePage()451cdf0e10cSrcweir void OMaybeListSelectionPage::ActivatePage() 452cdf0e10cSrcweir { 453cdf0e10cSrcweir OControlWizardPage::ActivatePage(); 454cdf0e10cSrcweir 455cdf0e10cSrcweir DBG_ASSERT(m_pYes, "OMaybeListSelectionPage::ActivatePage: no controls announced!"); 456cdf0e10cSrcweir if (m_pYes->IsChecked()) 457cdf0e10cSrcweir m_pList->GrabFocus(); 458cdf0e10cSrcweir else 459cdf0e10cSrcweir m_pNo->GrabFocus(); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir //===================================================================== 463cdf0e10cSrcweir //= ODBFieldPage 464cdf0e10cSrcweir //===================================================================== 465cdf0e10cSrcweir //--------------------------------------------------------------------- ODBFieldPage(OControlWizard * _pParent)466cdf0e10cSrcweir ODBFieldPage::ODBFieldPage( OControlWizard* _pParent ) 467cdf0e10cSrcweir :OMaybeListSelectionPage(_pParent, ModuleRes(RID_PAGE_OPTION_DBFIELD)) 468cdf0e10cSrcweir ,m_aFrame (this, ModuleRes(FL_DATABASEFIELD_EXPL)) 469cdf0e10cSrcweir ,m_aDescription (this, ModuleRes(FT_DATABASEFIELD_EXPL)) 470cdf0e10cSrcweir ,m_aQuestion (this, ModuleRes(FT_DATABASEFIELD_QUEST)) 471cdf0e10cSrcweir ,m_aStoreYes (this, ModuleRes(RB_STOREINFIELD_YES)) 472cdf0e10cSrcweir ,m_aStoreNo (this, ModuleRes(LB_STOREINFIELD)) 473cdf0e10cSrcweir ,m_aStoreWhere (this, ModuleRes(RB_STOREINFIELD_NO)) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir FreeResource(); 476cdf0e10cSrcweir announceControls(m_aStoreYes, m_aStoreNo, m_aStoreWhere); 477cdf0e10cSrcweir m_aStoreWhere.SetDropDownLineCount(10); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir //--------------------------------------------------------------------- initializePage()481cdf0e10cSrcweir void ODBFieldPage::initializePage() 482cdf0e10cSrcweir { 483cdf0e10cSrcweir OMaybeListSelectionPage::initializePage(); 484cdf0e10cSrcweir 485cdf0e10cSrcweir // fill the fields page 486cdf0e10cSrcweir fillListBox(m_aStoreWhere, getContext().aFieldNames); 487cdf0e10cSrcweir 488cdf0e10cSrcweir implInitialize(getDBFieldSetting()); 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir //--------------------------------------------------------------------- commitPage(::svt::WizardTypes::CommitPageReason _eReason)492cdf0e10cSrcweir sal_Bool ODBFieldPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) 493cdf0e10cSrcweir { 494cdf0e10cSrcweir if (!OMaybeListSelectionPage::commitPage(_eReason)) 495cdf0e10cSrcweir return sal_False; 496cdf0e10cSrcweir 497cdf0e10cSrcweir implCommit(getDBFieldSetting()); 498cdf0e10cSrcweir 499cdf0e10cSrcweir return sal_True; 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir //......................................................................... 503cdf0e10cSrcweir } // namespace dbp 504cdf0e10cSrcweir //......................................................................... 505cdf0e10cSrcweir 506