summaryrefslogtreecommitdiff
path: root/dbaccess/source/filter/migration/cfgimport.cxx
blob: f9e281c74e492043916ea91cebe75758cef9619a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
 /*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: cfgimport.cxx,v $
 * $Revision: 1.16.82.1 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"

#include "cfgimport.hxx"

#ifndef CFG_REGHELPER_HXX
#include "cfg_reghelper.hxx"
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
#include <com/sun/star/uno/XNamingService.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_
#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
#include <com/sun/star/sdbcx/XAppend.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
#include <com/sun/star/frame/XStorable.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XDOCUMENTDATASOURCE_HPP_
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
#endif
#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
#include <tools/urlobj.hxx>
#endif
#ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
#include <unotools/pathoptions.hxx>
#endif
#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
#include <com/sun/star/frame/XComponentLoader.hpp>
#endif
#ifndef DBACCESS_SHARED_CFGSTRINGS_HRC
#include "cfgstrings.hrc"
#endif
#ifndef _UNOTOOLS_UCBHELPER_HXX
#include <unotools/ucbhelper.hxx>
#endif
#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _SFX_DOCFILT_HACK_HXX
#include <sfx2/docfilt.hxx>
#endif
#ifndef _COMPHELPER_STREAMSECTION_HXX_
#include <comphelper/streamsection.hxx>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASINK_HPP_
#include <com/sun/star/io/XActiveDataSink.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOBJECTINPUTSTREAM_HPP_
#include <com/sun/star/io/XObjectInputStream.hpp>
#endif
#ifndef _COMPHELPER_BASIC_IO_HXX_
#include <comphelper/basicio.hxx>
#endif
#ifndef _COMPHELPER_SEQSTREAM_HXX
#include <comphelper/seqstream.hxx>
#endif
#ifndef _COM_SUN_STAR_SDB_XREPORTDOCUMENTSSUPPLIER_HPP_
#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XFORMDOCUMENTSSUPPLIER_HPP_
#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYER_HPP_
#include <com/sun/star/configuration/backend/XLayer.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XLOADABLE_HPP_
#include <com/sun/star/frame/XLoadable.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XTYPEDETECTION_HPP_
#include <com/sun/star/document/XTypeDetection.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
#include <com/sun/star/util/XCloseable.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEREPLACE_HPP_
#include <com/sun/star/container/XNameReplace.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
#include <com/sun/star/form/FormComponentType.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORMSSUPPLIER_HPP_
#include <com/sun/star/form/XFormsSupplier.hpp>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif


extern "C" void SAL_CALL createRegistryInfo_OCfgImport( )
{
    static ::dbacfg::OMultiInstanceAutoRegistration< ::dbacfg::OCfgImport > aAutoRegistration;
}

#define DATASOURCES             1
#define DATASOURCE              2
#define DATASOURCESETTINGS      3
#define TABLES                  4
#define QUERIES                 5
#define BOOKMARKS               6
#define DATASOURCESETTING       7
#define BOOKMARK                8
#define QUERY                   9
#define TABLE                   10
#define DATASETTINGS            11
#define COLUMNS                 12
#define COLUMN                  13
#define NO_PROP                 14
#define LOGINTIMEOUT            15

//--------------------------------------------------------------------------
using namespace dbacfg;
// {
    using namespace ::com::sun::star::util;
    using namespace ::com::sun::star::sdb;
    using namespace ::com::sun::star::sdbcx;
    using namespace ::com::sun::star::frame;
    using namespace ::com::sun::star::document;
    using namespace ::com::sun::star::io;
    using namespace ::com::sun::star::form;
    using namespace ::com::sun::star::drawing;
    using namespace ::com::sun::star::container;
    using namespace ::com::sun::star::beans;
    using namespace ::com::sun::star::task;
    using namespace ::com::sun::star::configuration::backend;
    using namespace ::utl;
    using namespace ::comphelper;

    void LoadTableWindows(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps);
    void LoadTableWindowData(const Reference<XObjectInputStream>& _rxIn,PropertyValue* _pValue);
    void LoadTableFields(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps);
    void LoadTableFieldDesc(const Reference< XObjectInputStream>& _rxIn,PropertyValue& _rProperty);
    sal_Bool isDocumentReport(const Reference< XMultiServiceFactory >& _xORB,const ::rtl::OUString& _sDocumentLocation);
// -------------
// - OCfgImport -
// -------------
DBG_NAME(OCfgImport)

OCfgImport::OCfgImport( const Reference< XMultiServiceFactory >& _rxMSF )
    :m_xORB( _rxMSF )
    ,m_bPropertyMayBeVoid(sal_True)
{
    DBG_CTOR(OCfgImport,NULL);

}

// -----------------------------------------------------------------------------

OCfgImport::~OCfgImport() throw()
{

    DBG_DTOR(OCfgImport,NULL);
}
// -----------------------------------------------------------------------------
IMPLEMENT_SERVICE_INFO1_STATIC( OCfgImport, "com.sun.star.comp.sdb.DataSourceMigration", "com.sun.star.sdb.DataSourceMigration")
// -----------------------------------------------------------------------------
// XInitialization
void SAL_CALL OCfgImport::initialize( const Sequence< Any >& _aArguments ) throw(Exception, RuntimeException)
{
    const Any* pIter = _aArguments.getConstArray();
    const Any* pEnd = pIter + _aArguments.getLength();
    Sequence<NamedValue> aOldConfigValues;
    NamedValue aValue;
    for(;pIter != pEnd;++pIter)
    {
        *pIter >>= aValue;
        if ( aValue.Name.equalsAscii("OldConfiguration") && (aValue.Value >>= aOldConfigValues) )
        {
            const NamedValue* configValues      = aOldConfigValues.getConstArray();
            const NamedValue* configValuesEnd   = configValues + aOldConfigValues.getLength();
            for(;configValues != configValuesEnd;++configValues)
            {
                if ( configValues->Name.equalsAscii("org.openoffice.Office.DataAccess") )
                {
                    configValues->Value >>= m_xLayer;
                    break;
                }
            }
            break;
        }
    }
}
// -----------------------------------------------------------------------------

void LoadTableWindows(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps)
{
    try
    {
        OStreamSection aSection(_rxIn.get());

        sal_Int32 nCount = 0;
        _rxIn >> nCount;
        if ( nCount > 0 )
        {
            PropertyValue *pViewIter = _rViewProps.getArray();
            PropertyValue *pEnd = pViewIter + _rViewProps.getLength();
            const static ::rtl::OUString s_sTables(RTL_CONSTASCII_USTRINGPARAM("Tables"));
            for (; pViewIter != pEnd && pViewIter->Name != s_sTables; ++pViewIter)
                ;

            if ( pViewIter == pEnd )
            {
                sal_Int32 nLen = _rViewProps.getLength();
                _rViewProps.realloc( nLen + 1 );
                pViewIter = _rViewProps.getArray() + nLen;
                pViewIter->Name = s_sTables;
            }

            Sequence<PropertyValue> aTables(nCount);
            PropertyValue *pIter = aTables.getArray();


            for(sal_Int32 i=0;i<nCount;++i,++pIter)
            {
                pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Table")) + ::rtl::OUString::valueOf(i+1);
                LoadTableWindowData(_rxIn,pIter);
            }
        }
    }
    catch(Exception&)
    {
    }
}
// -----------------------------------------------------------------------------
void LoadTableWindowData(const Reference<XObjectInputStream>& _rxIn,PropertyValue* _pValue)
{
    ::rtl::OUString sComposedName,aTableName,aWinName;
    sal_Int32 nX,nY,nWidth,nHeight;
    sal_Bool bShowAll;

    OStreamSection aSection(_rxIn.get());
    _rxIn >> sComposedName;
    _rxIn >> aTableName;
    _rxIn >> aWinName;
    _rxIn >> nX;
    _rxIn >> nY;
    _rxIn >> nWidth;
    _rxIn >> nHeight;
    _rxIn >> bShowAll;

    Sequence<PropertyValue> aWindow(8);
    sal_Int32 nPos = 0;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ComposedName"));
    aWindow[nPos++].Value <<= sComposedName;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableName"));
    aWindow[nPos++].Value <<= aTableName;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowName"));
    aWindow[nPos++].Value <<= aWinName;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowTop"));
    aWindow[nPos++].Value <<= nY;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowLeft"));
    aWindow[nPos++].Value <<= nX;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowWidth"));
    aWindow[nPos++].Value <<= nWidth;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WindowHeight"));
    aWindow[nPos++].Value <<= nHeight;
    aWindow[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowAll"));
    aWindow[nPos++].Value <<= bShowAll;

    _pValue->Value <<= aWindow;
}
// -----------------------------------------------------------------------------
void LoadTableFields(const Reference< XObjectInputStream>& _rxIn,Sequence<PropertyValue>& _rViewProps)
{
    LoadTableWindows(_rxIn,_rViewProps);
    OStreamSection aSection(_rxIn.get());
    PropertyValue *pIter = NULL;
    try
    {
        sal_Int32 nSplitPos,nVisibleRows;
        // some data
        _rxIn >> nSplitPos;
        _rxIn >> nVisibleRows;

        sal_Int32 nCount = 0;
        _rxIn >> nCount;

        sal_Int32 nLen = _rViewProps.getLength();
        _rViewProps.realloc( nLen + 2 + (nCount != 0 ? 1 : 0) );
        pIter = _rViewProps.getArray() + nLen;

        if ( nCount != 0 )
        {
            pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fields"));

            Sequence<PropertyValue> aFields(nCount);
            PropertyValue *pFieldsIter = aFields.getArray();
            // the fielddata
            for(sal_Int32 j=0;j<nCount;++j)
            {
                if ( aSection.available() )
                {
                    pFieldsIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Field")) + ::rtl::OUString::valueOf(j+1);
                    LoadTableFieldDesc(_rxIn,*pFieldsIter++);
                }
            }
            pIter->Value <<= aFields;
            ++pIter;
        }

        pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SplitterPosition"));
        pIter->Value <<= nSplitPos;
        ++pIter;
        pIter->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VisibleRows"));
        pIter->Value <<= nVisibleRows;
    }
    catch(Exception&)
    {
    }
}
// -----------------------------------------------------------------------------
void LoadTableFieldDesc(const Reference< XObjectInputStream>& _rxIn,PropertyValue& _rProperty)
{
    ::rtl::OUString     aTableName;
    ::rtl::OUString     aAliasName;     // table range
    ::rtl::OUString     aFieldName;     // column
    ::rtl::OUString     aFieldAlias;    // column alias
    ::rtl::OUString     aDatabaseName;  // qualifier or catalog
    ::rtl::OUString     aFunctionName;  // enth"alt den Funktionsnamen, nur wenn eFunctionType != FKT_NONE gesetzt

    sal_Int32           eDataType;
    sal_Int32           eFunctionType;
    sal_Int32           eFieldType;
    sal_Int32           eOrderDir;
    sal_Int32           nColWidth;
    sal_Bool            bGroupBy;
    sal_Bool            bVisible;

    OStreamSection aSection(_rxIn.get());
    _rxIn >> aTableName;
    _rxIn >> aAliasName;
    _rxIn >> aFieldName;
    _rxIn >> aFieldAlias;
    _rxIn >> aDatabaseName;
    _rxIn >> aFunctionName;
    _rxIn >> eDataType;
    _rxIn >> eFunctionType;
    _rxIn >> eFieldType;
    _rxIn >> eOrderDir;
    _rxIn >> nColWidth;
    _rxIn >> bGroupBy;
    _rxIn >> bVisible;

    Sequence<PropertyValue> aFieldDesc(13);
    sal_Int32 nPos = 0;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AliasName"));
    aFieldDesc[nPos++].Value <<= aAliasName;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableName"));
    aFieldDesc[nPos++].Value <<= aTableName;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldName"));
    aFieldDesc[nPos++].Value <<= aFieldName;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldAlias"));
    aFieldDesc[nPos++].Value <<= aFieldAlias;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseName"));
    aFieldDesc[nPos++].Value <<= aDatabaseName;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionName"));
    aFieldDesc[nPos++].Value <<= aFunctionName;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataType"));
    aFieldDesc[nPos++].Value <<= eDataType;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FunctionType"));
    aFieldDesc[nPos++].Value <<= (sal_Int32)eFunctionType;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldType"));
    aFieldDesc[nPos++].Value <<= (sal_Int32)eFieldType;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OrderDir"));
    aFieldDesc[nPos++].Value <<= (sal_Int32)eOrderDir;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColWidth"));
    aFieldDesc[nPos++].Value <<= nColWidth;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GroupBy"));
    aFieldDesc[nPos++].Value <<= bGroupBy;
    aFieldDesc[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Visible"));
    aFieldDesc[nPos++].Value <<= bVisible;

    _rProperty.Value <<= aFieldDesc;
}
// -----------------------------------------------------------------------------
void closeDocument(const Reference< XModel >& _xDocument)
{
    Reference< XCloseable > xCloseable( _xDocument, UNO_QUERY );
    if ( xCloseable.is() )
    {
        try
        {
            xCloseable->close( sal_True );
        }
        catch( Exception& )
        {
        }
    }
}
// -----------------------------------------------------------------------------
sal_Bool isDocumentReport(const Reference< XMultiServiceFactory >& _xORB,const ::rtl::OUString& _sDocumentLocation)
{
    sal_Bool bReport = sal_False;
    try
    {
        Reference< XModel > xDocument(_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument"))),UNO_QUERY);
        if ( xDocument.is() )
        {
            Reference< XLoadable > xLoadable( xDocument, UNO_QUERY );
            if ( xLoadable.is() )
            {
                Sequence< PropertyValue > aMedDescr(4);
                sal_Int32 nPos = 0;
                aMedDescr[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
                aMedDescr[nPos++].Value <<= sal_False;
                aMedDescr[nPos].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden"));
                aMedDescr[nPos++].Value <<= sal_False;
                aMedDescr[nPos].Name = PROPERTY_URL;
                aMedDescr[nPos++].Value <<= _sDocumentLocation;
                aMedDescr[nPos].Name = ::rtl::OUString::createFromAscii( "ReadOnly" );
                aMedDescr[nPos++].Value <<= sal_True;
                Reference< XTypeDetection > xTypeDetection(_xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection")) ),UNO_QUERY );

                if ( !xTypeDetection.is() )
                    throw RuntimeException(); // TODO

                // get TypeName
                ::rtl::OUString aTypeName = xTypeDetection->queryTypeByDescriptor( aMedDescr, sal_True );
                const PropertyValue* pIter = aMedDescr.getConstArray();
                const PropertyValue* pEnd     = pIter + aMedDescr.getLength();
                for( ; pIter != pEnd && !pIter->Name.equalsAscii( "FilterName" ); ++pIter)
                    ;
                if ( aTypeName.getLength() && pIter == pEnd )
                {
                    Reference<XNameAccess> xNameAccess( xTypeDetection, UNO_QUERY );
                    if ( xNameAccess.is() && xNameAccess->hasByName( aTypeName ) )
                    {
                        Sequence<PropertyValue> aTypes;
                        xNameAccess->getByName(aTypeName) >>= aTypes;
                        const PropertyValue* types      = aTypes.getConstArray();
                        const PropertyValue* typesEnd   = types + aTypes.getLength();
                        for( ; types != typesEnd && !types->Name.equalsAscii( "PreferredFilter" ) ; ++types)
                            ;
                        if ( types != typesEnd )
                        {
                            sal_Int32 nLen = aMedDescr.getLength();
                            aMedDescr.realloc(nLen+1);
                            aMedDescr[nLen].Value = types->Value;
                            aMedDescr[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName"));
                        }
                    }
                }
                try
                {
                    xLoadable->load(aMedDescr);

                    Reference< XEventsSupplier> xEventsSup(xDocument,UNO_QUERY);
                    Reference< XNameReplace> xEvents = xEventsSup.is() ? xEventsSup->getEvents() : Reference< XNameReplace>();
                    static const ::rtl::OUString s_sOnNew = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnNew"));
                    if ( xEvents.is() && xEvents->hasByName(s_sOnNew) )
                    {
                        Sequence<PropertyValue> aEventDesc;
                        if ( (xEvents->getByName(s_sOnNew) >>= aEventDesc ) && aEventDesc.getLength() )
                        {
                            ::rtl::OUString sScript;
                            const PropertyValue* events = aEventDesc.getConstArray();
                            const PropertyValue* eventsEnd = events + aEventDesc.getLength();
                            for( ; events != eventsEnd && !events->Name.equalsAscii( "Script" ) ; ++events)
                                ;
                            if ( events != eventsEnd && (events->Value >>= sScript) )
                                bReport = sScript.equalsAscii("service:com.sun.star.wizards.report.CallReportWizard?fill");
                        }
                    }
                    if ( !bReport )
                    {
                        sal_Bool bForm = sal_False;
                        Reference< XDrawPageSupplier> xDrawPageSup(xDocument,UNO_QUERY);
                        Reference< XFormsSupplier> xFormsSup(xDrawPageSup.is() ? xDrawPageSup->getDrawPage() : Reference< XDrawPage>(),UNO_QUERY);
                        Reference< XNameContainer> xForms(xFormsSup.is() ? xFormsSup->getForms() : Reference< XNameContainer>(),UNO_QUERY);
                        Sequence< ::rtl::OUString> aSeq = xForms.is() ? xForms->getElementNames() : Sequence< ::rtl::OUString>();
                        const ::rtl::OUString* elementNames = aSeq.getConstArray();
                        const ::rtl::OUString* elementNamesEnd = elementNames + aSeq.getLength();
                        for(;elementNames != elementNamesEnd && !bForm;++elementNames)
                        {
                            Reference< XNameContainer> xControls(xForms->getByName(*elementNames),UNO_QUERY);
                            Sequence< ::rtl::OUString> aControlSeq = xControls.is() ? xControls->getElementNames() : Sequence< ::rtl::OUString>();
                            const ::rtl::OUString* pControlIter = aControlSeq.getConstArray();
                            const ::rtl::OUString* pControlEnd  = pControlIter + aControlSeq.getLength();
                            for(;pControlIter != pControlEnd && !bForm;++pControlIter)
                            {
                                Reference<XPropertySet> xProp(xControls->getByName(*pControlIter),UNO_QUERY);
                                sal_Int16 nClassId = 0;
                                const static ::rtl::OUString s_sClassId = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
                                if ( xProp.is()
                                    && xProp->getPropertySetInfo().is()
                                    && xProp->getPropertySetInfo()->hasPropertyByName(s_sClassId)
                                    && (xProp->getPropertyValue(s_sClassId) >>= nClassId) )
                                {
                                    bForm = nClassId != FormComponentType::HIDDENCONTROL;
                                }
                            }
                        }
                        bReport = !bForm;
                    }
                }
                catch( Exception& )
                {
                    closeDocument(xDocument);
                }
            }
            closeDocument(xDocument);
        }
    }
    catch(Exception)
    {
        OSL_ENSURE(0,"isDocumentReport: catched exception!");
    }
    return bReport;
}
// -----------------------------------------------------------------------------
void OCfgImport::createDataSource(const ::rtl::OUString& _sName)
{
    SvtPathOptions aPathOptions;
    const String& rsWorkPath = aPathOptions.GetWorkPath();

    ::rtl::OUString sExtension;
    static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
    const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
    OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
    if ( pFilter )
    {
        String aRet = pFilter->GetDefaultExtension();
        while( aRet.SearchAndReplaceAscii( "*.", String() ) != STRING_NOTFOUND ) ;
        sExtension = aRet;
    }
    // then look for which of them settings are stored in the configuration
    ::rtl::OUString sFileName;
    try
    {
        m_xModel.set(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument"))),UNO_QUERY);

        if ( !m_xModel.is() )
            return;

        Reference<XOfficeDatabaseDocument> xOfficeDoc(m_xModel,UNO_QUERY);
        if ( xOfficeDoc.is() )
            m_xCurrentDS.set(xOfficeDoc->getDataSource(),UNO_QUERY);


        INetURLObject aURL(rsWorkPath,INetURLObject::WAS_ENCODED);
        aURL.insertName(_sName,false,INetURLObject::LAST_SEGMENT,true,INetURLObject::ENCODE_ALL);
        aURL.setExtension(sExtension);

        sFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);

        sal_Int32 i = 0;
        // create unique name
        while ( UCBContentHelper::IsDocument(sFileName) )
        {
            sFileName = _sName + ::rtl::OUString::valueOf(++i);
            aURL.setName(sFileName,INetURLObject::LAST_SEGMENT,true,INetURLObject::ENCODE_ALL);
            aURL.setExtension(sExtension);
            sFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
        }

        Sequence< PropertyValue > aArgs(1);
        aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" ) );
        aArgs[0].Value <<= sFileName;

        Reference< XLoadable > xLoad( m_xModel, UNO_QUERY_THROW );
        xLoad->load( aArgs );
        m_xModel->attachResource( sFileName, Sequence< PropertyValue >() );
    }
    catch(Exception&)
    {
        OSL_ENSURE(0,"Exception: convert");
        UCBContentHelper::Kill(sFileName);
    }
}
// -----------------------------------------------------------------------------
void OCfgImport::createObject(sal_Bool _bQuery ,const ::rtl::OUString& _sName)
{
    if ( !m_xCurrentObject.is() )
    {
        Sequence< Any > aArguments(1);
        PropertyValue aValue;
        // set as folder
        aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
        aValue.Value <<= _sName;
        aArguments[0] <<= aValue;
        m_xCurrentObject.set(m_xORB->createInstanceWithArguments(_bQuery ? SERVICE_SDB_COMMAND_DEFINITION : SERVICE_SDB_TABLEDEFINITION ,aArguments ),UNO_QUERY);
    }
}
// -----------------------------------------------------------------------------
void OCfgImport::setProperties(sal_Int16 _eType)
{
    if ( m_aValues[_eType].getLength() )
    {
        OSL_ENSURE(m_aProperties[_eType].getLength() == m_aValues[_eType].getLength(),"Count is not equal!");
        try
        {
            Reference< XMultiPropertySet >  xFormMultiSet;
            if ( _eType == COLUMN )
                xFormMultiSet.set(m_xCurrentColumn,UNO_QUERY);
            else if ( _eType == TABLE || _eType == QUERY )
                xFormMultiSet.set(m_xCurrentObject,UNO_QUERY);
            else if ( _eType == DATASOURCE )
                xFormMultiSet.set(m_xCurrentDS,UNO_QUERY);

            if ( xFormMultiSet.is() )
                xFormMultiSet->setPropertyValues(m_aProperties[_eType], m_aValues[_eType]);
        }
        catch(const Exception& e)
        {
            throw WrappedTargetException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Property could not be set.")),*this,makeAny(e));
        }
        m_aValues[_eType] = Sequence< Any>();
        m_aProperties[_eType] = Sequence< ::rtl::OUString>();
    }
}
// -----------------------------------------------------------------------------
Any SAL_CALL OCfgImport::execute( const Sequence< NamedValue >& /*Arguments*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
{
    m_xLayer->readData(this);
    return Any();
}
// -----------------------------------------------------------------------------
// XLayerHandler
void SAL_CALL OCfgImport::startLayer()
    throw(WrappedTargetException)
{
}
// -----------------------------------------------------------------------------

void SAL_CALL OCfgImport::endLayer()
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL OCfgImport::overrideNode(
        const ::rtl::OUString& aName,
        sal_Int16 aAttributes,
        sal_Bool /*bClear*/)
    throw(
        MalformedDataException,
        WrappedTargetException )
{
    addOrReplaceNode(aName,aAttributes);
}
// -----------------------------------------------------------------------------

