xref: /aoo41x/main/sw/source/ui/fldui/changedb.cxx (revision e9b3637d)
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 
SwChangeDBDlg(SwView & rVw)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    	)),
97*e9b3637dSmseidel     aApplDBFL   (this, SW_RES(FL_APPLDB     )),
98cdf0e10cSrcweir //	aChangeBT	(this, SW_RES(BT_CHANGEDB    )),
99cdf0e10cSrcweir     aImageList      (SW_RES(ILIST_DB_DLG    )),
100cdf0e10cSrcweir     aImageListHC    (SW_RES(ILIST_DB_DLG_HC )),
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     pSh(rVw.GetWrtShellPtr()),
103cdf0e10cSrcweir     pMgr( new SwFldMgr() )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     aAvailDBTLB.SetWrtShell(*pSh);
106cdf0e10cSrcweir     FillDBPopup();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	FreeResource();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	ShowDBName(pSh->GetDBData());
111cdf0e10cSrcweir 	aOKBT.SetClickHdl(LINK(this, SwChangeDBDlg, ButtonHdl));
112cdf0e10cSrcweir     aAddDBPB.SetClickHdl(LINK(this, SwChangeDBDlg, AddDBHdl));
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	aUsedDBTLB.SetSelectionMode(MULTIPLE_SELECTION);
115cdf0e10cSrcweir 	aUsedDBTLB.SetStyle(aUsedDBTLB.GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_SORT|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
116cdf0e10cSrcweir 	aUsedDBTLB.SetSpaceBetweenEntries(0);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     aUsedDBTLB.SetNodeBitmaps( aImageList.GetImage(IMG_COLLAPSE),
119cdf0e10cSrcweir                     aImageList.GetImage(IMG_EXPAND  ), BMP_COLOR_NORMAL );
120cdf0e10cSrcweir     aUsedDBTLB.SetNodeBitmaps( aImageListHC.GetImage(IMG_COLLAPSE),
121cdf0e10cSrcweir                     aImageListHC.GetImage(IMG_EXPAND  ), BMP_COLOR_HIGHCONTRAST );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	Link aLink = LINK(this, SwChangeDBDlg, TreeSelectHdl);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	aUsedDBTLB.SetSelectHdl(aLink);
126cdf0e10cSrcweir 	aUsedDBTLB.SetDeselectHdl(aLink);
127cdf0e10cSrcweir 	aAvailDBTLB.SetSelectHdl(aLink);
128cdf0e10cSrcweir 	aAvailDBTLB.SetDeselectHdl(aLink);
129cdf0e10cSrcweir 	TreeSelectHdl();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /*--------------------------------------------------------------------
133cdf0e10cSrcweir 	Beschreibung: Datenbank-Listboxen initialisieren
134cdf0e10cSrcweir  --------------------------------------------------------------------*/
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
FillDBPopup()137cdf0e10cSrcweir void SwChangeDBDlg::FillDBPopup()
138cdf0e10cSrcweir {
139cdf0e10cSrcweir 	Reference<XNameAccess> xDBContext;
140cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
141cdf0e10cSrcweir 	if( xMgr.is() )
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
144cdf0e10cSrcweir 		xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
145cdf0e10cSrcweir 	}
146cdf0e10cSrcweir 	DBG_ASSERT(xDBContext.is(), "com.sun.star.sdb.DataBaseContext: service not available");
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	const SwDBData& rDBData = pSh->GetDBData();
149cdf0e10cSrcweir 	String sDBName(rDBData.sDataSource);
150cdf0e10cSrcweir 	String sTableName(rDBData.sCommand);
151cdf0e10cSrcweir 	aAvailDBTLB.Select(sDBName, sTableName, aEmptyStr);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	SvStringsDtor aAllDBNames(5, 5);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     Sequence< ::rtl::OUString > aDBNames = xDBContext->getElementNames();
156cdf0e10cSrcweir     const ::rtl::OUString* pDBNames = aDBNames.getConstArray();
157cdf0e10cSrcweir     sal_Int32 nDBCount = aDBNames.getLength();
158cdf0e10cSrcweir     for(sal_Int32 i = 0; i < nDBCount; i++)
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir         aAllDBNames.Insert(new String(pDBNames[i]), aAllDBNames.Count());
161cdf0e10cSrcweir 	}
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	SvStringsDtor aDBNameList(5, 1);
164cdf0e10cSrcweir 	pSh->GetAllUsedDB( aDBNameList, &aAllDBNames );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	sal_uInt16 nCount = aDBNameList.Count();
167cdf0e10cSrcweir 	aUsedDBTLB.Clear();
168cdf0e10cSrcweir 	SvLBoxEntry *pFirst = 0;
169cdf0e10cSrcweir 	SvLBoxEntry *pLast = 0;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     for (sal_uInt16 k = 0; k < nCount; k++)
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir         sDBName = *aDBNameList.GetObject(k);
174cdf0e10cSrcweir 		sDBName = sDBName.GetToken(0);
175cdf0e10cSrcweir 		pLast = Insert(sDBName);
176cdf0e10cSrcweir 		if (!pFirst)
177cdf0e10cSrcweir 			pFirst = pLast;
178cdf0e10cSrcweir 	}
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	if (pFirst)
181cdf0e10cSrcweir 	{
182cdf0e10cSrcweir 		aUsedDBTLB.MakeVisible(pFirst);
183cdf0e10cSrcweir 		aUsedDBTLB.Select(pFirst);
184cdf0e10cSrcweir 	}
185cdf0e10cSrcweir 
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir /*--------------------------------------------------------------------
189cdf0e10cSrcweir 	Beschreibung:
190cdf0e10cSrcweir  --------------------------------------------------------------------*/
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
Insert(const String & rDBName)193cdf0e10cSrcweir SvLBoxEntry* SwChangeDBDlg::Insert(const String& rDBName)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	String sDBName(rDBName.GetToken(0, DB_DELIM));
196cdf0e10cSrcweir 	String sTableName(rDBName.GetToken(1, DB_DELIM));
197cdf0e10cSrcweir 	int nCommandType = rDBName.GetToken(2, DB_DELIM).ToInt32();
198cdf0e10cSrcweir 	SvLBoxEntry* pParent;
199cdf0e10cSrcweir 	SvLBoxEntry* pChild;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	sal_uInt16 nParent = 0;
202cdf0e10cSrcweir 	sal_uInt16 nChild = 0;
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     Image aTableImg = aImageList.GetImage(IMG_DBTABLE);
205cdf0e10cSrcweir     Image aDBImg = aImageList.GetImage(IMG_DB);
206cdf0e10cSrcweir     Image aQueryImg = aImageList.GetImage(IMG_DBQUERY);
207cdf0e10cSrcweir     Image aHCTableImg = aImageListHC.GetImage(IMG_DBTABLE);
208cdf0e10cSrcweir     Image aHCDBImg = aImageListHC.GetImage(IMG_DB);
209cdf0e10cSrcweir     Image aHCQueryImg = aImageListHC.GetImage(IMG_DBQUERY);
210cdf0e10cSrcweir     Image& rToInsert = nCommandType ? aQueryImg : aTableImg;
211cdf0e10cSrcweir     Image& rHCToInsert = nCommandType ? aHCQueryImg : aHCTableImg;
212cdf0e10cSrcweir     while ((pParent = aUsedDBTLB.GetEntry(nParent++)) != NULL)
213cdf0e10cSrcweir 	{
214cdf0e10cSrcweir 		if (sDBName == aUsedDBTLB.GetEntryText(pParent))
215cdf0e10cSrcweir 		{
216cdf0e10cSrcweir 			while ((pChild = aUsedDBTLB.GetEntry(pParent, nChild++)) != NULL)
217cdf0e10cSrcweir 			{
218cdf0e10cSrcweir 				if (sTableName == aUsedDBTLB.GetEntryText(pChild))
219cdf0e10cSrcweir 					return pChild;
220cdf0e10cSrcweir 			}
221cdf0e10cSrcweir             SvLBoxEntry* pRet = aUsedDBTLB.InsertEntry(sTableName, rToInsert, rToInsert, pParent);
222cdf0e10cSrcweir             aUsedDBTLB.SetExpandedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
223cdf0e10cSrcweir             aUsedDBTLB.SetCollapsedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
224cdf0e10cSrcweir             pRet->SetUserData((void*)nCommandType);
225cdf0e10cSrcweir 			return pRet;
226cdf0e10cSrcweir 		}
227cdf0e10cSrcweir 	}
228cdf0e10cSrcweir     pParent = aUsedDBTLB.InsertEntry(sDBName, aDBImg, aDBImg);
229cdf0e10cSrcweir     aUsedDBTLB.SetExpandedEntryBmp(pParent, aHCDBImg, BMP_COLOR_HIGHCONTRAST);
230cdf0e10cSrcweir     aUsedDBTLB.SetCollapsedEntryBmp(pParent, aHCDBImg, BMP_COLOR_HIGHCONTRAST);
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     SvLBoxEntry* pRet = aUsedDBTLB.InsertEntry(sTableName, rToInsert, rToInsert, pParent);
233cdf0e10cSrcweir     aUsedDBTLB.SetExpandedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
234cdf0e10cSrcweir     aUsedDBTLB.SetCollapsedEntryBmp(pRet, rHCToInsert, BMP_COLOR_HIGHCONTRAST);
235cdf0e10cSrcweir     pRet->SetUserData((void*)nCommandType);
236cdf0e10cSrcweir 	return pRet;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir /*--------------------------------------------------------------------
240cdf0e10cSrcweir 	Beschreibung: Dialog zerstoeren
241cdf0e10cSrcweir  --------------------------------------------------------------------*/
~SwChangeDBDlg()242cdf0e10cSrcweir __EXPORT SwChangeDBDlg::~SwChangeDBDlg()
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	delete pMgr;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir /*--------------------------------------------------------------------
248cdf0e10cSrcweir 	 Beschreibung:	Schliessen
249cdf0e10cSrcweir  --------------------------------------------------------------------*/
Apply()250cdf0e10cSrcweir void __EXPORT SwChangeDBDlg::Apply()
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	UpdateFlds();
253cdf0e10cSrcweir }
254cdf0e10cSrcweir /*--------------------------------------------------------------------
255cdf0e10cSrcweir 	 Beschreibung:
256cdf0e10cSrcweir  --------------------------------------------------------------------*/
UpdateFlds()257cdf0e10cSrcweir void SwChangeDBDlg::UpdateFlds()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir 	SvStringsDtor aDBNames( (sal_uInt8)aUsedDBTLB.GetSelectionCount(), 1 );
260cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aUsedDBTLB.FirstSelected();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 	while( pEntry )
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 		if( aUsedDBTLB.GetParent( pEntry ))
265cdf0e10cSrcweir 		{
266cdf0e10cSrcweir 			String* pTmp = new String( aUsedDBTLB.GetEntryText(
267cdf0e10cSrcweir 											aUsedDBTLB.GetParent( pEntry )));
268cdf0e10cSrcweir 			*pTmp += DB_DELIM;
269cdf0e10cSrcweir 			*pTmp += aUsedDBTLB.GetEntryText( pEntry );
270cdf0e10cSrcweir 			*pTmp += DB_DELIM;
271cdf0e10cSrcweir 			int nCommandType = (int)(sal_uLong)pEntry->GetUserData();
272cdf0e10cSrcweir             *pTmp += String::CreateFromInt32(nCommandType);
273cdf0e10cSrcweir 			aDBNames.Insert(pTmp, aDBNames.Count() );
274cdf0e10cSrcweir 		}
275cdf0e10cSrcweir 		pEntry = aUsedDBTLB.NextSelected(pEntry);
276cdf0e10cSrcweir 	}
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	pSh->StartAllAction();
279cdf0e10cSrcweir 	String sTableName, sColumnName;
280cdf0e10cSrcweir     sal_Bool bIsTable = sal_False;
281cdf0e10cSrcweir     String sTemp(aAvailDBTLB.GetDBName(sTableName, sColumnName, &bIsTable));
282cdf0e10cSrcweir 	sTemp += DB_DELIM;
283cdf0e10cSrcweir 	sTemp += sTableName;
284cdf0e10cSrcweir     sTemp += DB_DELIM;
285cdf0e10cSrcweir     sTemp += bIsTable ? '0' : '1';
286cdf0e10cSrcweir 	pSh->ChangeDBFields( aDBNames, sTemp);
287cdf0e10cSrcweir 	pSh->EndAllAction();
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir /*------------------------------------------------------------------------
291cdf0e10cSrcweir  Beschreibung:
292cdf0e10cSrcweir ------------------------------------------------------------------------*/
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
IMPL_LINK(SwChangeDBDlg,ButtonHdl,Button *,EMPTYARG)295cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, ButtonHdl, Button *, EMPTYARG )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	String sTableName, sColumnName;
298cdf0e10cSrcweir 	SwDBData aData;
299cdf0e10cSrcweir     sal_Bool bIsTable = sal_False;
300cdf0e10cSrcweir     aData.sDataSource = aAvailDBTLB.GetDBName(sTableName, sColumnName, &bIsTable);
301cdf0e10cSrcweir 	aData.sCommand = sTableName;
302cdf0e10cSrcweir     aData.nCommandType = bIsTable ? 0 : 1;;
303cdf0e10cSrcweir     pSh->ChgDBData(aData);
304cdf0e10cSrcweir 	ShowDBName(pSh->GetDBData());
305cdf0e10cSrcweir 	EndDialog(RET_OK);
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	return 0;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir /*------------------------------------------------------------------------
311cdf0e10cSrcweir  Beschreibung:
312cdf0e10cSrcweir ------------------------------------------------------------------------*/
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 
IMPL_LINK(SwChangeDBDlg,TreeSelectHdl,SvTreeListBox *,EMPTYARG)315cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, TreeSelectHdl, SvTreeListBox *, EMPTYARG )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	sal_Bool bEnable = sal_False;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 	SvLBoxEntry* pEntry = aAvailDBTLB.GetCurEntry();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	if (pEntry)
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		if (aAvailDBTLB.GetParent(pEntry))
324cdf0e10cSrcweir 			bEnable = sal_True;
325cdf0e10cSrcweir 		aOKBT.Enable( bEnable );
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 	return 0;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir /*--------------------------------------------------------------------
33129b78537SPeter 	Description: transform databasename for screen
332cdf0e10cSrcweir  --------------------------------------------------------------------*/
333cdf0e10cSrcweir 
ShowDBName(const SwDBData & rDBData)334cdf0e10cSrcweir void SwChangeDBDlg::ShowDBName(const SwDBData& rDBData)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	String sName;
33729b78537SPeter 	String sTmp(rDBData.sDataSource);
33829b78537SPeter 	if (!rDBData.sDataSource.isEmpty() && !rDBData.sCommand.isEmpty()) {
33929b78537SPeter 		sTmp += '.';
34029b78537SPeter 	}
341cdf0e10cSrcweir 	sTmp += (String)rDBData.sCommand;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	for (sal_uInt16 i = 0; i < sTmp.Len(); i++)
344cdf0e10cSrcweir 	{
345cdf0e10cSrcweir 		sName += sTmp.GetChar(i);
346cdf0e10cSrcweir 		if (sTmp.GetChar(i) == '~')
347cdf0e10cSrcweir 			sName += '~';
348cdf0e10cSrcweir 	}
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	aDocDBNameFT.SetText(sName);
351cdf0e10cSrcweir }
352cdf0e10cSrcweir /*-- 27.05.2004 09:14:01---------------------------------------------------
353cdf0e10cSrcweir 
354cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IMPL_LINK(SwChangeDBDlg,AddDBHdl,PushButton *,EMPTYARG)355cdf0e10cSrcweir IMPL_LINK( SwChangeDBDlg, AddDBHdl, PushButton *, EMPTYARG )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir     String sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
358cdf0e10cSrcweir     if(sNewDB.Len())
359cdf0e10cSrcweir         aAvailDBTLB.AddDataSource(sNewDB);
360cdf0e10cSrcweir     return 0;
361cdf0e10cSrcweir }
362cdf0e10cSrcweir 
363