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