xref: /aoo41x/main/sw/source/ui/fldui/changedb.cxx (revision 29b78537)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
29cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #define _CHANGEDB_CXX
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <svtools/stdctrl.hxx>
36cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
37cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
41cdf0e10cSrcweir #include <com/sun/star/sdb/XDatabaseAccess.hpp>
42cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
43cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #ifndef _VIEW_HXX
46cdf0e10cSrcweir #include <view.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <wrtsh.hxx>
49cdf0e10cSrcweir #ifndef _DBMGR_HXX
50cdf0e10cSrcweir #include <dbmgr.hxx>
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir #include <fldmgr.hxx>
53cdf0e10cSrcweir #include <expfld.hxx>
54cdf0e10cSrcweir #include <txtatr.hxx>
55cdf0e10cSrcweir #include <ndtxt.hxx>
56cdf0e10cSrcweir #include <fldbas.hxx>
57cdf0e10cSrcweir #include <dbfld.hxx>
58cdf0e10cSrcweir #include <changedb.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #ifndef _FLDUI_HRC
61cdf0e10cSrcweir #include <fldui.hrc>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _UTLUI_HRC
64cdf0e10cSrcweir #include <utlui.hrc>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir #ifndef _CHANGEDB_HRC
67cdf0e10cSrcweir #include <changedb.hrc>
68cdf0e10cSrcweir #endif
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include <unomid.h>
71cdf0e10cSrcweir 
72cdf0e10cSrcweir using namespace ::com::sun::star::uno;
73cdf0e10cSrcweir using namespace ::com::sun::star::container;
74cdf0e10cSrcweir using namespace ::com::sun::star::lang;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir /*--------------------------------------------------------------------
78cdf0e10cSrcweir 	Beschreibung: Feldeinfuegen bearbeiten
79cdf0e10cSrcweir  --------------------------------------------------------------------*/
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
82cdf0e10cSrcweir SwChangeDBDlg::SwChangeDBDlg(SwView& rVw) :
83cdf0e10cSrcweir 	SvxStandardDialog(&rVw.GetViewFrame()->GetWindow(), SW_RES(DLG_CHANGE_DB)),
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     aDBListFL   (this, SW_RES(FL_DBLIST     )),
86cdf0e10cSrcweir 	aUsedDBFT	(this, SW_RES(FT_USEDDB  	)),
87cdf0e10cSrcweir 	aAvailDBFT	(this, SW_RES(FT_AVAILDB 	)),
88cdf0e10cSrcweir 	aUsedDBTLB	(this, SW_RES(TLB_USEDDB  	)),
89cdf0e10cSrcweir     aAvailDBTLB (this, SW_RES(TLB_AVAILDB   ), 0),
90cdf0e10cSrcweir     aAddDBPB    (this, SW_RES(PB_ADDDB)),
91cdf0e10cSrcweir     aDescFT     (this, SW_RES(FT_DESC       )),
92cdf0e10cSrcweir 	aDocDBTextFT(this, SW_RES(FT_DOCDBTEXT	)),
93cdf0e10cSrcweir 	aDocDBNameFT(this, SW_RES(FT_DOCDBNAME	)),
94cdf0e10cSrcweir 	aOKBT		(this, SW_RES(BT_OK      	)),
95cdf0e10cSrcweir 	aCancelBT	(this, SW_RES(BT_CANCEL  	)),
96cdf0e10cSrcweir 	aHelpBT		(this, SW_RES(BT_HELP    	)),
97cdf0e10cSrcweir //	aChangeBT	(this, SW_RES(BT_CHANGEDB    )),
98cdf0e10cSrcweir     aImageList      (SW_RES(ILIST_DB_DLG    )),
99cdf0e10cSrcweir     aImageListHC    (SW_RES(ILIST_DB_DLG_HC )),
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     pSh(rVw.GetWrtShellPtr()),
102cdf0e10cSrcweir     pMgr( new SwFldMgr() )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     aAvailDBTLB.SetWrtShell(*pSh);
105cdf0e10cSrcweir     FillDBPopup();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	FreeResource();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	ShowDBName(pSh->GetDBData());
110cdf0e10cSrcweir 	aOKBT.SetClickHdl(LINK(this, SwChangeDBDlg, ButtonHdl));
111cdf0e10cSrcweir     aAddDBPB.SetClickHdl(LINK(this, SwChangeDBDlg, AddDBHdl));
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	aUsedDBTLB.SetSelectionMode(MULTIPLE_SELECTION);
114cdf0e10cSrcweir 	aUsedDBTLB.SetStyle(aUsedDBTLB.GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_SORT|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
115cdf0e10cSrcweir 	aUsedDBTLB.SetSpaceBetweenEntries(0);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     aUsedDBTLB.SetNodeBitmaps( aImageList.GetImage(IMG_COLLAPSE),
118cdf0e10cSrcweir                     aImageList.GetImage(IMG_EXPAND  ), BMP_COLOR_NORMAL );
119cdf0e10cSrcweir     aUsedDBTLB.SetNodeBitmaps( aImageListHC.GetImage(IMG_COLLAPSE),
120cdf0e10cSrcweir                     aImageListHC.GetImage(IMG_EXPAND  ), BMP_COLOR_HIGHCONTRAST );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	Link aLink = LINK(this, SwChangeDBDlg, TreeSelectHdl);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	aUsedDBTLB.SetSelectHdl(aLink);
125cdf0e10cSrcweir 	aUsedDBTLB.SetDeselectHdl(aLink);
126cdf0e10cSrcweir 	aAvailDBTLB.SetSelectHdl(aLink);
127cdf0e10cSrcweir 	aAvailDBTLB.SetDeselectHdl(aLink);
128cdf0e10cSrcweir 	TreeSelectHdl();
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /*--------------------------------------------------------------------
132cdf0e10cSrcweir 	Beschreibung: Datenbank-Listboxen initialisieren
133cdf0e10cSrcweir  --------------------------------------------------------------------*/
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir void SwChangeDBDlg::FillDBPopup()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir 	Reference<XNameAccess> xDBContext;
139cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
140cdf0e10cSrcweir 	if( xMgr.is() )
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
143cdf0e10cSrcweir 		xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 	DBG_ASSERT(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available");
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	const SwDBData& rDBData = pSh->GetDBData();
148cdf0e10cSrcweir 	String sDBName(rDBData.sDataSource);
149cdf0e10cSrcweir 	String sTableName(rDBData.sCommand);
150cdf0e10cSrcweir 	aAvailDBTLB.Select(sDBName, sTableName, aEmptyStr);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	SvStringsDtor aAllDBNames(5, 5);
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     Sequence< ::rtl::OUString > aDBNames = xDBContext->getElementNames();
155cdf0e10cSrcweir     const ::rtl::OUString* pDBNames = aDBNames.getConstArray();
156cdf0e10cSrcweir     sal_Int32 nDBCount = aDBNames.getLength();
157cdf0e10cSrcweir     for(sal_Int32 i = 0; i < nDBCount; i++)
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir         aAllDBNames.Insert(new String(pDBNames[i]), aAllDBNames.Count());
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	SvStringsDtor aDBNameList(5, 1);
163cdf0e10cSrcweir 	pSh->GetAllUsedDB( aDBNameList, &aAllDBNames );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	sal_uInt16 nCount = aDBNameList.Count();
166cdf0e10cSrcweir 	aUsedDBTLB.Clear();
167cdf0e10cSrcweir 	SvLBoxEntry *pFirst = 0;
168cdf0e10cSrcweir 	SvLBoxEntry *pLast = 0;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     for (sal_uInt16 k = 0; k < nCount; k++)
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir         sDBName = *aDBNameList.GetObject(k);
173cdf0e10cSrcweir 		sDBName = sDBName.GetToken(0);
174cdf0e10cSrcweir 		pLast = Insert(sDBName);
175cdf0e10cSrcweir 		if (!pFirst)
176cdf0e10cSrcweir 			pFirst = pLast;
177cdf0e10cSrcweir 	}
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	if (pFirst)
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		aUsedDBTLB.MakeVisible(pFirst);
182cdf0e10cSrcweir 		aUsedDBTLB.Select(pFirst);
183cdf0e10cSrcweir 	}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir /*--------------------------------------------------------------------
188cdf0e10cSrcweir 	Beschreibung:
189cdf0e10cSrcweir  --------------------------------------------------------------------*/
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 
192cdf0e10cSrcweir SvLBoxEntry* SwChangeDBDlg::Insert(const String& rDBName)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	String sDBName(rDBName.GetToken(0, DB_DELIM));
195cdf0e10cSrcweir 	String sTableName(rDBName.GetToken(1, DB_DELIM));
196cdf0e10cSrcweir 	int nCommandType = rDBName.GetToken(2, DB_DELIM).ToInt32();
197cdf0e10cSrcweir 	SvLBoxEntry* pParent;
198cdf0e10cSrcweir 	SvLBoxEntry* pChild;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	sal_uInt16 nParent = 0;
201cdf0e10cSrcweir 	sal_uInt16 nChild = 0;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     Image aTableImg = aImageList.GetImage(IMG_DBTABLE);
204cdf0e10cSrcweir     Image aDBImg = aImageList.GetImage(IMG_DB);
205cdf0e10cSrcweir     Image aQueryImg = aImageList.GetImage(IMG_DBQUERY);
206cdf0e10cSrcweir     Image aHCTableImg = aImageListHC.GetImage(IMG_DBTABLE);
207cdf0e10cSrcweir     Image aHCDBImg = aImageListHC.GetImage(IMG_DB);
208cdf0e10cSrcweir     Image aHCQueryImg = aImageListHC.GetImage(IMG_DBQUERY);
209cdf0e10cSrcweir     Image& rToInsert = nCommandType ? aQueryImg : aTableImg;
210cdf0e10cSrcweir     Image& rHCToInsert = nCommandType ? aHCQueryImg : aHCTableImg;
211cdf0e10cSrcweir     while ((pParent = aUsedDBTLB.GetEntry(nParent++)) != NULL)
212cdf0e10cSrcweir 	{
213cdf0e10cSrcweir 		if (sDBName == aUsedDBTLB.GetEntryText(pParent))
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			while ((pChild = aUsedDBTLB.GetEntry(pParent, nChild++)) != NULL)
216cdf0e10cSrcweir 			{
217cdf0e10cSrcweir 				if (sTableName == aUsedDBTLB.GetEntryText(pChild))
218cdf0e10cSrcweir 					return pChild;
219cdf0e10cSrcweir 			}
220cdf0e10cSrcweir             SvLBoxEntry* pRet = aUsedDBTLB.InsertEntry(sTableName, rToInsert, rToInsert, pParent);
221cdf0e10cSrcweir             aUsedDBTLB.SetExpandedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
222cdf0e10cSrcweir             aUsedDBTLB.SetCollapsedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
223cdf0e10cSrcweir             pRet->SetUserData((void*)nCommandType);
224cdf0e10cSrcweir 			return pRet;
225cdf0e10cSrcweir 		}
226cdf0e10cSrcweir 	}
227cdf0e10cSrcweir     pParent = aUsedDBTLB.InsertEntry(sDBName, aDBImg, aDBImg);
228cdf0e10cSrcweir     aUsedDBTLB.SetExpandedEntryBmp(pParent, aHCDBImg, BMP_COLOR_HIGHCONTRAST);
229cdf0e10cSrcweir     aUsedDBTLB.SetCollapsedEntryBmp(pParent, aHCDBImg, BMP_COLOR_HIGHCONTRAST);
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     SvLBoxEntry* pRet = aUsedDBTLB.InsertEntry(sTableName, rToInsert, rToInsert, pParent);
232cdf0e10cSrcweir     aUsedDBTLB.SetExpandedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
233cdf0e10cSrcweir     aUsedDBTLB.SetCollapsedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
234cdf0e10cSrcweir     pRet->SetUserData((void*)nCommandType);
235cdf0e10cSrcweir 	return pRet;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir /*--------------------------------------------------------------------
239cdf0e10cSrcweir 	Beschreibung: Dialog zerstoeren
240cdf0e10cSrcweir  --------------------------------------------------------------------*/
241cdf0e10cSrcweir __EXPORT SwChangeDBDlg::~SwChangeDBDlg()
242cdf0e10cSrcweir {
243cdf0e10cSrcweir 	delete pMgr;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir /*--------------------------------------------------------------------
247cdf0e10cSrcweir 	 Beschreibung:	Schliessen
248cdf0e10cSrcweir  --------------------------------------------------------------------*/
249cdf0e10cSrcweir void __EXPORT SwChangeDBDlg::Apply()
250cdf0e10cSrcweir {
251cdf0e10cSrcweir 	UpdateFlds();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir /*--------------------------------------------------------------------
254cdf0e10cSrcweir 	 Beschreibung:
255cdf0e10cSrcweir  --------------------------------------------------------------------*/
256cdf0e10cSrcweir void SwChangeDBDlg::UpdateFlds()
257cdf0e10cSrcweir {
258cdf0e10cSrcweir 	SvStringsDtor aDBNames( (sal_uInt8)aUsedDBTLB.GetSelectionCount(), 1 );
259cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aUsedDBTLB.FirstSelected();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	while( pEntry )
262cdf0e10cSrcweir 	{
263cdf0e10cSrcweir 		if( aUsedDBTLB.GetParent( pEntry ))
264cdf0e10cSrcweir 		{
265cdf0e10cSrcweir 			String* pTmp = new String( aUsedDBTLB.GetEntryText(
266cdf0e10cSrcweir 											aUsedDBTLB.GetParent( pEntry )));
267cdf0e10cSrcweir 			*pTmp += DB_DELIM;
268cdf0e10cSrcweir 			*pTmp += aUsedDBTLB.GetEntryText( pEntry );
269cdf0e10cSrcweir 			*pTmp += DB_DELIM;
270cdf0e10cSrcweir 			int nCommandType = (int)(sal_uLong)pEntry->GetUserData();
271cdf0e10cSrcweir             *pTmp += String::CreateFromInt32(nCommandType);
272cdf0e10cSrcweir 			aDBNames.Insert(pTmp, aDBNames.Count() );
273cdf0e10cSrcweir 		}
274cdf0e10cSrcweir 		pEntry = aUsedDBTLB.NextSelected(pEntry);
275cdf0e10cSrcweir 	}
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 	pSh->StartAllAction();
278cdf0e10cSrcweir 	String sTableName, sColumnName;
279cdf0e10cSrcweir     sal_Bool bIsTable = sal_False;
280cdf0e10cSrcweir     String sTemp(aAvailDBTLB.GetDBName(sTableName, sColumnName, &bIsTable));
281cdf0e10cSrcweir 	sTemp += DB_DELIM;
282cdf0e10cSrcweir 	sTemp += sTableName;
283cdf0e10cSrcweir     sTemp += DB_DELIM;
284cdf0e10cSrcweir     sTemp += bIsTable ? '0' : '1';
285cdf0e10cSrcweir 	pSh->ChangeDBFields( aDBNames, sTemp);
286cdf0e10cSrcweir 	pSh->EndAllAction();
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir /*------------------------------------------------------------------------
290cdf0e10cSrcweir  Beschreibung:
291cdf0e10cSrcweir ------------------------------------------------------------------------*/
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
294cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, ButtonHdl, Button *, EMPTYARG )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	String sTableName, sColumnName;
297cdf0e10cSrcweir 	SwDBData aData;
298cdf0e10cSrcweir     sal_Bool bIsTable = sal_False;
299cdf0e10cSrcweir     aData.sDataSource = aAvailDBTLB.GetDBName(sTableName, sColumnName, &bIsTable);
300cdf0e10cSrcweir 	aData.sCommand = sTableName;
301cdf0e10cSrcweir     aData.nCommandType = bIsTable ? 0 : 1;;
302cdf0e10cSrcweir     pSh->ChgDBData(aData);
303cdf0e10cSrcweir 	ShowDBName(pSh->GetDBData());
304cdf0e10cSrcweir 	EndDialog(RET_OK);
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	return 0;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir /*------------------------------------------------------------------------
310cdf0e10cSrcweir  Beschreibung:
311cdf0e10cSrcweir ------------------------------------------------------------------------*/
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 
314cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, TreeSelectHdl, SvTreeListBox *, EMPTYARG )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	sal_Bool bEnable = sal_False;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aAvailDBTLB.GetCurEntry();
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	if (pEntry)
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		if (aAvailDBTLB.GetParent(pEntry))
323cdf0e10cSrcweir 			bEnable = sal_True;
324cdf0e10cSrcweir 		aOKBT.Enable( bEnable );
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir 	return 0;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir /*--------------------------------------------------------------------
330*29b78537SPeter 	Description: transform databasename for screen
331cdf0e10cSrcweir  --------------------------------------------------------------------*/
332cdf0e10cSrcweir 
333cdf0e10cSrcweir void SwChangeDBDlg::ShowDBName(const SwDBData& rDBData)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir 	String sName;
336*29b78537SPeter 	String sTmp(rDBData.sDataSource);
337*29b78537SPeter 	if (!rDBData.sDataSource.isEmpty() && !rDBData.sCommand.isEmpty()) {
338*29b78537SPeter 		sTmp += '.';
339*29b78537SPeter 	}
340cdf0e10cSrcweir 	sTmp += (String)rDBData.sCommand;
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < sTmp.Len(); i++)
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		sName += sTmp.GetChar(i);
345cdf0e10cSrcweir 		if (sTmp.GetChar(i) == '~')
346cdf0e10cSrcweir 			sName += '~';
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	aDocDBNameFT.SetText(sName);
350cdf0e10cSrcweir }
351cdf0e10cSrcweir /*-- 27.05.2004 09:14:01---------------------------------------------------
352cdf0e10cSrcweir 
353cdf0e10cSrcweir   -----------------------------------------------------------------------*/
354cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, AddDBHdl, PushButton *, EMPTYARG )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir     String sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
357cdf0e10cSrcweir     if(sNewDB.Len())
358cdf0e10cSrcweir         aAvailDBTLB.AddDataSource(sNewDB);
359cdf0e10cSrcweir     return 0;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362