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