void SAL_CALL OCfgImport::addOrReplaceNode(
        const ::rtl::OUString& aName,
        sal_Int16 /*aAttributes*/)
    throw(
        MalformedDataException,
        WrappedTargetException )
{
    if ( !m_aStack.empty() )
    {
        switch(m_aStack.top().second)
        {
            case DATASOURCES:
                m_sCurrentDataSourceName = aName;
                if ( m_sCurrentDataSourceName.equalsAscii("Bibliography") )
                {
                    Reference< XNameAccess > xDatabaseContext(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
                    if ( xDatabaseContext.is() && xDatabaseContext->hasByName(m_sCurrentDataSourceName) )
                    {
                        m_xCurrentDS.set(xDatabaseContext->getByName(m_sCurrentDataSourceName),UNO_QUERY);
                        Reference<XDocumentDataSource> xDocumentDataSource(m_xCurrentDS,UNO_QUERY);
                        if ( xDocumentDataSource.is() )
                            m_xModel.set(xDocumentDataSource->getDatabaseDocument(),UNO_QUERY);
                    }
                }
                if ( !m_xCurrentDS.is() )
                    createDataSource(m_sCurrentDataSourceName);

                m_aStack.push(TElementStack::value_type(aName,DATASOURCE));
                break;
            case DATASOURCESETTINGS:
                {
                    PropertyValue aValue;
                    aValue.Name = aName;
                    m_aDataSourceSettings.push_back(aValue);
                    m_aStack.push(TElementStack::value_type(aName,DATASOURCESETTING));
                }
                break;
            case TABLES:
                m_aStack.push(TElementStack::value_type(aName,TABLE));
                createObject(sal_False,aName);
                break;
            case QUERIES:
                m_aStack.push(TElementStack::value_type(aName,QUERY));
                createObject(sal_True,aName);
                break;
            case COLUMNS:
                if ( !m_xCurrentColumn.is() )
                {
                    Reference<XColumnsSupplier> xSupplier(m_xCurrentObject,UNO_QUERY);
                    if ( xSupplier.is() )
                    {
                        Reference<XDataDescriptorFactory> xFact(xSupplier->getColumns(),UNO_QUERY);

                        m_xCurrentColumn = ( xFact.is() ? xFact->createDataDescriptor() : Reference<XPropertySet>());
                        if ( m_xCurrentColumn.is() )
                            m_xCurrentColumn->setPropertyValue(PROPERTY_NAME,makeAny(aName));
                    }
                }
                m_aStack.push(TElementStack::value_type(aName,COLUMN));
                break;
            case BOOKMARKS:
                m_aStack.push(TElementStack::value_type(aName,BOOKMARK));
                break;
        }
    }
    /*if ( aName.equalsAscii("org.openoffice.Office.DataAccess") )
        m_aStack.push(TElementStack::value_type(aName,0));
    else*/
    if ( aName.equalsAscii("DataSources") )
        m_aStack.push(TElementStack::value_type(aName,DATASOURCES));
    else if ( aName.equalsAscii("DataSourceSettings") )
        m_aStack.push(TElementStack::value_type(aName,DATASOURCESETTINGS));
    else if ( aName.equalsAscii("Tables") )
        m_aStack.push(TElementStack::value_type(aName,TABLES));
    else if ( aName.equalsAscii("Queries") )
        m_aStack.push(TElementStack::value_type(aName,QUERIES));
    else if ( aName == CONFIGKEY_DBLINK_BOOKMARKS )
        m_aStack.push(TElementStack::value_type(aName,BOOKMARKS));
    else if ( aName == CONFIGKEY_SETTINGS )
        m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
    else if ( aName.equalsAscii("Font") )
        m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
    else if ( aName == CONFIGKEY_QRYDESCR_COLUMNS )
        m_aStack.push(TElementStack::value_type(aName,COLUMNS));
    else if ( aName.equalsAscii("Font") )
        m_aStack.push(TElementStack::value_type(aName,DATASETTINGS));
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::addOrReplaceNodeFromTemplate(
        const ::rtl::OUString& /*aName*/,
        const TemplateIdentifier& /*aTemplate*/,
        sal_Int16 /*aAttributes*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::endNode()
    throw(
        MalformedDataException,
        WrappedTargetException )
{
    if ( !m_aStack.empty() )
    {
        sal_Int16 nElementType = m_aStack.top().second;
        ::rtl::OUString sName = m_aStack.top().first;
        m_aStack.pop();

        switch(nElementType)
        {
            case DATASOURCE:
                {
                    setProperties(nElementType);
                    Reference<XStorable> xStr(m_xModel,UNO_QUERY);
                    if ( xStr.is() )
                    {
                        xStr->store();
                        xStr = NULL;
                    }
                    // register the new datbase document

                    if ( !m_sCurrentDataSourceName.equalsAscii("Bibliography") )
                    {
                        // create unique name
                        Reference< XNameAccess > xDatabaseContext(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
                        if ( xDatabaseContext.is() )
                        {
                            sal_Int32 i = 0;
                            ::rtl::OUString sDataSourceName = m_sCurrentDataSourceName;
                            while ( xDatabaseContext->hasByName( sDataSourceName ) )
                            {
                                sDataSourceName = m_sCurrentDataSourceName + ::rtl::OUString::valueOf(++i);
                            }
                            Reference< XNamingService>(xDatabaseContext,UNO_QUERY)->registerObject(sDataSourceName,m_xCurrentDS);
                        }
                    }
                    ::comphelper::disposeComponent(m_xModel);
                    m_xCurrentDS = NULL;
                }
                break;
            case DATASOURCESETTINGS:
                OSL_ENSURE(m_xCurrentDS.is(),"Data Source is NULL!");
                {
                    PropertyValue* pSettings = m_aDataSourceSettings.empty() ? NULL : &m_aDataSourceSettings[0];
                    m_xCurrentDS->setPropertyValue(PROPERTY_INFO,makeAny(Sequence< PropertyValue >(pSettings, m_aDataSourceSettings.size())));
                }
                break;
            case TABLE:
                {
                    setProperties(nElementType);
                    Reference<XTablesSupplier> xSupplier(m_xCurrentDS,UNO_QUERY);
                    Reference<XNameContainer> xTables(xSupplier->getTables(),UNO_QUERY);
                    ::rtl::OUString sTableName;
                    m_xCurrentObject->getPropertyValue(PROPERTY_NAME) >>= sTableName;
                    if ( !xTables->hasByName( sTableName ) )
                        xTables->insertByName( sTableName, makeAny( m_xCurrentObject ) );
                    m_xCurrentObject = NULL;
                }
                break;
            case QUERY:
                {
                    setProperties(nElementType);
                    Reference<XQueryDefinitionsSupplier> xQueriesSupplier(m_xCurrentDS,UNO_QUERY);
                    Reference<XNameContainer> xQueries(xQueriesSupplier->getQueryDefinitions(),UNO_QUERY);
                    xQueries->insertByName(sName,makeAny(m_xCurrentObject));
                    m_xCurrentObject = NULL;
                }
                break;
            case BOOKMARK:
                try
                {
                    if ( !UCBContentHelper::IsDocument(m_sDocumentLocation) )
                        break;

                    sal_Bool bForm = sal_True;
                    bForm = !isDocumentReport(m_xORB,m_sDocumentLocation);
                    Reference<XNameAccess> xNames;
                    if ( bForm )
                    {
                        Reference<XFormDocumentsSupplier> xSup(m_xModel,UNO_QUERY);
                        if ( xSup.is() )
                            xNames = xSup->getFormDocuments();
                    }
                    else
                    {
                        Reference<XReportDocumentsSupplier> xSup(m_xModel,UNO_QUERY);
                        if ( xSup.is() )
                            xNames = xSup->getReportDocuments();
                    }

                    if ( xNames.is() && m_sBookmarkName.getLength() )
                    {
                        ::rtl::OUString sServiceName(SERVICE_SDB_DOCUMENTDEFINITION);
                        Sequence< Any > aArguments(3);
                        PropertyValue aValue;
                        // set as folder
                        aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
                        aValue.Value <<= m_sBookmarkName;
                        aArguments[0] <<= aValue;
                        //parent
                        aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
                        aValue.Value <<= xNames;
                        aArguments[1] <<= aValue;

                        aValue.Name = PROPERTY_URL;
                        aValue.Value <<= m_sDocumentLocation;
                        aArguments[2] <<= aValue;

                        Reference<XMultiServiceFactory> xORB(xNames,UNO_QUERY);
                        if ( xORB.is() )
                        {
                            Reference<XInterface> xComponent = xORB->createInstanceWithArguments(SERVICE_SDB_DOCUMENTDEFINITION,aArguments);
                            Reference<XNameContainer> xNameContainer(xNames,UNO_QUERY);
                            if ( xNameContainer.is() )
                                xNameContainer->insertByName(m_sBookmarkName,makeAny(xComponent));
                        }
                    }
                }
                catch(Exception&)
                {
                    OSL_ENSURE(0,"convertLinks: Exception catched!");
                }
                m_sBookmarkName = ::rtl::OUString();
                m_sDocumentLocation = ::rtl::OUString();
                break;
            case COLUMN:
                if ( m_xCurrentColumn.is() )
                {
                    setProperties(nElementType);
                    Reference<XColumnsSupplier> xSupplier(m_xCurrentObject,UNO_QUERY);
                    Reference<XAppend> xAppend(xSupplier->getColumns(),UNO_QUERY);
                    if ( xAppend.is() )
                        xAppend->appendByDescriptor(m_xCurrentColumn);
                    m_xCurrentColumn = NULL;
                }
                break;
        }
    }
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::dropNode(
        const ::rtl::OUString& /*aName*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::overrideProperty(
        const ::rtl::OUString& aName,
        sal_Int16 /*aAttributes*/,
        const Type& /*aType*/,
        sal_Bool /*bClear*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
    m_bPropertyMayBeVoid = sal_True;
    if ( !m_aStack.empty() )
    {
        switch(m_aStack.top().second)
        {
            case DATASOURCE:
                {
                    m_bPropertyMayBeVoid = sal_False;
                    ::rtl::OUString sProp;
                    if ( aName == CONFIGKEY_DBLINK_CONNECTURL )
                        sProp = PROPERTY_URL;
                    else if ( aName == CONFIGKEY_DBLINK_USER )
                        sProp = PROPERTY_USER;
                    else if ( aName == CONFIGKEY_DBLINK_TABLEFILTER )
                        sProp = PROPERTY_TABLEFILTER;
                    else if ( aName == CONFIGKEY_DBLINK_TABLETYEFILTER )
                        sProp = PROPERTY_TABLETYPEFILTER;
                    else if ( aName == CONFIGKEY_DBLINK_PASSWORDREQUIRED )
                        sProp = PROPERTY_ISPASSWORDREQUIRED;
                    else if ( aName == CONFIGKEY_DBLINK_SUPPRESSVERSIONCL )
                        sProp = PROPERTY_SUPPRESSVERSIONCL;
                    else if ( aName == CONFIGKEY_LAYOUTINFORMATION )
                        sProp = PROPERTY_LAYOUTINFORMATION;

                    if ( sProp.getLength() )
                    {
                        if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
                            m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
                        sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
                        m_aProperties[m_aStack.top().second].realloc(nPos+1);
                        m_aProperties[m_aStack.top().second][nPos] = sProp;
                    }
                    else if ( aName == CONFIGKEY_DBLINK_LOGINTIMEOUT )
                        m_aStack.push(TElementStack::value_type(aName,LOGINTIMEOUT));
                    else
                        m_aStack.push(TElementStack::value_type(aName,NO_PROP));
                }
                break;
            case QUERY:
                {
                    m_bPropertyMayBeVoid = sal_False;
                    ::rtl::OUString sProp;
                    if ( aName == CONFIGKEY_QRYDESCR_COMMAND )
                        sProp = PROPERTY_COMMAND;
                    else if ( aName == CONFIGKEY_QRYDESCR_ESCAPE_PROCESSING )
                        sProp = PROPERTY_ESCAPE_PROCESSING;
                    else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_TABLENAME )
                        sProp = PROPERTY_UPDATE_TABLENAME;
                    else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_SCHEMANAME )
                        sProp = PROPERTY_UPDATE_SCHEMANAME;
                    else if ( aName == CONFIGKEY_QRYDESCR_UPDATE_CATALOGNAME )
                        sProp = PROPERTY_UPDATE_CATALOGNAME;
                    else if ( aName == CONFIGKEY_LAYOUTINFORMATION )
                        sProp = PROPERTY_LAYOUTINFORMATION;

                    if ( sProp.getLength() )
                    {
                        if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
                            m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
                        sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
                        m_aProperties[m_aStack.top().second].realloc(nPos+1);
                        m_aProperties[m_aStack.top().second][nPos] = sProp;
                    }
                    else
                        m_aStack.push(TElementStack::value_type(aName,NO_PROP));
                }
                break;
            case DATASETTINGS:
                {
                    m_bPropertyMayBeVoid = sal_False;
                    ::rtl::OUString sProp;
                    if (      aName == CONFIGKEY_DEFSET_FILTER ) sProp = PROPERTY_FILTER;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_NAME ) sProp = PROPERTY_FONTNAME;
                    else if ( aName == CONFIGKEY_DEFSET_ORDER ) sProp = PROPERTY_ORDER;
                    else if ( aName == CONFIGKEY_DEFSET_APPLYFILTER ) sProp = PROPERTY_APPLYFILTER;
                    else if ( aName == CONFIGKEY_DEFSET_ROW_HEIGHT ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_ROW_HEIGHT; }
                    else if ( aName == CONFIGKEY_DEFSET_TEXTCOLOR ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_TEXTCOLOR; }
                    else if ( aName == CONFIGKEY_DEFSET_FONT_UNDERLINECOLOR ) { m_bPropertyMayBeVoid = true; sProp = PROPERTY_TEXTLINECOLOR; }
                    else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTEREMPHASIS ) sProp = PROPERTY_TEXTEMPHASIS;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTERRELIEF ) sProp = PROPERTY_TEXTRELIEF;
                        // font
                    else if ( aName == CONFIGKEY_DEFSET_FONT_HEIGHT ) sProp = PROPERTY_FONTHEIGHT;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_WIDTH ) sProp = PROPERTY_FONTWIDTH;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_STYLENAME ) sProp = PROPERTY_FONTSTYLENAME;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_FAMILY ) sProp = PROPERTY_FONTFAMILY;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_CHARSET ) sProp = PROPERTY_FONTCHARSET;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_PITCH ) sProp = PROPERTY_FONTPITCH;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_CHARACTERWIDTH ) sProp = PROPERTY_FONTCHARWIDTH;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_WEIGHT ) sProp = PROPERTY_FONTWEIGHT;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_UNDERLINE ) sProp = PROPERTY_FONTUNDERLINE;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_STRIKEOUT ) sProp = PROPERTY_FONTSTRIKEOUT;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_ORIENTATION ) sProp = PROPERTY_FONTORIENTATION;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_KERNING ) sProp = PROPERTY_FONTKERNING;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_WORDLINEMODE ) sProp = PROPERTY_FONTWORDLINEMODE;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_TYPE ) sProp = PROPERTY_FONTTYPE;
                    else if ( aName == CONFIGKEY_DEFSET_FONT_SLANT ) sProp = PROPERTY_FONTSLANT;

                    if ( sProp.getLength() )
                    {
                        if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
                            m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
                        sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
                        m_aProperties[m_aStack.top().second].realloc(nPos+1);
                        m_aProperties[m_aStack.top().second][nPos] = sProp;
                    }
                    else
                        m_aStack.push(TElementStack::value_type(aName,NO_PROP));
                }
                break;
            case COLUMN:
                {
                    ::rtl::OUString sProp;
                    m_bPropertyMayBeVoid = sal_False;
                    if ( aName == CONFIGKEY_COLUMN_ALIGNMENT ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_ALIGN;
                    } else if ( aName == CONFIGKEY_COLUMN_WIDTH ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_WIDTH;
                    } else if ( aName == CONFIGKEY_COLUMN_RELPOSITION ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_RELATIVEPOSITION;
                    } else if ( aName == CONFIGKEY_COLUMN_HIDDEN ) {
                        sProp = PROPERTY_HIDDEN;
                    } else if ( aName == CONFIGKEY_COLUMN_HELPTEXT ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_HELPTEXT;
                    } else if ( aName == CONFIGKEY_COLUMN_CONTROLDEFAULT ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_CONTROLDEFAULT;
                    } else if ( aName == CONFIGKEY_COLUMN_NUMBERFORMAT ) {
                        m_bPropertyMayBeVoid = true;
                        sProp = PROPERTY_NUMBERFORMAT;
                    }


                    if ( sProp.getLength() )
                    {
                        if ( m_aProperties.find(m_aStack.top().second) == m_aProperties.end() )
                            m_aProperties.insert(::std::map< sal_Int16 ,Sequence< ::rtl::OUString> >::value_type(m_aStack.top().second,Sequence< ::rtl::OUString>()));
                        sal_Int32 nPos = m_aProperties[m_aStack.top().second].getLength();
                        m_aProperties[m_aStack.top().second].realloc(nPos+1);
                        m_aProperties[m_aStack.top().second][nPos] = sProp;
                    }
                    else
                        m_aStack.push(TElementStack::value_type(aName,NO_PROP));
                }
                break;
            case BOOKMARK:
                break;
        }
    }
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::setPropertyValue(
        const Any& aValue )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
    if ( !m_aStack.empty() )
    {
        switch(m_aStack.top().second)
        {
            case LOGINTIMEOUT:
                {
                    Reference< ::com::sun::star::sdbc::XDataSource> xDataSource(m_xCurrentDS,UNO_QUERY);
                    sal_Int32 nTimeOut = 0;
                    aValue >>= nTimeOut;
                    if ( xDataSource.is() && nTimeOut >= 0 )
                        xDataSource->setLoginTimeout(nTimeOut);
                    m_aStack.pop();
                }
                break;
            case DATASOURCESETTING:
                OSL_ENSURE(!m_aDataSourceSettings.empty(),"Settings are emtpy!");
                if ( aValue.hasValue() )
                    m_aDataSourceSettings.rbegin()->Value = aValue;
                else
                    m_aDataSourceSettings.pop_back();
                break;
            case BOOKMARK:
                aValue >>= m_sDocumentLocation;
                break;
            case NO_PROP:
                m_aStack.pop();
                break;
            default:
                OSL_ENSURE(m_aProperties[m_aStack.top().second].getLength(),"Properties are zero!");
                if ( m_aProperties[m_aStack.top().second].getLength() )
                {
                    if ( m_aProperties[m_aStack.top().second][m_aProperties[m_aStack.top().second].getLength()-1] != PROPERTY_LAYOUTINFORMATION )
                    {
                        if ( !m_bPropertyMayBeVoid && !aValue.hasValue() )
                        {
                            m_aProperties[m_aStack.top().second].realloc(m_aProperties[m_aStack.top().second].getLength()-1);
                        }
                        else
                        {
                            if ( m_aValues.find(m_aStack.top().second) == m_aValues.end() )
                                m_aValues.insert(::std::map< sal_Int16 ,Sequence< Any> >::value_type(m_aStack.top().second,Sequence< Any>()));
                            sal_Int32 nPos = m_aValues[m_aStack.top().second].getLength();
                            m_aValues[m_aStack.top().second].realloc(nPos+1);
                            m_aValues[m_aStack.top().second][nPos] = aValue;
                        }
                    }
                    else
                    {
                        try
                        {
                            Sequence< sal_Int8 > aInputSequence;
                            aValue >>= aInputSequence;
                            if ( m_aValues.find(m_aStack.top().second) == m_aValues.end() )
                                m_aValues.insert(::std::map< sal_Int16 ,Sequence< Any> >::value_type(m_aStack.top().second,Sequence< Any>()));
                            sal_Int32 nPos = m_aValues[m_aStack.top().second].getLength();
                            m_aValues[m_aStack.top().second].realloc(nPos+1);
                            Sequence< PropertyValue > aLayout;
                            if ( aInputSequence.getLength() )
                            {
                                Reference< XInputStream>       xInStreamHelper = new SequenceInputStream(aInputSequence);;  // used for wrapping sequence to xinput
                                Reference< XObjectInputStream> xInStream = Reference< XObjectInputStream >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")),UNO_QUERY);
                                Reference< XInputStream> xMarkInStream = Reference< XInputStream >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")),UNO_QUERY);
                                Reference< XActiveDataSink >(xMarkInStream,UNO_QUERY)->setInputStream(xInStreamHelper);
                                Reference< XActiveDataSink >   xInDataSource(xInStream, UNO_QUERY);
                                OSL_ENSURE(xInDataSource.is(),"Couldn't create com.sun.star.io.ObjectInputStream!");
                                xInDataSource->setInputStream(xMarkInStream);

                                if ( DATASOURCE == m_aStack.top().second )
                                    LoadTableWindows(xInStream,aLayout);
                                else if ( QUERY == m_aStack.top().second )
                                    LoadTableFields(xInStream,aLayout);
                            }
                            m_aValues[m_aStack.top().second][nPos] <<= aLayout;
                        }
                        catch(const Exception& e)
                        {
                            throw WrappedTargetException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Property could not be set.")),*this,makeAny(e));
                        }
                    }
                }
                break;
        }
    }
}
// -----------------------------------------------------------------------------

void SAL_CALL OCfgImport::setPropertyValueForLocale(
        const Any& /*aValue*/,
        const ::rtl::OUString& /*aLocale*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::endProperty()
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::addProperty(
        const rtl::OUString& /*aName*/,
        sal_Int16 /*aAttributes*/,
        const Type& /*aType*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------

void SAL_CALL  OCfgImport::addPropertyWithValue(
        const rtl::OUString& /*aName*/,
        sal_Int16 /*aAttributes*/,
        const Any& /*aValue*/ )
    throw(
        MalformedDataException,
        WrappedTargetException )
{
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// }// dbacfg
// -----------------------------------------------------------------------------