merge the formfield patch from ooo-build
[ooovba.git] / dbaccess / source / ui / dlg / tablespage.cxx
blob02883dfce6fc11d36bf0b8108e6e34fda5f5bc31
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tablespage.cxx,v $
10 * $Revision: 1.33.6.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBAUI_TABLESPAGE_HXX_
35 #include "tablespage.hxx"
36 #endif
37 #ifndef _DBU_DLG_HRC_
38 #include "dbu_dlg.hrc"
39 #endif
40 #ifndef _DBAUI_DBADMIN_HRC_
41 #include "dbadmin.hrc"
42 #endif
43 #ifndef _DBAUI_DATASOURCEITEMS_HXX_
44 #include "dsitems.hxx"
45 #endif
46 #ifndef DBACCESS_UI_BROWSER_ID_HXX
47 #include "browserids.hxx"
48 #endif
49 #ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
50 #include "datasourceconnector.hxx"
51 #endif
52 #ifndef _COMPHELPER_TYPES_HXX_
53 #include <comphelper/types.hxx>
54 #endif
55 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
56 #include <connectivity/dbtools.hxx>
57 #endif
58 #ifndef _DBHELPER_DBEXCEPTION_HXX_
59 #include <connectivity/dbexception.hxx>
60 #endif
61 #ifndef _DBAUI_STRINGLISTITEM_HXX_
62 #include "stringlistitem.hxx"
63 #endif
64 #ifndef _SFXENUMITEM_HXX
65 #include <svtools/eitem.hxx>
66 #endif
67 #ifndef _SFXSTRITEM_HXX
68 #include <svtools/stritem.hxx>
69 #endif
70 #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
71 #include "dbustrings.hrc"
72 #endif
73 #ifndef _SV_SVAPP_HXX
74 #include <vcl/svapp.hxx>
75 #endif
76 #ifndef _SV_WAITOBJ_HXX
77 #include <vcl/waitobj.hxx>
78 #endif
79 #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
80 #include <com/sun/star/sdb/SQLContext.hpp>
81 #endif
82 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
83 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
84 #endif
85 #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
86 #include <com/sun/star/sdbcx/XAppend.hpp>
87 #endif
88 #ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
89 #include <com/sun/star/util/XModifiable.hpp>
90 #endif
91 #ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
92 #include <com/sun/star/sdbcx/XDrop.hpp>
93 #endif
94 #ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
95 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
96 #endif
97 #ifndef _DBAUI_SQLMESSAGE_HXX_
98 #include "sqlmessage.hxx"
99 #endif
100 #ifndef _SV_MSGBOX_HXX
101 #include <vcl/msgbox.hxx>
102 #endif
103 #ifndef _DBA_DBACCESS_HELPID_HRC_
104 #include "dbaccess_helpid.hrc"
105 #endif
106 #ifndef DBAUI_TOOLS_HXX
107 #include "UITools.hxx"
108 #endif
109 #ifndef _VOS_MUTEX_HXX_
110 #include <vos/mutex.hxx>
111 #endif
112 #ifndef _SVTOOLS_IMGDEF_HXX
113 #include <svtools/imgdef.hxx>
114 #endif
115 #ifndef _DBAUI_TABLESSINGLEDLG_HXX_
116 #include "TablesSingleDlg.hxx"
117 #endif
118 #ifndef TOOLS_DIAGNOSE_EX_H
119 #include <tools/diagnose_ex.h>
120 #endif
121 #ifndef _CPPUHELPER_EXC_HLP_HXX_
122 #include <cppuhelper/exc_hlp.hxx>
123 #endif
124 #ifndef _DBAUI_AUTOCONTROLS_HRC_
125 #include "AutoControls.hrc"
126 #endif
128 //.........................................................................
129 namespace dbaui
131 //.........................................................................
133 using namespace ::com::sun::star::uno;
134 using namespace ::com::sun::star::sdbc;
135 using namespace ::com::sun::star::sdbcx;
136 using namespace ::com::sun::star::sdb;
137 using namespace ::com::sun::star::beans;
138 using namespace ::com::sun::star::lang;
139 using namespace ::com::sun::star::i18n;
140 using namespace ::com::sun::star::container;
141 using namespace ::com::sun::star::frame;
142 using namespace ::com::sun::star::util;
143 using namespace ::dbtools;
144 using namespace ::comphelper;
146 //========================================================================
147 //= OTableSubscriptionPage
148 //========================================================================
149 DBG_NAME(OTableSubscriptionPage)
150 //------------------------------------------------------------------------
151 OTableSubscriptionPage::OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs,OTableSubscriptionDialog* _pTablesDlg )
152 :OGenericAdministrationPage( pParent, ModuleRes(PAGE_TABLESUBSCRIPTION), _rCoreAttrs )
153 ,m_aTables (this, ModuleRes(FL_SEPARATOR1))
154 ,m_aTablesList (this, NULL,ModuleRes(CTL_TABLESUBSCRIPTION),sal_True)
155 ,m_aExplanation (this, ModuleRes(FT_FILTER_EXPLANATION))
156 ,m_bCheckedAll ( sal_False )
157 ,m_bCatalogAtStart ( sal_True )
158 ,m_pTablesDlg(_pTablesDlg)
160 DBG_CTOR(OTableSubscriptionPage,NULL);
162 m_aTablesList.SetCheckHandler(getControlModifiedLink());
164 // initialize the TabListBox
165 m_aTablesList.SetSelectionMode( MULTIPLE_SELECTION );
166 m_aTablesList.SetDragDropMode( 0 );
167 m_aTablesList.EnableInplaceEditing( sal_False );
168 m_aTablesList.SetWindowBits(WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
170 m_aTablesList.Clear();
172 FreeResource();
174 m_aTablesList.SetCheckButtonHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
175 m_aTablesList.SetCheckHandler(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
178 //------------------------------------------------------------------------
179 OTableSubscriptionPage::~OTableSubscriptionPage()
181 // just to make sure that our connection will be removed
184 ::comphelper::disposeComponent(m_xCurrentConnection);
186 catch (RuntimeException&) { }
188 DBG_DTOR(OTableSubscriptionPage,NULL);
191 // -----------------------------------------------------------------------------
192 void OTableSubscriptionPage::StateChanged( StateChangedType nType )
194 OGenericAdministrationPage::StateChanged( nType );
196 if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
198 // Check if we need to get new images for normal/high contrast mode
199 m_aTablesList.notifyHiContrastChanged();
202 // -----------------------------------------------------------------------------
203 void OTableSubscriptionPage::DataChanged( const DataChangedEvent& rDCEvt )
205 OGenericAdministrationPage::DataChanged( rDCEvt );
207 if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
208 ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) &&
209 ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
211 // Check if we need to get new images for normal/high contrast mode
212 m_aTablesList.notifyHiContrastChanged();
215 //------------------------------------------------------------------
216 void OTableSubscriptionPage::resizeControls(const Size& _rDiff)
218 if ( _rDiff.Height() )
220 Size aOldSize = m_aTablesList.GetSizePixel();
221 aOldSize.Height() -= _rDiff.Height();
222 m_aTablesList.SetPosSizePixel(
223 m_aTablesList.GetPosPixel()+Point(0,_rDiff.Height()),
224 aOldSize
228 //------------------------------------------------------------------------
229 void OTableSubscriptionPage::implCheckTables(const Sequence< ::rtl::OUString >& _rTables)
231 // the meta data for the current connection, used for splitting up table names
232 Reference< XDatabaseMetaData > xMeta;
235 if (m_xCurrentConnection.is())
236 xMeta = m_xCurrentConnection->getMetaData();
238 catch(SQLException&)
240 DBG_ERROR("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!");
243 // uncheck all
244 CheckAll(sal_False);
246 // check the ones which are in the list
247 String aListBoxTable;
248 ::rtl::OUString sCatalog, sSchema, sName;
250 SvLBoxEntry* pRootEntry = m_aTablesList.getAllObjectsEntry();
251 sal_Bool bAllTables = sal_False;
252 sal_Bool bAllSchemas = sal_False;
254 const ::rtl::OUString* pIncludeTable = _rTables.getConstArray();
255 for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable)
257 if (xMeta.is())
258 qualifiedNameComponents(xMeta, pIncludeTable->getStr(), sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
259 else
260 sName = pIncludeTable->getStr();
262 bAllTables = (1 == sName.getLength()) && ('%' == sName[0]);
263 bAllSchemas = (1 == sSchema.getLength()) && ('%' == sSchema[0]);
265 // the catalog entry
266 SvLBoxEntry* pCatalog = m_aTablesList.GetEntryPosByName(sCatalog, pRootEntry);
267 if (!pCatalog && sCatalog.getLength())
268 // the table (resp. its catalog) refered in this filter entry does not exist anymore
269 continue;
271 if (bAllSchemas && pCatalog)
273 m_aTablesList.checkWildcard(pCatalog);
274 continue;
277 // the schema entry
278 SvLBoxEntry* pSchema = m_aTablesList.GetEntryPosByName(sSchema, (pCatalog ? pCatalog : pRootEntry));
279 if (!pSchema && sSchema.getLength())
280 // the table (resp. its schema) refered in this filter entry does not exist anymore
281 continue;
283 if (bAllTables && pSchema)
285 m_aTablesList.checkWildcard(pSchema);
286 continue;
289 SvLBoxEntry* pEntry = m_aTablesList.GetEntryPosByName(sName, pSchema ? pSchema : (pCatalog ? pCatalog : pRootEntry) );
290 if (pEntry)
291 m_aTablesList.SetCheckButtonState(pEntry, SV_BUTTON_CHECKED);
293 m_aTablesList.CheckButtons();
296 //------------------------------------------------------------------------
297 void OTableSubscriptionPage::implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter )
299 if (!_rTableFilter.getLength())
300 { // no tables visible
301 CheckAll(sal_False);
303 else
305 if ((1 == _rTableFilter.getLength()) && _rTableFilter[0].equalsAsciiL("%", 1))
306 { // all tables visible
307 CheckAll(sal_True);
309 else
310 implCheckTables( _rTableFilter );
314 //-------------------------------------------------------------------------
315 void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
317 // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
318 sal_Bool bValid, bReadonly;
319 getFlags(_rSet, bValid, bReadonly);
321 // get the name of the data source we're working for
322 SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
323 DBG_ASSERT(pNameItem, "OTableSubscriptionPage::implInitControls: missing the name attribute!");
324 String sDSName = pNameItem->GetValue();
326 if (bValid && sDSName.Len() && !m_xCurrentConnection.is() )
327 { // get the current table list from the connection for the current settings
329 // the PropertyValues for the current dialog settings
330 Sequence< PropertyValue > aConnectionParams;
331 DBG_ASSERT(m_pTablesDlg, "OTableSubscriptionPage::implInitControls: need a parent dialog doing the translation!");
332 if ( m_pTablesDlg )
334 if (!m_pTablesDlg->getCurrentSettings(aConnectionParams))
336 m_aTablesList.Clear();
337 m_pTablesDlg->endExecution();
338 return;
342 if (!m_xCollator.is())
344 // the collator for the string compares
347 m_xCollator = Reference< XCollator >(m_xORB->createInstance(SERVICE_I18N_COLLATOR), UNO_QUERY);
348 if (m_xCollator.is())
349 m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0);
351 catch(const Exception&)
353 DBG_UNHANDLED_EXCEPTION();
357 // fill the table list with this connection information
358 SQLExceptionInfo aErrorInfo;
359 // the current DSN
360 String sURL;
361 if ( m_pTablesDlg )
362 sURL = m_pTablesDlg->getConnectionURL();
366 WaitObject aWaitCursor(this);
367 m_aTablesList.GetModel()->SetSortMode(SortAscending);
368 m_aTablesList.GetModel()->SetCompareHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryCompare));
370 Reference< XDriver > xDriver;
371 m_aTablesList.setORB(m_xORB);
372 Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource();
373 OSL_ENSURE(xProp.is(),"No data source set!");
374 if ( xProp.is() )
376 Any aTableFilter = xProp->getPropertyValue(PROPERTY_TABLEFILTER);
377 Any aTableTypeFilter = xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER);
379 Reference<XModifiable> xModi(getDataSourceOrModel(xProp),UNO_QUERY);
380 sal_Bool bModified = ( xModi.is() && xModi->isModified() );
382 Sequence< ::rtl::OUString > aNewTableFilter(1);
383 aNewTableFilter[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
384 xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aNewTableFilter));
386 xProp->setPropertyValue( PROPERTY_TABLETYPEFILTER, makeAny( Sequence< ::rtl::OUString >() ) );
387 Reference< ::com::sun::star::lang::XEventListener> xEvt;
388 aErrorInfo = ::dbaui::createConnection(xProp,m_xORB,xEvt,m_xCurrentConnection);
390 xProp->setPropertyValue(PROPERTY_TABLEFILTER,aTableFilter);
391 xProp->setPropertyValue(PROPERTY_TABLETYPEFILTER,aTableTypeFilter);
393 if ( xModi.is() && !bModified )
394 xModi->setModified(sal_False);
398 if ( m_xCurrentConnection.is() )
400 m_aTablesList.UpdateTableList( m_xCurrentConnection );
401 if (m_pTablesDlg)
402 m_pTablesDlg->successfullyConnected();
405 catch (const SQLException&)
407 aErrorInfo = ::cppu::getCaughtException();
410 if (aErrorInfo.isValid())
412 // establishing the connection failed. Show an error window and exit.
413 OSQLMessageBox aMessageBox( GetParent()->GetParent(), aErrorInfo );
414 aMessageBox.Execute();
415 m_aTables.Enable(sal_False);
416 m_aTablesList.Enable(sal_False);
417 m_aExplanation.Enable(sal_False);
418 m_aTablesList.Clear();
420 if ( m_pTablesDlg )
422 m_pTablesDlg->clearPassword();
423 m_pTablesDlg->endExecution();
426 else
428 // in addition, we need some infos about the connection used
429 m_sCatalogSeparator = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); // (default)
430 m_bCatalogAtStart = sal_True; // (default)
433 Reference< XDatabaseMetaData > xMeta;
434 if (m_xCurrentConnection.is())
435 xMeta = m_xCurrentConnection->getMetaData();
436 if (xMeta.is() && xMeta->supportsCatalogsInDataManipulation())
438 m_sCatalogSeparator = xMeta->getCatalogSeparator();
439 m_bCatalogAtStart = xMeta->isCatalogAtStart();
442 catch(Exception&)
444 DBG_UNHANDLED_EXCEPTION();
449 bValid = bValid && m_xCurrentConnection.is();
450 bReadonly = bReadonly || !bValid;
452 // get the current table filter
453 SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, sal_True);
454 SFX_ITEMSET_GET(_rSet, pSuppress, SfxBoolItem, DSID_SUPPRESSVERSIONCL, sal_True);
455 Sequence< ::rtl::OUString > aTableFilter;
456 sal_Bool bSuppressVersionColumns = sal_True;
457 if (pTableFilter)
458 aTableFilter = pTableFilter->getList();
459 if (pSuppress)
460 bSuppressVersionColumns = pSuppress->GetValue();
462 implCompleteTablesCheck( aTableFilter );
464 // expand the first entry by default
465 SvLBoxEntry* pExpand = m_aTablesList.getAllObjectsEntry();
466 while (pExpand)
468 m_aTablesList.Expand(pExpand);
469 pExpand = m_aTablesList.FirstChild(pExpand);
470 if (pExpand && m_aTablesList.NextSibling(pExpand))
471 pExpand = NULL;
474 // update the toolbox according the the current selection and check state
475 OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
478 //------------------------------------------------------------------------
479 void OTableSubscriptionPage::CheckAll( sal_Bool _bCheck )
481 SvButtonState eState = _bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
482 SvLBoxEntry* pEntry = m_aTablesList.First();
483 while (pEntry)
485 m_aTablesList.SetCheckButtonState( pEntry, eState);
486 pEntry = m_aTablesList.Next(pEntry);
489 if (_bCheck && m_aTablesList.getAllObjectsEntry())
490 m_aTablesList.checkWildcard(m_aTablesList.getAllObjectsEntry());
493 //------------------------------------------------------------------------
494 int OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet)
496 int nResult = OGenericAdministrationPage::DeactivatePage(_pSet);
498 // dispose the connection, we don't need it anymore, so we're not wasting resources
501 ::comphelper::disposeComponent(m_xCurrentConnection);
503 catch (RuntimeException&) { }
505 return nResult;
507 //------------------------------------------------------------------------
508 IMPL_LINK( OTableSubscriptionPage, OnTreeEntryChecked, Control*, _pControl )
510 return OnControlModified(_pControl);
512 //------------------------------------------------------------------------
513 IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData )
515 SvLBoxEntry* pLHS = static_cast<SvLBoxEntry*>(_pSortData->pLeft);
516 SvLBoxEntry* pRHS = static_cast<SvLBoxEntry*>(_pSortData->pRight);
517 DBG_ASSERT(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
519 SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
520 SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
521 DBG_ASSERT(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
523 String sLeftText = pLeftTextItem->GetText();
524 String sRightText = pRightTextItem->GetText();
526 sal_Int32 nCompareResult = 0; // equal by default
528 if (m_xCollator.is())
532 nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
534 catch(Exception&)
538 else
539 // default behaviour if we do not have a collator -> do the simple string compare
540 nCompareResult = sLeftText.CompareTo(sRightText);
542 return nCompareResult;
545 //------------------------------------------------------------------------
546 Sequence< ::rtl::OUString > OTableSubscriptionPage::collectDetailedSelection() const
548 Sequence< ::rtl::OUString > aTableFilter;
549 static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM("."));
550 static const ::rtl::OUString sWildcard(RTL_CONSTASCII_USTRINGPARAM("%"));
552 ::rtl::OUString sComposedName;
553 const SvLBoxEntry* pAllObjectsEntry = m_aTablesList.getAllObjectsEntry();
554 if (!pAllObjectsEntry)
555 return aTableFilter;
556 SvLBoxEntry* pEntry = m_aTablesList.GetModel()->Next(const_cast<SvLBoxEntry*>(pAllObjectsEntry));
557 while(pEntry)
559 sal_Bool bCatalogWildcard = sal_False;
560 sal_Bool bSchemaWildcard = sal_False;
561 SvLBoxEntry* pSchema = NULL;
562 SvLBoxEntry* pCatalog = NULL;
564 if (m_aTablesList.GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_aTablesList.GetModel()->HasChilds(pEntry))
565 { // checked and a leaf, which means it's no catalog, no schema, but a real table
566 ::rtl::OUString sCatalog;
567 if(m_aTablesList.GetModel()->HasParent(pEntry))
569 pSchema = m_aTablesList.GetModel()->GetParent(pEntry);
570 if (pAllObjectsEntry == pSchema)
571 // do not want to have the root entry
572 pSchema = NULL;
574 if (pSchema)
575 { // it's a real schema entry, not the "all objects" root
576 if(m_aTablesList.GetModel()->HasParent(pSchema))
578 pCatalog = m_aTablesList.GetModel()->GetParent(pSchema);
579 if (pAllObjectsEntry == pCatalog)
580 // do not want to have the root entry
581 pCatalog = NULL;
583 if (pCatalog)
584 { // it's a real catalog entry, not the "all objects" root
585 bCatalogWildcard = m_aTablesList.isWildcardChecked(pCatalog);
586 if (m_bCatalogAtStart)
588 sComposedName += m_aTablesList.GetEntryText( pCatalog );
589 sComposedName += m_sCatalogSeparator;
590 if (bCatalogWildcard)
591 sComposedName += sWildcard;
593 else
595 if (bCatalogWildcard)
596 sCatalog = sWildcard;
597 else
598 sCatalog = ::rtl::OUString();
599 sCatalog += m_sCatalogSeparator;
600 sCatalog += m_aTablesList.GetEntryText( pCatalog );
604 bSchemaWildcard = m_aTablesList.isWildcardChecked(pSchema);
605 sComposedName += m_aTablesList.GetEntryText( pSchema );
606 sComposedName += sDot;
609 if (bSchemaWildcard)
610 sComposedName += sWildcard;
612 if (!bSchemaWildcard && !bCatalogWildcard)
613 sComposedName += m_aTablesList.GetEntryText( pEntry );
615 if (!m_bCatalogAtStart && !bCatalogWildcard)
616 sComposedName += sCatalog;
618 // need some space
619 sal_Int32 nOldLen = aTableFilter.getLength();
620 aTableFilter.realloc(nOldLen + 1);
621 // add the new name
622 aTableFilter[nOldLen] = sComposedName;
624 // reset the composed name
625 sComposedName = ::rtl::OUString();
628 if (bCatalogWildcard)
629 pEntry = implNextSibling(pCatalog);
630 else if (bSchemaWildcard)
631 pEntry = implNextSibling(pSchema);
632 else
633 pEntry = m_aTablesList.GetModel()->Next(pEntry);
636 return aTableFilter;
639 //------------------------------------------------------------------------
640 SvLBoxEntry* OTableSubscriptionPage::implNextSibling(SvLBoxEntry* _pEntry) const
642 SvLBoxEntry* pReturn = NULL;
643 if (_pEntry)
645 pReturn = m_aTablesList.NextSibling(_pEntry);
646 if (!pReturn)
647 pReturn = implNextSibling(m_aTablesList.GetParent(_pEntry));
649 return pReturn;
652 //------------------------------------------------------------------------
653 BOOL OTableSubscriptionPage::FillItemSet( SfxItemSet& _rCoreAttrs )
655 sal_Bool bValid, bReadonly;
656 getFlags(_rCoreAttrs, bValid, bReadonly);
658 if (!bValid || bReadonly)
659 // don't store anything if the data we're working with is invalid or readonly
660 return sal_True;
662 /////////////////////////////////////////////////////////////////////////
663 // create the output string which contains all the table names
664 if ( m_xCurrentConnection.is() )
665 { // collect the table filter data only if we have a connection - else no tables are displayed at all
666 Sequence< ::rtl::OUString > aTableFilter;
667 if (m_aTablesList.isWildcardChecked(m_aTablesList.getAllObjectsEntry()))
669 aTableFilter.realloc(1);
670 aTableFilter[0] = ::rtl::OUString("%", 1, RTL_TEXTENCODING_ASCII_US);
672 else
674 aTableFilter = collectDetailedSelection();
676 _rCoreAttrs.Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) );
679 return sal_True;
682 // -----------------------------------------------------------------------
683 void OTableSubscriptionPage::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
686 // -----------------------------------------------------------------------
687 void OTableSubscriptionPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
689 _rControlList.push_back(new ODisableWrapper<OTableTreeListBox>(&m_aTablesList));
690 _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aTables));
691 _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aExplanation));
693 // -----------------------------------------------------------------------
694 //.........................................................................
695 } // namespace dbaui
696 //.........................................................................