1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dbinsdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #ifdef SW_DLLIMPLEMENTATION
34 #undef SW_DLLIMPLEMENTATION
37 #include "dbinsdlg.hxx"
39 #ifndef INCLUDED_MEMORY
41 #define INCLUDED_MEMORY
44 #ifndef INCLUDED_FLOAT_H
46 #define INCLUDED_FLOAT_H
48 #include <hintids.hxx>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/container/XNameAccess.hpp>
51 #include <com/sun/star/sdbc/XDataSource.hpp>
52 #include <com/sun/star/sdbc/XRow.hpp>
53 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
54 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
55 #include <com/sun/star/sdb/XQueriesSupplier.hpp>
56 #include <com/sun/star/sdb/CommandType.hpp>
57 #include <com/sun/star/sdb/XColumn.hpp>
58 #include <com/sun/star/sdb/XDatabaseAccess.hpp>
59 #include <com/sun/star/sdbc/DataType.hpp>
60 #include <com/sun/star/sdbc/ResultSetType.hpp>
61 #include <com/sun/star/beans/XPropertySet.hpp>
62 #include <com/sun/star/util/XNumberFormatter.hpp>
63 #include <com/sun/star/util/XNumberFormatTypes.hpp>
64 #include <com/sun/star/sdbc/XRowSet.hpp>
65 #include <comphelper/processfactory.hxx>
66 #include <svx/langitem.hxx>
67 #include <svtools/numuno.hxx>
68 #include <svtools/stritem.hxx>
69 #include <vcl/msgbox.hxx>
70 #include <vcl/svapp.hxx>
71 #ifndef __SV_MNEMONIC_HXX
72 #include <vcl/mnemonic.hxx>
74 #include <svtools/style.hxx>
75 #include <svtools/zformat.hxx>
76 #include <svx/htmlmode.hxx>
77 #include <svx/unolingu.hxx>
78 #include <sfx2/app.hxx>
79 #include <svtools/itemset.hxx>
80 #include <svx/brshitem.hxx>
81 #include <svx/boxitem.hxx>
82 #include <svx/rulritem.hxx>
83 #include <swdbtoolsclient.hxx>
84 #ifndef _SWTABLEREP_HXX //autogen
85 #include <tabledlg.hxx>
87 #include <fmtclds.hxx>
89 #include <uiitems.hxx>
90 #include <viewopt.hxx>
102 #include <tblafmt.hxx>
103 #include <cellatr.hxx>
104 #include <swtable.hxx>
106 #include <fmtcol.hxx>
107 #include <section.hxx>
108 #include <swwait.hxx>
109 #include <modcfg.hxx>
110 #include <swmodule.hxx>
111 #include <poolfmt.hxx>
112 #include <crsskip.hxx>
114 #ifndef _DBINSDLG_HRC
115 #include <dbinsdlg.hrc>
128 #include <SwStyleNameMapper.hxx>
129 #include <comphelper/uno3.hxx>
131 #include "swabstdlg.hxx"
134 #include <IDocumentMarkAccess.hxx>
139 SwAbstractDialogFactory
* GetFactory();
142 using namespace ::com::sun::star
;
143 using namespace ::com::sun::star::uno
;
144 using namespace ::com::sun::star::container
;
145 using namespace ::com::sun::star::lang
;
146 using namespace ::com::sun::star::sdb
;
147 using namespace ::com::sun::star::sdbc
;
148 using namespace ::com::sun::star::sdbcx
;
149 using namespace ::com::sun::star::beans
;
152 SV_IMPL_PTRARR( _SwTableAutoFmtTbl
, SwTableAutoFmt
* )
154 const char cDBFldStart
= '<';
155 const char cDBFldEnd
= '>';
157 // Hilfsstruktur fuers einfuegen von Datenbankspalten als Felder oder Text
160 enum ColType
{ DB_FILLTEXT
, DB_COL_FIELD
, DB_COL_TEXT
, DB_SPLITPARA
} eColType
;
167 const SwInsDBColumn
* pColInfo
;
172 DB_ColumnData
.pText
= 0;
173 eColType
= DB_SPLITPARA
;
176 _DB_Column( const String
& rTxt
)
179 DB_ColumnData
.pText
= new String( rTxt
);
180 eColType
= DB_FILLTEXT
;
183 _DB_Column( const SwInsDBColumn
& rInfo
, ULONG nFormat
)
186 DB_ColumnData
.nFormat
= nFormat
;
187 eColType
= DB_COL_TEXT
;
190 _DB_Column( const SwInsDBColumn
& rInfo
, SwDBField
& rFld
)
193 DB_ColumnData
.pField
= &rFld
;
194 eColType
= DB_COL_FIELD
;
199 if( DB_COL_FIELD
== eColType
)
200 delete DB_ColumnData
.pField
;
201 else if( DB_FILLTEXT
== eColType
)
202 delete DB_ColumnData
.pText
;
206 typedef _DB_Column
* _DB_ColumnPtr
;
207 SV_DECL_PTRARR_DEL( _DB_Columns
, _DB_ColumnPtr
, 32, 32 )
208 SV_IMPL_PTRARR( _DB_Columns
, _DB_ColumnPtr
)
210 SV_IMPL_OP_PTRARR_SORT( SwInsDBColumns
, SwInsDBColumnPtr
)
214 #define DBCOLUMN_CONFIG_VERSION1 1
215 #define DBCOLUMN_CONFIG_VERSION DBCOLUMN_CONFIG_VERSION1
216 #define DBCOLUMN_MAXDATA 5
218 struct _DB_ColumnConfigData
220 SwInsDBColumns aDBColumns
;
221 rtl::OUString sSource
, sTable
, sEdit
, sTblList
, sTmplNm
, sTAutoFmtNm
;
227 _DB_ColumnConfigData()
229 bIsTable
= bIsHeadlineOn
= TRUE
;
230 bIsField
= bIsEmptyHeadln
= FALSE
;
233 ~_DB_ColumnConfigData();
235 _DB_ColumnConfigData( const _DB_ColumnConfigData
& );
236 _DB_ColumnConfigData
& operator =( const _DB_ColumnConfigData
& );
241 int SwInsDBColumn::operator<( const SwInsDBColumn
& rCmp
) const
243 return 0 > GetAppCollator().compareString( sColumn
, rCmp
.sColumn
);
245 /* ---------------------------------------------------------------------------
247 ---------------------------------------------------------------------------*/
248 SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView
& rView
,
249 Reference
<XDataSource
> xDataSource
,
250 Reference
<sdbcx::XColumnsSupplier
> xColSupp
,
251 const SwDBData
& rData
)
252 : SfxModalDialog( rView
.GetWindow(), SW_RES( DLG_AP_INSERT_DB_SEL
)),
253 ConfigItem(C2U("Office.Writer/InsertData/DataSet"), CONFIG_MODE_DELAYED_UPDATE
),
254 aFtInsertData( this, SW_RES( FT_INSERT_DATA
)),
255 aRbAsTable( this, SW_RES( RB_AS_TABLE
)),
256 aRbAsField( this, SW_RES( RB_AS_FIELD
)),
257 aRbAsText( this, SW_RES( RB_AS_TEXT
)),
259 aFlHead( this, SW_RES( FL_HEAD
)),
260 aFtDbColumn( this, SW_RES( FT_DB_COLUMN
)),
262 aLbTblDbColumn( this, SW_RES( LB_TBL_DB_COLUMN
)),
263 aLbTxtDbColumn( this, SW_RES( LB_TXT_DB_COLUMN
)),
265 aFlFormat( this, SW_RES( FL_FORMAT
)),
266 aRbDbFmtFromDb( this, SW_RES( RB_DBFMT_FROM_DB
)),
267 aRbDbFmtFromUsr( this, SW_RES( RB_DBFMT_FROM_USR
)),
268 aLbDbFmtFromUsr( this, &rView
, SW_RES( LB_DBFMT_FROM_USR
)),
270 aIbDbcolToEdit( this, SW_RES( IB_DBCOL_TOEDIT
)),
271 aEdDbText( this, SW_RES( ED_DB_TEXT
)),
272 aFtDbParaColl( this, SW_RES( FT_DB_PARA_COLL
)),
273 aLbDbParaColl( this, SW_RES( LB_DB_PARA_COLL
)),
275 aIbDbcolAllTo( this, SW_RES( IB_DBCOL_ALL_TO
)),
276 aIbDbcolOneTo( this, SW_RES( IB_DBCOL_ONE_TO
)),
277 aIbDbcolOneFrom( this, SW_RES( IB_DBCOL_ONE_FROM
)),
278 aIbDbcolAllFrom( this, SW_RES( IB_DBCOL_ALL_FROM
)),
279 aFtTableCol( this, SW_RES( FT_TABLE_COL
)),
280 aLbTableCol( this, SW_RES( LB_TABLE_COL
)),
281 aCbTableHeadon( this, SW_RES( CB_TABLE_HEADON
)),
282 aRbHeadlColnms( this, SW_RES( RB_HEADL_COLNMS
)),
283 aRbHeadlEmpty( this, SW_RES( RB_HEADL_EMPTY
)),
284 aPbTblFormat( this, SW_RES( PB_TBL_FORMAT
)),
285 aPbTblAutofmt( this, SW_RES( PB_TBL_AUTOFMT
)),
287 aBtOk( this, SW_RES( BT_OK
)),
288 aBtCancel( this, SW_RES( BT_CANCEL
)),
289 aBtHelp( this, SW_RES( BT_HELP
)),
291 aFlBottom( this, SW_RES( FL_BOTTOM
)),
295 aOldNumFmtLnk( aLbDbFmtFromUsr
.GetSelectHdl() ),
296 sNoTmpl( SW_RES( STR_NOTEMPL
)),
304 nGBFmtLen
= aFlFormat
.GetText().Len();
308 SwWrtShell
& rSh
= pView
->GetWrtShell();
309 Locale
aDocLocale( SvxCreateLocale( rSh
.GetCurLang() ));
310 SvNumberFormatter
* pNumFmtr
= rSh
.GetNumberFormatter();
311 SvNumberFormatsSupplierObj
* pNumFmt
= new SvNumberFormatsSupplierObj( pNumFmtr
);
312 Reference
< util::XNumberFormatsSupplier
> xDocNumFmtsSupplier
= pNumFmt
;
313 Reference
< util::XNumberFormats
> xDocNumberFormats
= xDocNumFmtsSupplier
->getNumberFormats();
314 Reference
< util::XNumberFormatTypes
> xDocNumberFormatTypes(xDocNumberFormats
, UNO_QUERY
);
316 Reference
<XPropertySet
> xSourceProps(xDataSource
, UNO_QUERY
);
317 Reference
< util::XNumberFormats
> xNumberFormats
;
318 if(xSourceProps
.is())
320 Any aFormats
= xSourceProps
->getPropertyValue(C2U("NumberFormatsSupplier"));
321 if(aFormats
.hasValue())
323 Reference
< util::XNumberFormatsSupplier
> xSuppl
;
327 xNumberFormats
= xSuppl
->getNumberFormats( );
331 Reference
<XNameAccess
> xCols
= xColSupp
->getColumns();
332 Sequence
<rtl::OUString
> aColNames
= xCols
->getElementNames();
333 const rtl::OUString
* pColNames
= aColNames
.getConstArray();
334 long nCount
= aColNames
.getLength();
335 for (long n
= 0; n
< nCount
; n
++)
337 SwInsDBColumn
* pNew
= new SwInsDBColumn( pColNames
[n
], (USHORT
)n
);
338 Any aCol
= xCols
->getByName(pColNames
[n
]);
339 Reference
<XPropertySet
> xCol
;
341 Any aType
= xCol
->getPropertyValue(C2S("Type"));
342 sal_Int32 eDataType
= 0;
347 case DataType::BOOLEAN
:
348 case DataType::TINYINT
:
349 case DataType::SMALLINT
:
350 case DataType::INTEGER
:
351 case DataType::BIGINT
:
352 case DataType::FLOAT
:
354 case DataType::DOUBLE
:
355 case DataType::NUMERIC
:
356 case DataType::DECIMAL
:
359 case DataType::TIMESTAMP
:
361 pNew
->bHasFmt
= TRUE
;
362 Any aFormat
= xCol
->getPropertyValue(C2U("FormatKey"));
363 if(aFormat
.hasValue())
367 if(xNumberFormats
.is())
371 Reference
<XPropertySet
> xNumProps
= xNumberFormats
->getByKey( nFmt
);
372 Any aFormatVal
= xNumProps
->getPropertyValue(C2U("FormatString"));
373 Any aLocale
= xNumProps
->getPropertyValue(C2U("Locale"));
374 rtl::OUString sFormat
;
375 aFormatVal
>>= sFormat
;
378 long nKey
= xDocNumberFormats
->queryKey( sFormat
, aLoc
, sal_True
);
381 nKey
= xDocNumberFormats
->addNew( sFormat
, aLoc
);
383 pNew
->nDBNumFmt
= nKey
;
385 catch(const Exception
& )
387 DBG_ERROR("illegal number format key");
393 pNew
->nDBNumFmt
= SwNewDBMgr::GetDbtoolsClient().getDefaultNumberFormat(xCol
,
394 xDocNumberFormatTypes
, aDocLocale
);
400 if( !aDBColumns
.Insert( pNew
))
402 ASSERT( !this, "Spaltenname mehrfach vergeben?" );
408 // Absatzvorlagen-ListBox fuellen
410 SfxStyleSheetBasePool
* pPool
= pView
->GetDocShell()->GetStyleSheetPool();
411 pPool
->SetSearchMask( SFX_STYLE_FAMILY_PARA
, SFXSTYLEBIT_ALL
);
412 aLbDbParaColl
.InsertEntry( sNoTmpl
);
414 const SfxStyleSheetBase
* pBase
= pPool
->First();
417 aLbDbParaColl
.InsertEntry( pBase
->GetName() );
418 pBase
= pPool
->Next();
420 aLbDbParaColl
.SelectEntryPos( 0 );
423 // steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
424 if( pView
->GetWrtShell().GetTableFmt() )
426 aRbAsTable
.Enable( FALSE
);
427 aRbAsField
.Check( TRUE
);
428 aRbDbFmtFromDb
.Check( TRUE
);
432 aRbAsTable
.Check( TRUE
);
433 aRbDbFmtFromDb
.Check( TRUE
);
434 aIbDbcolOneFrom
.Enable( FALSE
);
435 aIbDbcolAllFrom
.Enable( FALSE
);
438 aRbAsTable
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, PageHdl
));
439 aRbAsField
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, PageHdl
));
440 aRbAsText
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, PageHdl
));
442 aRbDbFmtFromDb
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, DBFormatHdl
));
443 aRbDbFmtFromUsr
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, DBFormatHdl
));
445 aPbTblFormat
.SetClickHdl(LINK(this, SwInsertDBColAutoPilot
, TblFmtHdl
));
446 aPbTblAutofmt
.SetClickHdl(LINK(this, SwInsertDBColAutoPilot
, AutoFmtHdl
));
448 aIbDbcolAllTo
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, TblToFromHdl
));
449 aIbDbcolOneTo
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, TblToFromHdl
));
450 aIbDbcolOneFrom
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, TblToFromHdl
));
451 aIbDbcolAllFrom
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, TblToFromHdl
));
452 aIbDbcolToEdit
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, TblToFromHdl
));
454 aCbTableHeadon
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, HeaderHdl
));
455 aRbHeadlColnms
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, HeaderHdl
));
456 aRbHeadlEmpty
.SetClickHdl( LINK(this, SwInsertDBColAutoPilot
, HeaderHdl
));
458 aLbTxtDbColumn
.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot
, SelectHdl
));
459 aLbTblDbColumn
.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot
, SelectHdl
));
460 aLbDbFmtFromUsr
.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot
, SelectHdl
));
461 aLbTableCol
.SetSelectHdl( LINK( this, SwInsertDBColAutoPilot
, SelectHdl
));
463 aLbTxtDbColumn
.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot
, DblClickHdl
));
464 aLbTblDbColumn
.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot
, DblClickHdl
));
465 aLbTableCol
.SetDoubleClickHdl( LINK( this, SwInsertDBColAutoPilot
, DblClickHdl
));
467 for( USHORT n
= 0; n
< aDBColumns
.Count(); ++n
)
469 const String
& rS
= aDBColumns
[ n
]->sColumn
;
470 aLbTblDbColumn
.InsertEntry( rS
, n
);
471 aLbTxtDbColumn
.InsertEntry( rS
, n
);
473 aLbTxtDbColumn
.SelectEntryPos( 0 );
474 aLbTblDbColumn
.SelectEntryPos( 0 );
476 // read configuration
479 // Controls initialisieren:
480 PageHdl( aRbAsTable
.IsChecked() ? &aRbAsTable
: &aRbAsField
);
482 /* ---------------------------------------------------------------------------
484 ---------------------------------------------------------------------------*/
485 SwInsertDBColAutoPilot::~SwInsertDBColAutoPilot()
493 /* ---------------------------------------------------------------------------
495 ---------------------------------------------------------------------------*/
496 IMPL_LINK( SwInsertDBColAutoPilot
, PageHdl
, Button
*, pButton
)
498 BOOL bShowTbl
= pButton
== &aRbAsTable
;
500 String
sTxt( pButton
->GetText() );
501 aFlHead
.SetText( MnemonicGenerator::EraseAllMnemonicChars( sTxt
) );
503 aLbTxtDbColumn
.Show( !bShowTbl
);
504 aIbDbcolToEdit
.Show( !bShowTbl
);
505 aEdDbText
.Show( !bShowTbl
);
506 aFtDbParaColl
.Show( !bShowTbl
);
507 aLbDbParaColl
.Show( !bShowTbl
);
509 aLbTblDbColumn
.Show( bShowTbl
);
510 aIbDbcolAllTo
.Show( bShowTbl
);
511 aIbDbcolOneTo
.Show( bShowTbl
);
512 aIbDbcolOneFrom
.Show( bShowTbl
);
513 aIbDbcolAllFrom
.Show( bShowTbl
);
514 aFtTableCol
.Show( bShowTbl
);
515 aLbTableCol
.Show( bShowTbl
);
516 aCbTableHeadon
.Show( bShowTbl
);
517 aRbHeadlColnms
.Show( bShowTbl
);
518 aRbHeadlEmpty
.Show( bShowTbl
);
519 aPbTblFormat
.Show( bShowTbl
);
520 aPbTblAutofmt
.Show( bShowTbl
);
523 aPbTblFormat
.Enable( 0 != aLbTableCol
.GetEntryCount() );
525 SelectHdl( bShowTbl
? &aLbTblDbColumn
: &aLbTxtDbColumn
);
529 /* ---------------------------------------------------------------------------
531 ---------------------------------------------------------------------------*/
532 IMPL_LINK( SwInsertDBColAutoPilot
, DBFormatHdl
, Button
*, pButton
)
535 ListBox
& rBox
= aRbAsTable
.IsChecked()
536 ? ( 0 == aLbTableCol
.GetEntryData( 0 )
541 SwInsDBColumn
aSrch( rBox
.GetSelectEntry(), 0 );
542 aDBColumns
.Seek_Entry( &aSrch
, &nFndPos
);
544 BOOL bFromDB
= &aRbDbFmtFromDb
== pButton
;
545 aDBColumns
[ nFndPos
]->bIsDBFmt
= bFromDB
;
546 aLbDbFmtFromUsr
.Enable( !bFromDB
);
550 /* ---------------------------------------------------------------------------
552 ---------------------------------------------------------------------------*/
553 IMPL_LINK( SwInsertDBColAutoPilot
, TblToFromHdl
, Button
*, pButton
)
555 BOOL bChgEnable
= TRUE
, bEnableTo
= TRUE
, bEnableFrom
= TRUE
;
556 aLbTblDbColumn
.SetUpdateMode( FALSE
);
557 aLbTableCol
.SetUpdateMode( FALSE
);
559 if( pButton
== &aIbDbcolAllTo
)
563 USHORT n
, nInsPos
= aLbTableCol
.GetSelectEntryPos(),
564 nCnt
= aLbTblDbColumn
.GetEntryCount();
565 if( LISTBOX_APPEND
== nInsPos
)
566 for( n
= 0; n
< nCnt
; ++n
)
567 aLbTableCol
.InsertEntry( aLbTblDbColumn
.GetEntry( n
),
570 for( n
= 0; n
< nCnt
; ++n
, ++nInsPos
)
571 aLbTableCol
.InsertEntry( aLbTblDbColumn
.GetEntry( n
), nInsPos
);
572 aLbTblDbColumn
.Clear();
573 aLbTableCol
.SelectEntryPos( nInsPos
);
574 aLbTblDbColumn
.SelectEntryPos( LISTBOX_APPEND
);
576 else if( pButton
== &aIbDbcolOneTo
&&
577 LISTBOX_ENTRY_NOTFOUND
!= aLbTblDbColumn
.GetSelectEntryPos() )
579 USHORT nInsPos
= aLbTableCol
.GetSelectEntryPos(),
580 nDelPos
= aLbTblDbColumn
.GetSelectEntryPos(),
581 nTopPos
= aLbTblDbColumn
.GetTopEntry();
582 aLbTableCol
.InsertEntry( aLbTblDbColumn
.GetEntry( nDelPos
), nInsPos
);
583 aLbTblDbColumn
.RemoveEntry( nDelPos
);
585 aLbTableCol
.SelectEntryPos( nInsPos
);
586 if( nDelPos
>= aLbTblDbColumn
.GetEntryCount() )
587 nDelPos
= aLbTblDbColumn
.GetEntryCount() - 1;
588 aLbTblDbColumn
.SelectEntryPos( nDelPos
);
589 aLbTblDbColumn
.SetTopEntry( nTopPos
);
591 bEnableTo
= 0 != aLbTblDbColumn
.GetEntryCount();
593 else if( pButton
== &aIbDbcolOneFrom
)
595 if( LISTBOX_ENTRY_NOTFOUND
!= aLbTableCol
.GetSelectEntryPos() )
597 USHORT nFndPos
, nInsPos
,
598 nDelPos
= aLbTableCol
.GetSelectEntryPos(),
599 nTopPos
= aLbTableCol
.GetTopEntry();
601 // die richtige InsertPos suchen!!
602 SwInsDBColumn
aSrch( aLbTableCol
.GetEntry( nDelPos
), 0 );
603 aDBColumns
.Seek_Entry( &aSrch
, &nFndPos
);
604 if( !nFndPos
|| nFndPos
== aDBColumns
.Count()-1 )
608 nInsPos
= LISTBOX_ENTRY_NOTFOUND
;
609 while( ++nFndPos
< aDBColumns
.Count() &&
610 LISTBOX_ENTRY_NOTFOUND
== (nInsPos
= aLbTblDbColumn
.
611 GetEntryPos( String(aDBColumns
[ nFndPos
]->sColumn
))) )
615 aLbTblDbColumn
.InsertEntry( aSrch
.sColumn
, nInsPos
);
616 aLbTableCol
.RemoveEntry( nDelPos
);
618 if( nInsPos
>= aLbTblDbColumn
.GetEntryCount() )
619 nInsPos
= aLbTblDbColumn
.GetEntryCount() - 1;
620 aLbTblDbColumn
.SelectEntryPos( nInsPos
);
622 if( nDelPos
>= aLbTableCol
.GetEntryCount() )
623 nDelPos
= aLbTableCol
.GetEntryCount() - 1;
624 aLbTableCol
.SelectEntryPos( nDelPos
);
625 aLbTableCol
.SetTopEntry( nTopPos
);
628 bEnableTo
= 0 != aLbTblDbColumn
.GetEntryCount();
630 bEnableFrom
= 0 != aLbTableCol
.GetEntryCount();
632 else if( pButton
== &aIbDbcolAllFrom
)
636 aLbTblDbColumn
.Clear();
638 for( USHORT n
= 0; n
< aDBColumns
.Count(); ++n
)
639 aLbTblDbColumn
.InsertEntry( aDBColumns
[ n
]->sColumn
, n
);
640 aLbTblDbColumn
.SelectEntryPos( 0 );
642 else if( pButton
== &aIbDbcolToEdit
)
645 // Daten ins Edit moven:
646 String
aFld( aLbTxtDbColumn
.GetSelectEntry() );
649 String
aStr( aEdDbText
.GetText() );
650 USHORT nPos
= (USHORT
)aEdDbText
.GetSelection().Min();
651 USHORT nSel
= USHORT(aEdDbText
.GetSelection().Max()) - nPos
;
653 // dann loesche erstmal die bestehende Selektion
654 aStr
.Erase( nPos
, nSel
);
656 aFld
.Insert( cDBFldStart
, 0 );
660 if( nPos
) // ein Space davor
662 sal_Unicode c
= aStr
.GetChar( nPos
-1 );
663 if( '\n' != c
&& '\r' != c
)
664 aFld
.Insert( ' ', 0 );
666 if( nPos
< aStr
.Len() ) // ein Space dahinter
668 sal_Unicode c
= aStr
.GetChar( nPos
);
669 if( '\n' != c
&& '\r' != c
)
674 aStr
.Insert( aFld
, nPos
);
675 aEdDbText
.SetText( aStr
);
676 nPos
= nPos
+ aFld
.Len();
677 aEdDbText
.SetSelection( Selection( nPos
));
683 aIbDbcolOneTo
.Enable( bEnableTo
);
684 aIbDbcolAllTo
.Enable( bEnableTo
);
685 aIbDbcolOneFrom
.Enable( bEnableFrom
);
686 aIbDbcolAllFrom
.Enable( bEnableFrom
);
688 aRbDbFmtFromDb
.Enable( FALSE
);
689 aRbDbFmtFromUsr
.Enable( FALSE
);
690 aLbDbFmtFromUsr
.Enable( FALSE
);
692 aPbTblFormat
.Enable( bEnableFrom
);
694 aLbTblDbColumn
.SetUpdateMode( TRUE
);
695 aLbTableCol
.SetUpdateMode( TRUE
);
699 /* ---------------------------------------------------------------------------
701 ---------------------------------------------------------------------------*/
702 IMPL_LINK( SwInsertDBColAutoPilot
, DblClickHdl
, ListBox
*, pBox
)
705 if( pBox
== &aLbTxtDbColumn
)
706 pButton
= &aIbDbcolToEdit
;
707 else if( pBox
== &aLbTblDbColumn
&& aIbDbcolOneTo
.IsEnabled() )
708 pButton
= &aIbDbcolOneTo
;
709 else if( pBox
== &aLbTableCol
&& aIbDbcolOneFrom
.IsEnabled() )
710 pButton
= &aIbDbcolOneFrom
;
713 TblToFromHdl( pButton
);
717 /* ---------------------------------------------------------------------------
719 ---------------------------------------------------------------------------*/
720 IMPL_LINK( SwInsertDBColAutoPilot
, TblFmtHdl
, PushButton
*, pButton
)
722 SwWrtShell
& rSh
= pView
->GetWrtShell();
723 BOOL bNewSet
= FALSE
;
727 pTblSet
= new SfxItemSet( rSh
.GetAttrPool(), SwuiGetUITableAttrRange() );
729 //Ersteinmal die einfachen Attribute besorgen.
730 pTblSet
->Put( SfxStringItem( FN_PARAM_TABLE_NAME
, rSh
.GetUniqueTblName() ));
731 pTblSet
->Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE
, 1 ) );
733 pTblSet
->Put( SfxUInt16Item( SID_BACKGRND_DESTINATION
,
734 rSh
.GetViewOptions()->GetTblDest() ));
736 SvxBrushItem
aBrush( RES_BACKGROUND
);
737 pTblSet
->Put( aBrush
);
738 pTblSet
->Put( aBrush
, SID_ATTR_BRUSH_ROW
);
739 pTblSet
->Put( aBrush
, SID_ATTR_BRUSH_TABLE
);
741 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
742 // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
743 aBoxInfo
.SetTable( TRUE
);
744 // Abstandsfeld immer anzeigen
745 aBoxInfo
.SetDist( TRUE
);
746 // Minimalgroesse in Tabellen und Absaetzen setzen
747 aBoxInfo
.SetMinDist( FALSE
);
748 // Default-Abstand immer setzen
749 aBoxInfo
.SetDefDist( MIN_BORDER_DIST
);
750 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
751 aBoxInfo
.SetValid( VALID_DISABLE
, TRUE
);
752 pTblSet
->Put( aBoxInfo
);
754 SwGetCurColNumPara aPara
;
755 const USHORT nNum
= rSh
.GetCurColNum( &aPara
);
760 nWidth
= aPara
.pPrtRect
->Width();
761 const SwFmtCol
& rCol
= aPara
.pFrmFmt
->GetCol();
762 const SwColumns
& rCols
= rCol
.GetColumns();
764 //nStart und nEnd initialisieren fuer nNum == 0
768 for( USHORT i
= 0; i
< nNum
; ++i
)
770 SwColumn
* pCol
= rCols
[i
];
771 nStart1
= pCol
->GetLeft() + nWidth1
;
772 nWidth1
+= (long)rCol
.CalcColWidth( i
, (USHORT
)nWidth
);
773 nEnd1
= nWidth1
- pCol
->GetRight();
775 if(nStart1
|| nEnd1
!= nWidth
)
776 nWidth
= nEnd1
- nStart1
;
779 nWidth
= rSh
.GetAnyCurRect(
780 FRMTYPE_FLY_ANY
& rSh
.GetFrmType( 0, TRUE
)
781 ? RECT_FLY_PRT_EMBEDDED
782 : RECT_PAGE_PRT
).Width();
785 aTabCols
.SetRight( nWidth
);
786 aTabCols
.SetRightMax( nWidth
);
787 pRep
= new SwTableRep( aTabCols
, FALSE
);
788 pRep
->SetAlign( text::HoriOrientation::NONE
);
789 pRep
->SetSpace( nWidth
);
790 pRep
->SetWidth( nWidth
);
791 pRep
->SetWidthPercent( 100 );
792 pTblSet
->Put( SwPtrItem( FN_TABLE_REP
, pRep
));
794 pTblSet
->Put( SfxUInt16Item( SID_HTML_MODE
,
795 ::GetHtmlMode( pView
->GetDocShell() )));
798 if( aLbTableCol
.GetEntryCount() != pRep
->GetAllColCount() )
800 // Anzahl der Spalten hat sich geaendert: dann muessen die
801 // TabCols angepasst werden
802 long nWidth
= pRep
->GetWidth();
803 USHORT nCols
= aLbTableCol
.GetEntryCount() - 1;
804 SwTabCols
aTabCols( nCols
);
805 aTabCols
.SetRight( nWidth
);
806 aTabCols
.SetRightMax( nWidth
);
808 for( USHORT n
= 0, nStep
= (USHORT
)(nWidth
/ (nCols
+1)), nW
= nStep
;
809 n
< nCols
; ++n
, nW
= nW
+ nStep
)
811 aTabCols
.Insert( nW
, FALSE
, n
);
814 pRep
= new SwTableRep( aTabCols
, FALSE
);
815 pRep
->SetAlign( text::HoriOrientation::NONE
);
816 pRep
->SetSpace( nWidth
);
817 pRep
->SetWidth( nWidth
);
818 pRep
->SetWidthPercent( 100 );
819 pTblSet
->Put( SwPtrItem( FN_TABLE_REP
, pRep
));
822 SwAbstractDialogFactory
* pFact
= swui::GetFactory();
823 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
825 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTableTabDlg( pButton
, rSh
.GetAttrPool(),pTblSet
, &rSh
, DLG_FORMAT_TABLE
);
826 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
827 if( RET_OK
== pDlg
->Execute() )
828 pTblSet
->Put( *pDlg
->GetOutputItemSet() );
831 delete pTblSet
, pTblSet
= 0;
832 delete pRep
, pRep
= 0;
838 /* ---------------------------------------------------------------------------
840 ---------------------------------------------------------------------------*/
841 IMPL_LINK( SwInsertDBColAutoPilot
, AutoFmtHdl
, PushButton
*, pButton
)
843 SwAbstractDialogFactory
* pFact
= swui::GetFactory();
844 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
846 AbstractSwAutoFormatDlg
* pDlg
= pFact
->CreateSwAutoFormatDlg(pButton
, pView
->GetWrtShellPtr(),DLG_AUTOFMT_TABLE
, FALSE
, pTAutoFmt
);
847 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
848 if( RET_OK
== pDlg
->Execute())
849 pDlg
->FillAutoFmtOfIndex( pTAutoFmt
);
853 /* ---------------------------------------------------------------------------
855 ---------------------------------------------------------------------------*/
856 IMPL_LINK( SwInsertDBColAutoPilot
, SelectHdl
, ListBox
*, pBox
)
858 ListBox
* pGetBox
= pBox
== &aLbDbFmtFromUsr
859 ? ( aRbAsTable
.IsChecked()
860 ? ( 0 == aLbTableCol
.GetEntryData( 0 )
867 SwInsDBColumn
aSrch( pGetBox
->GetSelectEntry(), 0 );
868 aDBColumns
.Seek_Entry( &aSrch
, &nFndPos
);
870 if( pBox
== &aLbDbFmtFromUsr
)
872 if( aSrch
.sColumn
.getLength() )
874 aOldNumFmtLnk
.Call( pBox
);
875 aDBColumns
[ nFndPos
]->nUsrNumFmt
= aLbDbFmtFromUsr
.GetFormat();
880 // an der FormatGroupBox den ausgewaehlten FeldNamen setzen, damit
881 // klar ist, welches Feld ueber das Format eingestellt wird!
882 String
sTxt( aFlFormat
.GetText().Copy( 0, nGBFmtLen
));
883 if( !aSrch
.sColumn
.getLength() )
885 aRbDbFmtFromDb
.Enable( FALSE
);
886 aRbDbFmtFromUsr
.Enable( FALSE
);
887 aLbDbFmtFromUsr
.Enable( FALSE
);
891 BOOL bEnableFmt
= aDBColumns
[ nFndPos
]->bHasFmt
;
892 aRbDbFmtFromDb
.Enable( bEnableFmt
);
893 aRbDbFmtFromUsr
.Enable( bEnableFmt
);
897 (( sTxt
+= C2S(" (" )) += String(aSrch
.sColumn
) ) += (sal_Unicode
)')';
900 BOOL bIsDBFmt
= aDBColumns
[ nFndPos
]->bIsDBFmt
;
901 aRbDbFmtFromDb
.Check( bIsDBFmt
);
902 aRbDbFmtFromUsr
.Check( !bIsDBFmt
);
903 aLbDbFmtFromUsr
.Enable( !bIsDBFmt
);
905 aLbDbFmtFromUsr
.SetDefFormat( aDBColumns
[ nFndPos
]->nUsrNumFmt
);
908 aFlFormat
.SetText( sTxt
);
910 // um spaeter zu wissen, welche ListBox die "aktive" war, wird sich
911 // im 1. Eintrag ein Flag gemerkt,
912 void* pPtr
= pBox
== &aLbTableCol
? &aLbTableCol
: 0;
913 aLbTableCol
.SetEntryData( 0, pPtr
);
917 /* ---------------------------------------------------------------------------
919 ---------------------------------------------------------------------------*/
920 IMPL_LINK( SwInsertDBColAutoPilot
, HeaderHdl
, Button
*, pButton
)
922 if( pButton
== &aCbTableHeadon
)
924 BOOL bEnable
= aCbTableHeadon
.IsChecked();
926 aRbHeadlColnms
.Enable( bEnable
);
927 aRbHeadlEmpty
.Enable( bEnable
);
931 /* ---------------------------------------------------------------------------
933 ---------------------------------------------------------------------------*/
934 static void lcl_InsTextInArr( const String
& rTxt
, _DB_Columns
& rColArr
)
937 USHORT nSttPos
= 0, nFndPos
;
938 while( STRING_NOTFOUND
!= ( nFndPos
= rTxt
.Search( '\x0A', nSttPos
)) )
942 pNew
= new _DB_Column( rTxt
.Copy( nSttPos
, nFndPos
-1 ) );
943 rColArr
.Insert( pNew
, rColArr
.Count() );
945 pNew
= new _DB_Column
;
946 rColArr
.Insert( pNew
, rColArr
.Count() );
947 nSttPos
= nFndPos
+ 1;
949 if( nSttPos
< rTxt
.Len() )
951 pNew
= new _DB_Column( rTxt
.Copy( nSttPos
) );
952 rColArr
.Insert( pNew
, rColArr
.Count() );
955 /* ---------------------------------------------------------------------------
957 ---------------------------------------------------------------------------*/
958 BOOL
SwInsertDBColAutoPilot::SplitTextToColArr( const String
& rTxt
,
959 _DB_Columns
& rColArr
,
962 // aus dem Text wieder die einzelnen Datenbank - Spalten erzeugen
963 // und dann in einem Array speichern
964 // Die Datenbankspalten stehen in <> und muessen im Array der Spalten
967 USHORT nFndPos
, nEndPos
, nSttPos
= 0;
969 while( STRING_NOTFOUND
!= ( nFndPos
= sTxt
.Search( cDBFldStart
, nSttPos
)))
971 nSttPos
= nFndPos
+ 1;
972 if( STRING_NOTFOUND
!= ( nEndPos
= sTxt
.Search( cDBFldEnd
, nSttPos
+1 )))
974 // Text in <> geklammert gefunden: was ist es denn:
975 SwInsDBColumn
aSrch( sTxt
.Copy( nSttPos
, nEndPos
- nSttPos
), 0);
976 if( aDBColumns
.Seek_Entry( &aSrch
, &nFndPos
) )
978 // das ist ein gueltiges Feld
979 // also sicher den Text "davor":
980 const SwInsDBColumn
& rFndCol
= *aDBColumns
[ nFndPos
];
986 ::lcl_InsTextInArr( sTxt
.Copy( 0, nSttPos
-1 ), rColArr
);
987 sTxt
.Erase( 0, nSttPos
-1 );
990 sTxt
.Erase( 0, (xub_StrLen
)(rFndCol
.sColumn
.getLength() + 2) );
995 if( rFndCol
.bHasFmt
)
997 if( rFndCol
.bIsDBFmt
)
998 nFormat
= rFndCol
.nDBNumFmt
;
1001 nFormat
= rFndCol
.nUsrNumFmt
;
1002 nSubType
= nsSwExtendedSubType::SUB_OWN_FMT
;
1010 SwWrtShell
& rSh
= pView
->GetWrtShell();
1011 SwDBFieldType
aFldType( rSh
.GetDoc(), aSrch
.sColumn
,
1013 pNew
= new _DB_Column( rFndCol
, *new SwDBField(
1014 (SwDBFieldType
*)rSh
.InsertFldType( aFldType
),
1017 pNew
->DB_ColumnData
.pField
->SetSubType( nSubType
);
1020 pNew
= new _DB_Column( rFndCol
, nFormat
);
1022 rColArr
.Insert( pNew
, rColArr
.Count() );
1027 // den letzten Text nicht vergessen
1029 ::lcl_InsTextInArr( sTxt
, rColArr
);
1031 return 0 != rColArr
.Count();
1033 /* ---------------------------------------------------------------------------
1035 ---------------------------------------------------------------------------*/
1036 void SwInsertDBColAutoPilot::DataToDoc( const Sequence
<Any
>& rSelection
,
1037 Reference
< XDataSource
> xSource
,
1038 Reference
< XConnection
> xConnection
,
1039 Reference
< sdbc::XResultSet
> xResultSet
)
1041 const Any
* pSelection
= rSelection
.getLength() ? rSelection
.getConstArray() : 0;
1042 SwWrtShell
& rSh
= pView
->GetWrtShell();
1044 //with the drag and drop interface no result set is initially available
1045 BOOL bDisposeResultSet
= FALSE
;
1046 // we don't have a cursor, so we have to create our own RowSet
1047 if ( !xResultSet
.is() )
1049 xResultSet
= SwNewDBMgr::createCursor(aDBData
.sDataSource
,aDBData
.sCommand
,aDBData
.nCommandType
,xConnection
);
1050 bDisposeResultSet
= xResultSet
.is();
1053 Reference
< sdbc::XRow
> xRow(xResultSet
, UNO_QUERY
);
1057 rSh
.StartAllAction();
1058 BOOL bUndo
= rSh
.DoesUndo();
1060 rSh
.StartUndo( UNDO_EMPTY
);
1062 BOOL bAsTable
= aRbAsTable
.IsChecked();
1063 SvNumberFormatter
& rNumFmtr
= *rSh
.GetNumberFormatter();
1065 if( rSh
.HasSelection() )
1068 ::std::auto_ptr
<SwWait
> pWait
;
1070 Reference
< XColumnsSupplier
> xColsSupp( xResultSet
, UNO_QUERY
);
1071 Reference
<XNameAccess
> xCols
= xColsSupp
->getColumns();
1073 do{ // middle checked loop!!
1074 if( bAsTable
) // Daten als Tabelle einfuegen
1076 rSh
.DoUndo( FALSE
);
1078 USHORT n
, nRows
= 0, nCols
= aLbTableCol
.GetEntryCount();
1079 if( aCbTableHeadon
.IsChecked() )
1083 nRows
= nRows
+ (USHORT
)rSelection
.getLength();
1087 // bereite das Array fuer die ausgewaehlten Spalten auf
1088 SwInsDBColumns_SAR
aColFlds( 255 >= nCols
? (BYTE
)nCols
: 255, 5 );
1089 for( n
= 0; n
< nCols
; ++n
)
1092 SwInsDBColumn
aSrch( aLbTableCol
.GetEntry( n
), 0 );
1093 if( aDBColumns
.Seek_Entry( &aSrch
, &nFndPos
) )
1094 aColFlds
.Insert( aDBColumns
[ nFndPos
], n
);
1096 ASSERT( !this, "Datenbankspalte nicht mehr gefunden" );
1100 if( nCols
!= aColFlds
.Count() )
1102 ASSERT( !this, "nicht alle Datenbankspalten gefunden" );
1103 nCols
= aColFlds
.Count();
1106 if(!nRows
|| !nCols
)
1108 ASSERT( !this, "wrong parameters" );
1112 const SwModuleOptions
* pModOpt
= SW_MOD()->GetModuleConfig();
1114 BOOL bHTML
= 0 != (::GetHtmlMode( pView
->GetDocShell() ) & HTMLMODE_ON
);
1116 pModOpt
->GetInsTblFlags(bHTML
),
1117 nRows
, nCols
, text::HoriOrientation::FULL
, (pSelection
? pTAutoFmt
: 0) );
1118 rSh
.MoveTable( GetfnTablePrev(), GetfnTableStart() );
1120 if( pSelection
&& pTblSet
)
1123 SfxItemSet
aTblSet( rSh
.GetAttrPool(), RES_BOXATR_FORMAT
,
1125 BOOL bIsAutoUpdateCells
= rSh
.IsAutoUpdateCells();
1126 rSh
.SetAutoUpdateCells( FALSE
);
1129 if( aCbTableHeadon
.IsChecked() )
1131 for( n
= 0; n
< nCols
; ++n
)
1133 if( aRbHeadlColnms
.IsChecked() )
1135 rSh
.SwEditShell::Insert2( aColFlds
[ n
]->sColumn
);
1141 rSh
.SetRowsToRepeat( 0 );
1143 for( sal_Int32 i
= 0 ; ; ++i
)
1145 BOOL bBreak
= FALSE
;
1151 pSelection
[i
] >>= nPos
;
1152 bBreak
= !xResultSet
->absolute(nPos
);
1155 bBreak
= !xResultSet
->first();
1157 catch(const Exception
& )
1164 for( n
= 0; n
< nCols
; ++n
)
1166 // beim aller erstenmal KEIN GoNextCell, weil wir schon
1167 // drin stehen. Auch nicht nach dem Insert das GoNextCell,
1168 // weil am Ende eine leere Zeile einfuegt wird.
1172 const SwInsDBColumn
* pEntry
= aColFlds
[ n
];
1174 Reference
< XColumn
> xColumn
;
1175 xCols
->getByName(pEntry
->sColumn
) >>= xColumn
;
1176 Reference
< XPropertySet
> xColumnProps( xColumn
, UNO_QUERY
);
1177 sal_Int32 eDataType
= 0;
1178 if( xColumnProps
.is() )
1180 Any aType
= xColumnProps
->getPropertyValue(C2U("Type"));
1181 aType
>>= eDataType
;
1185 if( pEntry
->bHasFmt
)
1187 SwTblBoxNumFormat
aNumFmt(
1188 pEntry
->bIsDBFmt
? pEntry
->nDBNumFmt
1189 : pEntry
->nUsrNumFmt
);
1190 aTblSet
.Put(aNumFmt
);
1193 double fVal
= xColumn
->getDouble();
1194 if( xColumn
->wasNull() )
1195 aTblSet
.ClearItem( RES_BOXATR_VALUE
);
1198 if(rNumFmtr
.GetType(aNumFmt
.GetValue()) & NUMBERFORMAT_DATE
)
1200 ::Date
aStandard(1,1,1900);
1201 if (*rNumFmtr
.GetNullDate() != aStandard
)
1202 fVal
+= (aStandard
- *rNumFmtr
.GetNullDate());
1204 aTblSet
.Put( SwTblBoxValue( fVal
));
1208 aTblSet
.ClearItem( RES_BOXATR_VALUE
);
1209 rSh
.SetTblBoxFormulaAttrs( aTblSet
);
1211 //#i60207# don't insert binary data as string - creates a loop
1212 else if( DataType::BINARY
== eDataType
||
1213 DataType::VARBINARY
== eDataType
||
1214 DataType::LONGVARBINARY
== eDataType
||
1215 DataType::SQLNULL
== eDataType
||
1216 DataType::OTHER
== eDataType
||
1217 DataType::OBJECT
== eDataType
||
1218 DataType::DISTINCT
== eDataType
||
1219 DataType::STRUCT
== eDataType
||
1220 DataType::ARRAY
== eDataType
||
1221 DataType::BLOB
== eDataType
||
1222 DataType::CLOB
== eDataType
||
1223 DataType::REF
== eDataType
1230 rtl::OUString sVal
= xColumn
->getString();
1231 if(!xColumn
->wasNull())
1233 rSh
.SwEditShell::Insert2( sVal
);
1243 DBG_ERROR(ByteString(String(aExcept
.Message
), gsl_getSystemTextEncoding()).GetBuffer());
1249 if ( !xResultSet
->next() )
1252 else if( i
+1 >= rSelection
.getLength() )
1256 pWait
= ::std::auto_ptr
<SwWait
>(new SwWait( *pView
->GetDocShell(), TRUE
));
1259 rSh
.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1260 if( !pSelection
&& ( pTblSet
|| pTAutoFmt
))
1266 rSh
.SetTableAutoFmt( *pTAutoFmt
);
1268 rSh
.SetAutoUpdateCells( bIsAutoUpdateCells
);
1270 else // Daten als Felder/Text einfuegen
1272 _DB_Columns aColArr
;
1273 if( SplitTextToColArr( aEdDbText
.GetText(), aColArr
, aRbAsField
.IsChecked() ) )
1275 // jetzt kann bei jedem Datensatz einfach ueber das Array iteriert
1276 // und die Daten eingefuegt werden
1278 if( !rSh
.IsSttPara() )
1279 rSh
.SwEditShell::SplitNode();
1280 if( !rSh
.IsEndPara() )
1282 rSh
.SwEditShell::SplitNode();
1283 rSh
.SwCrsrShell::Left(1,CRSR_SKIP_CHARS
);
1286 rSh
.DoUndo( FALSE
);
1288 SwTxtFmtColl
* pColl
= 0;
1290 String
sTmplNm( aLbDbParaColl
.GetSelectEntry() );
1291 if( sNoTmpl
!= sTmplNm
)
1293 pColl
= rSh
.FindTxtFmtCollByName( sTmplNm
);
1296 USHORT nId
= SwStyleNameMapper::GetPoolIdFromUIName( sTmplNm
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
1297 if( USHRT_MAX
!= nId
)
1298 pColl
= rSh
.GetTxtCollFromPool( nId
);
1300 pColl
= rSh
.MakeTxtFmtColl( sTmplNm
);
1302 rSh
.SetTxtFmtColl( pColl
);
1306 // fuers Einfuegen als Felder -> nach jedem Datensatz ein
1307 // "NextField" einfuegen
1308 SwDBFormatData aDBFormatData
;
1309 Reference
< XMultiServiceFactory
> xMgr( ::comphelper::getProcessServiceFactory() );
1312 Reference
<XInterface
> xInstance
= xMgr
->createInstance( C2U( "com.sun.star.util.NumberFormatter" ));
1313 aDBFormatData
.xFormatter
= Reference
<util::XNumberFormatter
>(xInstance
, UNO_QUERY
) ;
1316 Reference
<XPropertySet
> xSourceProps(xSource
, UNO_QUERY
);
1317 if(xSourceProps
.is())
1319 Any aFormats
= xSourceProps
->getPropertyValue(C2U("NumberFormatsSupplier"));
1320 if(aFormats
.hasValue())
1322 Reference
< util::XNumberFormatsSupplier
> xSuppl
;
1323 aFormats
>>= xSuppl
;
1326 Reference
< XPropertySet
> xSettings
= xSuppl
->getNumberFormatSettings();
1327 Any aNull
= xSettings
->getPropertyValue(C2U("NullDate"));
1328 aNull
>>= aDBFormatData
.aNullDate
;
1329 if(aDBFormatData
.xFormatter
.is())
1330 aDBFormatData
.xFormatter
->attachNumberFormatsSupplier(xSuppl
);
1334 aDBFormatData
.aLocale
= SvxCreateLocale( rSh
.GetCurLang() );
1335 SwDBNextSetField
aNxtDBFld( (SwDBNextSetFieldType
*)rSh
.
1336 GetFldType( 0, RES_DBNEXTSETFLD
),
1337 C2S("1"), aEmptyStr
, aDBData
);
1340 BOOL bSetCrsr
= TRUE
;
1341 USHORT n
= 0, nCols
= aColArr
.Count();
1342 ::sw::mark::IMark
* pMark
= NULL
;
1343 for( sal_Int32 i
= 0 ; ; ++i
)
1345 BOOL bBreak
= FALSE
;
1351 pSelection
[i
] >>= nPos
;
1352 bBreak
= !xResultSet
->absolute(nPos
);
1355 bBreak
= !xResultSet
->first();
1366 for( n
= 0; n
< nCols
; ++n
)
1368 _DB_Column
* pDBCol
= aColArr
[ n
];
1370 switch( pDBCol
->eColType
)
1372 case _DB_Column::DB_FILLTEXT
:
1373 sIns
= *pDBCol
->DB_ColumnData
.pText
;
1376 case _DB_Column::DB_SPLITPARA
:
1378 // wenn nicht die gleiche Vorlage die Follow Vorlage
1379 // ist, dann muss die ausgewaehlte neu gesetzt werden
1380 if( pColl
&& &pColl
->GetNextTxtFmtColl() != pColl
)
1381 rSh
.SetTxtFmtColl( pColl
);
1384 case _DB_Column::DB_COL_FIELD
:
1386 SwDBField
* pFld
= (SwDBField
*)pDBCol
->DB_ColumnData
.
1388 double nValue
= DBL_MAX
;
1390 Reference
< XPropertySet
> xColumnProps
;
1391 xCols
->getByName(pDBCol
->pColInfo
->sColumn
) >>= xColumnProps
;
1393 pFld
->SetExpansion( SwNewDBMgr::GetDBField(
1397 if( DBL_MAX
!= nValue
)
1399 Any aType
= xColumnProps
->getPropertyValue(C2U("Type"));
1400 sal_Int32 eDataType
= 0;
1401 aType
>>= eDataType
;
1402 if( DataType::DATE
== eDataType
|| DataType::TIME
== eDataType
||
1403 DataType::TIMESTAMP
== eDataType
)
1406 ::Date
aStandard(1,1,1900);
1407 ::Date
aCompare(aDBFormatData
.aNullDate
.Day
,
1408 aDBFormatData
.aNullDate
.Month
,
1409 aDBFormatData
.aNullDate
.Year
);
1410 if(aStandard
!= aCompare
)
1411 nValue
+= (aStandard
- aCompare
);
1413 pFld
->ChgValue( nValue
, TRUE
);
1415 pFld
->SetInitialized();
1417 rSh
.Insert( *pFld
);
1422 case _DB_Column::DB_COL_TEXT
:
1424 double nValue
= DBL_MAX
;
1425 Reference
< XPropertySet
> xColumnProps
;
1426 xCols
->getByName(pDBCol
->pColInfo
->sColumn
) >>= xColumnProps
;
1427 sIns
= SwNewDBMgr::GetDBField(
1431 if( pDBCol
->DB_ColumnData
.nFormat
&&
1435 if(rNumFmtr
.GetType(pDBCol
->DB_ColumnData
.nFormat
) & NUMBERFORMAT_DATE
)
1437 ::Date
aStandard(1,1,1900);
1438 if (*rNumFmtr
.GetNullDate() != aStandard
)
1439 nValue
+= (aStandard
- *rNumFmtr
.GetNullDate());
1441 rNumFmtr
.GetOutputString( nValue
,
1442 pDBCol
->DB_ColumnData
.nFormat
,
1452 if( bSetCrsr
&& sIns
.Len() )
1454 // zum Anfang und eine Mark setzen, damit der
1455 // Cursor am Ende wieder auf Anfangsposition
1456 // gesetzt werden kann.
1458 // rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaStart );
1459 rSh
.SwCrsrShell::MovePara(
1460 GetfnParaCurr(), GetfnParaStart() );
1461 pMark
= rSh
.SetBookmark(
1464 ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK
);
1465 // rSh.SwCrsrShell::MovePara( fnParaCurr, fnParaEnd );
1466 rSh
.SwCrsrShell::MovePara(
1467 GetfnParaCurr(), GetfnParaEnd() );
1474 BOOL bNext
= xResultSet
->next();
1478 else if( i
+1 >= rSelection
.getLength() )
1481 if( aRbAsField
.IsChecked() )
1482 rSh
.Insert( aNxtDBFld
);
1484 if( !rSh
.IsSttPara() )
1485 rSh
.SwEditShell::SplitNode();
1488 pWait
= ::std::auto_ptr
<SwWait
>(new SwWait( *pView
->GetDocShell(), TRUE
));
1491 if( !bSetCrsr
&& pMark
!= NULL
)
1494 rSh
.GotoMark( pMark
);
1495 rSh
.getIDocumentMarkAccess()->deleteMark( pMark
);
1500 // write configuration
1502 }while( FALSE
); // middle checked loop
1507 rSh
.AppendUndoForInsertFromDB( bAsTable
);
1508 rSh
.EndUndo( UNDO_EMPTY
);
1513 if ( bDisposeResultSet
)
1514 ::comphelper::disposeComponent(xResultSet
);
1516 void SwInsertDBColAutoPilot::SetTabSet()
1518 SwWrtShell
& rSh
= pView
->GetWrtShell();
1519 const SfxPoolItem
* pItem
;
1523 if( pTAutoFmt
->IsFrame() )
1525 // Umrandung kommt vom AutoFormat
1526 pTblSet
->ClearItem( RES_BOX
);
1527 pTblSet
->ClearItem( SID_ATTR_BORDER_INNER
);
1529 if( pTAutoFmt
->IsBackground() )
1531 pTblSet
->ClearItem( RES_BACKGROUND
);
1532 pTblSet
->ClearItem( SID_ATTR_BRUSH_ROW
);
1533 pTblSet
->ClearItem( SID_ATTR_BRUSH_TABLE
);
1538 // die Defaults wieder entfernen, es macht keinen Sinn sie zu setzen
1539 SvxBrushItem
aBrush( RES_BACKGROUND
);
1540 static USHORT __READONLY_DATA aIds
[3] =
1541 { RES_BACKGROUND
, SID_ATTR_BRUSH_ROW
, SID_ATTR_BRUSH_TABLE
};
1542 for( int i
= 0; i
< 3; ++i
)
1543 if( SFX_ITEM_SET
== pTblSet
->GetItemState( aIds
[ i
],
1544 FALSE
, &pItem
) && *pItem
== aBrush
)
1545 pTblSet
->ClearItem( aIds
[ i
] );
1548 if( SFX_ITEM_SET
== pTblSet
->GetItemState( FN_PARAM_TABLE_NAME
, FALSE
,
1549 &pItem
) && ((const SfxStringItem
*)pItem
)->GetValue() ==
1550 rSh
.GetTableFmt()->GetName() )
1551 pTblSet
->ClearItem( FN_PARAM_TABLE_NAME
);
1553 rSh
.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1555 rSh
.MoveTable( GetfnTableCurr(), GetfnTableEnd() );
1557 ItemSetToTableParam( *pTblSet
, rSh
);
1560 rSh
.MoveTable( GetfnTableCurr(), GetfnTableStart() );
1566 _DB_ColumnConfigData::~_DB_ColumnConfigData() {}
1568 /* -----------------------------05.12.00 16:15--------------------------------
1570 ---------------------------------------------------------------------------*/
1571 static Sequence
<rtl::OUString
> lcl_createSourceNames(const String
& rNodeName
)
1573 Sequence
<rtl::OUString
> aSourceNames(11);
1574 rtl::OUString
* pNames
= aSourceNames
.getArray();
1576 String
sTmp( rNodeName
);
1577 const xub_StrLen nPos
= sTmp
.Len();
1578 pNames
[0] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1579 RTL_CONSTASCII_STRINGPARAM( "/DataSource" ));
1580 pNames
[1] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1581 RTL_CONSTASCII_STRINGPARAM( "/Command" ));
1582 pNames
[2] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1583 RTL_CONSTASCII_STRINGPARAM( "/CommandType" ));
1584 pNames
[3] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1585 RTL_CONSTASCII_STRINGPARAM( "/ColumnsToText" ));
1586 pNames
[4] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1587 RTL_CONSTASCII_STRINGPARAM( "/ColumnsToTable" ));
1588 pNames
[5] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1589 RTL_CONSTASCII_STRINGPARAM( "/ParaStyle" ));
1590 pNames
[6] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1591 RTL_CONSTASCII_STRINGPARAM( "/TableAutoFormat" ));
1592 pNames
[7] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1593 RTL_CONSTASCII_STRINGPARAM( "/IsTable" ));
1594 pNames
[8] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1595 RTL_CONSTASCII_STRINGPARAM( "/IsField" ));
1596 pNames
[9] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1597 RTL_CONSTASCII_STRINGPARAM( "/IsHeadlineOn" ));
1598 pNames
[10] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1599 RTL_CONSTASCII_STRINGPARAM( "/IsEmptyHeadline" ));
1600 return aSourceNames
;
1602 /* -----------------------------05.12.00 16:25--------------------------------
1604 ---------------------------------------------------------------------------*/
1605 static Sequence
<rtl::OUString
> lcl_CreateSubNames( const String
& rSubNodeName
)
1607 Sequence
<rtl::OUString
> aSubSourceNames(6);
1608 rtl::OUString
* pNames
= aSubSourceNames
.getArray();
1609 String
sTmp( rSubNodeName
);
1610 const xub_StrLen nPos
= sTmp
.Len();
1611 pNames
[0] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1612 RTL_CONSTASCII_STRINGPARAM( "/ColumnName" ));
1613 pNames
[1] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1614 RTL_CONSTASCII_STRINGPARAM( "/ColumnIndex" ));
1615 pNames
[2] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1616 RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormat" ));
1617 pNames
[3] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1618 RTL_CONSTASCII_STRINGPARAM( "/IsNumberFormatFromDataBase" ));
1619 pNames
[4] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1620 RTL_CONSTASCII_STRINGPARAM( "/NumberFormat" ));
1621 pNames
[5] = sTmp
.ReplaceAscii( nPos
, STRING_MAXLEN
,
1622 RTL_CONSTASCII_STRINGPARAM( "/NumberFormatLocale" ));
1623 return aSubSourceNames
;
1625 /* -----------------------------06.12.00 13:03--------------------------------
1627 ---------------------------------------------------------------------------*/
1628 static rtl::OUString
lcl_CreateUniqueName(const Sequence
<rtl::OUString
>& aNames
)
1630 sal_Int32 nIdx
= aNames
.getLength();
1631 const rtl::OUString
* pNames
= aNames
.getConstArray();
1632 rtl::OUString
sTest(C2U("_"));
1636 sRet
= sTest
; sRet
+= rtl::OUString::valueOf(nIdx
++);
1637 sal_Bool bFound
= sal_False
;
1638 for(sal_Int32 i
= 0; i
< aNames
.getLength(); i
++)
1640 if(pNames
[i
] == sRet
)
1651 /* -----------------------------05.12.00 15:00--------------------------------
1653 ---------------------------------------------------------------------------*/
1654 void SwInsertDBColAutoPilot::Commit()
1656 Sequence
<rtl::OUString
> aNames
= GetNodeNames(rtl::OUString());
1657 const rtl::OUString
* pNames
= aNames
.getArray();
1658 //remove entries that contain this data source + table at first
1659 for(sal_Int32 nNode
= 0; nNode
< aNames
.getLength(); nNode
++)
1661 Sequence
<rtl::OUString
> aSourceNames(2);
1662 rtl::OUString
* pSourceNames
= aSourceNames
.getArray();
1663 pSourceNames
[0] = pNames
[nNode
];
1664 pSourceNames
[0] += C2U("/DataSource");
1665 pSourceNames
[1] = pNames
[nNode
];
1666 pSourceNames
[1] += C2U("/Command");
1667 Sequence
<Any
> aSourceProperties
= GetProperties(aSourceNames
);
1668 const Any
* pSourceProps
= aSourceProperties
.getArray();
1669 rtl::OUString sSource
, sCommand
;
1670 pSourceProps
[0] >>= sSource
;
1671 pSourceProps
[1] >>= sCommand
;
1672 if(sSource
.equals(aDBData
.sDataSource
) && sCommand
.equals(aDBData
.sCommand
))
1674 Sequence
<rtl::OUString
> aElements(1);
1675 aElements
.getArray()[0] = pNames
[nNode
];
1676 ClearNodeElements(rtl::OUString(), aElements
);
1680 aNames
= GetNodeNames(rtl::OUString());
1681 rtl::OUString sNewNode
= lcl_CreateUniqueName(aNames
);
1682 Sequence
<rtl::OUString
> aNodeNames
= lcl_createSourceNames(sNewNode
);
1683 Sequence
<PropertyValue
> aValues(aNodeNames
.getLength());
1684 PropertyValue
* pValues
= aValues
.getArray();
1685 const rtl::OUString
* pNodeNames
= aNodeNames
.getConstArray();
1686 rtl::OUString
sSlash(C2U("/"));
1687 for(sal_Int32 i
= 0; i
< aNodeNames
.getLength(); i
++)
1689 pValues
[i
].Name
= sSlash
;
1690 pValues
[i
].Name
+= pNodeNames
[i
];
1693 pValues
[0].Value
<<= rtl::OUString(aDBData
.sDataSource
);
1694 pValues
[1].Value
<<= rtl::OUString(aDBData
.sCommand
);
1695 pValues
[2].Value
<<= aDBData
.nCommandType
;
1696 pValues
[3].Value
<<= rtl::OUString(aEdDbText
.GetText());
1699 for( USHORT n
= 0, nCnt
= aLbTableCol
.GetEntryCount(); n
< nCnt
; ++n
)
1700 ( sTmp
+= aLbTableCol
.GetEntry( n
) ) += '\x0a';
1703 pValues
[4].Value
<<= rtl::OUString(sTmp
);
1705 if( sNoTmpl
!= (sTmp
= aLbDbParaColl
.GetSelectEntry()) )
1706 pValues
[5].Value
<<= rtl::OUString(sTmp
);
1709 pValues
[6].Value
<<= rtl::OUString(pTAutoFmt
->GetName());
1711 const Type
& rBoolType
= ::getBooleanCppuType();
1712 sal_Bool bTmp
= aRbAsTable
.IsChecked();
1713 pValues
[7].Value
.setValue(&bTmp
, rBoolType
);
1715 bTmp
= aRbAsField
.IsChecked();
1716 pValues
[8].Value
.setValue(&bTmp
, rBoolType
);
1718 bTmp
= aCbTableHeadon
.IsChecked();
1719 pValues
[9].Value
.setValue(&bTmp
, rBoolType
);
1721 bTmp
= aRbHeadlEmpty
.IsChecked();
1722 pValues
[10].Value
.setValue(&bTmp
, rBoolType
);
1724 SetSetProperties(rtl::OUString(), aValues
);
1726 sNewNode
+= C2U("/ColumnSet");
1727 String
sDelim( String::CreateFromAscii( "/__" ));
1729 LanguageType ePrevLang
= (LanguageType
)-1;
1730 rtl::OUString sPrevLang
;
1732 SvNumberFormatter
& rNFmtr
= *pView
->GetWrtShell().GetNumberFormatter();
1733 for(USHORT nCol
= 0; nCol
< aDBColumns
.Count(); nCol
++)
1735 rtl::OUString sColumnNode
= sNewNode
;
1736 SwInsDBColumn
* pColumn
= aDBColumns
[nCol
];
1737 String
sColumnInsertNode(sColumnNode
);
1738 sColumnInsertNode
+= sDelim
;
1740 sColumnInsertNode
+= '0';
1742 sColumnInsertNode
+= '0';
1743 sColumnInsertNode
+= String::CreateFromInt32( nCol
);
1745 Sequence
<rtl::OUString
> aSubNodeNames
= lcl_CreateSubNames(sColumnInsertNode
);
1746 Sequence
<PropertyValue
> aSubValues(aSubNodeNames
.getLength());
1747 PropertyValue
* pSubValues
= aSubValues
.getArray();
1748 const rtl::OUString
* pSubNodeNames
= aSubNodeNames
.getConstArray();
1751 for( i
= 0; i
< aSubNodeNames
.getLength(); i
++)
1752 pSubValues
[i
].Name
= pSubNodeNames
[i
];
1753 pSubValues
[0].Value
<<= pColumn
->sColumn
;
1754 pSubValues
[1].Value
<<= i
;
1756 sal_Bool bVal
= pColumn
->bHasFmt
;
1757 pSubValues
[2].Value
.setValue(&bVal
, rBoolType
);
1758 bVal
= pColumn
->bIsDBFmt
;
1759 pSubValues
[3].Value
.setValue(&bVal
, rBoolType
);
1761 SwStyleNameMapper::FillUIName( RES_POOLCOLL_STANDARD
, sTmp
);
1762 const SvNumberformat
* pNF
= rNFmtr
.GetEntry( pColumn
->nUsrNumFmt
);
1766 pSubValues
[4].Value
<<= rtl::OUString(pNF
->GetFormatstring());
1767 eLang
= pNF
->GetLanguage();
1771 pSubValues
[4].Value
<<= rtl::OUString(sTmp
);
1772 eLang
= (LanguageType
)GetAppLanguage();
1775 if( eLang
!= ePrevLang
)
1778 aLocale
= SvxLanguageToLocale( aLocale
, eLang
);
1779 (( sPrevLang
= aLocale
.Country
) += rtl::OUString( '-' )) += aLocale
.Language
;
1783 pSubValues
[5].Value
<<= sPrevLang
;
1784 SetSetProperties(sColumnNode
, aSubValues
);
1787 /* -----------------------------05.12.00 15:00--------------------------------
1789 ---------------------------------------------------------------------------*/
1790 void SwInsertDBColAutoPilot::Load()
1792 Sequence
<rtl::OUString
> aNames
= GetNodeNames(rtl::OUString());
1793 const rtl::OUString
* pNames
= aNames
.getArray();
1794 SvNumberFormatter
& rNFmtr
= *pView
->GetWrtShell().GetNumberFormatter();
1795 for(sal_Int32 nNode
= 0; nNode
< aNames
.getLength(); nNode
++)
1797 //search for entries with the appropriate data source and table
1798 Sequence
<rtl::OUString
> aSourceNames
= lcl_createSourceNames(pNames
[nNode
]);
1800 Sequence
< Any
> aDataSourceProps
= GetProperties(aSourceNames
);
1801 const Any
* pDataSourceProps
= aDataSourceProps
.getConstArray();
1802 rtl::OUString sSource
, sCommand
;
1803 sal_Int16 nCommandType
;
1804 pDataSourceProps
[0] >>= sSource
;
1805 pDataSourceProps
[1] >>= sCommand
;
1806 pDataSourceProps
[2] >>= nCommandType
;
1807 if(sSource
.equals(aDBData
.sDataSource
) && sCommand
.equals(aDBData
.sCommand
))
1809 _DB_ColumnConfigData
* pNewData
= new _DB_ColumnConfigData
;
1810 pNewData
->sSource
= sSource
;
1811 pNewData
->sTable
= sCommand
;
1813 pDataSourceProps
[3] >>= pNewData
->sEdit
;
1814 pDataSourceProps
[4] >>= pNewData
->sTblList
;
1815 pDataSourceProps
[5] >>= pNewData
->sTmplNm
;
1816 pDataSourceProps
[6] >>= pNewData
->sTAutoFmtNm
;
1817 if(pDataSourceProps
[7].hasValue())
1818 pNewData
->bIsTable
= *(sal_Bool
*)pDataSourceProps
[7].getValue();
1819 if(pDataSourceProps
[8].hasValue())
1820 pNewData
->bIsField
= *(sal_Bool
*)pDataSourceProps
[8].getValue();
1821 if(pDataSourceProps
[9].hasValue())
1822 pNewData
->bIsHeadlineOn
= *(sal_Bool
*)pDataSourceProps
[9].getValue();
1823 if(pDataSourceProps
[10].hasValue())
1824 pNewData
->bIsEmptyHeadln
= *(sal_Bool
*)pDataSourceProps
[10].getValue();
1826 rtl::OUString
sSubNodeName(pNames
[nNode
]);
1827 sSubNodeName
+= C2U("/ColumnSet/");
1828 Sequence
<rtl::OUString
> aSubNames
= GetNodeNames(sSubNodeName
);
1829 const rtl::OUString
* pSubNames
= aSubNames
.getConstArray();
1830 for(sal_Int32 nSub
= 0; nSub
< aSubNames
.getLength(); nSub
++)
1832 rtl::OUString
sSubSubNodeName(sSubNodeName
);
1833 sSubSubNodeName
+= pSubNames
[nSub
];
1834 Sequence
<rtl::OUString
> aSubNodeNames
= lcl_CreateSubNames(sSubSubNodeName
);
1835 Sequence
< Any
> aSubProps
= GetProperties(aSubNodeNames
);
1836 const Any
* pSubProps
= aSubProps
.getConstArray();
1838 rtl::OUString sColumn
;
1839 pSubProps
[0] >>= sColumn
;
1840 //check for existance of the loaded column name
1841 sal_Bool bFound
= sal_False
;
1842 for(sal_Int32 nRealColumn
= 0; nRealColumn
< aDBColumns
.Count(); nRealColumn
++)
1844 if(aDBColumns
[(USHORT
)nRealColumn
]->sColumn
== sColumn
)
1852 sal_Int16 nIndex
= 0;
1853 pSubProps
[1] >>= nIndex
;
1854 SwInsDBColumnPtr pInsDBColumn
= new SwInsDBColumn(sColumn
, nIndex
);
1855 if(pSubProps
[2].hasValue())
1856 pInsDBColumn
->bHasFmt
= *(sal_Bool
*)pSubProps
[2].getValue();
1857 if(pSubProps
[3].hasValue())
1858 pInsDBColumn
->bIsDBFmt
= *(sal_Bool
*)pSubProps
[3].getValue();
1860 pSubProps
[4] >>= pInsDBColumn
->sUsrNumFmt
;
1861 rtl::OUString sNumberFormatLocale
;
1862 pSubProps
[5] >>= sNumberFormatLocale
;
1865 aLocale
.Language
= sNumberFormatLocale
.copy(0, 2);
1866 aLocale
.Country
= sNumberFormatLocale
.copy(3, 2);
1867 pInsDBColumn
->eUsrNumFmtLng
= SvxLocaleToLanguage( aLocale
);
1869 pInsDBColumn
->nUsrNumFmt
= rNFmtr
.GetEntryKey( pInsDBColumn
->sUsrNumFmt
,
1870 pInsDBColumn
->eUsrNumFmtLng
);
1872 // pInsDBColumn->nDBNumFmt
1874 pNewData
->aDBColumns
.Insert(pInsDBColumn
);
1877 String
sTmp( pNewData
->sTblList
);
1881 String
sEntry( sTmp
.GetToken( 0, '\x0a', n
) );
1882 //preselect column - if they still exist!
1883 if(aLbTblDbColumn
.GetEntryPos(sEntry
) != LISTBOX_ENTRY_NOTFOUND
)
1885 aLbTableCol
.InsertEntry( sEntry
);
1886 aLbTblDbColumn
.RemoveEntry( sEntry
);
1888 } while( n
< sTmp
.Len() );
1890 if( !aLbTblDbColumn
.GetEntryCount() )
1892 aIbDbcolAllTo
.Enable( FALSE
);
1893 aIbDbcolOneTo
.Enable( FALSE
);
1895 aIbDbcolOneFrom
.Enable( TRUE
);
1896 aIbDbcolAllFrom
.Enable( TRUE
);
1898 aEdDbText
.SetText( pNewData
->sEdit
);
1900 sTmp
= pNewData
->sTmplNm
;
1902 aLbDbParaColl
.SelectEntry( sTmp
);
1904 aLbDbParaColl
.SelectEntryPos( 0 );
1907 delete pTAutoFmt
, pTAutoFmt
= 0;
1908 sTmp
= pNewData
->sTAutoFmtNm
;
1911 // dann erstmal die AutoFmt-Datei laden und das Autoformat suchen
1912 SwTableAutoFmtTbl aAutoFmtTbl
;
1914 for( USHORT nAutoFmt
= aAutoFmtTbl
.Count(); nAutoFmt
; )
1915 if( sTmp
== aAutoFmtTbl
[ --nAutoFmt
]->GetName() )
1917 pTAutoFmt
= new SwTableAutoFmt( *aAutoFmtTbl
[ nAutoFmt
] );
1922 aRbAsTable
.Check( pNewData
->bIsTable
);
1923 aRbAsField
.Check( pNewData
->bIsField
);
1924 aRbAsText
.Check( !pNewData
->bIsTable
&& !pNewData
->bIsField
);
1926 aCbTableHeadon
.Check( pNewData
->bIsHeadlineOn
);
1927 aRbHeadlColnms
.Check( !pNewData
->bIsEmptyHeadln
);
1928 aRbHeadlEmpty
.Check( pNewData
->bIsEmptyHeadln
);
1929 HeaderHdl(&aCbTableHeadon
);
1931 // jetzt noch die benutzerdefinierten Numberformat Strings in die
1932 // Shell kopieren. Nur diese sind dann als ID verfuegbar
1933 for( n
= 0; n
< aDBColumns
.Count() ; ++n
)
1935 SwInsDBColumn
& rSet
= *aDBColumns
[ n
];
1936 for( USHORT m
= 0; m
< pNewData
->aDBColumns
.Count() ; ++m
)
1938 const SwInsDBColumn
& rGet
= *pNewData
->aDBColumns
[ m
];
1939 if(rGet
.sColumn
== rSet
.sColumn
)
1941 if( rGet
.bHasFmt
&& !rGet
.bIsDBFmt
)
1943 rSet
.bIsDBFmt
= FALSE
;
1944 rSet
.nUsrNumFmt
= rNFmtr
.GetEntryKey( rGet
.sUsrNumFmt
,
1945 rGet
.eUsrNumFmtLng
);
1946 if( NUMBERFORMAT_ENTRY_NOT_FOUND
== rSet
.nUsrNumFmt
)
1948 xub_StrLen nCheckPos
;
1950 rNFmtr
.PutEntry( (String
&)rGet
.sUsrNumFmt
, nCheckPos
, nType
,
1951 rSet
.nUsrNumFmt
, rGet
.eUsrNumFmtLng
);
1959 // steht der Cursor in einer Tabelle, darf NIE Tabelle auswaehlbar sein
1960 if( !aRbAsTable
.IsEnabled() && aRbAsTable
.IsChecked() )
1961 aRbAsField
.Check( TRUE
);