xref: /AOO41X/main/sw/source/ui/dbui/dbinsdlg.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "dbinsdlg.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <memory>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <float.h>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <hintids.hxx>
41*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDataSource.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/sdb/XQueriesSupplier.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/sdb/XColumn.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/sdb/XDatabaseAccess.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp>
57*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
58*cdf0e10cSrcweir #include <editeng/langitem.hxx>
59*cdf0e10cSrcweir #include <svl/numuno.hxx>
60*cdf0e10cSrcweir #include <svl/stritem.hxx>
61*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
62*cdf0e10cSrcweir #include <vcl/svapp.hxx>
63*cdf0e10cSrcweir #include <vcl/mnemonic.hxx>
64*cdf0e10cSrcweir #include <svl/style.hxx>
65*cdf0e10cSrcweir #include <svl/zformat.hxx>
66*cdf0e10cSrcweir #include <svx/htmlmode.hxx>
67*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
68*cdf0e10cSrcweir #include <sfx2/app.hxx>
69*cdf0e10cSrcweir #include <svl/itemset.hxx>
70*cdf0e10cSrcweir #include <editeng/brshitem.hxx>
71*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
72*cdf0e10cSrcweir #include <svx/rulritem.hxx>
73*cdf0e10cSrcweir #include <swdbtoolsclient.hxx>
74*cdf0e10cSrcweir #include <tabledlg.hxx>
75*cdf0e10cSrcweir #include <fmtclds.hxx>
76*cdf0e10cSrcweir #include <tabcol.hxx>
77*cdf0e10cSrcweir #include <uiitems.hxx>
78*cdf0e10cSrcweir #include <viewopt.hxx>
79*cdf0e10cSrcweir #include <uitool.hxx>
80*cdf0e10cSrcweir #include <wrtsh.hxx>
81*cdf0e10cSrcweir #include <wview.hxx>
82*cdf0e10cSrcweir #include <docsh.hxx>
83*cdf0e10cSrcweir #include <dbmgr.hxx>
84*cdf0e10cSrcweir #include <tblafmt.hxx>
85*cdf0e10cSrcweir #include <cellatr.hxx>
86*cdf0e10cSrcweir #include <swtable.hxx>
87*cdf0e10cSrcweir #include <dbfld.hxx>
88*cdf0e10cSrcweir #include <fmtcol.hxx>
89*cdf0e10cSrcweir #include <section.hxx>
90*cdf0e10cSrcweir #include <swwait.hxx>
91*cdf0e10cSrcweir #include <modcfg.hxx>
92*cdf0e10cSrcweir #include <swmodule.hxx>
93*cdf0e10cSrcweir #include <poolfmt.hxx>
94*cdf0e10cSrcweir #include <crsskip.hxx>
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir #include <dbinsdlg.hrc>
97*cdf0e10cSrcweir #include <dbui.hrc>
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #include <cmdid.h>
100*cdf0e10cSrcweir #include <helpid.h>
101*cdf0e10cSrcweir #include <cfgid.h>
102*cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
103*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
104*cdf0e10cSrcweir #include "tabsh.hxx"
105*cdf0e10cSrcweir #include "swabstdlg.hxx"
106*cdf0e10cSrcweir #include "table.hrc"
107*cdf0e10cSrcweir #include <unomid.h>
108*cdf0e10cSrcweir #include <IDocumentMarkAccess.hxx>
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir namespace swui
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	SwAbstractDialogFactory * GetFactory();
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir using namespace ::com::sun::star;
117*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
118*cdf0e10cSrcweir using namespace ::com::sun::star::container;
119*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
120*cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
121*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
122*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
123*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir // tblafmt.hxx
126*cdf0e10cSrcweir SV_IMPL_PTRARR( _SwTableAutoFmtTbl, SwTableAutoFmt* )
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir const char cDBFldStart	= '<';
129*cdf0e10cSrcweir const char cDBFldEnd 	= '>';
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir // Hilfsstruktur fuers einfuegen von Datenbankspalten als Felder oder Text
132*cdf0e10cSrcweir struct _DB_Column
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	enum ColType { DB_FILLTEXT, DB_COL_FIELD, DB_COL_TEXT, DB_SPLITPARA } eColType;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 	union {
137*cdf0e10cSrcweir 		String* pText;
138*cdf0e10cSrcweir 		SwField* pField;
139*cdf0e10cSrcweir 		sal_uLong nFormat;
140*cdf0e10cSrcweir 	} DB_ColumnData;
141*cdf0e10cSrcweir 	const SwInsDBColumn* pColInfo;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	_DB_Column()
144*cdf0e10cSrcweir 	{
145*cdf0e10cSrcweir 		pColInfo = 0;
146*cdf0e10cSrcweir 		DB_ColumnData.pText = 0;
147*cdf0e10cSrcweir 		eColType = DB_SPLITPARA;
148*cdf0e10cSrcweir 	}
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	_DB_Column( const String& rTxt )
151*cdf0e10cSrcweir 	{
152*cdf0e10cSrcweir 		pColInfo = 0;
153*cdf0e10cSrcweir 		DB_ColumnData.pText = new String( rTxt );
154*cdf0e10cSrcweir 		eColType = DB_FILLTEXT;
155*cdf0e10cSrcweir 	}
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	_DB_Column( const SwInsDBColumn& rInfo, sal_uLong nFormat )
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		pColInfo = &rInfo;
160*cdf0e10cSrcweir 		DB_ColumnData.nFormat = nFormat;
161*cdf0e10cSrcweir 		eColType = DB_COL_TEXT;
162*cdf0e10cSrcweir 	}
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	_DB_Column( const SwInsDBColumn& rInfo, SwDBField& rFld )
165*cdf0e10cSrcweir 	{
166*cdf0e10cSrcweir 		pColInfo = &rInfo;
167*cdf0e10cSrcweir 		DB_ColumnData.pField = &rFld;
168*cdf0e10cSrcweir 		eColType = DB_COL_FIELD;
169*cdf0e10cSrcweir 	}
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	~_DB_Column()
172*cdf0e10cSrcweir 	{
173*cdf0e10cSrcweir 		if( DB_COL_FIELD == eColType )
174*cdf0e10cSrcweir 			delete DB_ColumnData.pField;
175*cdf0e10cSrcweir 		else if( DB_FILLTEXT == eColType )
176*cdf0e10cSrcweir 			delete DB_ColumnData.pText;
177*cdf0e10cSrcweir 	}
178*cdf0e10cSrcweir };
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir typedef _DB_Column* _DB_ColumnPtr;
181*cdf0e10cSrcweir SV_DECL_PTRARR_DEL( _DB_Columns, _DB_ColumnPtr, 32, 32 )
182*cdf0e10cSrcweir SV_IMPL_PTRARR( _DB_Columns, _DB_ColumnPtr )
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT( SwInsDBColumns, SwInsDBColumnPtr )
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir /*  */
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir #define DBCOLUMN_CONFIG_VERSION1 	1
189*cdf0e10cSrcweir #define DBCOLUMN_CONFIG_VERSION 	DBCOLUMN_CONFIG_VERSION1
190*cdf0e10cSrcweir #define DBCOLUMN_MAXDATA			5
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir struct _DB_ColumnConfigData
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir 	SwInsDBColumns aDBColumns;
195*cdf0e10cSrcweir     rtl::OUString sSource, sTable, sEdit, sTblList, sTmplNm, sTAutoFmtNm;
196*cdf0e10cSrcweir 	sal_Bool bIsTable : 1,
197*cdf0e10cSrcweir 		 bIsField : 1,
198*cdf0e10cSrcweir 		 bIsHeadlineOn : 1,
199*cdf0e10cSrcweir 		 bIsEmptyHeadln : 1;
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	_DB_ColumnConfigData()
202*cdf0e10cSrcweir 	{
203*cdf0e10cSrcweir 		bIsTable = bIsHeadlineOn = sal_True;
204*cdf0e10cSrcweir 		bIsField = bIsEmptyHeadln = sal_False;
205*cdf0e10cSrcweir 	}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	~_DB_ColumnConfigData();
208*cdf0e10cSrcweir private:
209*cdf0e10cSrcweir 	_DB_ColumnConfigData( const _DB_ColumnConfigData& );
210*cdf0e10cSrcweir 	_DB_ColumnConfigData& operator =( const _DB_ColumnConfigData& );
211*cdf0e10cSrcweir };
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir /*  */
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir int SwInsDBColumn::operator<( const SwInsDBColumn& rCmp ) const
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir 	return 0 > GetAppCollator().compareString( sColumn, rCmp.sColumn );
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
222*cdf0e10cSrcweir SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
223*cdf0e10cSrcweir 		Reference<XDataSource> xDataSource,
224*cdf0e10cSrcweir 		Reference<sdbcx::XColumnsSupplier> xColSupp,
225*cdf0e10cSrcweir 		const SwDBData& rData )
226*cdf0e10cSrcweir 	: SfxModalDialog( rView.GetWindow(), SW_RES( DLG_AP_INSERT_DB_SEL )),
227*cdf0e10cSrcweir 	ConfigItem(C2U("Office.Writer/InsertData/DataSet"), CONFIG_MODE_DELAYED_UPDATE),
228*cdf0e10cSrcweir 	aFtInsertData( this, SW_RES( FT_INSERT_DATA )),
229*cdf0e10cSrcweir 	aRbAsTable( this, SW_RES( RB_AS_TABLE )),
230*cdf0e10cSrcweir 	aRbAsField( this, SW_RES( RB_AS_FIELD )),
231*cdf0e10cSrcweir     aRbAsText( this, SW_RES( RB_AS_TEXT )),
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     aFlHead( this, SW_RES( FL_HEAD )),
234*cdf0e10cSrcweir     aFtDbColumn( this, SW_RES( FT_DB_COLUMN )),
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir     aLbTblDbColumn( this, SW_RES( LB_TBL_DB_COLUMN )),
237*cdf0e10cSrcweir     aLbTxtDbColumn( this, SW_RES( LB_TXT_DB_COLUMN )),
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     aFlFormat( this, SW_RES( FL_FORMAT )),
240*cdf0e10cSrcweir     aRbDbFmtFromDb( this, SW_RES( RB_DBFMT_FROM_DB )),
241*cdf0e10cSrcweir     aRbDbFmtFromUsr( this, SW_RES( RB_DBFMT_FROM_USR )),
242*cdf0e10cSrcweir     aLbDbFmtFromUsr( this, &rView, SW_RES( LB_DBFMT_FROM_USR )),
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     aIbDbcolToEdit( this, SW_RES( IB_DBCOL_TOEDIT )),
245*cdf0e10cSrcweir     aEdDbText( this, SW_RES( ED_DB_TEXT )),
246*cdf0e10cSrcweir     aFtDbParaColl( this, SW_RES( FT_DB_PARA_COLL )),
247*cdf0e10cSrcweir     aLbDbParaColl( this, SW_RES( LB_DB_PARA_COLL )),
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     aIbDbcolAllTo( this, SW_RES( IB_DBCOL_ALL_TO )),
250*cdf0e10cSrcweir     aIbDbcolOneTo( this, SW_RES( IB_DBCOL_ONE_TO )),
251*cdf0e10cSrcweir     aIbDbcolOneFrom( this, SW_RES( IB_DBCOL_ONE_FROM )),
252*cdf0e10cSrcweir     aIbDbcolAllFrom( this, SW_RES( IB_DBCOL_ALL_FROM )),
253*cdf0e10cSrcweir     aFtTableCol( this, SW_RES( FT_TABLE_COL )),
254*cdf0e10cSrcweir     aLbTableCol( this, SW_RES( LB_TABLE_COL )),
255*cdf0e10cSrcweir     aCbTableHeadon( this, SW_RES( CB_TABLE_HEADON )),
256*cdf0e10cSrcweir     aRbHeadlColnms( this, SW_RES( RB_HEADL_COLNMS )),
257*cdf0e10cSrcweir     aRbHeadlEmpty( this, SW_RES( RB_HEADL_EMPTY )),
258*cdf0e10cSrcweir     aPbTblFormat( this, SW_RES( PB_TBL_FORMAT )),
259*cdf0e10cSrcweir     aPbTblAutofmt( this, SW_RES( PB_TBL_AUTOFMT )),
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     aBtOk( this, SW_RES( BT_OK )),
262*cdf0e10cSrcweir     aBtCancel( this, SW_RES( BT_CANCEL )),
263*cdf0e10cSrcweir     aBtHelp( this, SW_RES( BT_HELP )),
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir     aFlBottom( this, SW_RES( FL_BOTTOM )),
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     aDBData(rData),
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     aOldNumFmtLnk( aLbDbFmtFromUsr.GetSelectHdl() ),
270*cdf0e10cSrcweir 	sNoTmpl( SW_RES( STR_NOTEMPL )),
271*cdf0e10cSrcweir 	pView( &rView ),
272*cdf0e10cSrcweir 	pTAutoFmt( 0 ),
273*cdf0e10cSrcweir 	pTblSet( 0 ),
274*cdf0e10cSrcweir     pRep( 0 )
275*cdf0e10cSrcweir {
276*cdf0e10cSrcweir 	FreeResource();
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     nGBFmtLen = aFlFormat.GetText().Len();
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	if(xColSupp.is())
281*cdf0e10cSrcweir 	{
282*cdf0e10cSrcweir 		SwWrtShell& rSh = pView->GetWrtShell();
283*cdf0e10cSrcweir 		Locale aDocLocale( SvxCreateLocale( rSh.GetCurLang() ));
284*cdf0e10cSrcweir 		SvNumberFormatter* pNumFmtr = rSh.GetNumberFormatter();
285*cdf0e10cSrcweir 		SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj( pNumFmtr );
286*cdf0e10cSrcweir 		Reference< util::XNumberFormatsSupplier >  xDocNumFmtsSupplier = pNumFmt;
287*cdf0e10cSrcweir         Reference< util::XNumberFormats > xDocNumberFormats = xDocNumFmtsSupplier->getNumberFormats();
288*cdf0e10cSrcweir         Reference< util::XNumberFormatTypes > xDocNumberFormatTypes(xDocNumberFormats, UNO_QUERY);
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 		Reference<XPropertySet> xSourceProps(xDataSource, UNO_QUERY);
291*cdf0e10cSrcweir         Reference< util::XNumberFormats > xNumberFormats;
292*cdf0e10cSrcweir 		if(xSourceProps.is())
293*cdf0e10cSrcweir 		{
294*cdf0e10cSrcweir 			Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
295*cdf0e10cSrcweir 			if(aFormats.hasValue())
296*cdf0e10cSrcweir 			{
297*cdf0e10cSrcweir                 Reference< util::XNumberFormatsSupplier> xSuppl;
298*cdf0e10cSrcweir                 aFormats >>= xSuppl;
299*cdf0e10cSrcweir 				if(xSuppl.is())
300*cdf0e10cSrcweir 				{
301*cdf0e10cSrcweir 					xNumberFormats = xSuppl->getNumberFormats(  );
302*cdf0e10cSrcweir 				}
303*cdf0e10cSrcweir 			}
304*cdf0e10cSrcweir 		}
305*cdf0e10cSrcweir 		Reference <XNameAccess> xCols = xColSupp->getColumns();
306*cdf0e10cSrcweir         Sequence<rtl::OUString> aColNames = xCols->getElementNames();
307*cdf0e10cSrcweir         const rtl::OUString* pColNames = aColNames.getConstArray();
308*cdf0e10cSrcweir 		long nCount = aColNames.getLength();
309*cdf0e10cSrcweir 		for (long n = 0; n < nCount; n++)
310*cdf0e10cSrcweir 		{
311*cdf0e10cSrcweir 			SwInsDBColumn* pNew = new SwInsDBColumn( pColNames[n], (sal_uInt16)n );
312*cdf0e10cSrcweir 			Any aCol = xCols->getByName(pColNames[n]);
313*cdf0e10cSrcweir             Reference <XPropertySet> xCol;
314*cdf0e10cSrcweir             aCol >>= xCol;
315*cdf0e10cSrcweir 			Any aType = xCol->getPropertyValue(C2S("Type"));
316*cdf0e10cSrcweir 			sal_Int32 eDataType = 0;
317*cdf0e10cSrcweir 			aType >>= eDataType;
318*cdf0e10cSrcweir 			switch(eDataType)
319*cdf0e10cSrcweir 			{
320*cdf0e10cSrcweir 				case DataType::BIT:
321*cdf0e10cSrcweir 				case DataType::BOOLEAN:
322*cdf0e10cSrcweir 				case DataType::TINYINT:
323*cdf0e10cSrcweir 				case DataType::SMALLINT:
324*cdf0e10cSrcweir 				case DataType::INTEGER:
325*cdf0e10cSrcweir 				case DataType::BIGINT:
326*cdf0e10cSrcweir 				case DataType::FLOAT:
327*cdf0e10cSrcweir 				case DataType::REAL:
328*cdf0e10cSrcweir 				case DataType::DOUBLE:
329*cdf0e10cSrcweir 				case DataType::NUMERIC:
330*cdf0e10cSrcweir 				case DataType::DECIMAL:
331*cdf0e10cSrcweir 				case DataType::DATE:
332*cdf0e10cSrcweir 				case DataType::TIME:
333*cdf0e10cSrcweir 				case DataType::TIMESTAMP:
334*cdf0e10cSrcweir 				{
335*cdf0e10cSrcweir 					pNew->bHasFmt = sal_True;
336*cdf0e10cSrcweir 					Any aFormat = xCol->getPropertyValue(C2U("FormatKey"));
337*cdf0e10cSrcweir 					if(aFormat.hasValue())
338*cdf0e10cSrcweir 					{
339*cdf0e10cSrcweir 						sal_Int32 nFmt = 0;
340*cdf0e10cSrcweir 						aFormat >>= nFmt;
341*cdf0e10cSrcweir 						if(xNumberFormats.is())
342*cdf0e10cSrcweir 						{
343*cdf0e10cSrcweir 							try
344*cdf0e10cSrcweir 							{
345*cdf0e10cSrcweir 								Reference<XPropertySet> xNumProps = xNumberFormats->getByKey( nFmt );
346*cdf0e10cSrcweir                                 Any aFormatVal = xNumProps->getPropertyValue(C2U("FormatString"));
347*cdf0e10cSrcweir 								Any aLocale = xNumProps->getPropertyValue(C2U("Locale"));
348*cdf0e10cSrcweir                                 rtl::OUString sFormat;
349*cdf0e10cSrcweir                                 aFormatVal >>= sFormat;
350*cdf0e10cSrcweir                                 lang::Locale aLoc;
351*cdf0e10cSrcweir 								aLocale >>= aLoc;
352*cdf0e10cSrcweir 								long nKey = xDocNumberFormats->queryKey( sFormat, aLoc, sal_True);
353*cdf0e10cSrcweir 								if(nKey < 0)
354*cdf0e10cSrcweir 								{
355*cdf0e10cSrcweir 									nKey = xDocNumberFormats->addNew( sFormat, aLoc );
356*cdf0e10cSrcweir 								}
357*cdf0e10cSrcweir 								pNew->nDBNumFmt = nKey;
358*cdf0e10cSrcweir 							}
359*cdf0e10cSrcweir 							catch(const Exception& )
360*cdf0e10cSrcweir 							{
361*cdf0e10cSrcweir 								DBG_ERROR("illegal number format key");
362*cdf0e10cSrcweir 							}
363*cdf0e10cSrcweir 						}
364*cdf0e10cSrcweir 					}
365*cdf0e10cSrcweir 					else
366*cdf0e10cSrcweir                     {
367*cdf0e10cSrcweir                         pNew->nDBNumFmt = SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xCol,
368*cdf0e10cSrcweir                                                     xDocNumberFormatTypes, aDocLocale);
369*cdf0e10cSrcweir                     }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 				}
372*cdf0e10cSrcweir 				break;
373*cdf0e10cSrcweir 			}
374*cdf0e10cSrcweir 			if( !aDBColumns.Insert( pNew ))
375*cdf0e10cSrcweir 			{
376*cdf0e10cSrcweir 				ASSERT( !this, "Spaltenname mehrfach vergeben?" );
377*cdf0e10cSrcweir 				delete pNew;
378*cdf0e10cSrcweir 			}
379*cdf0e10cSrcweir 		}
380*cdf0e10cSrcweir 	}
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	// Absatzvorlagen-ListBox fuellen
383*cdf0e10cSrcweir 	{
384*cdf0e10cSrcweir 		SfxStyleSheetBasePool* pPool = pView->GetDocShell()->GetStyleSheetPool();
385*cdf0e10cSrcweir 		pPool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
386*cdf0e10cSrcweir 		aLbDbParaColl.InsertEntry( sNoTmpl );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 		const SfxStyleSheetBase* pBase = pPool->First();
389*cdf0e10cSrcweir 		while( pBase )
390*cdf0e10cSrcweir 		{
391*cdf0e10cSrcweir 			aLbDbParaColl.InsertEntry( pBase->GetName() );
392*cdf0e10cSrcweir 			pBase = pPool->Next();
393*cdf0e10cSrcweir 		}
394*cdf0e10cSrcweir 		aLbDbParaColl.SelectEntryPos( 0 );
395*cdf0e10cSrcweir 	}
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 	// steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
398*cdf0e10cSrcweir 	if( pView->GetWrtShell().GetTableFmt() )
399*cdf0e10cSrcweir 	{
400*cdf0e10cSrcweir 		aRbAsTable.Enable( sal_False );
401*cdf0e10cSrcweir 		aRbAsField.Check( sal_True );
402*cdf0e10cSrcweir 		aRbDbFmtFromDb.Check( sal_True );
403*cdf0e10cSrcweir 	}
404*cdf0e10cSrcweir 	else
405*cdf0e10cSrcweir 	{
406*cdf0e10cSrcweir 		aRbAsTable.Check( sal_True );
407*cdf0e10cSrcweir 		aRbDbFmtFromDb.Check( sal_True );
408*cdf0e10cSrcweir         aIbDbcolOneFrom.Enable( sal_False );
409*cdf0e10cSrcweir         aIbDbcolAllFrom.Enable( sal_False );
410*cdf0e10cSrcweir 	}
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 	aRbAsTable.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
413*cdf0e10cSrcweir 	aRbAsField.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
414*cdf0e10cSrcweir 	aRbAsText.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, PageHdl ));
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir 	aRbDbFmtFromDb.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
417*cdf0e10cSrcweir 	aRbDbFmtFromUsr.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, DBFormatHdl ));
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 	aPbTblFormat.SetClickHdl(LINK(this, SwInsertDBColAutoPilot, TblFmtHdl ));
420*cdf0e10cSrcweir 	aPbTblAutofmt.SetClickHdl(LINK(this, SwInsertDBColAutoPilot, AutoFmtHdl ));
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir     aIbDbcolAllTo.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
423*cdf0e10cSrcweir     aIbDbcolOneTo.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
424*cdf0e10cSrcweir     aIbDbcolOneFrom.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
425*cdf0e10cSrcweir     aIbDbcolAllFrom.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
426*cdf0e10cSrcweir     aIbDbcolToEdit.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, TblToFromHdl ));
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 	aCbTableHeadon.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
429*cdf0e10cSrcweir 	aRbHeadlColnms.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
430*cdf0e10cSrcweir 	aRbHeadlEmpty.SetClickHdl( LINK(this, SwInsertDBColAutoPilot, HeaderHdl ));
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 	aLbTxtDbColumn.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
433*cdf0e10cSrcweir 	aLbTblDbColumn.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
434*cdf0e10cSrcweir 	aLbDbFmtFromUsr.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
435*cdf0e10cSrcweir 	aLbTableCol.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot, SelectHdl ));
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 	aLbTxtDbColumn.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
438*cdf0e10cSrcweir 	aLbTblDbColumn.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
439*cdf0e10cSrcweir 	aLbTableCol.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot, DblClickHdl ));
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 	for( sal_uInt16 n = 0; n < aDBColumns.Count(); ++n )
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		const String& rS = aDBColumns[ n ]->sColumn;
444*cdf0e10cSrcweir 		aLbTblDbColumn.InsertEntry( rS, n );
445*cdf0e10cSrcweir 		aLbTxtDbColumn.InsertEntry( rS, n );
446*cdf0e10cSrcweir 	}
447*cdf0e10cSrcweir 	aLbTxtDbColumn.SelectEntryPos( 0 );
448*cdf0e10cSrcweir 	aLbTblDbColumn.SelectEntryPos( 0 );
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 	// read configuration
451*cdf0e10cSrcweir 	Load();
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 	// Controls initialisieren:
454*cdf0e10cSrcweir 	PageHdl( aRbAsTable.IsChecked() ? &aRbAsTable : &aRbAsField );
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
459*cdf0e10cSrcweir SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot()
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir 	delete pTblSet;
462*cdf0e10cSrcweir 	delete pRep;
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir //	delete pConfig;
465*cdf0e10cSrcweir 	delete pTAutoFmt;
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
470*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, PageHdl, Button*, pButton )
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir 	sal_Bool bShowTbl = pButton == &aRbAsTable;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	String sTxt( pButton->GetText() );
475*cdf0e10cSrcweir     aFlHead.SetText( MnemonicGenerator::EraseAllMnemonicChars( sTxt ) );
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	aLbTxtDbColumn.Show( !bShowTbl );
478*cdf0e10cSrcweir     aIbDbcolToEdit.Show( !bShowTbl );
479*cdf0e10cSrcweir 	aEdDbText.Show( !bShowTbl );
480*cdf0e10cSrcweir 	aFtDbParaColl.Show( !bShowTbl );
481*cdf0e10cSrcweir 	aLbDbParaColl.Show( !bShowTbl );
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 	aLbTblDbColumn.Show( bShowTbl );
484*cdf0e10cSrcweir     aIbDbcolAllTo.Show( bShowTbl );
485*cdf0e10cSrcweir     aIbDbcolOneTo.Show( bShowTbl );
486*cdf0e10cSrcweir     aIbDbcolOneFrom.Show( bShowTbl );
487*cdf0e10cSrcweir     aIbDbcolAllFrom.Show( bShowTbl );
488*cdf0e10cSrcweir 	aFtTableCol.Show( bShowTbl );
489*cdf0e10cSrcweir 	aLbTableCol.Show( bShowTbl );
490*cdf0e10cSrcweir 	aCbTableHeadon.Show( bShowTbl );
491*cdf0e10cSrcweir 	aRbHeadlColnms.Show( bShowTbl );
492*cdf0e10cSrcweir 	aRbHeadlEmpty.Show( bShowTbl );
493*cdf0e10cSrcweir 	aPbTblFormat.Show( bShowTbl );
494*cdf0e10cSrcweir 	aPbTblAutofmt.Show( bShowTbl );
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir 	if( bShowTbl )
497*cdf0e10cSrcweir 		aPbTblFormat.Enable( 0 != aLbTableCol.GetEntryCount() );
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 	SelectHdl( bShowTbl ? &aLbTblDbColumn : &aLbTxtDbColumn );
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir 	return 0;
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
506*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, DBFormatHdl, Button*, pButton )
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir 	sal_uInt16 nFndPos;
509*cdf0e10cSrcweir 	ListBox& rBox = aRbAsTable.IsChecked()
510*cdf0e10cSrcweir 						? ( 0 == aLbTableCol.GetEntryData( 0 )
511*cdf0e10cSrcweir 							? aLbTblDbColumn
512*cdf0e10cSrcweir 							: aLbTableCol )
513*cdf0e10cSrcweir 						: aLbTxtDbColumn;
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 	SwInsDBColumn aSrch( rBox.GetSelectEntry(), 0 );
516*cdf0e10cSrcweir 	aDBColumns.Seek_Entry( &aSrch, &nFndPos );
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	sal_Bool bFromDB = &aRbDbFmtFromDb == pButton;
519*cdf0e10cSrcweir 	aDBColumns[ nFndPos ]->bIsDBFmt = bFromDB;
520*cdf0e10cSrcweir 	aLbDbFmtFromUsr.Enable( !bFromDB );
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 	return 0;
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
527*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, TblToFromHdl, Button*, pButton )
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir 	sal_Bool bChgEnable = sal_True, bEnableTo = sal_True, bEnableFrom = sal_True;
530*cdf0e10cSrcweir 	aLbTblDbColumn.SetUpdateMode( sal_False );
531*cdf0e10cSrcweir 	aLbTableCol.SetUpdateMode( sal_False );
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir     if( pButton == &aIbDbcolAllTo )
534*cdf0e10cSrcweir 	{
535*cdf0e10cSrcweir 		bEnableTo = sal_False;
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir 		sal_uInt16 n, nInsPos = aLbTableCol.GetSelectEntryPos(),
538*cdf0e10cSrcweir 			   nCnt = aLbTblDbColumn.GetEntryCount();
539*cdf0e10cSrcweir 		if( LISTBOX_APPEND == nInsPos )
540*cdf0e10cSrcweir 			for( n = 0; n < nCnt; ++n )
541*cdf0e10cSrcweir 				aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( n ),
542*cdf0e10cSrcweir 											LISTBOX_APPEND );
543*cdf0e10cSrcweir 		else
544*cdf0e10cSrcweir 			for( n = 0; n < nCnt; ++n, ++nInsPos )
545*cdf0e10cSrcweir 				aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( n ), nInsPos );
546*cdf0e10cSrcweir 		aLbTblDbColumn.Clear();
547*cdf0e10cSrcweir 		aLbTableCol.SelectEntryPos( nInsPos );
548*cdf0e10cSrcweir 		aLbTblDbColumn.SelectEntryPos( LISTBOX_APPEND );
549*cdf0e10cSrcweir 	}
550*cdf0e10cSrcweir     else if( pButton == &aIbDbcolOneTo &&
551*cdf0e10cSrcweir 			LISTBOX_ENTRY_NOTFOUND != aLbTblDbColumn.GetSelectEntryPos() )
552*cdf0e10cSrcweir 	{
553*cdf0e10cSrcweir 		sal_uInt16 nInsPos = aLbTableCol.GetSelectEntryPos(),
554*cdf0e10cSrcweir 			   nDelPos = aLbTblDbColumn.GetSelectEntryPos(),
555*cdf0e10cSrcweir 			   nTopPos = aLbTblDbColumn.GetTopEntry();
556*cdf0e10cSrcweir 		aLbTableCol.InsertEntry( aLbTblDbColumn.GetEntry( nDelPos ), nInsPos );
557*cdf0e10cSrcweir 		aLbTblDbColumn.RemoveEntry( nDelPos );
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 		aLbTableCol.SelectEntryPos( nInsPos );
560*cdf0e10cSrcweir 		if( nDelPos >= aLbTblDbColumn.GetEntryCount() )
561*cdf0e10cSrcweir 			nDelPos = aLbTblDbColumn.GetEntryCount() - 1;
562*cdf0e10cSrcweir 		aLbTblDbColumn.SelectEntryPos( nDelPos );
563*cdf0e10cSrcweir 		aLbTblDbColumn.SetTopEntry( nTopPos );
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir 		bEnableTo = 0 != aLbTblDbColumn.GetEntryCount();
566*cdf0e10cSrcweir 	}
567*cdf0e10cSrcweir     else if( pButton == &aIbDbcolOneFrom )
568*cdf0e10cSrcweir 	{
569*cdf0e10cSrcweir 		if( LISTBOX_ENTRY_NOTFOUND != aLbTableCol.GetSelectEntryPos() )
570*cdf0e10cSrcweir 		{
571*cdf0e10cSrcweir 			sal_uInt16 nFndPos, nInsPos,
572*cdf0e10cSrcweir 					nDelPos = aLbTableCol.GetSelectEntryPos(),
573*cdf0e10cSrcweir 					nTopPos = aLbTableCol.GetTopEntry();
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 			// die richtige InsertPos suchen!!
576*cdf0e10cSrcweir 			SwInsDBColumn aSrch( aLbTableCol.GetEntry( nDelPos ), 0 );
577*cdf0e10cSrcweir 			aDBColumns.Seek_Entry( &aSrch, &nFndPos );
578*cdf0e10cSrcweir 			if( !nFndPos || nFndPos == aDBColumns.Count()-1 )
579*cdf0e10cSrcweir 				nInsPos = nFndPos;
580*cdf0e10cSrcweir 			else
581*cdf0e10cSrcweir 			{
582*cdf0e10cSrcweir 				nInsPos = LISTBOX_ENTRY_NOTFOUND;
583*cdf0e10cSrcweir 				while( ++nFndPos < aDBColumns.Count() &&
584*cdf0e10cSrcweir 						LISTBOX_ENTRY_NOTFOUND == (nInsPos = aLbTblDbColumn.
585*cdf0e10cSrcweir 						GetEntryPos( String(aDBColumns[ nFndPos ]->sColumn ))) )
586*cdf0e10cSrcweir 					;
587*cdf0e10cSrcweir 			}
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir 			aLbTblDbColumn.InsertEntry( aSrch.sColumn, nInsPos );
590*cdf0e10cSrcweir 			aLbTableCol.RemoveEntry( nDelPos );
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 			if( nInsPos >= aLbTblDbColumn.GetEntryCount() )
593*cdf0e10cSrcweir 				nInsPos = aLbTblDbColumn.GetEntryCount() - 1;
594*cdf0e10cSrcweir 			aLbTblDbColumn.SelectEntryPos( nInsPos );
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 			if( nDelPos >= aLbTableCol.GetEntryCount() )
597*cdf0e10cSrcweir 				nDelPos = aLbTableCol.GetEntryCount() - 1;
598*cdf0e10cSrcweir 			aLbTableCol.SelectEntryPos( nDelPos );
599*cdf0e10cSrcweir 			aLbTableCol.SetTopEntry( nTopPos );
600*cdf0e10cSrcweir 		}
601*cdf0e10cSrcweir 		else
602*cdf0e10cSrcweir 			bEnableTo = 0 != aLbTblDbColumn.GetEntryCount();
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir 		bEnableFrom = 0 != aLbTableCol.GetEntryCount();
605*cdf0e10cSrcweir 	}
606*cdf0e10cSrcweir     else if( pButton == &aIbDbcolAllFrom )
607*cdf0e10cSrcweir 	{
608*cdf0e10cSrcweir 		bEnableFrom = sal_False;
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 		aLbTblDbColumn.Clear();
611*cdf0e10cSrcweir 		aLbTableCol.Clear();
612*cdf0e10cSrcweir 		for( sal_uInt16 n = 0; n < aDBColumns.Count(); ++n )
613*cdf0e10cSrcweir 			aLbTblDbColumn.InsertEntry( aDBColumns[ n ]->sColumn, n );
614*cdf0e10cSrcweir 		aLbTblDbColumn.SelectEntryPos( 0 );
615*cdf0e10cSrcweir 	}
616*cdf0e10cSrcweir     else if( pButton == &aIbDbcolToEdit )
617*cdf0e10cSrcweir 	{
618*cdf0e10cSrcweir 		bChgEnable = sal_False;
619*cdf0e10cSrcweir 		// Daten ins Edit moven:
620*cdf0e10cSrcweir 		String aFld( aLbTxtDbColumn.GetSelectEntry() );
621*cdf0e10cSrcweir 		if( aFld.Len() )
622*cdf0e10cSrcweir 		{
623*cdf0e10cSrcweir 			String aStr( aEdDbText.GetText() );
624*cdf0e10cSrcweir 			sal_uInt16 nPos = (sal_uInt16)aEdDbText.GetSelection().Min();
625*cdf0e10cSrcweir 			sal_uInt16 nSel = sal_uInt16(aEdDbText.GetSelection().Max()) - nPos;
626*cdf0e10cSrcweir 			if( nSel )
627*cdf0e10cSrcweir 				// dann loesche erstmal die bestehende Selektion
628*cdf0e10cSrcweir 				aStr.Erase( nPos, nSel );
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 			aFld.Insert( cDBFldStart, 0 );
631*cdf0e10cSrcweir 			aFld += cDBFldEnd;
632*cdf0e10cSrcweir 			if( aStr.Len() )
633*cdf0e10cSrcweir 			{
634*cdf0e10cSrcweir 				if( nPos ) 							// ein Space davor
635*cdf0e10cSrcweir 				{
636*cdf0e10cSrcweir 					sal_Unicode c = aStr.GetChar( nPos-1 );
637*cdf0e10cSrcweir 					if( '\n' != c && '\r' != c )
638*cdf0e10cSrcweir 						aFld.Insert( ' ', 0 );
639*cdf0e10cSrcweir 				}
640*cdf0e10cSrcweir 				if( nPos < aStr.Len() )				// ein Space dahinter
641*cdf0e10cSrcweir 				{
642*cdf0e10cSrcweir 					sal_Unicode c = aStr.GetChar( nPos );
643*cdf0e10cSrcweir 					if( '\n' != c && '\r' != c )
644*cdf0e10cSrcweir 						aFld += ' ';
645*cdf0e10cSrcweir 				}
646*cdf0e10cSrcweir 			}
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 			aStr.Insert( aFld, nPos );
649*cdf0e10cSrcweir 			aEdDbText.SetText( aStr );
650*cdf0e10cSrcweir             nPos = nPos + aFld.Len();
651*cdf0e10cSrcweir 			aEdDbText.SetSelection( Selection( nPos ));
652*cdf0e10cSrcweir 		}
653*cdf0e10cSrcweir 	}
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	if( bChgEnable )
656*cdf0e10cSrcweir 	{
657*cdf0e10cSrcweir         aIbDbcolOneTo.Enable( bEnableTo );
658*cdf0e10cSrcweir         aIbDbcolAllTo.Enable( bEnableTo );
659*cdf0e10cSrcweir         aIbDbcolOneFrom.Enable( bEnableFrom );
660*cdf0e10cSrcweir         aIbDbcolAllFrom.Enable( bEnableFrom );
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 		aRbDbFmtFromDb.Enable( sal_False );
663*cdf0e10cSrcweir 		aRbDbFmtFromUsr.Enable( sal_False );
664*cdf0e10cSrcweir 		aLbDbFmtFromUsr.Enable( sal_False );
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 		aPbTblFormat.Enable( bEnableFrom );
667*cdf0e10cSrcweir 	}
668*cdf0e10cSrcweir 	aLbTblDbColumn.SetUpdateMode( sal_True );
669*cdf0e10cSrcweir 	aLbTableCol.SetUpdateMode( sal_True );
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir 	return 0;
672*cdf0e10cSrcweir }
673*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
676*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, DblClickHdl, ListBox*, pBox )
677*cdf0e10cSrcweir {
678*cdf0e10cSrcweir 	Button* pButton = 0;
679*cdf0e10cSrcweir 	if( pBox == &aLbTxtDbColumn )
680*cdf0e10cSrcweir         pButton = &aIbDbcolToEdit;
681*cdf0e10cSrcweir     else if( pBox == &aLbTblDbColumn && aIbDbcolOneTo.IsEnabled() )
682*cdf0e10cSrcweir         pButton = &aIbDbcolOneTo;
683*cdf0e10cSrcweir     else if( pBox == &aLbTableCol && aIbDbcolOneFrom.IsEnabled() )
684*cdf0e10cSrcweir         pButton = &aIbDbcolOneFrom;
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir 	if( pButton )
687*cdf0e10cSrcweir 		TblToFromHdl( pButton );
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	return 0;
690*cdf0e10cSrcweir }
691*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
692*cdf0e10cSrcweir 
693*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
694*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, TblFmtHdl, PushButton*, pButton )
695*cdf0e10cSrcweir {
696*cdf0e10cSrcweir 	SwWrtShell& rSh = pView->GetWrtShell();
697*cdf0e10cSrcweir 	sal_Bool bNewSet = sal_False;
698*cdf0e10cSrcweir 	if( !pTblSet )
699*cdf0e10cSrcweir 	{
700*cdf0e10cSrcweir 		bNewSet = sal_True;
701*cdf0e10cSrcweir 		pTblSet = new SfxItemSet( rSh.GetAttrPool(), SwuiGetUITableAttrRange() );
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir 		//Ersteinmal die einfachen Attribute besorgen.
704*cdf0e10cSrcweir 		pTblSet->Put( SfxStringItem( FN_PARAM_TABLE_NAME, rSh.GetUniqueTblName() ));
705*cdf0e10cSrcweir 		pTblSet->Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, 1 ) );
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 		pTblSet->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION,
708*cdf0e10cSrcweir 									rSh.GetViewOptions()->GetTblDest() ));
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 		SvxBrushItem aBrush( RES_BACKGROUND );
711*cdf0e10cSrcweir 		pTblSet->Put( aBrush );
712*cdf0e10cSrcweir 		pTblSet->Put( aBrush, SID_ATTR_BRUSH_ROW );
713*cdf0e10cSrcweir 		pTblSet->Put( aBrush, SID_ATTR_BRUSH_TABLE );
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
716*cdf0e10cSrcweir 			// Tabellenvariante, wenn mehrere Tabellenzellen selektiert
717*cdf0e10cSrcweir 		aBoxInfo.SetTable( sal_True );
718*cdf0e10cSrcweir 			// Abstandsfeld immer anzeigen
719*cdf0e10cSrcweir 		aBoxInfo.SetDist( sal_True);
720*cdf0e10cSrcweir 			// Minimalgroesse in Tabellen und Absaetzen setzen
721*cdf0e10cSrcweir 		aBoxInfo.SetMinDist( sal_False );
722*cdf0e10cSrcweir 			// Default-Abstand immer setzen
723*cdf0e10cSrcweir 		aBoxInfo.SetDefDist( MIN_BORDER_DIST );
724*cdf0e10cSrcweir 			// Einzelne Linien koennen nur in Tabellen DontCare-Status haben
725*cdf0e10cSrcweir 		aBoxInfo.SetValid( VALID_DISABLE, sal_True );
726*cdf0e10cSrcweir 		pTblSet->Put( aBoxInfo );
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 		SwGetCurColNumPara aPara;
729*cdf0e10cSrcweir         const sal_uInt16 nNum = rSh.GetCurColNum( &aPara );
730*cdf0e10cSrcweir 		long nWidth;
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 		if( nNum )
733*cdf0e10cSrcweir 		{
734*cdf0e10cSrcweir 			nWidth = aPara.pPrtRect->Width();
735*cdf0e10cSrcweir 			const SwFmtCol& rCol = aPara.pFrmFmt->GetCol();
736*cdf0e10cSrcweir 			const SwColumns& rCols = rCol.GetColumns();
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir 			//nStart und nEnd initialisieren fuer nNum == 0
739*cdf0e10cSrcweir 			long nWidth1 = 0,
740*cdf0e10cSrcweir 				nStart1 = 0,
741*cdf0e10cSrcweir 				nEnd1 = nWidth;
742*cdf0e10cSrcweir             for( sal_uInt16 i = 0; i < nNum; ++i )
743*cdf0e10cSrcweir 			{
744*cdf0e10cSrcweir 				SwColumn* pCol = rCols[i];
745*cdf0e10cSrcweir 				nStart1 = pCol->GetLeft() + nWidth1;
746*cdf0e10cSrcweir 				nWidth1 += (long)rCol.CalcColWidth( i, (sal_uInt16)nWidth );
747*cdf0e10cSrcweir 				nEnd1 = nWidth1 - pCol->GetRight();
748*cdf0e10cSrcweir 			}
749*cdf0e10cSrcweir 			if(nStart1 || nEnd1 != nWidth)
750*cdf0e10cSrcweir 				nWidth = nEnd1 - nStart1;
751*cdf0e10cSrcweir 		}
752*cdf0e10cSrcweir 		else
753*cdf0e10cSrcweir 			nWidth = rSh.GetAnyCurRect(
754*cdf0e10cSrcweir 								FRMTYPE_FLY_ANY & rSh.GetFrmType( 0, sal_True )
755*cdf0e10cSrcweir 											  ? RECT_FLY_PRT_EMBEDDED
756*cdf0e10cSrcweir 											  : RECT_PAGE_PRT ).Width();
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir 		SwTabCols aTabCols;
759*cdf0e10cSrcweir 		aTabCols.SetRight( nWidth );
760*cdf0e10cSrcweir 		aTabCols.SetRightMax( nWidth );
761*cdf0e10cSrcweir 		pRep = new SwTableRep( aTabCols, sal_False );
762*cdf0e10cSrcweir         pRep->SetAlign( text::HoriOrientation::NONE );
763*cdf0e10cSrcweir 		pRep->SetSpace( nWidth );
764*cdf0e10cSrcweir 		pRep->SetWidth( nWidth );
765*cdf0e10cSrcweir 		pRep->SetWidthPercent( 100 );
766*cdf0e10cSrcweir 		pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 		pTblSet->Put( SfxUInt16Item( SID_HTML_MODE,
769*cdf0e10cSrcweir 					::GetHtmlMode( pView->GetDocShell() )));
770*cdf0e10cSrcweir 	}
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir 	if( aLbTableCol.GetEntryCount() != pRep->GetAllColCount() )
773*cdf0e10cSrcweir 	{
774*cdf0e10cSrcweir 		// Anzahl der Spalten hat sich geaendert: dann muessen die
775*cdf0e10cSrcweir 		// TabCols angepasst werden
776*cdf0e10cSrcweir 		long nWidth = pRep->GetWidth();
777*cdf0e10cSrcweir 		sal_uInt16 nCols = aLbTableCol.GetEntryCount() - 1;
778*cdf0e10cSrcweir 		SwTabCols aTabCols( nCols );
779*cdf0e10cSrcweir 		aTabCols.SetRight( nWidth  );
780*cdf0e10cSrcweir 		aTabCols.SetRightMax( nWidth );
781*cdf0e10cSrcweir 		if( nCols )
782*cdf0e10cSrcweir 			for( sal_uInt16 n = 0, nStep = (sal_uInt16)(nWidth / (nCols+1)), nW = nStep;
783*cdf0e10cSrcweir                     n < nCols; ++n, nW = nW + nStep )
784*cdf0e10cSrcweir 			{
785*cdf0e10cSrcweir                 aTabCols.Insert( nW, sal_False, n );
786*cdf0e10cSrcweir             }
787*cdf0e10cSrcweir 		delete pRep;
788*cdf0e10cSrcweir 		pRep = new SwTableRep( aTabCols, sal_False );
789*cdf0e10cSrcweir         pRep->SetAlign( text::HoriOrientation::NONE );
790*cdf0e10cSrcweir 		pRep->SetSpace( nWidth );
791*cdf0e10cSrcweir 		pRep->SetWidth( nWidth );
792*cdf0e10cSrcweir 		pRep->SetWidthPercent( 100 );
793*cdf0e10cSrcweir 		pTblSet->Put( SwPtrItem( FN_TABLE_REP, pRep ));
794*cdf0e10cSrcweir 	}
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir     SwAbstractDialogFactory* pFact = swui::GetFactory();
797*cdf0e10cSrcweir     DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir     SfxAbstractTabDialog* pDlg = pFact->CreateSwTableTabDlg(  pButton, rSh.GetAttrPool(),pTblSet, &rSh, DLG_FORMAT_TABLE );
800*cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");
801*cdf0e10cSrcweir 	if( RET_OK == pDlg->Execute() )
802*cdf0e10cSrcweir 		pTblSet->Put( *pDlg->GetOutputItemSet() );
803*cdf0e10cSrcweir 	else if( bNewSet )
804*cdf0e10cSrcweir 	{
805*cdf0e10cSrcweir 		delete pTblSet, pTblSet = 0;
806*cdf0e10cSrcweir 		delete pRep, pRep = 0;
807*cdf0e10cSrcweir 	}
808*cdf0e10cSrcweir 	delete pDlg;
809*cdf0e10cSrcweir 
810*cdf0e10cSrcweir 	return 0;
811*cdf0e10cSrcweir }
812*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
815*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, AutoFmtHdl, PushButton*, pButton )
816*cdf0e10cSrcweir {
817*cdf0e10cSrcweir     SwAbstractDialogFactory* pFact = swui::GetFactory();
818*cdf0e10cSrcweir     DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir     AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(pButton, pView->GetWrtShellPtr(),DLG_AUTOFMT_TABLE, sal_False, pTAutoFmt);
821*cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");
822*cdf0e10cSrcweir     if( RET_OK == pDlg->Execute())
823*cdf0e10cSrcweir         pDlg->FillAutoFmtOfIndex( pTAutoFmt );
824*cdf0e10cSrcweir     delete pDlg;
825*cdf0e10cSrcweir 	return 0;
826*cdf0e10cSrcweir }
827*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
830*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, SelectHdl, ListBox*, pBox )
831*cdf0e10cSrcweir {
832*cdf0e10cSrcweir 	ListBox* pGetBox = pBox == &aLbDbFmtFromUsr
833*cdf0e10cSrcweir 							? ( aRbAsTable.IsChecked()
834*cdf0e10cSrcweir 									? ( 0 == aLbTableCol.GetEntryData( 0 )
835*cdf0e10cSrcweir 										? &aLbTblDbColumn
836*cdf0e10cSrcweir 										: &aLbTableCol )
837*cdf0e10cSrcweir 									: &aLbTxtDbColumn )
838*cdf0e10cSrcweir 							: pBox;
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir 	sal_uInt16 nFndPos;
841*cdf0e10cSrcweir 	SwInsDBColumn aSrch( pGetBox->GetSelectEntry(), 0 );
842*cdf0e10cSrcweir 	aDBColumns.Seek_Entry( &aSrch, &nFndPos );
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 	if( pBox == &aLbDbFmtFromUsr )
845*cdf0e10cSrcweir 	{
846*cdf0e10cSrcweir 		if( aSrch.sColumn.getLength() )
847*cdf0e10cSrcweir 		{
848*cdf0e10cSrcweir 			aOldNumFmtLnk.Call( pBox );
849*cdf0e10cSrcweir 			aDBColumns[ nFndPos ]->nUsrNumFmt = aLbDbFmtFromUsr.GetFormat();
850*cdf0e10cSrcweir 		}
851*cdf0e10cSrcweir 	}
852*cdf0e10cSrcweir 	else
853*cdf0e10cSrcweir 	{
854*cdf0e10cSrcweir 		// an der FormatGroupBox den ausgewaehlten FeldNamen setzen, damit
855*cdf0e10cSrcweir 		// klar ist, welches Feld ueber das Format eingestellt wird!
856*cdf0e10cSrcweir         String sTxt( aFlFormat.GetText().Copy( 0, nGBFmtLen ));
857*cdf0e10cSrcweir 		if( !aSrch.sColumn.getLength() )
858*cdf0e10cSrcweir 		{
859*cdf0e10cSrcweir 			aRbDbFmtFromDb.Enable( sal_False );
860*cdf0e10cSrcweir 			aRbDbFmtFromUsr.Enable( sal_False );
861*cdf0e10cSrcweir 			aLbDbFmtFromUsr.Enable( sal_False );
862*cdf0e10cSrcweir 		}
863*cdf0e10cSrcweir 		else
864*cdf0e10cSrcweir 		{
865*cdf0e10cSrcweir 			sal_Bool bEnableFmt = aDBColumns[ nFndPos ]->bHasFmt;
866*cdf0e10cSrcweir 			aRbDbFmtFromDb.Enable( bEnableFmt );
867*cdf0e10cSrcweir 			aRbDbFmtFromUsr.Enable( bEnableFmt );
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir 			if( bEnableFmt )
870*cdf0e10cSrcweir 			{
871*cdf0e10cSrcweir 				(( sTxt += C2S(" (" )) += String(aSrch.sColumn) ) += (sal_Unicode)')';
872*cdf0e10cSrcweir 			}
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir 			sal_Bool bIsDBFmt = aDBColumns[ nFndPos ]->bIsDBFmt;
875*cdf0e10cSrcweir 			aRbDbFmtFromDb.Check( bIsDBFmt );
876*cdf0e10cSrcweir 			aRbDbFmtFromUsr.Check( !bIsDBFmt );
877*cdf0e10cSrcweir 			aLbDbFmtFromUsr.Enable( !bIsDBFmt );
878*cdf0e10cSrcweir 			if( !bIsDBFmt )
879*cdf0e10cSrcweir 				aLbDbFmtFromUsr.SetDefFormat( aDBColumns[ nFndPos ]->nUsrNumFmt );
880*cdf0e10cSrcweir 		}
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir         aFlFormat.SetText( sTxt );
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir 		// um spaeter zu wissen, welche ListBox die "aktive" war, wird sich
885*cdf0e10cSrcweir 		// im 1. Eintrag ein Flag gemerkt,
886*cdf0e10cSrcweir 		void* pPtr = pBox == &aLbTableCol ? &aLbTableCol : 0;
887*cdf0e10cSrcweir 		aLbTableCol.SetEntryData( 0, pPtr );
888*cdf0e10cSrcweir 	}
889*cdf0e10cSrcweir 	return 0;
890*cdf0e10cSrcweir }
891*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
894*cdf0e10cSrcweir IMPL_LINK( SwInsertDBColAutoPilot, HeaderHdl, Button*, pButton )
895*cdf0e10cSrcweir {
896*cdf0e10cSrcweir 	if( pButton == &aCbTableHeadon )
897*cdf0e10cSrcweir 	{
898*cdf0e10cSrcweir 		sal_Bool bEnable = aCbTableHeadon.IsChecked();
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir 		aRbHeadlColnms.Enable( bEnable );
901*cdf0e10cSrcweir 		aRbHeadlEmpty.Enable( bEnable );
902*cdf0e10cSrcweir 	}
903*cdf0e10cSrcweir 	return 0;
904*cdf0e10cSrcweir }
905*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
908*cdf0e10cSrcweir static void lcl_InsTextInArr( const String& rTxt, _DB_Columns& rColArr )
909*cdf0e10cSrcweir {
910*cdf0e10cSrcweir 	_DB_Column* pNew;
911*cdf0e10cSrcweir 	sal_uInt16 nSttPos = 0, nFndPos;
912*cdf0e10cSrcweir 	while( STRING_NOTFOUND != ( nFndPos = rTxt.Search( '\x0A', nSttPos )) )
913*cdf0e10cSrcweir 	{
914*cdf0e10cSrcweir 		if( 1 < nFndPos )
915*cdf0e10cSrcweir 		{
916*cdf0e10cSrcweir 			pNew = new _DB_Column( rTxt.Copy( nSttPos, nFndPos -1 ) );
917*cdf0e10cSrcweir 			rColArr.Insert( pNew, rColArr.Count() );
918*cdf0e10cSrcweir 		}
919*cdf0e10cSrcweir 		pNew = new _DB_Column;
920*cdf0e10cSrcweir 		rColArr.Insert( pNew, rColArr.Count() );
921*cdf0e10cSrcweir 		nSttPos = nFndPos + 1;
922*cdf0e10cSrcweir 	}
923*cdf0e10cSrcweir 	if( nSttPos < rTxt.Len() )
924*cdf0e10cSrcweir 	{
925*cdf0e10cSrcweir 		pNew = new _DB_Column( rTxt.Copy( nSttPos ) );
926*cdf0e10cSrcweir 		rColArr.Insert( pNew, rColArr.Count() );
927*cdf0e10cSrcweir 	}
928*cdf0e10cSrcweir }
929*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
932*cdf0e10cSrcweir sal_Bool SwInsertDBColAutoPilot::SplitTextToColArr( const String& rTxt,
933*cdf0e10cSrcweir 								_DB_Columns& rColArr,
934*cdf0e10cSrcweir 								sal_Bool bInsField )
935*cdf0e10cSrcweir {
936*cdf0e10cSrcweir 	// aus dem Text wieder die einzelnen Datenbank - Spalten erzeugen
937*cdf0e10cSrcweir 	// und dann in einem Array speichern
938*cdf0e10cSrcweir 	// Die Datenbankspalten stehen in <> und muessen im Array der Spalten
939*cdf0e10cSrcweir 	// vorhanden sein:
940*cdf0e10cSrcweir 	String sTxt( rTxt );
941*cdf0e10cSrcweir 	sal_uInt16 nFndPos, nEndPos, nSttPos = 0;
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir 	while( STRING_NOTFOUND != ( nFndPos = sTxt.Search( cDBFldStart, nSttPos )))
944*cdf0e10cSrcweir 	{
945*cdf0e10cSrcweir 		nSttPos = nFndPos + 1;
946*cdf0e10cSrcweir 		if( STRING_NOTFOUND != ( nEndPos = sTxt.Search( cDBFldEnd, nSttPos+1 )))
947*cdf0e10cSrcweir 		{
948*cdf0e10cSrcweir 			// Text in <> geklammert gefunden: was ist es denn:
949*cdf0e10cSrcweir 			SwInsDBColumn aSrch( sTxt.Copy( nSttPos, nEndPos - nSttPos ), 0);
950*cdf0e10cSrcweir 			if( aDBColumns.Seek_Entry( &aSrch, &nFndPos ) )
951*cdf0e10cSrcweir 			{
952*cdf0e10cSrcweir 				// das ist ein gueltiges Feld
953*cdf0e10cSrcweir 				// also sicher den Text "davor":
954*cdf0e10cSrcweir 				const SwInsDBColumn& rFndCol = *aDBColumns[ nFndPos ];
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir 				_DB_Column* pNew;
957*cdf0e10cSrcweir 
958*cdf0e10cSrcweir 				if( 1 < nSttPos )
959*cdf0e10cSrcweir 				{
960*cdf0e10cSrcweir 					::lcl_InsTextInArr( sTxt.Copy( 0, nSttPos-1 ), rColArr );
961*cdf0e10cSrcweir 					sTxt.Erase( 0, nSttPos-1 );
962*cdf0e10cSrcweir 				}
963*cdf0e10cSrcweir 
964*cdf0e10cSrcweir 				sTxt.Erase( 0, (xub_StrLen)(rFndCol.sColumn.getLength() + 2) );
965*cdf0e10cSrcweir 				nSttPos = 0;
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir 				sal_uInt16 nSubType = 0;
968*cdf0e10cSrcweir 				sal_uLong nFormat;
969*cdf0e10cSrcweir 				if( rFndCol.bHasFmt )
970*cdf0e10cSrcweir 				{
971*cdf0e10cSrcweir 					if( rFndCol.bIsDBFmt )
972*cdf0e10cSrcweir 						nFormat =  rFndCol.nDBNumFmt;
973*cdf0e10cSrcweir 					else
974*cdf0e10cSrcweir 					{
975*cdf0e10cSrcweir 						nFormat = rFndCol.nUsrNumFmt;
976*cdf0e10cSrcweir 						nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
977*cdf0e10cSrcweir 					}
978*cdf0e10cSrcweir 				}
979*cdf0e10cSrcweir 				else
980*cdf0e10cSrcweir 					nFormat = 0;
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir 				if( bInsField )
983*cdf0e10cSrcweir 				{
984*cdf0e10cSrcweir 					SwWrtShell& rSh = pView->GetWrtShell();
985*cdf0e10cSrcweir 					SwDBFieldType aFldType( rSh.GetDoc(), aSrch.sColumn,
986*cdf0e10cSrcweir 											aDBData );
987*cdf0e10cSrcweir 					pNew = new _DB_Column( rFndCol, *new SwDBField(
988*cdf0e10cSrcweir 							(SwDBFieldType*)rSh.InsertFldType( aFldType ),
989*cdf0e10cSrcweir 															nFormat ) );
990*cdf0e10cSrcweir 					if( nSubType )
991*cdf0e10cSrcweir 						pNew->DB_ColumnData.pField->SetSubType( nSubType );
992*cdf0e10cSrcweir 				}
993*cdf0e10cSrcweir 				else
994*cdf0e10cSrcweir 					pNew = new _DB_Column( rFndCol, nFormat );
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 				rColArr.Insert( pNew, rColArr.Count() );
997*cdf0e10cSrcweir 			}
998*cdf0e10cSrcweir 		}
999*cdf0e10cSrcweir 	}
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir 	// den letzten Text nicht vergessen
1002*cdf0e10cSrcweir 	if( sTxt.Len() )
1003*cdf0e10cSrcweir 		::lcl_InsTextInArr( sTxt, rColArr );
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir 	return 0 != rColArr.Count();
1006*cdf0e10cSrcweir }
1007*cdf0e10cSrcweir /* ---------------------------------------------------------------------------
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1010*cdf0e10cSrcweir void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
1011*cdf0e10cSrcweir 	Reference< XDataSource> xSource,
1012*cdf0e10cSrcweir 	Reference< XConnection> xConnection,
1013*cdf0e10cSrcweir 	Reference< sdbc::XResultSet > xResultSet )
1014*cdf0e10cSrcweir {
1015*cdf0e10cSrcweir     const Any* pSelection = rSelection.getLength() ? rSelection.getConstArray() : 0;
1016*cdf0e10cSrcweir 	SwWrtShell& rSh = pView->GetWrtShell();
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir 	//with the drag and drop interface no result set is initially available
1019*cdf0e10cSrcweir     sal_Bool bDisposeResultSet = sal_False;
1020*cdf0e10cSrcweir 	// we don't have a cursor, so we have to create our own RowSet
1021*cdf0e10cSrcweir 	if ( !xResultSet.is() )
1022*cdf0e10cSrcweir 	{
1023*cdf0e10cSrcweir 		xResultSet = SwNewDBMgr::createCursor(aDBData.sDataSource,aDBData.sCommand,aDBData.nCommandType,xConnection);
1024*cdf0e10cSrcweir 		bDisposeResultSet = xResultSet.is();
1025*cdf0e10cSrcweir 	}
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir 	Reference< sdbc::XRow > xRow(xResultSet, UNO_QUERY);
1028*cdf0e10cSrcweir 	if ( !xRow.is() )
1029*cdf0e10cSrcweir 		return;
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir 	rSh.StartAllAction();
1032*cdf0e10cSrcweir 	sal_Bool bUndo = rSh.DoesUndo();
1033*cdf0e10cSrcweir 	if( bUndo )
1034*cdf0e10cSrcweir         rSh.StartUndo( UNDO_EMPTY );
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir 	sal_Bool bAsTable = aRbAsTable.IsChecked();
1037*cdf0e10cSrcweir 	SvNumberFormatter& rNumFmtr = *rSh.GetNumberFormatter();
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir 	if( rSh.HasSelection() )
1040*cdf0e10cSrcweir 		rSh.DelRight();
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir 	::std::auto_ptr<SwWait> pWait;
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 	Reference< XColumnsSupplier > xColsSupp( xResultSet, UNO_QUERY );
1045*cdf0e10cSrcweir 	Reference <XNameAccess> xCols = xColsSupp->getColumns();
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir 	do{                                 // middle checked loop!!
1048*cdf0e10cSrcweir 	if( bAsTable )			// Daten als Tabelle einfuegen
1049*cdf0e10cSrcweir 	{
1050*cdf0e10cSrcweir 		rSh.DoUndo( sal_False );
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir 		sal_uInt16 n, nRows = 0, nCols = aLbTableCol.GetEntryCount();
1053*cdf0e10cSrcweir 		if( aCbTableHeadon.IsChecked() )
1054*cdf0e10cSrcweir 			nRows++;
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir 		if( pSelection )
1057*cdf0e10cSrcweir             nRows = nRows + (sal_uInt16)rSelection.getLength();
1058*cdf0e10cSrcweir 		else
1059*cdf0e10cSrcweir 			++nRows;
1060*cdf0e10cSrcweir 
1061*cdf0e10cSrcweir 		// bereite das Array fuer die ausgewaehlten Spalten auf
1062*cdf0e10cSrcweir 		SwInsDBColumns_SAR aColFlds( 255 >= nCols ? (sal_uInt8)nCols : 255, 5 );
1063*cdf0e10cSrcweir 		for( n = 0; n < nCols; ++n )
1064*cdf0e10cSrcweir 		{
1065*cdf0e10cSrcweir 			sal_uInt16 nFndPos;
1066*cdf0e10cSrcweir 			SwInsDBColumn aSrch( aLbTableCol.GetEntry( n ), 0 );
1067*cdf0e10cSrcweir 			if( aDBColumns.Seek_Entry( &aSrch, &nFndPos ) )
1068*cdf0e10cSrcweir 				aColFlds.Insert( aDBColumns[ nFndPos ], n );
1069*cdf0e10cSrcweir 			else {
1070*cdf0e10cSrcweir 				ASSERT( !this, "Datenbankspalte nicht mehr gefunden" );
1071*cdf0e10cSrcweir             }
1072*cdf0e10cSrcweir 		}
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir 		if( nCols != aColFlds.Count() )
1075*cdf0e10cSrcweir 		{
1076*cdf0e10cSrcweir 			ASSERT( !this, "nicht alle Datenbankspalten gefunden" );
1077*cdf0e10cSrcweir 			nCols = aColFlds.Count();
1078*cdf0e10cSrcweir 		}
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir 		if(!nRows || !nCols)
1081*cdf0e10cSrcweir 		{
1082*cdf0e10cSrcweir 			ASSERT( !this, "wrong parameters" );
1083*cdf0e10cSrcweir 			break;
1084*cdf0e10cSrcweir 		}
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir 		const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir 		sal_Bool bHTML = 0 != (::GetHtmlMode( pView->GetDocShell() ) & HTMLMODE_ON);
1089*cdf0e10cSrcweir         rSh.InsertTable(
1090*cdf0e10cSrcweir             pModOpt->GetInsTblFlags(bHTML),
1091*cdf0e10cSrcweir             nRows, nCols, text::HoriOrientation::FULL, (pSelection ? pTAutoFmt : 0) );
1092*cdf0e10cSrcweir         rSh.MoveTable( GetfnTablePrev(), GetfnTableStart() );
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir 		if( pSelection && pTblSet )
1095*cdf0e10cSrcweir 			SetTabSet();
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir 		SfxItemSet aTblSet( rSh.GetAttrPool(), RES_BOXATR_FORMAT,
1098*cdf0e10cSrcweir 												RES_BOXATR_VALUE );
1099*cdf0e10cSrcweir 		sal_Bool bIsAutoUpdateCells = rSh.IsAutoUpdateCells();
1100*cdf0e10cSrcweir 		rSh.SetAutoUpdateCells( sal_False );
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir 		if( aCbTableHeadon.IsChecked() )
1104*cdf0e10cSrcweir 		{
1105*cdf0e10cSrcweir 			for( n = 0; n < nCols; ++n )
1106*cdf0e10cSrcweir 			{
1107*cdf0e10cSrcweir 				if( aRbHeadlColnms.IsChecked() )
1108*cdf0e10cSrcweir                 {
1109*cdf0e10cSrcweir                     rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn );
1110*cdf0e10cSrcweir                 }
1111*cdf0e10cSrcweir 				rSh.GoNextCell();
1112*cdf0e10cSrcweir 			}
1113*cdf0e10cSrcweir 		}
1114*cdf0e10cSrcweir 		else
1115*cdf0e10cSrcweir             rSh.SetRowsToRepeat( 0 );
1116*cdf0e10cSrcweir 
1117*cdf0e10cSrcweir 		for( sal_Int32 i = 0 ; ; ++i )
1118*cdf0e10cSrcweir 		{
1119*cdf0e10cSrcweir 			sal_Bool bBreak = sal_False;
1120*cdf0e10cSrcweir 			try
1121*cdf0e10cSrcweir 			{
1122*cdf0e10cSrcweir 				if(pSelection)
1123*cdf0e10cSrcweir                 {
1124*cdf0e10cSrcweir                     sal_Int32 nPos = 0;
1125*cdf0e10cSrcweir                     pSelection[i] >>= nPos;
1126*cdf0e10cSrcweir                     bBreak = !xResultSet->absolute(nPos);
1127*cdf0e10cSrcweir                 }
1128*cdf0e10cSrcweir 				else if(!i)
1129*cdf0e10cSrcweir 					bBreak = !xResultSet->first();
1130*cdf0e10cSrcweir 			}
1131*cdf0e10cSrcweir             catch(const Exception& )
1132*cdf0e10cSrcweir 			{
1133*cdf0e10cSrcweir 				bBreak = sal_True;
1134*cdf0e10cSrcweir 			}
1135*cdf0e10cSrcweir 			if(bBreak)
1136*cdf0e10cSrcweir 				break;
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir 			for( n = 0; n < nCols; ++n )
1139*cdf0e10cSrcweir 			{
1140*cdf0e10cSrcweir 				// beim aller erstenmal KEIN GoNextCell, weil wir schon
1141*cdf0e10cSrcweir 				// drin stehen. Auch nicht nach dem Insert das GoNextCell,
1142*cdf0e10cSrcweir 				// weil am Ende eine leere Zeile einfuegt wird.
1143*cdf0e10cSrcweir 				if( i || n )
1144*cdf0e10cSrcweir 					rSh.GoNextCell();
1145*cdf0e10cSrcweir 
1146*cdf0e10cSrcweir 				const SwInsDBColumn* pEntry = aColFlds[ n ];
1147*cdf0e10cSrcweir 
1148*cdf0e10cSrcweir 				Reference< XColumn > xColumn;
1149*cdf0e10cSrcweir 				xCols->getByName(pEntry->sColumn) >>= xColumn;
1150*cdf0e10cSrcweir                 Reference< XPropertySet > xColumnProps( xColumn, UNO_QUERY );
1151*cdf0e10cSrcweir                 sal_Int32 eDataType = 0;
1152*cdf0e10cSrcweir                 if( xColumnProps.is() )
1153*cdf0e10cSrcweir                 {
1154*cdf0e10cSrcweir                     Any aType = xColumnProps->getPropertyValue(C2U("Type"));
1155*cdf0e10cSrcweir     	            aType >>= eDataType;
1156*cdf0e10cSrcweir                 }
1157*cdf0e10cSrcweir 				try
1158*cdf0e10cSrcweir 				{
1159*cdf0e10cSrcweir 					if( pEntry->bHasFmt )
1160*cdf0e10cSrcweir 					{
1161*cdf0e10cSrcweir 						SwTblBoxNumFormat aNumFmt(
1162*cdf0e10cSrcweir 										pEntry->bIsDBFmt ? pEntry->nDBNumFmt
1163*cdf0e10cSrcweir 													 	: pEntry->nUsrNumFmt );
1164*cdf0e10cSrcweir 						aTblSet.Put(aNumFmt);
1165*cdf0e10cSrcweir 						if( xColumn.is() )
1166*cdf0e10cSrcweir 						{
1167*cdf0e10cSrcweir 							double fVal = xColumn->getDouble();
1168*cdf0e10cSrcweir 							if(	xColumn->wasNull() )
1169*cdf0e10cSrcweir 								aTblSet.ClearItem( RES_BOXATR_VALUE );
1170*cdf0e10cSrcweir 							else
1171*cdf0e10cSrcweir 							{
1172*cdf0e10cSrcweir 								if(rNumFmtr.GetType(aNumFmt.GetValue()) & NUMBERFORMAT_DATE)
1173*cdf0e10cSrcweir 								{
1174*cdf0e10cSrcweir 									::Date aStandard(1,1,1900);
1175*cdf0e10cSrcweir 									if (*rNumFmtr.GetNullDate() != aStandard)
1176*cdf0e10cSrcweir 										fVal += (aStandard - *rNumFmtr.GetNullDate());
1177*cdf0e10cSrcweir 								}
1178*cdf0e10cSrcweir 								aTblSet.Put( SwTblBoxValue( fVal ));
1179*cdf0e10cSrcweir 							}
1180*cdf0e10cSrcweir 						}
1181*cdf0e10cSrcweir 						else
1182*cdf0e10cSrcweir 							aTblSet.ClearItem( RES_BOXATR_VALUE );
1183*cdf0e10cSrcweir 						rSh.SetTblBoxFormulaAttrs( aTblSet );
1184*cdf0e10cSrcweir 					}
1185*cdf0e10cSrcweir                     //#i60207# don't insert binary data as string - creates a loop
1186*cdf0e10cSrcweir                     else if( DataType::BINARY       == eDataType ||
1187*cdf0e10cSrcweir                              DataType::VARBINARY    == eDataType ||
1188*cdf0e10cSrcweir                              DataType::LONGVARBINARY== eDataType ||
1189*cdf0e10cSrcweir                              DataType::SQLNULL      == eDataType ||
1190*cdf0e10cSrcweir                              DataType::OTHER        == eDataType ||
1191*cdf0e10cSrcweir                              DataType::OBJECT       == eDataType ||
1192*cdf0e10cSrcweir                              DataType::DISTINCT     == eDataType ||
1193*cdf0e10cSrcweir                              DataType::STRUCT       == eDataType ||
1194*cdf0e10cSrcweir                              DataType::ARRAY        == eDataType ||
1195*cdf0e10cSrcweir                              DataType::BLOB         == eDataType ||
1196*cdf0e10cSrcweir                              DataType::CLOB         == eDataType ||
1197*cdf0e10cSrcweir                              DataType::REF          == eDataType
1198*cdf0e10cSrcweir                              )
1199*cdf0e10cSrcweir                     {
1200*cdf0e10cSrcweir                         // do nothing
1201*cdf0e10cSrcweir                     }
1202*cdf0e10cSrcweir                     else
1203*cdf0e10cSrcweir 					{
1204*cdf0e10cSrcweir                         rtl::OUString sVal =  xColumn->getString();
1205*cdf0e10cSrcweir 						if(!xColumn->wasNull())
1206*cdf0e10cSrcweir                         {
1207*cdf0e10cSrcweir                             rSh.SwEditShell::Insert2( sVal );
1208*cdf0e10cSrcweir                         }
1209*cdf0e10cSrcweir 					}
1210*cdf0e10cSrcweir 				}
1211*cdf0e10cSrcweir                 catch(Exception&
1212*cdf0e10cSrcweir #ifdef DBG_UTIL
1213*cdf0e10cSrcweir                             aExcept
1214*cdf0e10cSrcweir #endif
1215*cdf0e10cSrcweir                 )
1216*cdf0e10cSrcweir 				{
1217*cdf0e10cSrcweir 					DBG_ERROR(ByteString(String(aExcept.Message), gsl_getSystemTextEncoding()).GetBuffer());
1218*cdf0e10cSrcweir 				}
1219*cdf0e10cSrcweir 			}
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir 			if( !pSelection )
1222*cdf0e10cSrcweir 			{
1223*cdf0e10cSrcweir 				if ( !xResultSet->next() )
1224*cdf0e10cSrcweir 					break;
1225*cdf0e10cSrcweir 			}
1226*cdf0e10cSrcweir 			else if( i+1 >= rSelection.getLength() )
1227*cdf0e10cSrcweir 				break;
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 			if( 10 == i )
1230*cdf0e10cSrcweir 				pWait = ::std::auto_ptr<SwWait>(new SwWait( *pView->GetDocShell(), sal_True ));
1231*cdf0e10cSrcweir 		}
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir         rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1234*cdf0e10cSrcweir 		if( !pSelection && ( pTblSet || pTAutoFmt ))
1235*cdf0e10cSrcweir 		{
1236*cdf0e10cSrcweir 			if( pTblSet )
1237*cdf0e10cSrcweir 				SetTabSet();
1238*cdf0e10cSrcweir 
1239*cdf0e10cSrcweir 			if( pTAutoFmt )
1240*cdf0e10cSrcweir 				rSh.SetTableAutoFmt( *pTAutoFmt );
1241*cdf0e10cSrcweir 		}
1242*cdf0e10cSrcweir 		rSh.SetAutoUpdateCells( bIsAutoUpdateCells );
1243*cdf0e10cSrcweir 	}
1244*cdf0e10cSrcweir 	else 							// Daten als Felder/Text einfuegen
1245*cdf0e10cSrcweir 	{
1246*cdf0e10cSrcweir 		_DB_Columns aColArr;
1247*cdf0e10cSrcweir 		if( SplitTextToColArr( aEdDbText.GetText(), aColArr, aRbAsField.IsChecked() ) )
1248*cdf0e10cSrcweir 		{
1249*cdf0e10cSrcweir 			// jetzt kann bei jedem Datensatz einfach ueber das Array iteriert
1250*cdf0e10cSrcweir 			// und die Daten eingefuegt werden
1251*cdf0e10cSrcweir 
1252*cdf0e10cSrcweir 			if( !rSh.IsSttPara() )
1253*cdf0e10cSrcweir 				rSh.SwEditShell::SplitNode();
1254*cdf0e10cSrcweir 			if( !rSh.IsEndPara() )
1255*cdf0e10cSrcweir 			{
1256*cdf0e10cSrcweir 				rSh.SwEditShell::SplitNode();
1257*cdf0e10cSrcweir 				rSh.SwCrsrShell::Left(1,CRSR_SKIP_CHARS);
1258*cdf0e10cSrcweir 			}
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir 			rSh.DoUndo( sal_False );
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir 			SwTxtFmtColl* pColl = 0;
1263*cdf0e10cSrcweir 			{
1264*cdf0e10cSrcweir 				String sTmplNm( aLbDbParaColl.GetSelectEntry() );
1265*cdf0e10cSrcweir 				if( sNoTmpl != sTmplNm )
1266*cdf0e10cSrcweir 				{
1267*cdf0e10cSrcweir 					pColl = rSh.FindTxtFmtCollByName( sTmplNm );
1268*cdf0e10cSrcweir 					if( !pColl )
1269*cdf0e10cSrcweir 					{
1270*cdf0e10cSrcweir 						sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmplNm, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
1271*cdf0e10cSrcweir 						if( USHRT_MAX != nId )
1272*cdf0e10cSrcweir 							pColl = rSh.GetTxtCollFromPool( nId );
1273*cdf0e10cSrcweir 						else
1274*cdf0e10cSrcweir 							pColl = rSh.MakeTxtFmtColl( sTmplNm );
1275*cdf0e10cSrcweir 					}
1276*cdf0e10cSrcweir 					rSh.SetTxtFmtColl( pColl );
1277*cdf0e10cSrcweir 				}
1278*cdf0e10cSrcweir 			}
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir 			// fuers Einfuegen als Felder -> nach jedem Datensatz ein
1281*cdf0e10cSrcweir 			// "NextField" einfuegen
1282*cdf0e10cSrcweir 			SwDBFormatData aDBFormatData;
1283*cdf0e10cSrcweir 			Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
1284*cdf0e10cSrcweir 			if( xMgr.is() )
1285*cdf0e10cSrcweir 			{
1286*cdf0e10cSrcweir 				Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
1287*cdf0e10cSrcweir 				aDBFormatData.xFormatter = Reference<util::XNumberFormatter>(xInstance, UNO_QUERY) ;
1288*cdf0e10cSrcweir 			}
1289*cdf0e10cSrcweir 
1290*cdf0e10cSrcweir 			Reference<XPropertySet> xSourceProps(xSource, UNO_QUERY);
1291*cdf0e10cSrcweir 			if(xSourceProps.is())
1292*cdf0e10cSrcweir 			{
1293*cdf0e10cSrcweir               Any aFormats = xSourceProps->getPropertyValue(C2U("NumberFormatsSupplier"));
1294*cdf0e10cSrcweir               if(aFormats.hasValue())
1295*cdf0e10cSrcweir               {
1296*cdf0e10cSrcweir                   Reference< util::XNumberFormatsSupplier> xSuppl;
1297*cdf0e10cSrcweir                   aFormats >>= xSuppl;
1298*cdf0e10cSrcweir                   if(xSuppl.is())
1299*cdf0e10cSrcweir                   {
1300*cdf0e10cSrcweir                         Reference< XPropertySet > xSettings = xSuppl->getNumberFormatSettings();
1301*cdf0e10cSrcweir                         Any aNull = xSettings->getPropertyValue(C2U("NullDate"));
1302*cdf0e10cSrcweir                         aNull >>= aDBFormatData.aNullDate;
1303*cdf0e10cSrcweir                         if(aDBFormatData.xFormatter.is())
1304*cdf0e10cSrcweir                             aDBFormatData.xFormatter->attachNumberFormatsSupplier(xSuppl);
1305*cdf0e10cSrcweir                   }
1306*cdf0e10cSrcweir               }
1307*cdf0e10cSrcweir 			}
1308*cdf0e10cSrcweir 			aDBFormatData.aLocale = SvxCreateLocale( rSh.GetCurLang() );
1309*cdf0e10cSrcweir 			SwDBNextSetField aNxtDBFld( (SwDBNextSetFieldType*)rSh.
1310*cdf0e10cSrcweir 										GetFldType( 0, RES_DBNEXTSETFLD ),
1311*cdf0e10cSrcweir 										C2S("1"), aEmptyStr, aDBData );
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir 			sal_Bool bSetCrsr = sal_True;
1315*cdf0e10cSrcweir             sal_uInt16 n = 0, nCols = aColArr.Count();
1316*cdf0e10cSrcweir             ::sw::mark::IMark* pMark = NULL;
1317*cdf0e10cSrcweir 			for( sal_Int32 i = 0 ; ; ++i )
1318*cdf0e10cSrcweir 			{
1319*cdf0e10cSrcweir 				sal_Bool bBreak = sal_False;
1320*cdf0e10cSrcweir 				try
1321*cdf0e10cSrcweir 				{
1322*cdf0e10cSrcweir 					if(pSelection)
1323*cdf0e10cSrcweir                     {
1324*cdf0e10cSrcweir                         sal_Int32 nPos = 0;
1325*cdf0e10cSrcweir                         pSelection[i] >>= nPos;
1326*cdf0e10cSrcweir                         bBreak = !xResultSet->absolute(nPos);
1327*cdf0e10cSrcweir                     }
1328*cdf0e10cSrcweir 					else if(!i)
1329*cdf0e10cSrcweir 						bBreak = !xResultSet->first();
1330*cdf0e10cSrcweir 				}
1331*cdf0e10cSrcweir                 catch(Exception&)
1332*cdf0e10cSrcweir                 {
1333*cdf0e10cSrcweir 					bBreak = sal_True;
1334*cdf0e10cSrcweir 				}
1335*cdf0e10cSrcweir 
1336*cdf0e10cSrcweir 				if(bBreak)
1337*cdf0e10cSrcweir 					break;
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir 				for( n = 0; n < nCols; ++n )
1341*cdf0e10cSrcweir 				{
1342*cdf0e10cSrcweir 					_DB_Column* pDBCol = aColArr[ n ];
1343*cdf0e10cSrcweir 					String sIns;
1344*cdf0e10cSrcweir 					switch( pDBCol->eColType )
1345*cdf0e10cSrcweir 					{
1346*cdf0e10cSrcweir 					case _DB_Column::DB_FILLTEXT:
1347*cdf0e10cSrcweir 						sIns =  *pDBCol->DB_ColumnData.pText;
1348*cdf0e10cSrcweir 						break;
1349*cdf0e10cSrcweir 
1350*cdf0e10cSrcweir 					case _DB_Column::DB_SPLITPARA:
1351*cdf0e10cSrcweir 						rSh.SplitNode();
1352*cdf0e10cSrcweir 						// wenn nicht die gleiche Vorlage die Follow Vorlage
1353*cdf0e10cSrcweir 						// ist, dann muss die ausgewaehlte neu gesetzt werden
1354*cdf0e10cSrcweir 						if( pColl && &pColl->GetNextTxtFmtColl() != pColl )
1355*cdf0e10cSrcweir 							rSh.SetTxtFmtColl( pColl );
1356*cdf0e10cSrcweir 						break;
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir 					case _DB_Column::DB_COL_FIELD:
1359*cdf0e10cSrcweir 						{
1360*cdf0e10cSrcweir                             SwDBField *const pFld = static_cast<SwDBField *>(
1361*cdf0e10cSrcweir                                 pDBCol->DB_ColumnData.pField->CopyField());
1362*cdf0e10cSrcweir 							double nValue = DBL_MAX;
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir 							Reference< XPropertySet > xColumnProps;
1365*cdf0e10cSrcweir 							xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir 							pFld->SetExpansion( SwNewDBMgr::GetDBField(
1368*cdf0e10cSrcweir 												xColumnProps,
1369*cdf0e10cSrcweir 												aDBFormatData,
1370*cdf0e10cSrcweir 												&nValue ) );
1371*cdf0e10cSrcweir 							if( DBL_MAX != nValue )
1372*cdf0e10cSrcweir                             {
1373*cdf0e10cSrcweir 	                            Any aType = xColumnProps->getPropertyValue(C2U("Type"));
1374*cdf0e10cSrcweir 	                            sal_Int32 eDataType = 0;
1375*cdf0e10cSrcweir 	                            aType >>= eDataType;
1376*cdf0e10cSrcweir 		                        if(	DataType::DATE == eDataType  || DataType::TIME == eDataType  ||
1377*cdf0e10cSrcweir                                     DataType::TIMESTAMP  == eDataType)
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir 		                        {
1380*cdf0e10cSrcweir                                     ::Date aStandard(1,1,1900);
1381*cdf0e10cSrcweir                                     ::Date aCompare(aDBFormatData.aNullDate.Day ,
1382*cdf0e10cSrcweir                                                     aDBFormatData.aNullDate.Month,
1383*cdf0e10cSrcweir                                                     aDBFormatData.aNullDate.Year);
1384*cdf0e10cSrcweir                                     if(aStandard != aCompare)
1385*cdf0e10cSrcweir                                         nValue += (aStandard - aCompare);
1386*cdf0e10cSrcweir 	    	                    }
1387*cdf0e10cSrcweir                                 pFld->ChgValue( nValue, sal_True );
1388*cdf0e10cSrcweir                             }
1389*cdf0e10cSrcweir 							pFld->SetInitialized();
1390*cdf0e10cSrcweir 
1391*cdf0e10cSrcweir 							rSh.Insert( *pFld );
1392*cdf0e10cSrcweir 							delete pFld;
1393*cdf0e10cSrcweir 						}
1394*cdf0e10cSrcweir 						break;
1395*cdf0e10cSrcweir 
1396*cdf0e10cSrcweir 					case _DB_Column::DB_COL_TEXT:
1397*cdf0e10cSrcweir 						{
1398*cdf0e10cSrcweir 							double nValue = DBL_MAX;
1399*cdf0e10cSrcweir 							Reference< XPropertySet > xColumnProps;
1400*cdf0e10cSrcweir 							xCols->getByName(pDBCol->pColInfo->sColumn) >>= xColumnProps;
1401*cdf0e10cSrcweir 							sIns = SwNewDBMgr::GetDBField(
1402*cdf0e10cSrcweir 												xColumnProps,
1403*cdf0e10cSrcweir 												aDBFormatData,
1404*cdf0e10cSrcweir 												&nValue );
1405*cdf0e10cSrcweir 							if( pDBCol->DB_ColumnData.nFormat &&
1406*cdf0e10cSrcweir 								DBL_MAX != nValue )
1407*cdf0e10cSrcweir 							{
1408*cdf0e10cSrcweir 								Color* pCol;
1409*cdf0e10cSrcweir                                 if(rNumFmtr.GetType(pDBCol->DB_ColumnData.nFormat) & NUMBERFORMAT_DATE)
1410*cdf0e10cSrcweir                                 {
1411*cdf0e10cSrcweir                                     ::Date aStandard(1,1,1900);
1412*cdf0e10cSrcweir                                     if (*rNumFmtr.GetNullDate() != aStandard)
1413*cdf0e10cSrcweir                                         nValue += (aStandard - *rNumFmtr.GetNullDate());
1414*cdf0e10cSrcweir                                 }
1415*cdf0e10cSrcweir                                 rNumFmtr.GetOutputString( nValue,
1416*cdf0e10cSrcweir 											pDBCol->DB_ColumnData.nFormat,
1417*cdf0e10cSrcweir 											sIns, &pCol );
1418*cdf0e10cSrcweir 							}
1419*cdf0e10cSrcweir 						}
1420*cdf0e10cSrcweir 						break;
1421*cdf0e10cSrcweir 					}
1422*cdf0e10cSrcweir 
1423*cdf0e10cSrcweir 					if( sIns.Len() )
1424*cdf0e10cSrcweir 						rSh.Insert( sIns );
1425*cdf0e10cSrcweir 
1426*cdf0e10cSrcweir 					if( bSetCrsr && sIns.Len() )
1427*cdf0e10cSrcweir 					{
1428*cdf0e10cSrcweir 						// zum Anfang und eine Mark setzen, damit der
1429*cdf0e10cSrcweir 						// Cursor am Ende wieder auf Anfangsposition
1430*cdf0e10cSrcweir 						// gesetzt werden kann.
1431*cdf0e10cSrcweir 
1432*cdf0e10cSrcweir 						// rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
1433*cdf0e10cSrcweir 						rSh.SwCrsrShell::MovePara(
1434*cdf0e10cSrcweir 							GetfnParaCurr(), GetfnParaStart() );
1435*cdf0e10cSrcweir 						pMark = rSh.SetBookmark(
1436*cdf0e10cSrcweir                             KeyCode(),
1437*cdf0e10cSrcweir                             ::rtl::OUString(),
1438*cdf0e10cSrcweir                             ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
1439*cdf0e10cSrcweir 						// rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
1440*cdf0e10cSrcweir 						rSh.SwCrsrShell::MovePara(
1441*cdf0e10cSrcweir 							GetfnParaCurr(), GetfnParaEnd() );
1442*cdf0e10cSrcweir 						bSetCrsr = sal_False;
1443*cdf0e10cSrcweir 					}
1444*cdf0e10cSrcweir 				}
1445*cdf0e10cSrcweir 
1446*cdf0e10cSrcweir 				if( !pSelection )
1447*cdf0e10cSrcweir 				{
1448*cdf0e10cSrcweir 					sal_Bool bNext = xResultSet->next();
1449*cdf0e10cSrcweir 					if(!bNext)
1450*cdf0e10cSrcweir 						break;
1451*cdf0e10cSrcweir 				}
1452*cdf0e10cSrcweir 				else if( i+1 >= rSelection.getLength() )
1453*cdf0e10cSrcweir 					break;
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir 				if( aRbAsField.IsChecked() )
1456*cdf0e10cSrcweir 					rSh.Insert( aNxtDBFld );
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir 				if( !rSh.IsSttPara() )
1459*cdf0e10cSrcweir 					rSh.SwEditShell::SplitNode();
1460*cdf0e10cSrcweir 
1461*cdf0e10cSrcweir 				if( 10 == i )
1462*cdf0e10cSrcweir 					pWait = ::std::auto_ptr<SwWait>(new SwWait( *pView->GetDocShell(), sal_True ));
1463*cdf0e10cSrcweir 			}
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir 			if( !bSetCrsr && pMark != NULL)
1466*cdf0e10cSrcweir 			{
1467*cdf0e10cSrcweir                 rSh.SetMark();
1468*cdf0e10cSrcweir                 rSh.GotoMark( pMark );
1469*cdf0e10cSrcweir                 rSh.getIDocumentMarkAccess()->deleteMark( pMark );
1470*cdf0e10cSrcweir                 break;
1471*cdf0e10cSrcweir 			}
1472*cdf0e10cSrcweir 		}
1473*cdf0e10cSrcweir 	}
1474*cdf0e10cSrcweir 	// write configuration
1475*cdf0e10cSrcweir 	Commit();
1476*cdf0e10cSrcweir 	}while( sal_False );                    // middle checked loop
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir 	if( bUndo )
1479*cdf0e10cSrcweir 	{
1480*cdf0e10cSrcweir 		rSh.DoUndo( sal_True );
1481*cdf0e10cSrcweir 		rSh.AppendUndoForInsertFromDB( bAsTable );
1482*cdf0e10cSrcweir         rSh.EndUndo( UNDO_EMPTY );
1483*cdf0e10cSrcweir 	}
1484*cdf0e10cSrcweir 	rSh.ClearMark();
1485*cdf0e10cSrcweir 	rSh.EndAllAction();
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir     if ( bDisposeResultSet )
1488*cdf0e10cSrcweir 		::comphelper::disposeComponent(xResultSet);
1489*cdf0e10cSrcweir }
1490*cdf0e10cSrcweir void SwInsertDBColAutoPilot::SetTabSet()
1491*cdf0e10cSrcweir {
1492*cdf0e10cSrcweir 	SwWrtShell& rSh = pView->GetWrtShell();
1493*cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir 	if( pTAutoFmt )
1496*cdf0e10cSrcweir 	{
1497*cdf0e10cSrcweir 		if( pTAutoFmt->IsFrame() )
1498*cdf0e10cSrcweir 		{
1499*cdf0e10cSrcweir 			// Umrandung kommt vom AutoFormat
1500*cdf0e10cSrcweir 			pTblSet->ClearItem( RES_BOX );
1501*cdf0e10cSrcweir 			pTblSet->ClearItem( SID_ATTR_BORDER_INNER );
1502*cdf0e10cSrcweir 		}
1503*cdf0e10cSrcweir 		if( pTAutoFmt->IsBackground() )
1504*cdf0e10cSrcweir 		{
1505*cdf0e10cSrcweir 			pTblSet->ClearItem( RES_BACKGROUND );
1506*cdf0e10cSrcweir 			pTblSet->ClearItem( SID_ATTR_BRUSH_ROW );
1507*cdf0e10cSrcweir 			pTblSet->ClearItem( SID_ATTR_BRUSH_TABLE );
1508*cdf0e10cSrcweir 		}
1509*cdf0e10cSrcweir 	}
1510*cdf0e10cSrcweir 	else
1511*cdf0e10cSrcweir 	{
1512*cdf0e10cSrcweir 		// die Defaults wieder entfernen, es macht keinen Sinn sie zu setzen
1513*cdf0e10cSrcweir 		SvxBrushItem aBrush( RES_BACKGROUND );
1514*cdf0e10cSrcweir 		static sal_uInt16 __READONLY_DATA aIds[3] =
1515*cdf0e10cSrcweir 			{ RES_BACKGROUND, SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE };
1516*cdf0e10cSrcweir 		for( int i = 0; i < 3; ++i )
1517*cdf0e10cSrcweir 			if( SFX_ITEM_SET == pTblSet->GetItemState( aIds[ i ],
1518*cdf0e10cSrcweir 				sal_False, &pItem ) && *pItem == aBrush )
1519*cdf0e10cSrcweir 				pTblSet->ClearItem( aIds[ i ] );
1520*cdf0e10cSrcweir 	}
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir 	if( SFX_ITEM_SET == pTblSet->GetItemState( FN_PARAM_TABLE_NAME, sal_False,
1523*cdf0e10cSrcweir 		&pItem ) && ((const SfxStringItem*)pItem)->GetValue() ==
1524*cdf0e10cSrcweir 					rSh.GetTableFmt()->GetName() )
1525*cdf0e10cSrcweir 		pTblSet->ClearItem( FN_PARAM_TABLE_NAME );
1526*cdf0e10cSrcweir 
1527*cdf0e10cSrcweir     rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1528*cdf0e10cSrcweir 	rSh.SetMark();
1529*cdf0e10cSrcweir     rSh.MoveTable( GetfnTableCurr(), GetfnTableEnd() );
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir 	ItemSetToTableParam( *pTblSet, rSh );
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir 	rSh.ClearMark();
1534*cdf0e10cSrcweir     rSh.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1535*cdf0e10cSrcweir }
1536*cdf0e10cSrcweir 
1537*cdf0e10cSrcweir /*  */
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir _DB_ColumnConfigData::~_DB_ColumnConfigData() {}
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir /* -----------------------------05.12.00 16:15--------------------------------
1543*cdf0e10cSrcweir 
1544*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1545*cdf0e10cSrcweir static Sequence<rtl::OUString> lcl_createSourceNames(const String& rNodeName)
1546*cdf0e10cSrcweir {
1547*cdf0e10cSrcweir     Sequence<rtl::OUString> aSourceNames(11);
1548*cdf0e10cSrcweir     rtl::OUString* pNames = aSourceNames.getArray();
1549*cdf0e10cSrcweir 
1550*cdf0e10cSrcweir 	String sTmp( rNodeName );
1551*cdf0e10cSrcweir 	const xub_StrLen nPos = sTmp.Len();
1552*cdf0e10cSrcweir 	pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1553*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/DataSource" ));
1554*cdf0e10cSrcweir 	pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1555*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/Command" ));
1556*cdf0e10cSrcweir 	pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1557*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/CommandType" ));
1558*cdf0e10cSrcweir 	pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1559*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/ColumnsToText" ));
1560*cdf0e10cSrcweir 	pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1561*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/ColumnsToTable" ));
1562*cdf0e10cSrcweir 	pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1563*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/ParaStyle" ));
1564*cdf0e10cSrcweir 	pNames[6] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1565*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/TableAutoFormat" ));
1566*cdf0e10cSrcweir 	pNames[7] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1567*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsTable" ));
1568*cdf0e10cSrcweir 	pNames[8] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1569*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsField" ));
1570*cdf0e10cSrcweir 	pNames[9] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1571*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsHeadlineOn" ));
1572*cdf0e10cSrcweir 	pNames[10] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1573*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsEmptyHeadline" ));
1574*cdf0e10cSrcweir 	return aSourceNames;
1575*cdf0e10cSrcweir }
1576*cdf0e10cSrcweir /* -----------------------------05.12.00 16:25--------------------------------
1577*cdf0e10cSrcweir 
1578*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1579*cdf0e10cSrcweir static Sequence<rtl::OUString> lcl_CreateSubNames( const String& rSubNodeName )
1580*cdf0e10cSrcweir {
1581*cdf0e10cSrcweir     Sequence<rtl::OUString> aSubSourceNames(6);
1582*cdf0e10cSrcweir     rtl::OUString* pNames = aSubSourceNames.getArray();
1583*cdf0e10cSrcweir 	String sTmp( rSubNodeName );
1584*cdf0e10cSrcweir 	const xub_StrLen nPos = sTmp.Len();
1585*cdf0e10cSrcweir 	pNames[0] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1586*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/ColumnName" ));
1587*cdf0e10cSrcweir 	pNames[1] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1588*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/ColumnIndex" ));
1589*cdf0e10cSrcweir 	pNames[2] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1590*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormat" ));
1591*cdf0e10cSrcweir 	pNames[3] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1592*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormatFromDataBase" ));
1593*cdf0e10cSrcweir 	pNames[4] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1594*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/NumberFormat" ));
1595*cdf0e10cSrcweir 	pNames[5] = sTmp.ReplaceAscii( nPos, STRING_MAXLEN,
1596*cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "/NumberFormatLocale" ));
1597*cdf0e10cSrcweir 	return aSubSourceNames;
1598*cdf0e10cSrcweir }
1599*cdf0e10cSrcweir /* -----------------------------06.12.00 13:03--------------------------------
1600*cdf0e10cSrcweir 
1601*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1602*cdf0e10cSrcweir static rtl::OUString lcl_CreateUniqueName(const Sequence<rtl::OUString>& aNames)
1603*cdf0e10cSrcweir {
1604*cdf0e10cSrcweir 	sal_Int32 nIdx = aNames.getLength();
1605*cdf0e10cSrcweir     const rtl::OUString* pNames = aNames.getConstArray();
1606*cdf0e10cSrcweir     rtl::OUString sTest(C2U("_"));
1607*cdf0e10cSrcweir     rtl::OUString sRet;
1608*cdf0e10cSrcweir 	while(sal_True)
1609*cdf0e10cSrcweir 	{
1610*cdf0e10cSrcweir         sRet = sTest; sRet += rtl::OUString::valueOf(nIdx++);
1611*cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
1612*cdf0e10cSrcweir 		for(sal_Int32 i = 0; i < aNames.getLength(); i++)
1613*cdf0e10cSrcweir 		{
1614*cdf0e10cSrcweir 			if(pNames[i] == sRet)
1615*cdf0e10cSrcweir 			{
1616*cdf0e10cSrcweir 				bFound = sal_True;
1617*cdf0e10cSrcweir 				break;
1618*cdf0e10cSrcweir 			}
1619*cdf0e10cSrcweir 		}
1620*cdf0e10cSrcweir 		if(!bFound)
1621*cdf0e10cSrcweir 			break;
1622*cdf0e10cSrcweir 	}
1623*cdf0e10cSrcweir 	return sRet;
1624*cdf0e10cSrcweir }
1625*cdf0e10cSrcweir /* -----------------------------05.12.00 15:00--------------------------------
1626*cdf0e10cSrcweir 
1627*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1628*cdf0e10cSrcweir void SwInsertDBColAutoPilot::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >&  ) {}
1629*cdf0e10cSrcweir 
1630*cdf0e10cSrcweir void SwInsertDBColAutoPilot::Commit()
1631*cdf0e10cSrcweir {
1632*cdf0e10cSrcweir     Sequence <rtl::OUString> aNames = GetNodeNames(rtl::OUString());
1633*cdf0e10cSrcweir     const rtl::OUString* pNames = aNames.getArray();
1634*cdf0e10cSrcweir 	//remove entries that contain this data source + table at first
1635*cdf0e10cSrcweir 	for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
1636*cdf0e10cSrcweir 	{
1637*cdf0e10cSrcweir         Sequence<rtl::OUString> aSourceNames(2);
1638*cdf0e10cSrcweir         rtl::OUString* pSourceNames = aSourceNames.getArray();
1639*cdf0e10cSrcweir 		pSourceNames[0] = pNames[nNode];
1640*cdf0e10cSrcweir 		pSourceNames[0] += C2U("/DataSource");
1641*cdf0e10cSrcweir 		pSourceNames[1] = pNames[nNode];
1642*cdf0e10cSrcweir 		pSourceNames[1] += C2U("/Command");
1643*cdf0e10cSrcweir 		Sequence<Any> aSourceProperties = GetProperties(aSourceNames);
1644*cdf0e10cSrcweir 		const Any* pSourceProps = aSourceProperties.getArray();
1645*cdf0e10cSrcweir         rtl::OUString sSource, sCommand;
1646*cdf0e10cSrcweir 		pSourceProps[0] >>= sSource;
1647*cdf0e10cSrcweir 		pSourceProps[1] >>= sCommand;
1648*cdf0e10cSrcweir 		if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
1649*cdf0e10cSrcweir 		{
1650*cdf0e10cSrcweir             Sequence<rtl::OUString> aElements(1);
1651*cdf0e10cSrcweir 			aElements.getArray()[0] = pNames[nNode];
1652*cdf0e10cSrcweir             ClearNodeElements(rtl::OUString(), aElements);
1653*cdf0e10cSrcweir 		}
1654*cdf0e10cSrcweir 	}
1655*cdf0e10cSrcweir 
1656*cdf0e10cSrcweir     aNames = GetNodeNames(rtl::OUString());
1657*cdf0e10cSrcweir     rtl::OUString sNewNode = lcl_CreateUniqueName(aNames);
1658*cdf0e10cSrcweir     Sequence<rtl::OUString> aNodeNames = lcl_createSourceNames(sNewNode);
1659*cdf0e10cSrcweir 	Sequence<PropertyValue> aValues(aNodeNames.getLength());
1660*cdf0e10cSrcweir 	PropertyValue* pValues = aValues.getArray();
1661*cdf0e10cSrcweir     const rtl::OUString* pNodeNames = aNodeNames.getConstArray();
1662*cdf0e10cSrcweir     rtl::OUString sSlash(C2U("/"));
1663*cdf0e10cSrcweir 	for(sal_Int32 i = 0; i < aNodeNames.getLength(); i++)
1664*cdf0e10cSrcweir 	{
1665*cdf0e10cSrcweir 		pValues[i].Name = sSlash;
1666*cdf0e10cSrcweir 		pValues[i].Name += pNodeNames[i];
1667*cdf0e10cSrcweir 	}
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir     pValues[0].Value <<= rtl::OUString(aDBData.sDataSource);
1670*cdf0e10cSrcweir     pValues[1].Value <<= rtl::OUString(aDBData.sCommand);
1671*cdf0e10cSrcweir 	pValues[2].Value <<= aDBData.nCommandType;
1672*cdf0e10cSrcweir     pValues[3].Value <<= rtl::OUString(aEdDbText.GetText());
1673*cdf0e10cSrcweir 
1674*cdf0e10cSrcweir 	String sTmp;
1675*cdf0e10cSrcweir 	for( sal_uInt16 n = 0, nCnt = aLbTableCol.GetEntryCount(); n < nCnt; ++n )
1676*cdf0e10cSrcweir 		( sTmp += aLbTableCol.GetEntry( n ) ) += '\x0a';
1677*cdf0e10cSrcweir 
1678*cdf0e10cSrcweir 	if( sTmp.Len() )
1679*cdf0e10cSrcweir         pValues[4].Value <<= rtl::OUString(sTmp);
1680*cdf0e10cSrcweir 
1681*cdf0e10cSrcweir 	if( sNoTmpl != (sTmp = aLbDbParaColl.GetSelectEntry()) )
1682*cdf0e10cSrcweir         pValues[5].Value <<= rtl::OUString(sTmp);
1683*cdf0e10cSrcweir 
1684*cdf0e10cSrcweir 	if( pTAutoFmt )
1685*cdf0e10cSrcweir         pValues[6].Value <<= rtl::OUString(pTAutoFmt->GetName());
1686*cdf0e10cSrcweir 
1687*cdf0e10cSrcweir 	const Type& rBoolType = ::getBooleanCppuType();
1688*cdf0e10cSrcweir 	sal_Bool bTmp = aRbAsTable.IsChecked();
1689*cdf0e10cSrcweir 	pValues[7].Value.setValue(&bTmp, rBoolType);
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir 	bTmp = aRbAsField.IsChecked();
1692*cdf0e10cSrcweir 	pValues[8].Value.setValue(&bTmp, rBoolType);
1693*cdf0e10cSrcweir 
1694*cdf0e10cSrcweir 	bTmp = aCbTableHeadon.IsChecked();
1695*cdf0e10cSrcweir 	pValues[9].Value.setValue(&bTmp, rBoolType);
1696*cdf0e10cSrcweir 
1697*cdf0e10cSrcweir 	bTmp = aRbHeadlEmpty.IsChecked();
1698*cdf0e10cSrcweir 	pValues[10].Value.setValue(&bTmp, rBoolType);
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir     SetSetProperties(rtl::OUString(), aValues);
1701*cdf0e10cSrcweir 
1702*cdf0e10cSrcweir 	sNewNode += C2U("/ColumnSet");
1703*cdf0e10cSrcweir 	String sDelim( String::CreateFromAscii( "/__" ));
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir 	LanguageType ePrevLang = (LanguageType)-1;
1706*cdf0e10cSrcweir     rtl::OUString sPrevLang;
1707*cdf0e10cSrcweir 
1708*cdf0e10cSrcweir 	SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
1709*cdf0e10cSrcweir 	for(sal_uInt16 nCol = 0; nCol < aDBColumns.Count(); nCol++)
1710*cdf0e10cSrcweir 	{
1711*cdf0e10cSrcweir         rtl::OUString sColumnNode = sNewNode;
1712*cdf0e10cSrcweir  		SwInsDBColumn* pColumn = aDBColumns[nCol];
1713*cdf0e10cSrcweir 		String sColumnInsertNode(sColumnNode);
1714*cdf0e10cSrcweir 		sColumnInsertNode += sDelim;
1715*cdf0e10cSrcweir 		if( nCol < 100 )
1716*cdf0e10cSrcweir 			sColumnInsertNode += '0';
1717*cdf0e10cSrcweir 		if( nCol < 10 )
1718*cdf0e10cSrcweir 			sColumnInsertNode += '0';
1719*cdf0e10cSrcweir 		sColumnInsertNode += String::CreateFromInt32(  nCol );
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir         Sequence <rtl::OUString> aSubNodeNames = lcl_CreateSubNames(sColumnInsertNode);
1722*cdf0e10cSrcweir 		Sequence<PropertyValue> aSubValues(aSubNodeNames.getLength());
1723*cdf0e10cSrcweir 		PropertyValue* pSubValues = aSubValues.getArray();
1724*cdf0e10cSrcweir         const rtl::OUString* pSubNodeNames = aSubNodeNames.getConstArray();
1725*cdf0e10cSrcweir 		sal_Int32 i;
1726*cdf0e10cSrcweir 
1727*cdf0e10cSrcweir 		for( i = 0; i < aSubNodeNames.getLength(); i++)
1728*cdf0e10cSrcweir 			pSubValues[i].Name = pSubNodeNames[i];
1729*cdf0e10cSrcweir 		pSubValues[0].Value <<= pColumn->sColumn;
1730*cdf0e10cSrcweir 		pSubValues[1].Value <<= i;
1731*cdf0e10cSrcweir 
1732*cdf0e10cSrcweir 		sal_Bool bVal = pColumn->bHasFmt;
1733*cdf0e10cSrcweir 		pSubValues[2].Value.setValue(&bVal, rBoolType);
1734*cdf0e10cSrcweir 		bVal = pColumn->bIsDBFmt;
1735*cdf0e10cSrcweir 		pSubValues[3].Value.setValue(&bVal, rBoolType);
1736*cdf0e10cSrcweir 
1737*cdf0e10cSrcweir 		SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD, sTmp );
1738*cdf0e10cSrcweir 		const SvNumberformat* pNF = rNFmtr.GetEntry( pColumn->nUsrNumFmt );
1739*cdf0e10cSrcweir 		LanguageType eLang;
1740*cdf0e10cSrcweir 		if( pNF )
1741*cdf0e10cSrcweir 		{
1742*cdf0e10cSrcweir             pSubValues[4].Value <<= rtl::OUString(pNF->GetFormatstring());
1743*cdf0e10cSrcweir 			eLang = pNF->GetLanguage();
1744*cdf0e10cSrcweir 		}
1745*cdf0e10cSrcweir 		else
1746*cdf0e10cSrcweir 		{
1747*cdf0e10cSrcweir             pSubValues[4].Value <<= rtl::OUString(sTmp);
1748*cdf0e10cSrcweir 			eLang = (LanguageType)GetAppLanguage();
1749*cdf0e10cSrcweir 		}
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir 		if( eLang != ePrevLang )
1752*cdf0e10cSrcweir 		{
1753*cdf0e10cSrcweir 			Locale aLocale;
1754*cdf0e10cSrcweir 			aLocale = SvxLanguageToLocale( aLocale, eLang );
1755*cdf0e10cSrcweir             (( sPrevLang = aLocale.Country ) += rtl::OUString( '-' )) += aLocale.Language;
1756*cdf0e10cSrcweir 			ePrevLang = eLang;
1757*cdf0e10cSrcweir 		}
1758*cdf0e10cSrcweir 
1759*cdf0e10cSrcweir 		pSubValues[5].Value <<=  sPrevLang;
1760*cdf0e10cSrcweir 		SetSetProperties(sColumnNode, aSubValues);
1761*cdf0e10cSrcweir 	}
1762*cdf0e10cSrcweir }
1763*cdf0e10cSrcweir /* -----------------------------05.12.00 15:00--------------------------------
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
1766*cdf0e10cSrcweir void SwInsertDBColAutoPilot::Load()
1767*cdf0e10cSrcweir {
1768*cdf0e10cSrcweir     Sequence <rtl::OUString> aNames = GetNodeNames(rtl::OUString());
1769*cdf0e10cSrcweir     const rtl::OUString* pNames = aNames.getArray();
1770*cdf0e10cSrcweir 	SvNumberFormatter& rNFmtr = *pView->GetWrtShell().GetNumberFormatter();
1771*cdf0e10cSrcweir 	for(sal_Int32 nNode = 0; nNode < aNames.getLength(); nNode++)
1772*cdf0e10cSrcweir 	{
1773*cdf0e10cSrcweir 		//search for entries with the appropriate data source and table
1774*cdf0e10cSrcweir         Sequence<rtl::OUString> aSourceNames = lcl_createSourceNames(pNames[nNode]);
1775*cdf0e10cSrcweir 
1776*cdf0e10cSrcweir 		Sequence< Any> aDataSourceProps = GetProperties(aSourceNames);
1777*cdf0e10cSrcweir 		const Any* pDataSourceProps = aDataSourceProps.getConstArray();
1778*cdf0e10cSrcweir         rtl::OUString sSource, sCommand;
1779*cdf0e10cSrcweir 		sal_Int16 nCommandType;
1780*cdf0e10cSrcweir 		pDataSourceProps[0] >>= sSource;
1781*cdf0e10cSrcweir 		pDataSourceProps[1] >>= sCommand;
1782*cdf0e10cSrcweir 		pDataSourceProps[2] >>= nCommandType;
1783*cdf0e10cSrcweir 		if(sSource.equals(aDBData.sDataSource) && sCommand.equals(aDBData.sCommand))
1784*cdf0e10cSrcweir 		{
1785*cdf0e10cSrcweir 			_DB_ColumnConfigData* pNewData = new _DB_ColumnConfigData;
1786*cdf0e10cSrcweir 			pNewData->sSource = sSource;
1787*cdf0e10cSrcweir 			pNewData->sTable = sCommand;
1788*cdf0e10cSrcweir 
1789*cdf0e10cSrcweir 			pDataSourceProps[3] >>= pNewData->sEdit;
1790*cdf0e10cSrcweir 			pDataSourceProps[4] >>= pNewData->sTblList;
1791*cdf0e10cSrcweir 			pDataSourceProps[5] >>= pNewData->sTmplNm;
1792*cdf0e10cSrcweir 			pDataSourceProps[6] >>= pNewData->sTAutoFmtNm;
1793*cdf0e10cSrcweir 			if(pDataSourceProps[7].hasValue())
1794*cdf0e10cSrcweir 				pNewData->bIsTable = *(sal_Bool*)pDataSourceProps[7].getValue();
1795*cdf0e10cSrcweir 			if(pDataSourceProps[8].hasValue())
1796*cdf0e10cSrcweir 		 		pNewData->bIsField = *(sal_Bool*)pDataSourceProps[8].getValue();
1797*cdf0e10cSrcweir 			if(pDataSourceProps[9].hasValue())
1798*cdf0e10cSrcweir 		 		pNewData->bIsHeadlineOn = *(sal_Bool*)pDataSourceProps[9].getValue();
1799*cdf0e10cSrcweir 			if(pDataSourceProps[10].hasValue())
1800*cdf0e10cSrcweir 		 		pNewData->bIsEmptyHeadln = *(sal_Bool*)pDataSourceProps[10].getValue();
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir             rtl::OUString sSubNodeName(pNames[nNode]);
1803*cdf0e10cSrcweir 			sSubNodeName += C2U("/ColumnSet/");
1804*cdf0e10cSrcweir             Sequence <rtl::OUString> aSubNames = GetNodeNames(sSubNodeName);
1805*cdf0e10cSrcweir             const rtl::OUString* pSubNames = aSubNames.getConstArray();
1806*cdf0e10cSrcweir 			for(sal_Int32 nSub = 0; nSub < aSubNames.getLength(); nSub++)
1807*cdf0e10cSrcweir 			{
1808*cdf0e10cSrcweir                 rtl::OUString sSubSubNodeName(sSubNodeName);
1809*cdf0e10cSrcweir 				sSubSubNodeName += pSubNames[nSub];
1810*cdf0e10cSrcweir                 Sequence <rtl::OUString> aSubNodeNames = lcl_CreateSubNames(sSubSubNodeName);
1811*cdf0e10cSrcweir 				Sequence< Any> aSubProps = GetProperties(aSubNodeNames);
1812*cdf0e10cSrcweir 				const Any* pSubProps = aSubProps.getConstArray();
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir                 rtl::OUString sColumn;
1815*cdf0e10cSrcweir 				pSubProps[0] >>= sColumn;
1816*cdf0e10cSrcweir 				//check for existance of the loaded column name
1817*cdf0e10cSrcweir 				sal_Bool bFound = sal_False;
1818*cdf0e10cSrcweir 				for(sal_Int32 nRealColumn = 0; nRealColumn < aDBColumns.Count(); nRealColumn++)
1819*cdf0e10cSrcweir 				{
1820*cdf0e10cSrcweir                     if(aDBColumns[(sal_uInt16)nRealColumn]->sColumn == sColumn)
1821*cdf0e10cSrcweir 					{
1822*cdf0e10cSrcweir 						bFound = sal_True;
1823*cdf0e10cSrcweir 						break;
1824*cdf0e10cSrcweir 					}
1825*cdf0e10cSrcweir 				}
1826*cdf0e10cSrcweir 				if(!bFound)
1827*cdf0e10cSrcweir 					continue;
1828*cdf0e10cSrcweir 				sal_Int16 nIndex = 0;
1829*cdf0e10cSrcweir 				pSubProps[1] >>= nIndex;
1830*cdf0e10cSrcweir 				SwInsDBColumnPtr pInsDBColumn = new SwInsDBColumn(sColumn, nIndex);
1831*cdf0e10cSrcweir 				if(pSubProps[2].hasValue())
1832*cdf0e10cSrcweir 					pInsDBColumn->bHasFmt = *(sal_Bool*)pSubProps[2].getValue();
1833*cdf0e10cSrcweir 				if(pSubProps[3].hasValue())
1834*cdf0e10cSrcweir 					pInsDBColumn->bIsDBFmt = *(sal_Bool*)pSubProps[3].getValue();
1835*cdf0e10cSrcweir 
1836*cdf0e10cSrcweir 				pSubProps[4] >>= pInsDBColumn->sUsrNumFmt;
1837*cdf0e10cSrcweir                 rtl::OUString sNumberFormatLocale;
1838*cdf0e10cSrcweir 				pSubProps[5] >>= sNumberFormatLocale;
1839*cdf0e10cSrcweir 
1840*cdf0e10cSrcweir 				Locale aLocale;
1841*cdf0e10cSrcweir 				aLocale.Language = sNumberFormatLocale.copy(0, 2);
1842*cdf0e10cSrcweir 				aLocale.Country = sNumberFormatLocale.copy(3, 2);
1843*cdf0e10cSrcweir 				pInsDBColumn->eUsrNumFmtLng = SvxLocaleToLanguage( aLocale );
1844*cdf0e10cSrcweir 
1845*cdf0e10cSrcweir 				pInsDBColumn->nUsrNumFmt = rNFmtr.GetEntryKey( pInsDBColumn->sUsrNumFmt,
1846*cdf0e10cSrcweir 														pInsDBColumn->eUsrNumFmtLng );
1847*cdf0e10cSrcweir 
1848*cdf0e10cSrcweir //				pInsDBColumn->nDBNumFmt
1849*cdf0e10cSrcweir 
1850*cdf0e10cSrcweir 				pNewData->aDBColumns.Insert(pInsDBColumn);
1851*cdf0e10cSrcweir 			}
1852*cdf0e10cSrcweir 			sal_uInt16 n = 0;
1853*cdf0e10cSrcweir 			String sTmp( pNewData->sTblList );
1854*cdf0e10cSrcweir 			if( sTmp.Len() )
1855*cdf0e10cSrcweir 			{
1856*cdf0e10cSrcweir 				do {
1857*cdf0e10cSrcweir 					String sEntry( sTmp.GetToken( 0, '\x0a', n ) );
1858*cdf0e10cSrcweir 					//preselect column - if they still exist!
1859*cdf0e10cSrcweir                     if(aLbTblDbColumn.GetEntryPos(sEntry) != LISTBOX_ENTRY_NOTFOUND)
1860*cdf0e10cSrcweir                     {
1861*cdf0e10cSrcweir 						aLbTableCol.InsertEntry( sEntry );
1862*cdf0e10cSrcweir 						aLbTblDbColumn.RemoveEntry( sEntry );
1863*cdf0e10cSrcweir 					}
1864*cdf0e10cSrcweir 				} while( n < sTmp.Len() );
1865*cdf0e10cSrcweir 
1866*cdf0e10cSrcweir 				if( !aLbTblDbColumn.GetEntryCount() )
1867*cdf0e10cSrcweir 				{
1868*cdf0e10cSrcweir                     aIbDbcolAllTo.Enable( sal_False );
1869*cdf0e10cSrcweir                     aIbDbcolOneTo.Enable( sal_False );
1870*cdf0e10cSrcweir 				}
1871*cdf0e10cSrcweir                 aIbDbcolOneFrom.Enable( sal_True );
1872*cdf0e10cSrcweir                 aIbDbcolAllFrom.Enable( sal_True );
1873*cdf0e10cSrcweir 			}
1874*cdf0e10cSrcweir 			aEdDbText.SetText( pNewData->sEdit );
1875*cdf0e10cSrcweir 
1876*cdf0e10cSrcweir 			sTmp = pNewData->sTmplNm;
1877*cdf0e10cSrcweir 			if( sTmp.Len() )
1878*cdf0e10cSrcweir 				aLbDbParaColl.SelectEntry( sTmp );
1879*cdf0e10cSrcweir 			else
1880*cdf0e10cSrcweir 				aLbDbParaColl.SelectEntryPos( 0 );
1881*cdf0e10cSrcweir 
1882*cdf0e10cSrcweir 			if( pTAutoFmt )
1883*cdf0e10cSrcweir 				delete pTAutoFmt, pTAutoFmt = 0;
1884*cdf0e10cSrcweir 			sTmp = pNewData->sTAutoFmtNm;
1885*cdf0e10cSrcweir 			if( sTmp.Len() )
1886*cdf0e10cSrcweir 			{
1887*cdf0e10cSrcweir 				// dann erstmal die AutoFmt-Datei laden und das Autoformat suchen
1888*cdf0e10cSrcweir 				SwTableAutoFmtTbl aAutoFmtTbl;
1889*cdf0e10cSrcweir 				aAutoFmtTbl.Load();
1890*cdf0e10cSrcweir                 for( sal_uInt16 nAutoFmt = aAutoFmtTbl.Count(); nAutoFmt; )
1891*cdf0e10cSrcweir                     if( sTmp == aAutoFmtTbl[ --nAutoFmt ]->GetName() )
1892*cdf0e10cSrcweir 					{
1893*cdf0e10cSrcweir                         pTAutoFmt = new SwTableAutoFmt( *aAutoFmtTbl[ nAutoFmt ] );
1894*cdf0e10cSrcweir 						break;
1895*cdf0e10cSrcweir 					}
1896*cdf0e10cSrcweir 			}
1897*cdf0e10cSrcweir 
1898*cdf0e10cSrcweir 			aRbAsTable.Check( pNewData->bIsTable );
1899*cdf0e10cSrcweir 			aRbAsField.Check( pNewData->bIsField );
1900*cdf0e10cSrcweir 			aRbAsText.Check( !pNewData->bIsTable && !pNewData->bIsField );
1901*cdf0e10cSrcweir 
1902*cdf0e10cSrcweir 			aCbTableHeadon.Check( pNewData->bIsHeadlineOn );
1903*cdf0e10cSrcweir 			aRbHeadlColnms.Check( !pNewData->bIsEmptyHeadln );
1904*cdf0e10cSrcweir 			aRbHeadlEmpty.Check( pNewData->bIsEmptyHeadln );
1905*cdf0e10cSrcweir 			HeaderHdl(&aCbTableHeadon);
1906*cdf0e10cSrcweir 
1907*cdf0e10cSrcweir 			// jetzt noch die benutzerdefinierten Numberformat Strings in die
1908*cdf0e10cSrcweir 			// Shell kopieren. Nur diese sind dann als ID verfuegbar
1909*cdf0e10cSrcweir             for( n = 0; n < aDBColumns.Count() ; ++n )
1910*cdf0e10cSrcweir 			{
1911*cdf0e10cSrcweir 				SwInsDBColumn& rSet = *aDBColumns[ n ];
1912*cdf0e10cSrcweir                 for( sal_uInt16 m = 0; m < pNewData->aDBColumns.Count() ; ++m )
1913*cdf0e10cSrcweir                 {
1914*cdf0e10cSrcweir                     SwInsDBColumn& rGet = *pNewData->aDBColumns[ m ];
1915*cdf0e10cSrcweir                     if(rGet.sColumn == rSet.sColumn)
1916*cdf0e10cSrcweir                     {
1917*cdf0e10cSrcweir                         if( rGet.bHasFmt && !rGet.bIsDBFmt )
1918*cdf0e10cSrcweir                         {
1919*cdf0e10cSrcweir                             rSet.bIsDBFmt = sal_False;
1920*cdf0e10cSrcweir                             rSet.nUsrNumFmt = rNFmtr.GetEntryKey( rGet.sUsrNumFmt,
1921*cdf0e10cSrcweir                                                                     rGet.eUsrNumFmtLng );
1922*cdf0e10cSrcweir                             if( NUMBERFORMAT_ENTRY_NOT_FOUND == rSet.nUsrNumFmt )
1923*cdf0e10cSrcweir                             {
1924*cdf0e10cSrcweir                                 xub_StrLen nCheckPos;
1925*cdf0e10cSrcweir                                 short nType;
1926*cdf0e10cSrcweir                                 String sTmpFmt = rGet.sUsrNumFmt;
1927*cdf0e10cSrcweir                                 rNFmtr.PutEntry( sTmpFmt, nCheckPos, nType,
1928*cdf0e10cSrcweir                                                 rSet.nUsrNumFmt, rGet.eUsrNumFmtLng );
1929*cdf0e10cSrcweir                                 rGet.sUsrNumFmt = sTmpFmt;
1930*cdf0e10cSrcweir                             }
1931*cdf0e10cSrcweir                         }
1932*cdf0e10cSrcweir                         break;
1933*cdf0e10cSrcweir                     }
1934*cdf0e10cSrcweir                 }
1935*cdf0e10cSrcweir 			}
1936*cdf0e10cSrcweir 
1937*cdf0e10cSrcweir 			// steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
1938*cdf0e10cSrcweir 			if( !aRbAsTable.IsEnabled() && aRbAsTable.IsChecked() )
1939*cdf0e10cSrcweir 				aRbAsField.Check( sal_True );
1940*cdf0e10cSrcweir 			delete pNewData;
1941*cdf0e10cSrcweir 			break;
1942*cdf0e10cSrcweir 		}
1943*cdf0e10cSrcweir 	}
1944*cdf0e10cSrcweir }
1945*cdf0e10cSrcweir 
1946