summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r--dbaccess/source/ui/app/AppController.cxx3012
-rw-r--r--dbaccess/source/ui/app/AppController.hxx578
-rw-r--r--dbaccess/source/ui/app/AppControllerDnD.cxx818
-rw-r--r--dbaccess/source/ui/app/AppControllerGen.cxx846
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.cxx1407
-rw-r--r--dbaccess/source/ui/app/AppDetailPageHelper.hxx374
-rw-r--r--dbaccess/source/ui/app/AppDetailView.cxx955
-rw-r--r--dbaccess/source/ui/app/AppDetailView.hxx380
-rw-r--r--dbaccess/source/ui/app/AppIconControl.cxx120
-rw-r--r--dbaccess/source/ui/app/AppIconControl.hxx60
-rw-r--r--dbaccess/source/ui/app/AppSwapWindow.cxx215
-rw-r--r--dbaccess/source/ui/app/AppSwapWindow.hxx106
-rw-r--r--dbaccess/source/ui/app/AppTitleWindow.cxx182
-rw-r--r--dbaccess/source/ui/app/AppTitleWindow.hxx85
-rw-r--r--dbaccess/source/ui/app/AppView.cxx601
-rw-r--r--dbaccess/source/ui/app/AppView.hxx316
-rw-r--r--dbaccess/source/ui/app/IApplicationController.hxx103
-rw-r--r--dbaccess/source/ui/app/app.src478
-rw-r--r--dbaccess/source/ui/app/dbu_app.hrc78
-rw-r--r--dbaccess/source/ui/app/makefile.mk69
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.cxx614
-rw-r--r--dbaccess/source/ui/app/subcomponentmanager.hxx139
-rw-r--r--dbaccess/source/ui/app/window_layout.txt31
-rw-r--r--dbaccess/source/ui/browser/AsyncronousLink.cxx109
-rw-r--r--dbaccess/source/ui/browser/bcommon.src34
-rw-r--r--dbaccess/source/ui/browser/brwctrlr.cxx3074
-rw-r--r--dbaccess/source/ui/browser/brwview.cxx374
-rw-r--r--dbaccess/source/ui/browser/dataview.cxx226
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx265
-rw-r--r--dbaccess/source/ui/browser/dbloader.cxx361
-rw-r--r--dbaccess/source/ui/browser/dbtreemodel.cxx52
-rw-r--r--dbaccess/source/ui/browser/dbtreemodel.hxx72
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.cxx125
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.hxx80
-rw-r--r--dbaccess/source/ui/browser/dsEntriesNoExp.cxx269
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx298
-rw-r--r--dbaccess/source/ui/browser/exsrcbrw.cxx480
-rw-r--r--dbaccess/source/ui/browser/formadapter.cxx1777
-rw-r--r--dbaccess/source/ui/browser/genericcontroller.cxx1636
-rw-r--r--dbaccess/source/ui/browser/makefile.mk71
-rw-r--r--dbaccess/source/ui/browser/sbabrw.src200
-rw-r--r--dbaccess/source/ui/browser/sbagrid.cxx1660
-rw-r--r--dbaccess/source/ui/browser/sbagrid.src140
-rw-r--r--dbaccess/source/ui/browser/sbamultiplex.cxx111
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx3914
-rw-r--r--dbaccess/source/ui/control/ColumnControlWindow.cxx187
-rw-r--r--dbaccess/source/ui/control/FieldDescControl.cxx1941
-rw-r--r--dbaccess/source/ui/control/RelationControl.cxx717
-rw-r--r--dbaccess/source/ui/control/ScrollHelper.cxx79
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx100
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.cxx500
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.src70
-rw-r--r--dbaccess/source/ui/control/VertSplitView.cxx219
-rw-r--r--dbaccess/source/ui/control/charsetlistbox.cxx122
-rw-r--r--dbaccess/source/ui/control/curledit.cxx157
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx725
-rw-r--r--dbaccess/source/ui/control/listviewitems.cxx84
-rw-r--r--dbaccess/source/ui/control/makefile.mk78
-rw-r--r--dbaccess/source/ui/control/marktree.cxx242
-rw-r--r--dbaccess/source/ui/control/opendoccontrols.cxx335
-rw-r--r--dbaccess/source/ui/control/sqledit.cxx227
-rw-r--r--dbaccess/source/ui/control/statusbarontroller.cxx51
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx685
-rw-r--r--dbaccess/source/ui/control/tabletree.hrc37
-rw-r--r--dbaccess/source/ui/control/tabletree.src91
-rw-r--r--dbaccess/source/ui/control/toolboxcontroller.cxx279
-rw-r--r--dbaccess/source/ui/control/undosqledit.cxx48
-rw-r--r--dbaccess/source/ui/control/undosqledit.src35
-rw-r--r--dbaccess/source/ui/dlg/AdabasPage.hrc50
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.cxx305
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.hrc52
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.hxx86
-rw-r--r--dbaccess/source/ui/dlg/AdabasStat.src208
-rw-r--r--dbaccess/source/ui/dlg/AutoControls.src97
-rw-r--r--dbaccess/source/ui/dlg/AutoControls_tmpl.hrc517
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.cxx340
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.hrc50
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.src159
-rw-r--r--dbaccess/source/ui/dlg/ConnectionHelper.cxx905
-rw-r--r--dbaccess/source/ui/dlg/ConnectionHelper.hxx134
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.cxx378
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.hrc59
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.hxx109
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPage.src190
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPageSetup.cxx244
-rw-r--r--dbaccess/source/ui/dlg/ConnectionPageSetup.hxx102
-rw-r--r--dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx978
-rw-r--r--dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx344
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.cxx1222
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.hxx196
-rw-r--r--dbaccess/source/ui/dlg/DriverSettings.cxx119
-rw-r--r--dbaccess/source/ui/dlg/DriverSettings.hxx112
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.cxx270
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.hrc54
-rw-r--r--dbaccess/source/ui/dlg/RelationDlg.src179
-rw-r--r--dbaccess/source/ui/dlg/TablesSingleDlg.cxx140
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.cxx549
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.hxx124
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.cxx354
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.hrc59
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.hxx92
-rw-r--r--dbaccess/source/ui/dlg/UserAdmin.src218
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.cxx213
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.hrc33
-rw-r--r--dbaccess/source/ui/dlg/UserAdminDlg.src58
-rw-r--r--dbaccess/source/ui/dlg/admincontrols.cxx314
-rwxr-xr-xdbaccess/source/ui/dlg/admincontrols.hrc49
-rw-r--r--dbaccess/source/ui/dlg/admincontrols.hxx85
-rw-r--r--dbaccess/source/ui/dlg/admincontrols.src131
-rw-r--r--dbaccess/source/ui/dlg/adminpages.cxx356
-rw-r--r--dbaccess/source/ui/dlg/adminpages.hxx293
-rw-r--r--dbaccess/source/ui/dlg/adodatalinks.cxx212
-rw-r--r--dbaccess/source/ui/dlg/adodatalinks.hxx37
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.cxx532
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.hrc47
-rw-r--r--dbaccess/source/ui/dlg/adtabdlg.src108
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.cxx604
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.hrc77
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.hxx158
-rw-r--r--dbaccess/source/ui/dlg/advancedsettings.src386
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.cxx517
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.hrc111
-rw-r--r--dbaccess/source/ui/dlg/dbadmin.src807
-rw-r--r--dbaccess/source/ui/dlg/dbadmin2.src154
-rw-r--r--dbaccess/source/ui/dlg/dbadminsetup.hrc135
-rw-r--r--dbaccess/source/ui/dlg/dbadminsetup.src656
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.cxx554
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.hrc26
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.hxx156
-rw-r--r--dbaccess/source/ui/dlg/dbfindex.src197
-rw-r--r--dbaccess/source/ui/dlg/dbwiz.cxx386
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx1139
-rw-r--r--dbaccess/source/ui/dlg/detailpages.cxx1128
-rw-r--r--dbaccess/source/ui/dlg/detailpages.hxx373
-rw-r--r--dbaccess/source/ui/dlg/directsql.cxx351
-rw-r--r--dbaccess/source/ui/dlg/directsql.hrc43
-rw-r--r--dbaccess/source/ui/dlg/directsql.src139
-rw-r--r--dbaccess/source/ui/dlg/dlgattr.cxx112
-rw-r--r--dbaccess/source/ui/dlg/dlgattr.src91
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.cxx448
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.hrc53
-rw-r--r--dbaccess/source/ui/dlg/dlgsave.src143
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.cxx124
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.hrc39
-rw-r--r--dbaccess/source/ui/dlg/dlgsize.src151
-rw-r--r--dbaccess/source/ui/dlg/dsnItem.hxx71
-rw-r--r--dbaccess/source/ui/dlg/dsselect.cxx279
-rw-r--r--dbaccess/source/ui/dlg/dsselect.hrc41
-rw-r--r--dbaccess/source/ui/dlg/dsselect.hxx97
-rw-r--r--dbaccess/source/ui/dlg/dsselect.src109
-rw-r--r--dbaccess/source/ui/dlg/finteraction.cxx85
-rw-r--r--dbaccess/source/ui/dlg/finteraction.hxx73
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx638
-rw-r--r--dbaccess/source/ui/dlg/generalpage.hxx170
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.cxx925
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.hrc49
-rw-r--r--dbaccess/source/ui/dlg/indexdialog.src235
-rw-r--r--dbaccess/source/ui/dlg/indexfieldscontrol.cxx509
-rw-r--r--dbaccess/source/ui/dlg/makefile.mk154
-rw-r--r--dbaccess/source/ui/dlg/odbcconfig.cxx395
-rw-r--r--dbaccess/source/ui/dlg/odbcconfig.hxx142
-rw-r--r--dbaccess/source/ui/dlg/optionalboolitem.cxx79
-rw-r--r--dbaccess/source/ui/dlg/optionalboolitem.hxx70
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.cxx427
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.hrc46
-rw-r--r--dbaccess/source/ui/dlg/paramdialog.src102
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.cxx873
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.hrc64
-rw-r--r--dbaccess/source/ui/dlg/queryfilter.src220
-rw-r--r--dbaccess/source/ui/dlg/queryorder.cxx310
-rw-r--r--dbaccess/source/ui/dlg/queryorder.hrc57
-rw-r--r--dbaccess/source/ui/dlg/queryorder.src180
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.cxx779
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.hrc50
-rw-r--r--dbaccess/source/ui/dlg/sqlmessage.src145
-rw-r--r--dbaccess/source/ui/dlg/tablespage.cxx631
-rw-r--r--dbaccess/source/ui/dlg/tablespage.hxx123
-rw-r--r--dbaccess/source/ui/dlg/textconnectionsettings.cxx109
-rw-r--r--dbaccess/source/ui/dlg/textconnectionsettings.src61
-rw-r--r--dbaccess/source/ui/imagelists/dbimagelists.src169
-rw-r--r--dbaccess/source/ui/imagelists/makefile.mk49
-rw-r--r--dbaccess/source/ui/inc/AccessibleBaseIFace.hxx55
-rw-r--r--dbaccess/source/ui/inc/AppElementType.hxx68
-rw-r--r--dbaccess/source/ui/inc/CollectionView.hxx90
-rw-r--r--dbaccess/source/ui/inc/ColumnControlWindow.hxx85
-rw-r--r--dbaccess/source/ui/inc/ConnectionLine.hxx112
-rw-r--r--dbaccess/source/ui/inc/ConnectionLineAccess.hxx110
-rw-r--r--dbaccess/source/ui/inc/ConnectionLineData.hxx102
-rw-r--r--dbaccess/source/ui/inc/DExport.hxx188
-rw-r--r--dbaccess/source/ui/inc/FieldControls.hxx191
-rw-r--r--dbaccess/source/ui/inc/FieldDescControl.hxx234
-rw-r--r--dbaccess/source/ui/inc/FieldDescriptions.hxx125
-rw-r--r--dbaccess/source/ui/inc/GeneralUndo.hxx57
-rw-r--r--dbaccess/source/ui/inc/HtmlReader.hxx92
-rw-r--r--dbaccess/source/ui/inc/IClipBoardTest.hxx50
-rw-r--r--dbaccess/source/ui/inc/IItemSetHelper.hxx72
-rw-r--r--dbaccess/source/ui/inc/IUpdateHelper.hxx54
-rw-r--r--dbaccess/source/ui/inc/JAccess.hxx89
-rw-r--r--dbaccess/source/ui/inc/JoinController.hxx178
-rw-r--r--dbaccess/source/ui/inc/JoinDesignView.hxx87
-rw-r--r--dbaccess/source/ui/inc/JoinExchange.hxx89
-rw-r--r--dbaccess/source/ui/inc/JoinTableView.hxx326
-rw-r--r--dbaccess/source/ui/inc/QEnumTypes.hxx92
-rw-r--r--dbaccess/source/ui/inc/QueryDesignView.hxx177
-rw-r--r--dbaccess/source/ui/inc/QueryTableView.hxx145
-rw-r--r--dbaccess/source/ui/inc/QueryTextView.hxx74
-rw-r--r--dbaccess/source/ui/inc/QueryViewSwitch.hxx106
-rw-r--r--dbaccess/source/ui/inc/RTableConnectionData.hxx102
-rw-r--r--dbaccess/source/ui/inc/RefFunctor.hxx56
-rw-r--r--dbaccess/source/ui/inc/RelControliFace.hxx61
-rw-r--r--dbaccess/source/ui/inc/RelationControl.hrc34
-rw-r--r--dbaccess/source/ui/inc/RelationControl.hxx105
-rw-r--r--dbaccess/source/ui/inc/RelationController.hxx99
-rw-r--r--dbaccess/source/ui/inc/RelationDesignView.hxx68
-rw-r--r--dbaccess/source/ui/inc/RelationDlg.hxx115
-rw-r--r--dbaccess/source/ui/inc/RelationTableView.hxx84
-rw-r--r--dbaccess/source/ui/inc/RtfReader.hxx80
-rw-r--r--dbaccess/source/ui/inc/ScrollHelper.hxx77
-rw-r--r--dbaccess/source/ui/inc/SqlNameEdit.hxx110
-rw-r--r--dbaccess/source/ui/inc/TableConnection.hxx111
-rw-r--r--dbaccess/source/ui/inc/TableConnectionData.hxx114
-rw-r--r--dbaccess/source/ui/inc/TableController.hxx157
-rw-r--r--dbaccess/source/ui/inc/TableCopyHelper.hxx200
-rw-r--r--dbaccess/source/ui/inc/TableDesignControl.hxx102
-rw-r--r--dbaccess/source/ui/inc/TableDesignHelpBar.hxx75
-rw-r--r--dbaccess/source/ui/inc/TableDesignView.hxx123
-rw-r--r--dbaccess/source/ui/inc/TableFieldDescription.hxx163
-rw-r--r--dbaccess/source/ui/inc/TableGrantCtrl.hxx117
-rw-r--r--dbaccess/source/ui/inc/TableRow.hxx90
-rw-r--r--dbaccess/source/ui/inc/TableRowExchange.hxx53
-rw-r--r--dbaccess/source/ui/inc/TableWindow.hxx211
-rw-r--r--dbaccess/source/ui/inc/TableWindowAccess.hxx121
-rw-r--r--dbaccess/source/ui/inc/TableWindowData.hxx106
-rw-r--r--dbaccess/source/ui/inc/TableWindowListBox.hxx111
-rw-r--r--dbaccess/source/ui/inc/TableWindowTitle.hxx59
-rw-r--r--dbaccess/source/ui/inc/TablesSingleDlg.hxx87
-rw-r--r--dbaccess/source/ui/inc/TokenWriter.hxx257
-rw-r--r--dbaccess/source/ui/inc/TypeInfo.hxx146
-rw-r--r--dbaccess/source/ui/inc/UITools.hxx456
-rw-r--r--dbaccess/source/ui/inc/UserAdminDlg.hxx93
-rw-r--r--dbaccess/source/ui/inc/VertSplitView.hxx60
-rw-r--r--dbaccess/source/ui/inc/WCPage.hxx108
-rw-r--r--dbaccess/source/ui/inc/WColumnSelect.hxx105
-rw-r--r--dbaccess/source/ui/inc/WCopyTable.hxx423
-rw-r--r--dbaccess/source/ui/inc/WExtendPages.hxx86
-rw-r--r--dbaccess/source/ui/inc/WNameMatch.hxx102
-rw-r--r--dbaccess/source/ui/inc/WTabPage.hxx60
-rw-r--r--dbaccess/source/ui/inc/WTypeSelect.hxx144
-rw-r--r--dbaccess/source/ui/inc/adtabdlg.hxx127
-rw-r--r--dbaccess/source/ui/inc/advancedsettingsdlg.hxx97
-rw-r--r--dbaccess/source/ui/inc/asyncmodaldialog.hxx67
-rw-r--r--dbaccess/source/ui/inc/browserids.hxx121
-rw-r--r--dbaccess/source/ui/inc/brwctrlr.hxx372
-rw-r--r--dbaccess/source/ui/inc/brwview.hxx117
-rw-r--r--dbaccess/source/ui/inc/callbacks.hxx129
-rw-r--r--dbaccess/source/ui/inc/charsetlistbox.hxx68
-rw-r--r--dbaccess/source/ui/inc/charsets.hxx144
-rw-r--r--dbaccess/source/ui/inc/commontypes.hxx58
-rw-r--r--dbaccess/source/ui/inc/curledit.hxx89
-rw-r--r--dbaccess/source/ui/inc/databaseobjectview.hxx264
-rw-r--r--dbaccess/source/ui/inc/datasourceconnector.hxx96
-rw-r--r--dbaccess/source/ui/inc/datasourcemap.hxx266
-rw-r--r--dbaccess/source/ui/inc/dbadmin.hxx139
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx99
-rw-r--r--dbaccess/source/ui/inc/dbtreelistbox.hxx170
-rw-r--r--dbaccess/source/ui/inc/dbu_brw.hrc55
-rw-r--r--dbaccess/source/ui/inc/dbu_control.hrc56
-rw-r--r--dbaccess/source/ui/inc/dbu_dlg.hrc135
-rw-r--r--dbaccess/source/ui/inc/dbu_misc.hrc62
-rw-r--r--dbaccess/source/ui/inc/dbu_qry.hrc96
-rw-r--r--dbaccess/source/ui/inc/dbu_rel.hrc50
-rw-r--r--dbaccess/source/ui/inc/dbu_resource.hrc395
-rw-r--r--dbaccess/source/ui/inc/dbu_tbl.hrc99
-rw-r--r--dbaccess/source/ui/inc/dbu_uno.hrc56
-rw-r--r--dbaccess/source/ui/inc/dbwiz.hxx135
-rw-r--r--dbaccess/source/ui/inc/dbwizsetup.hxx197
-rw-r--r--dbaccess/source/ui/inc/defaultobjectnamecheck.hxx146
-rw-r--r--dbaccess/source/ui/inc/directsql.hxx141
-rw-r--r--dbaccess/source/ui/inc/dlgattr.hrc37
-rw-r--r--dbaccess/source/ui/inc/dlgattr.hxx64
-rw-r--r--dbaccess/source/ui/inc/dlgsave.hxx99
-rw-r--r--dbaccess/source/ui/inc/dlgsize.hxx72
-rw-r--r--dbaccess/source/ui/inc/dsitems.hxx108
-rw-r--r--dbaccess/source/ui/inc/dsmeta.hxx146
-rw-r--r--dbaccess/source/ui/inc/exsrcbrw.hxx115
-rw-r--r--dbaccess/source/ui/inc/formadapter.hxx449
-rw-r--r--dbaccess/source/ui/inc/imageprovider.hxx158
-rw-r--r--dbaccess/source/ui/inc/indexcollection.hxx119
-rw-r--r--dbaccess/source/ui/inc/indexdialog.hxx185
-rw-r--r--dbaccess/source/ui/inc/indexes.hxx105
-rw-r--r--dbaccess/source/ui/inc/indexfieldscontrol.hxx112
-rw-r--r--dbaccess/source/ui/inc/linkeddocuments.hxx141
-rw-r--r--dbaccess/source/ui/inc/listviewitems.hxx70
-rw-r--r--dbaccess/source/ui/inc/localresaccess.hxx62
-rw-r--r--dbaccess/source/ui/inc/makefile.mk43
-rw-r--r--dbaccess/source/ui/inc/marktree.hxx86
-rw-r--r--dbaccess/source/ui/inc/moduledbu.hxx106
-rw-r--r--dbaccess/source/ui/inc/objectnamecheck.hxx77
-rw-r--r--dbaccess/source/ui/inc/opendoccontrols.hxx95
-rw-r--r--dbaccess/source/ui/inc/paramdialog.hxx126
-rw-r--r--dbaccess/source/ui/inc/propertysetitem.hxx69
-rw-r--r--dbaccess/source/ui/inc/propertystorage.hxx97
-rw-r--r--dbaccess/source/ui/inc/querycontainerwindow.hxx126
-rw-r--r--dbaccess/source/ui/inc/querycontroller.hxx261
-rw-r--r--dbaccess/source/ui/inc/queryfilter.hxx149
-rw-r--r--dbaccess/source/ui/inc/queryorder.hxx130
-rw-r--r--dbaccess/source/ui/inc/queryview.hxx60
-rw-r--r--dbaccess/source/ui/inc/sbagrid.hrc107
-rw-r--r--dbaccess/source/ui/inc/sbagrid.hxx345
-rw-r--r--dbaccess/source/ui/inc/sbamultiplex.hxx438
-rw-r--r--dbaccess/source/ui/inc/singledoccontroller.hxx93
-rw-r--r--dbaccess/source/ui/inc/sqledit.hxx91
-rw-r--r--dbaccess/source/ui/inc/sqlmessage.hxx137
-rw-r--r--dbaccess/source/ui/inc/statusbarontroller.hxx54
-rw-r--r--dbaccess/source/ui/inc/stringlistitem.hxx68
-rw-r--r--dbaccess/source/ui/inc/tabletree.hxx200
-rw-r--r--dbaccess/source/ui/inc/textconnectionsettings.hxx82
-rw-r--r--dbaccess/source/ui/inc/toolbox_tmpl.hrc100
-rw-r--r--dbaccess/source/ui/inc/toolboxcontroller.hxx75
-rw-r--r--dbaccess/source/ui/inc/undosqledit.hxx59
-rw-r--r--dbaccess/source/ui/inc/unoadmin.hxx81
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx500
-rw-r--r--dbaccess/source/ui/inc/unosqlmessage.hxx90
-rw-r--r--dbaccess/source/ui/misc/DExport.cxx904
-rw-r--r--dbaccess/source/ui/misc/HtmlReader.cxx593
-rw-r--r--dbaccess/source/ui/misc/ModuleHelper.cxx44
-rw-r--r--dbaccess/source/ui/misc/RowSetDrop.cxx275
-rw-r--r--dbaccess/source/ui/misc/RtfReader.cxx375
-rw-r--r--dbaccess/source/ui/misc/TableCopyHelper.cxx344
-rw-r--r--dbaccess/source/ui/misc/TokenWriter.cxx1111
-rw-r--r--dbaccess/source/ui/misc/ToolBoxHelper.cxx125
-rw-r--r--dbaccess/source/ui/misc/UITools.cxx1697
-rw-r--r--dbaccess/source/ui/misc/UpdateHelperImpl.hxx151
-rw-r--r--dbaccess/source/ui/misc/WCPage.cxx383
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx426
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx1693
-rw-r--r--dbaccess/source/ui/misc/WExtendPages.cxx86
-rw-r--r--dbaccess/source/ui/misc/WNameMatch.cxx412
-rw-r--r--dbaccess/source/ui/misc/WTypeSelect.cxx483
-rw-r--r--dbaccess/source/ui/misc/WizardPages.hrc81
-rw-r--r--dbaccess/source/ui/misc/WizardPages.src592
-rw-r--r--dbaccess/source/ui/misc/asyncmodaldialog.cxx115
-rw-r--r--dbaccess/source/ui/misc/charsets.cxx186
-rw-r--r--dbaccess/source/ui/misc/controllerframe.cxx441
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx346
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx235
-rw-r--r--dbaccess/source/ui/misc/dbaundomanager.cxx394
-rw-r--r--dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx672
-rw-r--r--dbaccess/source/ui/misc/dbumiscres.hrc62
-rw-r--r--dbaccess/source/ui/misc/dbumiscres.src100
-rw-r--r--dbaccess/source/ui/misc/defaultobjectnamecheck.cxx206
-rw-r--r--dbaccess/source/ui/misc/dsmeta.cxx217
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx251
-rw-r--r--dbaccess/source/ui/misc/indexcollection.cxx402
-rw-r--r--dbaccess/source/ui/misc/linkeddocuments.cxx411
-rw-r--r--dbaccess/source/ui/misc/makefile.mk88
-rw-r--r--dbaccess/source/ui/misc/moduledbu.cxx140
-rw-r--r--dbaccess/source/ui/misc/propertysetitem.cxx86
-rw-r--r--dbaccess/source/ui/misc/propertystorage.cxx139
-rw-r--r--dbaccess/source/ui/misc/singledoccontroller.cxx204
-rw-r--r--dbaccess/source/ui/misc/stringlistitem.cxx87
-rw-r--r--dbaccess/source/ui/misc/uiservices.cxx139
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLine.cxx385
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx251
-rw-r--r--dbaccess/source/ui/querydesign/ConnectionLineData.cxx104
-rw-r--r--dbaccess/source/ui/querydesign/JAccess.cxx131
-rw-r--r--dbaccess/source/ui/querydesign/JoinController.cxx475
-rw-r--r--dbaccess/source/ui/querydesign/JoinDesignView.cxx128
-rw-r--r--dbaccess/source/ui/querydesign/JoinExchange.cxx179
-rw-r--r--dbaccess/source/ui/querydesign/JoinTableView.cxx1717
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnection.cxx99
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnection.hxx59
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnectionData.cxx169
-rw-r--r--dbaccess/source/ui/querydesign/QTableConnectionData.hxx91
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindow.cxx241
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindow.hxx94
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindowData.cxx60
-rw-r--r--dbaccess/source/ui/querydesign/QTableWindowData.hxx55
-rw-r--r--dbaccess/source/ui/querydesign/Query.hrc35
-rw-r--r--dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx63
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx161
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx50
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx3217
-rw-r--r--dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx52
-rw-r--r--dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx68
-rw-r--r--dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx86
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx139
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx59
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx66
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx137
-rw-r--r--dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx87
-rw-r--r--dbaccess/source/ui/querydesign/QueryTableView.cxx1035
-rw-r--r--dbaccess/source/ui/querydesign/QueryTextView.cxx153
-rw-r--r--dbaccess/source/ui/querydesign/QueryViewSwitch.cxx344
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx2834
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx347
-rw-r--r--dbaccess/source/ui/querydesign/TableConnection.cxx246
-rw-r--r--dbaccess/source/ui/querydesign/TableConnectionData.cxx198
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldDescription.cxx242
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldInfo.cxx57
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldInfo.hxx55
-rw-r--r--dbaccess/source/ui/querydesign/TableWindow.cxx803
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowAccess.cxx294
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowData.cxx156
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowListBox.cxx402
-rw-r--r--dbaccess/source/ui/querydesign/TableWindowTitle.cxx210
-rw-r--r--dbaccess/source/ui/querydesign/class.jpgbin0 -> 224242 bytes
-rw-r--r--dbaccess/source/ui/querydesign/makefile.mk89
-rw-r--r--dbaccess/source/ui/querydesign/query.src426
-rw-r--r--dbaccess/source/ui/querydesign/querycontainerwindow.cxx265
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx1868
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.cxx375
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.hrc61
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.hxx108
-rw-r--r--dbaccess/source/ui/querydesign/querydlg.src195
-rw-r--r--dbaccess/source/ui/querydesign/queryview.cxx58
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnection.cxx150
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnection.hxx57
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnectionData.cxx466
-rw-r--r--dbaccess/source/ui/relationdesign/RTableWindow.hxx51
-rw-r--r--dbaccess/source/ui/relationdesign/RelationController.cxx612
-rw-r--r--dbaccess/source/ui/relationdesign/RelationDesignView.cxx115
-rw-r--r--dbaccess/source/ui/relationdesign/RelationTableView.cxx446
-rw-r--r--dbaccess/source/ui/relationdesign/makefile.mk58
-rw-r--r--dbaccess/source/ui/relationdesign/relation.src83
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx182
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx86
-rw-r--r--dbaccess/source/ui/tabledesign/FieldDescriptions.cxx682
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.cxx1944
-rw-r--r--dbaccess/source/ui/tabledesign/TEditControl.hxx222
-rw-r--r--dbaccess/source/ui/tabledesign/TableController.cxx1600
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignControl.cxx224
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx125
-rw-r--r--dbaccess/source/ui/tabledesign/TableDesignView.cxx375
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.cxx156
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldControl.hxx72
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx320
-rw-r--r--dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx111
-rw-r--r--dbaccess/source/ui/tabledesign/TableRow.cxx229
-rw-r--r--dbaccess/source/ui/tabledesign/TableRowExchange.cxx84
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.cxx476
-rw-r--r--dbaccess/source/ui/tabledesign/TableUndo.hxx172
-rw-r--r--dbaccess/source/ui/tabledesign/makefile.mk65
-rw-r--r--dbaccess/source/ui/tabledesign/table.src466
-rw-r--r--dbaccess/source/ui/uno/AdabasSettingsDlg.cxx129
-rw-r--r--dbaccess/source/ui/uno/AdabasSettingsDlg.hxx82
-rw-r--r--dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx162
-rw-r--r--dbaccess/source/ui/uno/ColumnControl.cxx142
-rw-r--r--dbaccess/source/ui/uno/ColumnControl.hxx56
-rw-r--r--dbaccess/source/ui/uno/ColumnModel.cxx168
-rw-r--r--dbaccess/source/ui/uno/ColumnModel.hxx115
-rw-r--r--dbaccess/source/ui/uno/ColumnPeer.cxx165
-rw-r--r--dbaccess/source/ui/uno/ColumnPeer.hxx64
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlg.cxx128
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlg.hxx82
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx152
-rw-r--r--dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx86
-rw-r--r--dbaccess/source/ui/uno/TableFilterDlg.cxx129
-rw-r--r--dbaccess/source/ui/uno/TableFilterDlg.hxx82
-rw-r--r--dbaccess/source/ui/uno/UserSettingsDlg.cxx129
-rw-r--r--dbaccess/source/ui/uno/UserSettingsDlg.hxx82
-rw-r--r--dbaccess/source/ui/uno/admindlg.cxx135
-rw-r--r--dbaccess/source/ui/uno/admindlg.hxx82
-rw-r--r--dbaccess/source/ui/uno/composerdialogs.cxx211
-rw-r--r--dbaccess/source/ui/uno/composerdialogs.hxx146
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx1643
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.src83
-rw-r--r--dbaccess/source/ui/uno/dbinteraction.cxx379
-rw-r--r--dbaccess/source/ui/uno/dbinteraction.hxx188
-rw-r--r--dbaccess/source/ui/uno/dbinteraction.src41
-rw-r--r--dbaccess/source/ui/uno/makefile.mk76
-rw-r--r--dbaccess/source/ui/uno/textconnectionsettings_uno.cxx265
-rw-r--r--dbaccess/source/ui/uno/unoDirectSql.cxx138
-rw-r--r--dbaccess/source/ui/uno/unoDirectSql.hxx82
-rw-r--r--dbaccess/source/ui/uno/unoadmin.cxx125
-rw-r--r--dbaccess/source/ui/uno/unosqlmessage.cxx166
476 files changed, 130570 insertions, 0 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
new file mode 100644
index 000000000000..98852706f5d1
--- /dev/null
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -0,0 +1,3012 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppController.hxx"
+#include "dbustrings.hrc"
+#include "advancedsettingsdlg.hxx"
+#include "subcomponentmanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/XAlterView.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XRename.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/container/XHierarchicalName.hpp>
+/** === end UNO includes === **/
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <tools/string.hxx>
+
+#include <svl/urihelper.hxx>
+#include <svl/filenotation.hxx>
+#include <svtools/svtreebx.hxx>
+#include <svtools/transfer.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svtools/svlbitm.hxx>
+#include <svtools/insdlg.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/string.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/componentcontext.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <unotools/pathoptions.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/internaloptions.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <unotools/historyoptions.hxx>
+
+#include <sfx2/mailmodelapi.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/QuerySaveDocument.hxx>
+
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+
+#include <svx/dbaexchange.hxx>
+#include <svx/dbaobjectex.hxx>
+#include <svx/svxdlg.hxx>
+
+#include <osl/mutex.hxx>
+#include "AppView.hxx"
+#include "browserids.hxx"
+#include "dbu_reghelper.hxx"
+#include "dbu_app.hrc"
+#include "defaultobjectnamecheck.hxx"
+#include "databaseobjectview.hxx"
+#include "listviewitems.hxx"
+#include "AppDetailView.hxx"
+#include "linkeddocuments.hxx"
+#include "sqlmessage.hxx"
+#include "UITools.hxx"
+#include "dsntypes.hxx"
+#include "dbaccess_helpid.hrc"
+#include "dlgsave.hxx"
+#include "dbaccess_slotid.hrc"
+
+#include <algorithm>
+#include <functional>
+
+#include <boost/noncopyable.hpp>
+
+extern "C" void SAL_CALL createRegistryInfo_ODBApplication()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OApplicationController > aAutoRegistration;
+}
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+using namespace ::dbtools;
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::task;
+using ::com::sun::star::document::XEmbeddedScripts;
+using ::com::sun::star::document::XDocumentEventBroadcaster;
+using ::com::sun::star::document::DocumentEvent;
+using ::com::sun::star::sdb::application::NamedDatabaseObject;
+
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OApplicationController::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OApplicationController::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString(SERVICE_SDB_APPLICATIONCONTROLLER);
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.application.DefaultViewController"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL OApplicationController::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OApplicationController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OApplicationController(_rxFactory));
+}
+// -----------------------------------------------------------------------------
+
+struct XContainerFunctor : public ::std::unary_function< OApplicationController::TContainerVector::value_type , bool>
+{
+ Reference<XContainerListener> m_xContainerListener;
+ XContainerFunctor( const Reference<XContainerListener>& _xContainerListener)
+ : m_xContainerListener(_xContainerListener){}
+
+ bool operator() (const OApplicationController::TContainerVector::value_type& lhs) const
+ {
+ if ( lhs.is() )
+ lhs->removeContainerListener(m_xContainerListener);
+ return true;
+ }
+};
+
+//====================================================================
+//= OApplicationController
+//====================================================================
+class SelectionNotifier : public ::boost::noncopyable
+{
+private:
+ ::cppu::OInterfaceContainerHelper m_aSelectionListeners;
+ ::cppu::OWeakObject& m_rContext;
+ sal_Int32 m_nSelectionNestingLevel;
+
+public:
+ SelectionNotifier( ::osl::Mutex& _rMutex, ::cppu::OWeakObject& _rContext )
+ :m_aSelectionListeners( _rMutex )
+ ,m_rContext( _rContext )
+ ,m_nSelectionNestingLevel( 0 )
+ {
+ }
+
+ void addListener( const Reference< XSelectionChangeListener >& _Listener )
+ {
+ m_aSelectionListeners.addInterface( _Listener );
+ }
+
+ void removeListener( const Reference< XSelectionChangeListener >& _Listener )
+ {
+ m_aSelectionListeners.removeInterface( _Listener );
+ }
+
+ void disposing()
+ {
+ EventObject aEvent( m_rContext );
+ m_aSelectionListeners.disposeAndClear( aEvent );
+ }
+
+ ~SelectionNotifier()
+ {
+ }
+
+ struct SelectionGuardAccess { friend class SelectionGuard; private: SelectionGuardAccess() { } };
+
+ /** enters a block which modifies the selection of our owner.
+
+ Can be called multiple times, the only important thing is to call leaveSelection
+ equally often.
+ */
+ void enterSelection( SelectionGuardAccess )
+ {
+ ++m_nSelectionNestingLevel;
+ }
+
+ /** leaves a block which modifies the selection of our owner
+
+ Must be paired with enterSelection calls.
+
+ When the last block is left, i.e. the last leaveSelection call is made on the current stack,
+ then our SelectionChangeListeners are notified
+ */
+ void leaveSelection( SelectionGuardAccess )
+ {
+ if ( --m_nSelectionNestingLevel == 0 )
+ {
+ EventObject aEvent( m_rContext );
+ m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent );
+ }
+ }
+};
+
+class SelectionGuard : public ::boost::noncopyable
+{
+public:
+ SelectionGuard( SelectionNotifier& _rNotifier )
+ :m_rNotifier( _rNotifier )
+ {
+ m_rNotifier.enterSelection( SelectionNotifier::SelectionGuardAccess() );
+ }
+
+ ~SelectionGuard()
+ {
+ m_rNotifier.leaveSelection( SelectionNotifier::SelectionGuardAccess() );
+ }
+
+private:
+ SelectionNotifier& m_rNotifier;
+};
+
+//====================================================================
+//= OApplicationController
+//====================================================================
+DBG_NAME(OApplicationController)
+//--------------------------------------------------------------------
+OApplicationController::OApplicationController(const Reference< XMultiServiceFactory >& _rxORB)
+ :OApplicationController_CBASE( _rxORB )
+ ,m_aContextMenuInterceptors( getMutex() )
+ ,m_pSubComponentManager( new SubComponentManager( *this, getSharedMutex() ) )
+ ,m_aTypeCollection(_rxORB)
+ ,m_aTableCopyHelper(this)
+ ,m_pClipbordNotifier(NULL)
+ ,m_nAsyncDrop(0)
+ ,m_aControllerConnectedEvent( LINK( this, OApplicationController, OnFirstControllerConnected ) )
+ ,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) )
+ ,m_ePreviewMode(E_PREVIEWNONE)
+ ,m_eCurrentType(E_NONE)
+ ,m_bNeedToReconnect(sal_False)
+ ,m_bSuspended( sal_False )
+ ,m_pSelectionNotifier( new SelectionNotifier( getMutex(), *this ) )
+{
+ DBG_CTOR(OApplicationController,NULL);
+}
+//------------------------------------------------------------------------------
+OApplicationController::~OApplicationController()
+{
+ if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ OSL_FAIL("Please check who doesn't dispose this component!");
+ // increment ref count to prevent double call of Dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+ ::std::auto_ptr< Window> aTemp( getView() );
+ clearView();
+
+ DBG_DTOR(OApplicationController,NULL);
+}
+//--------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
+IMPLEMENT_FORWARD_XINTERFACE2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
+// -----------------------------------------------------------------------------
+void OApplicationController::disconnect()
+{
+ if ( m_xDataSourceConnection.is() )
+ stopConnectionListening( m_xDataSourceConnection );
+
+ try
+ {
+ // temporary (hopefully!) hack for #i55274#
+ Reference< XFlushable > xFlush( m_xDataSourceConnection, UNO_QUERY );
+ if ( xFlush.is() && m_xMetaData.is() && !m_xMetaData->isReadOnly() )
+ xFlush->flush();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xDataSourceConnection.clear();
+ m_xMetaData.clear();
+
+ InvalidateAll();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL OApplicationController::disposing()
+{
+ m_aControllerConnectedEvent.CancelCall();
+
+ ::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
+ m_aCurrentContainers.clear();
+ m_pSubComponentManager->disposing();
+ m_pSelectionNotifier->disposing();
+
+ if ( getView() )
+ {
+ getContainer()->showPreview(NULL);
+ m_pClipbordNotifier->ClearCallbackLink();
+ m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
+ m_pClipbordNotifier->release();
+ m_pClipbordNotifier = NULL;
+ }
+
+ disconnect();
+ try
+ {
+ Reference < XFrame > xFrame;
+ attachFrame( xFrame );
+
+ if ( m_xDataSource.is() )
+ {
+ m_xDataSource->removePropertyChangeListener(::rtl::OUString(), this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_INFO, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_TABLEFILTER, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
+ m_xDataSource->removePropertyChangeListener(PROPERTY_USER, this);
+ // otherwise we may delete our datasource twice
+ Reference<XPropertySet> xProp = m_xDataSource;
+ m_xDataSource = NULL;
+ }
+
+ Reference< XModifyBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
+
+ if ( m_xModel.is() )
+ {
+ ::rtl::OUString sUrl = m_xModel->getURL();
+ if ( sUrl.getLength() )
+ {
+ ::comphelper::NamedValueCollection aArgs( m_xModel->getArgs() );
+ if ( true == aArgs.getOrDefault( "PickListEntry", true ) )
+ {
+ ::rtl::OUString aFilter;
+ INetURLObject aURL( m_xModel->getURL() );
+ const SfxFilter* pFilter = getStandardDatabaseFilter();
+ if ( pFilter )
+ aFilter = pFilter->GetFilterName();
+
+ // add to svtool history options
+ SvtHistoryOptions().AppendItem( ePICKLIST,
+ aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
+ aFilter,
+ getStrippedDatabaseName(),
+ ::rtl::OUString() );
+ }
+ }
+
+ m_xModel->disconnectController( this );
+
+ m_xModel.clear();
+ }
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ clearView();
+ OApplicationController_CBASE::disposing(); // here the m_refCount must be equal 5
+}
+
+//--------------------------------------------------------------------
+sal_Bool OApplicationController::Construct(Window* _pParent)
+{
+ setView( * new OApplicationView( _pParent, getORB(), *this, m_ePreviewMode ) );
+ getView()->SetUniqueId(UID_APP_VIEW);
+
+ // late construction
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ getContainer()->Construct();
+ bSuccess = sal_True;
+ }
+ catch(SQLException&)
+ {
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("OApplicationController::Construct : the construction of UnoDataBrowserView failed !");
+ }
+
+ if ( !bSuccess )
+ {
+ ::std::auto_ptr< Window> aTemp( getView() );
+ clearView();
+ return sal_False;
+ }
+
+ // now that we have a view we can create the clipboard listener
+ m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
+ m_aSystemClipboard.StartClipboardListening( );
+
+ m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OApplicationController, OnClipboardChanged ) );
+ m_pClipbordNotifier->acquire();
+ m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
+
+ OApplicationController_CBASE::Construct( _pParent );
+ getView()->Show();
+
+ return sal_True;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL OApplicationController::disposing(const EventObject& _rSource) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
+ if ( xCon.is() )
+ {
+ OSL_ENSURE( m_xDataSourceConnection == xCon,
+ "OApplicationController::disposing: which connection does this come from?" );
+
+ if ( getContainer() && getContainer()->getElementType() == E_TABLE )
+ getContainer()->clearPages();
+ if ( m_xDataSourceConnection == xCon )
+ {
+ m_xMetaData.clear();
+ m_xDataSourceConnection.clear();
+ }
+ }
+ else if ( _rSource.Source == m_xModel )
+ {
+ m_xModel.clear();
+ }
+ else if ( _rSource.Source == m_xDataSource )
+ {
+ m_xDataSource = NULL;
+ }
+ else
+ {
+ Reference<XContainer> xContainer( _rSource.Source, UNO_QUERY );
+ if ( xContainer.is() )
+ {
+ TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer);
+ if ( aFind != m_aCurrentContainers.end() )
+ m_aCurrentContainers.erase(aFind);
+ }
+ OApplicationController_CBASE::disposing( _rSource );
+ }
+}
+//--------------------------------------------------------------------
+sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+{
+ // notify the OnPrepareViewClosing event (before locking any mutex)
+ Reference< XDocumentEventBroadcaster > xBroadcaster( m_xModel, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->notifyDocumentEvent(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnPrepareViewClosing" ) ),
+ this,
+ Any()
+ );
+ }
+
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( getView() && getView()->IsInModalMode() )
+ return sal_False;
+
+ sal_Bool bCanSuspend = sal_True;
+
+ if ( m_bSuspended != bSuspend )
+ {
+ if ( bSuspend && !closeSubComponents() )
+ return sal_False;
+
+ Reference<XModifiable> xModi(m_xModel,UNO_QUERY);
+ Reference<XStorable> xStor(getModel(),UNO_QUERY);
+
+ if ( bSuspend
+ && xStor.is()
+ && !xStor->isReadonly()
+ && ( xModi.is()
+ && xModi->isModified()
+ )
+ )
+ {
+ switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
+ {
+ case RET_YES:
+ Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
+ bCanSuspend = !xModi->isModified();
+ // when we save the document this must be false else some press cancel
+ break;
+ case RET_CANCEL:
+ bCanSuspend = sal_False;
+ default:
+ break;
+ }
+ }
+ }
+
+ if ( bCanSuspend )
+ m_bSuspended = bSuspend;
+
+ return bCanSuspend;
+}
+// -----------------------------------------------------------------------------
+FeatureState OApplicationController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ aReturn.bEnabled = sal_False;
+ // check this first
+ if ( !getContainer() || m_bReadOnly )
+ return aReturn;
+
+ try
+ {
+ switch (_nId)
+ {
+ case SID_OPENURL:
+ aReturn.bEnabled = sal_True;
+ if ( m_xModel.is() )
+ aReturn.sTitle = m_xModel->getURL();
+ break;
+ case ID_BROWSER_COPY:
+ {
+ sal_Int32 nCount = getContainer()->getSelectionCount();
+ aReturn.bEnabled = nCount >= 1;
+ if ( aReturn.bEnabled && nCount == 1 && getContainer()->getElementType() == E_TABLE )
+ aReturn.bEnabled = getContainer()->isALeafSelected();
+ }
+ break;
+ case ID_BROWSER_CUT:
+ aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() >= 1;
+ aReturn.bEnabled = aReturn.bEnabled && ( (ID_BROWSER_CUT == _nId && getContainer()->getElementType() == E_TABLE) ? getContainer()->isCutAllowed() : sal_True);
+ break;
+ case ID_BROWSER_PASTE:
+ switch( getContainer()->getElementType() )
+ {
+ case E_TABLE:
+ aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
+ break;
+ case E_QUERY:
+ aReturn.bEnabled = !isDataSourceReadOnly() && getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
+ break;
+ default:
+ aReturn.bEnabled = !isDataSourceReadOnly() && OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType() == E_FORM);
+ }
+ break;
+ case SID_DB_APP_PASTE_SPECIAL:
+ aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && !isDataSourceReadOnly() && !isConnectionReadOnly() && isTableFormat();
+ break;
+ case SID_OPENDOC:
+ case SID_HELP_INDEX:
+ aReturn.bEnabled = sal_True;
+ break;
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = !isDataSourceReadOnly() && m_xDocumentModify.is() && m_xDocumentModify->isModified();
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ aReturn.bEnabled = sal_True;
+ break;
+ case ID_BROWSER_SORTUP:
+ aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
+ aReturn.bChecked = aReturn.bEnabled && getContainer()->isSortUp();
+ break;
+ case ID_BROWSER_SORTDOWN:
+ aReturn.bEnabled = getContainer()->isFilled() && getContainer()->getElementCount();
+ aReturn.bChecked = aReturn.bEnabled && !getContainer()->isSortUp();
+ break;
+
+ case SID_NEWDOC:
+ case SID_APP_NEW_FORM:
+ case ID_DOCUMENT_CREATE_REPWIZ:
+ aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
+ break;
+ case SID_APP_NEW_REPORT:
+ aReturn.bEnabled = !isDataSourceReadOnly()
+ && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER);
+ if ( aReturn.bEnabled )
+ {
+ Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
+ aReturn.bEnabled = xEnumAccess.is();
+ if ( aReturn.bEnabled )
+ {
+ const ::rtl::OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(m_xServiceFactory);
+ aReturn.bEnabled = sReportEngineServiceName.getLength() != 0;
+ if ( aReturn.bEnabled )
+ {
+ const Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(sReportEngineServiceName);
+ aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
+ }
+ }
+ }
+ break;
+ case SID_DB_APP_VIEW_TABLES:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getElementType() == E_TABLE;
+ break;
+ case SID_DB_APP_VIEW_QUERIES:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getElementType() == E_QUERY;
+ break;
+ case SID_DB_APP_VIEW_FORMS:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getElementType() == E_FORM;
+ break;
+ case SID_DB_APP_VIEW_REPORTS:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getElementType() == E_REPORT;
+ break;
+ case ID_NEW_QUERY_DESIGN:
+ case ID_NEW_QUERY_SQL:
+ case ID_APP_NEW_QUERY_AUTO_PILOT:
+ case SID_DB_FORM_NEW_PILOT:
+ aReturn.bEnabled = !isDataSourceReadOnly();
+ break;
+ case ID_NEW_VIEW_DESIGN:
+ case SID_DB_NEW_VIEW_SQL:
+ case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
+ aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
+ if ( aReturn.bEnabled )
+ {
+ Reference<XViewsSupplier> xViewsSup( getConnection(), UNO_QUERY );
+ aReturn.bEnabled = xViewsSup.is();
+ }
+ break;
+ case ID_NEW_TABLE_DESIGN:
+ case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
+ aReturn.bEnabled = !isDataSourceReadOnly() && !isConnectionReadOnly();
+ break;
+ case ID_DIRECT_SQL:
+ aReturn.bEnabled = sal_True;
+ break;
+ case ID_MIGRATE_SCRIPTS:
+ {
+ // Our document supports embedding scripts into it, if and only if there are no
+ // forms/reports with macros/scripts into them. So, we need to enable migration
+ // if and only if the database document does *not* support embedding scripts.
+ bool bAvailable =
+ !Reference< XEmbeddedScripts >( m_xModel, UNO_QUERY ).is()
+ && !Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly();
+ aReturn.bEnabled = bAvailable;
+ if ( !bAvailable )
+ aReturn.bInvisible = true;
+ }
+ break;
+ case SID_APP_NEW_FOLDER:
+ aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1;
+ if ( aReturn.bEnabled )
+ {
+ const ElementType eType = getContainer()->getElementType();
+ aReturn.bEnabled = eType == E_REPORT || eType == E_FORM;
+ }
+ break;
+ case SID_FORM_CREATE_REPWIZ_PRE_SEL:
+ case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
+ case SID_APP_NEW_REPORT_PRE_SEL:
+ aReturn.bEnabled = !isDataSourceReadOnly()
+ && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER)
+ && getContainer()->isALeafSelected();
+ if ( aReturn.bEnabled )
+ {
+ ElementType eType = getContainer()->getElementType();
+ aReturn.bEnabled = eType == E_QUERY || eType == E_TABLE;
+ if ( aReturn.bEnabled && SID_APP_NEW_REPORT_PRE_SEL == _nId )
+ {
+ Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY);
+ aReturn.bEnabled = xEnumAccess.is();
+ if ( aReturn.bEnabled )
+ {
+ static ::rtl::OUString s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory"));
+ Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign);
+ aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements();
+ }
+ }
+ }
+ break;
+ case SID_DB_APP_DELETE:
+ case SID_DB_APP_RENAME:
+ aReturn.bEnabled = isRenameDeleteAllowed(getContainer()->getElementType(), _nId == SID_DB_APP_DELETE);
+ break;
+ case SID_DB_APP_TABLE_DELETE:
+ case SID_DB_APP_TABLE_RENAME:
+ aReturn.bEnabled = isRenameDeleteAllowed(E_TABLE, _nId == SID_DB_APP_TABLE_DELETE);
+ break;
+ case SID_DB_APP_QUERY_DELETE:
+ case SID_DB_APP_QUERY_RENAME:
+ aReturn.bEnabled = isRenameDeleteAllowed(E_QUERY, _nId == SID_DB_APP_QUERY_DELETE);
+ break;
+ case SID_DB_APP_FORM_DELETE:
+ case SID_DB_APP_FORM_RENAME:
+ aReturn.bEnabled = isRenameDeleteAllowed(E_FORM, _nId == SID_DB_APP_FORM_DELETE);
+ break;
+ case SID_DB_APP_REPORT_DELETE:
+ case SID_DB_APP_REPORT_RENAME:
+ aReturn.bEnabled = isRenameDeleteAllowed(E_REPORT, _nId == SID_DB_APP_REPORT_DELETE);
+ break;
+
+ case SID_SELECTALL:
+ aReturn.bEnabled = getContainer()->getElementCount() > 0 && getContainer()->getSelectionCount() != getContainer()->getElementCount();
+ break;
+ case SID_DB_APP_EDIT:
+ case SID_DB_APP_TABLE_EDIT:
+ case SID_DB_APP_QUERY_EDIT:
+ case SID_DB_APP_FORM_EDIT:
+ case SID_DB_APP_REPORT_EDIT:
+ aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() > 0
+ && getContainer()->isALeafSelected();
+ break;
+ case SID_DB_APP_EDIT_SQL_VIEW:
+ if ( isDataSourceReadOnly() )
+ aReturn.bEnabled = sal_False;
+ else
+ {
+ switch ( getContainer()->getElementType() )
+ {
+ case E_QUERY:
+ aReturn.bEnabled = ( getContainer()->getSelectionCount() > 0 )
+ && ( getContainer()->isALeafSelected() );
+ break;
+ case E_TABLE:
+ aReturn.bEnabled = sal_False;
+ // there's one exception: views which support altering their underlying
+ // command can be edited in SQL view, too
+ if ( ( getContainer()->getSelectionCount() > 0 )
+ && ( getContainer()->isALeafSelected() )
+ )
+ {
+ ::std::vector< ::rtl::OUString > aSelected;
+ getSelectionElementNames( aSelected );
+ bool bAlterableViews = true;
+ for ( ::std::vector< ::rtl::OUString >::const_iterator selectedName = aSelected.begin();
+ bAlterableViews && ( selectedName != aSelected.end() ) ;
+ ++selectedName
+ )
+ {
+ bAlterableViews &= impl_isAlterableView_nothrow( *selectedName );
+ }
+ aReturn.bEnabled = bAlterableViews;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case SID_DB_APP_OPEN:
+ case SID_DB_APP_TABLE_OPEN:
+ case SID_DB_APP_QUERY_OPEN:
+ case SID_DB_APP_FORM_OPEN:
+ case SID_DB_APP_REPORT_OPEN:
+ aReturn.bEnabled = getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
+ break;
+ case SID_DB_APP_DSUSERADMIN:
+ aReturn.bEnabled = !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
+ break;
+ case SID_DB_APP_DSRELDESIGN:
+ aReturn.bEnabled = sal_True;
+ break;
+ case SID_DB_APP_TABLEFILTER:
+ aReturn.bEnabled = !isDataSourceReadOnly();
+ break;
+ case SID_DB_APP_REFRESH_TABLES:
+ aReturn.bEnabled = getContainer()->getElementType() == E_TABLE && isConnected();
+ break;
+ case SID_DB_APP_DSPROPS:
+ aReturn.bEnabled = m_xDataSource.is() && m_aTypeCollection.isShowPropertiesEnabled(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
+ break;
+ case SID_DB_APP_DSCONNECTION_TYPE:
+ aReturn.bEnabled = !isDataSourceReadOnly() && m_xDataSource.is() && !m_aTypeCollection.isEmbeddedDatabase(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
+ break;
+ case SID_DB_APP_DSADVANCED_SETTINGS:
+ aReturn.bEnabled = m_xDataSource.is() && AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( m_aTypeCollection.getType(::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) )) );
+ break;
+ case SID_DB_APP_CONVERTTOVIEW:
+ aReturn.bEnabled = !isDataSourceReadOnly();
+ if ( aReturn.bEnabled )
+ {
+ ElementType eType = getContainer()->getElementType();
+ aReturn.bEnabled = eType == E_QUERY && getContainer()->getSelectionCount() > 0;
+ if ( aReturn.bEnabled )
+ {
+ Reference<XViewsSupplier> xViewSup( getConnection(), UNO_QUERY );
+ aReturn.bEnabled = xViewSup.is() && Reference<XAppend>(xViewSup->getViews(),UNO_QUERY).is();
+ }
+ }
+ break;
+ case SID_DB_APP_DISABLE_PREVIEW:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getPreviewMode() == E_PREVIEWNONE;
+ break;
+ case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
+ {
+ ElementType eType = getContainer()->getElementType();
+ aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType);
+ aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENTINFO;
+ }
+ break;
+ case SID_DB_APP_VIEW_DOC_PREVIEW:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENT;
+ break;
+ case ID_BROWSER_UNDO:
+ aReturn.bEnabled = sal_False;
+ break;
+ case SID_MAIL_SENDDOC:
+ aReturn.bEnabled = sal_True;
+ break;
+ case SID_DB_APP_SENDREPORTASMAIL:
+ {
+ ElementType eType = getContainer()->getElementType();
+ aReturn.bEnabled = E_REPORT == eType && getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected();
+ }
+ break;
+ case SID_DB_APP_SENDREPORTTOWRITER:
+ case SID_DB_APP_DBADMIN:
+ aReturn.bEnabled = sal_False;
+ break;
+ case SID_DB_APP_STATUS_TYPE:
+ aReturn.bEnabled = m_xDataSource.is();
+ if ( aReturn.bEnabled )
+ {
+ ::rtl::OUString sURL;
+ m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
+ ::rtl::OUString sDSTypeName;
+ if ( m_aTypeCollection.isEmbeddedDatabase( sURL ) )
+ {
+ sDSTypeName = String( ModuleRes( RID_STR_EMBEDDED_DATABASE ) );
+ }
+ else
+ {
+ sDSTypeName = m_aTypeCollection.getTypeDisplayName(sURL);
+ }
+ aReturn.sTitle = sDSTypeName;
+ }
+ break;
+ case SID_DB_APP_STATUS_DBNAME:
+ aReturn.bEnabled = m_xDataSource.is();
+ if ( aReturn.bEnabled )
+ {
+ ::rtl::OUString sURL;
+ m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL;
+ String sDatabaseName;
+ String sHostName;
+ sal_Int32 nPortNumber( -1 );
+
+ m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
+
+ if ( !sDatabaseName.Len() )
+ sDatabaseName = m_aTypeCollection.cutPrefix( sURL );
+ if ( m_aTypeCollection.isFileSystemBased(sURL) )
+ {
+ sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName );
+ if ( sDatabaseName.Len() )
+ {
+ ::svt::OFileNotation aFileNotation(sDatabaseName);
+ // set this decoded URL as text
+ sDatabaseName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM);
+ }
+ }
+
+ if ( sDatabaseName.Len() == 0 )
+ sDatabaseName = m_aTypeCollection.getTypeDisplayName( sURL );
+
+ aReturn.sTitle = sDatabaseName;
+ }
+ break;
+ case SID_DB_APP_STATUS_USERNAME:
+ aReturn.bEnabled = m_xDataSource.is();
+ if ( aReturn.bEnabled )
+ m_xDataSource->getPropertyValue( PROPERTY_USER ) >>= aReturn.sTitle;
+ break;
+ case SID_DB_APP_STATUS_HOSTNAME:
+ aReturn.bEnabled = m_xDataSource.is();
+ if ( aReturn.bEnabled )
+ {
+ ::rtl::OUString sURL;
+ m_xDataSource->getPropertyValue( PROPERTY_URL ) >>= sURL;
+
+ String sHostName, sDatabaseName;
+ sal_Int32 nPortNumber = -1;
+ m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber );
+ aReturn.sTitle = sHostName;
+ }
+ break;
+ default:
+ aReturn = OApplicationController_CBASE::GetState(_nId);
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aReturn;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, const Any& _rException )
+ {
+ bool bHandled = false;
+
+ // try handling the error with an interaction handler
+ ::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+ if ( xHandler.is() )
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rException ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove );
+ pRequest->addContinuation( pApprove.get() );
+
+ try
+ {
+ xHandler->handle( pRequest.get() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ bHandled = pApprove->wasSelected();
+ }
+ return bHandled;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( isUserDefinedFeature( _nId ) )
+ {
+ OApplicationController_CBASE::Execute( _nId, aArgs );
+ return;
+ }
+
+ if ( !getContainer() || m_bReadOnly )
+ return; // return without execution
+
+ try
+ {
+ switch(_nId)
+ {
+ case ID_BROWSER_CUT:
+ getContainer()->cut();
+ break;
+ case ID_BROWSER_COPY:
+ {
+ TransferableHelper* pTransfer = copyObject( );
+ Reference< XTransferable> aEnsureDelete = pTransfer;
+
+ if ( pTransfer )
+ pTransfer->CopyToClipboard(getView());
+ }
+ break;
+ case ID_BROWSER_PASTE:
+ {
+ const TransferableDataHelper& rTransferData( getViewClipboard() );
+ ElementType eType = getContainer()->getElementType();
+
+ switch( eType )
+ {
+ case E_TABLE:
+ {
+ // get the selected tablename
+ ::std::vector< ::rtl::OUString > aList;
+ getSelectionElementNames( aList );
+ if ( !aList.empty() )
+ m_aTableCopyHelper.SetTableNameForAppend( *aList.begin() );
+ else
+ m_aTableCopyHelper.ResetTableNameForAppend();
+
+ m_aTableCopyHelper.pasteTable( rTransferData , getDatabaseName(), ensureConnection() );
+ }
+ break;
+
+ case E_QUERY:
+ if ( rTransferData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
+ paste( E_QUERY, ODataAccessObjectTransferable::extractObjectDescriptor( rTransferData ) );
+ break;
+ default:
+ {
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+ ::rtl::OUString sFolderNameToInsertInto;
+ if ( !aList.empty() )
+ {
+ Reference< XHierarchicalNameAccess > xContainer(getElements(eType),UNO_QUERY);
+ if ( xContainer.is()
+ && xContainer->hasByHierarchicalName(*aList.begin())
+ && (xContainer->getByHierarchicalName(*aList.begin()) >>= xContainer)
+ && xContainer.is()
+ )
+ sFolderNameToInsertInto = *aList.begin();
+ }
+ paste( eType, OComponentTransferable::extractComponentDescriptor( rTransferData ),
+ sFolderNameToInsertInto );
+ }
+ break;
+ }
+ }
+ break;
+ case SID_DB_APP_PASTE_SPECIAL:
+ {
+ if ( !aArgs.getLength() )
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ ::std::auto_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( getView() ));
+ ::std::vector<SotFormatStringId> aFormatIds;
+ getSupportedFormats(getContainer()->getElementType(),aFormatIds);
+ const ::std::vector<SotFormatStringId>::iterator aEnd = aFormatIds.end();
+ ::rtl::OUString sEmpty;
+ for (::std::vector<SotFormatStringId>::iterator aIter = aFormatIds.begin();aIter != aEnd; ++aIter)
+ pDlg->Insert(*aIter,sEmpty);
+
+ const TransferableDataHelper& rClipboard = getViewClipboard();
+ pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable()));
+ }
+ else
+ {
+ const PropertyValue* pIter = aArgs.getConstArray();
+ const PropertyValue* pEnd = pIter + aArgs.getLength();
+ for( ; pIter != pEnd ; ++pIter)
+ {
+ if ( pIter->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("FormatStringId")) )
+ {
+ SotFormatStringId nFormatId = 0;
+ if ( pIter->Value >>= nFormatId )
+ pasteFormat(nFormatId);
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case SID_OPENDOC:
+ case SID_HELP_INDEX:
+ {
+ Reference < XDispatchProvider > xProv( getFrame(), UNO_QUERY );
+ if ( xProv.is() )
+ {
+ URL aURL;
+ switch(_nId)
+ {
+ case SID_HELP_INDEX:
+ aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:HelpIndex"));
+ break;
+ case SID_OPENDOC:
+ aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Open"));
+ break;
+ }
+
+ if ( m_xUrlTransformer.is() )
+ m_xUrlTransformer->parseStrict( aURL );
+ Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, String(), 0 );
+ if ( xDisp.is() )
+ xDisp->dispatch( aURL, Sequence < PropertyValue >() );
+ }
+ }
+ break;
+ case ID_BROWSER_SAVEDOC:
+ {
+ Reference< XStorable > xStore( m_xModel, UNO_QUERY_THROW );
+ try
+ {
+ xStore->store();
+ }
+ catch( const Exception& )
+ {
+ lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
+ }
+ }
+ break;
+
+ case ID_BROWSER_SAVEASDOC:
+ {
+ WinBits nBits(WB_STDMODAL|WB_SAVEAS);
+ ::rtl::OUString sUrl;
+ if ( m_xModel.is() )
+ sUrl = m_xModel->getURL();
+ if ( !sUrl.getLength() )
+ sUrl = SvtPathOptions().GetWorkPath();
+
+ ::sfx2::FileDialogHelper aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,static_cast<sal_uInt32>(nBits) ,getView());
+ aFileDlg.SetDisplayDirectory( sUrl );
+
+ const SfxFilter* pFilter = getStandardDatabaseFilter();
+ if ( pFilter )
+ {
+ aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
+ aFileDlg.SetCurrentFilter(pFilter->GetUIName());
+ }
+
+ if ( aFileDlg.Execute() != ERRCODE_NONE )
+ break;
+
+ Reference<XStorable> xStore( m_xModel, UNO_QUERY_THROW );
+ INetURLObject aURL( aFileDlg.GetPath() );
+ try
+ {
+ xStore->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), Sequence< PropertyValue >() );
+ }
+ catch( const Exception& )
+ {
+ lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() );
+ }
+
+ /*updateTitle();*/
+ m_bCurrentlyModified = sal_False;
+ InvalidateFeature(ID_BROWSER_SAVEDOC);
+ if ( getContainer()->getElementType() == E_NONE )
+ {
+ getContainer()->selectContainer(E_NONE);
+ getContainer()->selectContainer(E_TABLE);
+ // #i95524#
+ getContainer()->Invalidate();
+ refreshTables();
+ }
+
+ }
+ break;
+ case ID_BROWSER_SORTUP:
+ getContainer()->sortUp();
+ InvalidateFeature(ID_BROWSER_SORTDOWN);
+ break;
+ case ID_BROWSER_SORTDOWN:
+ getContainer()->sortDown();
+ InvalidateFeature(ID_BROWSER_SORTUP);
+ break;
+
+ case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
+ case ID_NEW_VIEW_DESIGN_AUTO_PILOT:
+ case ID_APP_NEW_QUERY_AUTO_PILOT:
+ case SID_DB_FORM_NEW_PILOT:
+ case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
+ case SID_APP_NEW_REPORT_PRE_SEL:
+ case SID_FORM_CREATE_REPWIZ_PRE_SEL:
+ case ID_DOCUMENT_CREATE_REPWIZ:
+ case SID_APP_NEW_FORM:
+ case SID_APP_NEW_REPORT:
+ case ID_NEW_QUERY_SQL:
+ case ID_NEW_QUERY_DESIGN:
+ case ID_NEW_TABLE_DESIGN:
+ {
+ ElementType eType = E_TABLE;
+ sal_Bool bAutoPilot = sal_False;
+ ::comphelper::NamedValueCollection aCreationArgs;
+
+ switch( _nId )
+ {
+ case SID_DB_FORM_NEW_PILOT:
+ case SID_FORM_CREATE_REPWIZ_PRE_SEL:
+ bAutoPilot = sal_True;
+ // run through
+ case SID_APP_NEW_FORM:
+ eType = E_FORM;
+ break;
+ case ID_DOCUMENT_CREATE_REPWIZ:
+ case SID_REPORT_CREATE_REPWIZ_PRE_SEL:
+ bAutoPilot = sal_True;
+ // run through
+ case SID_APP_NEW_REPORT:
+ case SID_APP_NEW_REPORT_PRE_SEL:
+ eType = E_REPORT;
+ break;
+ case ID_APP_NEW_QUERY_AUTO_PILOT:
+ bAutoPilot = sal_True;
+ eType = E_QUERY;
+ break;
+ case ID_NEW_QUERY_DESIGN:
+ aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, sal_True );
+ // run through
+ case ID_NEW_QUERY_SQL:
+ eType = E_QUERY;
+ break;
+ case ID_NEW_TABLE_DESIGN_AUTO_PILOT:
+ bAutoPilot = sal_True;
+ // run through
+ case ID_NEW_TABLE_DESIGN:
+ break;
+ default:
+ OSL_FAIL("illegal switch call!");
+ }
+ if ( bAutoPilot )
+ getContainer()->PostUserEvent( LINK( this, OApplicationController, OnCreateWithPilot ), reinterpret_cast< void* >( eType ) );
+ else
+ {
+ Reference< XComponent > xDocDefinition;
+ newElement( eType, aCreationArgs, xDocDefinition );
+ }
+ }
+ break;
+ case SID_APP_NEW_FOLDER:
+ {
+ ElementType eType = getContainer()->getElementType();
+ ::rtl::OUString sName = getContainer()->getQualifiedName( NULL );
+ insertHierachyElement(eType,sName);
+ }
+ break;
+ case ID_NEW_VIEW_DESIGN:
+ case SID_DB_NEW_VIEW_SQL:
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ {
+ QueryDesigner aDesigner( getORB(), this, getFrame(), true );
+
+ ::comphelper::NamedValueCollection aCreationArgs;
+ aCreationArgs.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId );
+
+ Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ Reference< XComponent > xComponent( aDesigner.createNew( xDataSource, aCreationArgs ), UNO_QUERY );
+ onDocumentOpened( ::rtl::OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, NULL );
+ }
+ }
+ break;
+ case SID_DB_APP_DELETE:
+ case SID_DB_APP_TABLE_DELETE:
+ case SID_DB_APP_QUERY_DELETE:
+ case SID_DB_APP_FORM_DELETE:
+ case SID_DB_APP_REPORT_DELETE:
+ deleteEntries();
+ break;
+ case SID_DB_APP_RENAME:
+ case SID_DB_APP_TABLE_RENAME:
+ case SID_DB_APP_QUERY_RENAME:
+ case SID_DB_APP_FORM_RENAME:
+ case SID_DB_APP_REPORT_RENAME:
+ renameEntry();
+ break;
+ case SID_DB_APP_EDIT:
+ case SID_DB_APP_EDIT_SQL_VIEW:
+ case SID_DB_APP_TABLE_EDIT:
+ case SID_DB_APP_QUERY_EDIT:
+ case SID_DB_APP_FORM_EDIT:
+ case SID_DB_APP_REPORT_EDIT:
+ doAction( _nId, E_OPEN_DESIGN );
+ break;
+ case SID_DB_APP_OPEN:
+ case SID_DB_APP_TABLE_OPEN:
+ case SID_DB_APP_QUERY_OPEN:
+ case SID_DB_APP_FORM_OPEN:
+ case SID_DB_APP_REPORT_OPEN:
+ doAction( _nId, E_OPEN_NORMAL );
+ break;
+ case SID_DB_APP_CONVERTTOVIEW:
+ doAction( _nId, E_OPEN_NORMAL );
+ break;
+ case SID_SELECTALL:
+ getContainer()->selectAll();
+ InvalidateAll();
+ break;
+ case SID_DB_APP_DSRELDESIGN:
+ {
+ Reference< XComponent > xRelationDesigner;
+ if ( !m_pSubComponentManager->activateSubFrame( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xRelationDesigner ) )
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ {
+ RelationDesigner aDesigner( getORB(), this, m_aCurrentFrame.getFrame() );
+
+ Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY );
+ onDocumentOpened( ::rtl::OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, NULL );
+ }
+ }
+ }
+ break;
+ case SID_DB_APP_DSUSERADMIN:
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog")));
+ }
+ break;
+ case SID_DB_APP_TABLEFILTER:
+ openTableFilterDialog();
+ askToReconnect();
+ break;
+ case SID_DB_APP_REFRESH_TABLES:
+ refreshTables();
+ break;
+ case SID_DB_APP_DSPROPS:
+ openDataSourceAdminDialog();
+ askToReconnect();
+ break;
+ case SID_DB_APP_DSADVANCED_SETTINGS:
+ openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog")));
+ askToReconnect();
+ break;
+ case SID_DB_APP_DSCONNECTION_TYPE:
+ openDialog(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog")));
+ askToReconnect();
+ break;
+ case ID_DIRECT_SQL:
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ openDirectSQLDialog();
+ }
+ break;
+ case ID_MIGRATE_SCRIPTS:
+ impl_migrateScripts_nothrow();
+ break;
+ case SID_DB_APP_VIEW_TABLES:
+ m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_TABLE ) );
+ break;
+ case SID_DB_APP_VIEW_QUERIES:
+ m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_QUERY ) );
+ break;
+ case SID_DB_APP_VIEW_FORMS:
+ m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_FORM ) );
+ break;
+ case SID_DB_APP_VIEW_REPORTS:
+ m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_REPORT ) );
+ break;
+ case SID_DB_APP_DISABLE_PREVIEW:
+ m_ePreviewMode = E_PREVIEWNONE;
+ getContainer()->switchPreview(m_ePreviewMode);
+ break;
+ case SID_DB_APP_VIEW_DOCINFO_PREVIEW:
+ m_ePreviewMode = E_DOCUMENTINFO;
+ getContainer()->switchPreview(m_ePreviewMode);
+ break;
+ case SID_DB_APP_VIEW_DOC_PREVIEW:
+ m_ePreviewMode = E_DOCUMENT;
+ getContainer()->switchPreview(m_ePreviewMode);
+ break;
+ case SID_MAIL_SENDDOC:
+ {
+ SfxMailModel aSendMail;
+ if ( aSendMail.AttachDocument(rtl::OUString(),getModel(), rtl::OUString()) == SfxMailModel::SEND_MAIL_OK )
+ aSendMail.Send( getFrame() );
+ }
+ break;
+ case SID_DB_APP_SENDREPORTASMAIL:
+ doAction( _nId, E_OPEN_FOR_MAIL );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ InvalidateFeature(_nId);
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::describeSupportedFeatures()
+{
+ OApplicationController_CBASE::describeSupportedFeatures();
+
+ implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL,
+ CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER,
+ CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection",
+ SID_FORM_CREATE_REPWIZ_PRE_SEL,
+ CommandGroup::APPLICATION );
+
+ implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot",
+ ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection",
+ SID_REPORT_CREATE_REPWIZ_PRE_SEL,
+ CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT,
+ CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT,
+ CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT );
+
+ implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
+
+ implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE,
+ CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings",
+ SID_DB_APP_DSADVANCED_SETTINGS,
+ CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBMigrateScripts", ID_MIGRATE_SCRIPTS, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview",
+ SID_DB_APP_VIEW_DOCINFO_PREVIEW,
+ CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW,
+ CommandGroup::VIEW );
+
+ implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION );
+
+ // this one should not appear under Tools->Customize->Keyboard
+ implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection",
+ SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::INTERNAL );
+ implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL);
+ implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL);
+ implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN, CommandGroup::INTERNAL);
+
+ // status info
+ implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE, CommandGroup::INTERNAL);
+ implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME, CommandGroup::INTERNAL);
+ implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME, CommandGroup::INTERNAL);
+ implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME, CommandGroup::INTERNAL);
+}
+// -----------------------------------------------------------------------------
+OApplicationView* OApplicationController::getContainer() const
+{
+ return static_cast< OApplicationView* >( getView() );
+}
+
+// -----------------------------------------------------------------------------
+// ::com::sun::star::container::XContainerListener
+void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
+ if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
+ {
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+ if ( getContainer() )
+ {
+ ::rtl::OUString sName;
+ _rEvent.Accessor >>= sName;
+ ElementType eType = getElementType(xContainer);
+
+ switch( eType )
+ {
+ case E_TABLE:
+ ensureConnection();
+ break;
+ case E_FORM:
+ case E_REPORT:
+ {
+ Reference< XContainer > xSubContainer(_rEvent.Element,UNO_QUERY);
+ if ( xSubContainer.is() )
+ containerFound(xSubContainer);
+ }
+ break;
+ default:
+ break;
+ }
+ getContainer()->elementAdded(eType,sName,_rEvent.Element);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
+ if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
+ {
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+ ::rtl::OUString sName;
+ _rEvent.Accessor >>= sName;
+ ElementType eType = getElementType(xContainer);
+ switch( eType )
+ {
+ case E_TABLE:
+ ensureConnection();
+ break;
+ case E_FORM:
+ case E_REPORT:
+ {
+ Reference<XContent> xContent(xContainer,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ getContainer()->elementRemoved(eType,sName);
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ Reference< XContainer > xContainer(_rEvent.Source, UNO_QUERY);
+ if ( ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xContainer) != m_aCurrentContainers.end() )
+ {
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+ ::rtl::OUString sName;
+ try
+ {
+ _rEvent.Accessor >>= sName;
+ Reference<XConnection> xConnection;
+ Reference<XPropertySet> xProp(_rEvent.Element,UNO_QUERY);
+ ::rtl::OUString sNewName;
+
+ ElementType eType = getElementType(xContainer);
+ switch( eType )
+ {
+ case E_TABLE:
+ {
+ ensureConnection();
+ if ( xProp.is() && m_xMetaData.is() )
+ sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
+ }
+ break;
+ case E_FORM:
+ case E_REPORT:
+ {
+ Reference<XContent> xContent(xContainer,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ sName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ // getContainer()->elementReplaced(getContainer()->getElementType(),sName,sNewName);
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+namespace
+{
+ ::rtl::OUString lcl_getToolBarResource(ElementType _eType)
+ {
+ ::rtl::OUString sToolbar;
+ switch(_eType)
+ {
+ case E_TABLE:
+ sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/tableobjectbar" ));
+ break;
+ case E_QUERY:
+ sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/queryobjectbar" ));
+ break;
+ case E_FORM:
+ sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/formobjectbar" ));
+ break;
+ case E_REPORT:
+ sToolbar = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/reportobjectbar" ));
+ break;
+ case E_NONE:
+ break;
+ default:
+ OSL_FAIL("Invalid ElementType!");
+ break;
+ }
+ return sToolbar;
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::onContainerSelect(ElementType _eType)
+{
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+
+ if ( m_eCurrentType != _eType && _eType != E_NONE )
+ {
+ SelectionGuard aSelGuard( *m_pSelectionNotifier );
+
+ if ( _eType == E_TABLE )
+ {
+ try
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() && getContainer()->getDetailView() )
+ {
+ getContainer()->getDetailView()->createTablesPage(xConnection);
+ Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
+ if ( xTabSup.is() )
+ addContainerListener(xTabSup->getTables());
+ }
+ else
+ {
+ return sal_False;
+ }
+ }
+ catch( const Exception& )
+ {
+ return sal_False;
+ }
+ }
+ Reference< XLayoutManager > xLayoutManager = getLayoutManager( getFrame() );
+ if ( xLayoutManager.is() )
+ {
+ ::rtl::OUString sToolbar = lcl_getToolBarResource(_eType);
+ ::rtl::OUString sDestroyToolbar = lcl_getToolBarResource(m_eCurrentType);
+
+ xLayoutManager->lock();
+ xLayoutManager->destroyElement( sDestroyToolbar );
+ if ( sToolbar.getLength() )
+ {
+ xLayoutManager->createElement( sToolbar );
+ xLayoutManager->requestElement( sToolbar );
+ }
+ xLayoutManager->unlock();
+ xLayoutManager->doLayout();
+ }
+
+ if ( _eType != E_TABLE && getContainer()->getDetailView() )
+ {
+ Reference< XNameAccess > xContainer = getElements(_eType);
+ addContainerListener(xContainer);
+ getContainer()->getDetailView()->createPage(_eType,xContainer);
+ }
+
+ SelectionByElementType::iterator pendingSelection = m_aPendingSelection.find( _eType );
+ if ( pendingSelection != m_aPendingSelection.end() )
+ {
+ Sequence< ::rtl::OUString > aSelected( pendingSelection->second.size() );
+ ::std::copy( pendingSelection->second.begin(), pendingSelection->second.end(), aSelected.getArray() );
+ getContainer()->selectElements( aSelected );
+
+ m_aPendingSelection.erase( pendingSelection );
+ }
+
+ InvalidateAll();
+ }
+ m_eCurrentType = _eType;
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree )
+{
+ if ( getContainer() && getContainer()->isLeaf( _rTree.GetHdlEntry() ) )
+ {
+ try
+ {
+ openElement(
+ getContainer()->getQualifiedName( _rTree.GetHdlEntry() ),
+ getContainer()->getElementType(),
+ E_OPEN_NORMAL
+ );
+ return true; // handled
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return false; // not handled
+}
+// -----------------------------------------------------------------------------
+bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString& _rTableOrViewName ) const
+{
+ OSL_PRECOND( m_xDataSourceConnection.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" );
+
+ bool bIsAlterableView( false );
+ try
+ {
+ Reference< XViewsSupplier > xViewsSupp( m_xDataSourceConnection, UNO_QUERY );
+ Reference< XNameAccess > xViews;
+ if ( xViewsSupp.is() )
+ xViews = xViewsSupp->getViews();
+
+ Reference< XAlterView > xAsAlterableView;
+ if ( xViews.is() && xViews->hasByName( _rTableOrViewName ) )
+ xAsAlterableView.set( xViews->getByName( _rTableOrViewName ), UNO_QUERY );
+
+ bIsAlterableView = xAsAlterableView.is();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsAlterableView;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > OApplicationController::openElement(const ::rtl::OUString& _sName, ElementType _eType,
+ ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand )
+{
+ return openElementWithArguments( _sName, _eType, _eOpenMode, _nInstigatorCommand, ::comphelper::NamedValueCollection() );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > OApplicationController::openElementWithArguments( const ::rtl::OUString& _sName, ElementType _eType,
+ ElementOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand, const ::comphelper::NamedValueCollection& _rAdditionalArguments )
+{
+ OSL_PRECOND( getContainer(), "OApplicationController::openElementWithArguments: no view!" );
+ if ( !getContainer() )
+ return NULL;
+
+ Reference< XComponent > xRet;
+ if ( _eOpenMode == E_OPEN_DESIGN )
+ {
+ // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382
+ getContainer()->showPreview(NULL);
+ }
+
+ bool isStandaloneDocument = false;
+ switch ( _eType )
+ {
+ case E_REPORT:
+ if ( _eOpenMode != E_OPEN_DESIGN )
+ {
+ // reports which are opened in a mode other than design are no sub components of our application
+ // component, but standalone documents.
+ isStandaloneDocument = true;
+ }
+ // NO break!
+ case E_FORM:
+ {
+ if ( isStandaloneDocument || !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
+ {
+ ::std::auto_ptr< OLinkedDocumentsAccess > aHelper = getDocumentsAccess( _eType );
+ if ( !aHelper->isConnected() )
+ break;
+
+ Reference< XComponent > xDefinition;
+ xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments );
+
+ if ( !isStandaloneDocument )
+ onDocumentOpened( _sName, _eType, _eOpenMode, xRet, xDefinition );
+ }
+ }
+ break;
+
+ case E_QUERY:
+ case E_TABLE:
+ {
+ if ( !m_pSubComponentManager->activateSubFrame( _sName, _eType, _eOpenMode, xRet ) )
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( !xConnection.is() )
+ break;
+
+ ::std::auto_ptr< DatabaseObjectView > pDesigner;
+ ::comphelper::NamedValueCollection aArguments( _rAdditionalArguments );
+
+ Any aDataSource;
+ if ( _eOpenMode == E_OPEN_DESIGN )
+ {
+ bool bAddViewTypeArg = false;
+
+ if ( _eType == E_TABLE )
+ {
+ if ( impl_isAlterableView_nothrow( _sName ) )
+ {
+ pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), true ) );
+ bAddViewTypeArg = true;
+ }
+ else
+ {
+ pDesigner.reset( new TableDesigner( getORB(), this, m_aCurrentFrame.getFrame() ) );
+ }
+ }
+ else if ( _eType == E_QUERY )
+ {
+ pDesigner.reset( new QueryDesigner( getORB(), this, m_aCurrentFrame.getFrame(), false ) );
+ bAddViewTypeArg = true;
+ }
+ aDataSource <<= m_xDataSource;
+
+ if ( bAddViewTypeArg )
+ {
+ const bool bQueryGraphicalMode =( _nInstigatorCommand != SID_DB_APP_EDIT_SQL_VIEW );
+ aArguments.put( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, bQueryGraphicalMode );
+ }
+
+ }
+ else
+ {
+ pDesigner.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame.getFrame(), _eType == E_TABLE ) );
+
+ if ( !aArguments.has( (::rtl::OUString)PROPERTY_SHOWMENU ) )
+ aArguments.put( (::rtl::OUString)PROPERTY_SHOWMENU, makeAny( (sal_Bool)sal_True ) );
+
+ aDataSource <<= getDatabaseName();
+ }
+
+ xRet.set( pDesigner->openExisting( aDataSource, _sName, aArguments ) );
+ onDocumentOpened( _sName, _eType, _eOpenMode, xRet, NULL );
+ }
+ }
+ break;
+
+ default:
+ OSL_FAIL( "OApplicationController::openElement: illegal object type!" );
+ break;
+ }
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnSelectContainer, void*, _pType )
+{
+ ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
+ if (getContainer())
+ getContainer()->selectContainer(eType);
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType )
+{
+ ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType );
+ newElementWithPilot( eType );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::newElementWithPilot( ElementType _eType )
+{
+ OSL_ENSURE( getContainer(), "OApplicationController::newElementWithPilot: without a view?" );
+
+ switch ( _eType )
+ {
+ case E_REPORT:
+ case E_FORM:
+ {
+ ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
+ if ( aHelper->isConnected() )
+ {
+ sal_Int32 nCommandType = -1;
+ const ::rtl::OUString sCurrentSelected( getCurrentlySelectedName( nCommandType ) );
+ if ( E_REPORT == _eType )
+ aHelper->newReportWithPilot( nCommandType, sCurrentSelected );
+ else
+ aHelper->newFormWithPilot( nCommandType, sCurrentSelected );
+ }
+ }
+ break;
+ case E_QUERY:
+ case E_TABLE:
+ {
+ ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType);
+ if ( aHelper->isConnected() )
+ {
+ if ( E_QUERY == _eType )
+ aHelper->newQueryWithPilot();
+ else
+ aHelper->newTableWithPilot();
+ }
+ }
+ break;
+ case E_NONE:
+ break;
+ }
+
+ // no need for onDocumentOpened, the table wizard opens the created table by using
+ // XDatabaseDocumentUI::loadComponent method.
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > OApplicationController::newElement( ElementType _eType, const ::comphelper::NamedValueCollection& i_rAdditionalArguments,
+ Reference< XComponent >& o_rDocumentDefinition )
+{
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+
+ Reference< XComponent > xComponent;
+ o_rDocumentDefinition.clear();
+
+ switch ( _eType )
+ {
+ case E_FORM:
+ case E_REPORT:
+ {
+ ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess( _eType );
+ if ( !aHelper->isConnected() )
+ break;
+
+ xComponent = aHelper->newDocument( _eType == E_FORM ? ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT, i_rAdditionalArguments, o_rDocumentDefinition );
+ }
+ break;
+
+ case E_QUERY:
+ case E_TABLE:
+ {
+ ::std::auto_ptr< DatabaseObjectView > pDesigner;
+ SharedConnection xConnection( ensureConnection() );
+ if ( !xConnection.is() )
+ break;
+
+ if ( _eType == E_TABLE )
+ {
+ pDesigner.reset( new TableDesigner( getORB(), this, getFrame() ) );
+ }
+ else if ( _eType == E_QUERY )
+ {
+ pDesigner.reset( new QueryDesigner( getORB(), this, getFrame(), false ) );
+ }
+
+ Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ xComponent.set( pDesigner->createNew( xDataSource, i_rAdditionalArguments ), UNO_QUERY );
+ }
+ break;
+
+ default:
+ OSL_FAIL( "OApplicationController::newElement: illegal type!" );
+ break;
+ }
+
+ if ( xComponent.is() )
+ onDocumentOpened( ::rtl::OUString(), _eType, E_OPEN_DESIGN, xComponent, o_rDocumentDefinition );
+
+ return xComponent;
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::addContainerListener(const Reference<XNameAccess>& _xCollection)
+{
+ try
+ {
+ Reference< XContainer > xCont(_xCollection, UNO_QUERY);
+ if ( xCont.is() )
+ {
+ // add as listener to get notified if elements are inserted or removed
+ TContainerVector::iterator aFind = ::std::find(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),xCont);
+ if ( aFind == m_aCurrentContainers.end() )
+ {
+ xCont->addContainerListener(this);
+ m_aCurrentContainers.push_back(xCont);
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::renameEntry()
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ OSL_ENSURE(getContainer(),"View is NULL! -> GPF");
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+
+ Reference< XNameAccess > xContainer = getElements(getContainer()->getElementType());
+ OSL_ENSURE(aList.size() == 1,"Invalid rename call here. More than one element!");
+ if ( aList.empty() )
+ return;
+
+ try
+ {
+ if ( xContainer.is() )
+ {
+ ::std::auto_ptr< IObjectNameCheck > pNameChecker;
+ ::std::auto_ptr< OSaveAsDlg > aDialog;
+
+ Reference<XRename> xRename;
+ const ElementType eType = getContainer()->getElementType();
+ switch( eType )
+ {
+ case E_FORM:
+ case E_REPORT:
+ {
+ Reference<XHierarchicalNameContainer> xHNames(xContainer, UNO_QUERY);
+ if ( xHNames.is() )
+ {
+ String sLabel;
+ if ( eType == E_FORM )
+ sLabel = String(ModuleRes( STR_FRM_LABEL ));
+ else
+ sLabel = String(ModuleRes( STR_RPT_LABEL ));
+
+ ::rtl::OUString sName = *aList.begin();
+ if ( xHNames->hasByHierarchicalName(sName) )
+ {
+ xRename.set(xHNames->getByHierarchicalName(sName),UNO_QUERY);
+ Reference<XChild> xChild(xRename,UNO_QUERY);
+ if ( xChild.is() )
+ {
+ Reference<XHierarchicalNameContainer> xParent(xChild->getParent(),UNO_QUERY);
+ if ( xParent.is() )
+ {
+ xHNames = xParent;
+ Reference<XPropertySet>(xRename,UNO_QUERY)->getPropertyValue(PROPERTY_NAME) >>= sName;
+ }
+ }
+ pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), String() ) );
+ aDialog.reset( new OSaveAsDlg(
+ getView(), getORB(), sName, sLabel, *pNameChecker, SAD_TITLE_RENAME ) );
+ }
+ }
+ }
+ break;
+ case E_TABLE:
+ ensureConnection();
+ if ( !getConnection().is() )
+ break;
+ // NO break
+ case E_QUERY:
+ if ( xContainer->hasByName(*aList.begin()) )
+ {
+ xRename.set(xContainer->getByName(*aList.begin()),UNO_QUERY);
+ sal_Int32 nCommandType = eType == E_QUERY ? CommandType::QUERY : CommandType::TABLE;
+
+ ensureConnection();
+ pNameChecker.reset( new DynamicTableOrQueryNameCheck( getConnection(), nCommandType ) );
+ aDialog.reset( new OSaveAsDlg(
+ getView(), nCommandType, getORB(), getConnection(),
+ *aList.begin(), *pNameChecker, SAD_TITLE_RENAME ) );
+ }
+ break;
+ default:
+ break;
+ }
+
+ if ( xRename.is() && aDialog.get() )
+ {
+
+ sal_Bool bTryAgain = sal_True;
+ while( bTryAgain )
+ {
+ if ( aDialog->Execute() == RET_OK )
+ {
+ try
+ {
+ ::rtl::OUString sNewName;
+ if ( eType == E_TABLE )
+ {
+ ::rtl::OUString sName = aDialog->getName();
+ ::rtl::OUString sCatalog = aDialog->getCatalog();
+ ::rtl::OUString sSchema = aDialog->getSchema();
+
+ sNewName = ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sName, sal_False, ::dbtools::eInDataManipulation );
+ }
+ else
+ sNewName = aDialog->getName();
+
+ ::rtl::OUString sOldName = *aList.begin();
+ if ( eType == E_FORM || eType == E_REPORT )
+ {
+ Reference<XContent> xContent(xRename,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ sOldName = xContent->getIdentifier()->getContentIdentifier();
+ }
+ }
+
+ xRename->rename(sNewName);
+
+ if ( eType == E_TABLE )
+ {
+ Reference<XPropertySet> xProp(xRename,UNO_QUERY);
+ sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false );
+ }
+ getContainer()->elementReplaced( eType , sOldName, sNewName );
+
+ bTryAgain = sal_False;
+ }
+ catch(const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+
+ }
+ catch(const ElementExistException& e)
+ {
+ static ::rtl::OUString sStatus = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
+ String sMsg = String( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
+ sMsg.SearchAndReplace('#',e.Message);
+ showError(SQLExceptionInfo(SQLException(sMsg, e.Context, sStatus, 0, Any())));
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ bTryAgain = sal_False;
+ }
+ }
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::onSelectionChanged()
+{
+ InvalidateAll();
+
+ SelectionGuard aSelGuard( *m_pSelectionNotifier );
+
+ OApplicationView* pView = getContainer();
+ if ( !pView )
+ return;
+
+ if ( pView->getSelectionCount() == 1 )
+ {
+ const ElementType eType = pView->getElementType();
+ if ( pView->isALeafSelected() )
+ {
+ const ::rtl::OUString sName = pView->getQualifiedName( NULL /* means 'first selected' */ );
+ showPreviewFor( eType, sName );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::showPreviewFor(const ElementType _eType,const ::rtl::OUString& _sName)
+{
+ if ( m_ePreviewMode == E_PREVIEWNONE )
+ return;
+
+ OApplicationView* pView = getContainer();
+ if ( !pView )
+ return;
+
+ try
+ {
+ switch( _eType )
+ {
+ case E_FORM:
+ case E_REPORT:
+ {
+ Reference< XHierarchicalNameAccess > xContainer( getElements( _eType ), UNO_QUERY_THROW );
+ Reference< XContent> xContent( xContainer->getByHierarchicalName( _sName ), UNO_QUERY_THROW );
+ pView->showPreview( xContent );
+ }
+ break;
+
+ case E_TABLE:
+ case E_QUERY:
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ pView->showPreview( getDatabaseName(), xConnection, _sName, _eType == E_TABLE );
+ }
+ return;
+
+ default:
+ OSL_FAIL( "OApplicationController::showPreviewFor: unexpected element type!" );
+ break;
+ }
+ }
+ catch( const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnClipboardChanged, void*, EMPTYARG )
+{
+ return OnInvalidateClipboard( NULL );
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OApplicationController, OnInvalidateClipboard, void*, EMPTYARG)
+{
+ InvalidateFeature(ID_BROWSER_CUT);
+ InvalidateFeature(ID_BROWSER_COPY);
+ InvalidateFeature(ID_BROWSER_PASTE);
+ InvalidateFeature(SID_DB_APP_PASTE_SPECIAL);
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::onCutEntry()
+{
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::onCopyEntry()
+{
+ Execute(ID_BROWSER_COPY,Sequence<PropertyValue>());
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::onPasteEntry()
+{
+ Execute(ID_BROWSER_PASTE,Sequence<PropertyValue>());
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::onDeleteEntry()
+{
+ ElementType eType = getContainer()->getElementType();
+ sal_uInt16 nId = 0;
+ switch(eType)
+ {
+ case E_TABLE:
+ nId = SID_DB_APP_TABLE_DELETE;
+ break;
+ case E_QUERY:
+ nId = SID_DB_APP_QUERY_DELETE;
+ break;
+ case E_FORM:
+ nId = SID_DB_APP_FORM_DELETE;
+ break;
+ case E_REPORT:
+ nId = SID_DB_APP_REPORT_DELETE;
+ break;
+ default:
+ OSL_FAIL("Invalid ElementType!");
+ break;
+ }
+ executeChecked(nId,Sequence<PropertyValue>());
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::executeUnChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
+{
+ OApplicationController_CBASE::executeUnChecked( _rCommand, aArgs );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::executeChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs)
+{
+ OApplicationController_CBASE::executeChecked( _rCommand, aArgs );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
+{
+ OApplicationController_CBASE::executeUnChecked( _nCommandId, aArgs );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs)
+{
+ OApplicationController_CBASE::executeChecked( _nCommandId, aArgs );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId) const
+{
+ return OApplicationController_CBASE::isCommandEnabled( _nCommandId );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
+{
+ return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL );
+}
+
+// -----------------------------------------------------------------------------
+sal_uInt16 OApplicationController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL )
+{
+ return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::notifyHiContrastChanged()
+{
+ OApplicationController_CBASE::notifyHiContrastChanged();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XController > OApplicationController::getXController() throw( RuntimeException )
+{
+ return OApplicationController_CBASE::getXController();
+}
+
+// -----------------------------------------------------------------------------
+bool OApplicationController::interceptUserInput( const NotifyEvent& _rEvent )
+{
+ return OApplicationController_CBASE::interceptUserInput( _rEvent );
+}
+
+// -----------------------------------------------------------------------------
+PopupMenu* OApplicationController::getContextMenu( Control& /*_rControl*/ ) const
+{
+ return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT ) );
+}
+
+// -----------------------------------------------------------------------------
+IController& OApplicationController::getCommandController()
+{
+ return *static_cast< IApplicationController* >( this );
+}
+
+// -----------------------------------------------------------------------------
+::cppu::OInterfaceContainerHelper* OApplicationController::getContextMenuInterceptors()
+{
+ return &m_aContextMenuInterceptors;
+}
+
+// -----------------------------------------------------------------------------
+Any OApplicationController::getCurrentSelection( Control& _rControl ) const
+{
+ Sequence< NamedDatabaseObject > aSelection;
+ getContainer()->describeCurrentSelectionForControl( _rControl, aSelection );
+ return makeAny( aSelection );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::requestQuickHelp( const SvLBoxEntry* /*_pEntry*/, String& /*_rText*/ ) const
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::requestDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
+{
+ TransferableHelper* pTransfer = NULL;
+ if ( getContainer() && getContainer()->getSelectionCount() )
+ {
+ try
+ {
+ pTransfer = copyObject( );
+ Reference< XTransferable> xEnsureDelete = pTransfer;
+
+ if ( pTransfer && getContainer()->getDetailView() )
+ {
+ ElementType eType = getContainer()->getElementType();
+ pTransfer->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType == E_FORM || eType == E_REPORT) ? DND_ACTION_COPYMOVE : DND_ACTION_COPY) );
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return NULL != pTransfer;
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
+{
+ sal_Int8 nActionAskedFor = _rEvt.mnAction;
+ // check if we're a table or query container
+ OApplicationView* pView = getContainer();
+ if ( pView && !isDataSourceReadOnly() )
+ {
+ ElementType eType = pView->getElementType();
+ if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) )
+ {
+ // check for the concrete type
+ if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType,sal_True)) != _rFlavors.end())
+ return DND_ACTION_COPY;
+ if ( eType == E_FORM || eType == E_REPORT )
+ {
+ sal_Int8 nAction = OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE;
+ if ( nAction != DND_ACTION_NONE )
+ {
+ SvLBoxEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
+ ::rtl::OUString sName;
+ if ( pHitEntry )
+ {
+ sName = pView->getQualifiedName( pHitEntry );
+ if ( sName.getLength() )
+ {
+ Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY);
+ if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) )
+ {
+ Reference< XHierarchicalNameAccess > xHitObject(xContainer->getByHierarchicalName(sName),UNO_QUERY);
+ if ( xHitObject.is() )
+ nAction = nActionAskedFor & DND_ACTION_COPYMOVE;
+ }
+ else
+ nAction = DND_ACTION_NONE;
+ }
+ }
+ }
+ return nAction;
+ }
+ }
+ }
+
+ return DND_ACTION_NONE;
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt )
+{
+ OApplicationView* pView = getContainer();
+ if ( !pView || pView->getElementType() == E_NONE )
+ {
+ OSL_FAIL("OApplicationController::executeDrop: what the hell did queryDrop do?");
+ // queryDrop shoud not have allowed us to reach this situation ....
+ return DND_ACTION_NONE;
+ }
+
+ // a TransferableDataHelper for accessing the dropped data
+ TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
+
+
+ // reset the data of the previous async drop (if any)
+ if ( m_nAsyncDrop )
+ Application::RemoveUserEvent(m_nAsyncDrop);
+
+
+ m_nAsyncDrop = 0;
+ m_aAsyncDrop.aDroppedData.clear();
+ m_aAsyncDrop.nType = pView->getElementType();
+ m_aAsyncDrop.nAction = _rEvt.mnAction;
+ m_aAsyncDrop.bError = sal_False;
+ m_aAsyncDrop.bHtml = sal_False;
+ m_aAsyncDrop.aUrl = ::rtl::OUString();
+
+
+ // loop through the available formats and see what we can do ...
+ // first we have to check if it is our own format, if not we have to copy the stream :-(
+ if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) )
+ {
+ m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData);
+
+ // asyncron because we some dialogs and we aren't allowed to show them while in D&D
+ m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
+ return DND_ACTION_COPY;
+ }
+ else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector(),m_aAsyncDrop.nType == E_FORM) )
+ {
+ m_aAsyncDrop.aDroppedData = OComponentTransferable::extractComponentDescriptor(aDroppedData);
+ SvLBoxEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
+ if ( pHitEntry )
+ m_aAsyncDrop.aUrl = pView->getQualifiedName( pHitEntry );
+
+ sal_Int8 nAction = _rEvt.mnAction;
+ Reference<XContent> xContent;
+ m_aAsyncDrop.aDroppedData[daComponent] >>= xContent;
+ if ( xContent.is() )
+ {
+ ::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
+ sal_Int32 nIndex = 0;
+ sName = sName.copy(sName.getToken(0,'/',nIndex).getLength() + 1);
+ if ( m_aAsyncDrop.aUrl.Len() >= sName.getLength() && 0 == sName.compareTo(m_aAsyncDrop.aUrl,sName.getLength()) )
+ {
+ m_aAsyncDrop.aDroppedData.clear();
+ return DND_ACTION_NONE;
+ }
+
+ // check if move is allowed, if another object with the same name exists only copy is allowed
+ Reference< XHierarchicalNameAccess > xContainer(getElements(m_aAsyncDrop.nType),UNO_QUERY);
+ Reference<XNameAccess> xNameAccess(xContainer,UNO_QUERY);
+
+ if ( m_aAsyncDrop.aUrl.Len() && xContainer.is() && xContainer->hasByHierarchicalName(m_aAsyncDrop.aUrl) )
+ xNameAccess.set(xContainer->getByHierarchicalName(m_aAsyncDrop.aUrl),UNO_QUERY);
+
+ if ( xNameAccess.is() )
+ {
+ Reference<XPropertySet> xProp(xContent,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
+ if ( xNameAccess.is() && xNameAccess->hasByName(sName) )
+ nAction &= ~DND_ACTION_MOVE;
+ }
+ else
+ nAction &= ~DND_ACTION_MOVE;
+ }
+ }
+ if ( nAction != DND_ACTION_NONE )
+ {
+ m_aAsyncDrop.nAction = nAction;
+ // asyncron because we some dialogs and we aren't allowed to show them while in D&D
+ m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
+ }
+ else
+ m_aAsyncDrop.aDroppedData.clear();
+ return nAction;
+ }
+ else
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() && m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xConnection ) )
+ {
+ // asyncron because we some dialogs and we aren't allowed to show them while in D&D
+ m_nAsyncDrop = Application::PostUserEvent(LINK(this, OApplicationController, OnAsyncDrop));
+ return DND_ACTION_COPY;
+ }
+ }
+
+ return DND_ACTION_NONE;
+}
+// -----------------------------------------------------------------------------
+Reference< XModel > SAL_CALL OApplicationController::getModel(void) throw( RuntimeException )
+{
+ return m_xModel;
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::onAttachedFrame()
+{
+ sal_Int32 nConnectedControllers( 0 );
+ try
+ {
+ Reference< XModel2 > xModel( m_xModel, UNO_QUERY_THROW );
+ Reference< XEnumeration > xEnumControllers( xModel->getControllers(), UNO_SET_THROW );
+ while ( xEnumControllers->hasMoreElements() )
+ {
+ Reference< XController > xController( xEnumControllers->nextElement(), UNO_QUERY_THROW );
+ ++nConnectedControllers;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( nConnectedControllers > 1 )
+ { // we are not the first connected controller, there were already others
+ return;
+ }
+
+ m_aControllerConnectedEvent.Call();
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnFirstControllerConnected, void*, /**/ )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( !m_xModel.is() )
+ {
+ OSL_FAIL( "OApplicationController::OnFirstControllerConnected: too late!" );
+ }
+
+ // if we have forms or reports which contain macros/scripts, then show a warning
+ // which suggests the user to migrate them to the database document
+ Reference< XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
+ if ( xDocumentScripts.is() )
+ {
+ // no need to show this warning, obviously the document supports embedding scripts
+ // into itself, so there are no "old-style" forms/reports which have macros/scripts
+ // themselves
+ return 0L;
+ }
+
+ try
+ {
+ // If the migration just happened, but was not successful, the document is reloaded.
+ // In this case, we should not show the warning, again.
+ ::comphelper::NamedValueCollection aModelArgs( m_xModel->getArgs() );
+ if ( aModelArgs.getOrDefault( "SuppressMigrationWarning", sal_False ) )
+ return 0L;
+
+ // also, if the document is read-only, then no migration is possible, and the
+ // respective menu entry is hidden. So, don't show the warning in this case, too.
+ if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() )
+ return 0L;
+
+ SQLWarning aWarning;
+ aWarning.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS ) );
+ SQLException aDetail;
+ aDetail.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL ) );
+ aWarning.NextException <<= aDetail;
+
+ ::comphelper::ComponentContext aContext( getORB() );
+ Sequence< Any > aArgs(1);
+ aArgs[0] <<= NamedValue( PROPERTY_SQLEXCEPTION, makeAny( aWarning ) );
+ Reference< XExecutableDialog > xDialog(
+ aContext.createComponentWithArguments( "com.sun.star.sdb.ErrorMessageDialog", aArgs ),
+ UNO_QUERY_THROW );
+ xDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return 1L;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::attachFrame( const Reference< XFrame > & i_rxFrame ) throw( RuntimeException )
+{
+ OApplicationController_CBASE::attachFrame( i_rxFrame );
+ if ( getFrame().is() )
+ onAttachedFrame();
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > & _rxModel) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
+ if ( !xOfficeDoc.is() && _rxModel.is() )
+ {
+ OSL_FAIL( "OApplicationController::attachModel: invalid model!" );
+ return sal_False;
+ }
+
+ OSL_ENSURE( !( m_xModel.is() && ( m_xModel != _rxModel ) ),
+ "OApplicationController::attachModel: missing implementation: setting a new model while we have another one!" );
+ // at least: remove as property change listener from the old model/data source
+
+ m_xModel = _rxModel;
+ if ( m_xModel.is() )
+ {
+ m_xDocumentModify.set( m_xModel, UNO_QUERY_THROW );
+ }
+ else
+ {
+ m_xDocumentModify.clear();
+ }
+
+ m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : Reference<XDataSource>(),UNO_QUERY);
+ if ( m_xDataSource.is() )
+ {
+ try
+ {
+ m_xDataSource->addPropertyChangeListener(PROPERTY_INFO, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_URL, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_TABLEFILTER, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
+ m_xDataSource->addPropertyChangeListener(PROPERTY_USER, this);
+ // to get the 'modified' for the data source
+ Reference< XModifyBroadcaster > xBroadcaster(m_xModel, UNO_QUERY);
+ if ( xBroadcaster.is() )
+ xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
+
+ Sequence<PropertyValue> aFields;
+ m_xDataSource->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aFields;
+ PropertyValue *pIter = aFields.getArray();
+ PropertyValue *pEnd = pIter + aFields.getLength();
+ for (; pIter != pEnd && pIter->Name != INFO_PREVIEW; ++pIter)
+ ;
+
+ if ( pIter != pEnd )
+ {
+ sal_Int32 nValue = 0;
+ pIter->Value >>= nValue;
+ m_ePreviewMode = static_cast<PreviewMode>(nValue);
+ if ( getView() )
+ {
+ getContainer()->switchPreview(m_ePreviewMode);
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::containerFound( const Reference< XContainer >& _xContainer)
+{
+ try
+ {
+ if ( _xContainer.is() )
+ {
+ m_aCurrentContainers.push_back(_xContainer);
+ _xContainer->addContainerListener(this);
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationController::getCurrentlySelectedName(sal_Int32& _rnCommandType) const
+{
+ _rnCommandType = ( (getContainer()->getElementType() == E_QUERY)
+ ? CommandType::QUERY : ( (getContainer()->getElementType() == E_TABLE) ? CommandType::TABLE : -1 ));
+
+
+ ::rtl::OUString sName;
+ if ( _rnCommandType != -1 )
+ {
+ try
+ {
+ sName = getContainer()->getQualifiedName( NULL );
+ OSL_ENSURE( sName.getLength(), "OApplicationController::getCurrentlySelectedName: no name given!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sName;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
+{
+ m_pSelectionNotifier->addListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
+{
+ m_pSelectionNotifier->removeListener( _Listener );
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ Sequence< ::rtl::OUString> aSelection;
+ if ( !_aSelection.hasValue() || !getView() )
+ {
+ getContainer()->selectElements(aSelection);
+ return sal_True;
+ }
+
+ // --------------------------------------------------------------
+ // BEGIN compatibility
+ Sequence< NamedValue > aCurrentSelection;
+ if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() )
+ {
+ ElementType eType = E_NONE;
+ const NamedValue* pIter = aCurrentSelection.getConstArray();
+ const NamedValue* pEnd = pIter + aCurrentSelection.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( pIter->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Type")) )
+ {
+ sal_Int32 nType = 0;
+ pIter->Value >>= nType;
+ if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT )
+ throw IllegalArgumentException();
+ eType = static_cast< ElementType >( nType );
+ }
+ else if ( pIter->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Selection")) )
+ pIter->Value >>= aSelection;
+ }
+
+ m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
+ getContainer()->selectContainer(eType);
+ getContainer()->selectElements(aSelection);
+ return sal_True;
+ }
+ // END compatibility
+ // --------------------------------------------------------------
+
+ Sequence< NamedDatabaseObject > aSelectedObjects;
+ if ( !( _aSelection >>= aSelectedObjects ) )
+ {
+ aSelectedObjects.realloc( 1 );
+ if ( !( _aSelection >>= aSelectedObjects[0] ) )
+ throw IllegalArgumentException();
+ }
+
+ SelectionByElementType aSelectedElements;
+ ElementType eSelectedCategory = E_NONE;
+ for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray();
+ pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength();
+ ++pObject
+ )
+ {
+ switch ( pObject->Type )
+ {
+ case DatabaseObject::TABLE:
+ case DatabaseObjectContainer::SCHEMA:
+ case DatabaseObjectContainer::CATALOG:
+ aSelectedElements[ E_TABLE ].push_back( pObject->Name );
+ break;
+ case DatabaseObject::QUERY:
+ aSelectedElements[ E_QUERY ].push_back( pObject->Name );
+ break;
+ case DatabaseObject::FORM:
+ case DatabaseObjectContainer::FORMS_FOLDER:
+ aSelectedElements[ E_FORM ].push_back( pObject->Name );
+ break;
+ case DatabaseObject::REPORT:
+ case DatabaseObjectContainer::REPORTS_FOLDER:
+ aSelectedElements[ E_REPORT ].push_back( pObject->Name );
+ break;
+ case DatabaseObjectContainer::TABLES:
+ case DatabaseObjectContainer::QUERIES:
+ case DatabaseObjectContainer::FORMS:
+ case DatabaseObjectContainer::REPORTS:
+ if ( eSelectedCategory != E_NONE )
+ throw IllegalArgumentException(
+ String(ModuleRes(RID_STR_NO_DIFF_CAT)),
+ *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) );
+ eSelectedCategory =
+ ( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE
+ : ( pObject->Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY
+ : ( pObject->Type == DatabaseObjectContainer::FORMS ) ? E_FORM
+ : ( pObject->Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT
+ : E_NONE;
+ break;
+
+ default:
+ case DatabaseObjectContainer::DATA_SOURCE:
+ {
+ ::rtl::OUString sMessage = String(ModuleRes( RID_STR_UNSUPPORTED_OBJECT_TYPE ));
+ ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$type$", ::rtl::OUString::valueOf(sal_Int32( pObject->Type )) );
+ throw IllegalArgumentException(sMessage, *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ));
+ }
+ }
+ }
+
+ for ( SelectionByElementType::const_iterator sel = aSelectedElements.begin();
+ sel != aSelectedElements.end();
+ ++sel
+ )
+ {
+ if ( sel->first == m_eCurrentType )
+ {
+ Sequence< ::rtl::OUString > aSelected( sel->second.size() );
+ ::std::copy( sel->second.begin(), sel->second.end(), aSelected.getArray() );
+ getContainer()->selectElements( aSelected );
+ }
+ else
+ {
+ m_aPendingSelection[ sel->first ] = sel->second;
+ }
+ }
+
+ m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running
+ getContainer()->selectContainer( eSelectedCategory );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OApplicationController::getSelection( ) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ Sequence< NamedDatabaseObject > aCurrentSelection;
+ const ElementType eType( getContainer()->getElementType() );
+ if ( eType != E_NONE )
+ {
+ getContainer()->describeCurrentSelectionForType( eType, aCurrentSelection );
+ if ( aCurrentSelection.getLength() == 0 )
+ { // if no objects are selected, add an entry to the sequence which describes the overall category
+ // which is selected currently
+ aCurrentSelection.realloc(1);
+ aCurrentSelection[0].Name = getDatabaseName();
+ switch ( eType )
+ {
+ case E_TABLE: aCurrentSelection[0].Type = DatabaseObjectContainer::TABLES; break;
+ case E_QUERY: aCurrentSelection[0].Type = DatabaseObjectContainer::QUERIES; break;
+ case E_FORM: aCurrentSelection[0].Type = DatabaseObjectContainer::FORMS; break;
+ case E_REPORT: aCurrentSelection[0].Type = DatabaseObjectContainer::REPORTS; break;
+ default:
+ OSL_FAIL( "OApplicationController::getSelection: unexpected current element type!" );
+ break;
+ }
+ }
+ }
+ return makeAny( aCurrentSelection );
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::impl_migrateScripts_nothrow()
+{
+ try
+ {
+ ::rtl::OUString sDialogService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.MacroMigrationWizard" ) );
+ ::comphelper::ComponentContext aContext( getORB() );
+ Sequence< Any > aDialogArgs(1);
+ aDialogArgs[0] <<= Reference< XOfficeDatabaseDocument >( m_xModel, UNO_QUERY_THROW );
+ Reference< XExecutableDialog > xDialog(
+ aContext.createComponentWithArguments( sDialogService, aDialogArgs ),
+ UNO_QUERY );
+
+ if ( !xDialog.is() )
+ {
+ ShowServiceNotAvailableError( getView(), sDialogService, true );
+ return;
+ }
+
+ xDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx
new file mode 100644
index 000000000000..8067846c2c1e
--- /dev/null
+++ b/dbaccess/source/ui/app/AppController.hxx
@@ -0,0 +1,578 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_APPCONTROLLER_HXX
+#define DBAUI_APPCONTROLLER_HXX
+
+#include "IApplicationController.hxx"
+#include "AppElementType.hxx"
+#include "callbacks.hxx"
+#include "commontypes.hxx"
+#include "dsntypes.hxx"
+#include "genericcontroller.hxx"
+#include "linkeddocuments.hxx"
+#include "moduledbu.hxx"
+#include "TableCopyHelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/ui/XContextMenuInterception.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/stl_types.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase5.hxx>
+#include <sot/storage.hxx>
+#include <svtools/transfer.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <vcl/timer.hxx>
+
+#include <memory>
+
+class ListBox;
+class SvLBoxEntry;
+class SvTreeListBox;
+class TransferableHelper;
+class TransferableClipboardListener;
+class SfxFilter;
+
+FORWARD_DECLARE_INTERFACE(container,XNameContainer)
+FORWARD_DECLARE_INTERFACE(container,XContainer)
+FORWARD_DECLARE_INTERFACE(ucb,XContent)
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ class SubComponentManager;
+
+ //====================================================================
+ //= OApplicationController
+ //====================================================================
+ class OApplicationController;
+ class OApplicationView;
+ class OLinkedDocumentsAccess;
+ typedef OGenericUnoController OApplicationController_CBASE;
+ typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::sdb::application::XDatabaseDocumentUI
+ , ::com::sun::star::ui::XContextMenuInterception
+ , ::com::sun::star::view::XSelectionSupplier
+ > OApplicationController_Base;
+
+ class SelectionNotifier;
+
+ class OApplicationController
+ :public OApplicationController_CBASE
+ ,public OApplicationController_Base
+ ,public IApplicationController
+ {
+ public:
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > TContainer;
+ typedef ::std::vector< TContainer > TContainerVector;
+
+ private:
+
+ OTableCopyHelper::DropDescriptor m_aAsyncDrop;
+
+ SharedConnection m_xDataSourceConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >
+ m_xMetaData;
+
+ OModuleClient m_aModuleClient;
+ TransferableDataHelper m_aSystemClipboard; // content of the clipboard
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xDataSource;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifiable >
+ m_xDocumentModify;
+ ::cppu::OInterfaceContainerHelper
+ m_aContextMenuInterceptors;
+
+ TContainerVector m_aCurrentContainers; // the containers where we are listener on
+ ::rtl::Reference< SubComponentManager >
+ m_pSubComponentManager;
+ ::dbaccess::ODsnTypeCollection
+ m_aTypeCollection;
+ OTableCopyHelper m_aTableCopyHelper;
+ TransferableClipboardListener*
+ m_pClipbordNotifier; // notifier for changes in the clipboard
+ sal_uLong m_nAsyncDrop;
+ OAsyncronousLink m_aControllerConnectedEvent;
+ OAsyncronousLink m_aSelectContainerEvent;
+ PreviewMode m_ePreviewMode; // the mode of the preview
+ ElementType m_eCurrentType;
+ sal_Bool m_bNeedToReconnect; // true when the settings of the data source were modified and the connection is no longer up to date
+ sal_Bool m_bSuspended; // is true when the controller was already suspended
+
+ ::std::auto_ptr< SelectionNotifier >
+ m_pSelectionNotifier;
+ typedef ::std::map< ElementType, ::std::vector< ::rtl::OUString > > SelectionByElementType;
+ SelectionByElementType m_aPendingSelection;
+
+ private:
+
+ OApplicationView* getContainer() const;
+
+
+ /** returns the database name
+ @return
+ the database name
+ */
+ ::rtl::OUString getDatabaseName() const;
+
+ /** returns the stripped database name.
+ @return
+ The stripped database name either the registered naem or if it is a file url the last segment.
+ */
+ ::rtl::OUString getStrippedDatabaseName() const;
+
+ /** return the element type for given container
+ @param _xContainer The container where the element type has to be found
+ @return the element type coressponding to the given container
+ */
+ ElementType getElementType(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer) const;
+
+ /** opens a new frame with either the table or the query or report or form or view
+ @param _sName
+ The name of the object to open
+ @param _eType
+ Defines the type to open
+ @param _eOpenMode
+ denotes the mode in which to open the object
+ @param _nInstigatorCommand
+ denotes the command which instigated the action. Might be 0.
+ @return the form or report model will only be returned, otherwise <NULL/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > openElement(
+ const ::rtl::OUString& _sName,
+ ElementType _eType,
+ ElementOpenMode _eOpenMode,
+ sal_uInt16 _nInstigatorCommand = 0
+ );
+
+ /** opens a new sub frame with a table/query/form/report/view, passing additional arguments
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > openElementWithArguments(
+ const ::rtl::OUString& _sName,
+ ElementType _eType,
+ ElementOpenMode _eOpenMode,
+ sal_uInt16 _nInstigatorCommand,
+ const ::comphelper::NamedValueCollection& _rAdditionalArguments
+ );
+
+ /** opens a new frame for creation or auto pilot
+ @param _eType
+ Defines the type to open
+ @param i_rAdditionalArguments
+ Additional arguments to pass when creating the component
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ newElement(
+ ElementType _eType,
+ const ::comphelper::NamedValueCollection& i_rAdditionalArguments,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_rDocumentDefinition
+ );
+
+ /** creates a new database object, using an auto pilot
+ @param _eType
+ Defines the type of the object to create
+ @precond
+ Our mutex must not be locked.
+ @since #i39203#
+ */
+ void newElementWithPilot( ElementType _eType );
+
+ /** converts the query to a view
+ @param _sName
+ The name of the query.
+ */
+ void convertToView(const ::rtl::OUString& _sName);
+
+ /** checks if the connection for the selected data source is read only. If the connection doesn't exist, <TRUE/> will be returned.
+ @return
+ <TRUE/> if read only or doesn't exist, otherwise <FALSE/>
+ */
+ sal_Bool isConnectionReadOnly() const;
+
+ /// fills the list with the selected entries.
+ void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
+
+ /// deletes the entries selected.
+ void deleteEntries();
+
+ /// renames the selected entry in the detail page
+ void renameEntry();
+
+ /** deletes queries, forms, or reports
+ @param _eType
+ the type of the objects
+ @param _rList
+ The names of the elements to delete
+ @param _bConfirm
+ determines whether the user must confirm the deletion
+ */
+ void deleteObjects( ElementType _eType,
+ const ::std::vector< ::rtl::OUString>& _rList,
+ bool _bConfirm );
+
+ /** deletes tables.
+ @param _rList
+ The list of tables.
+ */
+ void deleteTables(const ::std::vector< ::rtl::OUString>& _rList);
+
+ /// copies the current object into clipboard
+ TransferableHelper* copyObject();
+
+ /// returns the nameaccess
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getElements(ElementType _eType);
+
+ /** returns the document access for the specific type
+ @param _eType
+ the type
+ @return ::std::auto_ptr<OLinkedDocumentsAccess>
+ */
+ ::std::auto_ptr<OLinkedDocumentsAccess> getDocumentsAccess(ElementType _eType);
+
+ /// returns the query definitions of the active data source.
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer> getQueryDefintions() const;
+
+ /** pastes a special format from the system clipboard to the currently selected object types
+ @param _nFormatId
+ The format to be copied.
+ */
+ void pasteFormat(sal_uInt32 _nFormatId);
+
+ /** pastes a query, form or report into the data source
+ @param _eType
+ The type of the object to paste.
+ @param _rPasteData
+ The data descriptor.
+ @param _sParentFolder
+ The name of the parent folder if it exists.
+ @param _bMove
+ if <TRUE/> the name of the content must be inserted without any change, otherwise not.
+ @return
+ <TRUE/> if the paste opertions was successfull, otherwise <FALSE/>.
+ */
+ sal_Bool paste( ElementType _eType,const ::svx::ODataAccessDescriptor& _rPasteData ,const String& _sParentFolder = String(),sal_Bool _bMove = sal_False);
+
+ /// returns the system clipboard.
+ const TransferableDataHelper& getViewClipboard() const { return m_aSystemClipboard; }
+
+ /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
+ sal_Bool isTableFormat() const;
+
+ /** fills the vector with all supported formats
+ @param _eType
+ The type for which we need the formats
+ @param _rFormatIds
+ The vector to be filled up.
+ */
+ void getSupportedFormats(ElementType _eType,::std::vector<SotFormatStringId>& _rFormatIds) const;
+
+ /** adds a listener to the current name access.
+ @param _xCollection
+ The collection where we want to listen on.
+ */
+ void addContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xCollection);
+
+ /** opens a uno dialog withthe currently selected data source as initialize argument
+ @param _sServiceName
+ The serivce name of the dialog to be executed.
+ */
+ void openDialog(const ::rtl::OUString& _sServiceName);
+
+ /** opens the administration dialog for the selected data source
+ */
+ void openDataSourceAdminDialog();
+
+ /** opens the table filter dialog for the selected data source
+ */
+ void openTableFilterDialog();
+
+ /** opens the DirectSQLDialog to execute hand made sql statements.
+ */
+ void openDirectSQLDialog();
+
+ /** when the settings of the data source changed,
+ it opens a dialog which ask to close all depending documents, then recreate the connection.
+ The SolarMutex has to be locked before calling this.
+ */
+ void askToReconnect();
+
+ /** remember a newly opened sub document for later access
+ */
+ void onDocumentOpened(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nType,
+ const ElementOpenMode _eMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDocument,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition
+ );
+
+ /** Inserts a new object into the hierachy given be the type.
+ @param _eType
+ Where to insert the new item.
+ @param _sParentFolder
+ The name of the parent folder if it exists.
+ @param _xContent
+ The content to insert.
+ @param _bMove
+ if <TRUE/> the name of the content must be inserted without any change, otherwise not.
+ @return
+ <TRUE/> if the insert opertions was successfull, otherwise <FALSE/>.
+ */
+ sal_Bool insertHierachyElement( ElementType _eType
+ ,const String& _sParentFolder
+ ,sal_Bool _bCollection = sal_True
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent = ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>()
+ ,sal_Bool _bMove = sal_False);
+ /** checks if delete command or rename comamnd is allowed
+ @param _eType
+ The element type.
+ @param _bDelete
+ If <TRUE> then the delete command should be checked.
+ @return
+ <TRUE> if the command is allowed
+ */
+ sal_Bool isRenameDeleteAllowed(ElementType _eType,sal_Bool _bDelete) const;
+ /** all selected entries will be opened, or edited, or converted to a view
+ @param _nId
+ The slot which should be executed.
+ @param _eOpenMode
+ Defines the mode of opening. @see ElementOpenMode
+ */
+ void doAction(sal_uInt16 _nId ,ElementOpenMode _eOpenMode);
+
+ /** returns the currently selected table or query name.
+ *
+ * \return the name of the currently table or query. If the tables or query container is selected otherwise an empty string will be returned.
+ */
+ ::rtl::OUString getCurrentlySelectedName(sal_Int32& _rnCommandType) const;
+
+ /** shows the preview for the given entry
+ */
+ void showPreviewFor( const ElementType _eType,const ::rtl::OUString& _sName );
+
+ /** called we were attached to a frame
+
+ In particular, this is called *after* the controller has been announced to the model
+ (XModel::connectController)
+ */
+ void onAttachedFrame();
+
+ /// determines whether the given table name denotes a view which can be altered
+ bool impl_isAlterableView_nothrow( const ::rtl::OUString& _rTableOrViewName ) const;
+
+ /** does the macro/script migration, where macros/scripts in forms/reports are moved
+ to the database document itself.
+ */
+ void impl_migrateScripts_nothrow();
+
+ /** verifies the object type denotes a valid DatabaseObject, and the object name denotes an existing
+ object of this type. Throws if not.
+ */
+ void impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::boost::optional< ::rtl::OUString >& i_rObjectName );
+
+ protected:
+ // ----------------------------------------------------------------
+ // initalizing members
+ /** forces usage of a connection which we do not own
+ <p>To be used from within XInitialization::initialize only.</p>
+ */
+ void initializeConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxForeignConn );
+
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ // OGenericUnoController
+ virtual void onLoadedMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getPrivateModel() const
+ {
+ return m_xModel;
+ }
+
+ virtual ~OApplicationController();
+
+ public:
+ OApplicationController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // ::com::sun::star::frame::XController
+ virtual void SAL_CALL attachFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL attachModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModel(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseDocumentUI
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getApplicationMainWindow() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getActiveConnection() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > > SAL_CALL getSubComponents() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isConnected( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL connect( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Pair< ::sal_Int32, ::rtl::OUString > SAL_CALL identifySubComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& SubComponent ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL closeSubComponents( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponent( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponentWithArguments( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL createComponent( ::sal_Int32 ObjectType, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_DocumentDefinition ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL createComponentWithArguments( ::sal_Int32 ObjectType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_DocumentDefinition ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XContextMenuInterception
+ virtual void SAL_CALL registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XSelectionSupplier
+ virtual ::sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& xSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ /** retrieves the current connection, creates it if necessary
+
+ If an error occurs, then this is either stored in the location pointed to by <arg>_pErrorInfo</arg>,
+ or, if <code>_pErrorInfo</code> is <NULL/>, then the error is displayed to the user.
+ */
+ const SharedConnection& ensureConnection( ::dbtools::SQLExceptionInfo* _pErrorInfo = NULL );
+
+ /** retrieves the current connection
+ */
+ const SharedConnection& getConnection() const { return m_xDataSourceConnection; }
+
+ /// determines whether we're currently connected to the database
+ bool isConnected() const { return m_xDataSourceConnection.is(); }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >&
+ getConnectionMetaData() const { return m_xMetaData; }
+
+ /** refreshes the tables
+ */
+ void refreshTables();
+
+ // IApplicationController
+ virtual bool onEntryDoubleClick(SvTreeListBox& _rTree);
+ virtual sal_Bool onContainerSelect(ElementType _eType);
+ virtual void onSelectionChanged();
+ virtual void onCutEntry();
+ virtual void onCopyEntry();
+ virtual void onPasteEntry();
+ virtual void onDeleteEntry();
+ virtual void previewChanged( sal_Int32 _nMode);
+ virtual void containerFound( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer);
+
+ // IController (base of IApplicationController)
+ virtual void executeUnChecked(const ::com::sun::star::util::URL& _rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+ virtual void executeChecked(const ::com::sun::star::util::URL& _rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+ virtual void executeUnChecked(sal_uInt16 _nCommandId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+ virtual void executeChecked(sal_uInt16 _nCommandId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+ virtual sal_Bool isCommandEnabled(sal_uInt16 _nCommandId) const;
+ virtual sal_Bool isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const;
+ virtual sal_uInt16 registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL );
+ virtual void notifyHiContrastChanged();
+ virtual sal_Bool isDataSourceReadOnly() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
+ getXController(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual bool interceptUserInput( const NotifyEvent& _rEvent );
+
+ // IControlActionListener overridables
+ virtual sal_Bool requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const;
+ virtual sal_Bool requestDrag( sal_Int8 _nAction, const Point& _rPosPixel );
+ virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors );
+ virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt );
+
+ // IContextMenuProvider (base of IApplicationController)
+ virtual PopupMenu* getContextMenu( Control& _rControl ) const;
+ virtual IController& getCommandController();
+ virtual ::cppu::OInterfaceContainerHelper*
+ getContextMenuInterceptors();
+ virtual ::com::sun::star::uno::Any
+ getCurrentSelection( Control& _rControl ) const;
+
+ DECL_LINK( OnInvalidateClipboard, void* );
+ DECL_LINK( OnClipboardChanged, void* );
+ DECL_LINK( OnAsyncDrop, void* );
+ DECL_LINK( OnCreateWithPilot, void* );
+ DECL_LINK( OnSelectContainer, void* );
+ DECL_LINK( OnFirstControllerConnected, void* );
+
+ protected:
+ using OApplicationController_CBASE::connect;
+
+ /** disconnects from our XConnection, and cleans up this connection
+ */
+ virtual void disconnect();
+
+ // late construction
+ virtual sal_Bool Construct(Window* pParent);
+ virtual void describeSupportedFeatures();
+
+ protected:
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBAUI_APPCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppControllerDnD.cxx b/dbaccess/source/ui/app/AppControllerDnD.cxx
new file mode 100644
index 000000000000..7e8f56972e0f
--- /dev/null
+++ b/dbaccess/source/ui/app/AppControllerDnD.cxx
@@ -0,0 +1,818 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppController.hxx"
+#include <comphelper/sequence.hxx>
+#include <comphelper/property.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <tools/urlobj.hxx>
+#include <unotools/ucbhelper.hxx>
+#include "dlgsave.hxx"
+#include <comphelper/types.hxx>
+#include <vcl/msgbox.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <connectivity/dbexception.hxx>
+#include <vcl/waitobj.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "AppView.hxx"
+#include <svx/dataaccessdescriptor.hxx>
+#include <svx/dbaobjectex.hxx>
+#include "browserids.hxx"
+#include "dbu_reghelper.hxx"
+#include "dbu_app.hrc"
+#include <vcl/menu.hxx>
+#include <comphelper/uno3.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/svlbitm.hxx>
+#include "listviewitems.hxx"
+#include "AppDetailView.hxx"
+#include "linkeddocuments.hxx"
+#include <vcl/lstbox.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include "sqlmessage.hxx"
+#include <tools/string.hxx>
+#include "dbexchange.hxx"
+#include "UITools.hxx"
+#include <algorithm>
+#include <svtools/svtreebx.hxx>
+#include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
+#include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
+#include <sfx2/filedlghelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svtools/fileview.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "defaultobjectnamecheck.hxx"
+#include <osl/mutex.hxx>
+#include "subcomponentmanager.hxx"
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+using namespace ::dbtools;
+using namespace ::svx;
+using namespace ::svtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::util;
+
+// -----------------------------------------------------------------------------
+void OApplicationController::deleteTables(const ::std::vector< ::rtl::OUString>& _rList)
+{
+ SharedConnection xConnection( ensureConnection() );
+
+ Reference<XTablesSupplier> xSup(xConnection,UNO_QUERY);
+ OSL_ENSURE(xSup.is(),"OApplicationController::deleteTable: no XTablesSuppier!");
+ if ( xSup.is() )
+ {
+ Reference<XNameAccess> xTables = xSup->getTables();
+ Reference<XDrop> xDrop(xTables,UNO_QUERY);
+ if ( xDrop.is() )
+ {
+ bool bConfirm = true;
+ ::std::vector< ::rtl::OUString>::const_iterator aEnd = _rList.end();
+ for (::std::vector< ::rtl::OUString>::const_iterator aIter = _rList.begin(); aIter != aEnd; ++aIter)
+ {
+ ::rtl::OUString sTableName = *aIter;
+
+ sal_Int32 nResult = RET_YES;
+ if ( bConfirm )
+ nResult = ::dbaui::askForUserAction(getView(),STR_TITLE_CONFIRM_DELETION ,STR_QUERY_DELETE_TABLE,_rList.size() > 1 && (aIter+1) != _rList.end(),sTableName);
+
+ bool bUserConfirmedDelete =
+ ( RET_YES == nResult )
+ || ( RET_ALL == nResult );
+ if ( bUserConfirmedDelete && m_pSubComponentManager->closeSubFrames( sTableName, E_TABLE ) )
+ {
+ SQLExceptionInfo aErrorInfo;
+ try
+ {
+ if ( xTables->hasByName(sTableName) )
+ xDrop->dropByName(sTableName);
+ else
+ {// could be a view
+ Reference<XViewsSupplier> xViewsSup(xConnection,UNO_QUERY);
+
+ Reference<XNameAccess> xViews;
+ if ( xViewsSup.is() )
+ {
+ xViews = xViewsSup->getViews();
+ if ( xViews.is() && xViews->hasByName(sTableName) )
+ {
+ xDrop.set(xViews,UNO_QUERY);
+ if ( xDrop.is() )
+ xDrop->dropByName(sTableName);
+ }
+ }
+ }
+ }
+ catch(SQLContext& e) { aErrorInfo = e; }
+ catch(SQLWarning& e) { aErrorInfo = e; }
+ catch(SQLException& e) { aErrorInfo = e; }
+ catch(WrappedTargetException& e)
+ {
+ SQLException aSql;
+ if(e.TargetException >>= aSql)
+ aErrorInfo = aSql;
+ else
+ OSL_FAIL("OApplicationController::implDropTable: something strange happended!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( aErrorInfo.isValid() )
+ showError(aErrorInfo);
+
+ if ( RET_ALL == nResult )
+ bConfirm = false;
+ }
+ else
+ break;
+ }
+ }
+ else
+ {
+ String sMessage(ModuleRes(STR_MISSING_TABLES_XDROP));
+ ErrorBox aError(getView(), WB_OK, sMessage);
+ aError.Execute();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::deleteObjects( ElementType _eType, const ::std::vector< ::rtl::OUString>& _rList, bool _bConfirm )
+{
+ Reference< XNameContainer > xNames( getElements( _eType ), UNO_QUERY );
+ Reference< XHierarchicalNameContainer > xHierarchyName( xNames, UNO_QUERY );
+ if ( xNames.is() )
+ {
+ ByteString sDialogPosition;
+ svtools::QueryDeleteResult_Impl eResult = _bConfirm ? svtools::QUERYDELETE_YES : svtools::QUERYDELETE_ALL;
+
+ // The list of elements to delete is allowed to contain related elements: A given element may
+ // be the ancestor or child of another element from the list.
+ // We want to ensure that ancestors get deleted first, so we normalize the list in this respect.
+ // #i33353#
+ ::std::set< ::rtl::OUString > aDeleteNames;
+ // Note that this implicitly uses ::std::less< ::rtl::OUString > a comparison operation, which
+ // results in lexicographical order, which is exactly what we need, because "foo" is *before*
+ // any "foo/bar" in this order.
+ ::std::copy(
+ _rList.begin(), _rList.end(),
+ ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aDeleteNames, aDeleteNames.begin() )
+ );
+
+ ::std::set< ::rtl::OUString >::size_type nCount = aDeleteNames.size();
+ for ( ::std::set< ::rtl::OUString >::size_type nObjectsLeft = nCount; !aDeleteNames.empty(); )
+ {
+ ::std::set< ::rtl::OUString >::iterator aThisRound = aDeleteNames.begin();
+
+ if ( eResult != svtools::QUERYDELETE_ALL )
+ {
+ svtools::QueryDeleteDlg_Impl aDlg( getView(), *aThisRound );
+
+ if ( sDialogPosition.Len() )
+ aDlg.SetWindowState( sDialogPosition );
+
+ if ( nObjectsLeft > 1 )
+ aDlg.EnableAllButton();
+
+ if ( aDlg.Execute() == RET_OK )
+ eResult = aDlg.GetResult();
+ else
+ return;
+
+ sDialogPosition = aDlg.GetWindowState( );
+ }
+
+ bool bSuccess = false;
+
+ bool bUserConfirmedDelete =
+ ( eResult == svtools::QUERYDELETE_ALL )
+ || ( eResult == svtools::QUERYDELETE_YES );
+
+ if ( bUserConfirmedDelete
+ && ( ( _eType == E_QUERY ) ? m_pSubComponentManager->closeSubFrames( *aThisRound, _eType ) : true )
+ )
+ {
+ try
+ {
+ if ( xHierarchyName.is() )
+ xHierarchyName->removeByHierarchicalName( *aThisRound );
+ else
+ xNames->removeByName( *aThisRound );
+
+ bSuccess = true;
+
+ // now that we removed the element, care for all it's child elements
+ // which may also be a part of the list
+ // #i33353#
+ OSL_ENSURE( aThisRound->getLength() - 1 >= 0, "OApplicationController::deleteObjects: empty name?" );
+ ::rtl::OUStringBuffer sSmallestSiblingName( *aThisRound );
+ sSmallestSiblingName.append( (sal_Unicode)( '/' + 1) );
+
+ ::std::set< ::rtl::OUString >::iterator aUpperChildrenBound = aDeleteNames.lower_bound( sSmallestSiblingName.makeStringAndClear() );
+ for ( ::std::set< ::rtl::OUString >::iterator aObsolete = aThisRound;
+ aObsolete != aUpperChildrenBound;
+ )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sObsoleteName = *aObsolete;
+#endif
+ ::std::set< ::rtl::OUString >::iterator aNextObsolete = aObsolete; ++aNextObsolete;
+ aDeleteNames.erase( aObsolete );
+ --nObjectsLeft;
+ aObsolete = aNextObsolete;
+ }
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch(WrappedTargetException& e)
+ {
+ SQLException aSql;
+ if ( e.TargetException >>= aSql )
+ showError( SQLExceptionInfo( e.TargetException ) );
+ else
+ OSL_FAIL( "OApplicationController::deleteObjects: something strange happended!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( !bSuccess )
+ {
+ // okay, this object could not be deleted (or the user did not want to delete it),
+ // but continue with the rest
+ aDeleteNames.erase( aThisRound );
+ --nObjectsLeft;
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::deleteEntries()
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( getContainer() )
+ {
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+ ElementType eType = getContainer()->getElementType();
+ switch(eType)
+ {
+ case E_TABLE:
+ deleteTables(aList);
+ break;
+ case E_QUERY:
+ deleteObjects( E_QUERY, aList, true );
+ break;
+ case E_FORM:
+ deleteObjects( E_FORM, aList, true );
+ break;
+ case E_REPORT:
+ deleteObjects( E_REPORT, aList, true );
+ break;
+ case E_NONE:
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+const SharedConnection& OApplicationController::ensureConnection( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( !m_xDataSourceConnection.is() )
+ {
+ WaitObject aWO(getView());
+ String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
+ sConnectingContext.SearchAndReplaceAscii("$name$", getStrippedDatabaseName());
+
+ m_xDataSourceConnection.reset( connect( getDatabaseName(), sConnectingContext, _pErrorInfo ) );
+ if ( m_xDataSourceConnection.is() )
+ {
+ SQLExceptionInfo aError;
+ try
+ {
+ m_xMetaData = m_xDataSourceConnection->getMetaData();
+ }
+ catch( const SQLException& )
+ {
+ aError = ::cppu::getCaughtException();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if ( aError.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aError;
+ }
+ else
+ {
+ showError( aError );
+ }
+ }
+ }
+ }
+ return m_xDataSourceConnection;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isDataSourceReadOnly() const
+{
+ Reference<XStorable> xStore(m_xModel,UNO_QUERY);
+ return !xStore.is() || xStore->isReadonly();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isConnectionReadOnly() const
+{
+ sal_Bool bIsConnectionReadOnly = sal_True;
+ if ( m_xMetaData.is() )
+ {
+ try
+ {
+ bIsConnectionReadOnly = m_xMetaData->isReadOnly();
+ }
+ catch(const SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ // TODO check configuration
+ return bIsConnectionReadOnly;
+}
+// -----------------------------------------------------------------------------
+Reference< XNameAccess > OApplicationController::getElements( ElementType _eType )
+{
+ Reference< XNameAccess > xElements;
+ try
+ {
+ switch ( _eType )
+ {
+ case E_REPORT:
+ {
+ Reference< XReportDocumentsSupplier > xSupp( m_xModel, UNO_QUERY_THROW );
+ xElements.set( xSupp->getReportDocuments(), UNO_SET_THROW );
+ }
+ break;
+
+ case E_FORM:
+ {
+ Reference< XFormDocumentsSupplier > xSupp( m_xModel, UNO_QUERY_THROW );
+ xElements.set( xSupp->getFormDocuments(), UNO_SET_THROW );
+ }
+ break;
+
+ case E_QUERY:
+ {
+ xElements.set( getQueryDefintions(), UNO_QUERY_THROW );
+ }
+ break;
+
+ case E_TABLE:
+ {
+ if ( m_xDataSourceConnection.is() )
+ {
+ Reference< XTablesSupplier > xSup( getConnection(), UNO_QUERY_THROW );
+ xElements.set( xSup->getTables(), UNO_SET_THROW );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xElements;
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames) const
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ OSL_ENSURE(getContainer(),"View isn't valid! -> GPF");
+
+ getContainer()->getSelectionElementNames( _rNames );
+}
+
+// -----------------------------------------------------------------------------
+::std::auto_ptr< OLinkedDocumentsAccess > OApplicationController::getDocumentsAccess( ElementType _eType )
+{
+ OSL_ENSURE( ( _eType == E_TABLE ) || ( _eType == E_QUERY ) || ( _eType == E_FORM ) || ( _eType == E_REPORT ),
+ "OApplicationController::getDocumentsAccess: only forms and reports are supported here!" );
+
+ SharedConnection xConnection( ensureConnection() );
+ Reference< XNameAccess > xDocContainer;
+
+ if ( ( _eType == E_FORM ) | ( _eType == E_REPORT ) )
+ {
+ xDocContainer.set( getElements( _eType ) );
+ OSL_ENSURE( xDocContainer.is(), "OApplicationController::getDocumentsAccess: invalid container!" );
+ }
+
+ ::std::auto_ptr< OLinkedDocumentsAccess > pDocuments( new OLinkedDocumentsAccess(
+ getView(), this, getORB(), xDocContainer, xConnection, getDatabaseName()
+ ) );
+ return pDocuments;
+}
+// -----------------------------------------------------------------------------
+TransferableHelper* OApplicationController::copyObject()
+{
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ElementType eType = getContainer()->getElementType();
+ TransferableHelper* pData = NULL;
+ switch( eType )
+ {
+ case E_TABLE:
+ case E_QUERY:
+ {
+ SharedConnection xConnection( ensureConnection() );
+ Reference< XDatabaseMetaData> xMetaData;
+ if ( xConnection.is() )
+ xMetaData = xConnection->getMetaData();
+
+ ::rtl::OUString sName = getContainer()->getQualifiedName( NULL );
+ if ( sName.getLength() )
+ {
+ ::rtl::OUString sDataSource = getDatabaseName();
+
+ if ( eType == E_TABLE )
+ {
+ pData = new ODataClipboard(sDataSource, CommandType::TABLE, sName, xConnection, getNumberFormatter(xConnection,getORB()), getORB());
+ }
+ else
+ {
+ pData = new ODataClipboard(sDataSource, CommandType::QUERY, sName, getNumberFormatter(xConnection,getORB()), getORB());
+ }
+ }
+ }
+ break;
+ case E_FORM:
+ case E_REPORT:
+ {
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+ Reference< XHierarchicalNameAccess > xElements(getElements(eType),UNO_QUERY);
+ if ( xElements.is() && !aList.empty() )
+ {
+ Reference< XContent> xContent(xElements->getByHierarchicalName(*aList.begin()),UNO_QUERY);
+ pData = new OComponentTransferable( getDatabaseName(), xContent );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ // the owner ship goes to ODataClipboards
+ return pData;
+ }
+ catch(const SQLException&)
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::paste( ElementType _eType,const ::svx::ODataAccessDescriptor& _rPasteData,const String& _sParentFolder ,sal_Bool _bMove)
+{
+ try
+ {
+ if ( _eType == E_QUERY )
+ {
+ sal_Int32 nCommandType = CommandType::TABLE;
+ if ( _rPasteData.has(daCommandType) )
+ _rPasteData[daCommandType] >>= nCommandType;
+
+ if ( CommandType::QUERY == nCommandType || CommandType::COMMAND == nCommandType )
+ {
+ // read all necessary data
+
+ ::rtl::OUString sCommand;
+ sal_Bool bEscapeProcessing = sal_True;
+
+ _rPasteData[daCommand] >>= sCommand;
+ if ( _rPasteData.has(daEscapeProcessing) )
+ _rPasteData[daEscapeProcessing] >>= bEscapeProcessing;
+
+ // plausibility check
+ sal_Bool bValidDescriptor = sal_False;
+ ::rtl::OUString sDataSourceName = _rPasteData.getDataSource();
+ if (CommandType::QUERY == nCommandType)
+ bValidDescriptor = sDataSourceName.getLength() && sCommand.getLength();
+ else if (CommandType::COMMAND == nCommandType)
+ bValidDescriptor = (0 != sCommand.getLength());
+ if (!bValidDescriptor)
+ {
+ OSL_FAIL("OApplicationController::paste: invalid descriptor!");
+ return sal_False;
+ }
+
+ // the target object name (as we'll suggest it to the user)
+ ::rtl::OUString sTargetName;
+ try
+ {
+ if ( CommandType::QUERY == nCommandType )
+ sTargetName = sCommand;
+
+ if ( !sTargetName.getLength() )
+ {
+ String sDefaultName = String( ModuleRes( STR_QRY_TITLE ) );
+ sDefaultName = sDefaultName.GetToken( 0, ' ' );
+
+ Reference< XNameAccess > xQueries( getQueryDefintions(), UNO_QUERY_THROW );
+ sTargetName = ::dbtools::createUniqueName( xQueries, sDefaultName, sal_False );
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ Reference< XPropertySet > xQuery;
+ if (CommandType::QUERY == nCommandType)
+ {
+ // need to extract the statement and the escape processing flag from the query object
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ // the concrete query
+ Reference< XQueryDefinitionsSupplier > xSourceQuerySup(
+ getDataSourceByName( sDataSourceName, getView(), getORB(), NULL ),
+ UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSourceQuerySup->getQueryDefinitions(), UNO_SET_THROW );
+ if ( xQueries->hasByName( sCommand ) )
+ {
+ xQuery.set( xQueries->getByName(sCommand), UNO_QUERY_THROW );
+ bSuccess = true;
+ }
+ }
+ catch(SQLException&) { throw; } // caught and handled by the outer catch
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if (!bSuccess)
+ {
+ OSL_FAIL("OApplicationController::paste: could not extract the source query object!");
+ // TODO: maybe this is worth an error message to be displayed to the user ....
+ return sal_False;
+ }
+ }
+
+
+ Reference< XNameContainer > xDestQueries(getQueryDefintions(), UNO_QUERY);
+ Reference< XSingleServiceFactory > xQueryFactory(xDestQueries, UNO_QUERY);
+ if (!xQueryFactory.is())
+ {
+ OSL_FAIL("OApplicationController::paste: invalid destination query container!");
+ return sal_False;
+ }
+
+ // here we have everything needed to create a new query object ...
+ // ... ehm, except a new name
+ ensureConnection();
+
+ DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY );
+ ::dbtools::SQLExceptionInfo aDummy;
+ bool bNeedAskForName = ( sCommand.getLength() == 0 )
+ /* we did not have a source name, so the target name was auto-generated */
+ || ( !aNameChecker.isNameValid( sTargetName, aDummy ) );
+ /* name is invalid in the target DB (e.g. because it already
+ has a /table/ with that name) */
+ if ( bNeedAskForName )
+ {
+ OSaveAsDlg aAskForName( getView(),
+ CommandType::QUERY,
+ getORB(),
+ getConnection(),
+ sTargetName,
+ aNameChecker,
+ SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
+ if ( RET_OK != aAskForName.Execute() )
+ // cancelled by the user
+ return sal_False;
+ sTargetName = aAskForName.getName();
+ }
+
+ // create a new object
+ Reference< XPropertySet > xNewQuery(xQueryFactory->createInstance(), UNO_QUERY);
+ OSL_ENSURE(xNewQuery.is(), "OApplicationController::paste: invalid object created by factory!");
+ if (xNewQuery.is())
+ {
+ // initialize
+ if ( xQuery.is() )
+ ::comphelper::copyProperties(xQuery,xNewQuery);
+ else
+ {
+ xNewQuery->setPropertyValue(PROPERTY_COMMAND,makeAny(sCommand));
+ xNewQuery->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,makeAny(bEscapeProcessing));
+ }
+ // insert
+ xDestQueries->insertByName( sTargetName, makeAny(xNewQuery) );
+ xNewQuery.set(xDestQueries->getByName( sTargetName),UNO_QUERY);
+ if ( xQuery.is() && xNewQuery.is() )
+ {
+ Reference<XColumnsSupplier> xSrcColSup(xQuery,UNO_QUERY);
+ Reference<XColumnsSupplier> xDstColSup(xNewQuery,UNO_QUERY);
+ if ( xSrcColSup.is() && xDstColSup.is() )
+ {
+ Reference<XNameAccess> xSrcNameAccess = xSrcColSup->getColumns();
+ Reference<XNameAccess> xDstNameAccess = xDstColSup->getColumns();
+ Reference<XDataDescriptorFactory> xFac(xDstNameAccess,UNO_QUERY);
+ Reference<XAppend> xAppend(xFac,UNO_QUERY);
+ if ( xSrcNameAccess.is() && xDstNameAccess.is() && xSrcNameAccess->hasElements() && xAppend.is() )
+ {
+ Reference<XPropertySet> xDstProp(xFac->createDataDescriptor());
+
+ Sequence< ::rtl::OUString> aSeq = xSrcNameAccess->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for( ; pIter != pEnd ; ++pIter)
+ {
+ Reference<XPropertySet> xSrcProp(xSrcNameAccess->getByName(*pIter),UNO_QUERY);
+ ::comphelper::copyProperties(xSrcProp,xDstProp);
+ xAppend->appendByDescriptor(xDstProp);
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ OSL_TRACE("There should be a sequence in it!");
+ return sal_True;
+ }
+ else if ( _rPasteData.has(daComponent) ) // forms or reports
+ {
+ Reference<XContent> xContent;
+ _rPasteData[daComponent] >>= xContent;
+ return insertHierachyElement(_eType,_sParentFolder,Reference<XNameAccess>(xContent,UNO_QUERY).is(),xContent,_bMove);
+ }
+ }
+ catch(const SQLException&) { showError( SQLExceptionInfo( ::cppu::getCaughtException() ) ); }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+Reference<XNameContainer> OApplicationController::getQueryDefintions() const
+{
+ Reference<XQueryDefinitionsSupplier> xSet(m_xDataSource,UNO_QUERY);
+ Reference<XNameContainer> xNames;
+ if ( xSet.is() )
+ {
+ xNames.set(xSet->getQueryDefinitions(),UNO_QUERY);
+ }
+ return xNames;
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::getSupportedFormats(ElementType _eType,::std::vector<SotFormatStringId>& _rFormatIds) const
+{
+ switch( _eType )
+ {
+ case E_TABLE:
+ _rFormatIds.push_back(SOT_FORMATSTR_ID_DBACCESS_TABLE);
+ _rFormatIds.push_back(SOT_FORMAT_RTF);
+ _rFormatIds.push_back(SOT_FORMATSTR_ID_HTML);
+ // run through
+ case E_QUERY:
+ _rFormatIds.push_back(SOT_FORMATSTR_ID_DBACCESS_QUERY);
+ break;
+ default:
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isTableFormat() const
+{
+ return m_aTableCopyHelper.isTableFormat(getViewClipboard());
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnAsyncDrop, void*, /*NOTINTERESTEDIN*/ )
+{
+ m_nAsyncDrop = 0;
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+
+ if ( m_aAsyncDrop.nType == E_TABLE )
+ {
+ SharedConnection xConnection( ensureConnection() );
+ if ( xConnection.is() )
+ m_aTableCopyHelper.asyncCopyTagTable( m_aAsyncDrop, getDatabaseName(), xConnection );
+ }
+ else
+ {
+ if ( paste(m_aAsyncDrop.nType,m_aAsyncDrop.aDroppedData,m_aAsyncDrop.aUrl,m_aAsyncDrop.nAction == DND_ACTION_MOVE)
+ && m_aAsyncDrop.nAction == DND_ACTION_MOVE )
+ {
+ Reference<XContent> xContent;
+ m_aAsyncDrop.aDroppedData[daComponent] >>= xContent;
+ ::std::vector< ::rtl::OUString> aList;
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
+ ::rtl::OUString sErase = sName.getToken(0,'/',nIndex); // we don't want to have the "private:forms" part
+ if ( nIndex != -1 )
+ {
+ aList.push_back(sName.copy(sErase.getLength() + 1));
+ deleteObjects( m_aAsyncDrop.nType, aList, false );
+ }
+ }
+ }
+
+ m_aAsyncDrop.aDroppedData.clear();
+
+ return 0L;
+}
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
new file mode 100644
index 000000000000..5d90d8a7c104
--- /dev/null
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -0,0 +1,846 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppController.hxx"
+#include "AppDetailView.hxx"
+#include "AppView.hxx"
+#include "dbaccess_slotid.hrc"
+#include "dbu_app.hrc"
+#include "dbustrings.hrc"
+#include "defaultobjectnamecheck.hxx"
+#include "dlgsave.hxx"
+#include "UITools.hxx"
+#include "subcomponentmanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbcx/XRename.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/ucb/Command.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <connectivity/dbexception.hxx>
+#include <sfx2/mailmodelapi.hxx>
+#include <svx/dbaexchange.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <tools/urlobj.hxx>
+#include <unotools/bootstrap.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/waitobj.hxx>
+#include <osl/mutex.hxx>
+
+//........................................................................
+namespace dbaui
+{
+using namespace ::dbtools;
+using namespace ::connectivity;
+using namespace ::svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ucb;
+
+/** === begin UNO using === **/
+using ::com::sun::star::util::XCloseable;
+using ::com::sun::star::ui::XContextMenuInterceptor;
+/** === end UNO using === **/
+
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
+
+//........................................................................
+// -----------------------------------------------------------------------------
+
+class CloseChecker : public ::cppu::WeakImplHelper1< com::sun::star::lang::XEventListener >
+{
+ bool m_bClosed;
+
+public:
+ CloseChecker()
+ :m_bClosed( false )
+ {
+ }
+
+ virtual ~CloseChecker()
+ {
+ }
+
+ bool isClosed()
+ {
+ return true;
+ }
+
+ // interface XEventListener
+ virtual void SAL_CALL disposing( const EventObject& /*Source*/ ) throw( RuntimeException )
+ {
+ m_bClosed = true;
+ }
+
+};
+// -----------------------------------------------------------------------------
+void OApplicationController::convertToView(const ::rtl::OUString& _sName)
+{
+ try
+ {
+ SharedConnection xConnection( getConnection() );
+ Reference< XQueriesSupplier > xSup( xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSup->getQueries(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xSourceObject( xQueries->getByName( _sName ), UNO_QUERY_THROW );
+
+ Reference< XTablesSupplier > xTablesSup( xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xTablesSup->getTables(), UNO_QUERY_THROW );
+
+ Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
+
+ String aName = String(ModuleRes(STR_TBL_TITLE));
+ aName = aName.GetToken(0,' ');
+ String aDefaultName = ::dbaui::createDefaultName(xMeta,xTables,aName);
+
+ DynamicTableOrQueryNameCheck aNameChecker( xConnection, CommandType::TABLE );
+ OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), xConnection, aDefaultName, aNameChecker );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ ::rtl::OUString sName = aDlg.getName();
+ ::rtl::OUString sCatalog = aDlg.getCatalog();
+ ::rtl::OUString sSchema = aDlg.getSchema();
+ ::rtl::OUString sNewName(
+ ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sName, sal_False, ::dbtools::eInTableDefinitions ) );
+ Reference<XPropertySet> xView = ::dbaui::createView(sNewName,xConnection,xSourceObject);
+ if ( !xView.is() )
+ throw SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+ getContainer()->elementAdded(E_TABLE,sNewName,makeAny(xView));
+ }
+ }
+ catch(const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::pasteFormat(sal_uInt32 _nFormatId)
+{
+ if ( _nFormatId )
+ {
+ try
+ {
+ const TransferableDataHelper& rClipboard = getViewClipboard();
+ ElementType eType = getContainer()->getElementType();
+ if ( eType == E_TABLE )
+ {
+ m_aTableCopyHelper.pasteTable( _nFormatId, rClipboard, getDatabaseName(), ensureConnection() );
+ }
+ else
+ paste( eType, ODataAccessObjectTransferable::extractObjectDescriptor( rClipboard ) );
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::openDataSourceAdminDialog()
+{
+ openDialog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DatasourceAdministrationDialog" ) ) );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::openDialog( const ::rtl::OUString& _sServiceName )
+{
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ WaitObject aWO(getView());
+
+ Sequence< Any > aArgs(3);
+ sal_Int32 nArgPos = 0;
+
+ Reference< ::com::sun::star::awt::XWindow> xWindow = getTopMostContainerWindow();
+ if ( !xWindow.is() )
+ {
+ OSL_ENSURE( getContainer(), "OApplicationController::Construct: have no view!" );
+ if ( getContainer() )
+ xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent());
+ }
+ // the parent window
+ aArgs[nArgPos++] <<= PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")),
+ 0,
+ makeAny(xWindow),
+ PropertyState_DIRECT_VALUE);
+
+ // the initial selection
+ ::rtl::OUString sInitialSelection;
+ if ( getContainer() )
+ sInitialSelection = getDatabaseName();
+ if ( sInitialSelection.getLength() )
+ {
+ aArgs[ nArgPos++ ] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InitialSelection" ) ), 0,
+ makeAny( sInitialSelection ), PropertyState_DIRECT_VALUE );
+ }
+
+ SharedConnection xConnection( getConnection() );
+ if ( xConnection.is() )
+ {
+ aArgs[ nArgPos++ ] <<= PropertyValue(
+ PROPERTY_ACTIVE_CONNECTION, 0,
+ makeAny( xConnection ), PropertyState_DIRECT_VALUE );
+ }
+ aArgs.realloc( nArgPos );
+
+ // create the dialog
+ Reference< XExecutableDialog > xAdminDialog;
+ xAdminDialog = Reference< XExecutableDialog >(
+ getORB()->createInstanceWithArguments(_sServiceName,aArgs), UNO_QUERY);
+
+ // execute it
+ if (xAdminDialog.is())
+ xAdminDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::openTableFilterDialog()
+{
+ openDialog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TableFilterDialog" ) ) );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::refreshTables()
+{
+ if ( getContainer() && getContainer()->getDetailView() )
+ {
+ WaitObject aWO(getView());
+ OSL_ENSURE(getContainer()->getElementType() == E_TABLE,"Only allowed when the tables container is selected!");
+ try
+ {
+ Reference<XRefreshable> xRefresh(getElements(E_TABLE),UNO_QUERY);
+ if ( xRefresh.is() )
+ xRefresh->refresh();
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Could not refresh tables!");
+ }
+
+ getContainer()->getDetailView()->clearPages(sal_False);
+ getContainer()->getDetailView()->createTablesPage( ensureConnection() );
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::openDirectSQLDialog()
+{
+ openDialog( SERVICE_SDB_DIRECTSQLDIALOG );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( evt.PropertyName == PROPERTY_USER )
+ {
+ m_bNeedToReconnect = sal_True;
+ InvalidateFeature(SID_DB_APP_STATUS_USERNAME);
+ }
+ else if ( evt.PropertyName == PROPERTY_URL )
+ {
+ m_bNeedToReconnect = sal_True;
+ InvalidateFeature(SID_DB_APP_STATUS_DBNAME);
+ InvalidateFeature(SID_DB_APP_STATUS_TYPE);
+ InvalidateFeature(SID_DB_APP_STATUS_HOSTNAME);
+ }
+ else if ( PROPERTY_NAME == evt.PropertyName )
+ {
+ const ElementType eType = getContainer()->getElementType();
+ if ( eType == E_FORM || eType == E_REPORT )
+ {
+ ::rtl::OUString sOldName,sNewName;
+ evt.OldValue >>= sOldName;
+ evt.NewValue >>= sNewName;
+
+ // if the old name is empty, then this is a newly inserted content. We're notified of it via the
+ // elementInserted method, so there's no need to handle it here.
+
+ if ( sOldName.getLength() )
+ {
+ Reference<XChild> xChild(evt.Source,UNO_QUERY);
+ if ( xChild.is() )
+ {
+ Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
+ if ( xContent.is() )
+ sOldName = xContent->getIdentifier()->getContentIdentifier() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sOldName;
+ }
+
+ getContainer()->elementReplaced( eType , sOldName, sNewName );
+ }
+ }
+ }
+
+ EventObject aEvt;
+ aEvt.Source = m_xModel;
+ modified(aEvt);
+}
+
+// -----------------------------------------------------------------------------
+Reference< XDataSource > SAL_CALL OApplicationController::getDataSource() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY );
+ return xDataSource;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XWindow > SAL_CALL OApplicationController::getApplicationMainWindow() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ Reference< XFrame > xFrame( getFrame(), UNO_QUERY_THROW );
+ Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ return xWindow;
+}
+
+// -----------------------------------------------------------------------------
+Sequence< Reference< XComponent > > SAL_CALL OApplicationController::getSubComponents() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_pSubComponentManager->getSubComponents();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OApplicationController::getActiveConnection() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_xDataSourceConnection.getTyped();
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL OApplicationController::isConnected( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_xDataSourceConnection.is();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::connect( ) throw (SQLException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ SQLExceptionInfo aError;
+ SharedConnection xConnection = ensureConnection( &aError );
+ if ( !xConnection.is() )
+ {
+ if ( aError.isValid() )
+ aError.doThrow();
+
+ // no particular error, but nonetheless could not connect -> throw a generic exception
+ String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
+ sConnectingContext.SearchAndReplaceAscii( "$name$", getStrippedDatabaseName() );
+ ::dbtools::throwGenericSQLException( sConnectingContext, *this );
+ }
+}
+
+// -----------------------------------------------------------------------------
+beans::Pair< ::sal_Int32, ::rtl::OUString > SAL_CALL OApplicationController::identifySubComponent( const Reference< XComponent >& i_rSubComponent ) throw (IllegalArgumentException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ sal_Int32 nType = -1;
+ ::rtl::OUString sName;
+
+ if ( !m_pSubComponentManager->lookupSubComponent( i_rSubComponent, sName, nType ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ if ( nType == SID_DB_APP_DSRELDESIGN )
+ // this is somewhat hacky ... we're expected to return a DatabaseObject value. However, there is no such
+ // value for the relation design. /me thinks we should change the API definition here ...
+ nType = -1;
+
+ return beans::Pair< ::sal_Int32, ::rtl::OUString >( nType, sName );
+}
+
+// -----------------------------------------------------------------------------
+::sal_Bool SAL_CALL OApplicationController::closeSubComponents( ) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_pSubComponentManager->closeSubComponents();
+}
+
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ ElementType lcl_objectType2ElementType( const sal_Int32 _nObjectType )
+ {
+ ElementType eType( E_NONE );
+ switch ( _nObjectType )
+ {
+ case DatabaseObject::TABLE: eType = E_TABLE; break;
+ case DatabaseObject::QUERY: eType = E_QUERY; break;
+ case DatabaseObject::FORM: eType = E_FORM; break;
+ case DatabaseObject::REPORT: eType = E_REPORT; break;
+ default:
+ OSL_FAIL( "lcl_objectType2ElementType: unsupported object type!" );
+ // this should have been caught earlier
+ }
+ return eType;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::boost::optional< ::rtl::OUString >& i_rObjectName )
+{
+ // ensure we're connected
+ if ( !isConnected() )
+ {
+ SQLError aError( getORB() );
+ aError.raiseException( ErrorCondition::DB_NOT_CONNECTED, *this );
+ }
+
+ // ensure a proper object type
+ if ( ( _nObjectType != DatabaseObject::TABLE )
+ && ( _nObjectType != DatabaseObject::QUERY )
+ && ( _nObjectType != DatabaseObject::FORM )
+ && ( _nObjectType != DatabaseObject::REPORT )
+ )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ if ( !i_rObjectName )
+ return;
+
+ // ensure an existing object
+ Reference< XNameAccess > xContainer( getElements( lcl_objectType2ElementType( _nObjectType ) ) );
+ if ( !xContainer.is() )
+ // all possible reasons for this (e.g. not being connected currently) should
+ // have been handled before
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ bool bExistentObject = false;
+ switch ( _nObjectType )
+ {
+ case DatabaseObject::TABLE:
+ case DatabaseObject::QUERY:
+ bExistentObject = xContainer->hasByName( *i_rObjectName );
+ break;
+ case DatabaseObject::FORM:
+ case DatabaseObject::REPORT:
+ {
+ Reference< XHierarchicalNameAccess > xHierarchy( xContainer, UNO_QUERY_THROW );
+ bExistentObject = xHierarchy->hasByHierarchicalName( *i_rObjectName );
+ }
+ break;
+ }
+
+ if ( !bExistentObject )
+ throw NoSuchElementException( *i_rObjectName, *this );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL OApplicationController::loadComponent( ::sal_Int32 _ObjectType,
+ const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing ) throw (IllegalArgumentException, NoSuchElementException, SQLException, RuntimeException)
+{
+ return loadComponentWithArguments( _ObjectType, _ObjectName, _ForEditing, Sequence< PropertyValue >() );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL OApplicationController::loadComponentWithArguments( ::sal_Int32 _ObjectType,
+ const ::rtl::OUString& _ObjectName, ::sal_Bool _ForEditing, const Sequence< PropertyValue >& _Arguments ) throw (IllegalArgumentException, NoSuchElementException, SQLException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ impl_validateObjectTypeAndName_throw( _ObjectType, _ObjectName );
+
+ Reference< XComponent > xComponent( openElementWithArguments(
+ _ObjectName,
+ lcl_objectType2ElementType( _ObjectType ),
+ _ForEditing ? E_OPEN_DESIGN : E_OPEN_NORMAL,
+ _ForEditing ? SID_DB_APP_EDIT : SID_DB_APP_OPEN,
+ ::comphelper::NamedValueCollection( _Arguments )
+ ) );
+
+ return xComponent;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL OApplicationController::createComponent( ::sal_Int32 i_nObjectType, Reference< XComponent >& o_DocumentDefinition ) throw (IllegalArgumentException, SQLException, RuntimeException)
+{
+ return createComponentWithArguments( i_nObjectType, Sequence< PropertyValue >(), o_DocumentDefinition );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XComponent > SAL_CALL OApplicationController::createComponentWithArguments( ::sal_Int32 i_nObjectType, const Sequence< PropertyValue >& i_rArguments, Reference< XComponent >& o_DocumentDefinition ) throw (IllegalArgumentException, SQLException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ impl_validateObjectTypeAndName_throw( i_nObjectType, ::boost::optional< ::rtl::OUString >() );
+
+ Reference< XComponent > xComponent( newElement(
+ lcl_objectType2ElementType( i_nObjectType ),
+ ::comphelper::NamedValueCollection( i_rArguments ),
+ o_DocumentDefinition
+ ) );
+
+ return xComponent;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
+{
+ if ( _Interceptor.is() )
+ m_aContextMenuInterceptors.addInterface( _Interceptor );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OApplicationController::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
+{
+ m_aContextMenuInterceptors.removeInterface( _Interceptor );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::previewChanged( sal_Int32 _nMode )
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( m_xDataSource.is() && !isDataSourceReadOnly() )
+ {
+ try
+ {
+ ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) );
+ sal_Int32 nOldMode = aLayoutInfo.getOrDefault( "Preview", _nMode );
+ if ( nOldMode != _nMode )
+ {
+ aLayoutInfo.put( "Preview", _nMode );
+ m_xDataSource->setPropertyValue( PROPERTY_LAYOUTINFORMATION, makeAny( aLayoutInfo.getPropertyValues() ) );
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ InvalidateFeature(SID_DB_APP_DISABLE_PREVIEW);
+ InvalidateFeature(SID_DB_APP_VIEW_DOCINFO_PREVIEW);
+ InvalidateFeature(SID_DB_APP_VIEW_DOC_PREVIEW);
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::askToReconnect()
+{
+ if ( m_bNeedToReconnect )
+ {
+ m_bNeedToReconnect = sal_False;
+ sal_Bool bClear = sal_True;
+ if ( !m_pSubComponentManager->empty() )
+ {
+ QueryBox aQry(getView(), ModuleRes(APP_CLOSEDOCUMENTS));
+ switch (aQry.Execute())
+ {
+ case RET_YES:
+ closeSubComponents();
+ break;
+ default:
+ bClear = sal_False;
+ break;
+ }
+ }
+ if ( bClear )
+ {
+ ElementType eType = getContainer()->getElementType();
+ disconnect();
+ getContainer()->getDetailView()->clearPages(sal_False);
+ getContainer()->selectContainer(E_NONE); // invalidate the old selection
+ m_eCurrentType = E_NONE;
+ getContainer()->selectContainer(eType); // reselect the current one again
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationController::getDatabaseName() const
+{
+ ::rtl::OUString sDatabaseName;
+ try
+ {
+ if ( m_xDataSource.is() )
+ {
+ OSL_VERIFY( m_xDataSource->getPropertyValue( PROPERTY_NAME ) >>= sDatabaseName );
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sDatabaseName;
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationController::getStrippedDatabaseName() const
+{
+ ::rtl::OUString sDatabaseName;
+ return ::dbaui::getStrippedDatabaseName( m_xDataSource, sDatabaseName );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nType,
+ const ElementOpenMode _eMode, const Reference< XComponent >& _xDocument, const Reference< XComponent >& _rxDefinition )
+{
+ OSL_PRECOND( _xDocument.is(), "OApplicationController::onDocumentOpened: illegal document!" );
+ if ( !_xDocument.is() )
+ return;
+
+ try
+ {
+ OSL_ENSURE( _xDocument.is(), "OApplicationController::onDocumentOpened: is there any *valid* scenario where this fails?" );
+ m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument.is() ? _xDocument : _rxDefinition );
+
+ if ( _rxDefinition.is() )
+ {
+ Reference< XPropertySet > xProp( _rxDefinition, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xProp->getPropertySetInfo(), UNO_SET_THROW );
+ xProp->addPropertyChangeListener( PROPERTY_NAME, static_cast< XPropertyChangeListener* >( this ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::insertHierachyElement(ElementType _eType,const String& _sParentFolder,sal_Bool _bCollection,const Reference<XContent>& _xContent,sal_Bool _bMove)
+{
+ Reference<XHierarchicalNameContainer> xNames(getElements(_eType), UNO_QUERY);
+ return dbaui::insertHierachyElement(getView()
+ ,getORB()
+ ,xNames
+ ,_sParentFolder
+ ,_eType == E_FORM
+ ,_bCollection
+ ,_xContent
+ ,_bMove);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationController::isRenameDeleteAllowed(ElementType _eType,sal_Bool _bDelete) const
+{
+ ElementType eType = getContainer()->getElementType();
+ sal_Bool bEnabled = !isDataSourceReadOnly() && eType == _eType;
+ if ( bEnabled )
+ {
+
+ if ( E_TABLE == eType )
+ bEnabled = !isConnectionReadOnly() && getContainer()->isALeafSelected();
+
+ sal_Bool bCompareRes = sal_False;
+ if ( _bDelete )
+ bCompareRes = getContainer()->getSelectionCount() > 0;
+ else
+ {
+ bCompareRes = getContainer()->getSelectionCount() == 1;
+ if ( bEnabled && bCompareRes && E_TABLE == eType )
+ {
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+
+ try
+ {
+ Reference< XNameAccess > xContainer = const_cast<OApplicationController*>(this)->getElements(eType);
+ bEnabled = (xContainer.is() && xContainer->hasByName(*aList.begin()));
+ if ( bEnabled )
+ bEnabled = Reference<XRename>(xContainer->getByName(*aList.begin()),UNO_QUERY).is();
+ }
+ catch(Exception&)
+ {
+ bEnabled = sal_False;
+ }
+ }
+ }
+
+ bEnabled = bEnabled && bCompareRes;
+ }
+ return bEnabled;
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::onLoadedMenu(const Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager)
+{
+
+ if ( _xLayoutManager.is() )
+ {
+ static ::rtl::OUString s_sStatusbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/statusbar/statusbar"));
+ _xLayoutManager->createElement( s_sStatusbar );
+ _xLayoutManager->requestElement( s_sStatusbar );
+
+ if ( getContainer() )
+ {
+ // we need to share the "mnemonic space":
+ MnemonicGenerator aMnemonicGenerator;
+ // - the menu already has mnemonics
+ SystemWindow* pSystemWindow = getContainer()->GetSystemWindow();
+ MenuBar* pMenu = pSystemWindow ? pSystemWindow->GetMenuBar() : NULL;
+ if ( pMenu )
+ {
+ sal_uInt16 nMenuItems = pMenu->GetItemCount();
+ for ( sal_uInt16 i = 0; i < nMenuItems; ++i )
+ aMnemonicGenerator.RegisterMnemonic( pMenu->GetItemText( pMenu->GetItemId( i ) ) );
+ }
+ // - the icons should use automatic ones
+ getContainer()->createIconAutoMnemonics( aMnemonicGenerator );
+ // - as well as the entries in the task pane
+ getContainer()->setTaskExternalMnemonics( aMnemonicGenerator );
+ }
+
+ Execute( SID_DB_APP_VIEW_FORMS, Sequence< PropertyValue >() );
+ InvalidateAll();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationController::doAction(sal_uInt16 _nId ,ElementOpenMode _eOpenMode)
+{
+ ::std::vector< ::rtl::OUString> aList;
+ getSelectionElementNames(aList);
+ ElementType eType = getContainer()->getElementType();
+ ::comphelper::NamedValueCollection aArguments;
+ ElementOpenMode eOpenMode = _eOpenMode;
+ if ( eType == E_REPORT && E_OPEN_FOR_MAIL == _eOpenMode )
+ {
+ aArguments.put("Hidden",true);
+ eOpenMode = E_OPEN_NORMAL;
+ }
+
+ ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > > aCompoments;
+ ::std::vector< ::rtl::OUString>::iterator aEnd = aList.end();
+ for (::std::vector< ::rtl::OUString>::iterator aIter = aList.begin(); aIter != aEnd; ++aIter)
+ {
+ if ( SID_DB_APP_CONVERTTOVIEW == _nId )
+ convertToView(*aIter);
+ else
+ {
+ Reference< XModel > xModel( openElementWithArguments( *aIter, eType, eOpenMode, _nId,aArguments ), UNO_QUERY );
+ aCompoments.push_back( ::std::pair< ::rtl::OUString, Reference< XModel > >( *aIter, xModel ) );
+ }
+ }
+
+ // special handling for mail, if more than one document is selected attach them all
+ if ( _eOpenMode == E_OPEN_FOR_MAIL )
+ {
+
+ ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > >::iterator componentIter = aCompoments.begin();
+ ::std::vector< ::std::pair< ::rtl::OUString ,Reference< XModel > > >::iterator componentEnd = aCompoments.end();
+ ::rtl::OUString aDocTypeString;
+ SfxMailModel aSendMail;
+ SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_OK;
+ for (; componentIter != componentEnd && SfxMailModel::SEND_MAIL_OK == eResult; ++componentIter)
+ {
+ try
+ {
+ Reference< XModel > xModel(componentIter->second,UNO_QUERY);
+
+ // Send document as e-Mail using stored/default type
+ eResult = aSendMail.AttachDocument(aDocTypeString,xModel,componentIter->first);
+ ::comphelper::disposeComponent(xModel);
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ if ( !aSendMail.IsEmpty() )
+ aSendMail.Send( getFrame() );
+ }
+}
+// -----------------------------------------------------------------------------
+ElementType OApplicationController::getElementType(const Reference< XContainer >& _xContainer) const
+{
+ ElementType eRet = E_NONE;
+ Reference<XServiceInfo> xServiceInfo(_xContainer,UNO_QUERY);
+ if ( xServiceInfo.is() )
+ {
+ if ( xServiceInfo->supportsService(SERVICE_SDBCX_TABLES) )
+ eRet = E_TABLE;
+ else if ( xServiceInfo->supportsService(SERVICE_NAME_FORM_COLLECTION) )
+ eRet = E_FORM;
+ else if ( xServiceInfo->supportsService(SERVICE_NAME_REPORT_COLLECTION) )
+ eRet = E_REPORT;
+ else
+ eRet = E_QUERY;
+ }
+ return eRet;
+}
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.cxx b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
new file mode 100644
index 000000000000..b10ee6afd78f
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.cxx
@@ -0,0 +1,1407 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppDetailPageHelper.hxx"
+#include "moduledbu.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <connectivity/dbtools.hxx>
+#include "tabletree.hxx"
+#include "UITools.hxx"
+#include "dbtreelistbox.hxx"
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ucb/Command.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#include "AppView.hxx"
+#include "dbaccess_helpid.hrc"
+#include "dbu_app.hrc"
+#include "callbacks.hxx"
+#include "IController.hxx"
+#include "dbustrings.hrc"
+#include "dbaccess_slotid.hrc"
+#include "databaseobjectview.hxx"
+#include "imageprovider.hxx"
+#include <vcl/waitobj.hxx>
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "IApplicationController.hxx"
+
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdb::application;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star;
+using ::com::sun::star::awt::XTabController;
+
+namespace dbaui
+{
+ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+ namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+}
+
+namespace
+{
+ SvLBoxEntry* lcl_findEntry_impl(DBTreeListBox& rTree,const ::rtl::OUString& _rName,SvLBoxEntry* _pFirst)
+ {
+ SvLBoxEntry* pReturn = NULL;
+ sal_Int32 nIndex = 0;
+ String sName( _rName.getToken(0,'/',nIndex) );
+
+ SvLBoxEntry* pEntry = _pFirst;
+ while( pEntry )
+ {
+ if ( rTree.GetEntryText(pEntry) == sName )
+ {
+ if ( nIndex != -1 )
+ {
+ sName = _rName.getToken(0,'/',nIndex);
+ pEntry = rTree.FirstChild(pEntry);
+ }
+ else
+ {
+ pReturn = pEntry;
+ break;
+ }
+ }
+ else
+ pEntry = rTree.NextSibling(pEntry);
+ }
+ return pReturn;
+ }
+ SvLBoxEntry* lcl_findEntry(DBTreeListBox& rTree,const ::rtl::OUString& _rName,SvLBoxEntry* _pFirst)
+ {
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString sErase = _rName.getToken(0,'/',nIndex); // we don't want to have the "private:forms" part
+ return (nIndex != -1 ? lcl_findEntry_impl(rTree,_rName.copy(sErase.getLength() + 1),_pFirst) : NULL);
+ }
+ //==================================================================
+ // class OPreviewWindow
+ //==================================================================
+ class OTablePreviewWindow : public Window
+ {
+ DECL_LINK(OnDisableInput, void*);
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OTablePreviewWindow( Window* pParent, WinBits nStyle = 0 );
+ virtual long Notify( NotifyEvent& rNEvt );
+ };
+ // -----------------------------------------------------------------------------
+ OTablePreviewWindow::OTablePreviewWindow(Window* pParent, WinBits nStyle) : Window( pParent, nStyle)
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ }
+ // -----------------------------------------------------------------------------
+ long OTablePreviewWindow::Notify( NotifyEvent& rNEvt )
+ {
+ long nRet = Window::Notify( rNEvt );
+ if ( rNEvt.GetType() == EVENT_INPUTENABLE && IsInputEnabled() )
+ PostUserEvent( LINK( this, OTablePreviewWindow, OnDisableInput) );
+ return nRet;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OTablePreviewWindow, OnDisableInput, void*, EMPTYARG)
+ {
+ EnableInput(sal_False);
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ void OTablePreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
+ {
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void OTablePreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+ }
+
+}
+//==================================================================
+// class OAppDetailPageHelper
+DBG_NAME(OAppDetailPageHelper)
+//==================================================================
+OAppDetailPageHelper::OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
+ ,m_rBorderWin(_rBorderWin)
+ ,m_aFL(this,WB_VERT)
+ ,m_aTBPreview(this,WB_TABSTOP )
+ ,m_aBorder(this,WB_BORDER | WB_READONLY)
+ ,m_aPreview(&m_aBorder)
+ ,m_aDocumentInfo(&m_aBorder,WB_LEFT | WB_VSCROLL | WB_READONLY )
+ ,m_pTablePreview(NULL)
+ ,m_ePreviewMode(_ePreviewMode)
+{
+ DBG_CTOR(OAppDetailPageHelper,NULL);
+
+ m_aBorder.SetBorderStyle(WINDOW_BORDER_MONO);
+
+ m_aMenu.reset(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) ));
+
+ m_aTBPreview.SetOutStyle(TOOLBOX_STYLE_FLAT);
+ m_aTBPreview.InsertItem(SID_DB_APP_DISABLE_PREVIEW,m_aMenu->GetItemText(SID_DB_APP_DISABLE_PREVIEW),TIB_LEFT|TIB_DROPDOWN|TIB_AUTOSIZE|TIB_RADIOCHECK);
+ m_aTBPreview.SetHelpId(HID_APP_VIEW_PREVIEW_CB);
+ m_aTBPreview.SetDropdownClickHdl( LINK( this, OAppDetailPageHelper, OnDropdownClickHdl ) );
+ m_aTBPreview.EnableMenuStrings();
+ m_aTBPreview.Enable(sal_True);
+
+ m_aBorder.SetUniqueId(UID_APP_VIEW_PREVIEW_1);
+
+ m_aPreview.SetHelpId(HID_APP_VIEW_PREVIEW_1);
+
+ m_pTablePreview = new OTablePreviewWindow(&m_aBorder,WB_READONLY | WB_DIALOGCONTROL );
+ m_pTablePreview->SetHelpId(HID_APP_VIEW_PREVIEW_2);
+
+ m_aDocumentInfo.SetHelpId(HID_APP_VIEW_PREVIEW_3);
+
+ m_xWindow = VCLUnoHelper::GetInterface( m_pTablePreview );
+
+ SetUniqueId(UID_APP_DETAILPAGE_HELPER);
+ for (int i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
+ m_pLists[i] = NULL;
+ ImplInitSettings();
+}
+// -----------------------------------------------------------------------------
+OAppDetailPageHelper::~OAppDetailPageHelper()
+{
+ try
+ {
+ Reference< ::util::XCloseable> xCloseable(m_xFrame,UNO_QUERY);
+ if ( xCloseable.is() )
+ xCloseable->close(sal_True);
+ }
+ catch(Exception)
+ {
+ OSL_FAIL("Exception thrown while disposing preview frame!");
+ }
+
+ for (int i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
+ {
+ if ( m_pLists[i] )
+ {
+ m_pLists[i]->clearCurrentSelection();
+ m_pLists[i]->Hide();
+ ::std::auto_ptr<DBTreeListBox> aTemp(m_pLists[i]);
+ m_pLists[i]->clearCurrentSelection(); // why a second time?
+ m_pLists[i] = NULL;
+ }
+
+ }
+
+ DBG_DTOR(OAppDetailPageHelper,NULL);
+}
+// -----------------------------------------------------------------------------
+int OAppDetailPageHelper::getVisibleControlIndex() const
+{
+ int i = 0;
+ for (; i < E_ELEMENT_TYPE_COUNT ; ++i)
+ {
+ if ( m_pLists[i] && m_pLists[i]->IsVisible() )
+ break;
+ }
+ return i;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::selectAll()
+{
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ m_pLists[nPos]->SelectAll(sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::sort(int _nPos,SvSortMode _eSortMode )
+{
+ OSL_ENSURE(m_pLists[_nPos],"List can not be NULL! ->GPF");
+ SvLBoxTreeList* pModel = m_pLists[_nPos]->GetModel();
+ SvSortMode eOldSortMode = pModel->GetSortMode();
+ pModel->SetSortMode(_eSortMode);
+ if ( eOldSortMode != _eSortMode )
+ pModel->Resort();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isSortUp() const
+{
+ SvSortMode eSortMode = SortNone;
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ SvLBoxTreeList* pModel = m_pLists[nPos]->GetModel();
+ eSortMode = pModel->GetSortMode();
+ }
+ return eSortMode == SortAscending;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::sortDown()
+{
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ sort(nPos,SortDescending);
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::sortUp()
+{
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ sort(nPos,SortAscending);
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
+{
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ DBTreeListBox& rTree = *m_pLists[nPos];
+ sal_Int32 nCount = rTree.GetEntryCount();
+ _rNames.reserve(nCount);
+ SvLBoxEntry* pEntry = rTree.FirstSelected();
+ ElementType eType = getElementType();
+ while( pEntry )
+ {
+ if ( eType == E_TABLE )
+ {
+ if( rTree.GetChildCount(pEntry) == 0 )
+ _rNames.push_back( getQualifiedName( pEntry ) );
+ }
+ else
+ {
+ ::rtl::OUString sName = rTree.GetEntryText(pEntry);
+ SvLBoxEntry* pParent = rTree.GetParent(pEntry);
+ while(pParent)
+ {
+ sName = rTree.GetEntryText(pParent) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sName;
+ pParent = rTree.GetParent(pParent);
+ }
+ _rNames.push_back(sName);
+ }
+ pEntry = rTree.NextSelected(pEntry);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ enum ElementType eType = E_TABLE;
+ for ( size_t i=0; i < E_ELEMENT_TYPE_COUNT; eType = static_cast< ElementType >( ++i ) )
+ {
+ if ( m_pLists[eType] == &_rControl )
+ {
+ describeCurrentSelectionForType( eType, _out_rSelectedObjects );
+ return;
+ }
+ }
+ OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForControl: invalid control!" );
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ OSL_ENSURE( _eType < E_ELEMENT_TYPE_COUNT, "OAppDetailPageHelper::describeCurrentSelectionForType: invalid type!" );
+ DBTreeListBox* pList = ( _eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ _eType ] : NULL;
+ OSL_ENSURE( pList, "OAppDetailPageHelper::describeCurrentSelectionForType: "
+ "You really should ensure this type has already been viewed before!" );
+ if ( !pList )
+ return;
+
+ ::std::vector< NamedDatabaseObject > aSelected;
+
+ SvLBoxEntry* pEntry = pList->FirstSelected();
+ while( pEntry )
+ {
+ NamedDatabaseObject aObject;
+ switch ( _eType )
+ {
+ case E_TABLE:
+ {
+ OTableTreeListBox& rTableTree = dynamic_cast< OTableTreeListBox& >( *pList );
+ aObject = rTableTree.describeObject( pEntry );
+ }
+ break;
+ case E_QUERY:
+ aObject.Type = DatabaseObject::QUERY;
+ aObject.Name = pList->GetEntryText( pEntry );
+ break;
+
+ case E_FORM:
+ case E_REPORT:
+ {
+ ::rtl::OUString sName = pList->GetEntryText(pEntry);
+ SvLBoxEntry* pParent = pList->GetParent(pEntry);
+ while ( pParent )
+ {
+ ::rtl::OUStringBuffer buffer;
+ buffer.append( pList->GetEntryText( pParent ) );
+ buffer.append( sal_Unicode( '/' ) );
+ buffer.append( sName );
+ sName = buffer.makeStringAndClear();
+
+ pParent = pList->GetParent( pParent );
+ }
+
+ if ( isLeaf( pEntry ) )
+ aObject.Type = ( _eType == E_FORM ) ? DatabaseObject::FORM : DatabaseObject::REPORT;
+ else
+ aObject.Type = ( _eType == E_FORM ) ? DatabaseObjectContainer::FORMS_FOLDER : DatabaseObjectContainer::REPORTS_FOLDER;
+ aObject.Name = sName;
+ }
+ break;
+ default:
+ OSL_FAIL( "OAppDetailPageHelper::describeCurrentSelectionForType: unexpected type!" );
+ break;
+ }
+
+ if ( aObject.Name.getLength() )
+ {
+ aSelected.push_back( aObject );
+ }
+
+ pEntry = pList->NextSelected(pEntry);
+ }
+
+ _out_rSelectedObjects.realloc( aSelected.size() );
+ ::std::copy( aSelected.begin(), aSelected.end(), _out_rSelectedObjects.getArray() );
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::selectElements(const Sequence< ::rtl::OUString>& _aNames)
+{
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ DBTreeListBox& rTree = *m_pLists[nPos];
+ rTree.SelectAll(sal_False);
+ const ::rtl::OUString* pIter = _aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + _aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ SvLBoxEntry* pEntry = rTree.GetEntryPosByName(*pIter);
+ if ( pEntry )
+ rTree.Select(pEntry);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAppDetailPageHelper::getQualifiedName( SvLBoxEntry* _pEntry ) const
+{
+ int nPos = getVisibleControlIndex();
+ ::rtl::OUString sComposedName;
+
+ if ( nPos >= E_ELEMENT_TYPE_COUNT )
+ return sComposedName;
+
+ OSL_ENSURE(m_pLists[nPos],"Tables tree view is NULL! -> GPF");
+ DBTreeListBox& rTree = *m_pLists[nPos];
+
+ SvLBoxEntry* pEntry = _pEntry;
+ if ( !pEntry )
+ pEntry = rTree.FirstSelected();
+
+ if ( !pEntry )
+ return sComposedName;
+
+ if ( getElementType() == E_TABLE )
+ {
+ const OTableTreeListBox& rTreeView = dynamic_cast< const OTableTreeListBox& >( *m_pLists[nPos] );
+ sComposedName = rTreeView.getQualifiedTableName( pEntry );
+ }
+ else
+ {
+ sComposedName = rTree.GetEntryText(pEntry);
+ SvLBoxEntry* pParent = rTree.GetParent(pEntry);
+ while(pParent)
+ {
+ sComposedName = rTree.GetEntryText(pParent) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sComposedName;
+ pParent = rTree.GetParent(pParent);
+ }
+ }
+
+ return sComposedName;
+}
+// -----------------------------------------------------------------------------
+ElementType OAppDetailPageHelper::getElementType() const
+{
+ int nPos = getVisibleControlIndex();
+ return static_cast<ElementType>(nPos);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OAppDetailPageHelper::getSelectionCount()
+{
+ sal_Int32 nCount = 0;
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ DBTreeListBox& rTree = *m_pLists[nPos];
+ SvLBoxEntry* pEntry = rTree.FirstSelected();
+ while( pEntry )
+ {
+ ++nCount;
+ pEntry = rTree.NextSelected(pEntry);
+ }
+ }
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OAppDetailPageHelper::getElementCount()
+{
+ sal_Int32 nCount = 0;
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ nCount = m_pLists[nPos]->GetEntryCount();
+ }
+ return nCount;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isCutAllowed()
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isCopyAllowed()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isPasteAllowed()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::copy()
+{
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::cut()
+{
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::paste()
+{
+}
+// -----------------------------------------------------------------------------
+bool OAppDetailPageHelper::isLeaf(SvLBoxEntry* _pEntry) const
+{
+ if ( !_pEntry )
+ return false;
+ sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
+ if ( ( nEntryType == DatabaseObjectContainer::TABLES )
+ || ( nEntryType == DatabaseObjectContainer::CATALOG )
+ || ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ || ( nEntryType == DatabaseObjectContainer::FORMS_FOLDER )
+ || ( nEntryType == DatabaseObjectContainer::REPORTS_FOLDER )
+ )
+ return false;
+
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isALeafSelected() const
+{
+ int nPos = getVisibleControlIndex();
+ sal_Bool bLeafSelected = sal_False;
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ {
+ DBTreeListBox& rTree = *m_pLists[nPos];
+ SvLBoxEntry* pEntry = rTree.FirstSelected( );
+ while( !bLeafSelected && pEntry )
+ {
+ bLeafSelected = isLeaf( pEntry );
+ pEntry = rTree.NextSelected(pEntry);
+ }
+ }
+ return bLeafSelected;
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OAppDetailPageHelper::getEntry( const Point& _aPosPixel) const
+{
+ SvLBoxEntry* pReturn = NULL;
+ int nPos = getVisibleControlIndex();
+ if ( nPos < E_ELEMENT_TYPE_COUNT )
+ pReturn = m_pLists[nPos]->GetEntry( _aPosPixel,sal_True );
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::createTablesPage(const Reference< XConnection>& _xConnection)
+{
+ OSL_ENSURE(_xConnection.is(),"Connection is NULL! -> GPF");
+
+ if ( !m_pLists[E_TABLE] )
+ {
+ OTableTreeListBox* pTreeView = new OTableTreeListBox(this
+ ,getBorderWin().getView()->getORB()
+ ,WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP
+ ,sal_False);
+ pTreeView->SetHelpId(HID_APP_TABLE_TREE);
+ m_pLists[E_TABLE] = pTreeView;
+
+ ImageProvider aImageProvider( _xConnection );
+ createTree( pTreeView,
+ aImageProvider.getDefaultImage( DatabaseObject::TABLE )
+ );
+
+ pTreeView->notifyHiContrastChanged();
+ m_aBorder.SetZOrder(pTreeView, WINDOW_ZORDER_BEHIND);
+ }
+ if ( !m_pLists[E_TABLE]->GetEntryCount() )
+ {
+ static_cast<OTableTreeListBox*>(m_pLists[E_TABLE])->UpdateTableList(_xConnection);
+
+ SvLBoxEntry* pEntry = m_pLists[E_TABLE]->First();
+ if ( pEntry )
+ m_pLists[E_TABLE]->Expand(pEntry);
+ m_pLists[E_TABLE]->SelectAll(sal_False);
+ }
+
+ setDetailPage(m_pLists[E_TABLE]);
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::getElementIcons( ElementType _eType, sal_uInt16& _rImageId)
+{
+ ImageProvider aImageProvider;
+ _rImageId = 0;
+
+ sal_Int32 nDatabaseObjectType( 0 );
+ switch(_eType )
+ {
+ case E_FORM: nDatabaseObjectType = DatabaseObject::FORM; break;
+ case E_REPORT: nDatabaseObjectType = DatabaseObject::REPORT; break;
+ case E_QUERY: nDatabaseObjectType = DatabaseObject::QUERY; break;
+ default:
+ OSL_FAIL( "OAppDetailPageHelper::GetElementIcons: invalid element type!" );
+ return;
+ }
+ _rImageId = aImageProvider.getDefaultImageResourceID( nDatabaseObjectType );
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::createPage(ElementType _eType,const Reference< XNameAccess >& _xContainer)
+{
+ OSL_ENSURE(E_TABLE != _eType,"E_TABLE isn't allowed.");
+
+ sal_uInt16 nImageId = 0;
+ rtl::OString sHelpId;
+ ImageProvider aImageProvider;
+ Image aFolderImage;
+ switch( _eType )
+ {
+ case E_FORM:
+ sHelpId = HID_APP_FORM_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::FORM );
+ break;
+ case E_REPORT:
+ sHelpId = HID_APP_REPORT_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::REPORT );
+ break;
+ case E_QUERY:
+ sHelpId = HID_APP_QUERY_TREE;
+ aFolderImage = aImageProvider.getFolderImage( DatabaseObject::QUERY );
+ break;
+ default:
+ OSL_FAIL("Illegal call!");
+ }
+ getElementIcons( _eType, nImageId );
+
+ if ( !m_pLists[_eType] )
+ {
+ m_pLists[_eType] = createSimpleTree( sHelpId, aFolderImage );
+ }
+
+ if ( m_pLists[_eType] )
+ {
+ if ( !m_pLists[_eType]->GetEntryCount() && _xContainer.is() )
+ {
+ fillNames( _xContainer, _eType, nImageId, NULL );
+
+ m_pLists[_eType]->SelectAll(sal_False);
+ }
+ setDetailPage(m_pLists[_eType]);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::setDetailPage(Window* _pWindow)
+{
+ OSL_ENSURE(_pWindow,"OAppDetailPageHelper::setDetailPage: Window is NULL!");
+ Window* pCurrent = getCurrentView();
+ if ( pCurrent )
+ pCurrent->Hide();
+
+ showPreview(NULL);
+ sal_Bool bHasFocus = sal_False;
+ m_aFL.Show();
+ {
+ bHasFocus = pCurrent->HasChildPathFocus();
+ _pWindow->Show();
+ }
+ m_aTBPreview.Show();
+ m_aBorder.Show();
+ switchPreview(m_ePreviewMode,sal_True);
+
+ if ( bHasFocus )
+ _pWindow->GrabFocus();
+ Resize();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+ namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+
+ static sal_Int32 lcl_getFolderIndicatorForType( const ElementType _eType )
+ {
+ const sal_Int32 nFolderIndicator =
+ ( _eType == E_FORM ) ? DatabaseObjectContainer::FORMS_FOLDER
+ : ( _eType == E_REPORT ) ? DatabaseObjectContainer::REPORTS_FOLDER : -1;
+ return nFolderIndicator;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::fillNames( const Reference< XNameAccess >& _xContainer, const ElementType _eType,
+ const sal_uInt16 _nImageId, SvLBoxEntry* _pParent )
+{
+ OSL_ENSURE(_xContainer.is(),"Data source is NULL! -> GPF");
+ OSL_ENSURE( ( _eType >= E_TABLE ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OAppDetailPageHelper::fillNames: invalid type!" );
+
+ DBTreeListBox* pList = m_pLists[ _eType ];
+ OSL_ENSURE( pList, "OAppDetailPageHelper::fillNames: you really should create the list before calling this!" );
+ if ( !pList )
+ return;
+
+ if ( _xContainer.is() && _xContainer->hasElements() )
+ {
+ const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType );
+
+ Sequence< ::rtl::OUString> aSeq = _xContainer->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ SvLBoxEntry* pEntry = NULL;
+ Reference<XNameAccess> xSubElements(_xContainer->getByName(*pIter),UNO_QUERY);
+ if ( xSubElements.is() )
+ {
+ pEntry = pList->InsertEntry( *pIter, _pParent, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
+ getBorderWin().getView()->getAppController().containerFound( Reference< XContainer >( xSubElements, UNO_QUERY ) );
+ fillNames( xSubElements, _eType, _nImageId, pEntry );
+ }
+ else
+ {
+ pEntry = pList->InsertEntry( *pIter, _pParent );
+
+ Image aImage = Image( ModuleRes( _nImageId ) );
+ pList->SetExpandedEntryBmp( pEntry, aImage );
+ pList->SetCollapsedEntryBmp( pEntry, aImage );
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+DBTreeListBox* OAppDetailPageHelper::createSimpleTree( const rtl::OString& _sHelpId, const Image& _rImage)
+{
+ DBTreeListBox* pTreeView = new DBTreeListBox(this,getBorderWin().getView()->getORB(),WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP);
+ pTreeView->SetHelpId( _sHelpId );
+ return createTree( pTreeView, _rImage );
+}
+
+// -----------------------------------------------------------------------------
+DBTreeListBox* OAppDetailPageHelper::createTree( DBTreeListBox* _pTreeView, const Image& _rImage )
+{
+ WaitObject aWaitCursor(this);
+
+ _pTreeView->SetStyle(_pTreeView->GetStyle() | WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT | WB_TABSTOP);
+ _pTreeView->GetModel()->SetSortMode(SortAscending);
+ _pTreeView->EnableCheckButton( NULL ); // do not show any buttons
+ _pTreeView->SetSelectionMode(MULTIPLE_SELECTION);
+
+ _pTreeView->SetDefaultCollapsedEntryBmp( _rImage );
+ _pTreeView->SetDefaultExpandedEntryBmp( _rImage );
+
+ _pTreeView->SetDoubleClickHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
+ _pTreeView->SetEnterKeyHdl(LINK(this, OAppDetailPageHelper, OnEntryDoubleClick));
+ _pTreeView->SetSelChangeHdl(LINK(this, OAppDetailPageHelper, OnEntrySelChange));
+
+ _pTreeView->setCutHandler(LINK(this, OAppDetailPageHelper, OnCutEntry));
+ _pTreeView->setCopyHandler(LINK(this, OAppDetailPageHelper, OnCopyEntry));
+ _pTreeView->setPasteHandler(LINK(this, OAppDetailPageHelper, OnPasteEntry));
+ _pTreeView->setDeleteHandler(LINK(this, OAppDetailPageHelper, OnDeleteEntry));
+
+ _pTreeView->setControlActionListener( &getBorderWin().getView()->getAppController() );
+ _pTreeView->setContextMenuProvider( &getBorderWin().getView()->getAppController() );
+
+ return _pTreeView;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::clearPages()
+{
+ showPreview(NULL);
+ for (size_t i=0; i < E_ELEMENT_TYPE_COUNT; ++i)
+ {
+ if ( m_pLists[i] )
+ m_pLists[i]->Clear();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isFilled() const
+{
+ size_t i = 0;
+ for (; i < E_ELEMENT_TYPE_COUNT && !m_pLists[i]; ++i)
+ ;
+ return i != E_ELEMENT_TYPE_COUNT;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::elementReplaced(ElementType _eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName )
+{
+ DBTreeListBox* pTreeView = getCurrentView();
+ if ( pTreeView )
+ {
+ ::rtl::OUString sNewName = _rNewName;
+ SvLBoxEntry* pEntry = NULL;
+ switch( _eType )
+ {
+ case E_TABLE:
+ static_cast<OTableTreeListBox*>(pTreeView)->removedTable( _rOldName );
+ static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rNewName );
+ return;
+
+ case E_QUERY:
+ pEntry = lcl_findEntry_impl(*pTreeView,_rOldName,pTreeView->First());
+ break;
+ case E_FORM:
+ case E_REPORT:
+ pEntry = lcl_findEntry(*pTreeView,_rOldName,pTreeView->First());
+ break;
+ default:
+ OSL_FAIL("Invalid element type");
+ }
+ OSL_ENSURE(pEntry,"Do you know that the name isn't existence!");
+ if ( pEntry )
+ {
+ pTreeView->SetEntryText(pEntry,sNewName);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OAppDetailPageHelper::elementAdded(ElementType _eType,const ::rtl::OUString& _rName, const Any& _rObject )
+{
+ SvLBoxEntry* pRet = NULL;
+ DBTreeListBox* pTreeView = m_pLists[_eType];
+ if( _eType == E_TABLE && pTreeView )
+ {
+ pRet = static_cast<OTableTreeListBox*>(pTreeView)->addedTable( _rName );
+ }
+ else if ( pTreeView )
+ {
+
+ SvLBoxEntry* pEntry = NULL;
+ Reference<XChild> xChild(_rObject,UNO_QUERY);
+ if ( xChild.is() && E_QUERY != _eType )
+ {
+ Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
+ if ( xContent.is() )
+ {
+ ::rtl::OUString sName = xContent->getIdentifier()->getContentIdentifier();
+ pEntry = lcl_findEntry(*pTreeView,sName,pTreeView->First());
+ }
+ }
+
+ sal_uInt16 nImageId = 0;
+ getElementIcons( _eType, nImageId );
+ Reference<XNameAccess> xContainer(_rObject,UNO_QUERY);
+ if ( xContainer.is() )
+ {
+ const sal_Int32 nFolderIndicator = lcl_getFolderIndicatorForType( _eType );
+ pRet = pTreeView->InsertEntry( _rName, pEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderIndicator ) );
+ fillNames( xContainer, _eType, nImageId, pRet );
+ }
+ else
+ {
+ pRet = pTreeView->InsertEntry( _rName, pEntry );
+
+ Image aImage = Image( ModuleRes( nImageId ) );
+ pTreeView->SetExpandedEntryBmp( pRet, aImage );
+ pTreeView->SetCollapsedEntryBmp( pRet, aImage );
+ }
+ }
+ return pRet;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::elementRemoved( ElementType _eType,const ::rtl::OUString& _rName )
+{
+ DBTreeListBox* pTreeView = getCurrentView();
+ if ( pTreeView )
+ {
+ switch( _eType )
+ {
+ case E_TABLE:
+ // we don't need to clear the table here, it is already done by the dispose listener
+ static_cast< OTableTreeListBox* >( pTreeView )->removedTable( _rName );
+ break;
+ case E_QUERY:
+ if ( pTreeView )
+ {
+ SvLBoxEntry* pEntry = lcl_findEntry_impl(*pTreeView,_rName,pTreeView->First());
+ if ( pEntry )
+ pTreeView->GetModel()->Remove(pEntry);
+ }
+ break;
+ case E_FORM:
+ case E_REPORT:
+ {
+ if ( pTreeView )
+ {
+ SvLBoxEntry* pEntry = lcl_findEntry(*pTreeView,_rName,pTreeView->First());
+ if ( pEntry )
+ pTreeView->GetModel()->Remove(pEntry);
+ }
+ }
+ break;
+ default:
+ OSL_FAIL("Invalid element type");
+ }
+ if ( !pTreeView->GetEntryCount() )
+ showPreview(NULL);
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OAppDetailPageHelper, OnEntryDoubleClick, SvTreeListBox*, _pTree)
+{
+ OSL_ENSURE( _pTree, "OAppDetailPageHelper, OnEntryDoubleClick: invalid callback!" );
+ bool bHandled = ( _pTree != NULL ) && getBorderWin().getView()->getAppController().onEntryDoubleClick( *_pTree );
+ return bHandled ? 1L : 0L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OAppDetailPageHelper, OnEntrySelChange, void*, /*NOINTERESTEDIN*/)
+{
+ getBorderWin().getView()->getAppController().onSelectionChanged();
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OAppDetailPageHelper, OnCutEntry, void*, /*NOINTERESTEDIN*/ )
+{
+ getBorderWin().getView()->getAppController().onCutEntry();
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OAppDetailPageHelper, OnCopyEntry, void*, /*NOINTERESTEDIN*/ )
+{
+ getBorderWin().getView()->getAppController().onCopyEntry();
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OAppDetailPageHelper, OnPasteEntry, void*, /*NOINTERESTEDIN*/ )
+{
+ getBorderWin().getView()->getAppController().onPasteEntry();
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OAppDetailPageHelper, OnDeleteEntry, void*, /*NOINTERESTEDIN*/ )
+{
+ getBorderWin().getView()->getAppController().onDeleteEntry();
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::Resize()
+{
+ // parent window dimension
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+
+ Window* pWindow = getCurrentView();
+ if ( pWindow )
+ {
+ Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT );
+ sal_Int32 n6PPT = aFLSize.Height();
+ long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
+
+ pWindow->SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
+
+ m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0 ), Size(aFLSize.Width(), nOutputHeight ) );
+
+ String sText = m_aTBPreview.GetItemText(SID_DB_APP_DISABLE_PREVIEW);
+ Size aTBSize = m_aTBPreview.CalcWindowSizePixel();
+ m_aTBPreview.SetPosSizePixel(Point(nOutputWidth - aTBSize.getWidth(), 0 ),
+ aTBSize );
+
+ m_aBorder.SetPosSizePixel(Point(nHalfOutputWidth + aFLSize.Width() + n6PPT, aTBSize.getHeight() + n6PPT ),
+ Size(nHalfOutputWidth - aFLSize.Width() - n6PPT, nOutputHeight - 2*n6PPT - aTBSize.getHeight()) );
+ m_aPreview.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
+ m_aDocumentInfo.SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
+ m_pTablePreview->SetPosSizePixel(Point(0,0),m_aBorder.GetSizePixel() );
+ }
+}
+// -----------------------------------------------------------------------------
+PreviewMode OAppDetailPageHelper::getPreviewMode()
+{
+ return m_ePreviewMode;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAppDetailPageHelper::isPreviewEnabled()
+{
+ return m_ePreviewMode != E_PREVIEWNONE;
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::switchPreview(PreviewMode _eMode,sal_Bool _bForce)
+{
+ if ( m_ePreviewMode != _eMode || _bForce )
+ {
+ m_ePreviewMode = _eMode;
+
+ getBorderWin().getView()->getAppController().previewChanged(static_cast<sal_Int32>(m_ePreviewMode));
+
+ sal_uInt16 nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
+ switch ( m_ePreviewMode )
+ {
+ case E_PREVIEWNONE:
+ nSelectedAction = SID_DB_APP_DISABLE_PREVIEW;
+ break;
+ case E_DOCUMENT:
+ nSelectedAction = SID_DB_APP_VIEW_DOC_PREVIEW;
+ break;
+ case E_DOCUMENTINFO:
+ if ( getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) )
+ nSelectedAction = SID_DB_APP_VIEW_DOCINFO_PREVIEW;
+ else
+ m_ePreviewMode = E_PREVIEWNONE;
+ break;
+ }
+
+ m_aMenu->CheckItem(nSelectedAction);
+ m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, m_aMenu->GetItemText(nSelectedAction));
+ Resize();
+
+ // simulate a selectionChanged event at the controller, to force the preview to be updated
+ if ( isPreviewEnabled() )
+ {
+ if ( getCurrentView() && getCurrentView()->FirstSelected() )
+ {
+ getBorderWin().getView()->getAppController().onSelectionChanged();
+ }
+ }
+ else
+ {
+ m_pTablePreview->Hide();
+ m_aPreview.Hide();
+ m_aDocumentInfo.Hide();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::showPreview(const Reference< XContent >& _xContent)
+{
+ if ( isPreviewEnabled() )
+ {
+ m_pTablePreview->Hide();
+
+ WaitObject aWaitCursor( this );
+ try
+ {
+ Reference<XCommandProcessor> xContent(_xContent,UNO_QUERY);
+ if ( xContent.is() )
+ {
+ com::sun::star::ucb::Command aCommand;
+ if ( m_ePreviewMode == E_DOCUMENT )
+ aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("preview"));
+ else
+ aCommand.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getDocumentInfo"));
+
+ Any aPreview = xContent->execute(aCommand,xContent->createCommandIdentifier(),Reference< XCommandEnvironment >());
+ if ( m_ePreviewMode == E_DOCUMENT )
+ {
+ m_aDocumentInfo.Hide();
+ m_aPreview.Show();
+
+ Graphic aGraphic;
+ Sequence < sal_Int8 > aBmpSequence;
+ if ( aPreview >>= aBmpSequence )
+ {
+ SvMemoryStream aData( aBmpSequence.getArray(),
+ aBmpSequence.getLength(),
+ STREAM_READ );
+
+ GraphicConverter::Import(aData,aGraphic);
+ }
+ m_aPreview.setGraphic( aGraphic );
+ m_aPreview.Invalidate();
+ }
+ else
+ {
+ m_aPreview.Hide();
+ m_aDocumentInfo.Clear();
+ m_aDocumentInfo.Show();
+ Reference<document::XDocumentProperties> xProp(
+ aPreview, UNO_QUERY);
+ if ( xProp.is() )
+ m_aDocumentInfo.fill(xProp,String());
+ }
+ }
+ else
+ {
+ m_aPreview.Hide();
+ m_aDocumentInfo.Hide();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable)
+{
+ if ( isPreviewEnabled() )
+ {
+ WaitObject aWaitCursor( this );
+ m_aPreview.Hide();
+ m_aDocumentInfo.Hide();
+ m_pTablePreview->Show();
+ if ( !m_xFrame.is() )
+ {
+ try
+ {
+ m_xFrame = Reference < XFrame > ( getBorderWin().getView()->getORB()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame")) ), UNO_QUERY );
+ m_xFrame->initialize( m_xWindow );
+
+ // no layout manager (and thus no toolbars) in the preview
+ // Must be called after initialize ... but before any other call to this frame.
+ // Otherwise frame throws "life time exceptions" as e.g. NON_INITIALIZED
+ Reference< XPropertySet > xFrameProps( m_xFrame, UNO_QUERY_THROW );
+ xFrameProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ), makeAny(Reference< XLayoutManager >()) );
+
+ Reference<XFramesSupplier> xSup(getBorderWin().getView()->getAppController().getXController()->getFrame(),UNO_QUERY);
+ if ( xSup.is() )
+ {
+ Reference<XFrames> xFrames = xSup->getFrames();
+ xFrames->append(m_xFrame);
+ }
+ }
+ catch(Exception)
+ {
+ }
+ }
+
+ Reference< XDatabaseDocumentUI > xApplication( getBorderWin().getView()->getAppController().getXController(), UNO_QUERY );
+ ::std::auto_ptr< DatabaseObjectView > pDispatcher( new ResultSetBrowser(
+ getBorderWin().getView()->getORB(), xApplication, NULL, _bTable
+ ) );
+ pDispatcher->setTargetFrame( m_xFrame );
+
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "Preview", sal_True );
+ aArgs.put( "ReadOnly", sal_True );
+ aArgs.put( "AsTemplate", sal_False );
+ aArgs.put( (::rtl::OUString)PROPERTY_SHOWMENU, sal_False );
+
+ Reference< XController > xPreview( pDispatcher->openExisting( makeAny( _sDataSourceName ), _sName, aArgs ), UNO_QUERY );
+ sal_Bool bClearPreview = !xPreview.is();
+
+ // clear the preview when the query or table could not be loaded
+ if ( !bClearPreview )
+ {
+ Reference< XTabController > xTabController( xPreview, UNO_QUERY );
+ bClearPreview = !xTabController.is();
+ if ( !bClearPreview )
+ {
+ Reference< XLoadable > xLoadable( xTabController->getModel(), UNO_QUERY );
+ bClearPreview = !( xLoadable.is() && xLoadable->isLoaded() );
+ }
+ }
+ if ( bClearPreview )
+ showPreview(NULL);
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OAppDetailPageHelper, OnDropdownClickHdl, ToolBox*, /*pToolBox*/)
+{
+ m_aTBPreview.EndSelection();
+
+ // tell the toolbox that the item is pressed down
+ m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, sal_True );
+
+ // simulate a mouse move (so the "down" state is really painted)
+ Point aPoint = m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW ).TopLeft();
+ MouseEvent aMove( aPoint, 0, MOUSE_SIMPLEMOVE | MOUSE_SYNTHETIC );
+ m_aTBPreview.MouseMove( aMove );
+
+ m_aTBPreview.Update();
+
+ // execute the menu
+ ::std::auto_ptr<PopupMenu> aMenu(new PopupMenu( ModuleRes( RID_MENU_APP_PREVIEW ) ));
+
+ sal_uInt16 pActions[] = { SID_DB_APP_DISABLE_PREVIEW
+ , SID_DB_APP_VIEW_DOC_PREVIEW
+ , SID_DB_APP_VIEW_DOCINFO_PREVIEW
+ };
+
+ for(size_t i=0; i < SAL_N_ELEMENTS(pActions);++i)
+ {
+ aMenu->CheckItem(pActions[i],m_aMenu->IsItemChecked(pActions[i]));
+ }
+ aMenu->EnableItem( SID_DB_APP_VIEW_DOCINFO_PREVIEW, getBorderWin().getView()->getAppController().isCommandEnabled(SID_DB_APP_VIEW_DOCINFO_PREVIEW) );
+
+ // no disabled entries
+ aMenu->RemoveDisabledEntries();
+
+ sal_uInt16 nSelectedAction = aMenu->Execute(&m_aTBPreview, m_aTBPreview.GetItemRect( SID_DB_APP_DISABLE_PREVIEW ));
+ // "cleanup" the toolbox state
+ MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
+ m_aTBPreview.MouseMove( aLeave );
+ m_aTBPreview.SetItemDown( SID_DB_APP_DISABLE_PREVIEW, sal_False);
+ if ( nSelectedAction )
+ {
+ m_aTBPreview.SetItemText(SID_DB_APP_DISABLE_PREVIEW, aMenu->GetItemText(nSelectedAction));
+ Resize();
+ getBorderWin().getView()->getAppController().executeChecked(nSelectedAction,Sequence<PropertyValue>());
+ }
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::KeyInput( const KeyEvent& rKEvt )
+{
+ SvTreeListBox* pCurrentView = getCurrentView();
+ OSL_PRECOND( pCurrentView, "OAppDetailPageHelper::KeyInput: how this?" );
+
+ KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction(); (void)eFunc;
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+
+ if ( ( KEY_RETURN == nCode ) && pCurrentView )
+ {
+ getBorderWin().getView()->getAppController().onEntryDoubleClick( *pCurrentView );
+ }
+ else
+ Window::KeyInput(rKEvt);
+}
+
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+
+ {
+ ImplInitSettings();
+ if ( m_pLists[ E_TABLE ] )
+ {
+ OTableTreeListBox* pTableTree = dynamic_cast< OTableTreeListBox* >( m_pLists[ E_TABLE ] );
+ OSL_ENSURE( pTableTree != NULL, "OAppDetailPageHelper::DataChanged: a tree list for tables which is no TableTreeList?" );
+ if ( pTableTree )
+ pTableTree->notifyHiContrastChanged();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppDetailPageHelper::ImplInitSettings()
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ m_aTBPreview.SetPointFont( aFont );
+
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ m_aBorder.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aBorder.SetTextFillColor();
+ m_aTBPreview.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aTBPreview.SetTextFillColor();
+
+ SetBackground( rStyleSettings.GetFieldColor() );
+ m_aBorder.SetBackground( rStyleSettings.GetFieldColor() );
+ m_aFL.SetBackground( rStyleSettings.GetFieldColor() );
+ m_aDocumentInfo.SetBackground( rStyleSettings.GetFieldColor() );
+ m_aTBPreview.SetBackground( rStyleSettings.GetFieldColor() );
+ m_pTablePreview->SetBackground( rStyleSettings.GetFieldColor() );
+}
+// -----------------------------------------------------------------------------
+OPreviewWindow::OPreviewWindow(Window* _pParent)
+: Window(_pParent)
+{
+ ImplInitSettings( sal_True, sal_True, sal_True );
+}
+// -----------------------------------------------------------------------------
+sal_Bool OPreviewWindow::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
+{
+ const Size aWinSize( GetOutputSizePixel() );
+ Size aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
+ sal_Bool bRet = sal_False;
+
+ if( aNewSize.Width() && aNewSize.Height() )
+ {
+ // scale to fit window
+ const double fGrfWH = (double) aNewSize.Width() / aNewSize.Height();
+ const double fWinWH = (double) aWinSize.Width() / aWinSize.Height();
+
+ if ( fGrfWH < fWinWH )
+ {
+ aNewSize.Width() = (long) ( aWinSize.Height() * fGrfWH );
+ aNewSize.Height()= aWinSize.Height();
+ }
+ else
+ {
+ aNewSize.Width() = aWinSize.Width();
+ aNewSize.Height()= (long) ( aWinSize.Width() / fGrfWH);
+ }
+
+ const Point aNewPos( ( aWinSize.Width() - aNewSize.Width() ) >> 1,
+ ( aWinSize.Height() - aNewSize.Height() ) >> 1 );
+
+ rResultRect = Rectangle( aNewPos, aNewSize );
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void OPreviewWindow::Paint( const Rectangle& rRect )
+{
+ Window::Paint( rRect );
+
+ if( ImplGetGraphicCenterRect( m_aGraphicObj.GetGraphic(), m_aPreviewRect ) )
+ {
+ const Point aPos( m_aPreviewRect.TopLeft() );
+ const Size aSize( m_aPreviewRect.GetSize() );
+
+ if( m_aGraphicObj.IsAnimated() )
+ m_aGraphicObj.StartAnimation( this, aPos, aSize );
+ else
+ m_aGraphicObj.Draw( this, aPos, aSize );
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreviewWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreviewWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailPageHelper.hxx b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
new file mode 100644
index 000000000000..69a050c8e2ea
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailPageHelper.hxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPDETAILPAGEHELPER_HXX
+#define DBAUI_APPDETAILPAGEHELPER_HXX
+
+#include <vector>
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include "AppElementType.hxx"
+#include <svtools/svtreebx.hxx>
+#include <svtools/DocumentInfoPreview.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/graph.hxx>
+#include <svtools/grfmgr.hxx>
+#include "callbacks.hxx"
+#include <memory>
+
+namespace com{ namespace sun { namespace star { namespace awt { class XWindow; } } } }
+namespace com{ namespace sun { namespace star { namespace frame { class XFrame; } } } }
+namespace com{ namespace sun { namespace star { namespace io { class XPersist; } } } }
+
+#define ELEMENT_COUNT size_t(E_ELEMENT_TYPE_COUNT)
+
+namespace dbaui
+{
+ class OAppBorderWindow;
+ class DBTreeListBox;
+
+ class OPreviewWindow : public Window
+ {
+ GraphicObject m_aGraphicObj;
+ Rectangle m_aPreviewRect;
+
+ /** gets the graphic cnter rect
+ @param rGraphic
+ the graphic
+ @param rResultRect
+ the resulting rectangle
+
+ @return
+ <TRUE/> when successfull
+ */
+ sal_Bool ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const;
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OPreviewWindow(Window* _pParent);
+
+ // window overloads
+ virtual void Paint(const Rectangle& rRect);
+
+ void setGraphic(const Graphic& _rGraphic ) { m_aGraphicObj.SetGraphic(_rGraphic); }
+ };
+ //==================================================================
+ // A helper class for the controls in the detail page.
+ // Combines general functionality.
+ //==================================================================
+ class OAppDetailPageHelper : public Window
+ {
+ DBTreeListBox* m_pLists[ELEMENT_COUNT];
+ OAppBorderWindow& m_rBorderWin;
+ FixedLine m_aFL;
+ ToolBox m_aTBPreview;
+ Window m_aBorder;
+ OPreviewWindow m_aPreview;
+ ::svtools::ODocumentInfoPreview
+ m_aDocumentInfo;
+ Window* m_pTablePreview;
+ ::std::auto_ptr<PopupMenu> m_aMenu;
+ PreviewMode m_ePreviewMode;
+ ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame >
+ m_xFrame;
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XPersist >
+ m_xDocInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
+ m_xWindow;
+
+ /// returns the index of the visible control
+ int getVisibleControlIndex() const;
+
+ /** sorts the entries in the tree list box.
+ @param _nPos
+ Which list should be sorted.
+ @param _eSortMode
+ How should be sorted.
+ */
+ void sort(int _nPos,SvSortMode _eSortMode );
+
+ /** retrieves the resource ids of the images representing elements of the given type
+ */
+ void getElementIcons( ElementType _eType, sal_uInt16& _rImageId);
+
+ /** fills the names in the listbox
+ @param _xContainer
+ This can either be the queries, forms or report names.
+ @param _eType
+ the type of elements which are being filled
+ @param _nImageId
+ the resource id of the image to use for non-container entries
+ @param _pParent
+ The parent of the entries to be inserted.
+ */
+ void fillNames( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer,
+ const ElementType _eType,
+ const sal_uInt16 _nImageId,
+ SvLBoxEntry* _pParent );
+
+ /** sets the detail page
+ @param _pWindow
+ The control which should be visible.
+ */
+ void setDetailPage(Window* _pWindow);
+
+ /** sets all HandleCallbacks
+ @param _pTreeView
+ The newly created DBTreeListBox
+ @param _rImage
+ the resource id of the default icon
+ @return
+ The new tree.
+ */
+ DBTreeListBox* createTree( DBTreeListBox* _pTreeView, const Image& _rImage );
+
+ /** creates the tree and sets all HandleCallbacks
+ @param _nHelpId
+ The help id of the control
+ @param _nCollapsedBitmap
+ The image to use in high contrast mode.
+ @return
+ The new tree.
+ */
+ DBTreeListBox* createSimpleTree( const rtl::OString& _sHelpId, const Image& _rImage);
+
+ DECL_LINK( OnEntryDoubleClick, SvTreeListBox* );
+ DECL_LINK( OnEntrySelChange, void* );
+
+ DECL_LINK( OnCutEntry, void* );
+ DECL_LINK( OnCopyEntry, void* );
+ DECL_LINK( OnPasteEntry, void* );
+ DECL_LINK( OnDeleteEntry, void* );
+
+ DECL_LINK(PreviewChangeHdl, void*);
+ // click a TB slot
+ DECL_LINK(OnDropdownClickHdl, ToolBox*);
+
+ inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
+ void ImplInitSettings();
+
+ public:
+ OAppDetailPageHelper(Window* _pParent,OAppBorderWindow& _rBorderWin,PreviewMode _ePreviewMode);
+ virtual ~OAppDetailPageHelper();
+
+ // window overloads
+ virtual void Resize();
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+ sal_Bool isCutAllowed();
+ sal_Bool isCopyAllowed();
+ sal_Bool isPasteAllowed();
+ void copy();
+ void cut();
+ void paste();
+
+ /** creates the tables page
+ @param _xConnection
+ The connection to get the table names
+ */
+ void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ /** creates the page for the specific type.
+ @param _eType
+ The type which should be created. E_TABLE isn't allowed.
+ @param _xContainer
+ The container of the elements to be inserted.
+ */
+ void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
+
+ /** returns the current visible tree list box
+ */
+ inline DBTreeListBox* getCurrentView() const
+ {
+ ElementType eType = getElementType();
+ return (eType != E_NONE ) ? m_pLists[static_cast<sal_Int32>(eType)] : NULL;
+ }
+
+ /// select all entries in the visible control
+ void selectAll();
+
+ /// returns <TRUE/> if it sorts ascending
+ sal_Bool isSortUp() const;
+
+ /// sorts all entries ascending
+ void sortDown();
+
+ /// sorts all entries descending
+ void sortUp();
+
+ /** returns the element names which are selected
+ @param _rNames
+ The list will be filled.
+ */
+ void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
+
+ /** describes the current selection for the given control
+ */
+ void describeCurrentSelectionForControl(
+ const Control& _rControl,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** describes the current selection for the given ElementType
+ */
+ void describeCurrentSelectionForType(
+ const ElementType _eType,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** select all names on the currently selected container. Non existence names where ignored.
+ *
+ * \param _aNames the element names
+ */
+ void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
+
+ /** return the qualified name.
+ @param _pEntry
+ The entry of a table, or query, form, report to get the qualified name.
+ If the entry is <NULL/>, the first selected is chosen.
+ @return
+ the qualified name
+ */
+ ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
+
+ /// return the element of currently select entry
+ ElementType getElementType() const;
+
+ /// returns the count of selected entries
+ sal_Int32 getSelectionCount();
+
+ /// returns the count of entries
+ sal_Int32 getElementCount();
+
+ /** returns if an entry is a leaf
+ @param _pEntry
+ The entry to check
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ bool isLeaf(SvLBoxEntry* _pEntry) const;
+
+ /** returns if one of the selected entries is a leaf
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ sal_Bool isALeafSelected() const;
+
+ SvLBoxEntry* getEntry( const Point& _aPosPixel ) const;
+
+ /// clears the detail pages
+ void clearPages();
+
+ /// returns <TRUE/> when a detail page was filled
+ sal_Bool isFilled() const;
+
+ /** adds a new object to the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the object to be inserted
+ @param _rObject
+ The object to add.
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ */
+ SvLBoxEntry* elementAdded(ElementType eType
+ ,const ::rtl::OUString& _rName
+ ,const ::com::sun::star::uno::Any& _rObject );
+
+ /** replaces a objects name with a new one
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rOldName
+ The old name of the object to be replaced
+ @param _rNewName
+ The new name of the object to be replaced
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ */
+ void elementReplaced(ElementType eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName );
+
+ /** removes an element from the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the element to be removed.
+ @param _rxConn
+ If we remove a table, the connection must be set.
+ */
+ void elementRemoved(ElementType _eType
+ ,const ::rtl::OUString& _rName );
+
+
+ /// returns the preview mode
+ PreviewMode getPreviewMode();
+
+ /// <TRUE/> if the preview is enabled
+ sal_Bool isPreviewEnabled();
+
+ /** switches to the given preview mode
+ @param _eMode
+ the mode to set for the preview
+ @param _bForce
+ Force the preview to be resetted
+ */
+ void switchPreview(PreviewMode _eMode,sal_Bool _bForce = sal_False);
+
+ /** shows the Preview of the content when it is enabled.
+ @param _xContent
+ The content which must support the "preview" command.
+ */
+ void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
+
+ /** shows the Preview of a table or query
+ @param _sDataSourceName
+ the name of the data source
+ @param _sName
+ the name of table or query
+ @param _bTable
+ <TRUE/> if it is a table, otherwise <FALSE/>
+ @return void
+ */
+ void showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable);
+
+ protected:
+ void DataChanged( const DataChangedEvent& rDCEvt );
+ };
+}
+#endif // DBAUI_APPDETAILPAGEHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx
new file mode 100644
index 000000000000..a2259654a858
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailView.cxx
@@ -0,0 +1,955 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppDetailView.hxx"
+#include <osl/diagnose.h>
+#include "dbaccess_helpid.hrc"
+#include "dbu_app.hrc"
+#include "AppView.hxx"
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XImageManager.hpp>
+#include <com/sun/star/ui/ImageType.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include "listviewitems.hxx"
+#include <vcl/image.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/mnemonic.hxx>
+#include "browserids.hxx"
+#include "AppDetailPageHelper.hxx"
+#include <vcl/svapp.hxx>
+#include "callbacks.hxx"
+#include "IController.hxx"
+#include "moduledbu.hxx"
+#include <svtools/localresaccess.hxx>
+#include <algorithm>
+#include "dbtreelistbox.hxx"
+#include "IApplicationController.hxx"
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::graphic;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using ::com::sun::star::util::URL;
+using ::com::sun::star::sdb::application::NamedDatabaseObject;
+
+#define SPACEBETWEENENTRIES 4
+
+// -----------------------------------------------------------------------------
+TaskEntry::TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled )
+ :sUNOCommand( ::rtl::OUString::createFromAscii( _pAsciiUNOCommand ) )
+ ,nHelpID( _nHelpID )
+ ,sTitle( ModuleRes( _nTitleResourceID ) )
+ ,bHideWhenDisabled( _bHideWhenDisabled )
+{
+}
+
+// -----------------------------------------------------------------------------
+OCreationList::OCreationList( OTasksWindow& _rParent )
+ :SvTreeListBox( &_rParent, WB_TABSTOP | WB_HASBUTTONSATROOT | WB_HASBUTTONS )
+ ,m_rTaskWindow( _rParent )
+ ,m_pMouseDownEntry( NULL )
+ ,m_pLastActiveEntry( NULL )
+{
+ sal_uInt16 nSize = SPACEBETWEENENTRIES;
+ SetSpaceBetweenEntries(nSize);
+ SetSelectionMode( NO_SELECTION );
+ SetExtendedWinBits( EWB_NO_AUTO_CURENTRY );
+ EnableEntryMnemonics();
+}
+// -----------------------------------------------------------------------------
+void OCreationList::Paint( const Rectangle& _rRect )
+{
+ if ( m_pMouseDownEntry )
+ m_aOriginalFont = GetFont();
+
+ m_aOriginalBackgroundColor = GetBackground().GetColor();
+ SvTreeListBox::Paint( _rRect );
+ SetBackground( m_aOriginalBackgroundColor );
+
+ if ( m_pMouseDownEntry )
+ Control::SetFont( m_aOriginalFont );
+}
+
+// -----------------------------------------------------------------------------
+void OCreationList::PreparePaint( SvLBoxEntry* _pEntry )
+{
+ Wallpaper aEntryBackground( m_aOriginalBackgroundColor );
+ if ( _pEntry )
+ {
+ if ( _pEntry == GetCurEntry() )
+ {
+ // draw a selection background
+ bool bIsMouseDownEntry = ( _pEntry == m_pMouseDownEntry );
+ DrawSelectionBackground( GetBoundingRect( _pEntry ), bIsMouseDownEntry ? 1 : 2, sal_False, sal_True, sal_False );
+
+ if ( bIsMouseDownEntry )
+ {
+ Font aFont( GetFont() );
+ aFont.SetColor( GetSettings().GetStyleSettings().GetHighlightTextColor() );
+ Control::SetFont( aFont );
+ }
+
+ // and temporary set a transparent background, for all the other
+ // paint operations the SvTreeListBox is going to do
+ aEntryBackground = Wallpaper( Color( COL_TRANSPARENT ) );
+ }
+ }
+
+ SetBackground( aEntryBackground );
+}
+
+// -----------------------------------------------------------------------------
+void OCreationList::SelectSearchEntry( const void* _pEntry )
+{
+ SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) );
+ OSL_ENSURE( pEntry, "OCreationList::SelectSearchEntry: invalid entry!" );
+
+ if ( pEntry )
+ setCurrentEntryInvalidate( pEntry );
+
+ if ( !HasChildPathFocus() )
+ GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+void OCreationList::ExecuteSearchEntry( const void* _pEntry ) const
+{
+ SvLBoxEntry* pEntry = const_cast< SvLBoxEntry* >( static_cast< const SvLBoxEntry* >( _pEntry ) );
+ OSL_ENSURE( pEntry, "OCreationList::ExecuteSearchEntry: invalid entry!" );
+ OSL_ENSURE( pEntry == GetCurEntry(), "OCreationList::ExecuteSearchEntry: SelectSearchEntry should have been called before!" );
+
+ if ( pEntry )
+ onSelected( pEntry );
+}
+
+// -----------------------------------------------------------------------------
+Rectangle OCreationList::GetFocusRect( SvLBoxEntry* _pEntry, long _nLine )
+{
+ Rectangle aRect = SvTreeListBox::GetFocusRect( _pEntry, _nLine );
+ aRect.Left() = 0;
+
+ // try to let the focus rect start before the bitmap item - this looks better
+ SvLBoxItem* pBitmapItem = _pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP );
+ SvLBoxTab* pTab = pBitmapItem ? GetTab( _pEntry, pBitmapItem ) : NULL;
+ SvViewDataItem* pItemData = pBitmapItem ? GetViewDataItem( _pEntry, pBitmapItem ) : NULL;
+ OSL_ENSURE( pTab && pItemData, "OCreationList::GetFocusRect: could not find the first bitmap item!" );
+ if ( pTab && pItemData )
+ aRect.Left() = pTab->GetPos() - pItemData->aSize.Width() / 2;
+
+ // inflate the rectangle a little bit - looks better, too
+ aRect.Left() = ::std::max< long >( 0, aRect.Left() - 2 );
+ aRect.Right() = ::std::min< long >( GetOutputSizePixel().Width() - 1, aRect.Right() + 2 );
+
+ return aRect;
+}
+// -----------------------------------------------------------------------------
+void OCreationList::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
+{
+ // don't give this to the base class, it does a ReleaseMouse as very first action
+ // Though I think this is a bug (it should ReleaseMouse only if it is going to do
+ // something with the drag-event), I hesitate to fix it in the current state,
+ // since I don't overlook the consequences, and we're close to 2.0 ...)
+}
+// -----------------------------------------------------------------------------
+void OCreationList::ModelHasCleared()
+{
+ SvTreeListBox::ModelHasCleared();
+ m_pLastActiveEntry = NULL;
+ m_pMouseDownEntry = NULL;
+}
+// -----------------------------------------------------------------------------
+void OCreationList::GetFocus()
+{
+ SvTreeListBox::GetFocus();
+ if ( !GetCurEntry() )
+ setCurrentEntryInvalidate( m_pLastActiveEntry ? m_pLastActiveEntry : GetFirstEntryInView() );
+}
+// -----------------------------------------------------------------------------
+void OCreationList::LoseFocus()
+{
+ SvTreeListBox::LoseFocus();
+ m_pLastActiveEntry = GetCurEntry();
+ setCurrentEntryInvalidate( NULL );
+}
+// -----------------------------------------------------------------------------
+void OCreationList::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ SvTreeListBox::MouseButtonDown( rMEvt );
+
+ OSL_ENSURE( !m_pMouseDownEntry, "OCreationList::MouseButtonDown: I missed some mouse event!" );
+ m_pMouseDownEntry = GetCurEntry();
+ if ( m_pMouseDownEntry )
+ {
+ InvalidateEntry( m_pMouseDownEntry );
+ CaptureMouse();
+ }
+}
+// -----------------------------------------------------------------------------
+void OCreationList::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeaveWindow() )
+ {
+ setCurrentEntryInvalidate( NULL );
+ }
+ else if ( !rMEvt.IsSynthetic() )
+ {
+ SvLBoxEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
+
+ if ( m_pMouseDownEntry )
+ {
+ // we're currently in a "mouse down" phase
+ OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseMove: inconsistence (1)!" );
+ if ( pEntry == m_pMouseDownEntry )
+ {
+ setCurrentEntryInvalidate( m_pMouseDownEntry );
+ }
+ else
+ {
+ OSL_ENSURE( ( GetCurEntry() == m_pMouseDownEntry ) || !GetCurEntry(),
+ "OCreationList::MouseMove: inconsistence (2)!" );
+ setCurrentEntryInvalidate( NULL );
+ }
+ }
+ else
+ {
+ // the user is simply hovering with the mouse
+ if ( setCurrentEntryInvalidate( pEntry ) )
+ {
+ if ( !m_pMouseDownEntry )
+ updateHelpText();
+ }
+ }
+ }
+
+ SvTreeListBox::MouseMove(rMEvt);
+}
+// -----------------------------------------------------------------------------
+void OCreationList::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ SvLBoxEntry* pEntry = GetEntry( rMEvt.GetPosPixel() );
+ bool bExecute = false;
+ // Was the mouse released over the active entry?
+ // (i.e. the entry which was under the mouse when the button went down)
+ if ( pEntry && ( m_pMouseDownEntry == pEntry ) )
+ {
+ if ( !rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ bExecute = true;
+ }
+
+ if ( m_pMouseDownEntry )
+ {
+ OSL_ENSURE( IsMouseCaptured(), "OCreationList::MouseButtonUp: hmmm .... no mouse captured, but an active entry?" );
+ ReleaseMouse();
+
+ InvalidateEntry( m_pMouseDownEntry );
+ m_pMouseDownEntry = NULL;
+ }
+
+ SvTreeListBox::MouseButtonUp( rMEvt );
+
+ if ( bExecute )
+ onSelected( pEntry );
+}
+// -----------------------------------------------------------------------------
+bool OCreationList::setCurrentEntryInvalidate( SvLBoxEntry* _pEntry )
+{
+ if ( GetCurEntry() != _pEntry )
+ {
+ if ( GetCurEntry() )
+ InvalidateEntry( GetCurEntry() );
+ SetCurEntry( _pEntry );
+ if ( GetCurEntry() )
+ {
+ InvalidateEntry( GetCurEntry() );
+ CallEventListeners( VCLEVENT_LISTBOX_SELECT, GetCurEntry() );
+ }
+ updateHelpText();
+ return true;
+ }
+ return false;
+}
+// -----------------------------------------------------------------------------
+void OCreationList::updateHelpText()
+{
+ sal_uInt16 nHelpTextId = 0;
+ if ( GetCurEntry() )
+ nHelpTextId = reinterpret_cast< TaskEntry* >( GetCurEntry()->GetUserData() )->nHelpID;
+ m_rTaskWindow.setHelpText( nHelpTextId );
+}
+// -----------------------------------------------------------------------------
+void OCreationList::onSelected( SvLBoxEntry* _pEntry ) const
+{
+ OSL_ENSURE( _pEntry, "OCreationList::onSelected: invalid entry!" );
+ URL aCommand;
+ aCommand.Complete = reinterpret_cast< TaskEntry* >( _pEntry->GetUserData() )->sUNOCommand;
+ m_rTaskWindow.getDetailView()->getBorderWin().getView()->getAppController().executeChecked( aCommand, Sequence< PropertyValue >() );
+}
+// -----------------------------------------------------------------------------
+void OCreationList::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rCode = rKEvt.GetKeyCode();
+ if ( !rCode.IsMod1() && !rCode.IsMod2() && !rCode.IsShift() )
+ {
+ if ( rCode.GetCode() == KEY_RETURN )
+ {
+ SvLBoxEntry* pEntry = GetCurEntry() ? GetCurEntry() : FirstSelected();
+ if ( pEntry )
+ onSelected( pEntry );
+ return;
+ }
+ }
+ SvLBoxEntry* pOldCurrent = GetCurEntry();
+ SvTreeListBox::KeyInput(rKEvt);
+ SvLBoxEntry* pNewCurrent = GetCurEntry();
+
+ if ( pOldCurrent != pNewCurrent )
+ {
+ if ( pOldCurrent )
+ InvalidateEntry( pOldCurrent );
+ if ( pNewCurrent )
+ {
+ InvalidateEntry( pNewCurrent );
+ CallEventListeners( VCLEVENT_LISTBOX_SELECT, pNewCurrent );
+ }
+ updateHelpText();
+ }
+}
+// -----------------------------------------------------------------------------
+DBG_NAME(OTasksWindow)
+OTasksWindow::OTasksWindow(Window* _pParent,OApplicationDetailView* _pDetailView)
+ : Window(_pParent,WB_DIALOGCONTROL )
+ ,m_aCreation(*this)
+ ,m_aDescription(this)
+ ,m_aHelpText(this,WB_WORDBREAK)
+ ,m_aFL(this,WB_VERT)
+ ,m_pDetailView(_pDetailView)
+{
+ DBG_CTOR(OTasksWindow,NULL);
+ SetUniqueId(UID_APP_TASKS_WINDOW);
+ m_aCreation.SetHelpId(HID_APP_CREATION_LIST);
+ m_aCreation.SetSelectHdl(LINK(this, OTasksWindow, OnEntrySelectHdl));
+ m_aHelpText.SetHelpId(HID_APP_HELP_TEXT);
+ m_aDescription.SetHelpId(HID_APP_DESCRIPTION_TEXT);
+ m_aDescription.SetText(ModuleRes(STR_DESCRIPTION));
+ ImplInitSettings(sal_True,sal_True,sal_True);
+}
+// -----------------------------------------------------------------------------
+OTasksWindow::~OTasksWindow()
+{
+ DBG_DTOR(OTasksWindow,NULL);
+ Clear();
+}
+// -----------------------------------------------------------------------
+void OTasksWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OTasksWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ m_aHelpText.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aHelpText.SetTextFillColor();
+ m_aDescription.SetTextColor( rStyleSettings.GetFieldTextColor() );
+ m_aDescription.SetTextFillColor();
+ }
+
+ if( bBackground )
+ {
+ SetBackground( rStyleSettings.GetFieldColor() );
+ m_aHelpText.SetBackground( rStyleSettings.GetFieldColor() );
+ m_aDescription.SetBackground( rStyleSettings.GetFieldColor() );
+ m_aFL.SetBackground( rStyleSettings.GetFieldColor() );
+ }
+
+ Font aFont = m_aDescription.GetControlFont();
+ aFont.SetWeight(WEIGHT_BOLD);
+ m_aDescription.SetControlFont(aFont);
+}
+// -----------------------------------------------------------------------------
+void OTasksWindow::setHelpText(sal_uInt16 _nId)
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ if ( _nId )
+ {
+ String sText = ModuleRes(_nId);
+
+ m_aHelpText.SetText(sText);
+ }
+ else
+ {
+ m_aHelpText.SetText(String());
+}
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OTasksWindow, OnEntrySelectHdl, SvTreeListBox*, /*_pTreeBox*/)
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ SvLBoxEntry* pEntry = m_aCreation.GetHdlEntry();
+ if ( pEntry )
+ m_aHelpText.SetText( ModuleRes( reinterpret_cast< TaskEntry* >( pEntry->GetUserData() )->nHelpID ) );
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+void OTasksWindow::Resize()
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+
+ // parent window dimension
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+
+ Size aFLSize = LogicToPixel( Size( 2, 6 ), MAP_APPFONT );
+ sal_Int32 n6PPT = aFLSize.Height();
+ long nHalfOutputWidth = static_cast<long>(nOutputWidth * 0.5);
+
+ m_aCreation.SetPosSizePixel( Point(0, 0), Size(nHalfOutputWidth - n6PPT, nOutputHeight) );
+ // i77897 make the m_aHelpText a little bit smaller. (-5)
+ sal_Int32 nNewWidth = nOutputWidth - nHalfOutputWidth - aFLSize.Width() - 5;
+ m_aDescription.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, 0), Size(nNewWidth, nOutputHeight) );
+ Size aDesc = m_aDescription.CalcMinimumSize();
+ m_aHelpText.SetPosSizePixel( Point(nHalfOutputWidth + n6PPT, aDesc.Height() ), Size(nNewWidth, nOutputHeight - aDesc.Height() - n6PPT) );
+
+ m_aFL.SetPosSizePixel( Point(nHalfOutputWidth , 0), Size(aFLSize.Width(), nOutputHeight ) );
+}
+// -----------------------------------------------------------------------------
+void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList )
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ Clear();
+
+ try
+ {
+ Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier(
+ getDetailView()->getBorderWin().getView()->getORB()->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) )
+ ) ,
+ UNO_QUERY
+ );
+ Reference< XUIConfigurationManager > xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.OfficeDatabaseDocument" ) )
+ );
+ Reference< XImageManager > xImageMgr( xUIConfigMgr->getImageManager(), UNO_QUERY );
+
+ // copy the commands so we can use them with the config managers
+ Sequence< ::rtl::OUString > aCommands( _rList.size() );
+ ::rtl::OUString* pCommands = aCommands.getArray();
+ TaskEntryList::const_iterator aEnd = _rList.end();
+ for ( TaskEntryList::const_iterator pCopyTask = _rList.begin(); pCopyTask != aEnd; ++pCopyTask, ++pCommands )
+ *pCommands = pCopyTask->sUNOCommand;
+
+ Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages(
+ ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL ,
+ aCommands
+ );
+
+ const Reference< XGraphic >* pImages( aImages.getConstArray() );
+
+ for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages )
+ {
+ SvLBoxEntry* pEntry = m_aCreation.InsertEntry( pTask->sTitle );
+ pEntry->SetUserData( reinterpret_cast< void* >( new TaskEntry( *pTask ) ) );
+
+ Image aImage = Image( *pImages );
+ m_aCreation.SetExpandedEntryBmp( pEntry, aImage );
+ m_aCreation.SetCollapsedEntryBmp( pEntry, aImage );
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_aCreation.Show();
+ m_aCreation.SelectAll(sal_False);
+ m_aHelpText.Show();
+ m_aDescription.Show();
+ m_aFL.Show();
+ m_aCreation.updateHelpText();
+ Enable(!_rList.empty());
+}
+// -----------------------------------------------------------------------------
+void OTasksWindow::Clear()
+{
+ DBG_CHKTHIS(OTasksWindow,NULL);
+ m_aCreation.resetLastActive();
+ SvLBoxEntry* pEntry = m_aCreation.First();
+ while ( pEntry )
+ {
+ delete reinterpret_cast< TaskEntry* >( pEntry->GetUserData() );
+ pEntry = m_aCreation.Next(pEntry);
+ }
+ m_aCreation.Clear();
+}
+//==================================================================
+// class OApplicationDetailView
+//==================================================================
+DBG_NAME(OApplicationDetailView)
+OApplicationDetailView::OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode) : OSplitterView(&_rParent,sal_False )
+ ,m_aHorzSplitter(this)
+ ,m_aTasks(this,STR_TASKS,WB_BORDER | WB_DIALOGCONTROL )
+ ,m_aContainer(this,0,WB_BORDER | WB_DIALOGCONTROL )
+ ,m_rBorderWin(_rParent)
+{
+ DBG_CTOR(OApplicationDetailView,NULL);
+ SetUniqueId(UID_APP_DETAIL_VIEW);
+ ImplInitSettings( sal_True, sal_True, sal_True );
+
+ m_pControlHelper = new OAppDetailPageHelper(&m_aContainer,m_rBorderWin,_ePreviewMode);
+ m_pControlHelper->Show();
+ m_aContainer.setChildWindow(m_pControlHelper);
+
+ OTasksWindow* pTasks = new OTasksWindow(&m_aTasks,this);
+ pTasks->Show();
+ pTasks->Disable(m_rBorderWin.getView()->getCommandController().isDataSourceReadOnly());
+ m_aTasks.setChildWindow(pTasks);
+ m_aTasks.SetUniqueId(UID_APP_TASKS_VIEW);
+ m_aTasks.Show();
+
+ m_aContainer.SetUniqueId(UID_APP_CONTAINER_VIEW);
+ m_aContainer.Show();
+
+ const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
+ m_aHorzSplitter.SetPosSizePixel( Point(0,50), Size(0,nFrameWidth) );
+ // now set the components at the base class
+ set(&m_aContainer,&m_aTasks);
+
+ m_aHorzSplitter.Show();
+ m_aHorzSplitter.SetUniqueId(UID_APP_VIEW_HORZ_SPLIT);
+ setSplitter(&m_aHorzSplitter);
+}
+// -----------------------------------------------------------------------------
+OApplicationDetailView::~OApplicationDetailView()
+{
+ DBG_DTOR(OApplicationDetailView,NULL);
+ set(NULL,NULL);
+ setSplitter(NULL);
+ m_pControlHelper = NULL;
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+
+ m_aHorzSplitter.SetBackground( rStyleSettings.GetDialogColor() );
+ m_aHorzSplitter.SetFillColor( rStyleSettings.GetDialogColor() );
+ m_aHorzSplitter.SetTextFillColor(rStyleSettings.GetDialogColor() );
+}
+// -----------------------------------------------------------------------
+void OApplicationDetailView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ OSplitterView::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::GetFocus()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ OSplitterView::GetFocus();
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
+{
+ m_aExternalMnemonics = _rMnemonics;
+}
+
+// -----------------------------------------------------------------------------
+bool OApplicationDetailView::interceptKeyInput( const KeyEvent& _rEvent )
+{
+ const KeyCode& rKeyCode = _rEvent.GetKeyCode();
+ if ( rKeyCode.GetModifier() == KEY_MOD2 )
+ return getTasksWindow().HandleKeyInput( _rEvent );
+
+ // not handled
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::createTablesPage(const Reference< XConnection >& _xConnection )
+{
+ impl_createPage( E_TABLE, _xConnection, NULL );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::createPage( ElementType _eType,const Reference< XNameAccess >& _xContainer )
+{
+ impl_createPage( _eType, NULL, _xContainer );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::impl_createPage( ElementType _eType, const Reference< XConnection >& _rxConnection,
+ const Reference< XNameAccess >& _rxNonTableElements )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+
+ // get the data for the pane
+ const TaskPaneData& rData = impl_getTaskPaneData( _eType );
+ getTasksWindow().fillTaskEntryList( rData.aTasks );
+
+ // enable the pane as a whole, depending on the availability of the first command
+ OSL_ENSURE( !rData.aTasks.empty(), "OApplicationDetailView::impl_createPage: no tasks at all!?" );
+ bool bEnabled = rData.aTasks.empty()
+ ? false
+ : getBorderWin().getView()->getCommandController().isCommandEnabled( rData.aTasks[0].sUNOCommand );
+ getTasksWindow().Enable( bEnabled );
+ m_aContainer.setTitle( rData.nTitleId );
+
+ // let our helper create the object list
+ if ( _eType == E_TABLE )
+ m_pControlHelper->createTablesPage( _rxConnection );
+ else
+ m_pControlHelper->createPage( _eType, _rxNonTableElements );
+
+ // resize for proper window arrangements
+ Resize();
+}
+
+// -----------------------------------------------------------------------------
+const TaskPaneData& OApplicationDetailView::impl_getTaskPaneData( ElementType _eType )
+{
+ if ( m_aTaskPaneData.empty() )
+ m_aTaskPaneData.resize( ELEMENT_COUNT );
+ OSL_ENSURE( ( _eType >= 0 ) && ( _eType < E_ELEMENT_TYPE_COUNT ), "OApplicationDetailView::impl_getTaskPaneData: illegal element type!" );
+ TaskPaneData& rData = m_aTaskPaneData[ _eType ];
+
+ //oj: do not check, otherwise extensions will only be visible after a reload.
+ impl_fillTaskPaneData( _eType, rData );
+
+ return rData;
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const
+{
+ TaskEntryList& rList( _rData.aTasks );
+ rList.clear(); rList.reserve( 4 );
+
+ switch ( _eType )
+ {
+ case E_TABLE:
+ rList.push_back( TaskEntry( ".uno:DBNewTable", RID_STR_TABLES_HELP_TEXT_DESIGN, RID_STR_NEW_TABLE ) );
+ rList.push_back( TaskEntry( ".uno:DBNewTableAutoPilot", RID_STR_TABLES_HELP_TEXT_WIZARD, RID_STR_NEW_TABLE_AUTO ) );
+ rList.push_back( TaskEntry( ".uno:DBNewView", RID_STR_VIEWS_HELP_TEXT_DESIGN, RID_STR_NEW_VIEW, true ) );
+ _rData.nTitleId = RID_STR_TABLES_CONTAINER;
+ break;
+
+ case E_FORM:
+ rList.push_back( TaskEntry( ".uno:DBNewForm", RID_STR_FORMS_HELP_TEXT, RID_STR_NEW_FORM ) );
+ rList.push_back( TaskEntry( ".uno:DBNewFormAutoPilot", RID_STR_FORMS_HELP_TEXT_WIZARD, RID_STR_NEW_FORM_AUTO ) );
+ _rData.nTitleId = RID_STR_FORMS_CONTAINER;
+ break;
+
+ case E_REPORT:
+ rList.push_back( TaskEntry( ".uno:DBNewReport", RID_STR_REPORT_HELP_TEXT, RID_STR_NEW_REPORT, true ) );
+ rList.push_back( TaskEntry( ".uno:DBNewReportAutoPilot", RID_STR_REPORTS_HELP_TEXT_WIZARD, RID_STR_NEW_REPORT_AUTO ) );
+ _rData.nTitleId = RID_STR_REPORTS_CONTAINER;
+ break;
+
+ case E_QUERY:
+ rList.push_back( TaskEntry( ".uno:DBNewQuery", RID_STR_QUERIES_HELP_TEXT, RID_STR_NEW_QUERY ) );
+ rList.push_back( TaskEntry( ".uno:DBNewQueryAutoPilot", RID_STR_QUERIES_HELP_TEXT_WIZARD, RID_STR_NEW_QUERY_AUTO ) );
+ rList.push_back( TaskEntry( ".uno:DBNewQuerySql", RID_STR_QUERIES_HELP_TEXT_SQL, RID_STR_NEW_QUERY_SQL ) );
+ _rData.nTitleId = RID_STR_QUERIES_CONTAINER;
+ break;
+
+ default:
+ OSL_FAIL( "OApplicationDetailView::impl_fillTaskPaneData: illegal element type!" );
+ }
+
+ MnemonicGenerator aAllMnemonics( m_aExternalMnemonics );
+
+ // remove the entries which are not enabled currently
+ for ( TaskEntryList::iterator pTask = rList.begin();
+ pTask != rList.end();
+ )
+ {
+ if ( pTask->bHideWhenDisabled
+ && !getBorderWin().getView()->getCommandController().isCommandEnabled( pTask->sUNOCommand )
+ )
+ pTask = rList.erase( pTask );
+ else
+ {
+ aAllMnemonics.RegisterMnemonic( pTask->sTitle );
+ ++pTask;
+ }
+ }
+
+ // for the remaining entries, assign mnemonics
+ for ( TaskEntryList::iterator pTask = rList.begin();
+ pTask != rList.end();
+ ++pTask
+ )
+ {
+ aAllMnemonics.CreateMnemonic( pTask->sTitle );
+ // don't do this for now, until our task window really supports mnemonics
+ }
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationDetailView::getQualifiedName( SvLBoxEntry* _pEntry ) const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getQualifiedName( _pEntry );
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isLeaf(SvLBoxEntry* _pEntry) const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isLeaf(_pEntry);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isALeafSelected() const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isALeafSelected();
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::selectAll()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->selectAll();
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::sortDown()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->sortDown();
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::sortUp()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->sortUp();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isFilled() const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isFilled();
+}
+// -----------------------------------------------------------------------------
+ElementType OApplicationDetailView::getElementType() const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getElementType();
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::clearPages(sal_Bool _bTaskAlso)
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ if ( _bTaskAlso )
+ getTasksWindow().Clear();
+ m_pControlHelper->clearPages();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OApplicationDetailView::getSelectionCount()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getSelectionCount();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OApplicationDetailView::getElementCount()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getElementCount();
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->getSelectionElementNames( _rNames );
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::selectElements(const Sequence< ::rtl::OUString>& _aNames)
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->selectElements( _aNames );
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OApplicationDetailView::getEntry( const Point& _aPoint ) const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getEntry(_aPoint);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isCutAllowed()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isCutAllowed();
+}
+sal_Bool OApplicationDetailView::isCopyAllowed()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isCopyAllowed();
+}
+sal_Bool OApplicationDetailView::isPasteAllowed() { DBG_CHKTHIS(OApplicationDetailView,NULL);return m_pControlHelper->isPasteAllowed(); }
+void OApplicationDetailView::copy() { DBG_CHKTHIS(OApplicationDetailView,NULL);m_pControlHelper->copy(); }
+void OApplicationDetailView::cut() { DBG_CHKTHIS(OApplicationDetailView,NULL);m_pControlHelper->cut(); }
+void OApplicationDetailView::paste()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->paste();
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OApplicationDetailView::elementAdded(ElementType _eType,const ::rtl::OUString& _rName, const Any& _rObject )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->elementAdded(_eType,_rName, _rObject );
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::elementRemoved(ElementType _eType,const ::rtl::OUString& _rName )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->elementRemoved(_eType,_rName );
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::elementReplaced(ElementType _eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName )
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->elementReplaced( _eType, _rOldName, _rNewName );
+}
+// -----------------------------------------------------------------------------
+PreviewMode OApplicationDetailView::getPreviewMode()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->getPreviewMode();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isPreviewEnabled()
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isPreviewEnabled();
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::switchPreview(PreviewMode _eMode)
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->switchPreview(_eMode);
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::showPreview(const Reference< XContent >& _xContent)
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->showPreview(_xContent);
+}
+// -----------------------------------------------------------------------------
+void OApplicationDetailView::showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable)
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ m_pControlHelper->showPreview(_sDataSourceName,_sName,_bTable);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationDetailView::isSortUp() const
+{
+ DBG_CHKTHIS(OApplicationDetailView,NULL);
+ return m_pControlHelper->isSortUp();
+}
+// -----------------------------------------------------------------------------
+Window* OApplicationDetailView::getTreeWindow() const
+{
+ return m_pControlHelper->getCurrentView();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppDetailView.hxx b/dbaccess/source/ui/app/AppDetailView.hxx
new file mode 100644
index 000000000000..df890bbafb4b
--- /dev/null
+++ b/dbaccess/source/ui/app/AppDetailView.hxx
@@ -0,0 +1,380 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPDETAILVIEW_HXX
+#define DBAUI_APPDETAILVIEW_HXX
+
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <vcl/split.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/mnemonic.hxx>
+#include "IClipBoardTest.hxx"
+#include "AppTitleWindow.hxx"
+#include "AppElementType.hxx"
+#include <svtools/svtreebx.hxx>
+#include "VertSplitView.hxx"
+
+#include <vector>
+
+class SvLBoxEntry;
+
+namespace dbaui
+{
+ class OAppBorderWindow;
+ class OApplicationDetailView;
+ class OAppDetailPageHelper;
+ class OTasksWindow;
+
+ class OCreationList : public SvTreeListBox
+ {
+ OTasksWindow& m_rTaskWindow;
+
+ // members related to drawing the currently hovered/selected entry
+ SvLBoxEntry* m_pMouseDownEntry;
+ SvLBoxEntry* m_pLastActiveEntry;
+ Color m_aOriginalBackgroundColor;
+ Font m_aOriginalFont;
+
+ public:
+ OCreationList( OTasksWindow& _rParent );
+ // window overloads
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ inline void resetLastActive() { m_pLastActiveEntry = NULL;}
+
+ void updateHelpText();
+
+ protected:
+ virtual void PreparePaint( SvLBoxEntry* _pEntry );
+ virtual Rectangle GetFocusRect( SvLBoxEntry* _pEntry, long _nLine );
+ virtual void ModelHasCleared();
+
+ // IMnemonicEntryList
+ virtual void SelectSearchEntry( const void* _pEntry );
+ virtual void ExecuteSearchEntry( const void* _pEntry ) const;
+
+ private:
+ void onSelected( SvLBoxEntry* _pEntry ) const;
+ /** sets a new current entry, and invalidates the old and the new one, if necessary
+ @return <TRUE/> if and only if the "current entry" changed
+ */
+ bool setCurrentEntryInvalidate( SvLBoxEntry* _pEntry );
+ };
+
+ struct TaskEntry
+ {
+ ::rtl::OUString sUNOCommand;
+ sal_uInt16 nHelpID;
+ String sTitle;
+ bool bHideWhenDisabled;
+ // TODO: we should be consistent in the task pane and the menus/toolbars:
+ // If an entry is disabled in the latter, it should also be disabled in the former.
+ // If an entry is *hidden* in the former, it should also be hidden in the latter.
+
+ TaskEntry( const sal_Char* _pAsciiUNOCommand, sal_uInt16 _nHelpID, sal_uInt16 _nTitleResourceID, bool _bHideWhenDisabled = false );
+ };
+ typedef ::std::vector< TaskEntry > TaskEntryList;
+
+ struct TaskPaneData
+ {
+ /// the tasks available in the pane
+ TaskEntryList aTasks;
+ /// the resource ID for the title of the pane
+ sal_uInt16 nTitleId;
+ };
+
+ class OTasksWindow : public Window
+ {
+ OCreationList m_aCreation;
+ FixedText m_aDescription;
+ FixedText m_aHelpText;
+ FixedLine m_aFL;
+ OApplicationDetailView* m_pDetailView;
+
+ DECL_LINK( OnEntrySelectHdl, SvTreeListBox* );
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OTasksWindow(Window* _pParent,OApplicationDetailView* _pDetailView);
+ virtual ~OTasksWindow();
+
+ // window overloads
+ virtual void Resize();
+
+ OApplicationDetailView* getDetailView() const { return m_pDetailView; }
+
+ /// fills the Creation listbox with the necessary strings and images
+ void fillTaskEntryList( const TaskEntryList& _rList );
+
+ inline bool HandleKeyInput( const KeyEvent& _rKEvt )
+ {
+ return m_aCreation.HandleKeyInput( _rKEvt );
+ }
+
+ void Clear();
+ void setHelpText(sal_uInt16 _nId);
+ };
+ //==================================================================
+ class OApplicationDetailView : public OSplitterView
+ , public IClipboardTest
+ {
+ Splitter m_aHorzSplitter;
+ OTitleWindow m_aTasks;
+ OTitleWindow m_aContainer;
+ OAppBorderWindow& m_rBorderWin; // my parent
+ OAppDetailPageHelper* m_pControlHelper;
+ ::std::vector< TaskPaneData > m_aTaskPaneData;
+ MnemonicGenerator m_aExternalMnemonics;
+
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+
+ public:
+ OApplicationDetailView(OAppBorderWindow& _rParent,PreviewMode _ePreviewMode);
+ virtual ~OApplicationDetailView();
+ // window overloads
+ virtual void GetFocus();
+
+ /** creates the tables page
+ @param _xConnection
+ The connection to get the table names
+ */
+ void createTablesPage(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ /** creates the page for the specific type.
+ @param _eType
+ The type which should be created. E_TABLE isn't allowed.
+ @param _xContainer
+ The container of the elements to be inserted.
+ */
+ void createPage(ElementType _eType,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xContainer);
+
+ void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
+
+ /** called to give the window the chance to intercept key events, while it has not
+ the focus
+
+ @return <TRUE/> if and only if the event has been handled, and should not
+ not be further processed
+ */
+ bool interceptKeyInput( const KeyEvent& _rEvent );
+
+ inline OAppBorderWindow& getBorderWin() const { return m_rBorderWin; }
+ inline OTasksWindow& getTasksWindow() const { return *static_cast< OTasksWindow* >( m_aTasks.getChildWindow() ); }
+
+ sal_Bool isCutAllowed() ;
+ sal_Bool isCopyAllowed() ;
+ sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+ void copy();
+ void cut();
+ void paste();
+
+ /** return the qualified name.
+ @param _pEntry
+ The entry of a table, or query, form, report to get the qualified name.
+ If the entry is <NULL/>, the first selected is chosen.
+ @return
+ the qualified name
+ */
+ ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
+
+ /** returns if an entry is a leaf
+ @param _pEntry
+ The entry to check
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ sal_Bool isLeaf(SvLBoxEntry* _pEntry) const;
+
+ /** returns if one of the selected entries is a leaf
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ sal_Bool isALeafSelected() const;
+
+ /** select all entries in the detail page
+ */
+ void selectAll();
+
+ /// returns <TRUE/> if it sorts ascending
+ sal_Bool isSortUp() const;
+
+ /// sort the entries in the detail page down
+ void sortDown();
+
+ /// sort the entries in the detail page up
+ void sortUp();
+
+ /// returns <TRUE/> when a detail page was filled
+ sal_Bool isFilled() const;
+
+ /// return the element of currently select entry
+ ElementType getElementType() const;
+
+ /** clears the detail pages.
+ @param _bTaskAlso
+ If <TRUE/> the task window will also be cleared.
+ */
+ void clearPages(sal_Bool _bTaskAlso = sal_True);
+
+ /// returns the count of entries
+ sal_Int32 getElementCount();
+
+ /// returns the count of selected entries
+ sal_Int32 getSelectionCount();
+
+ /** returns the element names which are selected
+ @param _rNames
+ The list will be filled.
+ */
+ void getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames ) const;
+
+ /** describes the current selection for the given control
+ */
+ void describeCurrentSelectionForControl(
+ const Control& _rControl,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** describes the current selection for the given ElementType
+ */
+ void describeCurrentSelectionForType(
+ const ElementType _eType,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** select all names on the currently selected container. Non existence names where ignored.
+ *
+ * \param _aNames the element names
+ */
+ void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
+
+ /** adds a new object to the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the object to be inserted
+ @param _rObject
+ The object to add.
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ */
+ SvLBoxEntry* elementAdded(ElementType eType
+ ,const ::rtl::OUString& _rName
+ ,const ::com::sun::star::uno::Any& _rObject );
+
+ /** replaces a objects name with a new one
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rOldName
+ The old name of the object to be replaced
+ @param _rNewName
+ The new name of the object to be replaced
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ @param _xObject
+ The object which was replaced
+ */
+ void elementReplaced(ElementType eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName );
+
+ /** removes an element from the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the element to be removed.
+ @param _rxConn
+ If we remove a table, the connection must be set.
+ */
+ void elementRemoved(ElementType _eType
+ ,const ::rtl::OUString& _rName );
+
+ /// returns the preview mode
+ PreviewMode getPreviewMode();
+
+ /// <TRUE/> if the preview is enabled
+ sal_Bool isPreviewEnabled();
+
+
+ /** switches to the given preview mode
+ @param _eMode
+ the mode to set for the preview
+ */
+ void switchPreview(PreviewMode _eMode);
+
+ /** shows the Preview of the content when it is enabled.
+ @param _xContent
+ The content which must support the "preview" command.
+ */
+ void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
+
+ /** shows the Preview of a table or query
+ @param _sDataSourceName
+ the name of the data source
+ @param _sName
+ the name of table or query
+ @param _bTable
+ <TRUE/> if it is a table, otherwise <FALSE/>
+ @return void
+ */
+ void showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable);
+
+ SvLBoxEntry* getEntry( const Point& _aPoint ) const;
+
+ Window* getTreeWindow() const;
+ private:
+ void impl_createPage(
+ ElementType _eType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxNonTableElements
+ );
+
+ const TaskPaneData& impl_getTaskPaneData( ElementType _eType );
+ void impl_fillTaskPaneData( ElementType _eType, TaskPaneData& _rData ) const;
+ };
+}
+#endif // DBAUI_APPDETAILVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppIconControl.cxx b/dbaccess/source/ui/app/AppIconControl.cxx
new file mode 100644
index 000000000000..c6c3f2e480a2
--- /dev/null
+++ b/dbaccess/source/ui/app/AppIconControl.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppIconControl.hxx"
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "moduledbu.hxx"
+#include "dbu_app.hrc"
+#include <vcl/image.hxx>
+#include "callbacks.hxx"
+#include "AppElementType.hxx"
+#include <memory>
+
+using namespace ::dbaui;
+//==================================================================
+// class OApplicationIconControl
+DBG_NAME(OApplicationIconControl)
+//==================================================================
+OApplicationIconControl::OApplicationIconControl(Window* _pParent)
+ : SvtIconChoiceCtrl(_pParent,WB_ICON | WB_NOCOLUMNHEADER | WB_HIGHLIGHTFRAME | /*!WB_NOSELECTION |*/
+ WB_TABSTOP | WB_CLIPCHILDREN | WB_NOVSCROLL | WB_SMART_ARRANGE | WB_NOHSCROLL | WB_CENTER)
+ ,DropTargetHelper(this)
+ ,m_pActionListener(NULL)
+{
+ DBG_CTOR(OApplicationIconControl,NULL);
+
+ struct CategoryDescriptor
+ {
+ sal_uInt16 nLabelResId;
+ ElementType eType;
+ sal_uInt16 nImageResId;
+ } aCategories[] = {
+ { RID_STR_TABLES_CONTAINER, E_TABLE, IMG_TABLEFOLDER_TREE_L },
+ { RID_STR_QUERIES_CONTAINER, E_QUERY, IMG_QUERYFOLDER_TREE_L },
+ { RID_STR_FORMS_CONTAINER, E_FORM, IMG_FORMFOLDER_TREE_L },
+ { RID_STR_REPORTS_CONTAINER, E_REPORT, IMG_REPORTFOLDER_TREE_L }
+ };
+ for ( size_t i=0; i < SAL_N_ELEMENTS(aCategories); ++i)
+ {
+ SvxIconChoiceCtrlEntry* pEntry = InsertEntry(
+ String( ModuleRes( aCategories[i].nLabelResId ) ) ,
+ Image( ModuleRes( aCategories[i].nImageResId ) ) );
+ if ( pEntry )
+ pEntry->SetUserData( new ElementType( aCategories[i].eType ) );
+ }
+
+ SetChoiceWithCursor( sal_True );
+ SetSelectionMode(SINGLE_SELECTION);
+}
+// -----------------------------------------------------------------------------
+OApplicationIconControl::~OApplicationIconControl()
+{
+ sal_uLong nCount = GetEntryCount();
+ for ( sal_uLong i = 0; i < nCount; ++i )
+ {
+ SvxIconChoiceCtrlEntry* pEntry = GetEntry( i );
+ if ( pEntry )
+ {
+ ::std::auto_ptr<ElementType> aType(static_cast<ElementType*>(pEntry->GetUserData()));
+ pEntry->SetUserData(NULL);
+ }
+ }
+
+ DBG_DTOR(OApplicationIconControl,NULL);
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OApplicationIconControl::AcceptDrop( const AcceptDropEvent& _rEvt )
+{
+ sal_Int8 nDropOption = DND_ACTION_NONE;
+ if ( m_pActionListener )
+ {
+
+ SvxIconChoiceCtrlEntry* pEntry = GetEntry(_rEvt.maPosPixel);
+ if ( pEntry )
+ {
+ SetCursor(pEntry);
+ nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
+ m_aMousePos = _rEvt.maPosPixel;
+ }
+ }
+
+ return nDropOption;
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OApplicationIconControl::ExecuteDrop( const ExecuteDropEvent& _rEvt )
+{
+ if ( m_pActionListener )
+ return m_pActionListener->executeDrop( _rEvt );
+
+ return DND_ACTION_NONE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppIconControl.hxx b/dbaccess/source/ui/app/AppIconControl.hxx
new file mode 100644
index 000000000000..3bd27a99a56b
--- /dev/null
+++ b/dbaccess/source/ui/app/AppIconControl.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPICONCONTROL_HXX
+#define DBAUI_APPICONCONTROL_HXX
+
+#include <svtools/ivctrl.hxx>
+#include <svtools/transfer.hxx>
+
+
+namespace dbaui
+{
+ class IControlActionListener;
+ //==================================================================
+ class OApplicationIconControl :public SvtIconChoiceCtrl
+ ,public DropTargetHelper
+ {
+ Point m_aMousePos;
+ IControlActionListener* m_pActionListener;
+
+ public:
+ OApplicationIconControl(Window* _pParent);
+ virtual ~OApplicationIconControl();
+
+ void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; }
+ IControlActionListener* getControlActionListener( ) const { return m_pActionListener; }
+
+ protected:
+ // DropTargetHelper overridables
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& _rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& _rEvt );
+ };
+}
+#endif // DBAUI_APPICONCONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppSwapWindow.cxx b/dbaccess/source/ui/app/AppSwapWindow.cxx
new file mode 100644
index 000000000000..36475115d972
--- /dev/null
+++ b/dbaccess/source/ui/app/AppSwapWindow.cxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppSwapWindow.hxx"
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "dbu_app.hrc"
+#include "AppView.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/syswin.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/mnemonic.hxx>
+#include "IApplicationController.hxx"
+
+#include <memory>
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+//==================================================================
+// class OApplicationSwapWindow
+DBG_NAME(OApplicationSwapWindow)
+//==================================================================
+OApplicationSwapWindow::OApplicationSwapWindow( Window* _pParent, OAppBorderWindow& _rBorderWindow )
+ :Window(_pParent,WB_DIALOGCONTROL )
+ ,m_aIconControl(this)
+ ,m_eLastType(E_NONE)
+ ,m_rBorderWin( _rBorderWindow )
+{
+ DBG_CTOR(OApplicationSwapWindow,NULL);
+
+ ImplInitSettings( sal_True, sal_True, sal_True );
+
+ m_aIconControl.SetClickHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl));
+ m_aIconControl.setControlActionListener( &m_rBorderWin.getView()->getAppController() );
+ m_aIconControl.SetHelpId(HID_APP_SWAP_ICONCONTROL);
+ m_aIconControl.Show();
+}
+// -----------------------------------------------------------------------------
+OApplicationSwapWindow::~OApplicationSwapWindow()
+{
+
+ DBG_DTOR(OApplicationSwapWindow,NULL);
+}
+// -----------------------------------------------------------------------------
+void OApplicationSwapWindow::Resize()
+{
+ Size aFLSize = LogicToPixel( Size( 8, 0 ), MAP_APPFONT );
+ long nX = 0;
+ if ( m_aIconControl.GetEntryCount() != 0 )
+ nX = m_aIconControl.GetBoundingBox( m_aIconControl.GetEntry(0) ).GetWidth() + aFLSize.Width();
+
+ Size aOutputSize = GetOutputSize();
+
+ m_aIconControl.SetPosSizePixel( Point(static_cast<long>((aOutputSize.Width() - nX)*0.5), 0) ,Size(nX,aOutputSize.Height()));
+ m_aIconControl.ArrangeIcons();
+}
+// -----------------------------------------------------------------------------
+void OApplicationSwapWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+}
+// -----------------------------------------------------------------------
+void OApplicationSwapWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationSwapWindow::clearSelection()
+{
+ m_aIconControl.SetNoSelection();
+ sal_uLong nPos = 0;
+ SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos);
+ if ( pEntry )
+ m_aIconControl.InvalidateEntry(pEntry);
+ m_aIconControl.GetClickHdl().Call(&m_aIconControl);
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationSwapWindow::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics )
+{
+ m_aIconControl.CreateAutoMnemonics( _rMnemonics );
+}
+
+// -----------------------------------------------------------------------------
+bool OApplicationSwapWindow::interceptKeyInput( const KeyEvent& _rEvent )
+{
+ const KeyCode& rKeyCode = _rEvent.GetKeyCode();
+ if ( rKeyCode.GetModifier() == KEY_MOD2 )
+ return m_aIconControl.DoKeyInput( _rEvent );
+
+ // not handled
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+ElementType OApplicationSwapWindow::getElementType() const
+{
+ sal_uLong nPos = 0;
+ SvxIconChoiceCtrlEntry* pEntry = m_aIconControl.GetSelectedEntry(nPos);
+ return ( pEntry ) ? *static_cast<ElementType*>(pEntry->GetUserData()) : E_NONE;
+}
+
+// -----------------------------------------------------------------------------
+bool OApplicationSwapWindow::onContainerSelected( ElementType _eType )
+{
+ if ( m_eLastType == _eType )
+ return true;
+
+ if ( m_rBorderWin.getView()->getAppController().onContainerSelect( _eType ) )
+ {
+ if ( _eType != E_NONE )
+ m_eLastType = _eType;
+ return true;
+ }
+
+ PostUserEvent( LINK( this, OApplicationSwapWindow, ChangeToLastSelected ) );
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, SvtIconChoiceCtrl*, _pControl)
+{
+ sal_uLong nPos = 0;
+ SvxIconChoiceCtrlEntry* pEntry = _pControl->GetSelectedEntry( nPos );
+ ElementType eType = E_NONE;
+ if ( pEntry )
+ {
+ eType = *static_cast<ElementType*>(pEntry->GetUserData());
+ onContainerSelected( eType ); // i87582
+ }
+
+ return 1L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OApplicationSwapWindow, ChangeToLastSelected, void*, EMPTYARG)
+{
+ selectContainer(m_eLastType);
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OApplicationSwapWindow::selectContainer(ElementType _eType)
+{
+ sal_uLong nCount = m_aIconControl.GetEntryCount();
+ SvxIconChoiceCtrlEntry* pEntry = NULL;
+ for (sal_uLong i=0; i < nCount; ++i)
+ {
+ pEntry = m_aIconControl.GetEntry(i);
+ if ( pEntry && *static_cast<ElementType*>(pEntry->GetUserData()) == _eType )
+ break;
+ pEntry = NULL;
+ }
+
+ if ( pEntry )
+ m_aIconControl.SetCursor(pEntry); // this call also initiates a onContainerSelected call
+ else
+ onContainerSelected( _eType );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppSwapWindow.hxx b/dbaccess/source/ui/app/AppSwapWindow.hxx
new file mode 100644
index 000000000000..89d535806bd9
--- /dev/null
+++ b/dbaccess/source/ui/app/AppSwapWindow.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPSWAPWINDOW_HXX
+#define DBAUI_APPSWAPWINDOW_HXX
+
+#include "IClipBoardTest.hxx"
+#include <vcl/lstbox.hxx>
+#include "AppIconControl.hxx"
+#include "AppElementType.hxx"
+
+namespace dbaui
+{
+ class OAppBorderWindow;
+ //==================================================================
+ class OApplicationSwapWindow : public Window,
+ public IClipboardTest
+ {
+ OApplicationIconControl m_aIconControl;
+ ElementType m_eLastType;
+ OAppBorderWindow& m_rBorderWin;
+
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+
+ DECL_LINK( OnContainerSelectHdl, SvtIconChoiceCtrl* );
+ DECL_LINK( ChangeToLastSelected, void* );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OApplicationSwapWindow( Window* _pParent, OAppBorderWindow& _rBorderWindow );
+ virtual ~OApplicationSwapWindow();
+ // window overloads
+ virtual void Resize();
+
+
+ inline sal_Bool isCutAllowed() { return sal_False; }
+ inline sal_Bool isCopyAllowed() { return sal_False; }
+ inline sal_Bool isPasteAllowed() { return sal_False; }
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+ inline void copy() { }
+ inline void cut() { }
+ inline void paste() { }
+
+ inline sal_uLong GetEntryCount() const { return m_aIconControl.GetEntryCount(); }
+ inline SvxIconChoiceCtrlEntry* GetEntry( sal_uLong nPos ) const { return m_aIconControl.GetEntry(nPos); }
+ inline Rectangle GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const { return m_aIconControl.GetBoundingBox(pEntry); }
+
+ /** automatically creates mnemonics for the icon/texts in our left hand side panel
+ */
+ void createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
+
+ /** called to give the window the chance to intercept key events, while it has not
+ the focus
+
+ @return <TRUE/> if and only if the event has been handled, and should not
+ not be further processed
+ */
+ bool interceptKeyInput( const KeyEvent& _rEvent );
+
+ /// return the element of currently select entry
+ ElementType getElementType() const;
+
+
+ /** clears the selection in the icon choice control and calls the handler
+ */
+ void clearSelection();
+
+ /** changes the container which should be displayed. The select handler will also be called.
+ @param _eType
+ Which container to show.
+ */
+ void selectContainer(ElementType _eType);
+
+ private:
+ bool onContainerSelected( ElementType _eType );
+ };
+// .............................................................
+} // namespace dbaui
+// .............................................................
+#endif // DBAUI_APPSWAPWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppTitleWindow.cxx b/dbaccess/source/ui/app/AppTitleWindow.cxx
new file mode 100644
index 000000000000..e2473432e8cc
--- /dev/null
+++ b/dbaccess/source/ui/app/AppTitleWindow.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppTitleWindow.hxx"
+#include "moduledbu.hxx"
+#include "memory"
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+
+namespace dbaui
+{
+
+DBG_NAME(OTitleWindow)
+OTitleWindow::OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift)
+: Window(_pParent,_nBits | WB_DIALOGCONTROL)
+, m_aSpace1(this)
+, m_aSpace2(this)
+, m_aTitle(this)
+, m_pChild(NULL)
+, m_bShift(_bShift)
+{
+ DBG_CTOR(OTitleWindow,NULL);
+
+ setTitle(_nTitleId);
+ SetBorderStyle(WINDOW_BORDER_MONO);
+ ImplInitSettings( sal_True, sal_True, sal_True );
+
+ Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle };
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ pWindows[i]->Show();
+}
+// -----------------------------------------------------------------------------
+OTitleWindow::~OTitleWindow()
+{
+ if ( m_pChild )
+ {
+ m_pChild->Hide();
+ ::std::auto_ptr<Window> aTemp(m_pChild);
+ m_pChild = NULL;
+ }
+
+ DBG_DTOR(OTitleWindow,NULL);
+}
+// -----------------------------------------------------------------------------
+void OTitleWindow::setChildWindow(Window* _pChild)
+{
+ m_pChild = _pChild;
+}
+#define SPACE_BORDER 1
+// -----------------------------------------------------------------------------
+void OTitleWindow::Resize()
+{
+ // parent window dimension
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+
+ Size aTextSize = LogicToPixel( Size( 6, 3 ), MAP_APPFONT );
+ sal_Int32 nXOffset = aTextSize.Width();
+ sal_Int32 nYOffset = aTextSize.Height();
+ sal_Int32 nHeight = GetTextHeight() + 2*nYOffset;
+
+ m_aSpace1.SetPosSizePixel( Point(SPACE_BORDER, SPACE_BORDER ),
+ Size(nXOffset , nHeight - SPACE_BORDER) );
+ m_aSpace2.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, SPACE_BORDER ),
+ Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nYOffset) );
+ m_aTitle.SetPosSizePixel( Point(nXOffset + SPACE_BORDER, nYOffset + SPACE_BORDER),
+ Size(nOutputWidth - nXOffset - 2*SPACE_BORDER, nHeight - nYOffset - SPACE_BORDER) );
+ if ( m_pChild )
+ {
+ m_pChild->SetPosSizePixel( Point(m_bShift ? (nXOffset+SPACE_BORDER) : sal_Int32(SPACE_BORDER), nHeight + nXOffset + SPACE_BORDER),
+ Size(nOutputWidth - ( m_bShift ? (2*nXOffset - 2*SPACE_BORDER) : sal_Int32(SPACE_BORDER) ), nOutputHeight - nHeight - 2*nXOffset - 2*SPACE_BORDER) );
+ }
+}
+// -----------------------------------------------------------------------------
+void OTitleWindow::setTitle(sal_uInt16 _nTitleId)
+{
+ if ( _nTitleId != 0 )
+ {
+ m_aTitle.SetText(ModuleRes(_nTitleId));
+ }
+}
+// -----------------------------------------------------------------------------
+void OTitleWindow::GetFocus()
+{
+ Window::GetFocus();
+ if ( m_pChild )
+ m_pChild->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+long OTitleWindow::GetWidthPixel() const
+{
+ Size aTextSize = LogicToPixel( Size( 12, 0 ), MAP_APPFONT );
+ sal_Int32 nWidth = GetTextWidth(m_aTitle.GetText()) + 2*aTextSize.Width();
+
+ return nWidth;
+}
+// -----------------------------------------------------------------------
+void OTitleWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+//-----------------------------------------------------------------------------
+void OTitleWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ AllSettings aAllSettings = GetSettings();
+ StyleSettings aStyle = aAllSettings.GetStyleSettings();
+ aStyle.SetMonoColor(aStyle.GetActiveBorderColor());//GetMenuBorderColor());
+ aAllSettings.SetStyleSettings(aStyle);
+ SetSettings(aAllSettings);
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( bFont )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( bForeground || bFont )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( bBackground )
+ SetBackground( rStyleSettings.GetFieldColor() );
+
+
+ Window* pWindows [] = { &m_aSpace1, &m_aSpace2, &m_aTitle};
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ {
+ Font aFont = pWindows[i]->GetFont();
+ aFont.SetWeight(WEIGHT_BOLD);
+ pWindows[i]->SetFont(aFont);
+ pWindows[i]->SetTextColor( aStyle.GetLightColor() );
+ pWindows[i]->SetBackground( Wallpaper( aStyle.GetShadowColor() ) );
+ }
+}
+// .............................................................
+} // namespace dbaui
+// .............................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppTitleWindow.hxx b/dbaccess/source/ui/app/AppTitleWindow.hxx
new file mode 100644
index 000000000000..ab1719977f23
--- /dev/null
+++ b/dbaccess/source/ui/app/AppTitleWindow.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TITLE_WINDOW_HXX
+#define DBAUI_TITLE_WINDOW_HXX
+
+#include <vcl/fixed.hxx>
+
+namespace dbaui
+{
+ class OTitleWindow : public Window
+ {
+ FixedText m_aSpace1;
+ FixedText m_aSpace2;
+ FixedText m_aTitle;
+ Window* m_pChild;
+ sal_Bool m_bShift;
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OTitleWindow(Window* _pParent,sal_uInt16 _nTitleId,WinBits _nBits,sal_Bool _bShift = sal_True);
+ virtual ~OTitleWindow();
+
+ // window overloads
+ virtual void Resize();
+ virtual void GetFocus();
+
+ /** sets the child window which should be displayed below the title. It will be destroyed at the end.
+ @param _pChild
+ The child window.
+ */
+ void setChildWindow(Window* _pChild);
+
+ /** gets the child window.
+
+ @return
+ The child winodw.
+ */
+ inline Window* getChildWindow() const { return m_pChild; }
+
+ /** sets the title text out of the resource
+ @param _nTitleId
+ The resource id of the title text.
+ */
+ void setTitle(sal_uInt16 _nTitleId);
+
+
+ /** Gets the min Width in Pixel which is needed to display the whole
+
+ @return
+ the min width
+ */
+ long GetWidthPixel() const;
+ };
+// .............................................................
+} // namespace dbaui
+// .............................................................
+#endif // DBAUI_TITLE_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppView.cxx b/dbaccess/source/ui/app/AppView.cxx
new file mode 100644
index 000000000000..4974a3ef6333
--- /dev/null
+++ b/dbaccess/source/ui/app/AppView.cxx
@@ -0,0 +1,601 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AppView.hxx"
+#include "dbu_app.hrc"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "dbaccess_helpid.hrc"
+#include <vcl/toolbox.hxx>
+#include <unotools/configmgr.hxx>
+#include <vcl/waitobj.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <unotools/syslocale.hxx>
+#include "UITools.hxx"
+#include "AppDetailView.hxx"
+#include "tabletree.hxx"
+#include "AppSwapWindow.hxx"
+#include <vcl/svapp.hxx>
+#include "AppSwapWindow.hxx"
+#include "AppTitleWindow.hxx"
+#include "dsntypes.hxx"
+#include "dbustrings.hrc"
+#include "IController.hxx"
+#include "browserids.hxx"
+#include <unotools/pathoptions.hxx>
+#include "IApplicationController.hxx"
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::container;
+using ::com::sun::star::sdb::application::NamedDatabaseObject;
+
+//==================================================================
+// class OAppBorderWindow
+DBG_NAME(OAppBorderWindow)
+//==================================================================
+OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
+ ,m_pPanel(NULL)
+ ,m_pDetailView(NULL)
+ ,m_pView(_pParent)
+{
+ DBG_CTOR(OAppBorderWindow,NULL);
+
+ SetBorderStyle(WINDOW_BORDER_MONO);
+
+ m_pPanel = new OTitleWindow(this,STR_DATABASE,WB_BORDER | WB_DIALOGCONTROL ,sal_False);
+ m_pPanel->SetBorderStyle(WINDOW_BORDER_MONO);
+ OApplicationSwapWindow* pSwap = new OApplicationSwapWindow( m_pPanel, *this );
+ pSwap->Show();
+ pSwap->SetUniqueId(UID_APP_SWAP_VIEW);
+
+ m_pPanel->setChildWindow(pSwap);
+ m_pPanel->SetUniqueId(UID_APP_DATABASE_VIEW);
+ m_pPanel->Show();
+
+ m_pDetailView = new OApplicationDetailView(*this,_ePreviewMode);
+ m_pDetailView->Show();
+
+ ImplInitSettings();
+}
+// -----------------------------------------------------------------------------
+OAppBorderWindow::~OAppBorderWindow()
+{
+ // destroy children
+ if ( m_pPanel )
+ {
+ m_pPanel->Hide();
+ ::std::auto_ptr<Window> aTemp(m_pPanel);
+ m_pPanel = NULL;
+ }
+ if ( m_pDetailView )
+ {
+ m_pDetailView->Hide();
+ ::std::auto_ptr<Window> aTemp(m_pDetailView);
+ m_pDetailView = NULL;
+ }
+
+ DBG_DTOR(OAppBorderWindow,NULL);
+}
+// -----------------------------------------------------------------------------
+void OAppBorderWindow::GetFocus()
+{
+ if ( m_pPanel )
+ m_pPanel->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+void OAppBorderWindow::Resize()
+{
+ // parent window dimension
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+ long nX = 0;
+
+ Size aFLSize = LogicToPixel( Size( 3, 8 ), MAP_APPFONT );
+ if ( m_pPanel )
+ {
+ OApplicationSwapWindow* pSwap = getPanel();
+ if ( pSwap )
+ {
+ if ( pSwap->GetEntryCount() != 0 )
+ nX = pSwap->GetBoundingBox( pSwap->GetEntry(0) ).GetWidth() + aFLSize.Height();
+ }
+ nX = ::std::max(m_pPanel->GetWidthPixel() ,nX);
+ m_pPanel->SetPosSizePixel(Point(0,0),Size(nX,nOutputHeight));
+ }
+
+ if ( m_pDetailView )
+ m_pDetailView->SetPosSizePixel(Point(nX + aFLSize.Width(),0),Size(nOutputWidth - nX - aFLSize.Width(),nOutputHeight));
+}
+// -----------------------------------------------------------------------------
+void OAppBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ ImplInitSettings();
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OAppBorderWindow::ImplInitSettings()
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( true )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( true )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( true )
+ SetBackground( rStyleSettings.GetDialogColor() );
+}
+// -----------------------------------------------------------------------------
+OApplicationView* OAppBorderWindow::getView() const
+{
+ return m_pView;
+}
+
+// -----------------------------------------------------------------------------
+OApplicationSwapWindow* OAppBorderWindow::getPanel() const
+{
+ return static_cast< OApplicationSwapWindow* >( m_pPanel->getChildWindow() );
+}
+
+// -----------------------------------------------------------------------------
+OApplicationDetailView* OAppBorderWindow::getDetailView() const
+{
+ return m_pDetailView;
+}
+
+//==================================================================
+// class OApplicationView
+//==================================================================
+DBG_NAME(OApplicationView);
+//------------------------------------------------------------------------------
+OApplicationView::OApplicationView( Window* pParent
+ ,const Reference< XMultiServiceFactory >& _rxOrb
+ ,IApplicationController& _rAppController
+ ,PreviewMode _ePreviewMode
+ ) :
+ ODataView( pParent, _rAppController, _rxOrb, WB_DIALOGCONTROL )
+ ,m_rAppController( _rAppController )
+ ,m_eChildFocus(NONE)
+{
+ DBG_CTOR(OApplicationView,NULL);
+
+ try
+ {
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_pWin = new OAppBorderWindow(this,_ePreviewMode);
+ m_pWin->SetUniqueId(UID_APP_VIEW_BORDER_WIN);
+ m_pWin->Show();
+
+ ImplInitSettings();
+}
+
+//------------------------------------------------------------------------------
+OApplicationView::~OApplicationView()
+{
+ DBG_DTOR(OApplicationView,NULL);
+
+ {
+ stopComponentListening(m_xObject);
+ m_pWin->Hide();
+ ::std::auto_ptr<Window> aTemp(m_pWin);
+ m_pWin = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics )
+{
+ if ( m_pWin && m_pWin->getPanel() )
+ m_pWin->getPanel()->createIconAutoMnemonics( _rMnemonics );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
+{
+ if ( m_pWin && m_pWin->getDetailView() )
+ m_pWin->getDetailView()->setTaskExternalMnemonics( _rMnemonics );
+}
+
+// -----------------------------------------------------------------------------
+void OApplicationView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ODataView::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ ImplInitSettings();
+ Invalidate();
+ }
+}
+//------------------------------------------------------------------------------
+void OApplicationView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ if ( m_pWin && !_rPlayground.IsEmpty() )
+ {
+ Size aFLSize = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
+ _rPlayground.Move( aFLSize.A(),aFLSize.B() );
+ Size aOldSize = _rPlayground.GetSize();
+ _rPlayground.SetSize( Size(aOldSize.A() - 2*aFLSize.A(), aOldSize.B() - 2*aFLSize.B()) );
+
+ m_pWin->SetPosSizePixel(_rPlayground.TopLeft() , _rPlayground.GetSize() );
+ }
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+//------------------------------------------------------------------------------
+long OApplicationView::PreNotify( NotifyEvent& rNEvt )
+{
+ switch(rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if( m_pWin && getPanel() && getPanel()->HasChildPathFocus() )
+ m_eChildFocus = PANELSWAP;
+ else if ( m_pWin && getDetailView() && getDetailView()->HasChildPathFocus() )
+ m_eChildFocus = DETAIL;
+ else
+ m_eChildFocus = NONE;
+ break;
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ // give the pane the chance to intercept mnemonic accelerators
+ // #i34790#
+ if ( getPanel() && getPanel()->interceptKeyInput( *pKeyEvent ) )
+ return 1L;
+ // and ditto the detail view
+ // #i72799#
+ if ( getDetailView() && getDetailView()->interceptKeyInput( *pKeyEvent ) )
+ return 1L;
+ }
+ break;
+ }
+
+ return ODataView::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+IClipboardTest* OApplicationView::getActiveChild() const
+{
+ IClipboardTest* pTest = NULL;
+ if ( DETAIL == m_eChildFocus )
+ pTest = getDetailView();
+ return pTest;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isCopyAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isCutAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCutAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isPasteAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isPasteAllowed();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::copy()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->copy();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::cut()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->cut();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::paste()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->paste();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OApplicationView::getQualifiedName( SvLBoxEntry* _pEntry ) const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getQualifiedName( _pEntry );
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isLeaf(SvLBoxEntry* _pEntry) const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->isLeaf(_pEntry);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isALeafSelected() const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->isALeafSelected();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::selectAll()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->selectAll();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isSortUp() const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->isSortUp();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::sortDown()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->sortDown();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::sortUp()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->sortUp();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isFilled() const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->isFilled();
+}
+// -----------------------------------------------------------------------------
+ElementType OApplicationView::getElementType() const
+{
+ OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
+ return getDetailView()->HasChildPathFocus() ? getDetailView()->getElementType() : getPanel()->getElementType();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OApplicationView::getSelectionCount()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getSelectionCount();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OApplicationView::getElementCount()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getElementCount();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->getSelectionElementNames( _rNames );
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::selectElements(const Sequence< ::rtl::OUString>& _aNames)
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->selectElements( _aNames );
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OApplicationView::elementAdded(ElementType eType,const ::rtl::OUString& _rName, const Any& _rObject )
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->elementAdded(eType,_rName,_rObject);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::elementRemoved(ElementType eType,const ::rtl::OUString& _rName )
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->elementRemoved(eType,_rName);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::elementReplaced(ElementType _eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName )
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->elementReplaced(_eType, _rOldName, _rNewName );
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::clearPages(sal_Bool _bTaskAlso)
+{
+ OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
+ getPanel()->clearSelection();
+ getDetailView()->clearPages(_bTaskAlso);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::selectContainer(ElementType _eType)
+{
+ OSL_ENSURE(m_pWin && getPanel(),"Detail view is NULL! -> GPF");
+ WaitObject aWO(this);
+ getPanel()->selectContainer(_eType);
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* OApplicationView::getEntry( const Point& _aPosPixel ) const
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getEntry(_aPosPixel);
+}
+// -----------------------------------------------------------------------------
+PreviewMode OApplicationView::getPreviewMode()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->getPreviewMode();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OApplicationView::isPreviewEnabled()
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ return getDetailView()->isPreviewEnabled();
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::switchPreview(PreviewMode _eMode)
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ getDetailView()->switchPreview(_eMode);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::showPreview(const Reference< XContent >& _xContent)
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ stopComponentListening(m_xObject);
+ m_xObject = NULL;
+ getDetailView()->showPreview(_xContent);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable)
+{
+ OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
+ if ( isPreviewEnabled() )
+ {
+ stopComponentListening(m_xObject);
+ m_xObject = NULL;
+ try
+ {
+ Reference<XNameAccess> xNameAccess;
+ if ( _bTable )
+ {
+ Reference<XTablesSupplier> xSup(_xConnection,UNO_QUERY);
+ if ( xSup.is() )
+ xNameAccess.set(xSup->getTables(),UNO_QUERY);
+ }
+ else
+ {
+ Reference<XQueriesSupplier> xSup(_xConnection,UNO_QUERY);
+ if ( xSup.is() )
+ xNameAccess.set(xSup->getQueries(),UNO_QUERY);
+ }
+ if ( xNameAccess.is() && xNameAccess->hasByName(_sName) )
+ m_xObject.set(xNameAccess->getByName(_sName),UNO_QUERY);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if ( m_xObject.is() )
+ startComponentListening(m_xObject);
+ getDetailView()->showPreview(_sDataSourceName,_sName,_bTable);
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::GetFocus()
+{
+ if ( m_eChildFocus == NONE && m_pWin )
+ {
+ m_pWin->GrabFocus();
+ }
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
+{
+ if ( m_pWin && getDetailView() )
+ showPreview(NULL);
+}
+// -----------------------------------------------------------------------------
+void OApplicationView::ImplInitSettings()
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ if( true )
+ {
+ Font aFont;
+ aFont = rStyleSettings.GetFieldFont();
+ aFont.SetColor( rStyleSettings.GetWindowTextColor() );
+ SetPointFont( aFont );
+ }
+
+ if( true )
+ {
+ SetTextColor( rStyleSettings.GetFieldTextColor() );
+ SetTextFillColor();
+ }
+
+ if( true )
+ SetBackground( rStyleSettings.GetFieldColor() );
+}
+//-----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/AppView.hxx b/dbaccess/source/ui/app/AppView.hxx
new file mode 100644
index 000000000000..d4fa76c35849
--- /dev/null
+++ b/dbaccess/source/ui/app/AppView.hxx
@@ -0,0 +1,316 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPVIEW_HXX
+#define DBAUI_APPVIEW_HXX
+
+#include "dataview.hxx"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <vcl/fixed.hxx>
+#include <unotools/eventlisteneradapter.hxx>
+#include "IClipBoardTest.hxx"
+#include "AppElementType.hxx"
+
+namespace com{ namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
+
+class Control;
+class SvLBoxEntry;
+class MnemonicGenerator;
+
+namespace dbaui
+{
+ class IControlActionListener;
+ class IApplicationController;
+ class OApplicationView;
+ class OApplicationDetailView;
+ class OApplicationSwapWindow;
+ class OTitleWindow;
+ //==================================================================
+ class OAppBorderWindow : public Window
+ {
+ OTitleWindow* m_pPanel;
+ OApplicationDetailView* m_pDetailView;
+ OApplicationView* m_pView;
+
+ void ImplInitSettings();
+ protected:
+ // Window
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ public:
+ OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode);
+ virtual ~OAppBorderWindow();
+
+ // window overloads
+ virtual void GetFocus();
+ virtual void Resize();
+
+ OApplicationView* getView() const;
+ OApplicationSwapWindow* getPanel() const;
+ OApplicationDetailView* getDetailView() const;
+ };
+
+ //==================================================================
+ class OApplicationView : public ODataView
+ ,public IClipboardTest
+ ,public ::utl::OEventListenerAdapter
+ {
+ enum ChildFocusState
+ {
+ PANELSWAP,
+ DETAIL,
+ NONE
+ };
+ private:
+ ::com::sun::star::lang::Locale m_aLocale;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ m_xObject;
+ OAppBorderWindow* m_pWin;
+ IApplicationController& m_rAppController;
+ ChildFocusState m_eChildFocus;
+
+ IClipboardTest* getActiveChild() const;
+
+ void ImplInitSettings();
+ protected:
+
+
+ // return the Rectangle where I can paint myself
+ virtual void resizeDocumentView(Rectangle& rRect);
+
+ // OEventListenerAdapter
+ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
+
+ // Window
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ public:
+ OApplicationView( Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ ,IApplicationController& _rAppController
+ ,PreviewMode _ePreviewMode
+ );
+ virtual ~OApplicationView();
+
+ /// automatically creates mnemonics for the icon/texts in our left hand side panel
+ void createIconAutoMnemonics( MnemonicGenerator& _rMnemonics );
+
+ /// automatically creates mnemonics for the texts in our task pane
+ void setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+
+ inline IApplicationController& getAppController() const { return m_rAppController; }
+ inline const ::com::sun::star::lang::Locale& getLocale() const { return m_aLocale;}
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ /// get the left panel
+ inline OApplicationSwapWindow* getPanel() const { return m_pWin->getPanel(); }
+ /// get the detail page
+ inline OApplicationDetailView* getDetailView() const { return m_pWin->getDetailView(); }
+
+ /** return the qualified name.
+ @param _pEntry
+ The entry of a table, or query, form, report to get the qualified name.
+ If the entry is <NULL/>, the first selected is chosen.
+ @return
+ the qualified name
+ */
+ ::rtl::OUString getQualifiedName( SvLBoxEntry* _pEntry ) const;
+
+ /** returns if an entry is a leaf
+ @param _pEntry
+ The entry to check
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ sal_Bool isLeaf(SvLBoxEntry* _pEntry) const;
+
+ /** returns if one of the selected entries is a leaf
+ @return
+ <TRUE/> if the entry is a leaf, otherwise <FALSE/>
+ */
+ sal_Bool isALeafSelected() const;
+
+ /** select all entries in the detail page
+ */
+ void selectAll();
+
+ /// returns <TRUE/> if it sorts ascending
+ sal_Bool isSortUp() const;
+
+ /// sort the entries in the detail page down
+ void sortDown();
+
+ /// sort the entries in the detail page up
+ void sortUp();
+
+ /// returns <TRUE/> when a detail page was filled
+ sal_Bool isFilled() const;
+
+ /// return the element of currently select entry
+ ElementType getElementType() const;
+
+ /// returns the count of entries
+ sal_Int32 getElementCount();
+
+ /// returns the count of selected entries
+ sal_Int32 getSelectionCount();
+
+ /** clears the detail page and the selection on the left side.
+ @param _bTaskAlso
+ If <TRUE/> the task window will also be cleared.
+ */
+ void clearPages(sal_Bool _bTaskAlso = sal_True);
+
+ /** returns the element names which are selected
+ @param _rNames
+ The list will be filled.
+ */
+ void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const;
+
+ /** describes the current selection for the given control
+ */
+ void describeCurrentSelectionForControl(
+ const Control& _rControl,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** describes the current selection for the given ElementType
+ */
+ void describeCurrentSelectionForType(
+ const ElementType _eType,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::sdb::application::NamedDatabaseObject >& _out_rSelectedObjects
+ );
+
+ /** select all names on the currently selected container. Non existence names where ignored.
+ *
+ * \param _aNames the element names
+ */
+ void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames);
+
+ /** adds a new object to the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the object to be inserted
+ @param _rObject
+ The object to add.
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ */
+ SvLBoxEntry* elementAdded(ElementType _eType
+ ,const ::rtl::OUString& _rName
+ ,const ::com::sun::star::uno::Any& _rObject );
+
+ /** replaces a objects name with a new one
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rOldName
+ The old name of the object to be replaced
+ @param _rNewName
+ The new name of the object to be replaced
+ @param _rxConn
+ If we insert a table, the connection must be set.
+ @param _xObject
+ The object which was replaced
+ */
+ void elementReplaced(ElementType eType
+ ,const ::rtl::OUString& _rOldName
+ ,const ::rtl::OUString& _rNewName );
+
+ /** removes an element from the detail page.
+ @param _eType
+ The type where the entry shold be appended.
+ @param _rName
+ The name of the element to be removed.
+ @param _rxConn
+ If we remove a table, the connection must be set.
+ */
+ void elementRemoved(ElementType _eType
+ ,const ::rtl::OUString& _rName );
+
+
+ /** changes the container which should be displayed. The select handler will also be called.
+ @param _eType
+ Which container to show.
+ */
+ void selectContainer(ElementType _eType);
+
+ /// returns the preview mode
+ PreviewMode getPreviewMode();
+
+ /// <TRUE/> if the preview is enabled
+ sal_Bool isPreviewEnabled();
+
+ /** switches to the given preview mode
+ @param _eMode
+ the mode to set for the preview
+ */
+ void switchPreview(PreviewMode _eMode);
+
+ /** shows the Preview of the content when it is enabled.
+ @param _xContent
+ The content which must support the "preview" command.
+ */
+ void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >& _xContent);
+
+ /** shows the Preview of a table or query
+ @param _sDataSourceName
+ the name of the data source
+ @param _xConnection
+ the connection which will be shared
+ @param _sName
+ the name of table or query
+ @param _bTable
+ <TRUE/> if it is a table, otherwise <FALSE/>
+ @return void
+ */
+ void showPreview( const ::rtl::OUString& _sDataSourceName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _sName,
+ sal_Bool _bTable);
+
+ SvLBoxEntry* getEntry( const Point& _aPosPixel ) const;
+
+ DECL_LINK( SwitchHdl, Accelerator* );
+ };
+}
+#endif // DBAUI_APPVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/IApplicationController.hxx b/dbaccess/source/ui/app/IApplicationController.hxx
new file mode 100644
index 000000000000..5e7123e4d3ed
--- /dev/null
+++ b/dbaccess/source/ui/app/IApplicationController.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef DBA30D_IAPPLICATIONCONTROLLER_HXX
+#define DBA30D_IAPPLICATIONCONTROLLER_HXX
+
+#include "IController.hxx"
+#include "AppElementType.hxx"
+#include "callbacks.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+class SvTreeListBox;
+class SvLBoxEntry;
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ class SAL_NO_VTABLE IApplicationController :public IController
+ ,public IControlActionListener
+ ,public IContextMenuProvider
+ {
+ public:
+ /** called when an entry in a tree list box has been double-clicked
+ @param _rTree
+ The tree list box.
+ @return
+ <TRUE/> if the double click event has been handled by the called, and should not
+ be processed further.
+ */
+ virtual bool onEntryDoubleClick( SvTreeListBox& _rTree ) = 0;
+
+ /** called when a container (category) in the application view has been selected
+ @param _pTree
+ The tree list box.
+ @return
+ <TRUE/> if the cotainer could be changed otherwise <FALSE/>
+ */
+ virtual sal_Bool onContainerSelect(ElementType _eType) = 0;
+
+ /** called when an entry in a tree view has been selected
+ @param _pEntry
+ the selected entry
+ */
+ virtual void onSelectionChanged() = 0;
+
+ /** called when a "Cut" command is executed in a tree view
+ */
+ virtual void onCutEntry() = 0;
+
+ /** called when a "Copy" command is executed in a tree view
+ */
+ virtual void onCopyEntry() = 0;
+
+ /** called when a "Paste" command is executed in a tree view
+ */
+ virtual void onPasteEntry() = 0;
+
+ /** called when a "Delete" command is executed in a tree view
+ */
+ virtual void onDeleteEntry() = 0;
+
+ /// called when the preview mode was changed
+ virtual void previewChanged( sal_Int32 _nMode ) = 0;
+
+ /// called when an object container of any kind was found during enumerating tree view elements
+ virtual void containerFound( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer) = 0;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBA30D_IAPPLICATIONCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/app.src b/dbaccess/source/ui/app/app.src
new file mode 100644
index 000000000000..431f434fcea3
--- /dev/null
+++ b/dbaccess/source/ui/app/app.src
@@ -0,0 +1,478 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_APP_HRC_
+#include "dbu_app.hrc"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef _CNTIDS_HRC
+#include <sfx2/cntids.hrc>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+
+#define MN_PROPS 25
+
+
+String RID_STR_NEW_FORM
+{
+ Text [ en-US ] = "Create Form in Design View..." ;
+};
+
+String RID_STR_NEW_FORM_AUTO
+{
+ Text [ en-US ] = "Use Wizard to Create Form..." ;
+};
+
+String RID_STR_NEW_REPORT_AUTO
+{
+ Text [ en-US ] = "Use Wizard to Create Report..." ;
+};
+
+String RID_STR_NEW_REPORT
+{
+ Text [ en-US ] = "Create Report in Design View..." ;
+};
+
+String RID_STR_NEW_QUERY
+{
+ Text [ en-US ] = "Create Query in Design View..." ;
+};
+
+String RID_STR_NEW_QUERY_SQL
+{
+ Text [ en-US ] = "Create Query in SQL View..." ;
+};
+
+String RID_STR_NEW_QUERY_AUTO
+{
+ Text [ en-US ] = "Use Wizard to Create Query..." ;
+};
+String RID_STR_NEW_TABLE
+{
+ Text [ en-US ] = "Create Table in Design View..." ;
+};
+
+String RID_STR_NEW_TABLE_AUTO
+{
+ Text [ en-US ] = "Use Wizard to Create Table..." ;
+};
+String RID_STR_NEW_VIEW
+{
+ Text [ en-US ] = "Create View..." ;
+};
+
+String RID_STR_FORMS_CONTAINER
+{
+ Text [ en-US ] = "Forms" ;
+};
+
+String RID_STR_REPORTS_CONTAINER
+{
+ Text [ en-US ] = "Reports" ;
+};
+
+Menu RID_MENU_APP_NEW
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_APP_NEW_FORM;
+ Command = ".uno:DBNewForm";
+ Text [ en-US ] = "Form..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_APP_NEW_REPORT;
+ Command = ".uno:DBNewReport";
+ Text [ en-US ] = "Report..." ;
+ };
+ MenuItem
+ {
+ MID_DOCUMENT_CREATE_REPWIZ
+ Command = ".uno:DBNewReportAutoPilot";
+ };
+ MenuItem
+ {
+ MID_QUERY_NEW_DESIGN
+ Command = ".uno:DBNewQuery";
+ };
+ MenuItem
+ {
+ MID_QUERY_NEW_SQL
+ Command = ".uno:DBNewQuerySql";
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ MID_NEW_TABLE_DESIGN
+ Command = ".uno:DBNewTable";
+ };
+ MenuItem
+ {
+ MID_NEW_VIEW_DESIGN
+ Command = ".uno:DBNewView";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_NEW_VIEW_SQL;
+ Command = ".uno:DBNewViewSQL";
+ Text [ en-US ] = "View (Simple)..." ;
+ };
+
+ };
+};
+
+Menu RID_MENU_APP_EDIT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
+ MenuItem
+ {
+ ITEM_EDIT_PASTE
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_PASTE_SPECIAL;
+ Text[ en-US ] = "Paste Special...";
+ Command = ".uno:PasteSpecial";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DELETE;
+ Text[ en-US ] = "Delete";
+ Command = ".uno:DBDelete";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_RENAME;
+ Text[ en-US ] = "Rename";
+ Command = ".uno:DBRename";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_EDIT;
+ Text[ en-US ] = "Edit";
+ Command = ".uno:DBEdit";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_EDIT_SQL_VIEW;
+ Text [ en-US ] = "Edit in SQL View...";
+ Command = ".uno:DBEditSqlView";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_OPEN;
+ Text[ en-US ] = "Open";
+ Command = ".uno:DBOpen";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_CONVERTTOVIEW;
+ Text[ en-US ] = "Create as View";
+ Command = ".uno:DBConvertToView";
+ };
+ MenuItem
+ {
+ Identifier = SID_FORM_CREATE_REPWIZ_PRE_SEL;
+ Text [ en-US ] = "Form Wizard...";
+ Command = ".uno:DBNewFormAutoPilotWithPreSelection";
+ };
+ MenuItem
+ {
+ Identifier = SID_APP_NEW_REPORT_PRE_SEL;
+ Command = ".uno:DBNewReportWithPreSelection";
+ Text [ en-US ] = "Report..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_REPORT_CREATE_REPWIZ_PRE_SEL ;
+ Text[ en-US ] = "Report Wizard...";
+
+ Command = ".uno:DBNewReportAutoPilotWithPreSelection";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SELECTALL;
+ Text[ en-US ] = "Select All";
+ Command = ".uno:SelectAll";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_PROPS;
+ Text[ en-US ] = "~Database";
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DSPROPS;
+ Text[ en-US ] = "Properties";
+ Command = ".uno:DBDSProperties";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DSCONNECTION_TYPE;
+ Text[ en-US ] = "Connection Type";
+ Command = ".uno:DBDSConnectionType";
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DSADVANCED_SETTINGS;
+ Text[ en-US ] = "Advanced Settings";
+ Command = ".uno:DBDSAdvancedSettings";
+ };
+ };
+ };
+ };
+ };
+};
+
+String STR_QUERY_DELETE_DATASOURCE
+{
+ Text [ en-US ] = "Do you want to delete the data source '%1'?" ;
+};
+
+String STR_APP_TITLE
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base" ;
+};
+
+String RID_STR_REPORTS_HELP_TEXT_WIZARD
+{
+ Text [ en-US ] = "The wizard will guide you through the steps necessary to create a report." ;
+};
+
+String RID_STR_FORMS_HELP_TEXT
+{
+ Text [ en-US ] = "Create a form by specifying the record source, controls, and control properties." ;
+};
+
+String RID_STR_REPORT_HELP_TEXT
+{
+ Text [ de ] ="Erstellen Sie einen Bericht, indem Sie die Datensatzquelle, Steuerelemente und Steuerelementeigenschaften angeben." ;
+ Text [ en-US ] = "Create a report by specifying the record source, controls, and control properties." ;
+};
+
+String RID_STR_FORMS_HELP_TEXT_WIZARD
+{
+ Text [ en-US ] = "The wizard will guide you through the steps necessary to create a form." ;
+};
+
+String RID_STR_QUERIES_HELP_TEXT
+{
+ Text [ en-US ] = "Create a query by specifying the filters, input tables, field names, and properties for sorting or grouping." ;
+};
+
+String RID_STR_QUERIES_HELP_TEXT_SQL
+{
+ Text [ en-US ] = "Create a query entering an SQL statement directly." ;
+};
+
+String RID_STR_QUERIES_HELP_TEXT_WIZARD
+{
+ Text [ en-US ] = "The wizard will guide you through the steps necessary to create a query." ;
+};
+
+String RID_STR_TABLES_HELP_TEXT_DESIGN
+{
+ Text [ en-US ] = "Create a table by specifying the field names and properties, as well as the data types." ;
+};
+
+String RID_STR_TABLES_HELP_TEXT_WIZARD
+{
+ Text [ en-US ] = "Choose from a selection of business and personal table samples, which you customize to create a table." ;
+};
+
+String RID_STR_VIEWS_HELP_TEXT_DESIGN
+{
+ Text [ en-US ] = "Create a view by specifying the tables and field names you would like to have visible." ;
+};
+
+String RID_STR_VIEWS_HELP_TEXT_WIZARD
+{
+ Text [ en-US ] = "Opens the view wizard" ;
+};
+
+String STR_DATABASE
+{
+ Text [ en-US ] = "Database" ;
+};
+
+String STR_TASKS
+{
+ Text [ en-US ] = "Tasks" ;
+};
+
+String STR_DESCRIPTION
+{
+ Text [ en-US ] = "Description" ;
+};
+
+String STR_PREVIEW
+{
+ Text [ en-US ] = "Preview" ;
+};
+
+String STR_DISABLEPREVIEW
+{
+ Text [ en-US ] = "Disable Preview" ;
+};
+
+QueryBox APP_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The database has been modified.\nDo you want to save the changes?" ;
+};
+
+QueryBox APP_CLOSEDOCUMENTS
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The connection type has been altered.\nFor the changes to take effect, all forms, reports, queries and tables must be closed.\n\nDo you want to close all documents now?" ;
+};
+
+Menu RID_MENU_APP_PREVIEW
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_DB_APP_DISABLE_PREVIEW;
+ Text[ en-US ] = "None";
+ Command = ".uno:DBDisablePreview";
+ Checkable = TRUE;
+ RadioCheck = TRUE;
+ AutoCheck = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_VIEW_DOCINFO_PREVIEW;
+ Text[ en-US ] = "Document Information";
+ Command = ".uno:DBShowDocInfoPreview";
+ Checkable = TRUE;
+ RadioCheck = TRUE;
+ AutoCheck = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = SID_DB_APP_VIEW_DOC_PREVIEW;
+ Text[ en-US ] = "Document";
+ Command = ".uno:DBShowDocPreview";
+ Checkable = TRUE;
+ RadioCheck = TRUE;
+ AutoCheck = TRUE;
+ };
+ };
+};
+
+String RID_STR_FORM
+{
+ Text [ en-US ] = "Form";
+};
+
+String RID_STR_REPORT
+{
+ Text [ en-US ] = "Report";
+};
+
+String STR_FRM_LABEL
+{
+ Text [ en-US ] = "F~orm name" ;
+};
+
+String STR_RPT_LABEL
+{
+ Text [ en-US ] = "~Report name" ;
+};
+
+String STR_FOLDER_LABEL
+{
+ Text [ en-US ] = "F~older name" ;
+};
+
+String STR_SUB_DOCS_WITH_SCRIPTS
+{
+ Text [ en-US ] = "The document contains forms or reports with embedded macros.";
+};
+
+String STR_SUB_DOCS_WITH_SCRIPTS_DETAIL
+{
+ Text [ en-US ] = "Macros should be embedded into the database document itself.\n\n"
+
+ "You can continue to use your document as before, however, you are encouraged to migrate "
+ "your macros. The menu item 'Tools / Migrate Macros ...' will assist you with this.\n\n"
+
+ "Note that you won't be able to embed macros into the database document itself until "
+ "this migration is done. ";
+};
+
+String RID_STR_EMBEDDED_DATABASE
+{
+ Text [ en-US ] = "Embedded database";
+};
+
+String RID_STR_NO_DIFF_CAT
+{
+ Text [ en-US ] = "You cannot select different categories.";
+};
+
+String RID_STR_UNSUPPORTED_OBJECT_TYPE
+{
+ Text [ en-US ] = "Unsupported object type found ($type$).";
+};
diff --git a/dbaccess/source/ui/app/dbu_app.hrc b/dbaccess/source/ui/app/dbu_app.hrc
new file mode 100644
index 000000000000..7412dd85786d
--- /dev/null
+++ b/dbaccess/source/ui/app/dbu_app.hrc
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_APP_HRC_
+#define _DBU_APP_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+#define TBI_SWITCH_PREVIEW RID_DBACCESS_START
+
+#define RID_STR_NEW_FORM RID_STR_APP_START
+#define RID_STR_NEW_FORM_AUTO RID_STR_APP_START + 1
+#define RID_STR_NEW_REPORT RID_STR_APP_START + 2
+#define RID_STR_NEW_REPORT_AUTO RID_STR_APP_START + 3
+#define RID_STR_NEW_TABLE RID_STR_APP_START + 4
+#define RID_STR_NEW_TABLE_AUTO RID_STR_APP_START + 5
+#define RID_STR_NEW_VIEW RID_STR_APP_START + 6
+#define RID_STR_NEW_VIEW_AUTO RID_STR_APP_START + 7
+#define RID_STR_NEW_QUERY RID_STR_APP_START + 8
+#define RID_STR_NEW_QUERY_AUTO RID_STR_APP_START + 9
+#define STR_QUERY_DELETE_DATASOURCE RID_STR_APP_START + 10
+#define STR_APP_TITLE RID_STR_APP_START + 11
+#define RID_STR_NEW_QUERY_SQL RID_STR_APP_START + 12
+#define RID_STR_REPORTS_CONTAINER RID_STR_APP_START + 13
+#define RID_STR_FORMS_CONTAINER RID_STR_APP_START + 14
+#define RID_STR_REPORTS_HELP_TEXT_WIZARD RID_STR_APP_START + 15
+#define RID_STR_FORMS_HELP_TEXT RID_STR_APP_START + 16
+#define RID_STR_QUERIES_HELP_TEXT RID_STR_APP_START + 17
+#define RID_STR_QUERIES_HELP_TEXT_SQL RID_STR_APP_START + 18
+#define RID_STR_VIEWS_HELP_TEXT_DESIGN RID_STR_APP_START + 19
+#define RID_STR_VIEWS_HELP_TEXT_WIZARD RID_STR_APP_START + 20
+#define STR_DATABASE RID_STR_APP_START + 21
+#define STR_TASKS RID_STR_APP_START + 22
+#define STR_DESCRIPTION RID_STR_APP_START + 23
+#define STR_PREVIEW RID_STR_APP_START + 24
+#define STR_DISABLEPREVIEW RID_STR_APP_START + 25
+#define RID_STR_QUERIES_HELP_TEXT_WIZARD RID_STR_APP_START + 26
+#define RID_STR_TABLES_HELP_TEXT_DESIGN RID_STR_APP_START + 27
+#define RID_STR_TABLES_HELP_TEXT_WIZARD RID_STR_APP_START + 28
+#define RID_STR_FORMS_HELP_TEXT_WIZARD RID_STR_APP_START + 29
+#define RID_STR_REPORT_HELP_TEXT RID_STR_APP_START + 30
+#define RID_STR_EMBEDDED_DATABASE RID_STR_APP_START + 31
+#define RID_STR_NO_DIFF_CAT RID_STR_APP_START + 32
+#define RID_STR_UNSUPPORTED_OBJECT_TYPE RID_STR_APP_START + 33
+
+// please adjust checking before insert new strings
+
+#if RID_STR_UNSUPPORTED_OBJECT_TYPE > RID_STR_APP_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif // _DBU_BRW_HRC_
+
diff --git a/dbaccess/source/ui/app/makefile.mk b/dbaccess/source/ui/app/makefile.mk
new file mode 100644
index 000000000000..658456f4135b
--- /dev/null
+++ b/dbaccess/source/ui/app/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=app
+
+# BMP_IN=$(PRJ)$/res
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+# IMGLST_SRS=$(SRS)$/$(TARGET).srs
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/AppController.obj \
+ $(SLO)$/AppControllerDnD.obj \
+ $(SLO)$/AppControllerGen.obj \
+ $(SLO)$/AppDetailPageHelper.obj \
+ $(SLO)$/AppDetailView.obj \
+ $(SLO)$/AppIconControl.obj \
+ $(SLO)$/AppSwapWindow.obj \
+ $(SLO)$/AppTitleWindow.obj \
+ $(SLO)$/AppView.obj \
+ $(SLO)$/subcomponentmanager.obj
+
+
+SLOFILES =\
+ $(EXCEPTIONSFILES)
+
+SRS1NAME=$(TARGET)
+SRC1FILES = app.src
+
+
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
+
diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx
new file mode 100644
index 000000000000..9b6d612b1b4c
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.cxx
@@ -0,0 +1,614 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#include "subcomponentmanager.hxx"
+#include "AppController.hxx"
+#include "dbustrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/embed/XComponentSupplier.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XModel2;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::awt::XTopWindow;
+ using ::com::sun::star::embed::XComponentSupplier;
+ using ::com::sun::star::ucb::XCommandProcessor;
+ using ::com::sun::star::ucb::Command;
+ using ::com::sun::star::document::XDocumentEventBroadcaster;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= helper structs
+ //==================================================================================================================
+ namespace
+ {
+ //..............................................................................................................
+ struct SubComponentDescriptor
+ {
+ /// the name of the sub component, empty if it is yet unsaved
+ ::rtl::OUString sName;
+ /// type of the component - an ElementType value, except for relation design
+ sal_Int32 nComponentType;
+ /// the mode in which the sub component has been opened
+ ElementOpenMode eOpenMode;
+ /// the frame which the component resides in. Must not be <NULL/>
+ Reference< XFrame > xFrame;
+ /// the controller of the sub component. Must not be <NULL/>
+ Reference< XController > xController;
+ /// the model of the sub component. Might be <NULL/>
+ Reference< XModel > xModel;
+ /// the document definition which holds the component, if any; as CommandProcessor
+ Reference< XCommandProcessor > xComponentCommandProcessor;
+ /// the document definition which holds the component, if any; as PropertySet
+ Reference< XPropertySet > xDocumentDefinitionProperties;
+
+ SubComponentDescriptor()
+ :sName()
+ ,nComponentType( -1 )
+ ,eOpenMode( E_OPEN_NORMAL )
+ ,xFrame()
+ ,xController()
+ ,xModel()
+ {
+ }
+
+ SubComponentDescriptor( const ::rtl::OUString& i_rName, const sal_Int32 i_nComponentType,
+ const ElementOpenMode i_eOpenMode, const Reference< XComponent >& i_rComponent )
+ :sName( i_rName )
+ ,nComponentType( i_nComponentType )
+ ,eOpenMode( i_eOpenMode )
+ {
+ if ( !impl_constructFrom( i_rComponent ) )
+ {
+ // i_rComponent is neither a model, nor a controller, nor a frame
+ // => it must be a css.sdb.DocumentDefinition
+ Reference< XComponentSupplier > xCompSupp( i_rComponent, UNO_QUERY_THROW );
+ Reference< XComponent > xComponent( xCompSupp->getComponent(), UNO_QUERY_THROW );
+ if ( !impl_constructFrom( xComponent ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal component type." ) ), NULL );
+ xComponentCommandProcessor.set( i_rComponent, UNO_QUERY_THROW );
+ xDocumentDefinitionProperties.set( i_rComponent, UNO_QUERY_THROW );
+ }
+ }
+
+ inline bool is() const { return xFrame.is(); }
+
+ private:
+ bool impl_constructFrom( const Reference< XComponent >& _rxComponent )
+ {
+ // is it a model?
+ xModel.set( _rxComponent, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ xController.set( xModel->getCurrentController() );
+ if ( xController.is() )
+ xFrame.set( xController->getFrame(), UNO_SET_THROW );
+ }
+ else
+ {
+ // is it a controller?
+ xController.set( _rxComponent, UNO_QUERY );
+ if ( xController.is() )
+ {
+ xFrame.set( xController->getFrame(), UNO_SET_THROW );
+ }
+ else
+ {
+ // is it a frame?
+ xFrame.set( _rxComponent, UNO_QUERY );
+ if ( !xFrame.is() )
+ return false;
+
+ // ensure we have a controller
+ xController.set( xFrame->getController(), UNO_SET_THROW );
+ }
+
+ // check wether there is a model (not required)
+ xModel.set( xController->getModel() );
+ }
+
+ return true;
+ }
+ };
+
+ //..............................................................................................................
+ struct SelectSubComponent : public ::std::unary_function< SubComponentDescriptor, Reference< XComponent > >
+ {
+ Reference< XComponent > operator()( const SubComponentDescriptor &_desc ) const
+ {
+ if ( _desc.xModel.is() )
+ return _desc.xModel.get();
+ OSL_ENSURE( _desc.xController.is(), "SelectSubComponent::operator(): illegal component!" );
+ return _desc.xController.get();
+ }
+ };
+
+ //..............................................................................................................
+ typedef ::std::vector< SubComponentDescriptor > SubComponents;
+
+ //..............................................................................................................
+ struct SubComponentMatch : public ::std::unary_function< SubComponentDescriptor, bool >
+ {
+ public:
+ SubComponentMatch( const ::rtl::OUString& i_rName, const sal_Int32 i_nComponentType,
+ const ElementOpenMode i_eOpenMode )
+ :m_sName( i_rName )
+ ,m_nComponentType( i_nComponentType )
+ ,m_eOpenMode( i_eOpenMode )
+ {
+ }
+
+ bool operator()( const SubComponentDescriptor& i_rCompareWith ) const
+ {
+ return ( m_sName == i_rCompareWith.sName )
+ && ( m_nComponentType == i_rCompareWith.nComponentType )
+ && ( m_eOpenMode == i_rCompareWith.eOpenMode );
+ }
+ private:
+ const ::rtl::OUString m_sName;
+ const sal_Int32 m_nComponentType;
+ const ElementOpenMode m_eOpenMode;
+ };
+ }
+
+ //==================================================================================================================
+ //= SubComponentManager_Data
+ //==================================================================================================================
+ struct SubComponentManager_Data
+ {
+ SubComponentManager_Data( OApplicationController& _rController, const ::comphelper::SharedMutex& _rMutex )
+ :m_rController( _rController )
+ ,m_aMutex( _rMutex )
+ {
+ }
+
+ OApplicationController& m_rController;
+ mutable ::comphelper::SharedMutex m_aMutex;
+ SubComponents m_aComponents;
+
+ ::osl::Mutex& getMutex() const { return m_aMutex; }
+ };
+
+ //==================================================================================================================
+ //= SubComponentManager
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ SubComponentManager::SubComponentManager( OApplicationController& _rController, const ::comphelper::SharedMutex& _rMutex )
+ :m_pData( new SubComponentManager_Data( _rController, _rMutex ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ SubComponentManager::~SubComponentManager()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SubComponentManager::disposing()
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+ m_pData->m_aComponents.clear();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................................................................
+ bool lcl_fallbackToAnotherController( SubComponentDescriptor& _rCompDesc )
+ {
+ Reference< XController > xFallback;
+ OSL_PRECOND( _rCompDesc.xModel.is(), "lcl_fallbackToAnotherController: illegal call!" );
+ if ( !_rCompDesc.xModel.is() )
+ return false;
+
+ xFallback.set( _rCompDesc.xModel->getCurrentController() );
+ if ( xFallback == _rCompDesc.xController )
+ // don't accept the very same controller as fallback
+ xFallback.clear();
+
+ if ( !xFallback.is() )
+ {
+ // perhaps XModel2 can be of help here
+ Reference< XModel2 > xModel2( _rCompDesc.xModel, UNO_QUERY );
+ Reference< XEnumeration > xControllerEnum;
+ if ( xModel2.is() )
+ xControllerEnum = xModel2->getControllers();
+ while ( xControllerEnum.is() && xControllerEnum->hasMoreElements() )
+ {
+ xFallback.set( xControllerEnum->nextElement(), UNO_QUERY );
+ if ( xFallback == _rCompDesc.xController )
+ xFallback.clear();
+ }
+ }
+
+ if ( xFallback.is() )
+ {
+ _rCompDesc.xController = xFallback;
+ _rCompDesc.xFrame.set( xFallback->getFrame(), UNO_SET_THROW );
+ return true;
+ }
+
+ return false;
+ }
+
+ //..............................................................................................................
+ bool lcl_closeComponent( const Reference< XCommandProcessor >& _rxCommandProcessor )
+ {
+ bool bSuccess = false;
+ try
+ {
+ Reference< XCommandProcessor > xCommandProcessor( _rxCommandProcessor, UNO_SET_THROW );
+ sal_Int32 nCommandIdentifier = xCommandProcessor->createCommandIdentifier();
+
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "close" ) );
+ xCommandProcessor->execute( aCommand, nCommandIdentifier, NULL );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSuccess;
+ }
+
+ //..............................................................................................................
+ bool lcl_closeComponent( const SubComponentDescriptor& _rComponent )
+ {
+ if ( _rComponent.xComponentCommandProcessor.is() )
+ return lcl_closeComponent( _rComponent.xComponentCommandProcessor );
+
+ Reference< XController > xController( _rComponent.xController );
+ OSL_ENSURE( xController.is(), "lcl_closeComponent: invalid controller!" );
+
+ // suspend the controller in the document
+ if ( xController.is() )
+ if ( !xController->suspend( sal_True ) )
+ return false;
+
+ bool bSuccess = false;
+ try
+ {
+ Reference< XCloseable > xCloseable( _rComponent.xFrame, UNO_QUERY_THROW );
+ xCloseable->close( sal_True );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSuccess;
+ }
+
+ //..............................................................................................................
+ void lcl_notifySubComponentEvent( const SubComponentManager_Data& _rData, const sal_Char* _pAsciiEventName,
+ const SubComponentDescriptor& _rComponent )
+ {
+ try
+ {
+ Reference< XDocumentEventBroadcaster > xBroadcaster( _rData.m_rController.getModel(), UNO_QUERY_THROW );
+ xBroadcaster->notifyDocumentEvent(
+ ::rtl::OUString::createFromAscii( _pAsciiEventName ),
+ &_rData.m_rController,
+ makeAny( _rComponent.xFrame )
+ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL SubComponentManager::propertyChange( const PropertyChangeEvent& i_rEvent ) throw (RuntimeException)
+ {
+ if ( i_rEvent.PropertyName != PROPERTY_NAME )
+ // by definition, it's allowed to broadcast more than what we've registered for
+ return;
+
+ // find the sub component whose name changed
+ for ( SubComponents::iterator comp = m_pData->m_aComponents.begin();
+ comp != m_pData->m_aComponents.end();
+ ++comp
+ )
+ {
+ if ( comp->xDocumentDefinitionProperties != i_rEvent.Source )
+ continue;
+
+ ::rtl::OUString sNewName;
+ OSL_VERIFY( i_rEvent.NewValue >>= sNewName );
+
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sOldKnownName( comp->sName );
+ ::rtl::OUString sOldName;
+ OSL_VERIFY( i_rEvent.OldValue >>= sOldName );
+ OSL_ENSURE( sOldName == sOldKnownName, "SubComponentManager::propertyChange: inconsistency in the old names!" );
+ #endif
+
+ comp->sName = sNewName;
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL SubComponentManager::disposing( const EventObject& _rSource ) throw (RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_pData->getMutex() );
+
+ SubComponentDescriptor aClosedComponent;
+
+ for ( SubComponents::iterator comp = m_pData->m_aComponents.begin();
+ comp != m_pData->m_aComponents.end();
+ ++comp
+ )
+ {
+ bool bRemove = false;
+
+ if ( comp->xController == _rSource.Source )
+ {
+ if ( !comp->xModel.is() )
+ {
+ bRemove = true;
+ }
+ else
+ {
+ // maybe this is just one view to the sub document, and only this view is closed
+ if ( !lcl_fallbackToAnotherController( *comp ) )
+ {
+ bRemove = true;
+ }
+ }
+ }
+ else if ( comp->xModel == _rSource.Source )
+ {
+ bRemove = true;
+ }
+
+ if ( bRemove )
+ {
+ aClosedComponent = *comp;
+ m_pData->m_aComponents.erase( comp );
+ break;
+ }
+ }
+
+ if ( aClosedComponent.is() )
+ {
+ aGuard.clear();
+ lcl_notifySubComponentEvent( *m_pData, "OnSubComponentClosed", aClosedComponent );
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< Reference< XComponent> > SubComponentManager::getSubComponents() const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ Sequence< Reference< XComponent > > aComponents( m_pData->m_aComponents.size() );
+ ::std::transform(
+ m_pData->m_aComponents.begin(),
+ m_pData->m_aComponents.end(),
+ aComponents.getArray(),
+ SelectSubComponent()
+ );
+ return aComponents;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Bool SubComponentManager::closeSubComponents()
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ try
+ {
+ SubComponents aWorkingCopy( m_pData->m_aComponents );
+ for ( SubComponents::const_iterator comp = aWorkingCopy.begin();
+ comp != aWorkingCopy.end();
+ ++comp
+ )
+ {
+ lcl_closeComponent( *comp );
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return empty();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool SubComponentManager::empty() const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+ return m_pData->m_aComponents.empty();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SubComponentManager::onSubComponentOpened( const ::rtl::OUString& _rName, const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode, const Reference< XComponent >& _rxComponent )
+ {
+ ::osl::ClearableMutexGuard aGuard( m_pData->getMutex() );
+
+#if OSL_DEBUG_LEVEL > 0
+ if ( _rName.getLength() )
+ {
+ // check there does not already exist such a component
+ SubComponents::const_iterator existentPos = ::std::find_if(
+ m_pData->m_aComponents.begin(),
+ m_pData->m_aComponents.end(),
+ SubComponentMatch( _rName, _nComponentType, _eOpenMode )
+ );
+ OSL_ENSURE( existentPos == m_pData->m_aComponents.end(), "already existent!" );
+ }
+#endif
+ SubComponentDescriptor aElement( _rName, _nComponentType, _eOpenMode, _rxComponent );
+ ENSURE_OR_THROW( aElement.xModel.is() || aElement.xController.is(), "illegal component" );
+
+ m_pData->m_aComponents.push_back( aElement );
+
+ // add as listener
+ if ( aElement.xController.is() )
+ aElement.xController->addEventListener( this );
+ if ( aElement.xModel.is() )
+ aElement.xModel->addEventListener( this );
+ if ( aElement.xDocumentDefinitionProperties.is() )
+ aElement.xDocumentDefinitionProperties->addPropertyChangeListener( PROPERTY_NAME, this );
+
+ // notify this to interested parties
+ aGuard.clear();
+ lcl_notifySubComponentEvent( *m_pData, "OnSubComponentOpened", aElement );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool SubComponentManager::activateSubFrame( const ::rtl::OUString& _rName, const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode, Reference< XComponent >& o_rComponent ) const
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+
+ SubComponents::const_iterator pos = ::std::find_if(
+ m_pData->m_aComponents.begin(),
+ m_pData->m_aComponents.end(),
+ SubComponentMatch( _rName, _nComponentType, _eOpenMode )
+ );
+ if ( pos == m_pData->m_aComponents.end() )
+ // no component with this name/type/open mode
+ return false;
+
+ const Reference< XFrame > xFrame( pos->xFrame, UNO_SET_THROW );
+ const Reference< XTopWindow > xTopWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ xTopWindow->toFront();
+
+ if ( pos->xModel.is() )
+ o_rComponent = pos->xModel.get();
+ else if ( pos->xController.is() )
+ o_rComponent = pos->xController.get();
+ else
+ o_rComponent = pos->xFrame.get();
+
+ return true;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool SubComponentManager::closeSubFrames( const ::rtl::OUString& i_rName, const sal_Int32 _nComponentType )
+ {
+ ::osl::MutexGuard aGuard( m_pData->getMutex() );
+ ENSURE_OR_RETURN_FALSE( i_rName.getLength(), "SubComponentManager::closeSubFrames: illegal name!" );
+
+ SubComponents aWorkingCopy( m_pData->m_aComponents );
+ for ( SubComponents::const_iterator comp = aWorkingCopy.begin();
+ comp != aWorkingCopy.end();
+ ++comp
+ )
+ {
+ if ( ( comp->sName != i_rName ) || ( comp->nComponentType != _nComponentType ) )
+ continue;
+
+ if ( !lcl_closeComponent( *comp ) )
+ return false;
+ }
+
+ return true;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool SubComponentManager::lookupSubComponent( const Reference< XComponent >& i_rComponent,
+ ::rtl::OUString& o_rName, sal_Int32& o_rComponentType )
+ {
+ for ( SubComponents::const_iterator comp = m_pData->m_aComponents.begin();
+ comp != m_pData->m_aComponents.end();
+ ++comp
+ )
+ {
+ if ( ( comp->xModel.is()
+ && ( comp->xModel == i_rComponent )
+ )
+ || ( comp->xController.is()
+ && ( comp->xController == i_rComponent )
+ )
+ || ( comp->xFrame.is()
+ && ( comp->xFrame == i_rComponent )
+ )
+ )
+ {
+ o_rName = comp->sName;
+ o_rComponentType = comp->nComponentType;
+ return true;
+ }
+ }
+ return false;
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/subcomponentmanager.hxx b/dbaccess/source/ui/app/subcomponentmanager.hxx
new file mode 100644
index 000000000000..c66732528471
--- /dev/null
+++ b/dbaccess/source/ui/app/subcomponentmanager.hxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef DBACCESS_SUBCOMPONENTMANAGER_HXX
+#define DBACCESS_SUBCOMPONENTMANAGER_HXX
+
+#include "AppElementType.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/frame/XController.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/sharedmutex.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ struct SubComponentManager_Data;
+ class OApplicationController;
+
+ //====================================================================
+ //= SubComponentManager
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > SubComponentManager_Base;
+ class SubComponentManager : public SubComponentManager_Base
+ {
+ public:
+ SubComponentManager( OApplicationController& _rController, const ::comphelper::SharedMutex& _rMutex );
+ virtual ~SubComponentManager();
+
+ void disposing();
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseDocumentUI helpers
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> >
+ getSubComponents() const;
+ sal_Bool closeSubComponents();
+
+ // container access
+ void onSubComponentOpened(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&
+ _rxComponent
+ );
+ bool empty() const;
+
+ /** activates (i.e. brings to top) the frame in which the given component is loaded, if any
+
+ @return
+ <TRUE/> if any only of such a frame was found, i.e. the component had already been loaded
+ previously
+ */
+ bool activateSubFrame(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType,
+ const ElementOpenMode _eOpenMode,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_rComponent
+ ) const;
+
+ /** closes all frames of the given component
+
+ If a view for the component (given by name and type) has been loaded into one or more
+ frames (with potentially different OpenModes), then those frames are gracefully closed.
+
+ @return
+ <TRUE/> if and only if closing those frames was successful, or frames for the given sub component
+ exist.
+ */
+ bool closeSubFrames(
+ const ::rtl::OUString& _rName,
+ const sal_Int32 _nComponentType
+ );
+
+ /** searches for the given sub component
+
+ @param i_rComponent
+ the sub component to look up
+ @param o_rName
+ contains, upon successful return, the name of the sub component
+ @param o_nComponentType
+ contains, upon successful return, the type of the sub component
+ @return
+ <TRUE/> if and only if the component was found
+ */
+ bool lookupSubComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& i_rComponent,
+ ::rtl::OUString& o_rName,
+ sal_Int32& o_rComponentType
+ );
+
+ private:
+ ::std::auto_ptr< SubComponentManager_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SUBCOMPONENTMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/app/window_layout.txt b/dbaccess/source/ui/app/window_layout.txt
new file mode 100644
index 000000000000..dba1ff98a603
--- /dev/null
+++ b/dbaccess/source/ui/app/window_layout.txt
@@ -0,0 +1,31 @@
+(still unfinished)
+
+OApplicationView
+|
++-OAppBorderWindow
+ |
+ +-OTitleWindow "Database"
+ | |
+ | +-OApplicationSwapWindow
+ | |
+ | +-OApplicationIconControl
+ |
+ +-OApplicationDetailView
+ |
+ +-OTitleWindow "Tasks"
+ | |
+ | +-OTasksWindow
+ | |
+ | +-OCreationList
+ |
+ +-OTitleWindow "Forms" "Tables" "Queries" "Reports"
+ |
+ +-OAppDetailPageHelper
+ |
+ +-SvTreeListBox*
+ |
+ +-FixedLine
+ |
+ +-Window (Border)
+ |
+ +-OPreviewWindow
diff --git a/dbaccess/source/ui/browser/AsyncronousLink.cxx b/dbaccess/source/ui/browser/AsyncronousLink.cxx
new file mode 100644
index 000000000000..7cc0ac71d23b
--- /dev/null
+++ b/dbaccess/source/ui/browser/AsyncronousLink.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "AsyncronousLink.hxx"
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+
+//==================================================================
+//= OAsyncronousLink
+//==================================================================
+using namespace dbaui;
+DBG_NAME(OAsyncronousLink)
+//------------------------------------------------------------------
+OAsyncronousLink::OAsyncronousLink( const Link& _rHandler )
+ :m_aHandler(_rHandler)
+ ,m_aEventSafety()
+ ,m_aDestructionSafety()
+ ,m_nEventId(0)
+{
+ DBG_CTOR(OAsyncronousLink,NULL);
+}
+
+//------------------------------------------------------------------
+OAsyncronousLink::~OAsyncronousLink()
+{
+ {
+ ::osl::MutexGuard aEventGuard( m_aEventSafety );
+ if ( m_nEventId )
+ Application::RemoveUserEvent(m_nEventId);
+ m_nEventId = 0;
+ }
+
+ {
+ ::osl::MutexGuard aDestructionGuard( m_aDestructionSafety );
+ // this is just for the case we're deleted while another thread just handled the event :
+ // if this other thread called our link while we were deleting the event here, the
+ // link handler blocked. With leaving the above block it continued, but now we are prevented
+ // to leave this destructor 'til the link handler recognizes that nEvent == 0 and leaves.
+ }
+ DBG_DTOR(OAsyncronousLink,NULL);
+}
+
+
+//------------------------------------------------------------------
+void OAsyncronousLink::Call( void* _pArgument )
+{
+ ::osl::MutexGuard aEventGuard( m_aEventSafety );
+ if (m_nEventId)
+ Application::RemoveUserEvent(m_nEventId);
+ m_nEventId = Application::PostUserEvent( LINK( this, OAsyncronousLink, OnAsyncCall ), _pArgument );
+}
+
+//------------------------------------------------------------------
+void OAsyncronousLink::CancelCall()
+{
+ ::osl::MutexGuard aEventGuard( m_aEventSafety );
+ if ( m_nEventId )
+ Application::RemoveUserEvent( m_nEventId );
+ m_nEventId = 0;
+}
+
+//------------------------------------------------------------------
+IMPL_LINK(OAsyncronousLink, OnAsyncCall, void*, _pArg)
+{
+ {
+ ::osl::MutexGuard aDestructionGuard( m_aDestructionSafety );
+ {
+ ::osl::MutexGuard aEventGuard( m_aEventSafety );
+ if (!m_nEventId)
+ // our destructor deleted the event just while we we're waiting for m_aEventSafety
+ // -> get outta here
+ return 0;
+ m_nEventId = 0;
+ }
+ }
+ if (m_aHandler.IsSet())
+ return m_aHandler.Call(_pArg);
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/bcommon.src b/dbaccess/source/ui/browser/bcommon.src
new file mode 100644
index 000000000000..d5b8401b4e8c
--- /dev/null
+++ b/dbaccess/source/ui/browser/bcommon.src
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+String RID_STR_TBL_TITLE
+{
+ Text [ en-US ] = "Table #" ;
+};
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx
new file mode 100644
index 000000000000..7b4293318712
--- /dev/null
+++ b/dbaccess/source/ui/browser/brwctrlr.cxx
@@ -0,0 +1,3074 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "browserids.hxx"
+#include "brwctrlr.hxx"
+#include "brwview.hxx"
+#include "dbu_brw.hrc"
+#include "dbustrings.hrc"
+#include "queryfilter.hxx"
+#include "queryorder.hxx"
+#include "sqlmessage.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#include <com/sun/star/form/FormSubmitMethod.hpp>
+#include <com/sun/star/form/XApproveActionBroadcaster.hpp>
+#include <com/sun/star/form/XBoundControl.hpp>
+#include <com/sun/star/form/XChangeBroadcaster.hpp>
+#include <com/sun/star/form/XChangeListener.hpp>
+#include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/form/XResetListener.hpp>
+#include <com/sun/star/form/XSubmit.hpp>
+#include <com/sun/star/form/XSubmitListener.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/sdb/ParametersRequest.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/uno/TypeClass.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfx.hrc>
+#include <svx/fmsearch.hxx>
+#include <svx/svxdlg.hxx>
+#include <tools/color.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::dbtools;
+using namespace ::comphelper;
+using namespace ::svt;
+
+#define HANDLE_SQL_ERRORS( action, successflag, context, message ) \
+ try \
+ { \
+ successflag = sal_False; \
+ action; \
+ successflag = sal_True; \
+ } \
+ catch(SQLException& e) \
+ { \
+ SQLException aError = ::dbtools::prependErrorInfo(e, *this, context); \
+ ::com::sun::star::sdb::SQLErrorEvent aEvent; \
+ aEvent.Reason <<= aError; \
+ errorOccured(aEvent); \
+ } \
+ catch(Exception&) \
+ { \
+ DBG_UNHANDLED_EXCEPTION(); \
+ } \
+
+#define DO_SAFE( action, message ) try { action; } catch(Exception&) { OSL_FAIL(message); } ;
+
+//..................................................................
+namespace dbaui
+{
+//..................................................................
+
+//==================================================================
+// OParameterContinuation
+//==================================================================
+class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
+{
+ Sequence< PropertyValue > m_aValues;
+
+public:
+ OParameterContinuation() { }
+
+ Sequence< PropertyValue > getValues() const { return m_aValues; }
+
+// XInteractionSupplyParameters
+ virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException);
+};
+
+//------------------------------------------------------------------
+void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException)
+{
+ m_aValues = _rValues;
+}
+
+
+//==============================================================================
+// a helper class implementing a runtime::XFormController, will be aggregated by SbaXDataBrowserController
+// (we can't derive from XFormController as it's base class is XTabController and the XTabController::getModel collides
+// with the XController::getModel implemented in our base class SbaXDataBrowserController)
+class SbaXDataBrowserController::FormControllerImpl
+ : public ::cppu::WeakAggImplHelper2< ::com::sun::star::form::runtime::XFormController,
+ ::com::sun::star::frame::XFrameActionListener >
+{
+ friend class SbaXDataBrowserController;
+ ::cppu::OInterfaceContainerHelper m_aActivateListeners;
+ SbaXDataBrowserController* m_pOwner;
+
+public:
+ FormControllerImpl(SbaXDataBrowserController* pOwner);
+
+ // XFormController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XChild, base of XFormController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XComponent, base of XFormController
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess, base of XFormController
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess, base of XIndexAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess, base of XElementAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XModifyBroadcaster, base of XFormController
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XConfirmDeleteBroadcaster, base of XFormController
+ virtual void SAL_CALL addConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeConfirmDeleteListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XSQLErrorBroadcaster, base of XFormController
+ virtual void SAL_CALL addSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSQLErrorListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XRowSetApproveBroadcaster, base of XFormController
+ virtual void SAL_CALL addRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRowSetApproveListener( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseParameterBroadcaster2, base of XFormController
+ virtual void SAL_CALL addDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeDatabaseParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseParameterBroadcaster, base of XDatabaseParameterBroadcaster2
+ virtual void SAL_CALL addParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeParameterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XModeSelector, base of XFormController
+ virtual void SAL_CALL setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getMode( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTabController, base of XFormController
+ virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > & Model) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL getModel(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > & _Container) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SAL_CALL getContainer(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL autoTabOrder(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL activateTabOrder(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL activateFirst(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL activateLast(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XFrameActionListener
+ virtual void SAL_CALL frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+protected:
+ ~FormControllerImpl();
+};
+
+
+DBG_NAME(FormControllerImpl)
+//------------------------------------------------------------------
+SbaXDataBrowserController::FormControllerImpl::FormControllerImpl(SbaXDataBrowserController* _pOwner)
+ :m_aActivateListeners(_pOwner->getMutex())
+ ,m_pOwner(_pOwner)
+{
+ DBG_CTOR(FormControllerImpl,NULL);
+
+ OSL_ENSURE(m_pOwner, "SbaXDataBrowserController::FormControllerImpl::FormControllerImpl : invalid Owner !");
+}
+
+//------------------------------------------------------------------
+SbaXDataBrowserController::FormControllerImpl::~FormControllerImpl()
+{
+
+ DBG_DTOR(FormControllerImpl,NULL);
+}
+
+//------------------------------------------------------------------
+Reference< runtime::XFormOperations > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getFormOperations() throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getFormOperations: not supported!" );
+ return NULL;
+}
+
+//------------------------------------------------------------------
+Reference< ::com::sun::star::awt::XControl > SbaXDataBrowserController::FormControllerImpl::getCurrentControl(void) throw( RuntimeException )
+{
+ return m_pOwner->getBrowserView() ? m_pOwner->getBrowserView()->getGridControl() : Reference< ::com::sun::star::awt::XControl > ();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException )
+{
+ m_aActivateListeners.addInterface(l);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeActivateListener(const Reference< ::com::sun::star::form::XFormControllerListener > & l) throw( RuntimeException )
+{
+ m_aActivateListeners.removeInterface(l);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addChildController( const Reference< runtime::XFormController >& /*_ChildController*/ ) throw( RuntimeException, IllegalArgumentException )
+{
+ // not supported
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+}
+
+//------------------------------------------------------------------
+Reference< runtime::XFormControllerContext > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getContext() throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getContext: no support!!" );
+ return NULL;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContext( const Reference< runtime::XFormControllerContext >& /*_context*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::setContext: no support!!" );
+}
+
+//------------------------------------------------------------------
+Reference< XInteractionHandler > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getInteractionHandler() throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::getInteractionHandler: no support!!" );
+ return NULL;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setInteractionHandler( const Reference< XInteractionHandler >& /*_interactionHandler*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::setInteractionHandler: no support!!" );
+}
+
+//------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getParent( ) throw (RuntimeException)
+{
+ // don't have any parent form controllers
+ return NULL;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setParent( const Reference< XInterface >& /*Parent*/ ) throw (NoSupportException, RuntimeException)
+{
+ throw NoSupportException( ::rtl::OUString(), *this );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::dispose( ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::dispose: no, you do *not* want to do this!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addEventListener( const Reference< XEventListener >& /*xListener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addEventListener: no support!!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeEventListener( const Reference< XEventListener >& /*aListener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeEventListener: no support!!" );
+}
+
+//------------------------------------------------------------------
+::sal_Int32 SAL_CALL SbaXDataBrowserController::FormControllerImpl::getCount( ) throw (RuntimeException)
+{
+ // no sub controllers, never
+ return 0;
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL SbaXDataBrowserController::FormControllerImpl::getByIndex( ::sal_Int32 /*Index*/ ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ // no sub controllers, never
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+}
+
+//------------------------------------------------------------------
+Type SAL_CALL SbaXDataBrowserController::FormControllerImpl::getElementType( ) throw (RuntimeException)
+{
+ return ::cppu::UnoType< runtime::XFormController >::get();
+}
+
+//------------------------------------------------------------------
+::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::hasElements( ) throw (RuntimeException)
+{
+ // no sub controllers, never
+ return false;
+}
+
+//------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL SbaXDataBrowserController::FormControllerImpl::createEnumeration( ) throw (RuntimeException)
+{
+ return new ::comphelper::OEnumerationByIndex( this );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addModifyListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeModifyListener( const Reference< XModifyListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeModifyListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addConfirmDeleteListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener( const Reference< XConfirmDeleteListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeConfirmDeleteListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addSQLErrorListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener( const Reference< XSQLErrorListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeSQLErrorListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addRowSetApproveListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeRowSetApproveListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addDatabaseParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeDatabaseParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::addParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::addParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::removeParameterListener( const Reference< XDatabaseParameterListener >& /*_Listener*/ ) throw (RuntimeException)
+{
+ OSL_FAIL( "SbaXDataBrowserController::FormControllerImpl::removeParameterListener: no support!" );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setMode( const ::rtl::OUString& _rMode ) throw (NoSupportException, RuntimeException)
+{
+ if ( !supportsMode( _rMode ) )
+ throw NoSupportException();
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXDataBrowserController::FormControllerImpl::getMode( ) throw (RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getSupportedModes( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aModes(1);
+ aModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
+ return aModes;
+}
+
+//------------------------------------------------------------------
+::sal_Bool SAL_CALL SbaXDataBrowserController::FormControllerImpl::supportsMode( const ::rtl::OUString& aMode ) throw (RuntimeException)
+{
+ return aMode.compareToAscii( "DataMode" ) == 0;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setModel(const Reference< ::com::sun::star::awt::XTabControllerModel > & /*Model*/) throw( RuntimeException )
+{
+ OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::setModel : invalid call, can't change my model !");
+}
+
+//------------------------------------------------------------------
+Reference< ::com::sun::star::awt::XTabControllerModel > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getModel(void) throw( RuntimeException )
+{
+ return Reference< XTabControllerModel >(m_pOwner->getRowSet(), UNO_QUERY);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::setContainer(const Reference< ::com::sun::star::awt::XControlContainer > & /*_Container*/) throw( RuntimeException )
+{
+ OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::setContainer : invalid call, can't change my container !");
+}
+
+//------------------------------------------------------------------
+Reference< ::com::sun::star::awt::XControlContainer > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getContainer(void) throw( RuntimeException )
+{
+ if (m_pOwner->getBrowserView())
+ return m_pOwner->getBrowserView()->getContainer();
+ return Reference< ::com::sun::star::awt::XControlContainer > ();
+}
+
+//------------------------------------------------------------------
+Sequence< Reference< ::com::sun::star::awt::XControl > > SAL_CALL SbaXDataBrowserController::FormControllerImpl::getControls(void) throw( RuntimeException )
+{
+ if (m_pOwner->getBrowserView())
+ {
+ Reference< ::com::sun::star::awt::XControl > xGrid = m_pOwner->getBrowserView()->getGridControl();
+ return Sequence< Reference< ::com::sun::star::awt::XControl > >(&xGrid, 1);
+ }
+ return Sequence< Reference< ::com::sun::star::awt::XControl > >();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::autoTabOrder(void) throw( RuntimeException )
+{
+ OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::autoTabOrder : nothing to do (always have only one control) !");
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateTabOrder(void) throw( RuntimeException )
+{
+ OSL_FAIL("SbaXDataBrowserController::FormControllerImpl::activateTabOrder : nothing to do (always have only one control) !");
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateFirst(void) throw( RuntimeException )
+{
+ if (m_pOwner->getBrowserView())
+ m_pOwner->getBrowserView()->getVclControl()->ActivateCell();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::activateLast(void) throw( RuntimeException )
+{
+ if (m_pOwner->getBrowserView())
+ m_pOwner->getBrowserView()->getVclControl()->ActivateCell();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::frameAction(const ::com::sun::star::frame::FrameActionEvent& /*aEvent*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::FormControllerImpl::disposing(const ::com::sun::star::lang::EventObject& /*Source*/) throw( RuntimeException )
+{
+ // nothing to do
+ // we don't add ourself as listener to any broadcasters, so we are not resposible for removing us
+}
+
+//==================================================================
+//= SbaXDataBrowserController
+//==================================================================
+//------------------------------------------------------------------
+Sequence< Type > SAL_CALL SbaXDataBrowserController::getTypes( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getTypes" );
+ return ::comphelper::concatSequences(
+ SbaXDataBrowserController_Base::getTypes(),
+ m_pFormControllerImpl->getTypes()
+ );
+}
+
+//------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL SbaXDataBrowserController::getImplementationId( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getImplementationId" );
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL SbaXDataBrowserController::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ // check for our additional interfaces
+ Any aRet = SbaXDataBrowserController_Base::queryInterface(_rType);
+
+ // check for our aggregate (implementing the XFormController)
+ if (!aRet.hasValue())
+ aRet = m_xFormControllerImpl->queryAggregation(_rType);
+
+ // no more to offer
+ return aRet;
+}
+
+DBG_NAME(SbaXDataBrowserController)
+//------------------------------------------------------------------------------
+SbaXDataBrowserController::SbaXDataBrowserController(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
+ :SbaXDataBrowserController_Base(_rM)
+ ,m_nRowSetPrivileges(0)
+ ,m_pClipbordNotifier( NULL )
+ ,m_aAsyncGetCellFocus(LINK(this, SbaXDataBrowserController, OnAsyncGetCellFocus))
+ ,m_aAsyncDisplayError( LINK( this, SbaXDataBrowserController, OnAsyncDisplayError ) )
+ ,m_sStateSaveRecord(ModuleRes(RID_STR_SAVE_CURRENT_RECORD))
+ ,m_sStateUndoRecord(ModuleRes(RID_STR_UNDO_MODIFY_RECORD))
+ ,m_sModuleIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataSourceBrowser" ) ) )
+ ,m_pFormControllerImpl(NULL)
+ ,m_nPendingLoadFinished(0)
+ ,m_nFormActionNestingLevel(0)
+ ,m_bLoadCanceled( sal_False )
+ ,m_bClosingKillOpen( sal_False )
+ ,m_bCannotSelectUnfiltered( true )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SbaXDataBrowserController" );
+ DBG_CTOR(SbaXDataBrowserController,NULL);
+
+ // create the form controller aggregate
+ ::comphelper::increment(m_refCount);
+ {
+ m_pFormControllerImpl = new FormControllerImpl(this);
+ m_xFormControllerImpl = m_pFormControllerImpl;
+ m_xFormControllerImpl->setDelegator(*this);
+ }
+ ::comphelper::decrement(m_refCount);
+
+ m_aInvalidateClipboard.SetTimeoutHdl(LINK(this, SbaXDataBrowserController, OnInvalidateClipboard));
+ m_aInvalidateClipboard.SetTimeout(300);
+}
+
+//------------------------------------------------------------------------------
+SbaXDataBrowserController::~SbaXDataBrowserController()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::~SbaXDataBrowserController" );
+ // deleteView();
+ // release the aggregated form controller
+ if (m_xFormControllerImpl.is())
+ {
+ Reference< XInterface > xEmpty;
+ m_xFormControllerImpl->setDelegator(xEmpty);
+ }
+
+ DBG_DTOR(SbaXDataBrowserController,NULL);
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::startFrameListening( const Reference< XFrame >& _rxFrame )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::startFrameListening" );
+ SbaXDataBrowserController_Base::startFrameListening( _rxFrame );
+
+ Reference< XFrameActionListener > xAggListener;
+ if ( m_xFormControllerImpl.is() )
+ m_xFormControllerImpl->queryAggregation( XFrameActionListener::static_type() ) >>= xAggListener;
+
+ if ( _rxFrame.is() && xAggListener.is() )
+ _rxFrame->addFrameActionListener( xAggListener );
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::stopFrameListening( const Reference< XFrame >& _rxFrame )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::stopFrameListening" );
+ SbaXDataBrowserController_Base::stopFrameListening( _rxFrame );
+
+ Reference< XFrameActionListener > xAggListener;
+ if ( m_xFormControllerImpl.is() )
+ m_xFormControllerImpl->queryAggregation( XFrameActionListener::static_type() ) >>= xAggListener;
+
+ if ( _rxFrame.is() && xAggListener.is() )
+ _rxFrame->removeFrameActionListener( xAggListener );
+}
+
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::onStartLoading( const Reference< XLoadable >& _rxLoadable )
+{
+ m_bLoadCanceled = sal_False;
+ m_bCannotSelectUnfiltered = false;
+
+ Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
+ if ( xWarnings.is() )
+ xWarnings->clearWarnings();
+}
+
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::impl_checkForCannotSelectUnfiltered( const SQLExceptionInfo& _rError )
+{
+ ::connectivity::SQLError aError( getORB() );
+ ::connectivity::ErrorCode nErrorCode( aError.getErrorCode( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED ) );
+ if ( ((const SQLException*)_rError)->ErrorCode == nErrorCode )
+ {
+ m_bCannotSelectUnfiltered = true;
+ InvalidateFeature( ID_BROWSER_FILTERCRIT );
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::reloadForm( const Reference< XLoadable >& _rxLoadable )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloadForm" );
+ WaitObject aWO(getBrowserView());
+
+ onStartLoading( _rxLoadable );
+
+ FormErrorHelper aReportError(this);
+ if (_rxLoadable->isLoaded())
+ _rxLoadable->reload();
+ else
+ _rxLoadable->load();
+
+ m_xParser.clear();
+ const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
+ xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
+
+ {
+ const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY );
+ const Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xRowSetProps->getPropertyValue( PROPERTY_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY );
+ if ( xAnalyzer.is() )
+ {
+ const Reference< XIndexAccess > xOrderColumns( xAnalyzer->getOrderColumns(), UNO_SET_THROW );
+ const sal_Int32 nOrderColumns( xOrderColumns->getCount() );
+ for ( sal_Int32 c=0; c<nOrderColumns; ++c )
+ {
+ const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW );
+ ::rtl::OUString sColumnName;
+ OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName);
+ ::rtl::OUString sTableName;
+ OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName);
+ (void)sColumnName;
+ (void)sTableName;
+ }
+ }
+ }
+
+ Reference< XWarningsSupplier > xWarnings( _rxLoadable, UNO_QUERY );
+ if ( xWarnings.is() )
+ {
+ SQLExceptionInfo aInfo( xWarnings->getWarnings() );
+ if ( aInfo.isValid() )
+ {
+ showError( aInfo );
+ impl_checkForCannotSelectUnfiltered( aInfo );
+ }
+ }
+
+ return _rxLoadable->isLoaded();
+}
+
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::initFormatter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::initFormatter" );
+ // ---------------------------------------------------------------
+ // create a formatter working with the connections format supplier
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,getORB()));
+
+ if(xSupplier.is())
+ {
+ // create a new formatter
+ m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (
+ getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ else // clear the formatter
+ m_xFormatter = NULL;
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::describeSupportedFeatures()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::describeSupportedFeatures" );
+ SbaXDataBrowserController_Base::describeSupportedFeatures();
+ implDescribeSupportedFeature( ".uno:FormSlots/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FormController/undoRecord", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:RecUndo", ID_BROWSER_UNDORECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FormSlots/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FormController/saveRecord", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:RecSave", ID_BROWSER_SAVERECORD, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVERECORD, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:RecSearch", SID_FM_SEARCH, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:AutoFilter", SID_FM_AUTOFILTER, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:Refresh", SID_FM_REFRESH, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:OrderCrit", SID_FM_ORDERCRIT, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:RemoveFilterSort", SID_FM_REMOVE_FILTER_SORT,CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FormFiltered", SID_FM_FORM_FILTERED, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FilterCrit", SID_FM_FILTERCRIT, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::CONTROLS );
+ implDescribeSupportedFeature( ".uno:FormSlots/deleteRecord", SID_FM_DELETEROWS, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:FormSlots/insertRecord", ID_BROWSER_INSERT_ROW, CommandGroup::INSERT );
+}
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::Construct(Window* pParent)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::Construct" );
+ // ---------------------------------------------
+ // create/initialize the form and the grid model
+ m_xRowSet = CreateForm();
+ if (!m_xRowSet.is())
+ return sal_False;
+
+ m_xColumnsSupplier.set(m_xRowSet,UNO_QUERY);
+ m_xLoadable.set(m_xRowSet,UNO_QUERY);
+
+ Reference< XPropertySet > xFormProperties( m_xRowSet, UNO_QUERY );
+ if ( !InitializeForm( xFormProperties ) )
+ return sal_False;
+
+ m_xGridModel = CreateGridModel();
+ if (!m_xGridModel.is())
+ return sal_False;
+
+ // set the formatter if available
+ initFormatter();
+ // ---------------------------------------------------------------
+
+ // we want to have a grid with a "flat" border
+ Reference< XPropertySet > xGridSet(m_xGridModel, UNO_QUERY);
+ if ( xGridSet.is() )
+ xGridSet->setPropertyValue(PROPERTY_BORDER, makeAny((sal_Int16)2));
+
+ // ----------
+ // marry them
+ Reference< ::com::sun::star::container::XNameContainer > xNameCont(m_xRowSet, UNO_QUERY);
+ {
+ String sText(ModuleRes(STR_DATASOURCE_GRIDCONTROL_NAME));
+ xNameCont->insertByName(::rtl::OUString(sText), makeAny(m_xGridModel));
+ }
+
+ // ---------------
+ // create the view
+ setView( * new UnoDataBrowserView( pParent, *this, getORB() ) );
+ if (!getBrowserView())
+ return sal_False;
+
+ // late construction
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ getBrowserView()->Construct(getControlModel());
+ bSuccess = sal_True;
+ }
+ catch(SQLException&)
+ {
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaXDataBrowserController::Construct : the construction of UnoDataBrowserView failed !");
+ }
+
+ if (!bSuccess)
+ {
+ // deleteView();
+ return sal_False;
+ }
+
+ // now that we have a view we can create the clipboard listener
+ m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
+ m_aSystemClipboard.StartClipboardListening( );
+
+ m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, SbaXDataBrowserController, OnClipboardChanged ) );
+ m_pClipbordNotifier->acquire();
+ m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
+
+ // this call create the toolbox
+ SbaXDataBrowserController_Base::Construct(pParent);
+
+ getBrowserView()->Show();
+
+ // set the callbacks for the grid control
+ SbaGridControl* pVclGrid = getBrowserView()->getVclControl();
+ OSL_ENSURE(pVclGrid, "SbaXDataBrowserController::Construct : have no VCL control !");
+ pVclGrid->SetMasterListener(this);
+
+ // --------------------------
+ // add listeners ...
+
+ // ... to the form model
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (xFormSet.is())
+ {
+ xFormSet->addPropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->addPropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
+ }
+ Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
+ if (xFormError.is())
+ xFormError->addSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
+
+ if (m_xLoadable.is())
+ m_xLoadable->addLoadListener(this);
+
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY);
+ if (xFormParameter.is())
+ xFormParameter->addParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
+
+ addModelListeners(getControlModel());
+ addControlListeners(getBrowserView()->getGridControl());
+
+ // -------------
+ // load the form
+ return LoadForm();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::LoadForm()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::LoadForm" );
+ reloadForm( m_xLoadable );
+ return sal_True;
+}
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::AddColumnListener(const Reference< XPropertySet > & /*xCol*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::AddColumnListener" );
+ // we're not interested in any column properties ...
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::RemoveColumnListener(const Reference< XPropertySet > & /*xCol*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::RemoveColumnListener" );
+}
+//------------------------------------------------------------------------------
+Reference< XRowSet > SbaXDataBrowserController::CreateForm()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CreateForm" );
+ return Reference< XRowSet > (getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.Form"))), UNO_QUERY);
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::form::XFormComponent > SbaXDataBrowserController::CreateGridModel()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CreateGridModel" );
+ return Reference< ::com::sun::star::form::XFormComponent > (getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.GridControl"))), UNO_QUERY);
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addModelListeners" );
+ // ... all the grid columns
+ addColumnListeners(_xGridControlModel);
+
+ // (we are interested in all columns the grid has (and only in these) so we have to listen to the container, too)
+ Reference< ::com::sun::star::container::XContainer > xColContainer(_xGridControlModel, UNO_QUERY);
+ if (xColContainer.is())
+ xColContainer->addContainerListener((::com::sun::star::container::XContainerListener*)this);
+
+ Reference< ::com::sun::star::form::XReset > xReset(_xGridControlModel, UNO_QUERY);
+ if (xReset.is())
+ xReset->addResetListener((::com::sun::star::form::XResetListener*)this);
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::removeModelListeners(const Reference< XControlModel > & _xGridControlModel)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::removeModelListeners" );
+ // every single column model
+ Reference< XIndexContainer > xColumns(_xGridControlModel, UNO_QUERY);
+ if (xColumns.is())
+ {
+ sal_Int32 nCount = xColumns->getCount();
+ for (sal_uInt16 i=0; i < nCount; ++i)
+ {
+ Reference< XPropertySet > xCol(xColumns->getByIndex(i),UNO_QUERY);
+ RemoveColumnListener(xCol);
+ }
+ }
+
+ Reference< XContainer > xColContainer(_xGridControlModel, UNO_QUERY);
+ if (xColContainer.is())
+ xColContainer->removeContainerListener( this );
+
+ Reference< XReset > xReset(_xGridControlModel, UNO_QUERY);
+ if (xReset.is())
+ xReset->removeResetListener( this );
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::addControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addControlListeners" );
+ // to ge the 'modified' for the current cell
+ Reference< XModifyBroadcaster > xBroadcaster(getBrowserView()->getGridControl(), UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
+
+ // introduce ourself as dispatch provider for the grid
+ Reference< XDispatchProviderInterception > xInterception(getBrowserView()->getGridControl(), UNO_QUERY);
+ if (xInterception.is())
+ xInterception->registerDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));
+
+ // add as focus listener to the control (needed for the form controller functionality)
+ Reference< XWindow > xWindow(_xGridControl, UNO_QUERY);
+ if (xWindow.is())
+ xWindow->addFocusListener(this);
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::removeControlListeners(const Reference< ::com::sun::star::awt::XControl > & _xGridControl)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::removeControlListeners" );
+ Reference< XModifyBroadcaster > xBroadcaster(_xGridControl, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
+
+ Reference< XDispatchProviderInterception > xInterception(_xGridControl, UNO_QUERY);
+ if (xInterception.is())
+ xInterception->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));
+
+ Reference< XWindow > xWindow(_xGridControl, UNO_QUERY);
+ if (xWindow.is())
+ xWindow->removeFocusListener(this);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::focusGained(const FocusEvent& /*e*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::focusGained" );
+ // notify our activate listeners (registered on the form controller aggregate)
+ EventObject aEvt(*this);
+ ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners);
+ while (aIter.hasMoreElements())
+ static_cast<XFormControllerListener*>(aIter.next())->formActivated(aEvt);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::focusLost(const FocusEvent& e) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::focusLost" );
+ // some general checks
+ if (!getBrowserView() || !getBrowserView()->getGridControl().is())
+ return;
+ Reference< XVclWindowPeer > xMyGridPeer(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
+ if (!xMyGridPeer.is())
+ return;
+ Reference< XWindowPeer > xNextControlPeer(e.NextFocus, UNO_QUERY);
+ if (!xNextControlPeer.is())
+ return;
+
+ // don't do a notification if it remains in the family (i.e. a child of the grid control gets the focus)
+ if (xMyGridPeer->isChild(xNextControlPeer))
+ return;
+
+ if (xMyGridPeer == xNextControlPeer)
+ return;
+
+ // notify the listeners that the "form" we represent has been deactivated
+ EventObject aEvt(*this);
+ ::cppu::OInterfaceIteratorHelper aIter(m_pFormControllerImpl->m_aActivateListeners);
+ while (aIter.hasMoreElements())
+ static_cast<XFormControllerListener*>(aIter.next())->formDeactivated(aEvt);
+
+ // commit the changes of the grid control (as we're deactivated)
+ Reference< XBoundComponent > xCommitable(getBrowserView()->getGridControl(), UNO_QUERY);
+ if (xCommitable.is())
+ xCommitable->commit();
+ else
+ OSL_FAIL("SbaXDataBrowserController::focusLost : why is my control not commitable ?");
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::disposingGridControl(const ::com::sun::star::lang::EventObject& /*Source*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingGridControl" );
+ removeControlListeners(getBrowserView()->getGridControl());
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::disposingGridModel(const ::com::sun::star::lang::EventObject& /*Source*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingGridModel" );
+ removeModelListeners(getControlModel());
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::disposingFormModel(const ::com::sun::star::lang::EventObject& Source)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingFormModel" );
+ Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY);
+ if (xSourceSet.is())
+ {
+ xSourceSet->removePropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
+ }
+
+ Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(Source.Source, UNO_QUERY);
+ if (xFormError.is())
+ xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
+
+ if (m_xLoadable.is())
+ m_xLoadable->removeLoadListener(this);
+
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(Source.Source, UNO_QUERY);
+ if (xFormParameter.is())
+ xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::disposingColumnModel(const ::com::sun::star::lang::EventObject& Source)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposingColumnModel" );
+ RemoveColumnListener(Reference< XPropertySet > (Source.Source, UNO_QUERY));
+}
+
+// -------------------------------------------------------------------------
+void SbaXDataBrowserController::disposing(const EventObject& Source) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::disposing" );
+ // if it's a component other than our aggregate, forward it to the aggregate
+ if ( m_xFormControllerImpl != Source.Source )
+ {
+ Reference< XEventListener > xAggListener;
+ m_xFormControllerImpl->queryAggregation( ::getCppuType( &xAggListener ) ) >>= xAggListener;
+ if ( xAggListener.is( ))
+ xAggListener->disposing( Source );
+ }
+
+ // is it the grid control ?
+ if (getBrowserView())
+ {
+ Reference< ::com::sun::star::awt::XControl > xSourceControl(Source.Source, UNO_QUERY);
+ if (xSourceControl == getBrowserView()->getGridControl())
+ disposingGridControl(Source);
+ }
+
+ // it's model (the container of the columns) ?
+ if (getControlModel() == Source.Source)
+ disposingGridModel(Source);
+
+ // the form's model ?
+ if ((getRowSet() == Source.Source))
+ disposingFormModel(Source);
+
+ // from a single column model ?
+ Reference< XPropertySet > xSourceSet(Source.Source, UNO_QUERY);
+ if (xSourceSet.is())
+ {
+ Reference< XPropertySetInfo > xInfo = xSourceSet->getPropertySetInfo();
+ // we assume that columns have a Width property and all other sets we are listening to don't have
+ if (xInfo->hasPropertyByName(PROPERTY_WIDTH))
+ disposingColumnModel(Source);
+ }
+ SbaXDataBrowserController_Base::OGenericUnoController::disposing( Source );
+}
+
+// -----------------------------------------------------------------------
+void SAL_CALL SbaXDataBrowserController::setIdentifier( const ::rtl::OUString& _Identifier ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setIdentifier" );
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_sModuleIdentifier = _Identifier;
+}
+
+// -----------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXDataBrowserController::getIdentifier( ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getIdentifier" );
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_sModuleIdentifier;
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::propertyChange(const PropertyChangeEvent& evt) throw ( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::propertyChange" );
+ Reference< XPropertySet > xSource(evt.Source, UNO_QUERY);
+ if (!xSource.is())
+ return;
+
+ SolarMutexGuard aGuard;
+ // the IsModified changed to sal_False ?
+ if ( (evt.PropertyName.equals(PROPERTY_ISMODIFIED))
+ && (::comphelper::getBOOL(evt.NewValue) == sal_False)
+ )
+ { // -> the current field isn't modified anymore, too
+ setCurrentModified( sal_False );
+ }
+
+ // switching to a new record ?
+ if ( (evt.PropertyName.equals(PROPERTY_ISNEW))
+ && (::comphelper::getBOOL(evt.NewValue) == sal_True)
+ )
+ {
+ if (::comphelper::getINT32(xSource->getPropertyValue(PROPERTY_ROWCOUNT)) == 0)
+ // if we're switching to a new record and didn't have any records before we need to invalidate
+ // all slots (as the cursor was invalid before the mode change and so the slots were disabled)
+ InvalidateAll();
+ }
+
+
+ if (evt.PropertyName.equals(PROPERTY_FILTER))
+ {
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ }
+ else if (evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE))
+ {
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ }
+ else if (evt.PropertyName.equals(PROPERTY_ORDER))
+ {
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ }
+
+ // a new record count ? -> may be our search availability has changed
+ if (evt.PropertyName.equals(PROPERTY_ROWCOUNT))
+ {
+ sal_Int32 nNewValue = 0, nOldValue = 0;
+ evt.NewValue >>= nNewValue;
+ evt.OldValue >>= nOldValue;
+ if((nOldValue == 0 && nNewValue != 0) || (nOldValue != 0 && nNewValue == 0))
+ InvalidateAll();
+ }
+}
+
+//------------------------------------------------------------------------
+void SbaXDataBrowserController::modified(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::modified" );
+ setCurrentModified( sal_True );
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::elementInserted(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementInserted" );
+ OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
+ "SbaXDataBrowserController::elementInserted: where did this come from (not from the grid model)?!");
+ Reference< XPropertySet > xNewColumn(evt.Element,UNO_QUERY);
+ if ( xNewColumn.is() )
+ AddColumnListener(xNewColumn);
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::elementRemoved(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementRemoved" );
+ OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
+ "SbaXDataBrowserController::elementRemoved: where did this come from (not from the grid model)?!");
+ Reference< XPropertySet > xOldColumn(evt.Element,UNO_QUERY);
+ if ( xOldColumn.is() )
+ RemoveColumnListener(xOldColumn);
+}
+
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::elementReplaced(const ::com::sun::star::container::ContainerEvent& evt) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::elementReplaced" );
+ OSL_ENSURE(Reference< XInterface >(evt.Source, UNO_QUERY).get() == Reference< XInterface >(getControlModel(), UNO_QUERY).get(),
+ "SbaXDataBrowserController::elementReplaced: where did this come from (not from the grid model)?!");
+ Reference< XPropertySet > xOldColumn(evt.ReplacedElement,UNO_QUERY);
+ if ( xOldColumn.is() )
+ RemoveColumnListener(xOldColumn);
+
+ Reference< XPropertySet > xNewColumn(evt.Element,UNO_QUERY);
+ if ( xNewColumn.is() )
+ AddColumnListener(xNewColumn);
+}
+
+// -----------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::suspend(sal_Bool /*bSuspend*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::suspend" );
+ OSL_ENSURE(m_nPendingLoadFinished == 0, "SbaXDataBrowserController::suspend : there shouldn't be a pending load !");
+
+ m_aAsyncGetCellFocus.CancelCall();
+ m_aAsyncDisplayError.CancelCall();
+ m_aAsyncInvalidateAll.CancelCall();
+
+ sal_Bool bSuccess = SaveModified();
+ return bSuccess;
+}
+// -----------------------------------------------------------------------
+void SbaXDataBrowserController::disposing()
+{
+ // the base class
+ SbaXDataBrowserController_Base::OGenericUnoController::disposing();
+
+ // the data source
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (xFormSet.is())
+ {
+ xFormSet->removePropertyChangeListener(PROPERTY_ISNEW, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_ISMODIFIED, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_ROWCOUNT, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_ACTIVECOMMAND, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_ORDER, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_FILTER, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_HAVING_CLAUSE, static_cast<XPropertyChangeListener*>(this));
+ xFormSet->removePropertyChangeListener(PROPERTY_APPLYFILTER, static_cast<XPropertyChangeListener*>(this));
+ }
+
+ Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
+ if (xFormError.is())
+ xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
+
+ if (m_xLoadable.is())
+ m_xLoadable->removeLoadListener(this);
+
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xFormParameter(getRowSet(), UNO_QUERY);
+ if (xFormParameter.is())
+ xFormParameter->removeParameterListener((::com::sun::star::form::XDatabaseParameterListener*)this);
+
+ removeModelListeners(getControlModel());
+
+ if ( getView() && m_pClipbordNotifier )
+ {
+ m_pClipbordNotifier->ClearCallbackLink();
+ m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
+ m_pClipbordNotifier->release();
+ m_pClipbordNotifier = NULL;
+ }
+
+ if (getBrowserView())
+ {
+ removeControlListeners(getBrowserView()->getGridControl());
+ // don't delete explicitly, this is done by the owner (and user) of this controller (me hopes ...)
+ clearView();
+ }
+
+ if(m_aInvalidateClipboard.IsActive())
+ m_aInvalidateClipboard.Stop();
+
+ // dispose the row set
+ try
+ {
+ ::comphelper::disposeComponent(m_xRowSet);
+
+ m_xRowSet = NULL;
+ m_xColumnsSupplier = NULL;
+ m_xLoadable = NULL;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xParser.clear();
+ // don't dispose, just reset - it's owned by the RowSet
+}
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::frameAction" );
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ SbaXDataBrowserController_Base::frameAction( aEvent );
+
+ if ( aEvent.Source == getFrame() )
+ switch ( aEvent.Action )
+ {
+ case FrameAction_FRAME_ACTIVATED:
+ case FrameAction_FRAME_UI_ACTIVATED:
+ // ensure that the active cell (if any) has the focus
+ m_aAsyncGetCellFocus.Call();
+ // start the clipboard timer
+ if (getBrowserView() && getBrowserView()->getVclControl() && !m_aInvalidateClipboard.IsActive())
+ {
+ m_aInvalidateClipboard.Start();
+ OnInvalidateClipboard( NULL );
+ }
+ break;
+ case FrameAction_FRAME_DEACTIVATING:
+ case FrameAction_FRAME_UI_DEACTIVATING:
+ // stop the clipboard invalidator
+ if (getBrowserView() && getBrowserView()->getVclControl() && m_aInvalidateClipboard.IsActive())
+ {
+ m_aInvalidateClipboard.Stop();
+ OnInvalidateClipboard( NULL );
+ }
+ // remove the "get cell focus"-event
+ m_aAsyncGetCellFocus.CancelCall();
+ break;
+ default:
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( SbaXDataBrowserController, OnAsyncDisplayError, void*, /* _pNotInterestedIn */ )
+{
+ if ( m_aCurrentError.isValid() )
+ {
+ OSQLMessageBox aDlg( getBrowserView(), m_aCurrentError );
+ aDlg.Execute();
+ }
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::errorOccurred" );
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ SQLExceptionInfo aInfo( aEvent.Reason );
+ if ( !aInfo.isValid() )
+ return;
+
+ if ( m_nFormActionNestingLevel )
+ {
+ OSL_ENSURE( !m_aCurrentError.isValid(), "SbaXDataBrowserController::errorOccurred: can handle one error per transaction only!" );
+ m_aCurrentError = aInfo;
+ }
+ else
+ {
+ m_aCurrentError = aInfo;
+ m_aAsyncDisplayError.Call();
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::approveParameter" );
+ if (aEvent.Source != getRowSet())
+ {
+ // not my data source -> allow anything
+ OSL_FAIL("SbaXDataBrowserController::approveParameter : invalid event source !");
+ return sal_True;
+ }
+
+ Reference< ::com::sun::star::container::XIndexAccess > xParameters = aEvent.Parameters;
+ SolarMutexGuard aSolarGuard;
+
+ // default handling: instantiate an interaction handler and let it handle the parameter request
+ try
+ {
+ // two continuations allowed: OK and Cancel
+ OParameterContinuation* pParamValues = new OParameterContinuation;
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ // the request
+ ParametersRequest aRequest;
+ aRequest.Parameters = xParameters;
+ aRequest.Connection = getConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
+ OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xParamRequest(pParamRequest);
+ // some knittings
+ pParamRequest->addContinuation(pParamValues);
+ pParamRequest->addContinuation(pAbort);
+
+ // create the handler, let it handle the request
+ Reference< XInteractionHandler > xHandler(getORB()->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY);
+ if (xHandler.is())
+ xHandler->handle(xParamRequest);
+
+ if (!pParamValues->wasSelected())
+ { // canceled
+ setLoadingCancelled();
+ return sal_False;
+ }
+
+ // transfer the values into the parameter supplier
+ Sequence< PropertyValue > aFinalValues = pParamValues->getValues();
+ if (aFinalValues.getLength() != aRequest.Parameters->getCount())
+ {
+ OSL_FAIL("SbaXDataBrowserController::approveParameter: the InteractionHandler returned nonsense!");
+ setLoadingCancelled();
+ return sal_False;
+ }
+ const PropertyValue* pFinalValues = aFinalValues.getConstArray();
+ for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
+ {
+ Reference< XPropertySet > xParam;
+ ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i));
+ OSL_ENSURE(xParam.is(), "SbaXDataBrowserController::approveParameter: one of the parameters is no property set!");
+ if (xParam.is())
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sName;
+ xParam->getPropertyValue(PROPERTY_NAME) >>= sName;
+ OSL_ENSURE(sName.equals(pFinalValues->Name), "SbaXDataBrowserController::approveParameter: suspicious value names!");
+#endif
+ try { xParam->setPropertyValue(PROPERTY_VALUE, pFinalValues->Value); }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaXDataBrowserController::approveParameter: setting one of the properties failed!");
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_True;
+}
+
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::approveReset(const ::com::sun::star::lang::EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::approveReset" );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::resetted" );
+ OSL_ENSURE(rEvent.Source == getControlModel(), "SbaXDataBrowserController::resetted : where did this come from ?");
+ (void)rEvent;
+ setCurrentModified( sal_False );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::confirmDelete" );
+ if (QueryBox(getBrowserView(), ModuleRes(QUERY_BRW_DELETE_ROWS)).Execute() != RET_YES)
+ return sal_False;
+
+ return sal_True;
+}
+//------------------------------------------------------------------------------
+FeatureState SbaXDataBrowserController::GetState(sal_uInt16 nId) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::GetState" );
+ FeatureState aReturn;
+ // (disabled automatically)
+
+ try
+ {
+ // no chance without a view
+ if (!getBrowserView() || !getBrowserView()->getVclControl())
+ return aReturn;
+
+ switch (nId)
+ {
+ case ID_BROWSER_REMOVEFILTER:
+ if (!m_xParser.is())
+ {
+ aReturn.bEnabled = false;
+ return aReturn;
+ }
+ // any filter or sort order set ?
+ aReturn.bEnabled = m_xParser->getFilter().getLength() || m_xParser->getHavingClause().getLength() || m_xParser->getOrder().getLength();
+ return aReturn;
+ }
+ // no chance without valid models
+ if (isValid() && !isValidCursor())
+ return aReturn;
+
+ switch (nId)
+ {
+ case ID_BROWSER_SEARCH:
+ {
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ sal_Int32 nCount = ::comphelper::getINT32(xFormSet->getPropertyValue(PROPERTY_ROWCOUNT));
+ aReturn.bEnabled = nCount != 0;
+ }
+ break;
+ case ID_BROWSER_INSERT_ROW:
+ {
+ // check if it is available
+ sal_Bool bInsertPrivilege = ( m_nRowSetPrivileges & Privilege::INSERT) != 0;
+ sal_Bool bAllowInsertions = sal_True;
+ try
+ {
+ Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
+ OSL_VERIFY( xRowSetProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowInserts")) ) >>= bAllowInsertions );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ aReturn.bEnabled = bInsertPrivilege && bAllowInsertions;
+ }
+ break;
+ case SID_FM_DELETEROWS:
+ {
+ // check if it is available
+ sal_Bool bDeletePrivilege = ( m_nRowSetPrivileges & Privilege::INSERT) != 0;
+ sal_Bool bAllowDeletions = sal_True;
+ sal_Int32 nRowCount = 0;
+ sal_Bool bInsertionRow = sal_False;
+ try
+ {
+ Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
+ OSL_VERIFY( xRowSetProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowDeletes")) ) >>= bAllowDeletions );
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ROWCOUNT ) >>= nRowCount );
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ISNEW ) >>= bInsertionRow );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ aReturn.bEnabled = bDeletePrivilege && bAllowDeletions && ( nRowCount != 0 ) && !bInsertionRow;
+ }
+ break;
+
+ case ID_BROWSER_COPY:
+ if ( getBrowserView()->getVclControl()->GetSelectRowCount() )
+ {
+ aReturn.bEnabled = m_aCurrentFrame.isActive();
+ break;
+ }
+ // run through
+ case ID_BROWSER_PASTE:
+ case ID_BROWSER_CUT:
+ {
+ CellControllerRef xCurrentController = getBrowserView()->getVclControl()->Controller();
+ if (xCurrentController.Is() && xCurrentController->ISA(EditCellController))
+ {
+ Edit& rEdit = (Edit&)xCurrentController->GetWindow();
+ sal_Bool bHasLen = (rEdit.GetSelection().Len() != 0);
+ sal_Bool bIsReadOnly = rEdit.IsReadOnly();
+ switch (nId)
+ {
+ case ID_BROWSER_CUT: aReturn.bEnabled = m_aCurrentFrame.isActive() && bHasLen && !bIsReadOnly; break;
+ case SID_COPY : aReturn.bEnabled = m_aCurrentFrame.isActive() && bHasLen; break;
+ case ID_BROWSER_PASTE:
+ aReturn.bEnabled = m_aCurrentFrame.isActive() && !bIsReadOnly;
+ if(aReturn.bEnabled)
+ {
+ aReturn.bEnabled = aReturn.bEnabled && IsFormatSupported( m_aSystemClipboard.GetDataFlavorExVector(), FORMAT_STRING );
+ }
+ break;
+ }
+ }
+ }
+ break;
+
+ case ID_BROWSER_SORTUP:
+ case ID_BROWSER_SORTDOWN:
+ case ID_BROWSER_AUTOFILTER:
+ {
+ // a native statement can't be filtered or sorted
+ const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() )
+ break;
+
+ Reference< XPropertySet > xCurrentField = getBoundField();
+ if (!xCurrentField.is())
+ break;
+
+ aReturn.bEnabled = ::comphelper::getBOOL(xCurrentField->getPropertyValue(PROPERTY_ISSEARCHABLE));
+ const Reference< XRowSet > xRow = getRowSet();
+ aReturn.bEnabled = aReturn.bEnabled
+ && xRow.is()
+ && !xRow->isBeforeFirst()
+ && !xRow->isAfterLast()
+ && !xRow->rowDeleted()
+ && ( ::comphelper::getINT32( xFormSet->getPropertyValue( PROPERTY_ROWCOUNT ) ) != 0 );
+ }
+ break;
+
+ case ID_BROWSER_FILTERCRIT:
+ if ( m_bCannotSelectUnfiltered && m_xParser.is() )
+ {
+ aReturn.bEnabled = sal_True;
+ break;
+ }
+ // no break
+ case ID_BROWSER_ORDERCRIT:
+ {
+ const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if ( !::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || !m_xParser.is() )
+ break;
+
+ aReturn.bEnabled = getRowSet().is()
+ && ( ::comphelper::getINT32( xFormSet->getPropertyValue( PROPERTY_ROWCOUNT ) ) != 0 );
+ }
+ break;
+
+ case ID_BROWSER_REFRESH:
+ aReturn.bEnabled = sal_True;
+ break;
+
+ case ID_BROWSER_REDO:
+ aReturn.bEnabled = sal_False; // simply forget it ;). no redo possible.
+ break;
+
+ case ID_BROWSER_UNDORECORD:
+ case ID_BROWSER_SAVERECORD:
+ {
+ if (!m_bCurrentlyModified)
+ {
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (xFormSet.is())
+ aReturn.bEnabled = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED));
+ }
+ else
+ aReturn.bEnabled = sal_True;
+
+ aReturn.sTitle = (ID_BROWSER_UNDORECORD == nId) ? m_sStateUndoRecord : m_sStateSaveRecord;
+ }
+ break;
+ case ID_BROWSER_EDITDOC:
+ {
+ // check if it is available
+ Reference< XPropertySet > xDataSourceSet(getRowSet(), UNO_QUERY);
+ if (!xDataSourceSet.is())
+ break; // no datasource -> no edit mode
+
+ sal_Int32 nDataSourcePrivileges = ::comphelper::getINT32(xDataSourceSet->getPropertyValue(PROPERTY_PRIVILEGES));
+ sal_Bool bInsertAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::INSERT) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowInserts"))));
+ sal_Bool bUpdateAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::UPDATE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowUpdates"))));
+ sal_Bool bDeleteAllowedAndPossible = ((nDataSourcePrivileges & ::com::sun::star::sdbcx::Privilege::DELETE) != 0) && ::comphelper::getBOOL(xDataSourceSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowDeletes"))));
+ if (!bInsertAllowedAndPossible && !bUpdateAllowedAndPossible && !bDeleteAllowedAndPossible)
+ break; // no insert/update/delete -> no edit mode
+
+ if (!isValidCursor() || !isLoaded())
+ break; // no cursor -> no edit mode
+
+ aReturn.bEnabled = sal_True;
+
+ sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions();
+ aReturn.bChecked = nGridMode > DbGridControl::OPT_READONLY;
+ }
+ break;
+ case ID_BROWSER_FILTERED:
+ {
+ aReturn.bEnabled = sal_False;
+ Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY);
+ ::rtl::OUString aFilter = ::comphelper::getString(xActiveSet->getPropertyValue(PROPERTY_FILTER));
+ ::rtl::OUString aHaving = ::comphelper::getString(xActiveSet->getPropertyValue(PROPERTY_HAVING_CLAUSE));
+ if ( aFilter.getLength() || aHaving.getLength() )
+ {
+ xActiveSet->getPropertyValue( PROPERTY_APPLYFILTER ) >>= aReturn.bChecked;
+ aReturn.bEnabled = sal_True;
+ }
+ else
+ {
+ aReturn.bChecked = sal_False;
+ aReturn.bEnabled = sal_False;
+ }
+ }
+ break;
+ default:
+ return SbaXDataBrowserController_Base::GetState(nId);
+ }
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::applyParserOrder(const ::rtl::OUString& _rOldOrder,const Reference< XSingleSelectQueryComposer >& _xParser)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserOrder" );
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (!m_xLoadable.is())
+ {
+ OSL_FAIL("SbaXDataBrowserController::applyParserOrder: invalid row set!");
+ return;
+ }
+
+ sal_uInt16 nPos = getCurrentColumnPosition();
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_xParser->getOrder()));
+ bSuccess = reloadForm(m_xLoadable);
+ }
+ catch(Exception&)
+ {
+ }
+
+ if (!bSuccess)
+ {
+ xFormSet->setPropertyValue(PROPERTY_ORDER, makeAny(_rOldOrder));
+
+ try
+ {
+ if (loadingCancelled() || !reloadForm(m_xLoadable))
+ criticalFail();
+ }
+ catch(Exception&)
+ {
+ criticalFail();
+ }
+ InvalidateAll();
+ }
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+
+ setCurrentColumnPosition(nPos);
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const Reference< XSingleSelectQueryComposer >& _xParser)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::applyParserFilter" );
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (!m_xLoadable.is())
+ {
+ OSL_FAIL("SbaXDataBrowserController::applyParserFilter: invalid row set!");
+ return;
+ }
+
+ sal_uInt16 nPos = getCurrentColumnPosition();
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ FormErrorHelper aError(this);
+ xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_xParser->getFilter()));
+ xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_xParser->getHavingClause()));
+ xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+
+ bSuccess = reloadForm(m_xLoadable);
+ }
+ catch(Exception&)
+ {
+ }
+
+ if (!bSuccess)
+ {
+ xFormSet->setPropertyValue(PROPERTY_FILTER, makeAny(_rOldFilter));
+ xFormSet->setPropertyValue(PROPERTY_HAVING_CLAUSE, makeAny(_sOldHaving));
+ xFormSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(_bOldFilterApplied));
+
+ try
+ {
+ if (loadingCancelled() || !reloadForm(m_xLoadable))
+ criticalFail();
+ }
+ catch(Exception&)
+ {
+ criticalFail();
+ }
+ InvalidateAll();
+ }
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+
+ setCurrentColumnPosition(nPos);
+}
+
+//------------------------------------------------------------------------------
+Reference< XSingleSelectQueryComposer > SbaXDataBrowserController::createParser_nothrow()
+{
+ Reference< XSingleSelectQueryComposer > xComposer;
+ try
+ {
+ const Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
+ const Reference< XMultiServiceFactory > xFactory(
+ xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY_THROW );
+ xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sActiveCommand;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sActiveCommand );
+ if ( sActiveCommand.getLength() > 0 )
+ {
+ xComposer->setElementaryQuery( sActiveCommand );
+ }
+ else
+ {
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND_TYPE ) >>= nCommandType );
+ xComposer->setCommand( sCommand, nCommandType );
+ }
+
+ ::rtl::OUString sFilter;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_FILTER ) >>= sFilter );
+ xComposer->setFilter( sFilter );
+
+ ::rtl::OUString sHavingClause;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_HAVING_CLAUSE ) >>= sHavingClause );
+ xComposer->setHavingClause( sHavingClause );
+
+ ::rtl::OUString sOrder;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ORDER ) >>= sOrder );
+ xComposer->setOrder( sOrder );
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xComposer;
+}
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::ExecuteFilterSortCrit(sal_Bool bFilter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ExecuteFilterSortCrit" );
+ if (!SaveModified())
+ return;
+
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+
+ const ::rtl::OUString sOldVal = bFilter ? m_xParser->getFilter() : m_xParser->getOrder();
+ const ::rtl::OUString sOldHaving = m_xParser->getHavingClause();
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
+ try
+ {
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSup = getColumnsSupplier();
+ Reference< XConnection> xCon(xFormSet->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+ if(bFilter)
+ {
+ DlgFilterCrit aDlg( getBrowserView(), getORB(), xCon, xParser, xSup->getColumns() );
+ String aFilter;
+ if ( !aDlg.Execute() )
+ return; // if so we don't need to update the grid
+ aDlg.BuildWherePart();
+ }
+ else
+ {
+ DlgOrderCrit aDlg( getBrowserView(),xCon,xParser,xSup->getColumns() );
+ String aOrder;
+ if(!aDlg.Execute())
+ {
+ return; // if so we don't need to actualize the grid
+ }
+ aDlg.BuildOrderPart();
+ }
+ }
+ catch(const SQLException& )
+ {
+ SQLExceptionInfo aError( ::cppu::getCaughtException() );
+ showError( aError );
+ return;
+ }
+ catch(Exception&)
+ {
+ return;
+ }
+
+ ::rtl::OUString sNewVal = bFilter ? xParser->getFilter() : xParser->getOrder();
+ sal_Bool bOldFilterApplied(sal_False);
+ if (bFilter)
+ {
+ try { bOldFilterApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER)); } catch(Exception&) { } ;
+ }
+
+ ::rtl::OUString sNewHaving = xParser->getHavingClause();
+ if ( sOldVal.equals(sNewVal) && (!bFilter || sOldHaving.equals(sNewHaving)) )
+ // nothing to be done
+ return;
+
+ if (bFilter)
+ applyParserFilter(sOldVal, bOldFilterApplied,sOldHaving,xParser);
+ else
+ applyParserOrder(sOldVal,xParser);
+
+ ::comphelper::disposeComponent(xParser);
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::ExecuteSearch()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ExecuteSearch" );
+ // calculate the control source of the active field
+ Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
+ OSL_ENSURE(xGrid.is(), "SbaXDataBrowserController::ExecuteSearch : the control should have an ::com::sun::star::form::XGrid interface !");
+
+ Reference< ::com::sun::star::form::XGridPeer > xGridPeer(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns = xGridPeer->getColumns();
+ OSL_ENSURE(xGridPeer.is() && xColumns.is(), "SbaXDataBrowserController::ExecuteSearch : invalid peer !");
+
+ sal_Int16 nViewCol = xGrid->getCurrentColumnPosition();
+ sal_Int16 nModelCol = getBrowserView()->View2ModelPos(nViewCol);
+
+ Reference< XPropertySet > xCurrentCol(xColumns->getByIndex(nModelCol),UNO_QUERY);
+ String sActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(PROPERTY_CONTROLSOURCE));
+
+ // the text within the current cell
+ String sInitialText;
+ Reference< ::com::sun::star::container::XIndexAccess > xColControls(xGridPeer, UNO_QUERY);
+ Reference< XInterface > xCurControl(xColControls->getByIndex(nViewCol),UNO_QUERY);
+ ::rtl::OUString aInitialText;
+ if (IsSearchableControl(xCurControl, &aInitialText))
+ sInitialText = aInitialText;
+
+ // prohibit the synchronization of the grid's display with the cursor's position
+ Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
+ OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::ExecuteSearch : no model set ?!");
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CursorColor")), makeAny(sal_Int32(COL_LIGHTRED)));
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xNFS(::dbtools::getNumberFormats(::dbtools::getConnection(m_xRowSet), sal_True,getORB()));
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ AbstractFmSearchDialog* pDialog = NULL;
+ if ( pFact )
+ {
+ ::std::vector< String > aContextNames;
+ aContextNames.push_back( String::CreateFromAscii("Standard") );
+ pDialog = pFact->CreateFmSearchDialog(getBrowserView(), sInitialText, aContextNames, 0, LINK(this, SbaXDataBrowserController, OnSearchContextRequest));
+ }
+ OSL_ENSURE( pDialog, "SbaXDataBrowserController::ExecuteSearch: could not get the search dialog!" );
+ if ( pDialog )
+ {
+ pDialog->SetActiveField( sActiveField );
+ pDialog->SetFoundHandler( LINK( this, SbaXDataBrowserController, OnFoundData ) );
+ pDialog->SetCanceledNotFoundHdl( LINK( this, SbaXDataBrowserController, OnCanceledNotFound ) );
+ pDialog->Execute();
+ delete pDialog;
+ }
+
+ // restore the grid's normal operating state
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor")), ::comphelper::makeBoolAny(sal_Bool(sal_False)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CursorColor")), Any());
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& _rArgs)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::Execute" );
+ sal_Bool bSortUp = sal_True;
+
+ switch (nId)
+ {
+ default:
+ SbaXDataBrowserController_Base::Execute( nId, _rArgs );
+ return;
+
+ case ID_BROWSER_INSERT_ROW:
+ try
+ {
+ if (SaveModified())
+ {
+ getRowSet()->afterLast();
+ // check if it is available
+ Reference< XResultSetUpdate > xUpdateCursor(getRowSet(), UNO_QUERY_THROW);
+ xUpdateCursor->moveToInsertRow();
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("Exception caught!");
+ }
+ break;
+ case SID_FM_DELETEROWS:
+
+ if (SaveModified())
+ {
+ SbaGridControl* pVclGrid = getBrowserView()->getVclControl();
+ if ( pVclGrid )
+ {
+ if( !pVclGrid->GetSelectRowCount() )
+ {
+ pVclGrid->DeactivateCell();
+ pVclGrid->SelectRow(pVclGrid->GetCurRow());
+ }
+ pVclGrid->DeleteSelectedRows();
+ }
+ }
+ break;
+
+ case ID_BROWSER_FILTERED:
+ if (SaveModified())
+ {
+ Reference< XPropertySet > xActiveSet(getRowSet(), UNO_QUERY);
+ sal_Bool bApplied = ::comphelper::getBOOL(xActiveSet->getPropertyValue(PROPERTY_APPLYFILTER));
+ xActiveSet->setPropertyValue(PROPERTY_APPLYFILTER, ::comphelper::makeBoolAny(sal_Bool(!bApplied)));
+ reloadForm(m_xLoadable);
+ }
+ InvalidateFeature(ID_BROWSER_FILTERED);
+ break;
+ case ID_BROWSER_EDITDOC:
+ {
+ sal_Int16 nGridMode = getBrowserView()->getVclControl()->GetOptions();
+ if (nGridMode == DbGridControl::OPT_READONLY)
+ getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_UPDATE | DbGridControl::OPT_INSERT | DbGridControl::OPT_DELETE);
+ // the options not supported by the data source will be removed automatically
+ else
+ {
+ if ( !SaveModified( ) )
+ // give the user a chance to save the current record (if neccessary)
+ break;
+
+ // maybe the user wanted to reject the modified record ?
+ if (GetState(ID_BROWSER_UNDORECORD).bEnabled)
+ Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>());
+
+ getBrowserView()->getVclControl()->SetOptions(DbGridControl::OPT_READONLY);
+ }
+ InvalidateFeature(ID_BROWSER_EDITDOC);
+ }
+ break;
+
+ case ID_BROWSER_SEARCH:
+ if ( SaveModified( ) )
+ ExecuteSearch();
+ break;
+
+ case ID_BROWSER_COPY:
+ if ( getBrowserView()->getVclControl()->GetSelectRowCount() > 0 )
+ {
+ getBrowserView()->getVclControl()->CopySelectedRowsToClipboard();
+ break;
+ }
+ // run through
+ case ID_BROWSER_CUT:
+ case ID_BROWSER_PASTE:
+ {
+ CellControllerRef xCurrentController = getBrowserView()->getVclControl()->Controller();
+ if (!xCurrentController.Is())
+ // should be intercepted by GetState. Normally.
+ // Unfortunately ID_BROWSER_PASTE is a 'fast call' slot, which means it may be executed without checking if it is
+ // enabled. This would be really deadly herein if the current cell has no controller ...
+ return;
+
+ Edit& rEdit = (Edit&)xCurrentController->GetWindow();
+ switch (nId)
+ {
+ case ID_BROWSER_CUT : rEdit.Cut(); break;
+ case SID_COPY : rEdit.Copy(); break;
+ case ID_BROWSER_PASTE : rEdit.Paste(); break;
+ }
+ if (ID_BROWSER_CUT == nId || ID_BROWSER_PASTE == nId)
+ {
+ xCurrentController->SetModified();
+ rEdit.Modify();
+ }
+ }
+ break;
+
+ case ID_BROWSER_SORTDOWN:
+ bSortUp = sal_False;
+ // DON'T break
+ case ID_BROWSER_SORTUP:
+ {
+ if (!SaveModified())
+ break;
+
+ if (!isValidCursor())
+ break;
+
+ // only one sort order
+ Reference< XPropertySet > xField(getBoundField(), UNO_QUERY);
+ if (!xField.is())
+ break;
+
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
+ const ::rtl::OUString sOldSort = xParser->getOrder();
+ sal_Bool bParserSuccess = sal_False;
+ HANDLE_SQL_ERRORS(
+ xParser->setOrder(::rtl::OUString()); xParser->appendOrderByColumn(xField, bSortUp),
+ bParserSuccess,
+ UniString(ModuleRes(SBA_BROWSER_SETTING_ORDER)),
+ "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
+ )
+
+ if (bParserSuccess)
+ applyParserOrder(sOldSort,xParser);
+ }
+ break;
+
+ case ID_BROWSER_AUTOFILTER:
+ {
+ if (!SaveModified())
+ break;
+
+ if (!isValidCursor())
+ break;
+
+ Reference< XPropertySet > xField(getBoundField(), UNO_QUERY);
+ if (!xField.is())
+ break;
+
+ // check if the column is a aggregate function
+ sal_Bool bHaving = sal_False;
+ ::rtl::OUString sName;
+ xField->getPropertyValue(PROPERTY_NAME) >>= sName;
+ Reference< XColumnsSupplier > xColumnsSupplier(m_xParser, UNO_QUERY);
+ Reference< ::com::sun::star::container::XNameAccess > xCols = xColumnsSupplier.is() ? xColumnsSupplier->getColumns() : Reference< ::com::sun::star::container::XNameAccess > ();
+ if ( xCols.is() && xCols->hasByName(sName) )
+ {
+ Reference<XPropertySet> xProp(xCols->getByName(sName),UNO_QUERY);
+ static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
+ if ( xProp->getPropertySetInfo()->hasPropertyByName(sAgg) )
+ xProp->getPropertyValue(sAgg) >>= bHaving;
+ }
+
+ Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow();
+ const ::rtl::OUString sOldFilter = xParser->getFilter();
+ const ::rtl::OUString sOldHaving = xParser->getHavingClause();
+
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ sal_Bool bApplied = ::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_APPLYFILTER));
+ // do we have a filter but it's not applied ?
+ // -> completely overwrite it, else append one
+ if (!bApplied)
+ {
+ DO_SAFE( (bHaving ? xParser->setHavingClause(::rtl::OUString()) : xParser->setFilter(::rtl::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" );
+ }
+
+ sal_Bool bParserSuccess = sal_False;
+
+ sal_Int32 nOp = SQLFilterOperator::EQUAL;
+ if ( xField.is() )
+ {
+ sal_Int32 nType = 0;
+ xField->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ case DataType::LONGVARCHAR:
+ nOp = SQLFilterOperator::LIKE;
+ break;
+ default:
+ nOp = SQLFilterOperator::EQUAL;
+ }
+ }
+
+ if ( bHaving )
+ {
+ HANDLE_SQL_ERRORS(
+ xParser->appendHavingClauseByColumn(xField,sal_True,nOp),
+ bParserSuccess,
+ UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)),
+ "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
+ )
+ }
+ else
+ {
+ HANDLE_SQL_ERRORS(
+ xParser->appendFilterByColumn(xField,sal_True,nOp),
+ bParserSuccess,
+ UniString(ModuleRes(SBA_BROWSER_SETTING_FILTER)),
+ "SbaXDataBrowserController::Execute : caught an exception while composing the new filter !"
+ )
+ }
+
+ if (bParserSuccess)
+ applyParserFilter(sOldFilter, bApplied,sOldHaving,xParser);
+
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ InvalidateFeature(ID_BROWSER_FILTERED);
+ }
+ break;
+
+ case ID_BROWSER_ORDERCRIT:
+ ExecuteFilterSortCrit(sal_False);
+ break;
+
+ case ID_BROWSER_FILTERCRIT:
+ ExecuteFilterSortCrit(sal_True);
+ InvalidateFeature(ID_BROWSER_FILTERED);
+ break;
+
+ case ID_BROWSER_REMOVEFILTER:
+ {
+ if (!SaveModified())
+ break;
+
+ sal_Bool bNeedPostReload = preReloadForm();
+ // reset the filter and the sort property simutaneously so only _one_ new statement has to be
+ // sent
+ Reference< XPropertySet > xSet(getRowSet(), UNO_QUERY);
+ if ( xSet.is() )
+ {
+ xSet->setPropertyValue(PROPERTY_FILTER,makeAny(::rtl::OUString()));
+ xSet->setPropertyValue(PROPERTY_HAVING_CLAUSE,makeAny(::rtl::OUString()));
+ xSet->setPropertyValue(PROPERTY_ORDER,makeAny(::rtl::OUString()));
+ }
+ try
+ {
+ reloadForm(m_xLoadable);
+ if ( bNeedPostReload )
+ postReloadForm();
+ }
+ catch(Exception&)
+ {
+ }
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+ InvalidateFeature(ID_BROWSER_FILTERED);
+ }
+ break;
+
+ case ID_BROWSER_REFRESH:
+ if ( SaveModified( ) )
+ {
+ if (!reloadForm(m_xLoadable))
+ criticalFail();
+ }
+ break;
+
+ case ID_BROWSER_SAVERECORD:
+ if ( SaveModified( sal_False ) )
+ setCurrentModified( sal_False );
+ break;
+
+ case ID_BROWSER_UNDORECORD:
+ {
+ try
+ {
+ // restore the cursor state
+ Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY);
+ Reference< XPropertySet > xSet(xCursor, UNO_QUERY);
+ Any aVal = xSet->getPropertyValue(PROPERTY_ISNEW);
+ if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
+ {
+ xCursor->moveToInsertRow();
+ // no need to reset the grid model after we moved to the insert row, this is done implicitly by the
+ // form
+ // (and in some cases it may be deadly to do the reset explicitly after the form did it implicitly,
+ // cause the form's reset may be async, and this leads to some nice deadlock scenarios ....)
+ }
+ else
+ {
+ xCursor->cancelRowUpdates();
+
+ // restore the grids state
+ Reference< ::com::sun::star::form::XReset > xReset(getControlModel(), UNO_QUERY);
+ if (xReset.is())
+ xReset->reset();
+ }
+ }
+ catch(SQLException&)
+ {
+ }
+
+ setCurrentModified( sal_False );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::SaveModified(sal_Bool bAskFor)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SaveModified" );
+ if ( bAskFor && GetState(ID_BROWSER_SAVERECORD).bEnabled )
+ {
+ getBrowserView()->getVclControl()->GrabFocus();
+
+ QueryBox aQry(getBrowserView()->getVclControl(), ModuleRes(QUERY_BRW_SAVEMODIFIED));
+
+ switch (aQry.Execute())
+ {
+ case RET_NO:
+ Execute(ID_BROWSER_UNDORECORD,Sequence<PropertyValue>());
+ return sal_True;
+ case RET_CANCEL:
+ return sal_False;
+ }
+ }
+
+ if ( !CommitCurrent() ) // das aktuelle Control committen lassen
+ return sal_False;
+
+ Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ sal_Bool bResult = sal_False;
+ try
+ {
+ if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISMODIFIED)))
+ {
+ Reference< XResultSetUpdate > xCursor(getRowSet(), UNO_QUERY);
+ if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ISNEW)))
+ xCursor->insertRow();
+ else
+ xCursor->updateRow();
+ }
+ bResult = sal_True;
+ }
+ catch(SQLException&)
+ {
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaXDataBrowserController::SaveModified : could not save the current record !");
+ bResult = sal_False;
+ }
+
+ InvalidateFeature(ID_BROWSER_SAVERECORD);
+ InvalidateFeature(ID_BROWSER_UNDORECORD);
+ return bResult;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::CommitCurrent()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CommitCurrent" );
+ if (!getBrowserView())
+ return sal_True;
+
+ Reference< ::com::sun::star::awt::XControl > xActiveControl(getBrowserView()->getGridControl());
+ Reference< ::com::sun::star::form::XBoundControl > xLockingTest(xActiveControl, UNO_QUERY);
+ sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock();
+ if (xActiveControl.is() && !bControlIsLocked)
+ {
+ // zunaechst das Control fragen ob es das IFace unterstuetzt
+ Reference< ::com::sun::star::form::XBoundComponent > xBoundControl(xActiveControl, UNO_QUERY);
+ if (!xBoundControl.is())
+ xBoundControl = Reference< ::com::sun::star::form::XBoundComponent > (xActiveControl->getModel(), UNO_QUERY);
+ if (xBoundControl.is() && !xBoundControl->commit())
+ return sal_False;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::setCurrentModified( sal_Bool _bSet )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setCurrentModified" );
+ m_bCurrentlyModified = _bSet;
+ InvalidateFeature( ID_BROWSER_SAVERECORD );
+ InvalidateFeature( ID_BROWSER_UNDORECORD );
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::RowChanged()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::RowChanged" );
+ setCurrentModified( sal_False );
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::ColumnChanged()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::ColumnChanged" );
+ InvalidateFeature(ID_BROWSER_SORTUP);
+ InvalidateFeature(ID_BROWSER_SORTDOWN);
+ InvalidateFeature(ID_BROWSER_ORDERCRIT);
+ InvalidateFeature(ID_BROWSER_FILTERCRIT);
+ InvalidateFeature(ID_BROWSER_AUTOFILTER);
+ InvalidateFeature(ID_BROWSER_REMOVEFILTER);
+
+ setCurrentModified( sal_False );
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::SelectionChanged()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SelectionChanged" );
+ // not interested in
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::CellActivated()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CellActivated" );
+ m_aInvalidateClipboard.Start();
+ OnInvalidateClipboard( NULL );
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::CellDeactivated()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::CellDeactivated" );
+ m_aInvalidateClipboard.Stop();
+ OnInvalidateClipboard( NULL );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( SbaXDataBrowserController, OnClipboardChanged, void*, EMPTYARG )
+{
+ SolarMutexGuard aGuard;
+ return OnInvalidateClipboard( NULL );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaXDataBrowserController, OnInvalidateClipboard, AutoTimer*, _pTimer)
+{
+ InvalidateFeature(ID_BROWSER_CUT);
+ InvalidateFeature(ID_BROWSER_COPY);
+
+ // if the invalidation was triggered by the timer, we do not need to invalidate PASTE.
+ // The timer is only for checking the CUT/COPY slots regulariry, which depend on the
+ // selection state of the active cell
+ // TODO: get a callback at the Edit which allows to be notified when the selection
+ // changes. This would be much better than this cycle-eating polling mechanism here ....
+ if ( _pTimer != &m_aInvalidateClipboard )
+ InvalidateFeature(ID_BROWSER_PASTE);
+
+ return 0L;
+}
+
+// -------------------------------------------------------------------------
+Reference< XPropertySet > SbaXDataBrowserController::getBoundField(sal_uInt16 nViewPos) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::SaveData" );
+ Reference< XPropertySet > xEmptyReturn;
+
+ // get the current column from the grid
+ if (nViewPos == (sal_uInt16)-1)
+ {
+ Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
+ if (!xGrid.is())
+ return xEmptyReturn;
+ nViewPos = xGrid->getCurrentColumnPosition();
+ }
+ sal_uInt16 nCurrentCol = getBrowserView()->View2ModelPos(nViewPos);
+ if (nCurrentCol == (sal_uInt16)-1)
+ return xEmptyReturn;
+
+ // get the according column from the model
+ Reference< ::com::sun::star::container::XIndexContainer > xCols(getControlModel(), UNO_QUERY);
+ Reference< XPropertySet > xCurrentCol(xCols->getByIndex(nCurrentCol),UNO_QUERY);
+ if (!xCurrentCol.is())
+ return xEmptyReturn;
+
+ xEmptyReturn.set(xCurrentCol->getPropertyValue(PROPERTY_BOUNDFIELD) ,UNO_QUERY);
+ return xEmptyReturn;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaXDataBrowserController, OnSearchContextRequest, FmSearchContext*, pContext)
+{
+ Reference< ::com::sun::star::container::XIndexAccess > xPeerContainer(getBrowserView()->getGridControl(), UNO_QUERY);
+
+ // check all grid columns for their control source
+ Reference< ::com::sun::star::container::XIndexAccess > xModelColumns(getFormComponent(), UNO_QUERY);
+ OSL_ENSURE(xModelColumns.is(), "SbaXDataBrowserController::OnSearchContextRequest : there is a grid control without columns !");
+ // the case 'no columns' should be indicated with an empty container, I think ...
+ OSL_ENSURE(xModelColumns->getCount() >= xPeerContainer->getCount(), "SbaXDataBrowserController::OnSearchContextRequest : impossible : have more view than model columns !");
+
+ String sFieldList;
+ for (sal_Int32 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos)
+ {
+ Reference< XInterface > xCurrentColumn(xPeerContainer->getByIndex(nViewPos),UNO_QUERY);
+ if (!xCurrentColumn.is())
+ continue;
+
+ // can we use this column control for searching ?
+ if (!IsSearchableControl(xCurrentColumn))
+ continue;
+
+ sal_uInt16 nModelPos = getBrowserView()->View2ModelPos((sal_uInt16)nViewPos);
+ Reference< XPropertySet > xCurrentColModel(xModelColumns->getByIndex(nModelPos),UNO_QUERY);
+ String aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(PROPERTY_CONTROLSOURCE));
+
+ sFieldList += aName;
+ sFieldList += ';';
+
+ pContext->arrFields.push_back(xCurrentColumn);
+ }
+ sFieldList.EraseTrailingChars(';');
+
+ pContext->xCursor.set(getRowSet(),UNO_QUERY);
+ pContext->strUsedFields = sFieldList;
+
+ // if the cursor is in a mode other than STANDARD -> reset
+ Reference< XPropertySet > xCursorSet(pContext->xCursor, UNO_QUERY);
+ OSL_ENSURE(xCursorSet.is() && !::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISMODIFIED)),
+ "SbaXDataBrowserController::OnSearchContextRequest : please do not call for cursors with modified rows !");
+ if (xCursorSet.is() && ::comphelper::getBOOL(xCursorSet->getPropertyValue(PROPERTY_ISNEW)))
+ {
+ Reference< XResultSetUpdate > xUpdateCursor(pContext->xCursor, UNO_QUERY);
+ xUpdateCursor->moveToCurrentRow();
+ }
+ return pContext->arrFields.size();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaXDataBrowserController, OnFoundData, FmFoundRecordInformation*, pInfo)
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY);
+ OSL_ENSURE(xCursor.is(), "SbaXDataBrowserController::OnFoundData : shit happens. sometimes. but this is simply impossible !");
+
+ // move the cursor
+ xCursor->moveToBookmark(pInfo->aPosition);
+
+ // let the grid snyc it's display with the cursor
+ Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
+ OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnFoundData : no model set ?!");
+ Any aOld = xModelSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), aOld);
+
+ // and move to the field
+ Reference< ::com::sun::star::container::XIndexAccess > aColumnControls(getBrowserView()->getGridControl()->getPeer(), UNO_QUERY);
+ sal_uInt16 nViewPos;
+
+ for ( nViewPos = 0; nViewPos < aColumnControls->getCount(); ++nViewPos )
+ {
+ Reference< XInterface > xCurrent(aColumnControls->getByIndex(nViewPos),UNO_QUERY);
+ if (IsSearchableControl(xCurrent))
+ {
+ if (pInfo->nFieldPos)
+ --pInfo->nFieldPos;
+ else
+ break;
+ }
+ }
+
+ Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
+ xGrid->setCurrentColumnPosition(nViewPos);
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaXDataBrowserController, OnCanceledNotFound, FmFoundRecordInformation*, pInfo)
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xCursor(getRowSet(), UNO_QUERY);
+
+ try
+ {
+ OSL_ENSURE(xCursor.is(), "SbaXDataBrowserController::OnCanceledNotFound : shit happens. sometimes. but this is simply impossible !");
+ // move the cursor
+ xCursor->moveToBookmark(pInfo->aPosition);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ try
+ {
+ // let the grid snyc its display with the cursor
+ Reference< XPropertySet > xModelSet(getControlModel(), UNO_QUERY);
+ OSL_ENSURE(xModelSet.is(), "SbaXDataBrowserController::OnCanceledNotFound : no model set ?!");
+ Any aOld = xModelSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), ::comphelper::makeBoolAny(sal_Bool(sal_True)));
+ xModelSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayIsSynchron")), aOld);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaXDataBrowserController, OnAsyncGetCellFocus, void*, EMPTYARG)
+{
+ SbaGridControl* pVclGrid = getBrowserView() ? getBrowserView()->getVclControl() : NULL;
+ // if we have a controller, but the window for the controller doesn't have the focus, we correct this
+ if(pVclGrid)
+ {
+ if (!pVclGrid->IsEditing())
+ return 0L;
+
+ if (pVclGrid->HasChildPathFocus())
+ pVclGrid->Controller()->GetWindow().GrabFocus();
+ }
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::criticalFail()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::criticalFail" );
+ InvalidateAll();
+ m_nRowSetPrivileges = 0;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::LoadFinished(sal_Bool /*bWasSynch*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::LoadFinished" );
+ m_nRowSetPrivileges = 0;
+
+ if (isValid() && !loadingCancelled())
+ {
+ // obtain cached values
+ try
+ {
+ Reference< XPropertySet > xFormProps( m_xLoadable, UNO_QUERY_THROW );
+ OSL_VERIFY( xFormProps->getPropertyValue( PROPERTY_PRIVILEGES ) >>= m_nRowSetPrivileges );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // --------------------------------
+ // switch the control to alive mode
+ getBrowserView()->getGridControl()->setDesignMode(sal_False);
+
+ // -------------------------------
+ initializeParser();
+
+ // -------------------------------
+ InvalidateAll();
+
+ m_aAsyncGetCellFocus.Call();
+ }
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::initializeParser() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::initializeParser" );
+ if ( !m_xParser.is() )
+ {
+ // ----------------------------------------------
+ // create a parser (needed for filtering/sorting)
+ try
+ {
+ const Reference< XPropertySet > xFormSet(getRowSet(), UNO_QUERY);
+ if (::comphelper::getBOOL(xFormSet->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)))
+ { // (only if the statement isn't native)
+ // (it is allowed to use the PROPERTY_ISPASSTHROUGH : _after_ loading a form it is valid)
+ xFormSet->getPropertyValue(PROPERTY_SINGLESELECTQUERYCOMPOSER) >>= m_xParser;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_xParser = NULL;
+ // no further handling, we ignore the error
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::loaded(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::loaded" );
+ // not interested in
+ // we're loading within an separate thread and have a handling for it's "finished event"
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::unloading" );
+ // not interested in
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::unloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::unloaded" );
+ m_xParser.clear();
+ InvalidateAll();
+ // do this asynchronously, there are other listeners reacting on this message ...
+ // (it's a little hack : the grid columns are listening to this event, too, and their bound field may
+ // change as a reaction on that event. as we have no chance to be notified of this change (which is
+ // the one we're interested in) we give them time to do what they want to before invalidating our
+ // bound-field-dependent slots ....
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloading" );
+ // not interested in
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::reloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::reloaded" );
+ InvalidateAll();
+ // do this asynchronously, there are other listeners reacting on this message ...
+ // (it's a little hack : the grid columns are listening to this event, too, and their bound field may
+ // change as a reaction on that event. as we have no chance to be notified of this change (which is
+ // the one we're interested in) we give them time to do what they want to before invalidating our
+ // bound-field-dependent slots ....
+}
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::enterFormAction()
+{
+ if ( !m_nFormActionNestingLevel )
+ // first action -> reset
+ m_aCurrentError.clear();
+
+ ++m_nFormActionNestingLevel;
+}
+
+//------------------------------------------------------------------------------
+void SbaXDataBrowserController::leaveFormAction()
+{
+ OSL_ENSURE( m_nFormActionNestingLevel > 0, "SbaXDataBrowserController::leaveFormAction : invalid call !" );
+ if ( --m_nFormActionNestingLevel > 0 )
+ return;
+
+ if ( !m_aCurrentError.isValid() )
+ return;
+
+ m_aAsyncDisplayError.Call();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::isLoaded() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::isLoaded" );
+ return m_xLoadable.is() && m_xLoadable->isLoaded();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::isValidCursor() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::isValidCursor" );
+ if (!m_xColumnsSupplier.is())
+ return sal_False;
+ Reference< ::com::sun::star::container::XNameAccess > xCols = m_xColumnsSupplier->getColumns();
+ if (!xCols.is() || !xCols->hasElements())
+ return sal_False;
+
+ sal_Bool bIsValid = !(m_xRowSet->isBeforeFirst() || m_xRowSet->isAfterLast());
+ if ( !bIsValid )
+ {
+ Reference<XPropertySet> xProp(m_xRowSet,UNO_QUERY);
+ bIsValid = ::cppu::any2bool(xProp->getPropertyValue(PROPERTY_ISNEW));
+ if ( !bIsValid )
+ {
+ bIsValid = m_xParser.is();
+ }
+ }
+ return bIsValid;
+}
+
+//==================================================================
+// LoadFormHelper
+//==================================================================
+
+class LoadFormHelper :public ::cppu::WeakImplHelper2< ::com::sun::star::form::XLoadListener,
+ XRowSetListener>
+{
+ enum STATE { STARTED, LOADED, POSITIONED, DISPOSED };
+ STATE m_eState;
+
+ Reference< XRowSet > m_xForm;
+
+ ::osl::Mutex m_aAccessSafety;
+
+public:
+ LoadFormHelper(const Reference< XRowSet > & _rxForm);
+
+ // ::com::sun::star::form::XLoadListener
+ virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException );
+ virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException );
+ virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException );
+ virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException );
+ virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException );
+
+ // XRowSetListener
+ virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException );
+ virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException );
+ virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( RuntimeException );
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException );
+
+
+ bool WaitUntilReallyLoaded(bool _bOnlyIfLoaded);
+ // waits 'til the first positioned event after the loaded event. returns true if successfull,
+ // false if the form was disposed or unloaded before or while waiting
+ // if _bOnlyIfLoaded is false and the form isn't loaded already loaded, false will be returned
+ // (without any wating)
+
+ void cancel();
+
+protected:
+ ~LoadFormHelper();
+
+ void implDispose();
+};
+
+DBG_NAME(LoadFormHelper)
+//------------------------------------------------------------------------------
+LoadFormHelper::LoadFormHelper(const Reference< XRowSet > & _rxForm)
+ :m_eState(STARTED)
+ ,m_xForm(_rxForm)
+{
+ DBG_CTOR(LoadFormHelper,NULL);
+
+ Reference< ::com::sun::star::form::XLoadable > (m_xForm, UNO_QUERY)->addLoadListener(this);
+ m_xForm->addRowSetListener(this);
+}
+
+//------------------------------------------------------------------------------
+LoadFormHelper::~LoadFormHelper()
+{
+ ::osl::MutexGuard aGuard(m_aAccessSafety);
+ implDispose();
+
+ DBG_DTOR(LoadFormHelper,NULL);
+}
+
+//------------------------------------------------------------------------------
+void LoadFormHelper::implDispose()
+{
+ if (DISPOSED != m_eState)
+ {
+
+ Reference< ::com::sun::star::form::XLoadable > (m_xForm, UNO_QUERY)->removeLoadListener(this);
+ m_xForm->removeRowSetListener(this);
+ m_xForm = NULL;
+ m_eState = DISPOSED;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::loaded(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aAccessSafety);
+ OSL_ENSURE(m_eState == STARTED || m_eState == DISPOSED, "LoadFormHelper::loaded : wrong call !");
+ if (m_eState == STARTED)
+ m_eState = LOADED;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::unloaded(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aAccessSafety);
+ OSL_FAIL("LoadFormHelper::unloaded : shouldn't be called !");
+ implDispose();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::unloading(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::reloading(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::reloaded(const ::com::sun::star::lang::EventObject& /*aEvent*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::cursorMoved(const ::com::sun::star::lang::EventObject& /*event*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aAccessSafety);
+ if (m_eState == LOADED)
+ m_eState = POSITIONED;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::rowChanged(const ::com::sun::star::lang::EventObject& /*event*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::rowSetChanged(const ::com::sun::star::lang::EventObject& /*event*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL LoadFormHelper::disposing(const ::com::sun::star::lang::EventObject& /*Source*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aAccessSafety);
+ implDispose();
+}
+
+//------------------------------------------------------------------------------
+void LoadFormHelper::cancel()
+{
+ implDispose();
+}
+
+//------------------------------------------------------------------------------
+bool LoadFormHelper::WaitUntilReallyLoaded(bool _bOnlyIfLoaded)
+{
+ ::osl::ResettableMutexGuard aGuard( m_aAccessSafety );
+ if (DISPOSED == m_eState)
+ return false;
+
+ if (_bOnlyIfLoaded && (STARTED == m_eState))
+ // we did't get a "loaded" event ....
+ return false;
+
+ sal_Bool bDone = (POSITIONED == m_eState);
+ aGuard.clear();
+
+ while (!bDone)
+ {
+ aGuard.reset();
+ bDone = (POSITIONED == m_eState);
+ aGuard.clear();
+ }
+
+ aGuard.reset();
+ implDispose();
+
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+sal_Int16 SbaXDataBrowserController::getCurrentColumnPosition()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::getCurrentColumnPosition" );
+ Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
+ sal_Int16 nViewPos = -1;
+ try
+ {
+ if ( xGrid.is() )
+ nViewPos = xGrid->getCurrentColumnPosition();
+ }
+ catch(Exception&) {}
+ return nViewPos;
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::setCurrentColumnPosition( sal_Int16 _nPos )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::setCurrentColumnPosition" );
+ Reference< ::com::sun::star::form::XGrid > xGrid(getBrowserView()->getGridControl(), UNO_QUERY);
+ try
+ {
+ if ( -1 != _nPos )
+ xGrid->setCurrentColumnPosition(_nPos);
+ }
+ catch(Exception&) {}
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::BeforeDrop()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::BeforeDrop" );
+ Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
+ if (xFormError.is())
+ xFormError->removeSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::AfterDrop()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::AfterDrop" );
+ Reference< ::com::sun::star::sdb::XSQLErrorBroadcaster > xFormError(getRowSet(), UNO_QUERY);
+ if (xFormError.is())
+ xFormError->addSQLErrorListener((::com::sun::star::sdb::XSQLErrorListener*)this);
+}
+// -----------------------------------------------------------------------------
+void SbaXDataBrowserController::addColumnListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::addColumnListeners" );
+// ... all the grid columns
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns(_xGridControlModel, UNO_QUERY);
+ if (xColumns.is())
+ {
+ sal_Int32 nCount = xColumns->getCount();
+ for (sal_uInt16 i=0; i < nCount; ++i)
+ {
+ Reference< XPropertySet > xCol(xColumns->getByIndex(i),UNO_QUERY);
+ AddColumnListener(xCol);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool SbaXDataBrowserController::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & /*xGrid*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaui", "Ocke.Janssen@sun.com", "SbaXDataBrowserController::InitializeGridModel" );
+ return sal_True;
+}
+//..................................................................
+} // namespace dbaui
+//..................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/brwview.cxx b/dbaccess/source/ui/browser/brwview.cxx
new file mode 100644
index 000000000000..337cd3b01177
--- /dev/null
+++ b/dbaccess/source/ui/browser/brwview.cxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "brwctrlr.hxx"
+#include "brwview.hxx"
+#include "sbagrid.hxx"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/split.hxx>
+#include "dbtreeview.hxx"
+#include "dbustrings.hrc"
+#include "dbu_brw.hrc"
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include "UITools.hxx"
+#include <osl/diagnose.h>
+
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+namespace
+{
+ sal_Bool isGrabVclControlFocusAllowed(const UnoDataBrowserView* _pView)
+ {
+ sal_Bool bGrabFocus = sal_False;
+ SbaGridControl* pVclControl = _pView->getVclControl();
+ Reference< ::com::sun::star::awt::XControl > xGrid = _pView->getGridControl();
+ if (pVclControl && xGrid.is())
+ {
+ bGrabFocus = sal_True;
+ if(!pVclControl->HasChildPathFocus())
+ {
+ Reference<XChild> xChild(xGrid->getModel(),UNO_QUERY);
+ Reference<XLoadable> xLoad;
+ if(xChild.is())
+ xLoad.set(xChild->getParent(),UNO_QUERY);
+ bGrabFocus = xLoad.is() && xLoad->isLoaded();
+ }
+ }
+ return bGrabFocus;
+ }
+}
+//==================================================================
+//= UnoDataBrowserView
+//==================================================================
+
+DBG_NAME(UnoDataBrowserView)
+// -------------------------------------------------------------------------
+UnoDataBrowserView::UnoDataBrowserView( Window* pParent,
+ IController& _rController,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory)
+ :ODataView(pParent,_rController,_rFactory)
+ ,m_pTreeView(NULL)
+ ,m_pSplitter(NULL)
+ ,m_pVclControl(NULL)
+ ,m_pStatus(NULL)
+{
+ DBG_CTOR(UnoDataBrowserView,NULL);
+
+}
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::Construct(const Reference< ::com::sun::star::awt::XControlModel >& xModel)
+{
+ try
+ {
+ ODataView::Construct();
+
+ // our UNO representation
+ m_xMe = VCLUnoHelper::CreateControlContainer(this);
+
+ // create the (UNO-) control
+ m_xGrid = new SbaXGridControl(getORB());
+ OSL_ENSURE(m_xGrid.is(), "UnoDataBrowserView::Construct : could not create a grid control !");
+ // in design mode (for the moment)
+ m_xGrid->setDesignMode(sal_True);
+
+ Reference< ::com::sun::star::awt::XWindow > xGridWindow(m_xGrid, UNO_QUERY);
+ xGridWindow->setVisible(sal_True);
+ xGridWindow->setEnable(sal_True);
+
+ // introduce the model to the grid
+ m_xGrid->setModel(xModel);
+ // introduce the container (me) to the grid
+ Reference< ::com::sun::star::beans::XPropertySet > xModelSet(xModel, UNO_QUERY);
+ getContainer()->addControl(::comphelper::getString(xModelSet->getPropertyValue(PROPERTY_NAME)), m_xGrid);
+
+ // get the VCL-control
+ m_pVclControl = NULL;
+ getVclControl();
+
+ OSL_ENSURE(m_pVclControl != NULL, "UnoDataBrowserView::Construct : no real grid control !");
+ }
+ catch(Exception&)
+ {
+ ::comphelper::disposeComponent(m_xGrid);
+ throw;
+ }
+}
+// -------------------------------------------------------------------------
+UnoDataBrowserView::~UnoDataBrowserView()
+{
+ {
+ ::std::auto_ptr<Splitter> aTemp(m_pSplitter);
+ m_pSplitter = NULL;
+ }
+ setTreeView(NULL);
+
+ if ( m_pStatus )
+ {
+ delete m_pStatus;
+ m_pStatus = NULL;
+ }
+
+ try
+ {
+ ::comphelper::disposeComponent(m_xGrid);
+ ::comphelper::disposeComponent(m_xMe);
+ }
+ catch(Exception)
+ {}
+
+ DBG_DTOR(UnoDataBrowserView,NULL);
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( UnoDataBrowserView, SplitHdl, void*, /*NOINTERESTEDIN*/ )
+{
+ long nYPos = m_pSplitter->GetPosPixel().Y();
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nYPos ) );
+ Resize();
+
+ return 0L;
+}
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::setSplitter(Splitter* _pSplitter)
+{
+ m_pSplitter = _pSplitter;
+ m_pSplitter->SetSplitHdl( LINK( this, UnoDataBrowserView, SplitHdl ) );
+ LINK( this, UnoDataBrowserView, SplitHdl ).Call(m_pSplitter);
+}
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::setTreeView(DBTreeView* _pTreeView)
+{
+ if (m_pTreeView != _pTreeView)
+ {
+ if (m_pTreeView)
+ {
+ ::std::auto_ptr<Window> aTemp(m_pTreeView);
+ m_pTreeView = NULL;
+ }
+ m_pTreeView = _pTreeView;
+ }
+}
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::showStatus( const String& _rStatus )
+{
+ if (0 == _rStatus.Len())
+ hideStatus();
+ else
+ {
+ if (!m_pStatus)
+ m_pStatus = new FixedText(this);
+ m_pStatus->SetText(_rStatus);
+ m_pStatus->Show();
+ Resize();
+ Update();
+ }
+}
+
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::hideStatus()
+{
+ if (!m_pStatus || !m_pStatus->IsVisible())
+ // nothing to do
+ return;
+ m_pStatus->Hide();
+ Resize();
+ Update();
+}
+
+// -------------------------------------------------------------------------
+void UnoDataBrowserView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ Point aSplitPos;
+ Size aSplitSize;
+ Point aPlaygroundPos( _rPlayground.TopLeft() );
+ Size aPlaygroundSize( _rPlayground.GetSize() );
+
+ if (m_pTreeView && m_pTreeView->IsVisible() && m_pSplitter)
+ {
+ // calculate the splitter pos and size
+ aSplitPos = m_pSplitter->GetPosPixel();
+ aSplitPos.Y() = aPlaygroundPos.Y();
+ aSplitSize = m_pSplitter->GetOutputSizePixel();
+ aSplitSize.Height() = aPlaygroundSize.Height();
+
+ if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() ))
+ aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width();
+
+ if( aSplitPos.X() <= aPlaygroundPos.X() )
+ aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.2);
+
+ // the tree pos and size
+ Point aTreeViewPos( aPlaygroundPos );
+ Size aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() );
+
+ // the status pos and size
+ if (m_pStatus && m_pStatus->IsVisible())
+ {
+ Size aStatusSize(aPlaygroundPos.X(), GetTextHeight() + 2);
+ aStatusSize = LogicToPixel(aStatusSize, MAP_APPFONT);
+ aStatusSize.Width() = aTreeViewSize.Width() - 2 - 2;
+
+ Point aStatusPos( aPlaygroundPos.X() + 2, aTreeViewPos.Y() + aTreeViewSize.Height() - aStatusSize.Height() );
+ m_pStatus->SetPosSizePixel( aStatusPos, aStatusSize );
+ aTreeViewSize.Height() -= aStatusSize.Height();
+ }
+
+ // set the size of treelistbox
+ m_pTreeView->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
+
+ //set the size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) );
+ m_pSplitter->SetDragRectPixel( _rPlayground );
+ }
+
+ // set the size of grid control
+ Reference< ::com::sun::star::awt::XWindow > xGridAsWindow(m_xGrid, UNO_QUERY);
+ if (xGridAsWindow.is())
+ xGridAsWindow->setPosSize( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(),
+ aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height(), ::com::sun::star::awt::PosSize::POSSIZE);
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+
+//------------------------------------------------------------------
+sal_uInt16 UnoDataBrowserView::View2ModelPos(sal_uInt16 nPos) const
+{
+ return m_pVclControl ? m_pVclControl->GetModelColumnPos(m_pVclControl->GetColumnIdFromViewPos(nPos)) : -1;
+}
+
+// -----------------------------------------------------------------------------
+SbaGridControl* UnoDataBrowserView::getVclControl() const
+{
+ if ( !m_pVclControl )
+ {
+ OSL_ENSURE(m_xGrid.is(),"Grid not set!");
+ if ( m_xGrid.is() )
+ {
+ Reference< ::com::sun::star::awt::XWindowPeer > xPeer = m_xGrid->getPeer();
+ if ( xPeer.is() )
+ {
+ SbaXGridPeer* pPeer = SbaXGridPeer::getImplementation(xPeer);
+ UnoDataBrowserView* pTHIS = const_cast<UnoDataBrowserView*>(this);
+ if ( pPeer )
+ {
+ m_pVclControl = static_cast<SbaGridControl*>(pPeer->GetWindow());
+ pTHIS->startComponentListening(Reference<XComponent>(VCLUnoHelper::GetInterface(m_pVclControl),UNO_QUERY));
+ }
+ }
+ }
+ }
+ return m_pVclControl;
+}
+// -----------------------------------------------------------------------------
+void UnoDataBrowserView::GetFocus()
+{
+ ODataView::GetFocus();
+ if( m_pTreeView && m_pTreeView->IsVisible() && !m_pTreeView->HasChildPathFocus())
+ m_pTreeView->GrabFocus();
+ else if (m_pVclControl && m_xGrid.is())
+ {
+ sal_Bool bGrabFocus = sal_False;
+ if(!m_pVclControl->HasChildPathFocus())
+ {
+ bGrabFocus = isGrabVclControlFocusAllowed(this);
+ if( bGrabFocus )
+ m_pVclControl->GrabFocus();
+ }
+ if(!bGrabFocus && m_pTreeView && m_pTreeView->IsVisible() )
+ m_pTreeView->GrabFocus();
+ }
+}
+// -----------------------------------------------------------------------------
+void UnoDataBrowserView::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
+{
+ stopComponentListening(Reference<XComponent>(VCLUnoHelper::GetInterface(m_pVclControl),UNO_QUERY));
+ m_pVclControl = NULL;
+}
+// -------------------------------------------------------------------------
+long UnoDataBrowserView::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0L;
+ if(rNEvt.GetType() == EVENT_KEYINPUT)
+ {
+ sal_Bool bGrabAllowed = isGrabVclControlFocusAllowed(this);
+ if ( bGrabAllowed )
+ {
+ const KeyEvent* pKeyEvt = rNEvt.GetKeyEvent();
+ const KeyCode& rKeyCode = pKeyEvt->GetKeyCode();
+ if ( ( rKeyCode == KeyCode( KEY_E, sal_True, sal_True, sal_False, sal_False ) )
+ || ( rKeyCode == KeyCode( KEY_TAB, sal_True, sal_False, sal_False, sal_False ) )
+ )
+ {
+ if ( m_pTreeView && m_pVclControl && m_pTreeView->HasChildPathFocus() )
+ m_pVclControl->GrabFocus();
+ else if ( m_pTreeView && m_pVclControl && m_pVclControl->HasChildPathFocus() )
+ m_pTreeView->GrabFocus();
+
+ nDone = 1L;
+ }
+ }
+ }
+ return nDone ? nDone : ODataView::PreNotify(rNEvt);
+}
+
+DBG_NAME(BrowserViewStatusDisplay)
+// -----------------------------------------------------------------------------
+BrowserViewStatusDisplay::BrowserViewStatusDisplay( UnoDataBrowserView* _pView, const String& _rStatus )
+ :m_pView(_pView)
+{
+ DBG_CTOR(BrowserViewStatusDisplay,NULL);
+
+ if (m_pView)
+ m_pView->showStatus(_rStatus);
+}
+
+// -----------------------------------------------------------------------------
+BrowserViewStatusDisplay::~BrowserViewStatusDisplay( )
+{
+ if (m_pView)
+ m_pView->showStatus(String());
+
+ DBG_DTOR(BrowserViewStatusDisplay,NULL);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
new file mode 100644
index 000000000000..ff4817eba056
--- /dev/null
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -0,0 +1,226 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dataview.hxx"
+#include <toolkit/unohlp.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/imgmgr.hxx>
+#include "IController.hxx"
+#include "UITools.hxx"
+#include <sfx2/sfx.hrc>
+#include <svtools/imgdef.hxx>
+#include <tools/diagnose_ex.h>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+
+ //=====================================================================
+ //= ColorChanger
+ //=====================================================================
+ class ColorChanger
+ {
+ protected:
+ OutputDevice* m_pDev;
+
+ public:
+ ColorChanger( OutputDevice* _pDev, const Color& _rNewLineColor, const Color& _rNewFillColor )
+ :m_pDev( _pDev )
+ {
+ m_pDev->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ m_pDev->SetLineColor( _rNewLineColor );
+ m_pDev->SetFillColor( _rNewFillColor );
+ }
+
+ ~ColorChanger()
+ {
+ m_pDev->Pop();
+ }
+ };
+
+ DBG_NAME(ODataView)
+ // -------------------------------------------------------------------------
+ ODataView::ODataView( Window* pParent,
+ IController& _rController,
+ const Reference< XMultiServiceFactory >& _rFactory,
+ WinBits nStyle)
+ :Window(pParent,nStyle)
+ ,m_xServiceFactory(_rFactory)
+ ,m_rController( _rController )
+ ,m_aSeparator( this )
+ {
+ DBG_CTOR(ODataView,NULL);
+ m_rController.acquire();
+ m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper());
+ m_aSeparator.Show();
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::Construct()
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ ODataView::~ODataView()
+ {
+ DBG_DTOR(ODataView,NULL);
+
+ m_rController.release();
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::resizeDocumentView( Rectangle& /*_rPlayground*/ )
+ {
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::Paint( const Rectangle& _rRect )
+ {
+ //.................................................................
+ // draw the background
+ {
+ ColorChanger aColors( this, COL_TRANSPARENT, GetSettings().GetStyleSettings().GetFaceColor() );
+ DrawRect( _rRect );
+ }
+
+ // let the base class do anything it needs
+ Window::Paint( _rRect );
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::resizeAll( const Rectangle& _rPlayground )
+ {
+ Rectangle aPlayground( _rPlayground );
+
+ // position the separator
+ const Size aSeparatorSize = Size( aPlayground.GetWidth(), 2 );
+ m_aSeparator.SetPosSizePixel( aPlayground.TopLeft(), aSeparatorSize );
+ aPlayground.Top() += aSeparatorSize.Height() + 1;
+
+ // position the controls of the document's view
+ resizeDocumentView( aPlayground );
+ }
+
+ // -------------------------------------------------------------------------
+ void ODataView::Resize()
+ {
+ Window::Resize();
+ resizeAll( Rectangle( Point( 0, 0), GetSizePixel() ) );
+ }
+ // -----------------------------------------------------------------------------
+ long ODataView::PreNotify( NotifyEvent& _rNEvt )
+ {
+ bool bHandled = false;
+ switch ( _rNEvt.GetType() )
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ const KeyCode& aKeyCode = pKeyEvent->GetKeyCode();
+ if ( m_pAccel.get() && m_pAccel->execute( aKeyCode ) )
+ // the accelerator consumed the event
+ return 1L;
+ }
+ // NO break
+ case EVENT_KEYUP:
+ case EVENT_MOUSEBUTTONDOWN:
+ case EVENT_MOUSEBUTTONUP:
+ bHandled = m_rController.interceptUserInput( _rNEvt );
+ break;
+ }
+ return bHandled ? 1L : Window::PreNotify( _rNEvt );
+ }
+ // -----------------------------------------------------------------------------
+ void ODataView::StateChanged( StateChangedType nType )
+ {
+ Window::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ m_rController.notifyHiContrastChanged();
+ }
+
+ if ( nType == STATE_CHANGE_INITSHOW )
+ {
+ // now that there's a view which is finally visible, remove the "Hidden" value from the
+ // model's arguments.
+ try
+ {
+ Reference< XController > xController( m_rController.getXController(), UNO_SET_THROW );
+ Reference< XModel > xModel( xController->getModel(), UNO_QUERY );
+ if ( xModel.is() )
+ {
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ aArgs.remove( "Hidden" );
+ xModel->attachResource( xModel->getURL(), aArgs.getPropertyValues() );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void ODataView::DataChanged( const DataChangedEvent& rDCEvt )
+ {
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ m_rController.notifyHiContrastChanged();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
+ {
+ m_pAccel->init(m_xServiceFactory,_xFrame);
+ }
+//.........................................................................
+}
+// namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
new file mode 100644
index 000000000000..0273c7f5a746
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbexchange.hxx"
+#include <sot/formats.hxx>
+#include <sot/storage.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include "TokenWriter.hxx"
+#include "dbustrings.hrc"
+#include <comphelper/uno3.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include "UITools.hxx"
+
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::datatransfer;
+ using namespace ::svx;
+
+ namespace
+ {
+ template<class T > void lcl_setListener(const Reference<T>& _xComponent, const Reference< XEventListener >& i_rListener, const bool i_bAdd )
+ {
+ if ( !_xComponent.is() )
+ return;
+
+ Reference< XComponent> xCom( _xComponent, UNO_QUERY );
+ OSL_ENSURE( xCom.is(), "lcl_setListener: no component!" );
+ if ( !xCom.is() )
+ return;
+
+ i_bAdd ? xCom->addEventListener( i_rListener ) : xCom->removeEventListener( i_rListener );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ ODataClipboard::ODataClipboard(
+ const ::rtl::OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ const Reference< XConnection >& _rxConnection,
+ const Reference< XNumberFormatter >& _rxFormatter,
+ const Reference< XMultiServiceFactory >& _rxORB)
+ :ODataAccessObjectTransferable( _rDatasource,::rtl::OUString(), _nCommandType, _rCommand, _rxConnection )
+ ,m_pHtml(NULL)
+ ,m_pRtf(NULL)
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ lcl_setListener( _rxConnection, this, true );
+
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(), _rxORB, _rxFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(), _rxORB, _rxFormatter ) );
+
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ // -----------------------------------------------------------------------------
+ ODataClipboard::ODataClipboard(
+ const ::rtl::OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ const Reference< XNumberFormatter >& _rxFormatter,
+ const Reference< XMultiServiceFactory >& _rxORB)
+ :ODataAccessObjectTransferable( _rDatasource, ::rtl::OUString(),_nCommandType, _rCommand)
+ ,m_pHtml(NULL)
+ ,m_pRtf(NULL)
+ {
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(),_rxORB, _rxFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(),_rxORB, _rxFormatter ) );
+ }
+
+ // -----------------------------------------------------------------------------
+ ODataClipboard::ODataClipboard( const Reference< XPropertySet >& i_rAliveForm,
+ const Sequence< Any >& i_rSelectedRows,
+ const sal_Bool i_bBookmarkSelection,
+ const Reference< XMultiServiceFactory >& i_rORB )
+ :ODataAccessObjectTransferable( i_rAliveForm )
+ ,m_pHtml(NULL)
+ ,m_pRtf(NULL)
+ {
+ OSL_PRECOND( i_rORB.is(), "ODataClipboard::ODataClipboard: having no factory is not good ..." );
+
+ osl_incrementInterlockedCount( &m_refCount );
+
+ Reference<XConnection> xConnection;
+ getDescriptor()[ daConnection ] >>= xConnection;
+ lcl_setListener( xConnection, this, true );
+
+ // do not pass the form itself as source result set, since the client might operate on the form, which
+ // might lead to undesired effects. Instead, use a clone.
+ Reference< XResultSet > xResultSetClone;
+ Reference< XResultSetAccess > xResultSetAccess( i_rAliveForm, UNO_QUERY );
+ if ( xResultSetAccess.is() )
+ xResultSetClone = xResultSetAccess->createResultSet();
+ OSL_ENSURE( xResultSetClone.is(), "ODataClipboard::ODataClipboard: could not clone the form's result set" );
+ lcl_setListener( xResultSetClone, this, true );
+
+ getDescriptor()[daCursor] <<= xResultSetClone;
+ getDescriptor()[daSelection] <<= i_rSelectedRows;
+ getDescriptor()[daBookmarkSelection]<<= i_bBookmarkSelection;
+ addCompatibleSelectionDescription( i_rSelectedRows );
+
+ if ( xConnection.is() && i_rORB.is() )
+ {
+ Reference< XNumberFormatter > xFormatter( getNumberFormatter( xConnection, i_rORB ) );
+ if ( xFormatter.is() )
+ {
+ m_pHtml.set( new OHTMLImportExport( getDescriptor(), i_rORB, xFormatter ) );
+ m_pRtf.set( new ORTFImportExport( getDescriptor(), i_rORB, xFormatter ) );
+ }
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODataClipboard::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& /*rFlavor*/ )
+ {
+ if (nUserObjectId == SOT_FORMAT_RTF || nUserObjectId == SOT_FORMATSTR_ID_HTML )
+ {
+ ODatabaseImportExport* pExport = reinterpret_cast<ODatabaseImportExport*>(pUserObject);
+ if ( pExport && rxOStm.Is() )
+ {
+ pExport->setStream(&rxOStm);
+ return pExport->Write();
+ }
+ }
+ return sal_False;
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODataClipboard::AddSupportedFormats()
+ {
+ if ( m_pRtf.is() )
+ AddFormat( SOT_FORMAT_RTF );
+
+ if ( m_pHtml.is() )
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+
+ ODataAccessObjectTransferable::AddSupportedFormats();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODataClipboard::GetData( const DataFlavor& rFlavor )
+ {
+ const sal_uLong nFormat = SotExchange::GetFormat(rFlavor);
+ switch (nFormat)
+ {
+ case SOT_FORMAT_RTF:
+ if ( m_pRtf.is() )
+ m_pRtf->initialize(getDescriptor());
+ return m_pRtf.is() && SetObject( m_pRtf.get(), SOT_FORMAT_RTF, rFlavor );
+
+ case SOT_FORMATSTR_ID_HTML:
+ if ( m_pHtml.is() )
+ m_pHtml->initialize(getDescriptor());
+ return m_pHtml.is() && SetObject( m_pHtml.get(), SOT_FORMATSTR_ID_HTML, rFlavor );
+ }
+
+ return ODataAccessObjectTransferable::GetData( rFlavor );
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODataClipboard::ObjectReleased()
+ {
+ if ( m_pHtml.is() )
+ {
+ m_pHtml->dispose();
+ m_pHtml.clear();
+ }
+
+ if ( m_pRtf.is() )
+ {
+ m_pRtf->dispose();
+ m_pRtf.clear();
+ }
+
+ if ( getDescriptor().has( daConnection ) )
+ {
+ Reference<XConnection> xConnection( getDescriptor()[daConnection], UNO_QUERY );
+ lcl_setListener( xConnection, this, false );
+ }
+
+ if ( getDescriptor().has( daCursor ) )
+ {
+ Reference< XResultSet > xResultSet( getDescriptor()[ daCursor ], UNO_QUERY );
+ lcl_setListener( xResultSet, this, false );
+ }
+
+ ODataAccessObjectTransferable::ObjectReleased( );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL ODataClipboard::disposing( const ::com::sun::star::lang::EventObject& i_rSource ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ ODataAccessDescriptor& rDescriptor( getDescriptor() );
+
+ if ( rDescriptor.has( daConnection ) )
+ {
+ Reference< XConnection > xConnection( rDescriptor[daConnection], UNO_QUERY );
+ if ( xConnection == i_rSource.Source )
+ {
+ rDescriptor.erase( daConnection );
+ }
+ }
+
+ if ( rDescriptor.has( daCursor ) )
+ {
+ Reference< XResultSet > xResultSet( rDescriptor[ daCursor ], UNO_QUERY );
+ if ( xResultSet == i_rSource.Source )
+ {
+ rDescriptor.erase( daCursor );
+ // Selection and BookmarkSelection are meaningless without a result set
+ if ( rDescriptor.has( daSelection ) )
+ rDescriptor.erase( daSelection );
+ if ( rDescriptor.has( daBookmarkSelection ) )
+ rDescriptor.erase( daBookmarkSelection );
+ }
+ }
+
+ // no matter whether it was the source connection or the source result set which died,
+ // we cannot provide the data anymore.
+ ClearFormats();
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbloader.cxx b/dbaccess/source/ui/browser/dbloader.cxx
new file mode 100644
index 000000000000..244347057906
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbloader.cxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "dbustrings.hrc"
+#include "UITools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/frame/XController2.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrameLoader.hpp>
+#include <com/sun/star/frame/XLoadEventListener.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/frame/XModule.hpp>
+/** === end UNO includes === **/
+
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+#include <sal/macros.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using ::com::sun::star::sdbc::XDataSource;
+using namespace dbaui;
+
+class DBContentLoader : public ::cppu::WeakImplHelper2< XFrameLoader, XServiceInfo>
+{
+private:
+ ::rtl::OUString m_aURL;
+ Sequence< PropertyValue> m_aArgs;
+ Reference< XLoadEventListener > m_xListener;
+ Reference< XFrame > m_xFrame;
+ Reference< XMultiServiceFactory > m_xServiceFactory;
+public:
+ DBContentLoader(const Reference< XMultiServiceFactory >&);
+ ~DBContentLoader();
+
+ // XServiceInfo
+ ::rtl::OUString SAL_CALL getImplementationName() throw( );
+ sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw( );
+ Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
+
+ // static methods
+ static ::rtl::OUString getImplementationName_Static() throw( )
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.DBContentLoader"));
+ }
+ static Sequence< ::rtl::OUString> getSupportedServiceNames_Static(void) throw( );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XLoader
+ virtual void SAL_CALL load( const Reference< XFrame > & _rFrame, const ::rtl::OUString& _rURL,
+ const Sequence< PropertyValue >& _rArgs,
+ const Reference< XLoadEventListener > & _rListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancel(void) throw();
+};
+DBG_NAME(DBContentLoader)
+
+DBContentLoader::DBContentLoader(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_xServiceFactory(_rxFactory)
+{
+ DBG_CTOR(DBContentLoader,NULL);
+
+}
+// -------------------------------------------------------------------------
+
+DBContentLoader::~DBContentLoader()
+{
+
+ DBG_DTOR(DBContentLoader,NULL);
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DBContentLoader()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< DBContentLoader > aAutoRegistration;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL DBContentLoader::Create( const Reference< XMultiServiceFactory > & rSMgr )
+{
+ return *(new DBContentLoader(rSMgr));
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+::rtl::OUString SAL_CALL DBContentLoader::getImplementationName() throw( )
+{
+ return getImplementationName_Static();
+}
+// -------------------------------------------------------------------------
+
+// XServiceInfo
+sal_Bool SAL_CALL DBContentLoader::supportsService(const ::rtl::OUString& ServiceName) throw( )
+{
+ Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
+ const ::rtl::OUString * pBegin = aSNL.getConstArray();
+ const ::rtl::OUString * pEnd = pBegin + aSNL.getLength();
+ for( ; pBegin != pEnd; ++pBegin)
+ if( *pBegin == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+// XServiceInfo
+Sequence< ::rtl::OUString > SAL_CALL DBContentLoader::getSupportedServiceNames(void) throw( )
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+// ORegistryServiceManager_Static
+Sequence< ::rtl::OUString > DBContentLoader::getSupportedServiceNames_Static(void) throw( )
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.FrameLoader"));
+ aSNS.getArray()[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ContentLoader"));
+ return aSNS;
+}
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL writeDBLoaderInfo(void* pRegistryKey)
+{
+ Reference< XRegistryKey> xKey(reinterpret_cast< XRegistryKey*>(pRegistryKey));
+
+ // register content loader for dispatch
+ ::rtl::OUString aImpl(RTL_CONSTASCII_USTRINGPARAM("/"));
+ aImpl += DBContentLoader::getImplementationName_Static();
+
+ ::rtl::OUString aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/Loader"));
+ Reference< XRegistryKey> xNewKey = xKey->createKey( aImpltwo );
+ aImpltwo = aImpl;
+ aImpltwo += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/Loader"));
+ Reference< XRegistryKey > xLoaderKey = xKey->createKey( aImpltwo );
+ xNewKey = xLoaderKey->createKey( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Pattern")) );
+ xNewKey->setAsciiValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".component:DB*")) );
+}
+
+// -----------------------------------------------------------------------
+void SAL_CALL DBContentLoader::load(const Reference< XFrame > & rFrame, const ::rtl::OUString& rURL,
+ const Sequence< PropertyValue >& rArgs,
+ const Reference< XLoadEventListener > & rListener) throw(::com::sun::star::uno::RuntimeException)
+{
+ m_xFrame = rFrame;
+ m_xListener = rListener;
+ m_aURL = rURL;
+ m_aArgs = rArgs;
+
+ ::comphelper::ComponentContext aContext( m_xServiceFactory );
+
+ struct ServiceNameToImplName
+ {
+ const sal_Char* pAsciiServiceName;
+ const sal_Char* pAsciiImplementationName;
+ ServiceNameToImplName( const sal_Char* _pService, const sal_Char* _pImpl )
+ :pAsciiServiceName( _pService )
+ ,pAsciiImplementationName( _pImpl )
+ {
+ }
+ } aImplementations[] = {
+ ServiceNameToImplName( URL_COMPONENT_FORMGRIDVIEW, "org.openoffice.comp.dbu.OFormGridView" ),
+ ServiceNameToImplName( URL_COMPONENT_DATASOURCEBROWSER, "org.openoffice.comp.dbu.ODatasourceBrowser" ),
+ ServiceNameToImplName( URL_COMPONENT_QUERYDESIGN, "org.openoffice.comp.dbu.OQueryDesign" ),
+ ServiceNameToImplName( URL_COMPONENT_TABLEDESIGN, "org.openoffice.comp.dbu.OTableDesign" ),
+ ServiceNameToImplName( URL_COMPONENT_RELATIONDESIGN, "org.openoffice.comp.dbu.ORelationDesign" ),
+ ServiceNameToImplName( URL_COMPONENT_VIEWDESIGN, "org.openoffice.comp.dbu.OViewDesign" )
+ };
+
+ INetURLObject aParser( rURL );
+ Reference< XController2 > xController;
+
+ const ::rtl::OUString sComponentURL( aParser.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
+ for ( size_t i=0; i < SAL_N_ELEMENTS( aImplementations ); ++i )
+ {
+ if ( sComponentURL.equalsAscii( aImplementations[i].pAsciiServiceName ) )
+ {
+ aContext.createComponent( aImplementations[i].pAsciiImplementationName, xController );
+ break;
+ }
+ }
+
+ // if a data source browser is loaded without its tree pane, then we assume it to be a
+ // table data view, effectively. In this case, we need to adjust the module identifier.
+ // #i85879#
+ ::comphelper::NamedValueCollection aLoadArgs( rArgs );
+
+ if ( sComponentURL == URL_COMPONENT_DATASOURCEBROWSER )
+ {
+ sal_Bool bDisableBrowser = ( sal_False == aLoadArgs.getOrDefault( "ShowTreeViewButton", sal_True ) ) // compatibility name
+ || ( sal_False == aLoadArgs.getOrDefault( (::rtl::OUString)PROPERTY_ENABLE_BROWSER, sal_True ) );
+
+ if ( bDisableBrowser )
+ {
+ try
+ {
+ Reference< XModule > xModule( xController, UNO_QUERY_THROW );
+ xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TableDataView" ) ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ if ( sComponentURL == URL_COMPONENT_REPORTDESIGN )
+ {
+ sal_Bool bPreview = aLoadArgs.getOrDefault( "Preview", sal_False );
+ if ( bPreview )
+ { // report designs cannot be previewed
+ if ( rListener.is() )
+ rListener->loadCancelled( this );
+ return;
+ }
+ Reference< XModel > xReportModel( aLoadArgs.getOrDefault( "Model", Reference< XModel >() ) );
+ if ( xReportModel.is() )
+ {
+ xController.set( m_xServiceFactory->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.ReportDesign" ) ) ), UNO_QUERY );
+ if ( xController.is() )
+ {
+ xController->attachModel( xReportModel );
+ xReportModel->connectController( xController.get() );
+ xReportModel->setCurrentController( xController.get() );
+ }
+ }
+ }
+
+ sal_Bool bSuccess = xController.is();
+ Reference< XModel > xDatabaseDocument;
+ if ( bSuccess )
+ {
+ Reference< XDataSource > xDataSource ( aLoadArgs.getOrDefault( "DataSource", Reference< XDataSource >() ) );
+ ::rtl::OUString sDataSourceName( aLoadArgs.getOrDefault( "DataSourceName", ::rtl::OUString() ) );
+ Reference< XConnection > xConnection ( aLoadArgs.getOrDefault( "ActiveConnection", Reference< XConnection >() ) );
+ if ( xDataSource.is() )
+ {
+ xDatabaseDocument.set( getDataSourceOrModel( xDataSource ), UNO_QUERY );
+ }
+ else if ( sDataSourceName.getLength() )
+ {
+ ::dbtools::SQLExceptionInfo aError;
+ xDataSource.set( getDataSourceByName( sDataSourceName, NULL, m_xServiceFactory, &aError ) );
+ xDatabaseDocument.set( getDataSourceOrModel( xDataSource ), UNO_QUERY );
+ }
+ else if ( xConnection.is() )
+ {
+ Reference< XChild > xAsChild( xConnection, UNO_QUERY );
+ if ( xAsChild.is() )
+ {
+ OSL_ENSURE( Reference< XDataSource >( xAsChild->getParent(), UNO_QUERY ).is(),
+ "DBContentLoader::load: a connection whose parent is no data source?" );
+ xDatabaseDocument.set( getDataSourceOrModel( xAsChild->getParent() ), UNO_QUERY );
+ }
+ }
+
+ // init controller
+ SolarMutexGuard aGuard;
+ try
+ {
+ Reference<XInitialization > xIni(xController,UNO_QUERY);
+ PropertyValue aFrame(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Frame")),0,makeAny(rFrame),PropertyState_DIRECT_VALUE);
+ Sequence< Any > aInitArgs(m_aArgs.getLength()+1);
+
+ Any* pBegin = aInitArgs.getArray();
+ Any* pEnd = pBegin + aInitArgs.getLength();
+ *pBegin <<= aFrame;
+ const PropertyValue* pIter = m_aArgs.getConstArray();
+ for(++pBegin;pBegin != pEnd;++pBegin,++pIter)
+ {
+ *pBegin <<= *pIter;
+ }
+
+ xIni->initialize(aInitArgs);
+ }
+ catch(const Exception&)
+ {
+ // Does this need to be shown to the user?
+ bSuccess = false;
+ try
+ {
+ ::comphelper::disposeComponent( xController );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // assign controller and frame
+ if ( bSuccess )
+ {
+ if ( xController.is() && rFrame.is() )
+ {
+ rFrame->setComponent( xController->getComponentWindow(), xController.get() );
+ xController->attachFrame(rFrame);
+ }
+
+ if ( rListener.is() )
+ rListener->loadFinished( this );
+ }
+ else
+ if ( rListener.is() )
+ rListener->loadCancelled( this );
+}
+
+// -----------------------------------------------------------------------
+void DBContentLoader::cancel(void) throw()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbtreemodel.cxx b/dbaccess/source/ui/browser/dbtreemodel.cxx
new file mode 100644
index 000000000000..c2975b9d8314
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreemodel.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbtreemodel.hxx"
+#include "dbu_resource.hrc"
+#include <osl/diagnose.h>
+
+namespace dbaui
+{
+ DBG_NAME(DBTreeListUserData)
+ //------------------------------------------------------------------------
+ DBTreeListUserData::DBTreeListUserData()
+ :eType(SbaTableQueryBrowser::etQuery)
+ {
+ DBG_CTOR(DBTreeListUserData,NULL);
+ }
+ //------------------------------------------------------------------------
+ DBTreeListUserData::~DBTreeListUserData()
+ {
+ DBG_DTOR(DBTreeListUserData,NULL);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbtreemodel.hxx b/dbaccess/source/ui/browser/dbtreemodel.hxx
new file mode 100644
index 000000000000..12ce3ed3925a
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreemodel.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBTREEMODEL_HXX
+#define DBAUI_DBTREEMODEL_HXX
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <svtools/svlbox.hxx>
+#include <svtools/svlbitm.hxx>
+#include "unodatbr.hxx"
+#include "commontypes.hxx"
+
+// syntax of the tree userdata
+// datasource holds the connection
+// queries holds the nameaccess for the queries
+// query holds the query
+// tables holds the nameaccess for the tables
+// table holds the table
+
+#define CONTAINER_QUERIES sal_uLong( 0 )
+#define CONTAINER_TABLES sal_uLong( 1 )
+
+namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } } } }
+
+namespace dbaui
+{
+ struct DBTreeListUserData
+ {
+ /// if the entry denotes a table or query, this is the respective UNO object
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ xObjectProperties;
+ /// if the entry denotes a object container, this is the UNO interface for this container
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ xContainer;
+ /// if the entry denotes a data source, this is the connection for this data source (if already connection)
+ SharedConnection xConnection;
+ SbaTableQueryBrowser::EntryType eType;
+ String sAccessor;
+
+ DBTreeListUserData();
+ ~DBTreeListUserData();
+ };
+}
+
+#endif // DBAUI_DBTREEMODEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx
new file mode 100644
index 000000000000..b69c67bc4bee
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreeview.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbtreeview.hxx"
+#include <svtools/svtreebx.hxx>
+#include "dbtreelistbox.hxx"
+#include "dbtreemodel.hxx"
+#include "dbaccess_helpid.hrc"
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+DBG_NAME(DBTreeView)
+//========================================================================
+// class DBTreeView
+//========================================================================
+DBTreeView::DBTreeView( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nBits)
+ : Window( pParent, nBits )
+ , m_pTreeListBox(NULL)
+{
+ DBG_CTOR(DBTreeView,NULL);
+
+ m_pTreeListBox = new DBTreeListBox(this, _rxORB ,WB_HASLINES | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT,sal_True);
+ m_pTreeListBox->EnableCheckButton(NULL);
+ m_pTreeListBox->SetDragDropMode( 0 );
+ m_pTreeListBox->EnableInplaceEditing( sal_True );
+ m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
+ m_pTreeListBox->Show();
+}
+
+// -----------------------------------------------------------------------------
+
+DBTreeView::~DBTreeView()
+{
+ DBG_DTOR(DBTreeView,NULL);
+ if (m_pTreeListBox)
+ {
+ if (m_pTreeListBox->GetModel())
+ {
+ m_pTreeListBox->GetModel()->RemoveView(m_pTreeListBox);
+ m_pTreeListBox->DisconnectFromModel();
+ }
+ ::std::auto_ptr<Window> aTemp(m_pTreeListBox);
+ m_pTreeListBox = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeView::SetPreExpandHandler(const Link& _rHdl)
+{
+ m_pTreeListBox->SetPreExpandHandler(_rHdl);
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeView::setCopyHandler(const Link& _rHdl)
+{
+ m_pTreeListBox->setCopyHandler(_rHdl);
+}
+// -----------------------------------------------------------------------------
+void DBTreeView::Resize()
+{
+ Window::Resize();
+ m_pTreeListBox->SetPosSizePixel(Point(0,0),GetOutputSizePixel());
+}
+// -------------------------------------------------------------------------
+void DBTreeView::setModel(SvLBoxTreeList* _pTreeModel)
+{
+ if (_pTreeModel)
+ _pTreeModel->InsertView(m_pTreeListBox);
+ m_pTreeListBox->SetModel(_pTreeModel);
+}
+
+// -------------------------------------------------------------------------
+void DBTreeView::setSelChangeHdl( const Link& _rHdl )
+{
+ m_pTreeListBox->SetSelChangeHdl( _rHdl );
+}
+// -----------------------------------------------------------------------------
+void DBTreeView::GetFocus()
+{
+ Window::GetFocus();
+ if ( m_pTreeListBox )//&& !m_pTreeListBox->HasChildPathFocus())
+ m_pTreeListBox->GrabFocus();
+}
+
+
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx
new file mode 100644
index 000000000000..2cba0dd10b08
--- /dev/null
+++ b/dbaccess/source/ui/browser/dbtreeview.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_UI_DBTREEVIEW_HXX
+#define DBACCESS_UI_DBTREEVIEW_HXX
+
+#include <vcl/window.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+class SvTreeListBox;
+class SvLBoxTreeList;
+namespace dbaui
+{
+ class DBTreeListBox;
+ // ------------------
+ // - DBTreeView -
+ // ------------------
+
+ class DBTreeView : public Window
+ {
+ private:
+ DBTreeListBox* m_pTreeListBox;
+ protected:
+ // window overridables
+ virtual void Resize();
+ public:
+
+ DBTreeView( Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ WinBits nBits );
+ ~DBTreeView();
+
+ /** sets a handler which is called when an list box entry is to be expanded.
+ <p>When calling the link, the parameter is an SvLBoxEntry marking the entry to be expanded.
+ </p>
+ */
+ void SetPreExpandHandler(const Link& _rHdl);
+ /// gets the currently set NodeExpansionHandler
+
+ void setCopyHandler(const Link& _rHdl);
+
+
+ void setModel(SvLBoxTreeList* _pTreeModel);
+ void setSelChangeHdl(const Link& _rHdl);
+
+ DBTreeListBox& getListBox() const { return *m_pTreeListBox; }
+
+ virtual void GetFocus();
+ };
+}
+
+#endif // DBACCESS_UI_DBTREEVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
new file mode 100644
index 000000000000..f9fe22be550b
--- /dev/null
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -0,0 +1,269 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "unodatbr.hxx"
+#include "browserids.hxx"
+#include "listviewitems.hxx"
+#include "imageprovider.hxx"
+#include <osl/diagnose.h>
+#include "dbtreeview.hxx"
+#include "dbtreelistbox.hxx"
+#include "dbu_brw.hrc"
+#include "dbtreemodel.hxx"
+
+using namespace ::com::sun::star::frame;
+using namespace ::dbtools;
+using namespace ::svx;
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+// -----------------------------------------------------------------------------
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvLBoxEntry* _pEntry ) const
+{
+ OSL_ENSURE(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
+ switch (getEntryType(_pEntry))
+ {
+ case etTableContainer:
+ return etTableOrView;
+ case etQueryContainer:
+ return etQuery;
+ default:
+ break;
+ }
+ return etUnknown;
+}
+
+// -----------------------------------------------------------------------------
+String SbaTableQueryBrowser::GetEntryText( SvLBoxEntry* _pEntry ) const
+{
+ return m_pTreeView->getListBox().GetEntryText(_pEntry);
+}
+
+// -----------------------------------------------------------------------------
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( SvLBoxEntry* _pEntry ) const
+{
+ if (!_pEntry)
+ return etUnknown;
+
+ SvLBoxEntry* pRootEntry = m_pTreeView->getListBox().GetRootLevelParent(_pEntry);
+ SvLBoxEntry* pEntryParent = m_pTreeView->getListBox().GetParent(_pEntry);
+ SvLBoxEntry* pTables = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
+ SvLBoxEntry* pQueries = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
+
+#ifdef DBG_UTIL
+ String sTest;
+ if (pTables) sTest = m_pTreeView->getListBox().GetEntryText(pTables);
+ if (pQueries) sTest = m_pTreeView->getListBox().GetEntryText(pQueries);
+#endif
+
+ if (pRootEntry == _pEntry)
+ return etDatasource;
+
+ if (pTables == _pEntry)
+ return etTableContainer;
+
+ if (pQueries == _pEntry)
+ return etQueryContainer;
+
+ if (pTables == pEntryParent)
+ return etTableOrView;
+
+ if (pQueries == pEntryParent)
+ {
+ DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+ if ( pEntryData )
+ return pEntryData->eType;
+
+ return etQuery;
+ }
+ while( pEntryParent != pQueries )
+ {
+ pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent);
+ if ( !pEntryParent )
+ return etUnknown;
+ }
+
+ return etQueryContainer;
+}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::select(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
+{
+ SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
+ if (pTextItem)
+ {
+ static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
+ m_pTreeModel->InvalidateEntry(_pEntry);
+ }
+ else {
+ OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!");
+ }
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::selectPath(SvLBoxEntry* _pEntry, sal_Bool _bSelect)
+{
+ while (_pEntry)
+ {
+ select(_pEntry, _bSelect);
+ _pEntry = m_pTreeModel->GetParent(_pEntry);
+ }
+}
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::isSelected(SvLBoxEntry* _pEntry) const
+{
+ SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING) : NULL;
+ if (pTextItem)
+ return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
+ else {
+ OSL_FAIL("SbaTableQueryBrowser::isSelected: invalid entry!");
+ }
+ return sal_False;
+}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::SelectionChanged()
+{
+ if ( !m_bShowMenu )
+ {
+ InvalidateFeature(ID_BROWSER_INSERTCOLUMNS);
+ InvalidateFeature(ID_BROWSER_INSERTCONTENT);
+ InvalidateFeature(ID_BROWSER_FORMLETTER);
+ }
+ InvalidateFeature(ID_BROWSER_COPY);
+ InvalidateFeature(ID_BROWSER_CUT);
+}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::describeSupportedFeatures()
+{
+ SbaXDataBrowserController::describeSupportedFeatures();
+
+ implDescribeSupportedFeature( ".uno:Title", ID_BROWSER_TITLE );
+ if ( !m_bShowMenu )
+ {
+ implDescribeSupportedFeature( ".uno:DSBrowserExplorer", ID_BROWSER_EXPLORER, CommandGroup::VIEW );
+
+ implDescribeSupportedFeature( ".uno:DSBFormLetter", ID_BROWSER_FORMLETTER, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DSBInsertColumns", ID_BROWSER_INSERTCOLUMNS, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DSBInsertContent", ID_BROWSER_INSERTCONTENT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DSBDocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE, CommandGroup::VIEW );
+
+ implDescribeSupportedFeature( ".uno:DataSourceBrowser/FormLetter", ID_BROWSER_FORMLETTER );
+ implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertColumns", ID_BROWSER_INSERTCOLUMNS );
+ implDescribeSupportedFeature( ".uno:DataSourceBrowser/InsertContent", ID_BROWSER_INSERTCONTENT );
+ implDescribeSupportedFeature( ".uno:DataSourceBrowser/DocumentDataSource", ID_BROWSER_DOCUMENT_DATASOURCE );
+ }
+
+ implDescribeSupportedFeature( ".uno:CloseWin", ID_BROWSER_CLOSE, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBRebuildData", ID_BROWSER_REFRESH_REBUILD, CommandGroup::DATA );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType )
+{
+ switch ( _eType )
+ {
+ case etQuery:
+ case etQueryContainer:
+ return DatabaseObject::QUERY;
+ case etTableOrView:
+ case etTableContainer:
+ return DatabaseObject::TABLE;
+ default:
+ break;
+ }
+ OSL_FAIL( "SbaTableQueryBrowser::getDatabaseObjectType: folder types and 'Unknown' not allowed here!" );
+ return DatabaseObject::TABLE;
+}
+
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::notifyHiContrastChanged()
+{
+ if ( m_pTreeView )
+ {
+ // change all bitmap entries
+ SvLBoxEntry* pEntryLoop = m_pTreeModel->First();
+ while ( pEntryLoop )
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
+ if ( !pData )
+ {
+ pEntryLoop = m_pTreeModel->Next(pEntryLoop);
+ continue;
+ }
+
+ // the connection to which this entry belongs, if any
+ ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) );
+
+ // the images for this entry
+ Image aImage;
+ if ( pData->eType == etDatasource )
+ aImage = pImageProvider->getDatabaseImage();
+ else
+ {
+ bool bIsFolder = !isObject( pData->eType );
+ if ( bIsFolder )
+ {
+ sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
+ aImage = pImageProvider->getFolderImage( nObjectType );
+ }
+ else
+ {
+ sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
+ pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage );
+ }
+ }
+
+ // find the proper item, and set its icons
+ sal_uInt16 nCount = pEntryLoop->ItemCount();
+ for (sal_uInt16 i=0;i<nCount;++i)
+ {
+ SvLBoxItem* pItem = pEntryLoop->GetItem(i);
+ if ( !pItem || ( pItem->IsA() != SV_ITEM_ID_LBOXCONTEXTBMP ) )
+ continue;
+
+ SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
+
+ pContextBitmapItem->SetBitmap1( aImage );
+ pContextBitmapItem->SetBitmap2( aImage );
+ break;
+ }
+
+ pEntryLoop = m_pTreeModel->Next(pEntryLoop);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
new file mode 100644
index 000000000000..3baafb3e860f
--- /dev/null
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -0,0 +1,298 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbexchange.hxx"
+#include "dbtreelistbox.hxx"
+#include "dbtreemodel.hxx"
+#include "dbtreeview.hxx"
+#include "dbu_brw.hrc"
+#include "dbustrings.hrc"
+#include "QEnumTypes.hxx"
+#include "UITools.hxx"
+#include "unodatbr.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <svtools/treelist.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+
+#include <functional>
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::i18n;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::datatransfer;
+ using namespace ::dbtools;
+ using namespace ::svx;
+
+ // -----------------------------------------------------------------------------
+ TransferableHelper* SbaTableQueryBrowser::implCopyObject( SvLBoxEntry* _pApplyTo, sal_Int32 _nCommandType, sal_Bool _bAllowConnection )
+ {
+ try
+ {
+ ::rtl::OUString aName = GetEntryText( _pApplyTo );
+ ::rtl::OUString aDSName = getDataSourceAcessor( m_pTreeView->getListBox().GetRootLevelParent( _pApplyTo ) );
+
+ ODataClipboard* pData = NULL;
+ SharedConnection xConnection;
+ if ( CommandType::QUERY != _nCommandType )
+ {
+ if ( _bAllowConnection && !ensureConnection( _pApplyTo, xConnection) )
+ return NULL;
+ pData = new ODataClipboard(aDSName, _nCommandType, aName, xConnection, getNumberFormatter(), getORB());
+ }
+ else
+ pData = new ODataClipboard(aDSName, _nCommandType, aName, getNumberFormatter(), getORB());
+
+ // the owner ship goes to ODataClipboards
+ return pData;
+ }
+ catch(const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int8 SbaTableQueryBrowser::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
+ {
+ // check if we're a table or query container
+ SvLBoxEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rEvt.maPosPixel );
+
+ if ( pHitEntry ) // no drop if no entry was hit ....
+ {
+ // it must be a container
+ EntryType eEntryType = getEntryType( pHitEntry );
+ SharedConnection xConnection;
+ if ( eEntryType == etTableContainer && ensureConnection( pHitEntry, xConnection ) && xConnection.is() )
+ {
+ Reference<XChild> xChild(xConnection,UNO_QUERY);
+ Reference<XStorable> xStore(xChild.is() ? getDataSourceOrModel(xChild->getParent()) : Reference<XInterface>(),UNO_QUERY);
+ // check for the concrete type
+ if ( xStore.is() && !xStore->isReadonly() && ::std::find_if(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(E_TABLE,sal_True)) != _rFlavors.end())
+ return DND_ACTION_COPY;
+ }
+ }
+
+ return DND_ACTION_NONE;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int8 SbaTableQueryBrowser::executeDrop( const ExecuteDropEvent& _rEvt )
+ {
+ SvLBoxEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rEvt.maPosPixel );
+ EntryType eEntryType = getEntryType( pHitEntry );
+ if (!isContainer(eEntryType))
+ {
+ OSL_FAIL("SbaTableQueryBrowser::executeDrop: what the hell did queryDrop do?");
+ // queryDrop shoud not have allowed us to reach this situation ....
+ return DND_ACTION_NONE;
+ }
+ // a TransferableDataHelper for accessing the dropped data
+ TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
+
+
+ // reset the data of the previous async drop (if any)
+ if ( m_nAsyncDrop )
+ Application::RemoveUserEvent(m_nAsyncDrop);
+
+
+ m_nAsyncDrop = 0;
+ m_aAsyncDrop.aDroppedData.clear();
+ m_aAsyncDrop.nType = E_TABLE;
+ m_aAsyncDrop.nAction = _rEvt.mnAction;
+ m_aAsyncDrop.bError = sal_False;
+ m_aAsyncDrop.bHtml = sal_False;
+ m_aAsyncDrop.pDroppedAt = NULL;
+ m_aAsyncDrop.aUrl = ::rtl::OUString();
+
+
+ // loop through the available formats and see what we can do ...
+ // first we have to check if it is our own format, if not we have to copy the stream :-(
+ if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) )
+ {
+ m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData);
+ m_aAsyncDrop.pDroppedAt = pHitEntry;
+
+ // asyncron because we some dialogs and we aren't allowed to show them while in D&D
+ m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop));
+ return DND_ACTION_COPY;
+ }
+ else
+ {
+ SharedConnection xDestConnection;
+ if ( ensureConnection( pHitEntry, xDestConnection )
+ && xDestConnection.is()
+ && m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xDestConnection )
+ )
+ {
+ m_aAsyncDrop.pDroppedAt = pHitEntry;
+
+ // asyncron because we some dialogs and we aren't allowed to show them while in D&D
+ m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop));
+ return DND_ACTION_COPY;
+ }
+ }
+
+ return DND_ACTION_NONE;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SbaTableQueryBrowser::requestDrag( sal_Int8 /*_nAction*/, const Point& _rPosPixel )
+ {
+ // get the affected list entry
+ // ensure that the entry which the user clicked at is selected
+ SvLBoxEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rPosPixel );
+ if (!pHitEntry)
+ // no drag of no entry was hit ....
+ return sal_False;
+
+ // it must be a query/table
+ EntryType eEntryType = getEntryType( pHitEntry );
+ if (!isObject(eEntryType))
+ return DND_ACTION_NONE;
+
+ TransferableHelper* pTransfer = implCopyObject( pHitEntry, ( etTableOrView == eEntryType ) ? CommandType::TABLE : CommandType::QUERY);
+ Reference< XTransferable> xEnsureDelete = pTransfer;
+
+ if (pTransfer)
+ pTransfer->StartDrag( &m_pTreeView->getListBox(), DND_ACTION_COPY );
+
+ return NULL != pTransfer;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(SbaTableQueryBrowser, OnCopyEntry, void*, /*NOTINTERESIN*/)
+ {
+ SvLBoxEntry* pSelected = m_pTreeView->getListBox().FirstSelected();
+ if( isEntryCopyAllowed( pSelected ) )
+ copyEntry( pSelected );
+ return 0;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SbaTableQueryBrowser::isEntryCopyAllowed(SvLBoxEntry* _pEntry) const
+ {
+ EntryType eType = getEntryType(_pEntry);
+ return ( eType == etTableOrView || eType == etQuery );
+ }
+ // -----------------------------------------------------------------------------
+ void SbaTableQueryBrowser::copyEntry(SvLBoxEntry* _pEntry)
+ {
+ TransferableHelper* pTransfer = NULL;
+ Reference< XTransferable> aEnsureDelete;
+ EntryType eType = getEntryType(_pEntry);
+ pTransfer = implCopyObject( _pEntry, eType == etQuery ? CommandType::QUERY : CommandType::TABLE);
+ aEnsureDelete = pTransfer;
+ if (pTransfer)
+ pTransfer->CopyToClipboard(getView());
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( SbaTableQueryBrowser, OnAsyncDrop, void*, /*NOTINTERESTEDIN*/ )
+ {
+ m_nAsyncDrop = 0;
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( m_aAsyncDrop.nType == E_TABLE )
+ {
+ SharedConnection xDestConnection;
+ if ( ensureConnection( m_aAsyncDrop.pDroppedAt, xDestConnection ) && xDestConnection.is() )
+ {
+ SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(m_aAsyncDrop.pDroppedAt);
+ m_aTableCopyHelper.asyncCopyTagTable( m_aAsyncDrop, getDataSourceAcessor( pDataSourceEntry ), xDestConnection );
+ }
+ }
+
+ m_aAsyncDrop.aDroppedData.clear();
+
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ void SbaTableQueryBrowser::clearTreeModel()
+ {
+ if (m_pTreeModel)
+ {
+ // clear the user data of the tree model
+ SvLBoxEntry* pEntryLoop = m_pTreeModel->First();
+ while (pEntryLoop)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
+ if(pData)
+ {
+ pEntryLoop->SetUserData(NULL);
+ Reference< XContainer > xContainer(pData->xContainer, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->removeContainerListener(this);
+
+ if ( pData->xConnection.is() )
+ {
+ OSL_ENSURE( impl_isDataSourceEntry( pEntryLoop ), "SbaTableQueryBrowser::clearTreeModel: no data source entry, but a connection?" );
+ // connections are to be stored *only* at the data source entries
+ impl_releaseConnection( pData->xConnection );
+ }
+
+ delete pData;
+ }
+ pEntryLoop = m_pTreeModel->Next(pEntryLoop);
+ }
+ }
+ m_pCurrentlyDisplayed = NULL;
+ }
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx
new file mode 100644
index 000000000000..898f78cd3ebe
--- /dev/null
+++ b/dbaccess/source/ui/browser/exsrcbrw.cxx
@@ -0,0 +1,480 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "exsrcbrw.hxx"
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include "formadapter.hxx"
+#include <comphelper/processfactory.hxx>
+#include "dbustrings.hrc"
+#include "dbu_reghelper.hxx"
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::frame;
+using namespace dbaui;
+
+//==============================================================================
+//= SbaExternalSourceBrowser
+//==============================================================================
+extern "C" void SAL_CALL createRegistryInfo_OFormGridView()
+{
+ static OMultiInstanceAutoRegistration< SbaExternalSourceBrowser > aAutoRegistration;
+}
+//------------------------------------------------------------------------------
+Any SAL_CALL SbaExternalSourceBrowser::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aRet = SbaXDataBrowserController::queryInterface(_rType);
+ if(!aRet.hasValue())
+ aRet = ::cppu::queryInterface(_rType,
+ (::com::sun::star::util::XModifyBroadcaster*)this,
+ (::com::sun::star::form::XLoadListener*)this);
+
+ return aRet;
+}
+DBG_NAME(SbaExternalSourceBrowser)
+//------------------------------------------------------------------------------
+SbaExternalSourceBrowser::SbaExternalSourceBrowser(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
+ :SbaXDataBrowserController(_rM)
+ ,m_aModifyListeners(getMutex())
+ ,m_pDataSourceImpl(NULL)
+ ,m_bInQueryDispatch( sal_False )
+{
+ DBG_CTOR(SbaExternalSourceBrowser,NULL);
+
+}
+
+//------------------------------------------------------------------------------
+SbaExternalSourceBrowser::~SbaExternalSourceBrowser()
+{
+
+ DBG_DTOR(SbaExternalSourceBrowser,NULL);
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL SbaExternalSourceBrowser::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SbaExternalSourceBrowser::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OFormGridView"));
+}
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SbaExternalSourceBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FormGridView"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaExternalSourceBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new SbaExternalSourceBrowser(_rxFactory));
+}
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaExternalSourceBrowser::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+//------------------------------------------------------------------------------
+Reference< XRowSet > SbaExternalSourceBrowser::CreateForm()
+{
+ m_pDataSourceImpl = new SbaXFormAdapter();
+ return m_pDataSourceImpl;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaExternalSourceBrowser::InitializeForm(const Reference< XPropertySet > & /*i_formProperties*/)
+{
+ return sal_True;
+}
+
+//------------------------------------------------------------------
+sal_Bool SbaExternalSourceBrowser::LoadForm()
+{
+ // as we don't have a main form (yet), we have nothing to do
+ // we don't call FormLoaded, because this expects a working data source
+ return sal_True;
+}
+
+
+//------------------------------------------------------------------
+void SbaExternalSourceBrowser::modified(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException )
+{
+ SbaXDataBrowserController::modified(aEvent);
+
+ // multiplex this event to all my listeners
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ ::cppu::OInterfaceIteratorHelper aIt(m_aModifyListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::util::XModifyListener*)aIt.next())->modified(aEvt);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) throw(::com::sun::star::uno::RuntimeException)
+{
+ const ::com::sun::star::beans::PropertyValue* pArguments = aArgs.getConstArray();
+ if (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/AddGridColumn"))))
+ {
+ // search the argument describing the column to create
+ ::rtl::OUString sControlType;
+ sal_Int32 nControlPos = -1;
+ Sequence< ::com::sun::star::beans::PropertyValue> aControlProps;
+ sal_uInt16 i;
+ for ( i = 0; i < aArgs.getLength(); ++i, ++pArguments )
+ {
+ if (pArguments->Name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnType"))))
+ {
+ sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const ::rtl::OUString*)0));
+ OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnType\" !");
+ if (bCorrectType)
+ sControlType = ::comphelper::getString(pArguments->Value);
+ }
+ else if (pArguments->Name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnPosition"))))
+ {
+ sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const sal_Int16*)0));
+ OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnPosition\" !");
+ if (bCorrectType)
+ nControlPos = ::comphelper::getINT16(pArguments->Value);
+ }
+ else if (pArguments->Name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnProperties"))))
+ {
+ sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const Sequence< ::com::sun::star::beans::PropertyValue>*)0));
+ OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnProperties\" !");
+ if (bCorrectType)
+ aControlProps = *(Sequence< ::com::sun::star::beans::PropertyValue>*)pArguments->Value.getValue();
+ }
+ else
+ OSL_FAIL(((ByteString("SbaExternalSourceBrowser::dispatch(AddGridColumn) : unknown argument (") += ByteString((const sal_Unicode*)pArguments->Name, gsl_getSystemTextEncoding()).GetBuffer()) += ") !").GetBuffer());
+ }
+ if (!sControlType.getLength())
+ {
+ OSL_FAIL("SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnType) !");
+ sControlType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextField"));
+ }
+ OSL_ENSURE(aControlProps.getLength(), "SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnProperties) !");
+
+ // create the col
+ Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(getControlModel(), UNO_QUERY);
+ Reference< ::com::sun::star::beans::XPropertySet > xNewCol = xColFactory->createColumn(sControlType);
+ Reference< XPropertySetInfo > xNewColProperties;
+ if (xNewCol.is())
+ xNewColProperties = xNewCol->getPropertySetInfo();
+ // set its properties
+ if (xNewColProperties.is())
+ {
+ const ::com::sun::star::beans::PropertyValue* pControlProps = aControlProps.getConstArray();
+ for (i=0; i<aControlProps.getLength(); ++i, ++pControlProps)
+ {
+ try
+ {
+ if (xNewColProperties->hasPropertyByName(pControlProps->Name))
+ xNewCol->setPropertyValue(pControlProps->Name, pControlProps->Value);
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL(( ByteString("SbaExternalSourceBrowser::dispatch : could not set a column property (")
+ += ByteString(pControlProps->Name.getStr(), (sal_uInt16)pControlProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ByteString(")!")).GetBuffer());
+ }
+ }
+ }
+
+ // correct the position
+ Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY);
+
+ if (nControlPos > xColContainer->getCount())
+ nControlPos = xColContainer->getCount();
+ if (nControlPos < 0)
+ nControlPos = 0;
+
+ // append the column
+ xColContainer->insertByIndex(nControlPos, makeAny(xNewCol));
+ }
+ else if (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/ClearView"))))
+ {
+ ClearView();
+ }
+ else if (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/AttachToForm"))))
+ {
+ if (!m_pDataSourceImpl)
+ return;
+
+ Reference< XRowSet > xMasterForm;
+ // search the arguments for the master form
+ for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArguments)
+ {
+ if ((pArguments->Name.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MasterForm")))) && (pArguments->Value.getValueTypeClass() == TypeClass_INTERFACE))
+ {
+ xMasterForm = Reference< XRowSet > (*(Reference< XInterface > *)pArguments->Value.getValue(), UNO_QUERY);
+ break;
+ }
+ }
+ if (!xMasterForm.is())
+ {
+ OSL_FAIL("SbaExternalSourceBrowser::dispatch(FormSlots/AttachToForm) : please specify a form to attach to as argument !");
+ return;
+ }
+
+ Attach(xMasterForm);
+ }
+ else
+ SbaXDataBrowserController::dispatch(aURL, aArgs);
+}
+
+//------------------------------------------------------------------
+Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaExternalSourceBrowser::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatch > xReturn;
+ if (m_bInQueryDispatch)
+ return xReturn;
+
+ m_bInQueryDispatch = sal_True;
+
+ if ( (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/AttachToForm"))))
+ // attach a new external form
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/AddGridColumn"))))
+ // add a column to the grid
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/ClearView"))))
+ // clear the grid
+ )
+ xReturn = (::com::sun::star::frame::XDispatch*)this;
+
+ if ( !xReturn.is()
+ && ( (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/moveToFirst"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/moveToPrev"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/moveToNext"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/moveToLast"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/moveToNew"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:FormSlots/undoRecord"))))
+ )
+ )
+ {
+ OSL_ENSURE(aURL.Mark.getLength() == 0, "SbaExternalSourceBrowser::queryDispatch : the ::com::sun::star::util::URL shouldn't have a mark !");
+ ::com::sun::star::util::URL aNewUrl = aURL;
+
+ // split the ::com::sun::star::util::URL
+ OSL_ENSURE( m_xUrlTransformer.is(), "SbaExternalSourceBrowser::queryDispatch : could not create an URLTransformer !" );
+ if ( m_xUrlTransformer.is() )
+ m_xUrlTransformer->parseStrict( aNewUrl );
+
+ // set a new mark
+ aNewUrl.Mark = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DB/FormGridView"));
+ // this controller is instantiated when somebody dispatches the ".component:DB/FormGridView" in any
+ // frame, so we use "FormGridView" as mark that a dispatch request came from this view
+
+ if (m_xUrlTransformer.is())
+ m_xUrlTransformer->assemble(aNewUrl);
+
+ Reference< XDispatchProvider > xFrameDispatcher( getFrame(), UNO_QUERY );
+ if (xFrameDispatcher.is())
+ xReturn = xFrameDispatcher->queryDispatch(aNewUrl, aTargetFrameName, FrameSearchFlag::PARENT);
+
+ }
+
+ if (!xReturn.is())
+ xReturn = SbaXDataBrowserController::queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+
+ m_bInQueryDispatch = sal_False;
+ return xReturn;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::disposing()
+{
+ // say our modify listeners goodbye
+ ::com::sun::star::lang::EventObject aEvt;
+ aEvt.Source = (XWeak*) this;
+ m_aModifyListeners.disposeAndClear(aEvt);
+
+ stopListening();
+
+ SbaXDataBrowserController::disposing();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException )
+{
+ m_aModifyListeners.addInterface(aListener);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException )
+{
+ m_aModifyListeners.removeInterface(aListener);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException )
+{
+ if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == aEvent.Source))
+ {
+ ClearView();
+ }
+
+ SbaXDataBrowserController::unloading(aEvent);
+}
+
+//------------------------------------------------------------------
+void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster)
+{
+ Any aOldPos;
+ sal_Bool bWasInsertRow = sal_False;
+ sal_Bool bBeforeFirst = sal_True;
+ sal_Bool bAfterLast = sal_True;
+ Reference< XResultSet > xResultSet(xMaster, UNO_QUERY);
+ Reference< XRowLocate > xCursor(xMaster, UNO_QUERY);
+ Reference< XPropertySet > xMasterProps(xMaster, UNO_QUERY);
+
+ try
+ {
+ // switch the control to design mode
+ if (getBrowserView() && getBrowserView()->getGridControl().is())
+ getBrowserView()->getGridControl()->setDesignMode(sal_True);
+
+ // the grid will move the form's cursor to the first record, but we want the form to remain unchanged
+ // restore the old position
+ if (xCursor.is() && xResultSet.is())
+ {
+ bBeforeFirst = xResultSet->isBeforeFirst();
+ bAfterLast = xResultSet->isAfterLast();
+ if(!bBeforeFirst && !bAfterLast)
+ aOldPos = xCursor->getBookmark();
+ }
+
+ if (xMasterProps.is())
+ xMasterProps->getPropertyValue(PROPERTY_ISNEW) >>= bWasInsertRow;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ onStartLoading( Reference< XLoadable >( xMaster, UNO_QUERY ) );
+
+ stopListening();
+ m_pDataSourceImpl->AttachForm(xMaster);
+ startListening();
+
+ if (xMaster.is())
+ {
+ // at this point we have to reset the formatter for the new form
+ initFormatter();
+ // assume that the master form is already loaded
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Reference< XLoadable > xLoadable( xMaster, UNO_QUERY );
+ OSL_ENSURE( xLoadable.is() && xLoadable->isLoaded(), "SbaExternalSourceBrowser::Attach: master is not loaded!" );
+ }
+#endif
+
+ LoadFinished(sal_True);
+
+ Reference< XResultSetUpdate > xUpdate(xMaster, UNO_QUERY);
+ try
+ {
+ if (bWasInsertRow && xUpdate.is())
+ xUpdate->moveToInsertRow();
+ else if (xCursor.is() && aOldPos.hasValue())
+ xCursor->moveToBookmark(aOldPos);
+ else if(bBeforeFirst && xResultSet.is())
+ xResultSet->beforeFirst();
+ else if(bAfterLast && xResultSet.is())
+ xResultSet->afterLast();
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaExternalSourceBrowser::Attach : couldn't restore the cursor position !");
+ }
+
+ }
+}
+
+//------------------------------------------------------------------
+void SbaExternalSourceBrowser::ClearView()
+{
+ // set a new (empty) datasource
+ Attach(Reference< XRowSet > ());
+
+
+ // clear all cols in the grid
+ Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY);
+ while (xColContainer->getCount() > 0)
+ xColContainer->removeByIndex(0);
+}
+
+//------------------------------------------------------------------
+void SAL_CALL SbaExternalSourceBrowser::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException )
+{
+ if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == Source.Source))
+ {
+ ClearView();
+ }
+
+ SbaXDataBrowserController::disposing(Source);
+}
+
+//------------------------------------------------------------------
+void SbaExternalSourceBrowser::startListening()
+{
+ if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is())
+ {
+ Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY);
+ xLoadable->addLoadListener((::com::sun::star::form::XLoadListener*)this);
+ }
+}
+
+//------------------------------------------------------------------
+void SbaExternalSourceBrowser::stopListening()
+{
+ if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is())
+ {
+ Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY);
+ xLoadable->removeLoadListener((::com::sun::star::form::XLoadListener*)this);
+ }
+}
+
+//==================================================================
+//==================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx
new file mode 100644
index 000000000000..913a491b0c0f
--- /dev/null
+++ b/dbaccess/source/ui/browser/formadapter.cxx
@@ -0,0 +1,1777 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "formadapter.hxx"
+#include <tools/debug.hxx>
+#include <osl/diagnose.h>
+#include <comphelper/types.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <tools/string.hxx>
+#include "dbu_brw.hrc"
+#include "dbustrings.hrc"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+//==================================================================
+// SbaXFormAdapter
+//==================================================================
+
+DBG_NAME(SbaXFormAdapter)
+// -------------------------------------------------------------------------
+SbaXFormAdapter::SbaXFormAdapter()
+ :m_aLoadListeners(*this, m_aMutex)
+ ,m_aRowSetListeners(*this, m_aMutex)
+ ,m_aRowSetApproveListeners(*this, m_aMutex)
+ ,m_aErrorListeners(*this, m_aMutex)
+ ,m_aParameterListeners(*this, m_aMutex)
+ ,m_aSubmitListeners(*this, m_aMutex)
+ ,m_aResetListeners(*this, m_aMutex)
+ ,m_aPropertyChangeListeners(*this, m_aMutex)
+ ,m_aVetoablePropertyChangeListeners(*this, m_aMutex)
+ ,m_aPropertiesChangeListeners(*this, m_aMutex)
+ ,m_aDisposeListeners(m_aMutex)
+ ,m_aContainerListeners(m_aMutex)
+ ,m_nNamePropHandle(-1)
+{
+ DBG_CTOR(SbaXFormAdapter,NULL);
+
+}
+
+// -------------------------------------------------------------------------
+SbaXFormAdapter::~SbaXFormAdapter()
+{
+
+ DBG_DTOR(SbaXFormAdapter,NULL);
+}
+
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL SbaXFormAdapter::getTypes( ) throw (RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ SbaXFormAdapter_BASE1::getTypes(),
+ SbaXFormAdapter_BASE2::getTypes(),
+ SbaXFormAdapter_BASE3::getTypes()
+ );
+}
+
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getImplementationId( ) throw (RuntimeException)
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn = SbaXFormAdapter_BASE1::queryInterface( _rType );
+
+ if (!aReturn.hasValue())
+ aReturn = SbaXFormAdapter_BASE2::queryInterface( _rType );
+
+ if (!aReturn.hasValue())
+ aReturn = SbaXFormAdapter_BASE3::queryInterface( _rType );
+
+ return aReturn;
+}
+
+// -------------------------------------------------------------------------
+void SbaXFormAdapter::StopListening()
+{
+ // log off all our multiplexers
+ STOP_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
+ STOP_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
+ STOP_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
+ STOP_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
+ STOP_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
+ STOP_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
+
+ if (m_aParameterListeners.getLength())
+ {
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removeParameterListener(&m_aParameterListeners);
+ }
+
+ STOP_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+ STOP_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+ if (m_aPropertiesChangeListeners.getLength())
+ {
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
+ }
+
+ // log off ourself
+ Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
+}
+
+// -------------------------------------------------------------------------
+void SbaXFormAdapter::StartListening()
+{
+ // log off all our multiplexers
+ START_MULTIPLEXER_LISTENING(LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm);
+ START_MULTIPLEXER_LISTENING(RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm);
+ START_MULTIPLEXER_LISTENING(RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm);
+ START_MULTIPLEXER_LISTENING(SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm);
+ START_MULTIPLEXER_LISTENING(SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm);
+ START_MULTIPLEXER_LISTENING(ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm);
+
+ if (m_aParameterListeners.getLength())
+ {
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->addParameterListener(&m_aParameterListeners);
+ }
+
+ START_PROPERTY_MULTIPLEXER_LISTENING(PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+ START_PROPERTY_MULTIPLEXER_LISTENING(VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+ if (m_aPropertiesChangeListeners.getLength())
+ {
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
+ ::rtl::OUString sEmpty;
+ if (xBroadcaster.is())
+ xBroadcaster->addPropertiesChangeListener(::comphelper::StringSequence(&sEmpty, 1), &m_aPropertiesChangeListeners);
+ }
+
+ // log off ourself
+ Reference< ::com::sun::star::lang::XComponent > xComp(m_xMainForm, UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener((::com::sun::star::lang::XEventListener*)(::com::sun::star::beans::XPropertyChangeListener*)this);
+}
+
+// -------------------------------------------------------------------------
+void SbaXFormAdapter::AttachForm(const Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster)
+{
+ if (xNewMaster == m_xMainForm)
+ return;
+
+ OSL_ENSURE(xNewMaster.get() != static_cast< ::com::sun::star::sdbc::XRowSet* >(this), "SbaXFormAdapter::AttachForm : invalid argument !");
+
+ if (m_xMainForm.is())
+ {
+ StopListening();
+
+ // if our old master is loaded we have to send an 'unloaded' event
+ Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
+ if (xLoadable->isLoaded())
+ {
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::form::XLoadListener*)aIt.next())->unloaded(aEvt);
+ }
+ }
+
+ m_xMainForm = xNewMaster;
+
+ if (m_xMainForm.is())
+ {
+ StartListening();
+
+ // if our new master is loaded we have to send an 'loaded' event
+ Reference< ::com::sun::star::form::XLoadable > xLoadable(m_xMainForm, UNO_QUERY);
+ if (xLoadable->isLoaded())
+ {
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ ::cppu::OInterfaceIteratorHelper aIt(m_aLoadListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::form::XLoadListener*)aIt.next())->loaded(aEvt);
+ }
+ }
+
+ // TODO : perhaps _all_ of our listeners should be notified about our new state
+ // (nearly every aspect of us may have changed with new master form)
+}
+
+// ::com::sun::star::sdbc::XCloseable
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::close() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XCloseable > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->close();
+}
+
+// ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL SbaXFormAdapter::getMetaData() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetMetaDataSupplier > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getMetaData();
+ return Reference< ::com::sun::star::sdbc::XResultSetMetaData > ();
+}
+
+// ::com::sun::star::sdbc::XColumnLocate
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::findColumn(const ::rtl::OUString& columnName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XColumnLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->findColumn(columnName);
+ return 0;
+}
+
+// ::com::sun::star::sdbcx::XColumnsSupplier
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL SbaXFormAdapter::getColumns() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getColumns();
+ return Reference< ::com::sun::star::container::XNameAccess > ();
+}
+
+// ::com::sun::star::sdbc::XRow
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::wasNull() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->wasNull();
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXFormAdapter::getString(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getString(columnIndex);
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::getBoolean(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getBoolean(columnIndex);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL SbaXFormAdapter::getByte(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getByte(columnIndex);
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL SbaXFormAdapter::getShort(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getShort(columnIndex);
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::getInt(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getInt(columnIndex);
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL SbaXFormAdapter::getLong(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getLong(columnIndex);
+ return 0;
+}
+// -------------------------------------------------------------------------
+float SAL_CALL SbaXFormAdapter::getFloat(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getFloat(columnIndex);
+ return 0.0;
+}
+// -------------------------------------------------------------------------
+double SAL_CALL SbaXFormAdapter::getDouble(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getDouble(columnIndex);
+ return 0.0;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL SbaXFormAdapter::getBytes(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getBytes(columnIndex);
+ return Sequence <sal_Int8> ();
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL SbaXFormAdapter::getDate(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getDate(columnIndex);
+ return ::com::sun::star::util::Date();
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL SbaXFormAdapter::getTime(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getTime(columnIndex);
+ return ::com::sun::star::util::Time();
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL SbaXFormAdapter::getTimestamp(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getTimestamp(columnIndex);
+ return ::com::sun::star::util::DateTime();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getBinaryStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getBinaryStream(columnIndex);
+ return Reference< ::com::sun::star::io::XInputStream > ();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL SbaXFormAdapter::getCharacterStream(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getCharacterStream(columnIndex);
+ return Reference< ::com::sun::star::io::XInputStream > ();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getObject(columnIndex, typeMap);
+ return Any();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XRef > SAL_CALL SbaXFormAdapter::getRef(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getRef(columnIndex);
+ return Reference< ::com::sun::star::sdbc::XRef > ();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL SbaXFormAdapter::getBlob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getBlob(columnIndex);
+ return Reference< ::com::sun::star::sdbc::XBlob > ();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XClob > SAL_CALL SbaXFormAdapter::getClob(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getClob(columnIndex);
+ return Reference< ::com::sun::star::sdbc::XClob > ();
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XArray > SAL_CALL SbaXFormAdapter::getArray(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRow > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getArray(columnIndex);
+ return Reference< ::com::sun::star::sdbc::XArray > ();
+}
+
+// ::com::sun::star::sdbcx::XRowLocate
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getBookmark() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getBookmark();
+ return Any();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::moveToBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->moveToBookmark(bookmark);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->moveRelativeToBookmark(bookmark,rows);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::compareBookmarks(const Any& _first, const Any& _second) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->compareBookmarks(_first, _second);
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::hasOrderedBookmarks() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->hasOrderedBookmarks();
+ return sal_False;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::hashBookmark(const Any& bookmark) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->hashBookmark(bookmark);
+ return 0;
+}
+
+// ::com::sun::star::sdbc::XRowUpdate
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateNull(sal_Int32 columnIndex) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateNull(columnIndex);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateBoolean(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateByte(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateShort(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateInt(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateLong(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateFloat(sal_Int32 columnIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateFloat(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateDouble(sal_Int32 columnIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateDouble(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateString(sal_Int32 columnIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateString(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateBytes(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateDate(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateTime(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateTimestamp(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateBinaryStream(columnIndex, x, length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateCharacterStream(columnIndex, x, length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateObject(sal_Int32 columnIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateObject(columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XRowUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateNumericObject(columnIndex, x, scale);
+}
+
+// ::com::sun::star::sdbc::XResultSet
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::next() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->next();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::isBeforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->isBeforeFirst();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::isAfterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->isAfterLast();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::isFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->isFirst();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::isLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->isLast();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::beforeFirst() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ m_xMainForm->beforeFirst();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::afterLast() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ m_xMainForm->afterLast();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::first() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->first();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::last() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->last();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::getRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->getRow();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::absolute(sal_Int32 row) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->absolute(row);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::relative(sal_Int32 rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->relative(rows);
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::previous() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->previous();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::refreshRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ m_xMainForm->refreshRow();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::rowUpdated() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->rowUpdated();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::rowInserted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->rowInserted();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::rowDeleted() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->rowDeleted();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaXFormAdapter::getStatement() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ return m_xMainForm->getStatement();
+ return NULL;
+}
+
+// ::com::sun::star::sdbc::XResultSetUpdate
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::insertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->insertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::updateRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->updateRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::deleteRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->deleteRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::cancelRowUpdates() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->cancelRowUpdates();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::moveToInsertRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->moveToInsertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::moveToCurrentRow() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XResultSetUpdate > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->moveToCurrentRow();
+}
+
+// ::com::sun::star::sdbc::XRowSet
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::execute() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ if (m_xMainForm.is())
+ m_xMainForm->execute();
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdbc, RowSetListener, m_aRowSetListeners, ::com::sun::star::sdbc::XRowSet, m_xMainForm)
+
+// ::com::sun::star::sdbcx::XDeleteRows
+// -------------------------------------------------------------------------
+Sequence<sal_Int32> SAL_CALL SbaXFormAdapter::deleteRows(const Sequence< Any >& rows) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbcx::XDeleteRows > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->deleteRows(rows);
+ return Sequence<sal_Int32>();
+}
+
+// ::com::sun::star::sdbc::XWarningsSupplier
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->getWarnings();
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::clearWarnings() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XWarningsSupplier > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->clearWarnings();
+}
+
+// ::com::sun::star::sdb::XRowSetApproveBroadcaster
+// -------------------------------------------------------------------------
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, RowSetApproveListener, m_aRowSetApproveListeners, ::com::sun::star::sdb::XRowSetApproveBroadcaster, m_xMainForm)
+
+// com::sun::star::sdbc::XSQLErrorBroadcaster
+// -------------------------------------------------------------------------
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, sdb, SQLErrorListener, m_aErrorListeners, ::com::sun::star::sdb::XSQLErrorBroadcaster, m_xMainForm)
+
+// ::com::sun::star::sdb::XResultSetAccess
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL SbaXFormAdapter::createResultSet() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdb::XResultSetAccess > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->createResultSet();
+ return Reference< ::com::sun::star::sdbc::XResultSet > ();
+}
+
+// com::sun::star::form::XLoadable
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::load() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->load();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::unload() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->unload();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::reload() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->reload();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::isLoaded() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XLoadable > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ return xIface->isLoaded();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, LoadListener, m_aLoadListeners, ::com::sun::star::form::XLoadable, m_xMainForm)
+
+// ::com::sun::star::sdbc::XParameters
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setNull(parameterIndex, sqlType);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setObjectNull(parameterIndex, sqlType, typeName);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setBoolean(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setByte(sal_Int32 parameterIndex, sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setByte(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setShort(sal_Int32 parameterIndex, sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setShort(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setInt(sal_Int32 parameterIndex, sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setInt(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setLong(sal_Int32 parameterIndex, sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setLong(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setFloat(sal_Int32 parameterIndex, float x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setFloat(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setDouble(sal_Int32 parameterIndex, double x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setDouble(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setString(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setBytes(sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setBytes(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setDate(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setTime(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setTimestamp(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setBinaryStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setBinaryStream(parameterIndex, x, length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setCharacterStream(sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setCharacterStream(parameterIndex, x, length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setObject(sal_Int32 parameterIndex, const Any& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setObject(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setObjectWithInfo(sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setObjectWithInfo(parameterIndex, x, targetSqlType, scale);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setRef(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XRef >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setRef(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setBlob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XBlob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setBlob(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setClob(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XClob >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setClob(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setArray(sal_Int32 parameterIndex, const Reference< ::com::sun::star::sdbc::XArray >& x) throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->setArray(parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::clearParameters() throw( ::com::sun::star::sdbc::SQLException, RuntimeException )
+{
+ Reference< ::com::sun::star::sdbc::XParameters > xIface(m_xMainForm, UNO_QUERY);
+ if (xIface.is())
+ xIface->clearParameters();
+}
+
+// ::com::sun::star::form::XDatabaseParameterBroadcaster
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::addParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
+{
+ m_aParameterListeners.addInterface(aListener);
+ if (m_aParameterListeners.getLength() == 1)
+ {
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->addParameterListener(&m_aParameterListeners);
+ }
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removeParameterListener(const Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw( RuntimeException )
+{
+ if (m_aParameterListeners.getLength() == 1)
+ {
+ Reference< ::com::sun::star::form::XDatabaseParameterBroadcaster > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removeParameterListener(&m_aParameterListeners);
+ }
+ m_aParameterListeners.removeInterface(aListener);
+}
+
+// ::com::sun::star::container::XChild
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaXFormAdapter::getParent() throw( RuntimeException )
+{
+ return m_xParent;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setParent(const Reference< XInterface >& Parent) throw( ::com::sun::star::lang::NoSupportException, RuntimeException )
+{
+ m_xParent = Parent;
+}
+
+// ::com::sun::star::form::XSubmit
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::submit(const Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XSubmit > xSubmit(m_xMainForm, UNO_QUERY);
+ if (xSubmit.is())
+ xSubmit->submit(aControl, aMouseEvt);
+}
+
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, SubmitListener, m_aSubmitListeners, ::com::sun::star::form::XSubmit, m_xMainForm)
+
+// ::com::sun::star::awt::XTabControllerModel
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::getGroupControl() throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupControl : not supported !");
+ return sal_False;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroupControl : not supported !");
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setControlModels(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*Controls*/) throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::setControlModels : not supported !");
+}
+
+// -------------------------------------------------------------------------
+Sequence< Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL SbaXFormAdapter::getControlModels() throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::getControlModels : not supported !");
+ return Sequence< Reference< ::com::sun::star::awt::XControlModel > >();
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setGroup(const Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, const ::rtl::OUString& /*GroupName*/) throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::setGroup : not supported !");
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::getGroupCount() throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupCount : not supported !");
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/, ::rtl::OUString& /*Name*/) throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroup : not supported !");
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::getGroupByName(const ::rtl::OUString& /*Name*/, Sequence< Reference< ::com::sun::star::awt::XControlModel > >& /*_rGroup*/) throw( RuntimeException )
+{
+ OSL_FAIL("SAL_CALL SbaXFormAdapter::getGroupByName : not supported !");
+}
+
+// ::com::sun::star::lang::XComponent
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::dispose() throw( RuntimeException )
+{
+ // log off all multiplexers
+ if (m_xMainForm.is())
+ StopListening();
+
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aLoadListeners.disposeAndClear(aEvt);
+ m_aRowSetListeners.disposeAndClear(aEvt);
+ m_aRowSetApproveListeners.disposeAndClear(aEvt);
+ m_aErrorListeners.disposeAndClear(aEvt);
+ m_aParameterListeners.disposeAndClear(aEvt);
+ m_aSubmitListeners.disposeAndClear(aEvt);
+ m_aResetListeners.disposeAndClear(aEvt);
+
+ m_aVetoablePropertyChangeListeners.disposeAndClear();
+ m_aPropertyChangeListeners.disposeAndClear();
+ m_aPropertiesChangeListeners.disposeAndClear(aEvt);
+
+ m_aDisposeListeners.disposeAndClear(aEvt);
+ m_aContainerListeners.disposeAndClear(aEvt);
+
+ // dispose all childs
+ for ( ::std::vector< Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = m_aChildren.begin();
+ aIter != m_aChildren.end();
+ ++aIter
+ )
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xSet(*aIter, UNO_QUERY);
+ if (xSet.is())
+ xSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
+
+ Reference< ::com::sun::star::container::XChild > xChild(*aIter, UNO_QUERY);
+ if (xChild.is())
+ xChild->setParent(Reference< XInterface > ());
+
+ Reference< ::com::sun::star::lang::XComponent > xComp(*aIter, UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_aChildren.clear();
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::addEventListener(const Reference< ::com::sun::star::lang::XEventListener >& xListener) throw( RuntimeException )
+{
+ m_aDisposeListeners.addInterface(xListener);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removeEventListener(const Reference< ::com::sun::star::lang::XEventListener >& aListener) throw( RuntimeException )
+{
+ m_aDisposeListeners.removeInterface(aListener);
+}
+
+// ::com::sun::star::beans::XFastPropertySet
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setFastPropertyValue(sal_Int32 nHandle, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::setFastPropertyValue : have no master form !");
+
+ if (m_nNamePropHandle == nHandle)
+ {
+ if (aValue.getValueType().getTypeClass() != TypeClass_STRING)
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ // for notifying property listeners
+ ::com::sun::star::beans::PropertyChangeEvent aEvt;
+ aEvt.Source = *this;
+ aEvt.PropertyName = PROPERTY_NAME;
+ aEvt.PropertyHandle = m_nNamePropHandle;
+ aEvt.OldValue <<= m_sName;
+ aEvt.NewValue = aValue;
+
+ aValue >>= m_sName;
+
+ ::cppu::OInterfaceIteratorHelper aIt(*m_aPropertyChangeListeners.getContainer(PROPERTY_NAME));
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::beans::XPropertyChangeListener*)aIt.next())->propertyChange(aEvt);
+
+ return;
+ }
+
+ xSet->setFastPropertyValue(nHandle, aValue);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getFastPropertyValue(sal_Int32 nHandle) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XFastPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ OSL_ENSURE(xSet.is(), "SAL_CALL SbaXFormAdapter::getFastPropertyValue : have no master form !");
+
+ if (m_nNamePropHandle == nHandle)
+ return makeAny(m_sName);
+
+ return xSet->getFastPropertyValue(nHandle);
+}
+
+// ::com::sun::star::container::XNamed
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXFormAdapter::getName() throw( RuntimeException )
+{
+ return ::comphelper::getString(getPropertyValue(PROPERTY_NAME));
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setName(const ::rtl::OUString& aName) throw( RuntimeException )
+{
+ setPropertyValue(PROPERTY_NAME, makeAny(aName));
+}
+
+// ::com::sun::star::io::XPersistObject
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXFormAdapter::getServiceName() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
+ if (xPersist.is())
+ return xPersist->getServiceName();
+ return ::rtl::OUString();
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::write(const Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw( ::com::sun::star::io::IOException, RuntimeException )
+{
+ Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
+ if (xPersist.is())
+ xPersist->write(_rxOutStream);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::read(const Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw( ::com::sun::star::io::IOException, RuntimeException )
+{
+ Reference< ::com::sun::star::io::XPersistObject > xPersist(m_xMainForm, UNO_QUERY);
+ if (xPersist.is())
+ xPersist->read(_rxInStream);
+}
+
+// ::com::sun::star::beans::XMultiPropertySet
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertySetInfo() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (!xSet.is())
+ return Reference< ::com::sun::star::beans::XPropertySetInfo > ();
+
+ Reference< ::com::sun::star::beans::XPropertySetInfo > xReturn = xSet->getPropertySetInfo();
+ if (-1 == m_nNamePropHandle)
+ {
+ // we need to determine the handle for the NAME property
+ Sequence< ::com::sun::star::beans::Property> aProps = xReturn->getProperties();
+ const ::com::sun::star::beans::Property* pProps = aProps.getConstArray();
+
+ for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
+ {
+ if (pProps->Name.equals(PROPERTY_NAME))
+ {
+ ((SbaXFormAdapter*)this)->m_nNamePropHandle = pProps->Handle;
+ break;
+ }
+ }
+ }
+ return xReturn;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setPropertyValues(const Sequence< ::rtl::OUString >& PropertyNames, const Sequence< Any >& Values) throw( ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (xSet.is())
+ xSet->setPropertyValues(PropertyNames, Values);
+}
+
+// -------------------------------------------------------------------------
+Sequence< Any > SAL_CALL SbaXFormAdapter::getPropertyValues(const Sequence< ::rtl::OUString >& aPropertyNames) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (!xSet.is())
+ return Sequence< Any>(aPropertyNames.getLength());
+
+ Sequence< Any> aReturn = xSet->getPropertyValues(aPropertyNames);
+
+ // search for (and fake) the NAME property
+ const ::rtl::OUString* pNames = aPropertyNames.getConstArray();
+ Any* pValues = aReturn.getArray();
+ OSL_ENSURE(aReturn.getLength() == aPropertyNames.getLength(), "SAL_CALL SbaXFormAdapter::getPropertyValues : the main form returned an invalid-length sequence !");
+ for (sal_Int32 i=0; i<aPropertyNames.getLength(); ++i, ++pNames, ++pValues)
+ if (pNames->equals(PROPERTY_NAME))
+ {
+ (*pValues) <<= m_sName;
+ break;
+ }
+
+ return aReturn;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::addPropertiesChangeListener(const Sequence< ::rtl::OUString>& /*aPropertyNames*/, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
+{
+ // we completely ignore the property names, _all_ changes of _all_ properties will be forwarded to _all_ listeners
+ m_aPropertiesChangeListeners.addInterface(xListener);
+ if (m_aPropertiesChangeListeners.getLength() == 1)
+ {
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
+ ::rtl::OUString sEmpty;
+ if (xBroadcaster.is())
+ xBroadcaster->addPropertiesChangeListener(Sequence< ::rtl::OUString>(&sEmpty, 1), &m_aPropertiesChangeListeners);
+ }
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removePropertiesChangeListener(const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw( RuntimeException )
+{
+ if (m_aPropertiesChangeListeners.getLength() == 1)
+ {
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xBroadcaster(m_xMainForm, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removePropertiesChangeListener(&m_aPropertiesChangeListeners);
+ }
+ m_aPropertiesChangeListeners.removeInterface(Listener);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::firePropertiesChangeEvent(const Sequence< ::rtl::OUString >& aPropertyNames, const Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XMultiPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (xSet.is())
+ xSet->firePropertiesChangeEvent(aPropertyNames, xListener);
+}
+
+
+// ::com::sun::star::beans::XPropertySet
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (!xSet.is())
+ return;
+
+ // special handling for the "name" property
+ if (aPropertyName.equals(PROPERTY_NAME))
+ setFastPropertyValue(m_nNamePropHandle, aValue);
+
+ xSet->setPropertyValue(aPropertyName, aValue);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getPropertyValue(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertySet > xSet(m_xMainForm, UNO_QUERY);
+ if (!xSet.is())
+ return Any();
+
+ // special handling for the "name" property
+ if (PropertyName.equals(PROPERTY_NAME))
+ return getFastPropertyValue(m_nNamePropHandle);
+
+ return xSet->getPropertyValue(PropertyName);
+}
+
+IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, PropertyChangeListener, m_aPropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(SbaXFormAdapter, VetoableChangeListener, m_aVetoablePropertyChangeListeners, ::com::sun::star::beans::XPropertySet, m_xMainForm);
+
+// ::com::sun::star::util::XCancellable
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::cancel() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::util::XCancellable > xCancel(m_xMainForm, UNO_QUERY);
+ if (xCancel.is())
+ return;
+ xCancel->cancel();
+}
+
+// ::com::sun::star::beans::XPropertyState
+// -------------------------------------------------------------------------
+::com::sun::star::beans::PropertyState SAL_CALL SbaXFormAdapter::getPropertyState(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyState(PropertyName);
+ return ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
+}
+
+// -------------------------------------------------------------------------
+Sequence< ::com::sun::star::beans::PropertyState> SAL_CALL SbaXFormAdapter::getPropertyStates(const Sequence< ::rtl::OUString >& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyStates(aPropertyName);
+
+ // set them all to DEFAULT
+ Sequence< ::com::sun::star::beans::PropertyState> aReturn(aPropertyName.getLength());
+ ::com::sun::star::beans::PropertyState* pStates = aReturn.getArray();
+ for (sal_uInt16 i=0; i<aPropertyName.getLength(); ++i, ++pStates)
+ *pStates = ::com::sun::star::beans::PropertyState_DEFAULT_VALUE;
+ return aReturn;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::setPropertyToDefault(const ::rtl::OUString& PropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
+ if (xState.is())
+ xState->setPropertyToDefault(PropertyName);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getPropertyDefault(const ::rtl::OUString& aPropertyName) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ Reference< ::com::sun::star::beans::XPropertyState > xState(m_xMainForm, UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyDefault(aPropertyName);
+ return Any();
+}
+
+// ::com::sun::star::form::XReset
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::reset() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::form::XReset > xReset(m_xMainForm, UNO_QUERY);
+ if (xReset.is())
+ xReset->reset();
+}
+
+IMPLEMENT_LISTENER_ADMINISTRATION(SbaXFormAdapter, form, ResetListener, m_aResetListeners, ::com::sun::star::form::XReset, m_xMainForm)
+
+// ::com::sun::star::container::XNameContainer
+// -------------------------------------------------------------------------
+void SbaXFormAdapter::implInsert(const Any& aElement, sal_Int32 nIndex, const ::rtl::OUString* pNewElName) throw( ::com::sun::star::lang::IllegalArgumentException )
+{
+ // extract the form component
+ if (aElement.getValueType().getTypeClass() != TypeClass_INTERFACE)
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)aElement.getValue(), UNO_QUERY);
+ if (!xElement.is())
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ // for the name we need the propset
+ Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
+ if (!xElementSet.is())
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+ ::rtl::OUString sName;
+ try
+ {
+ if (pNewElName)
+ xElementSet->setPropertyValue(PROPERTY_NAME, makeAny(*pNewElName));
+
+ xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
+ }
+ catch(Exception&)
+ {
+ // the set didn't support the name prop
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ // check the index
+ OSL_ASSERT(nIndex >= 0);
+ if (sal::static_int_cast< sal_uInt32 >(nIndex) > m_aChildren.size())
+ nIndex = m_aChildren.size();
+
+ OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::implInsert : inconsistent container state !");
+ m_aChildren.insert(m_aChildren.begin() + nIndex, xElement);
+ m_aChildNames.insert(m_aChildNames.begin() + nIndex, sName);
+
+ // listen for a changes of the name
+ xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
+
+ // we are now the parent of the new element
+ xElement->setParent((::com::sun::star::container::XContainer*)this);
+
+ // notify the container listeners
+ ::com::sun::star::container::ContainerEvent aEvt;
+ aEvt.Source = *this;
+ aEvt.Accessor <<= nIndex;
+ aEvt.Element <<= xElement;
+ ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::container::XContainerListener*)aIt.next())->elementInserted(aEvt);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SbaXFormAdapter::implGetPos(const ::rtl::OUString& rName)
+{
+ ::std::vector< ::rtl::OUString>::iterator aIter = ::std::find_if( m_aChildNames.begin(),
+ m_aChildNames.end(),
+ ::std::bind2nd(::std::equal_to< rtl::OUString>(),rName));
+
+ if(aIter != m_aChildNames.end())
+ return aIter - m_aChildNames.begin();
+
+ return -1;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::insertByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ implInsert(aElement, m_aChildren.size(), &aName);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removeByName(const ::rtl::OUString& Name) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ sal_Int32 nPos = implGetPos(Name);
+ if (-1 == nPos)
+ {
+ throw ::com::sun::star::container::NoSuchElementException();
+ }
+ removeByIndex(nPos);
+}
+
+// ::com::sun::star::container::XNameReplace
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::replaceByName(const ::rtl::OUString& aName, const Any& aElement) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ sal_Int32 nPos = implGetPos(aName);
+ if (-1 == nPos)
+ {
+ throw ::com::sun::star::container::NoSuchElementException();
+ }
+ replaceByIndex(nPos, aElement);
+}
+
+// ::com::sun::star::container::XNameAccess
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getByName(const ::rtl::OUString& aName) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ sal_Int32 nPos = implGetPos(aName);
+ if (-1 == nPos)
+ {
+ throw ::com::sun::star::container::NoSuchElementException();
+ }
+ return makeAny(m_aChildren[nPos]);
+}
+
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL SbaXFormAdapter::getElementNames() throw( RuntimeException )
+{
+ ::rtl::OUString *pChildNames = m_aChildNames.empty() ? 0 : &m_aChildNames[0];
+ return Sequence< ::rtl::OUString >(pChildNames, m_aChildNames.size());
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::hasByName(const ::rtl::OUString& aName) throw( RuntimeException )
+{
+ return (-1 != implGetPos(aName));
+}
+
+// ::com::sun::star::container::XElementAccess
+// -------------------------------------------------------------------------
+Type SAL_CALL SbaXFormAdapter::getElementType() throw(RuntimeException)
+{
+ return ::getCppuType(
+ static_cast< Reference< ::com::sun::star::form::XFormComponent >* >(NULL));
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaXFormAdapter::hasElements() throw(RuntimeException)
+{
+ return m_aChildren.size() > 0;
+}
+
+
+// ::com::sun::star::container::XIndexContainer
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::insertByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+ implInsert(Element, _rIndex);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removeByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ Reference< ::com::sun::star::form::XFormComponent > xAffected = *(m_aChildren.begin() + _rIndex);
+
+ OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::removeByIndex : inconsistent container state !");
+ m_aChildren.erase(m_aChildren.begin() + _rIndex);
+ m_aChildNames.erase(m_aChildNames.begin() + _rIndex);
+
+ // no need to listen anymore
+ Reference< ::com::sun::star::beans::XPropertySet > xAffectedSet(xAffected, UNO_QUERY);
+ xAffectedSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
+
+ // we are no longer the parent
+ xAffected->setParent(Reference< XInterface > ());
+
+ // notify container listeners
+ ::com::sun::star::container::ContainerEvent aEvt;
+ aEvt.Source = *this;
+ aEvt.Element <<= xAffected;
+ ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::container::XContainerListener*)aIt.next())->elementRemoved(aEvt);
+
+}
+
+// ::com::sun::star::container::XIndexReplace
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::replaceByIndex(sal_Int32 _rIndex, const Any& Element) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ // extract the form component
+ if (Element.getValueType().getTypeClass() != TypeClass_INTERFACE)
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ Reference< ::com::sun::star::form::XFormComponent > xElement(*(Reference< XInterface > *)Element.getValue(), UNO_QUERY);
+ if (!xElement.is())
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ // for the name we need the propset
+ Reference< ::com::sun::star::beans::XPropertySet > xElementSet(xElement, UNO_QUERY);
+ if (!xElementSet.is())
+ {
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+ ::rtl::OUString sName;
+ try
+ {
+ xElementSet->getPropertyValue(PROPERTY_NAME) >>= sName;
+ }
+ catch(Exception&)
+ {
+ // the set didn't support the name prop
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ Reference< ::com::sun::star::form::XFormComponent > xOld = *(m_aChildren.begin() + _rIndex);
+
+ OSL_ENSURE(m_aChildren.size() == m_aChildNames.size(), "SAL_CALL SbaXFormAdapter::replaceByIndex : inconsistent container state !");
+ *(m_aChildren.begin() + _rIndex) = xElement;
+ *(m_aChildNames.begin() + _rIndex) = sName;
+
+ // correct property change listening
+ Reference< ::com::sun::star::beans::XPropertySet > xOldSet(xOld, UNO_QUERY);
+ xOldSet->removePropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
+ xElementSet->addPropertyChangeListener(PROPERTY_NAME, (::com::sun::star::beans::XPropertyChangeListener*)this);
+
+ // parent reset
+ xOld->setParent(Reference< XInterface > ());
+ xElement->setParent((::com::sun::star::container::XContainer*)this);
+
+ // notify container listeners
+ ::com::sun::star::container::ContainerEvent aEvt;
+ aEvt.Source = *this;
+ aEvt.Accessor <<= (sal_Int32)_rIndex;
+ aEvt.Element <<= xElement;
+ aEvt.ReplacedElement <<= xOld;
+
+ ::cppu::OInterfaceIteratorHelper aIt(m_aContainerListeners);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::container::XContainerListener*)aIt.next())->elementReplaced(aEvt);
+}
+
+// ::com::sun::star::container::XIndexAccess
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL SbaXFormAdapter::getCount() throw( RuntimeException )
+{
+ return m_aChildren.size();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaXFormAdapter::getByIndex(sal_Int32 _rIndex) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, RuntimeException )
+{
+ if ( ( _rIndex < 0 ) || ( (size_t)_rIndex >= m_aChildren.size() ) )
+ throw ::com::sun::star::lang::IndexOutOfBoundsException();
+
+ Reference< ::com::sun::star::form::XFormComponent > xElement = *(m_aChildren.begin() + _rIndex);
+ return makeAny(xElement);
+}
+
+// ::com::sun::star::container::XContainer
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::addContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
+{
+ m_aContainerListeners.addInterface(xListener);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::removeContainerListener(const Reference< ::com::sun::star::container::XContainerListener >& xListener) throw( RuntimeException )
+{
+ m_aContainerListeners.removeInterface(xListener);
+}
+
+// ::com::sun::star::container::XEnumerationAccess
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XEnumeration > SAL_CALL SbaXFormAdapter::createEnumeration() throw( RuntimeException )
+{
+ return new ::comphelper::OEnumerationByName(this);
+}
+
+// ::com::sun::star::beans::XPropertyChangeListener
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ if (evt.PropertyName.equals(PROPERTY_NAME))
+ {
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
+ m_aChildren.end(),
+ ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),evt.Source));
+
+ if(aIter != m_aChildren.end())
+ {
+ sal_Int32 nPos = aIter - m_aChildren.begin();
+ OSL_ENSURE(*(m_aChildNames.begin() + nPos) == ::comphelper::getString(evt.OldValue), "SAL_CALL SbaXFormAdapter::propertyChange : object has a wrong name !");
+ *(m_aChildNames.begin() + nPos) = ::comphelper::getString(evt.NewValue);
+ }
+ }
+}
+
+// ::com::sun::star::lang::XEventListener
+// -------------------------------------------------------------------------
+void SAL_CALL SbaXFormAdapter::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException )
+{
+ // was it our main form ?
+ if (Source.Source == m_xMainForm)
+ dispose();
+
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >::iterator aIter = ::std::find_if( m_aChildren.begin(),
+ m_aChildren.end(),
+ ::std::bind2nd(::std::equal_to< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >(),Source.Source));
+ if(aIter != m_aChildren.end())
+ removeByIndex(aIter - m_aChildren.begin());
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
new file mode 100644
index 000000000000..706d58400c2d
--- /dev/null
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -0,0 +1,1636 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "genericcontroller.hxx"
+#include <comphelper/uno3.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include "browserids.hxx"
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include "dataview.hxx"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "dbustrings.hrc"
+#include <vcl/stdtext.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <framework/titlehelper.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include "UITools.hxx"
+#include "commontypes.hxx"
+
+#include <sal/macros.h>
+#include <vcl/waitobj.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/urihelper.hxx>
+#include "datasourceconnector.hxx"
+#include <unotools/moduleoptions.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/status/Visibility.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <rtl/ustring.hxx>
+#include <rtl/logfile.hxx>
+#include <algorithm>
+#include <o3tl/compat_functional.hxx>
+#include <boost/unordered_map.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <limits>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::frame::status;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star;
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+// -------------------------------------------------------------------------
+#define ALL_FEATURES -1
+#define FIRST_USER_DEFINED_FEATURE ( ::std::numeric_limits< sal_uInt16 >::max() - 1000 )
+#define LAST_USER_DEFINED_FEATURE ( ::std::numeric_limits< sal_uInt16 >::max() )
+
+// -------------------------------------------------------------------------
+typedef ::boost::unordered_map< sal_Int16, sal_Int16 > CommandHashMap;
+typedef ::std::list< DispatchInformation > DispatchInfoList;
+
+
+// -------------------------------------------------------------------------
+const ::rtl::OUString& getConfirmDeletionURL()
+{
+ static const ::rtl::OUString sConfirmDeletionURL( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/ConfirmDeletion" ) );
+ return sConfirmDeletionURL;
+}
+
+namespace dbaui
+{
+
+//==========================================================================
+//= UserDefinedFeatures
+//==========================================================================
+class UserDefinedFeatures
+{
+public:
+ UserDefinedFeatures( const Reference< XController >& _rxController );
+
+ FeatureState getState( const URL& _rFeatureURL );
+ void execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs );
+
+private:
+ ::com::sun::star::uno::WeakReference< XController > m_aController;
+};
+
+//--------------------------------------------------------------------------
+UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController )
+ :m_aController( _rxController )
+{
+}
+
+//--------------------------------------------------------------------------
+FeatureState UserDefinedFeatures::getState( const URL& /*_rFeatureURL*/ )
+{
+ // for now, enable all the time
+ // TODO: we should ask the dispatcher. However, this is laborious, since you cannot ask a dispatcher
+ // directly, but need to add a status listener.
+ FeatureState aState;
+ aState.bEnabled = sal_True;
+ return aState;
+}
+
+//--------------------------------------------------------------------------
+void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs )
+{
+ try
+ {
+ Reference< XController > xController( (Reference< XController >)m_aController, UNO_SET_THROW );
+ Reference< XDispatchProvider > xDispatchProvider( xController->getFrame(), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch(
+ _rFeatureURL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
+ FrameSearchFlag::AUTO
+ ) );
+
+ if ( xDispatch == xController )
+ {
+ OSL_FAIL( "UserDefinedFeatures::execute: the controller shouldn't be the dispatcher here!" );
+ xDispatch.clear();
+ }
+
+ if ( xDispatch.is() )
+ xDispatch->dispatch( _rFeatureURL, _rArgs );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//==========================================================================
+//= OGenericUnoController_Data
+//==========================================================================
+struct OGenericUnoController_Data
+{
+ ::sfx2::UserInputInterception m_aUserInputInterception;
+ UserDefinedFeatures m_aUserDefinedFeatures;
+
+ OGenericUnoController_Data( OGenericUnoController& _rController, ::osl::Mutex& _rMutex )
+ :m_aUserInputInterception( _rController, _rMutex )
+ ,m_aUserDefinedFeatures( _rController.getXController() )
+ {
+ }
+};
+
+//==========================================================================
+//= OGenericUnoController
+//==========================================================================
+DBG_NAME(OGenericUnoController)
+// -------------------------------------------------------------------------
+OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFactory >& _rM)
+ :OGenericUnoController_Base( getMutex() )
+ ,m_pView(NULL)
+#ifdef DBG_UTIL
+ ,m_bDescribingSupportedFeatures( false )
+#endif
+ ,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
+ ,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
+ ,m_xServiceFactory(_rM)
+ ,m_aCurrentFrame( *this )
+ ,m_bPreview(sal_False)
+ ,m_bReadOnly(sal_False)
+ ,m_bCurrentlyModified(sal_False)
+ ,m_bExternalTitle(sal_False)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ DBG_CTOR(OGenericUnoController,NULL);
+
+ try
+ {
+ m_xUrlTransformer = Reference< XURLTransformer > (_rM->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))), UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+#ifdef WNT
+// -----------------------------------------------------------------------------
+OGenericUnoController::OGenericUnoController()
+ :OGenericUnoController_Base( getMutex() )
+ ,m_pView(NULL)
+#ifdef DBG_UTIL
+ ,m_bDescribingSupportedFeatures( false )
+#endif
+ ,m_aAsyncInvalidateAll(LINK(this, OGenericUnoController, OnAsyncInvalidateAll))
+ ,m_aAsyncCloseTask(LINK(this, OGenericUnoController, OnAsyncCloseTask))
+ ,m_aCurrentFrame( *this )
+ ,m_bPreview(sal_False)
+ ,m_bReadOnly(sal_False)
+ ,m_bCurrentlyModified(sal_False)
+{
+ OSL_FAIL( "OGenericUnoController::OGenericUnoController: illegal call!" );
+ // This ctor only exists because the MSVC compiler complained about an unresolved external
+ // symbol. It should not be used at all. Since using it yields strange runtime problems,
+ // we simply abort here.
+ abort();
+}
+#endif
+
+// -----------------------------------------------------------------------------
+OGenericUnoController::~OGenericUnoController()
+{
+
+ DBG_DTOR(OGenericUnoController,NULL);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OGenericUnoController::Construct(Window* /*pParent*/)
+{
+ OSL_ENSURE( getView(), "the view is NULL!" );
+
+ if ( getView() )
+ {
+ getView()->Construct();
+ getView()->Show();
+ }
+
+ m_aSupportedFeatures.clear();
+ fillSupportedFeatures();
+
+ // create the database context
+ OSL_ENSURE(getORB().is(), "OGenericUnoController::Construct need a service factory!");
+ try
+ {
+ m_xDatabaseContext = Reference< XNameAccess >(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("OGenericUnoController::Construct: could not create (or start listening at) the database context!");
+ }
+
+ if (!m_xDatabaseContext.is())
+ { // at least notify the user. Though the whole component does not make any sense without the database context ...
+ ShowServiceNotAvailableError(getView(), String(SERVICE_SDB_DATABASECONTEXT), sal_True);
+ }
+ return sal_True;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OGenericUnoController, OnAsyncInvalidateAll, void*, EMPTYARG)
+{
+ if ( !OGenericUnoController_Base::rBHelper.bInDispose && !OGenericUnoController_Base::rBHelper.bDisposed )
+ InvalidateFeature_Impl();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::impl_initialize()
+{
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ Reference< XWindow > xParent;
+ Reference< XFrame > xFrame;
+
+ PropertyValue aValue;
+ const Any* pIter = aArguments.getConstArray();
+ const Any* pEnd = pIter + aArguments.getLength();
+
+ for ( ; pIter != pEnd; ++pIter )
+ {
+ if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Frame" ) ) )
+ {
+ xFrame.set(aValue.Value,UNO_QUERY_THROW);
+ }
+ else if ( ( *pIter >>= aValue ) && ( 0 == aValue.Name.compareToAscii( "Preview" ) ) )
+ {
+ aValue.Value >>= m_bPreview;
+ m_bReadOnly = sal_True;
+ }
+ }
+ try
+ {
+ if ( !xFrame.is() )
+ throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "need a frame" ) ), *this, 1 );
+
+ xParent = xFrame->getContainerWindow();
+ VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xParent);
+ Window* pParentWin = pParentComponent ? pParentComponent->GetWindow() : NULL;
+ if (!pParentWin)
+ {
+ throw IllegalArgumentException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent window is null")), *this, 1 );
+ }
+
+ m_aInitParameters.assign( aArguments );
+ Construct( pParentWin );
+
+ ODataView* pView = getView();
+ if ( !pView )
+ throw RuntimeException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unable to create a view")), *this );
+
+ if ( m_bReadOnly || m_bPreview )
+ pView->EnableInput( sal_False );
+
+ impl_initialize();
+ }
+ catch(Exception& e)
+ {
+ // no one clears my view if I won't
+ ::std::auto_ptr<Window> aTemp(m_pView);
+ m_pView = NULL;
+ throw;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::acquire( ) throw ()
+{
+ OGenericUnoController_Base::acquire();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::release( ) throw ()
+{
+ OGenericUnoController_Base::release();
+}
+
+// -------------------------------------------------------------------------
+void OGenericUnoController::startFrameListening( const Reference< XFrame >& _rxFrame )
+{
+ if ( _rxFrame.is() )
+ _rxFrame->addFrameActionListener( this );
+}
+
+// -------------------------------------------------------------------------
+void OGenericUnoController::stopFrameListening( const Reference< XFrame >& _rxFrame )
+{
+ if ( _rxFrame.is() )
+ _rxFrame->removeFrameActionListener( this );
+}
+
+// -------------------------------------------------------------------------
+void OGenericUnoController::disposing(const EventObject& Source) throw( RuntimeException )
+{
+ // our frame ?
+ if ( Source.Source == getFrame() )
+ stopFrameListening( getFrame() );
+}
+//------------------------------------------------------------------------
+void OGenericUnoController::modified(const EventObject& aEvent) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !isDataSourceReadOnly() )
+ {
+ Reference<XModifiable> xModi(aEvent.Source,UNO_QUERY);
+ if ( xModi.is() )
+ m_bCurrentlyModified = xModi->isModified(); // can only be reset by save
+ else
+ m_bCurrentlyModified = sal_True;
+ }
+ InvalidateFeature(ID_BROWSER_SAVEDOC);
+ InvalidateFeature(ID_BROWSER_UNDO);
+}
+// -----------------------------------------------------------------------
+Reference< XWindow > SAL_CALL OGenericUnoController::getComponentWindow() throw (RuntimeException)
+{
+ return VCLUnoHelper::GetInterface( getView() );
+}
+
+// -----------------------------------------------------------------------
+::rtl::OUString SAL_CALL OGenericUnoController::getViewControllerName() throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
+}
+
+// -----------------------------------------------------------------------
+Sequence< PropertyValue > SAL_CALL OGenericUnoController::getCreationArguments() throw (RuntimeException)
+{
+ // currently we do not support any creation args, so anything passed to XModel2::createViewController would be
+ // lost, so we can equally return an empty sequence here
+ return Sequence< PropertyValue >();
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::attachFrame( const Reference< XFrame >& _rxFrame ) throw( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ stopFrameListening( m_aCurrentFrame.getFrame() );
+ Reference< XFrame > xFrame = m_aCurrentFrame.attachFrame( _rxFrame );
+ startFrameListening( xFrame );
+
+ loadMenu( xFrame );
+
+ if ( getView() )
+ getView()->attachFrame( xFrame );
+}
+
+// -----------------------------------------------------------------------------
+struct CommandCollector : public ::std::unary_function< SupportedFeatures::value_type, void>
+{
+ sal_uInt16 m_nFeature;
+ StringBag& m_rFeatureCommands;
+ CommandCollector( sal_uInt16 _nFeature, StringBag& _rFeatureCommands )
+ :m_nFeature ( _nFeature )
+ ,m_rFeatureCommands( _rFeatureCommands )
+ {
+ }
+
+ void operator() ( const SupportedFeatures::value_type& lhs )
+ {
+ if ( lhs.second.nFeatureId == m_nFeature )
+ m_rFeatureCommands.insert( lhs.first );
+ }
+};
+
+// -----------------------------------------------------------------------
+namespace
+{
+ typedef ::std::vector< Any > States;
+
+ // ...................................................................
+ void lcl_notifyMultipleStates( XStatusListener& _rListener, FeatureStateEvent& _rEvent, const States& _rStates )
+ {
+ for ( States::const_iterator state = _rStates.begin();
+ state != _rStates.end();
+ ++state
+ )
+ {
+ _rEvent.State = *state;
+ _rListener.statusChanged( _rEvent );
+ }
+ }
+
+ // ...................................................................
+ void lcl_collectStates( const FeatureState& _rFeatureState, States& _out_rStates )
+ {
+ // order matters, due to a bug in framework which resets the check state when any non-boolean event
+ // arrives
+ // #i68215# is the bug to (re-)introduce this "ordered" notification here
+ // #i67882# is the bug which was caused by the real fix which we did in framework
+ // #i68216# is the bug which requests to fix the code in Draw which relies on
+ // framework's implementation details
+ if ( !!_rFeatureState.sTitle )
+ _out_rStates.push_back( makeAny( *_rFeatureState.sTitle ) );
+ if ( !!_rFeatureState.bChecked )
+ _out_rStates.push_back( makeAny( (sal_Bool)*_rFeatureState.bChecked ) );
+ if ( !!_rFeatureState.bInvisible )
+ _out_rStates.push_back( makeAny( Visibility( !*_rFeatureState.bInvisible ) ) );
+ if ( _rFeatureState.aValue.hasValue() )
+ _out_rStates.push_back( _rFeatureState.aValue );
+ if ( _out_rStates.empty() )
+ _out_rStates.push_back( Any() );
+ }
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::ImplBroadcastFeatureState(const ::rtl::OUString& _rFeature, const Reference< XStatusListener > & xListener, sal_Bool _bIgnoreCache)
+{
+ sal_uInt16 nFeat = m_aSupportedFeatures[ _rFeature ].nFeatureId;
+ FeatureState aFeatState( GetState( nFeat ) );
+
+ FeatureState& rCachedState = m_aStateCache[nFeat]; // creates if neccessary
+ if ( !_bIgnoreCache )
+ {
+ // check if we really need to notify the listeners : this method may be called much more often than needed, so check
+ // the cached state of the feature
+ sal_Bool bAlreadyCached = ( m_aStateCache.find(nFeat) != m_aStateCache.end() );
+ if ( bAlreadyCached )
+ if ( ( rCachedState.bEnabled == aFeatState.bEnabled )
+ && ( rCachedState.bChecked == aFeatState.bChecked )
+ && ( rCachedState.bInvisible == aFeatState.bInvisible )
+ && ( rCachedState.sTitle == aFeatState.sTitle )
+ )
+ return;
+ }
+ rCachedState = aFeatState;
+
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL.Complete = _rFeature;
+ if (m_xUrlTransformer.is())
+ m_xUrlTransformer->parseStrict(aEvent.FeatureURL);
+ aEvent.Source = (XDispatch*)this;
+ aEvent.IsEnabled = aFeatState.bEnabled;
+
+ // collect all states to be notified
+ States aStates;
+ lcl_collectStates( aFeatState, aStates );
+
+ // a special listener ?
+ if ( xListener.is() )
+ lcl_notifyMultipleStates( *xListener.get(), aEvent, aStates );
+ else
+ { // no -> iterate through all listeners responsible for the URL
+ StringBag aFeatureCommands;
+ ::std::for_each(
+ m_aSupportedFeatures.begin(),
+ m_aSupportedFeatures.end(),
+ CommandCollector( nFeat, aFeatureCommands )
+ );
+
+ // it is possible that listeners are registered or revoked while
+ // we are notifying them, so we must use a copy of m_arrStatusListener, not
+ // m_arrStatusListener itself
+ Dispatch aNotifyLoop( m_arrStatusListener );
+ DispatchIterator iterSearch = aNotifyLoop.begin();
+ DispatchIterator iterEnd = aNotifyLoop.end();
+
+ while (iterSearch != iterEnd)
+ {
+ DispatchTarget& rCurrent = *iterSearch;
+ if ( aFeatureCommands.find( rCurrent.aURL.Complete ) != aFeatureCommands.end() )
+ {
+ aEvent.FeatureURL = rCurrent.aURL;
+ lcl_notifyMultipleStates( *rCurrent.xListener.get(), aEvent, aStates );
+ }
+ ++iterSearch;
+ }
+ }
+
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OGenericUnoController::isFeatureSupported( sal_Int32 _nId )
+{
+ SupportedFeatures::iterator aFeaturePos = ::std::find_if(
+ m_aSupportedFeatures.begin(),
+ m_aSupportedFeatures.end(),
+ ::std::bind2nd( CompareFeatureById(), _nId )
+ );
+
+ return ( m_aSupportedFeatures.end() != aFeaturePos && aFeaturePos->first.getLength());
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::InvalidateFeature(const ::rtl::OUString& _rURLPath, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
+{
+ ImplInvalidateFeature( m_aSupportedFeatures[ _rURLPath ].nFeatureId, _xListener, _bForceBroadcast );
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::InvalidateFeature_Impl()
+{
+#ifdef DBG_UTIL
+ static sal_Int32 s_nRecursions = 0;
+ ++s_nRecursions;
+#endif
+
+ sal_Bool bEmpty = sal_True;
+ FeatureListener aNextFeature;
+ {
+ ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ bEmpty = m_aFeaturesToInvalidate.empty();
+ if (!bEmpty)
+ aNextFeature = m_aFeaturesToInvalidate.front();
+ }
+ while(!bEmpty)
+ {
+ if ( ALL_FEATURES == aNextFeature.nId )
+ {
+ InvalidateAll_Impl();
+ break;
+ }
+ else
+ {
+ SupportedFeatures::iterator aFeaturePos = ::std::find_if(
+ m_aSupportedFeatures.begin(),
+ m_aSupportedFeatures.end(),
+ ::std::bind2nd( CompareFeatureById(), aNextFeature.nId )
+ );
+
+#if OSL_DEBUG_LEVEL > 0
+ if ( m_aSupportedFeatures.end() == aFeaturePos )
+ {
+ ::rtl::OString sMessage( "OGenericUnoController::InvalidateFeature_Impl: feature id " );
+ sMessage += ::rtl::OString::valueOf( aNextFeature.nId );
+ sMessage += ::rtl::OString( " has been invalidated, but is not supported!" );
+ OSL_FAIL( sMessage.getStr() );
+ }
+#endif
+ if ( m_aSupportedFeatures.end() != aFeaturePos )
+ // we really know this feature
+ ImplBroadcastFeatureState( aFeaturePos->first, aNextFeature.xListener, aNextFeature.bForceBroadcast );
+ }
+
+ ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ m_aFeaturesToInvalidate.pop_front();
+ bEmpty = m_aFeaturesToInvalidate.empty();
+ if (!bEmpty)
+ aNextFeature = m_aFeaturesToInvalidate.front();
+ }
+
+#ifdef DBG_UTIL
+ --s_nRecursions;
+#endif
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Reference< XStatusListener >& _xListener, sal_Bool _bForceBroadcast )
+{
+#if OSL_DEBUG_LEVEL > 0
+ if ( _nId != -1 )
+ {
+ SupportedFeatures::iterator aFeaturePos = ::std::find_if(
+ m_aSupportedFeatures.begin(),
+ m_aSupportedFeatures.end(),
+ ::std::bind2nd( CompareFeatureById(), _nId )
+ );
+ OSL_ENSURE( aFeaturePos != m_aSupportedFeatures.end(), "OGenericUnoController::ImplInvalidateFeature: invalidating an unsupported feature is suspicious, at least!" );
+ }
+#endif
+
+ FeatureListener aListener;
+ aListener.nId = _nId;
+ aListener.xListener = _xListener;
+ aListener.bForceBroadcast = _bForceBroadcast;
+
+ sal_Bool bWasEmpty;
+ {
+ ::osl::MutexGuard aGuard( m_aFeatureMutex );
+ bWasEmpty = m_aFeaturesToInvalidate.empty();
+ m_aFeaturesToInvalidate.push_back( aListener );
+ }
+
+ if ( bWasEmpty )
+ m_aAsyncInvalidateAll.Call();
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::InvalidateFeature(sal_uInt16 _nId, const Reference< XStatusListener > & _xListener, sal_Bool _bForceBroadcast)
+{
+ ImplInvalidateFeature( _nId, _xListener, _bForceBroadcast );
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::InvalidateAll()
+{
+ ImplInvalidateFeature( ALL_FEATURES, NULL, sal_True );
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::InvalidateAll_Impl()
+{
+ // ---------------------------------
+ // invalidate all supported features
+
+ for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
+ aIter != m_aSupportedFeatures.end();
+ ++aIter
+ )
+ ImplBroadcastFeatureState( aIter->first, NULL, sal_True );
+
+ {
+ ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ OSL_ENSURE(m_aFeaturesToInvalidate.size(), "OGenericUnoController::InvalidateAll_Impl: to be called from within InvalidateFeature_Impl only!");
+ m_aFeaturesToInvalidate.pop_front();
+ if(!m_aFeaturesToInvalidate.empty())
+ m_aAsyncInvalidateAll.Call();
+ }
+}
+
+// -----------------------------------------------------------------------
+Reference< XDispatch > OGenericUnoController::queryDispatch(const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
+{
+ Reference< XDispatch > xReturn;
+
+ OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::queryDispatch: shouldn't this be filled at construction time?" );
+ if ( m_aSupportedFeatures.empty() )
+ fillSupportedFeatures();
+
+ // URL's we can handle ourself?
+ if ( aURL.Complete.equals( getConfirmDeletionURL() )
+ || ( ( m_aSupportedFeatures.find( aURL.Complete ) != m_aSupportedFeatures.end() )
+ && !isUserDefinedFeature( aURL.Complete )
+ )
+ )
+ {
+ xReturn = this;
+ }
+ // no? -> ask the slave dispatcher
+ else if ( m_xSlaveDispatcher.is() )
+ {
+ xReturn = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+ }
+
+ // outta here
+ return xReturn;
+}
+
+// -----------------------------------------------------------------------
+Sequence< Reference< XDispatch > > OGenericUnoController::queryDispatches(const Sequence< DispatchDescriptor >& aDescripts) throw( RuntimeException )
+{
+ Sequence< Reference< XDispatch > > aReturn;
+ sal_Int32 nLen = aDescripts.getLength();
+ if ( nLen )
+ {
+ aReturn.realloc( nLen );
+ Reference< XDispatch >* pReturn = aReturn.getArray();
+ const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen;
+ const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
+
+ for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
+ {
+ *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
+ }
+ }
+
+ return aReturn;
+}
+
+// -----------------------------------------------------------------------
+Reference< XDispatchProvider > OGenericUnoController::getSlaveDispatchProvider(void) throw( RuntimeException )
+{
+ return m_xSlaveDispatcher;
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::setSlaveDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
+{
+ m_xSlaveDispatcher = _xNewProvider;
+}
+
+// -----------------------------------------------------------------------
+Reference< XDispatchProvider > OGenericUnoController::getMasterDispatchProvider(void) throw( RuntimeException )
+{
+ return m_xMasterDispatcher;
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::setMasterDispatchProvider(const Reference< XDispatchProvider > & _xNewProvider) throw( RuntimeException )
+{
+ m_xMasterDispatcher = _xNewProvider;
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::dispatch(const URL& _aURL, const Sequence< PropertyValue >& aArgs) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ // The SolarMutex is not locked anymore when the framework calls into
+ // here. So, lock it ourself. The real solution would be to lock it only in the places
+ // where it's needed, but a) this might turn out difficult, since we then also need to care
+ // for locking in the proper order (SolarMutex and m_aMutex), and b) this would be too many places
+ // for the time frame of the fix.
+ // #i52602#
+
+#ifdef TIMELOG
+ ::rtl::OString sLog( "OGenericUnoController::dispatch( '" );
+ sLog += ::rtl::OString( _aURL.Main.getStr(), _aURL.Main.getLength(), osl_getThreadTextEncoding() );
+ sLog += ::rtl::OString( "' )" );
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "frank.schoenheit@sun.com", sLog.getStr() );
+#endif
+
+ executeChecked(_aURL,aArgs);
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::addStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
+{
+ // parse the ULR now and here, this saves later parsing in each notification round
+ URL aParsedURL( _rURL );
+ if ( m_xUrlTransformer.is() )
+ m_xUrlTransformer->parseStrict( aParsedURL );
+
+ // remember the listener together with the URL
+ m_arrStatusListener.insert( m_arrStatusListener.end(), DispatchTarget( aParsedURL, aListener ) );
+
+ // initially broadcast the state
+ ImplBroadcastFeatureState( aParsedURL.Complete, aListener, sal_True );
+ // force the new state to be broadcast to the new listener
+}
+
+// -----------------------------------------------------------------------
+void OGenericUnoController::removeStatusListener(const Reference< XStatusListener > & aListener, const URL& _rURL) throw(RuntimeException)
+{
+ DispatchIterator iterSearch = m_arrStatusListener.begin();
+
+ sal_Bool bRemoveForAll = (_rURL.Complete.getLength() == 0);
+ while ( iterSearch != m_arrStatusListener.end() )
+ {
+ DispatchTarget& rCurrent = *iterSearch;
+ if ( (rCurrent.xListener == aListener)
+ && ( bRemoveForAll
+ || (rCurrent.aURL.Complete.equals(_rURL.Complete))
+ )
+ )
+ {
+ m_arrStatusListener.erase( iterSearch );
+ if (!bRemoveForAll)
+ // remove the listener only for the given URL, so we can exit the loop after deletion
+ break;
+ }
+ else
+ ++iterSearch;
+ }
+
+ OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::removeStatusListener: shouldn't this be filled at construction time?" );
+ if ( m_aSupportedFeatures.empty() )
+ fillSupportedFeatures();
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find(_rURL.Complete);
+ if (aIter != m_aSupportedFeatures.end())
+ { // clear the cache for that feature
+ StateCacheIterator aCachePos = m_aStateCache.find( aIter->second.nFeatureId );
+ if ( aCachePos != m_aStateCache.end() )
+ m_aStateCache.erase( aCachePos );
+ }
+
+ // now remove the listener from the deque
+ ::osl::MutexGuard aGuard( m_aFeatureMutex );
+ m_aFeaturesToInvalidate.erase(
+ ::std::remove_if( m_aFeaturesToInvalidate.begin(),
+ m_aFeaturesToInvalidate.end(),
+ ::std::bind2nd(FindFeatureListener(),aListener))
+ ,m_aFeaturesToInvalidate.end());
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::releaseNumberForComponent()
+{
+ try
+ {
+ Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY );
+ if ( xUntitledProvider.is() )
+ xUntitledProvider->releaseNumberForComponent(static_cast<XWeak*>(this));
+ }
+ catch( const Exception& )
+ {
+ // NII
+ }
+}
+// -----------------------------------------------------------------------
+void OGenericUnoController::disposing()
+{
+ {
+ EventObject aDisposeEvent;
+ aDisposeEvent.Source = static_cast<XWeak*>(this);
+ Dispatch aStatusListener = m_arrStatusListener;
+ Dispatch::iterator aEnd = aStatusListener.end();
+ for (Dispatch::iterator aIter = aStatusListener.begin(); aIter != aEnd; ++aIter)
+ {
+ aIter->xListener->disposing(aDisposeEvent);
+ }
+ m_arrStatusListener.clear();
+ }
+
+ m_xDatabaseContext = NULL;
+ {
+ ::osl::MutexGuard aGuard( m_aFeatureMutex);
+ m_aAsyncInvalidateAll.CancelCall();
+ m_aFeaturesToInvalidate.clear();
+ }
+
+ releaseNumberForComponent();
+
+ // check out from all the objects we are listening
+ // the frame
+ stopFrameListening( m_aCurrentFrame.getFrame() );
+ m_aCurrentFrame.attachFrame( NULL );
+
+ m_xMasterDispatcher = NULL;
+ m_xSlaveDispatcher = NULL;
+ m_xServiceFactory = NULL;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
+{
+ // disambiguate
+ OGenericUnoController_Base::WeakComponentImplHelperBase::addEventListener( xListener );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
+{
+ // disambiguate
+ OGenericUnoController_Base::WeakComponentImplHelperBase::removeEventListener( xListener );
+}
+
+//------------------------------------------------------------------------------
+void OGenericUnoController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( aEvent.Frame == m_aCurrentFrame.getFrame() )
+ m_aCurrentFrame.frameAction( aEvent.Action );
+}
+
+//------------------------------------------------------------------------------
+void OGenericUnoController::implDescribeSupportedFeature( const sal_Char* _pAsciiCommandURL,
+ sal_uInt16 _nFeatureId, sal_Int16 _nCommandGroup )
+{
+#ifdef DBG_UTIL
+ OSL_ENSURE( m_bDescribingSupportedFeatures, "OGenericUnoController::implDescribeSupportedFeature: bad timing for this call!" );
+#endif
+ OSL_PRECOND( _nFeatureId < FIRST_USER_DEFINED_FEATURE, "OGenericUnoController::implDescribeSupportedFeature: invalid feature id!" );
+
+ ControllerFeature aFeature;
+ aFeature.Command = ::rtl::OUString::createFromAscii( _pAsciiCommandURL );
+ aFeature.nFeatureId = _nFeatureId;
+ aFeature.GroupId = _nCommandGroup;
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_ENSURE( m_aSupportedFeatures.find( aFeature.Command ) == m_aSupportedFeatures.end(),
+ "OGenericUnoController::implDescribeSupportedFeature: this feature is already there!" );
+#endif
+ m_aSupportedFeatures[ aFeature.Command ] = aFeature;
+}
+
+//------------------------------------------------------------------------------
+void OGenericUnoController::describeSupportedFeatures()
+{
+ // add all supported features
+ implDescribeSupportedFeature( ".uno:Copy", ID_BROWSER_COPY, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Cut", ID_BROWSER_CUT, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Paste", ID_BROWSER_PASTE, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:ClipboardFormatItems", ID_BROWSER_CLIPBOARD_FORMAT_ITEMS );
+ implDescribeSupportedFeature( ".uno:DSBEditDoc", ID_BROWSER_EDITDOC, CommandGroup::DOCUMENT );
+}
+
+//------------------------------------------------------------------------------
+FeatureState OGenericUnoController::GetState( sal_uInt16 _nId ) const
+{
+ FeatureState aReturn;
+ // (disabled automatically)
+
+ switch ( _nId )
+ {
+ case ID_BROWSER_UNDO:
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = sal_True;
+ break;
+ default:
+ aReturn = m_pData->m_aUserDefinedFeatures.getState( getURLForId( _nId ) );
+ break;
+ }
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+void OGenericUnoController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue>& _rArgs )
+{
+ OSL_ENSURE( isUserDefinedFeature( _nId ),
+ "OGenericUnoController::Execute: responsible for user defined features only!" );
+
+ // user defined features can be handled by dispatch interceptors resp. protocol handlers only.
+ // So, we need to do a queryDispatch, and dispatch the URL
+ m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs );
+}
+
+//------------------------------------------------------------------------------
+URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
+{
+ URL aReturn;
+ if ( m_xUrlTransformer.is() )
+ {
+ SupportedFeatures::const_iterator aIter = ::std::find_if(
+ m_aSupportedFeatures.begin(),
+ m_aSupportedFeatures.end(),
+ ::std::bind2nd( CompareFeatureById(), _nId )
+ );
+
+ if ( m_aSupportedFeatures.end() != aIter && aIter->first.getLength() )
+ {
+ aReturn.Complete = aIter->first;
+ m_xUrlTransformer->parseStrict( aReturn );
+ }
+ }
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId ) const
+{
+ return ( _nFeatureId >= FIRST_USER_DEFINED_FEATURE ) && ( _nFeatureId < LAST_USER_DEFINED_FEATURE );
+}
+
+//-------------------------------------------------------------------------
+bool OGenericUnoController::isUserDefinedFeature( const ::rtl::OUString& _rFeatureURL ) const
+{
+ SupportedFeatures::const_iterator pos = m_aSupportedFeatures.find( _rFeatureURL );
+ OSL_PRECOND( pos != m_aSupportedFeatures.end(),
+ "OGenericUnoController::isUserDefinedFeature: this is no supported feature at all!" );
+
+ return ( pos != m_aSupportedFeatures.end() ) ? isUserDefinedFeature( pos->second.nFeatureId ) : false;
+}
+
+//-------------------------------------------------------------------------
+sal_Bool SAL_CALL OGenericUnoController::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+
+ const ::rtl::OUString* pArray = aSupported.getConstArray();
+ const ::rtl::OUString* pArrayEnd = aSupported.getConstArray() + aSupported.getLength();
+
+ for ( ;( pArray != pArrayEnd ) && !pArray->equals( ServiceName ); ++pArray )
+ ;
+ return pArray != pArrayEnd;
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::startConnectionListening(const Reference< XConnection >& _rxConnection)
+{
+ // we have to remove ourself before dispoing the connection
+ Reference< XComponent > xComponent(_rxConnection, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(static_cast<XFrameActionListener*>(this));
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::stopConnectionListening(const Reference< XConnection >& _rxConnection)
+{
+ // we have to remove ourself before dispoing the connection
+ Reference< XComponent > xComponent(_rxConnection, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener(static_cast<XFrameActionListener*>(this));
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > OGenericUnoController::connect( const Reference< XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ WaitObject aWaitCursor( getView() );
+
+ ODatasourceConnector aConnector( getORB(), getView(), ::rtl::OUString() );
+ Reference< XConnection > xConnection = aConnector.connect( _xDataSource, _pErrorInfo );
+ startConnectionListening( xConnection );
+
+ return xConnection;
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection > OGenericUnoController::connect( const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rContextInformation, ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ WaitObject aWaitCursor( getView() );
+
+ ODatasourceConnector aConnector( getORB(), getView(), _rContextInformation );
+ Reference<XConnection> xConnection = aConnector.connect( _rDataSourceName, _pErrorInfo );
+ startConnectionListening( xConnection );
+
+ return xConnection;
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::showError(const SQLExceptionInfo& _rInfo)
+{
+ ::dbaui::showError(_rInfo,getView(),getORB());
+}
+// -----------------------------------------------------------------------------
+Reference< XLayoutManager > OGenericUnoController::getLayoutManager(const Reference< XFrame >& _xFrame) const
+{
+ Reference< XPropertySet > xPropSet( _xFrame, UNO_QUERY );
+ Reference< XLayoutManager > xLayoutManager;
+ if ( xPropSet.is() )
+ {
+ try
+ {
+ xLayoutManager.set(xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))),UNO_QUERY);
+ }
+ catch ( Exception& )
+ {
+ }
+ }
+ return xLayoutManager;
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::loadMenu(const Reference< XFrame >& _xFrame)
+{
+ Reference< XLayoutManager > xLayoutManager = getLayoutManager(_xFrame);
+ if ( xLayoutManager.is() )
+ {
+ xLayoutManager->lock();
+ xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
+ xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/toolbar" )));
+ xLayoutManager->unlock();
+ xLayoutManager->doLayout();
+ }
+
+ onLoadedMenu( xLayoutManager );
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::onLoadedMenu(const Reference< XLayoutManager >& /*_xLayoutManager*/)
+{
+ // not interested in
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::closeTask()
+{
+ m_aAsyncCloseTask.Call();
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OGenericUnoController, OnAsyncCloseTask, void*, EMPTYARG)
+{
+ if ( !OGenericUnoController_Base::rBHelper.bInDispose )
+ {
+ try
+ {
+ Reference< util::XCloseable > xCloseable( m_aCurrentFrame.getFrame(), UNO_QUERY_THROW );
+ xCloseable->close( sal_False ); // false - holds the owner ship for this frame inside this object!
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OGenericUnoController::getViewData(void) throw( RuntimeException )
+{
+ return Any();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::restoreViewData(const Any& /*Data*/) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+Reference< XModel > SAL_CALL OGenericUnoController::getModel(void) throw( RuntimeException )
+{
+ return Reference< XModel >();
+}
+
+// -----------------------------------------------------------------------------
+Reference< XFrame > SAL_CALL OGenericUnoController::getFrame(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ return m_aCurrentFrame.getFrame();
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OGenericUnoController::attachModel(const Reference< XModel > & /*xModel*/) throw( RuntimeException )
+{
+ OSL_FAIL( "OGenericUnoController::attachModel: not supported!" );
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
+{
+ Execute(_nCommandId, aArgs);
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::executeUnChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
+{
+ OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::executeUnChecked: shouldn't this be filled at construction time?" );
+ if ( m_aSupportedFeatures.empty() )
+ fillSupportedFeatures();
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
+ if (aIter != m_aSupportedFeatures.end())
+ Execute( aIter->second.nFeatureId, aArgs );
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::executeChecked(const util::URL& _rCommand, const Sequence< PropertyValue >& aArgs)
+{
+ OSL_PRECOND( !m_aSupportedFeatures.empty(), "OGenericUnoController::executeChecked: shouldn't this be filled at construction time?" );
+ if ( m_aSupportedFeatures.empty() )
+ fillSupportedFeatures();
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCommand.Complete );
+ if ( aIter != m_aSupportedFeatures.end() )
+ {
+ sal_uInt16 nFeatureId = aIter->second.nFeatureId;
+ if ( GetState( nFeatureId ).bEnabled )
+ Execute( nFeatureId, aArgs );
+ }
+}
+// -----------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getModuleHelpModuleName( const Reference< XFrame >& _rxFrame )
+ {
+ const sal_Char* pReturn = NULL;
+
+ try
+ {
+ // get the model of the document in the given frame
+ Reference< XController > xController;
+ if ( _rxFrame.is() )
+ xController = _rxFrame->getController();
+ Reference< XModel > xModel;
+ if ( xController.is() )
+ xModel = xController->getModel();
+ Reference< XServiceInfo > xSI( xModel, UNO_QUERY );
+
+ if ( !xSI.is() )
+ { // try to go up the frame hierarchy
+
+ Reference< XFrame > xParentFrame;
+ if ( _rxFrame.is() )
+ xParentFrame = xParentFrame.query( _rxFrame->getCreator() );
+ // did we find a parent frame? Which is no top-level frame?
+ if ( xParentFrame.is() && !_rxFrame->isTop() )
+ // TODO: to prevent framework assertions, re-insert this "isTop" once 98303 is fixed
+ return lcl_getModuleHelpModuleName( xParentFrame );
+ }
+ else
+ {
+#if OSL_DEBUG_LEVEL > 0
+ Sequence< ::rtl::OUString > sServiceNames = xSI->getSupportedServiceNames();
+ const ::rtl::OUString* pLoop = sServiceNames.getConstArray();
+ for ( sal_Int32 i=0; i<sServiceNames.getLength(); ++i, ++pLoop )
+ {
+ sal_Int32 nDummy = 0;
+ (void)nDummy;
+ }
+#endif
+
+ // check which service we know ....
+ static const sal_Char* pTransTable[] = {
+ "com.sun.star.sdb.OfficeDatabaseDocument","sdatabase",
+ "com.sun.star.report.ReportDefinition","sdatabase",
+ "com.sun.star.text.TextDocument", "swriter",
+ "com.sun.star.sheet.SpreadsheetDocument", "scalc",
+ "com.sun.star.presentation.PresentationDocument", "simpress",
+ "com.sun.star.drawing.DrawingDocument", "sdraw",
+ "com.sun.star.formula.FormularProperties", "smath",
+ "com.sun.star.chart.ChartDocument", "schart"
+ };
+ OSL_ENSURE( ( SAL_N_ELEMENTS( pTransTable ) ) % 2 == 0,
+ "lcl_getModuleHelpModuleName: odd size of translation table!" );
+
+ // loop through the table
+ sal_Int32 nTableEntries = ( SAL_N_ELEMENTS( pTransTable ) ) / 2;
+ const sal_Char** pDocumentService = pTransTable;
+ const sal_Char** pHelpModuleName = pTransTable + 1;
+ for ( sal_Int32 j=0; j<nTableEntries; ++j )
+ {
+ if ( xSI->supportsService( ::rtl::OUString::createFromAscii( *pDocumentService ) ) )
+ { // found a table entry which matches the model's services
+ pReturn = *pHelpModuleName;
+ break;
+ }
+
+ ++pDocumentService; ++pDocumentService;
+ ++pHelpModuleName; ++pHelpModuleName;
+ }
+ }
+
+ if ( !pReturn )
+ {
+ // could not determine the document type we're living in
+ // ->fallback
+ SvtModuleOptions aModOpt;
+ if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
+ pReturn = "swriter";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ pReturn = "sdatabase";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
+ pReturn = "scalc";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
+ pReturn = "simpress";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
+ pReturn = "sdraw";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
+ pReturn = "smath";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SCHART ) )
+ pReturn = "schart";
+ else if ( aModOpt.IsModuleInstalled( SvtModuleOptions::E_SBASIC ) )
+ pReturn = "sbasic";
+ else
+ {
+ OSL_FAIL( "lcl_getModuleHelpModuleName: no installed module found" );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !pReturn )
+ pReturn = "swriter";
+
+ return ::rtl::OUString::createFromAscii( pReturn );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OGenericUnoController::openHelpAgent(rtl::OUString const& _suHelpStringURL )
+{
+ rtl::OUString suURL(_suHelpStringURL);
+ rtl::OUString sLanguage(RTL_CONSTASCII_USTRINGPARAM("Language="));
+ if (suURL.indexOf(sLanguage) == -1)
+ {
+ AppendConfigToken(suURL, sal_False /* sal_False := add '&' */ );
+ }
+ URL aURL;
+ aURL.Complete = suURL;
+
+ openHelpAgent( aURL );
+}
+
+void OGenericUnoController::openHelpAgent(const rtl::OString& _sHelpId)
+{
+ openHelpAgent( createHelpAgentURL( lcl_getModuleHelpModuleName( getFrame() ), _sHelpId ) );
+}
+
+void OGenericUnoController::openHelpAgent( const URL& _rURL )
+{
+ try
+ {
+ URL aURL( _rURL );
+
+ if ( m_xUrlTransformer.is() )
+ m_xUrlTransformer->parseStrict(aURL);
+
+ Reference< XDispatchProvider > xDispProv( m_aCurrentFrame.getFrame(), UNO_QUERY );
+ Reference< XDispatch > xHelpDispatch;
+ if ( xDispProv.is() )
+ xHelpDispatch = xDispProv->queryDispatch(aURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_helpagent")), FrameSearchFlag::PARENT | FrameSearchFlag::SELF);
+ OSL_ENSURE(xHelpDispatch.is(), "SbaTableQueryBrowser::openHelpAgent: could not get a dispatcher!");
+ if (xHelpDispatch.is())
+ {
+ xHelpDispatch->dispatch(aURL, Sequence< PropertyValue >());
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< awt::XWindow> OGenericUnoController::getTopMostContainerWindow() const
+{
+ Reference< ::com::sun::star::awt::XWindow> xWindow;
+
+ // get the top most window
+ Reference< XFrame > xFrame( m_aCurrentFrame.getFrame() );
+ if ( xFrame.is() )
+ {
+ xWindow = xFrame->getContainerWindow();
+
+ while ( xFrame.is() && !xFrame->isTop() )
+ {
+ xFrame.set( xFrame->getCreator(), UNO_QUERY );
+ }
+ if ( xFrame.is() )
+ xWindow = xFrame->getContainerWindow();
+ }
+ return xWindow;
+}
+// -----------------------------------------------------------------------------
+Reference< XTitle > OGenericUnoController::impl_getTitleHelper_throw()
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ if ( ! m_xTitleHelper.is ())
+ {
+ Reference< XUntitledNumbers > xUntitledProvider(getPrivateModel(), UNO_QUERY );
+ Reference< XController > xThis(static_cast< XController* >(this), UNO_QUERY_THROW);
+
+ ::framework::TitleHelper* pHelper = new ::framework::TitleHelper(m_xServiceFactory);
+ m_xTitleHelper.set( static_cast< ::cppu::OWeakObject* >(pHelper), UNO_QUERY_THROW);
+
+ pHelper->setOwner (xThis );
+ pHelper->connectWithUntitledNumbers (xUntitledProvider);
+ }
+
+ return m_xTitleHelper;
+}
+
+//=============================================================================
+// XTitle
+::rtl::OUString SAL_CALL OGenericUnoController::getTitle()
+ throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( m_bExternalTitle )
+ return impl_getTitleHelper_throw()->getTitle ();
+ return getPrivateTitle() + impl_getTitleHelper_throw()->getTitle ();
+}
+
+//=============================================================================
+// XTitle
+void SAL_CALL OGenericUnoController::setTitle(const ::rtl::OUString& sTitle)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_bExternalTitle = sal_True;
+ impl_getTitleHelper_throw()->setTitle (sTitle);
+}
+
+//=============================================================================
+// XTitleChangeBroadcaster
+void SAL_CALL OGenericUnoController::addTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
+ throw (RuntimeException)
+{
+ Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
+ if (xBroadcaster.is ())
+ xBroadcaster->addTitleChangeListener (xListener);
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::removeTitleChangeListener(const Reference< XTitleChangeListener >& xListener)
+ throw (RuntimeException)
+{
+ Reference< XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper_throw(), UNO_QUERY);
+ if (xBroadcaster.is ())
+ xBroadcaster->removeTitleChangeListener (xListener);
+}
+
+// =============================================================================
+// XUserInputInterception
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::addKeyHandler( const Reference< XKeyHandler >& _rxHandler ) throw (RuntimeException)
+{
+ if ( _rxHandler.is() )
+ m_pData->m_aUserInputInterception.addKeyHandler( _rxHandler );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::removeKeyHandler( const Reference< XKeyHandler >& _rxHandler ) throw (RuntimeException)
+{
+ m_pData->m_aUserInputInterception.removeKeyHandler( _rxHandler );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::addMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) throw (RuntimeException)
+{
+ if ( _rxHandler.is() )
+ m_pData->m_aUserInputInterception.addMouseClickHandler( _rxHandler );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OGenericUnoController::removeMouseClickHandler( const Reference< XMouseClickHandler >& _rxHandler ) throw (RuntimeException)
+{
+ m_pData->m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
+void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue >& aArgs)
+{
+ if ( isCommandEnabled(_nCommandId) )
+ Execute(_nCommandId, aArgs);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OGenericUnoController::isCommandEnabled(sal_uInt16 _nCommandId) const
+{
+ return GetState( _nCommandId ).bEnabled;
+}
+
+// -----------------------------------------------------------------------------
+sal_uInt16 OGenericUnoController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL )
+{
+ if ( !_rCompleteCommandURL.getLength() )
+ return 0;
+
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL );
+ if ( aIter != m_aSupportedFeatures.end() )
+ return aIter->second.nFeatureId;
+
+ // this is a previously unkwnon command
+ sal_uInt16 nFeatureId = FIRST_USER_DEFINED_FEATURE;
+ while ( isFeatureSupported( nFeatureId ) && ( nFeatureId < LAST_USER_DEFINED_FEATURE ) )
+ ++nFeatureId;
+ if ( nFeatureId == LAST_USER_DEFINED_FEATURE )
+ {
+ OSL_FAIL( "OGenericUnoController::registerCommandURL: no more space for user defined features!" );
+ return 0L;
+ }
+
+ ControllerFeature aFeature;
+ aFeature.Command = _rCompleteCommandURL;
+ aFeature.nFeatureId = nFeatureId;
+ aFeature.GroupId = CommandGroup::INTERNAL;
+ m_aSupportedFeatures[ aFeature.Command ] = aFeature;
+
+ return nFeatureId;
+}
+
+// -----------------------------------------------------------------------------
+void OGenericUnoController::notifyHiContrastChanged()
+{
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OGenericUnoController::isDataSourceReadOnly() const
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XController > OGenericUnoController::getXController() throw( RuntimeException )
+{
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent )
+{
+ return m_pData->m_aUserInputInterception.handleNotifyEvent( _rEvent );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const
+{
+ FeatureState aState = GetState( _nCommandId );
+
+ return aState.bChecked && (sal_Bool)*aState.bChecked;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OGenericUnoController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const
+{
+ OSL_ENSURE( _rCompleteCommandURL.getLength(), "OGenericUnoController::isCommandEnabled: Empty command url!" );
+
+ sal_Bool bIsEnabled = sal_False;
+ SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( _rCompleteCommandURL );
+ if ( aIter != m_aSupportedFeatures.end() )
+ bIsEnabled = isCommandEnabled( aIter->second.nFeatureId );
+
+ return bIsEnabled;
+}
+
+// -----------------------------------------------------------------------------
+Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroups() throw (RuntimeException)
+{
+ CommandHashMap aCmdHashMap;
+ for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
+ aIter != m_aSupportedFeatures.end();
+ ++aIter
+ )
+ if ( aIter->second.GroupId != CommandGroup::INTERNAL )
+ aCmdHashMap.insert( CommandHashMap::value_type( aIter->second.GroupId, 0 ));
+
+ Sequence< sal_Int16 > aCommandGroups( aCmdHashMap.size() );
+ ::std::transform( aCmdHashMap.begin(),
+ aCmdHashMap.end(),
+ aCommandGroups.getArray(),
+ ::o3tl::select1st< CommandHashMap::value_type >()
+ );
+
+ return aCommandGroups;
+}
+
+namespace
+{
+ //Current c++0x draft (apparently) has std::identity, but not operator()
+ template<typename T> struct SGI_identity : public std::unary_function<T,T>
+ {
+ T& operator()(T& x) const { return x; }
+ const T& operator()(const T& x) const { return x; }
+ };
+}
+
+// -----------------------------------------------------------------------------
+Sequence< DispatchInformation > SAL_CALL OGenericUnoController::getConfigurableDispatchInformation( ::sal_Int16 CommandGroup ) throw (RuntimeException)
+{
+ DispatchInfoList aInformationList;
+ DispatchInformation aDispatchInfo;
+ for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin();
+ aIter != m_aSupportedFeatures.end();
+ ++aIter
+ )
+ {
+ if ( sal_Int16( aIter->second.GroupId ) == CommandGroup )
+ {
+ aDispatchInfo = aIter->second;
+ aInformationList.push_back( aDispatchInfo );
+ }
+ }
+
+ Sequence< DispatchInformation > aInformation( aInformationList.size() );
+ ::std::transform( aInformationList.begin(),
+ aInformationList.end(),
+ aInformation.getArray(),
+ SGI_identity< DispatchInformation >()
+ );
+
+ return aInformation;
+}
+// -----------------------------------------------------------------------------
+void OGenericUnoController::fillSupportedFeatures()
+{
+#ifdef DBG_UTIL
+ m_bDescribingSupportedFeatures = true;
+#endif
+ describeSupportedFeatures();
+// -----------------------------------------------------------------------------
+#ifdef DBG_UTIL
+ m_bDescribingSupportedFeatures = false;
+#endif
+}
+
+
+void SAL_CALL OGenericUnoController::dispose() throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ OGenericUnoController_Base::dispose();
+}
+} // namespace dbaui
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/makefile.mk b/dbaccess/source/ui/browser/makefile.mk
new file mode 100644
index 000000000000..4d0cbc8f8517
--- /dev/null
+++ b/dbaccess/source/ui/browser/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=browser
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/AsyncronousLink.obj \
+ $(SLO)$/brwctrlr.obj \
+ $(SLO)$/brwview.obj \
+ $(SLO)$/dataview.obj \
+ $(SLO)$/dbexchange.obj \
+ $(SLO)$/dbloader.obj \
+ $(SLO)$/dbtreemodel.obj \
+ $(SLO)$/dbtreeview.obj \
+ $(SLO)$/dsEntriesNoExp.obj \
+ $(SLO)$/dsbrowserDnD.obj \
+ $(SLO)$/exsrcbrw.obj \
+ $(SLO)$/formadapter.obj \
+ $(SLO)$/genericcontroller.obj \
+ $(SLO)$/sbagrid.obj \
+ $(SLO)$/sbamultiplex.obj \
+ $(SLO)$/unodatbr.obj
+
+SLOFILES =\
+ $(EXCEPTIONSFILES)
+
+SRS1NAME=$(TARGET)
+SRC1FILES = sbabrw.src \
+ sbagrid.src
+
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
+
diff --git a/dbaccess/source/ui/browser/sbabrw.src b/dbaccess/source/ui/browser/sbabrw.src
new file mode 100644
index 000000000000..eebcc013788d
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbabrw.src
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#include "toolbox.hrc"
+
+QueryBox QUERY_BRW_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The current record has been changed.\nDo you want to save the changes?" ;
+};
+
+QueryBox QUERY_BRW_DELETE_ROWS
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "Do you want to delete the selected data?" ;
+};
+
+String RID_STR_DATABROWSER_FILTERED
+{
+ Text [ en-US ] = "(filtered)" ;
+};
+
+String SBA_BROWSER_SETTING_ORDER
+{
+ Text [ en-US ] = "Error setting the sort criteria";
+};
+
+String SBA_BROWSER_SETTING_FILTER
+{
+ Text [ en-US ] = "Error setting the filter criteria";
+};
+
+String RID_STR_CONNECTION_LOST
+{
+ Text [ en-US ] = "Connection lost";
+};
+
+String RID_STR_QUERIES_CONTAINER
+{
+ Text [ en-US ] = "Queries";
+};
+
+String RID_STR_TABLES_CONTAINER
+{
+ Text [ en-US ] = "Tables";
+};
+
+#define MID_EDIT_DATABASE \
+ Identifier = ID_TREE_EDIT_DATABASE ; \
+ HelpId = HID_BROWSER_EDIT_DATABASE; \
+ Text [ en-US ] = "Edit ~Database File..." ;\
+
+#define MID_ADMINISTRATE \
+ Identifier = ID_TREE_ADMINISTRATE ; \
+ HelpId = HID_BROWSER_ADMINISTRATE; \
+ Text [ en-US ] = "Registered databases ..." ;\
+
+#define MID_CLOSECONN \
+ Identifier = ID_TREE_CLOSE_CONN ; \
+ HelpId = HID_BROWSER_CLOSECONN ; \
+ Text [ en-US ] = "Disco~nnect" ; \
+
+Menu MENU_BROWSER_DEFAULTCONTEXT
+{
+ ItemList =
+ {
+ MenuItem \
+ { \
+ MID_EDIT_DATABASE \
+ }; \
+ MenuItem \
+ { \
+ MID_CLOSECONN \
+ }; \
+ MenuItem \
+ { \
+ Separator = TRUE; \
+ }; \
+ MenuItem { ITEM_EDIT_COPY };
+ MenuItem \
+ { \
+ Separator = TRUE; \
+ }; \
+ MenuItem \
+ { \
+ MID_ADMINISTRATE \
+ };
+ };
+};
+
+String STR_TITLE_CONFIRM_DELETION
+{
+ Text [ en-US ] = "Confirm Deletion" ;
+};
+
+String STR_QUERY_DELETE_TABLE
+{
+ Text [ en-US ] = "Do you want to delete the table '%1'?" ;
+};
+
+QueryBox QUERY_BRW_DELETE_QUERY_CONFIRM
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "The query already exists. Do you want to delete it?" ;
+};
+
+QueryBox QUERY_CONNECTION_LOST
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "The connection to the database has been lost. Do you want to reconnect?" ;
+};
+
+String STR_OPENTABLES_WARNINGS
+{
+ Text [ en-US ] = "Warnings encountered";
+};
+
+String STR_OPENTABLES_WARNINGS_DETAILS
+{
+ Text [ en-US ] = "While retrieving the tables, warnings were reported by the database connection.";
+};
+
+String STR_CONNECTING_DATASOURCE
+{
+ Text [ en-US ] = "Connecting to \"$name$\" ...";
+};
+
+String STR_LOADING_QUERY
+{
+ Text [ en-US ] = "Loading query $name$ ...";
+};
+
+String STR_LOADING_TABLE
+{
+ Text [ en-US ] = "Loading table $name$ ...";
+};
+
+String STR_NO_TABLE_FORMAT_INSIDE
+{
+ Text [ en-US ] = "No table format could be found." ;
+};
+
+String STR_COULDNOTCONNECT_DATASOURCE
+{
+ Text [ en-US ] = "The connection to the data source \"$name$\" could not be established.";
+};
+
+Menu RID_MENU_REFRESH_DATA
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ MID_SBA_QRY_REFRESH
+ Command = ".uno:Refresh";
+ };
+ MenuItem
+ {
+ Identifier = ID_BROWSER_REFRESH_REBUILD;
+ Command = ".uno:DBRebuildData";
+ Text [ en-US ] = "Rebuild";
+ };
+ };
+};
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
new file mode 100644
index 000000000000..d80a80281ae3
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -0,0 +1,1660 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "sbagrid.hrc"
+
+#include <svx/svxids.hrc>
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+#define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO
+
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svx/numinf.hxx>
+#include <svx/dbaexchange.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+
+#include "sbagrid.hxx"
+#include "dlgattr.hxx"
+#include "dlgsize.hxx"
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/form/DataSelectionType.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <svl/intitem.hxx>
+
+#include <svx/algitem.hxx>
+
+#include <tools/multisel.hxx>
+
+#include <svx/svxids.hrc>
+
+#include <svl/numuno.hxx>
+
+#include <svl/itempool.hxx>
+
+#include <svl/itemset.hxx>
+
+#include <svl/rngitem.hxx>
+
+#include <vcl/waitobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <svl/zforlist.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <vcl/msgbox.hxx>
+#include <svx/dbexch.hrc>
+#include "dbu_brw.hrc"
+#include "browserids.hxx"
+#include "dbustrings.hrc"
+#include "dbu_reghelper.hxx"
+#include "dbexchange.hxx"
+#include "TableRowExchange.hxx"
+#include "TableRow.hxx"
+#include "FieldDescriptions.hxx"
+#include <svtools/stringtransfer.hxx>
+#include <vcl/stdtext.hxx>
+#include "UITools.hxx"
+#include "TokenWriter.hxx"
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::dbaui;
+using namespace ::dbtools;
+using namespace ::svx;
+using namespace ::svt;
+
+extern "C" void SAL_CALL createRegistryInfo_SbaXGridControl()
+{
+ static OMultiInstanceAutoRegistration< SbaXGridControl > aAutoRegistration;
+}
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL SbaXGridControl::getSupportedServiceNames() throw()
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaXGridControl::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new SbaXGridControl(_rxFactory));
+}
+
+//------------------------------------------------------------------
+
+//------------------------------------------------------------------
+//=======================================================================================
+// SbaXGridControl
+//=======================================================================================
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaXGridControl::getImplementationName() throw()
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SbaXGridControl::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.dbu.SbaXGridControl"));
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SbaXGridControl::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(3);
+ aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.control.InteractionGridControl"));
+ aSupported[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.control.GridControl"));
+ aSupported[2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControl"));
+ return aSupported;
+}
+DBG_NAME(SbaXGridControl );
+//---------------------------------------------------------------------------------------
+SbaXGridControl::SbaXGridControl(const Reference< XMultiServiceFactory >& _rM)
+ : FmXGridControl(_rM)
+{
+ DBG_CTOR(SbaXGridControl ,NULL);
+}
+
+//---------------------------------------------------------------------------------------
+SbaXGridControl::~SbaXGridControl()
+{
+ DBG_DTOR(SbaXGridControl ,NULL);
+}
+
+//---------------------------------------------------------------------------------------
+FmXGridPeer* SbaXGridControl::imp_CreatePeer(Window* pParent)
+{
+ FmXGridPeer* pReturn = new SbaXGridPeer(m_xServiceFactory);
+
+ // translate properties into WinBits
+ WinBits nStyle = WB_TABSTOP;
+ Reference< XPropertySet > xModelSet(getModel(), UNO_QUERY);
+ if (xModelSet.is())
+ {
+ try
+ {
+ if (::comphelper::getINT16(xModelSet->getPropertyValue(PROPERTY_BORDER)))
+ nStyle |= WB_BORDER;
+ }
+ catch(Exception&)
+ {
+ }
+
+ }
+
+ pReturn->Create(pParent, nStyle);
+ return pReturn;
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL SbaXGridControl::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aRet = FmXGridControl::queryInterface(_rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this);
+}
+
+//------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL SbaXGridControl::getTypes( ) throw (RuntimeException)
+{
+ Sequence< Type > aTypes = FmXGridControl::getTypes();
+
+ sal_Int32 nTypes = aTypes.getLength();
+ aTypes.realloc(nTypes + 1);
+ aTypes[nTypes] = ::getCppuType(static_cast< Reference< ::com::sun::star::frame::XDispatch >* >(NULL));
+
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL SbaXGridControl::getImplementationId( ) throw (RuntimeException)
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridControl::createPeer(const Reference< ::com::sun::star::awt::XToolkit > & rToolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer) throw( RuntimeException )
+{
+ FmXGridControl::createPeer(rToolkit, rParentPeer);
+
+ OSL_ENSURE(!mbCreatingPeer, "FmXGridControl::createPeer : recursion!");
+ // see the base class' createPeer for a comment on this
+
+ // TODO: why the hell this whole class does not use any mutex?
+
+ Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY);
+ for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin();
+ aIter != m_aStatusMultiplexer.end();
+ ++aIter)
+ {
+ if ((*aIter).second && (*aIter).second->getLength())
+ xDisp->addStatusListener((*aIter).second, (*aIter).first);
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridControl::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY);
+ if (xDisp.is())
+ xDisp->dispatch(aURL, aArgs);
+}
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridControl::addStatusListener( const Reference< XStatusListener > & _rxListener, const URL& _rURL ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+ if ( _rxListener.is() )
+ {
+ SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[ _rURL ];
+ if ( !pMultiplexer )
+ {
+ pMultiplexer = new SbaXStatusMultiplexer( *this, GetMutex() );
+ pMultiplexer->acquire();
+ }
+
+ pMultiplexer->addInterface( _rxListener );
+ if ( getPeer().is() )
+ {
+ if ( 1 == pMultiplexer->getLength() )
+ { // the first external listener for this URL
+ Reference< XDispatch > xDisp( getPeer(), UNO_QUERY );
+ xDisp->addStatusListener( pMultiplexer, _rURL );
+ }
+ else
+ { // already have other listeners for this URL
+ _rxListener->statusChanged( pMultiplexer->getLastEvent() );
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridControl::removeStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & _rxListener, const ::com::sun::star::util::URL& _rURL) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+
+ SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[_rURL];
+ if (!pMultiplexer)
+ {
+ pMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex());
+ pMultiplexer->acquire();
+ }
+
+ if (getPeer().is() && pMultiplexer->getLength() == 1)
+ {
+ Reference< ::com::sun::star::frame::XDispatch > xDisp(getPeer(), UNO_QUERY);
+ xDisp->removeStatusListener(pMultiplexer, _rURL);
+ }
+ pMultiplexer->removeInterface( _rxListener );
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridControl::dispose(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ EventObject aEvt;
+ aEvt.Source = *this;
+
+ for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin();
+ aIter != m_aStatusMultiplexer.end();
+ ++aIter)
+ {
+ if ((*aIter).second)
+ {
+ (*aIter).second->disposeAndClear(aEvt);
+ (*aIter).second->release();
+ (*aIter).second = NULL;
+ }
+ }
+ StatusMultiplexerArray().swap(m_aStatusMultiplexer);
+
+ FmXGridControl::dispose();
+}
+
+//=======================================================================================
+// SbaXGridPeer
+//=======================================================================================
+DBG_NAME(SbaXGridPeer )
+//---------------------------------------------------------------------------------------
+SbaXGridPeer::SbaXGridPeer(const Reference< XMultiServiceFactory >& _rM)
+: FmXGridPeer(_rM)
+,m_aStatusListeners(m_aMutex)
+{
+ DBG_CTOR(SbaXGridPeer ,NULL);
+}
+
+//---------------------------------------------------------------------------------------
+SbaXGridPeer::~SbaXGridPeer()
+{
+ DBG_DTOR(SbaXGridPeer ,NULL);
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridPeer::dispose(void) throw( RuntimeException )
+{
+ EventObject aEvt(*this);
+
+ m_aStatusListeners.disposeAndClear(aEvt);
+
+ FmXGridPeer::dispose();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaXGridPeer::NotifyStatusChanged(const ::com::sun::star::util::URL& _rUrl, const Reference< ::com::sun::star::frame::XStatusListener > & xControl)
+{
+ SbaGridControl* pGrid = (SbaGridControl*) GetWindow();
+ if (!pGrid)
+ return;
+
+ ::com::sun::star::frame::FeatureStateEvent aEvt;
+ aEvt.Source = *this;
+ aEvt.IsEnabled = !pGrid->IsReadOnlyDB();
+ aEvt.FeatureURL = _rUrl;
+
+ ConstMapDispatchToBoolIterator aURLStatePos = m_aDispatchStates.find( classifyDispatchURL( _rUrl ) );
+ if ( m_aDispatchStates.end() != aURLStatePos )
+ aEvt.State <<= aURLStatePos->second;
+ else
+ aEvt.State <<= sal_False;
+
+ if (xControl.is())
+ xControl->statusChanged(aEvt);
+ else
+ {
+ ::cppu::OInterfaceContainerHelper * pIter = m_aStatusListeners.getContainer(_rUrl);
+
+ if (pIter)
+ {
+ ::cppu::OInterfaceIteratorHelper aListIter(*pIter);
+ while (aListIter.hasMoreElements())
+ ((::com::sun::star::frame::XStatusListener*)aListIter.next())->statusChanged(aEvt);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL SbaXGridPeer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(_rType,(::com::sun::star::frame::XDispatch*)this);
+ if(aRet.hasValue())
+ return aRet;
+ return FmXGridPeer::queryInterface(_rType);
+}
+
+//---------------------------------------------------------------------------------------
+Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaXGridPeer::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
+{
+ if ( (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:GridSlots/BrowserAttribs"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:GridSlots/RowHeight"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:GridSlots/ColumnAttribs"))))
+ || (aURL.Complete.equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:GridSlots/ColumnWidth"))))
+ )
+ {
+ return (::com::sun::star::frame::XDispatch*)this;
+ }
+
+ return FmXGridPeer::queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+}
+
+//---------------------------------------------------------------------------------------
+IMPL_LINK( SbaXGridPeer, OnDispatchEvent, void*, /*NOTINTERESTEDIN*/ )
+{
+ SbaGridControl* pGrid = static_cast< SbaGridControl* >( GetWindow() );
+ if ( pGrid ) // if this fails, we were disposing before arriving here
+ {
+ if ( Application::GetMainThreadIdentifier() != ::osl::Thread::getCurrentIdentifier() )
+ {
+ // still not in the main thread (see SbaXGridPeer::dispatch). post an event, again
+ // without moving the special even to the back of the queue
+ pGrid->PostUserEvent( LINK( this, SbaXGridPeer, OnDispatchEvent ) );
+ }
+ else
+ {
+ DispatchArgs aArgs = m_aDispatchArgs.front();
+ m_aDispatchArgs.pop();
+
+ SbaXGridPeer::dispatch( aArgs.aURL, aArgs.aArgs );
+ }
+ }
+
+ return 0;
+}
+
+//---------------------------------------------------------------------------------------
+SbaXGridPeer::DispatchType SbaXGridPeer::classifyDispatchURL( const URL& _rURL )
+{
+ DispatchType eURLType = dtUnknown;
+ if ( _rURL.Complete.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GridSlots/BrowserAttribs" ) ) )
+ eURLType = dtBrowserAttribs;
+ else if ( _rURL.Complete.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GridSlots/RowHeight" ) ) )
+ eURLType = dtRowHeight;
+ else if ( _rURL.Complete.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GridSlots/ColumnAttribs" ) ) )
+ eURLType = dtColumnAttribs;
+ else if ( _rURL.Complete.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ".uno:GridSlots/ColumnWidth" ) ) )
+ eURLType = dtColumnWidth;
+ return eURLType;
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridPeer::dispatch(const URL& aURL, const Sequence< PropertyValue >& aArgs) throw( RuntimeException )
+{
+ SbaGridControl* pGrid = (SbaGridControl*)GetWindow();
+ if (!pGrid)
+ return;
+
+ if ( Application::GetMainThreadIdentifier() != ::osl::Thread::getCurrentIdentifier() )
+ {
+ // we're not in the main thread. This is bad, as we want to raise windows here,
+ // and VCL does not like windows to be opened in non-main threads (at least on Win32).
+ // Okay, do this async. No problem with this, as XDispatch::dispatch is defined to be
+ // a one-way method.
+
+ // save the args
+ DispatchArgs aDispatchArgs;
+ aDispatchArgs.aURL = aURL;
+ aDispatchArgs.aArgs = aArgs;
+ m_aDispatchArgs.push( aDispatchArgs );
+
+ // post an event
+ // we use the Window::PostUserEvent here, instead of the application::PostUserEvent
+ // this saves us from keeping track of these events - as soon as the window dies,
+ // the events are deleted automatically. For the application way, we would need to
+ // do this ourself.
+ // As we use our grid as window, and the grid dies before we dy, this should be no problem.
+ pGrid->PostUserEvent( LINK( this, SbaXGridPeer, OnDispatchEvent ) );
+ return;
+ }
+
+ SolarMutexGuard aGuard;
+ sal_Int16 nColId = -1;
+ const PropertyValue* pArgs = aArgs.getConstArray();
+ for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArgs)
+ {
+ if (pArgs->Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnViewPos")))
+ {
+ nColId = pGrid->GetColumnIdFromViewPos(::comphelper::getINT16(pArgs->Value));
+ break;
+ }
+ if (pArgs->Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnModelPos")))
+ {
+ nColId = pGrid->GetColumnIdFromModelPos(::comphelper::getINT16(pArgs->Value));
+ break;
+ }
+ if (pArgs->Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnId")))
+ {
+ nColId = ::comphelper::getINT16(pArgs->Value);
+ break;
+ }
+ }
+
+ DispatchType eURLType = classifyDispatchURL( aURL );
+
+ if ( dtUnknown != eURLType )
+ {
+ // notify any status listeners that the dialog is now active (well, about to be active)
+ MapDispatchToBool::iterator aThisURLState = m_aDispatchStates.insert( MapDispatchToBool::value_type( eURLType, sal_True ) ).first;
+ NotifyStatusChanged( aURL, NULL );
+
+ // execute the dialog
+ switch ( eURLType )
+ {
+ case dtBrowserAttribs:
+ pGrid->SetBrowserAttrs();
+ break;
+
+ case dtRowHeight:
+ pGrid->SetRowHeight();
+ break;
+
+ case dtColumnAttribs:
+ {
+ OSL_ENSURE(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !");
+ if (nColId != -1)
+ break;
+ pGrid->SetColAttrs(nColId);
+ }
+ break;
+
+ case dtColumnWidth:
+ {
+ OSL_ENSURE(nColId != -1, "SbaXGridPeer::dispatch : invalid parameter !");
+ if (nColId != -1)
+ break;
+ pGrid->SetColWidth(nColId);
+ }
+ break;
+
+ case dtUnknown:
+ break;
+ }
+
+ // notify any status listeners that the dialog vanished
+ m_aDispatchStates.erase( aThisURLState );
+ NotifyStatusChanged( aURL, NULL );
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridPeer::addStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( RuntimeException )
+{
+ ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL);
+ if (!pCont)
+ m_aStatusListeners.addInterface(aURL,xControl);
+ else
+ pCont->addInterface(xControl);
+ NotifyStatusChanged(aURL, xControl);
+}
+
+//---------------------------------------------------------------------------------------
+void SAL_CALL SbaXGridPeer::removeStatusListener(const Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( RuntimeException )
+{
+ ::cppu::OInterfaceContainerHelper* pCont = m_aStatusListeners.getContainer(aURL);
+ if ( pCont )
+ pCont->removeInterface(xControl);
+}
+
+//---------------------------------------------------------------------------------------
+const Sequence< sal_Int8 > & SbaXGridPeer::getUnoTunnelId()
+{
+ static Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0,sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+//---------------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL SbaXGridPeer::getTypes() throw (RuntimeException)
+{
+ Sequence< Type > aTypes = FmXGridPeer::getTypes();
+ sal_Int32 nOldLen = aTypes.getLength();
+ aTypes.realloc(nOldLen + 1);
+ aTypes.getArray()[nOldLen] = ::getCppuType( reinterpret_cast< Reference< ::com::sun::star::frame::XDispatch >* >(NULL) );
+
+ return aTypes;
+}
+
+// return implementation specific data
+//------------------------------------------------------------------
+sal_Int64 SAL_CALL SbaXGridPeer::getSomething( const Sequence< sal_Int8 > & rId ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
+ return reinterpret_cast< sal_Int64 >( this );
+
+ return FmXGridPeer::getSomething(rId);
+}
+
+//---------------------------------------------------------------------------------------
+SbaXGridPeer* SbaXGridPeer::getImplementation(const Reference< XInterface >& _rxIFace)
+{
+ Reference< XUnoTunnel > xTunnel(
+ _rxIFace, UNO_QUERY);
+ if (xTunnel.is())
+ return reinterpret_cast<SbaXGridPeer*>(xTunnel->getSomething(getUnoTunnelId()));
+ return NULL;
+}
+
+//---------------------------------------------------------------------------------------
+FmGridControl* SbaXGridPeer::imp_CreateControl(Window* pParent, WinBits nStyle)
+{
+ return new SbaGridControl(m_xServiceFactory, pParent, this, nStyle);
+}
+
+//==================================================================
+// SbaGridHeader
+//==================================================================
+
+//---------------------------------------------------------------------------------------
+SbaGridHeader::SbaGridHeader(BrowseBox* pParent, WinBits nWinBits)
+ :FmGridHeader(pParent, nWinBits)
+ ,DragSourceHelper(this)
+{
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridHeader::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
+{
+ SolarMutexGuard aGuard;
+ // in the new DnD API, the solar mutex is not locked when StartDrag get's called
+
+ ImplStartColumnDrag( _nAction, _rPosPixel );
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridHeader::MouseButtonDown( const MouseEvent& _rMEvt )
+{
+ if (_rMEvt.IsLeft())
+ if (_rMEvt.GetClicks() != 2)
+ {
+ // the base class will start a column move here, which we don't want to allow
+ // (at the moment. If we store relative positions with the columns, we can allow column moves ....)
+
+ }
+
+ FmGridHeader::MouseButtonDown(_rMEvt);
+}
+
+//---------------------------------------------------------------------------------------
+sal_Bool SbaGridHeader::ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMousePos)
+{
+ sal_uInt16 nId = GetItemId(_rMousePos);
+ sal_Bool bResizingCol = sal_False;
+ if (HEADERBAR_ITEM_NOTFOUND != nId)
+ {
+ Rectangle aColRect = GetItemRect(nId);
+ aColRect.Left() += nId ? 3 : 0; // the handle col (nId == 0) does not have a left margin for resizing
+ aColRect.Right() -= 3;
+ bResizingCol = !aColRect.IsInside(_rMousePos);
+ }
+ if (!bResizingCol)
+ {
+ // force the the base class to end it's drag mode
+ EndTracking(ENDTRACK_CANCEL | ENDTRACK_END);
+
+ // because we have 3d-buttons the select handler is called from MouseButtonUp, but StartDrag
+ // occures earlier (while the mouse button is down)
+ // so for optical reasons we select the column before really starting the drag operation.
+ notifyColumnSelect(nId);
+
+ static_cast<SbaGridControl*>(GetParent())->StartDrag(_nAction,
+ Point(
+ _rMousePos.X() + GetPosPixel().X(), // we aren't left-justified with our parent, in contrast to the data window
+ _rMousePos.Y() - GetSizePixel().Height()
+ )
+ );
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu)
+{
+ FmGridHeader::PreExecuteColumnContextMenu(nColId, rMenu);
+
+ // some items are valid only if the db isn't readonly
+ sal_Bool bDBIsReadOnly = ((SbaGridControl*)GetParent())->IsReadOnlyDB();
+
+ if (bDBIsReadOnly)
+ {
+ rMenu.EnableItem(SID_FM_HIDECOL, sal_False);
+ PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(SID_FM_SHOWCOLS);
+ if (pShowColsMenu)
+ {
+ // at most 16 items which mean "show column <name>"
+ for (sal_uInt16 i=1; i<16; ++i)
+ pShowColsMenu->EnableItem(i, sal_False);
+ // "show cols/more..." and "show cols/all"
+ pShowColsMenu->EnableItem(SID_FM_SHOWCOLS_MORE, sal_False);
+ pShowColsMenu->EnableItem(SID_FM_SHOWALLCOLS, sal_False);
+ }
+ }
+
+ // prepend some new items
+ sal_Bool bColAttrs = (nColId != (sal_uInt16)-1) && (nColId != 0);
+ if ( bColAttrs && !bDBIsReadOnly)
+ {
+ PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_COLCTXMENU));
+ sal_uInt16 nPos = 0;
+ sal_uInt16 nModelPos = ((SbaGridControl*)GetParent())->GetModelColumnPos(nColId);
+ Reference< XPropertySet > xField = ((SbaGridControl*)GetParent())->getField(nModelPos);
+
+ if ( xField.is() )
+ {
+ switch( ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE)) )
+ {
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::SQLNULL:
+ case DataType::OBJECT:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::REF:
+ break;
+ default:
+ rMenu.InsertItem(ID_BROWSER_COLATTRSET, aNewItems.GetItemText(ID_BROWSER_COLATTRSET), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_COLATTRSET, aNewItems.GetHelpId(ID_BROWSER_COLATTRSET));
+ rMenu.InsertSeparator(nPos++);
+ }
+ }
+
+ rMenu.InsertItem(ID_BROWSER_COLWIDTH, aNewItems.GetItemText(ID_BROWSER_COLWIDTH), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_COLWIDTH, aNewItems.GetHelpId(ID_BROWSER_COLWIDTH));
+ rMenu.InsertSeparator(nPos++);
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+{
+ switch (nExecutionResult)
+ {
+ case ID_BROWSER_COLWIDTH:
+ ((SbaGridControl*)GetParent())->SetColWidth(nColId);
+ break;
+
+ case ID_BROWSER_COLATTRSET:
+ ((SbaGridControl*)GetParent())->SetColAttrs(nColId);
+ break;
+ case ID_BROWSER_COLUMNINFO:
+ {
+ sal_uInt16 nModelPos = ((SbaGridControl*)GetParent())->GetModelColumnPos(nColId);
+ Reference< XPropertySet > xField = ((SbaGridControl*)GetParent())->getField(nModelPos);
+
+ if(!xField.is())
+ break;
+ ::std::vector< ::boost::shared_ptr<OTableRow> > vClipboardList;
+ // send it to the clipboard
+ vClipboardList.push_back(::boost::shared_ptr<OTableRow>(new OTableRow(xField)));
+ OTableRowExchange* pData = new OTableRowExchange(vClipboardList);
+ Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
+ pData->CopyToClipboard(GetParent());
+ }
+ break;
+
+ default: FmGridHeader::PostExecuteColumnContextMenu(nColId, rMenu, nExecutionResult);
+ }
+}
+
+//==================================================================
+// SbaGridControl
+//==================================================================
+DBG_NAME(SbaGridControl );
+//---------------------------------------------------------------------------------------
+SbaGridControl::SbaGridControl(Reference< XMultiServiceFactory > _rM,
+ Window* pParent, FmXGridPeer* _pPeer, WinBits nBits)
+ :FmGridControl(_rM,pParent, _pPeer, nBits)
+ ,m_pMasterListener(NULL)
+ ,m_nAsyncDropEvent(0)
+ ,m_nCurrentActionColId((sal_uInt16)-1)
+ ,m_bActivatingForDrop(sal_False)
+{
+ DBG_CTOR(SbaGridControl ,NULL);
+}
+
+//---------------------------------------------------------------------------------------
+SbaGridControl::~SbaGridControl()
+{
+ DBG_DTOR(SbaGridControl ,NULL);
+ if (m_nAsyncDropEvent)
+ Application::RemoveUserEvent(m_nAsyncDropEvent);
+}
+
+//---------------------------------------------------------------------------------------
+BrowserHeader* SbaGridControl::imp_CreateHeaderBar(BrowseBox* pParent)
+{
+ return new SbaGridHeader(pParent);
+}
+
+//---------------------------------------------------------------------------------------
+CellController* SbaGridControl::GetController(long nRow, sal_uInt16 nCol)
+{
+ if ( m_bActivatingForDrop )
+ return NULL;
+
+ return FmGridControl::GetController(nRow, nCol);
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu)
+{
+ FmGridControl::PreExecuteRowContextMenu(nRow, rMenu);
+
+ PopupMenu aNewItems(ModuleRes(RID_SBA_GRID_ROWCTXMENU));
+ sal_uInt16 nPos = 0;
+
+ if (!IsReadOnlyDB())
+ {
+ rMenu.InsertItem(ID_BROWSER_TABLEATTR, aNewItems.GetItemText(ID_BROWSER_TABLEATTR), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_TABLEATTR, aNewItems.GetHelpId(ID_BROWSER_TABLEATTR));
+
+ rMenu.InsertItem(ID_BROWSER_ROWHEIGHT, aNewItems.GetItemText(ID_BROWSER_ROWHEIGHT), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_ROWHEIGHT, aNewItems.GetHelpId(ID_BROWSER_ROWHEIGHT));
+ rMenu.InsertSeparator(nPos++);
+ }
+
+ if ( GetSelectRowCount() > 0 )
+ {
+ rMenu.InsertItem(ID_BROWSER_COPY, aNewItems.GetItemText(SID_COPY), 0, nPos++);
+ rMenu.SetHelpId(ID_BROWSER_COPY, aNewItems.GetHelpId(SID_COPY));
+
+ rMenu.InsertSeparator(nPos++);
+ }
+}
+
+//------------------------------------------------------------------------------
+SvNumberFormatter* SbaGridControl::GetDatasourceFormatter()
+{
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = ::dbtools::getNumberFormats(::dbtools::getConnection(Reference< XRowSet > (getDataSource(),UNO_QUERY)), sal_True,getServiceManager());
+
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ if ( !pSupplierImpl )
+ return NULL;
+
+ SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
+ return pFormatter;
+}
+
+//------------------------------------------------------------------------------
+void SbaGridControl::SetColWidth(sal_uInt16 nColId)
+{
+ // get the (UNO) column model
+ sal_uInt16 nModelPos = GetModelColumnPos(nColId);
+ Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY);
+ Reference< XPropertySet > xAffectedCol;
+ if (xCols.is() && (nModelPos != (sal_uInt16)-1))
+ ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos));
+
+ if (xAffectedCol.is())
+ {
+ Any aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH);
+ sal_Int32 nCurWidth = aWidth.hasValue() ? ::comphelper::getINT32(aWidth) : -1;
+
+ DlgSize aDlgColWidth(this, nCurWidth, sal_False);
+ if (aDlgColWidth.Execute())
+ {
+ sal_Int32 nValue = aDlgColWidth.GetValue();
+ Any aNewWidth;
+ if (-1 == nValue)
+ { // set to default
+ Reference< XPropertyState > xPropState(xAffectedCol, UNO_QUERY);
+ if (xPropState.is())
+ {
+ try { aNewWidth = xPropState->getPropertyDefault(PROPERTY_WIDTH); } catch(Exception&) { } ;
+ }
+ }
+ else
+ aNewWidth <<= nValue;
+ try { xAffectedCol->setPropertyValue(PROPERTY_WIDTH, aNewWidth); } catch(Exception&) { } ;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SbaGridControl::SetRowHeight()
+{
+ Reference< XPropertySet > xCols(GetPeer()->getColumns(), UNO_QUERY);
+ if (!xCols.is())
+ return;
+
+ Any aHeight = xCols->getPropertyValue(PROPERTY_ROW_HEIGHT);
+ sal_Int32 nCurHeight = aHeight.hasValue() ? ::comphelper::getINT32(aHeight) : -1;
+
+ DlgSize aDlgRowHeight(this, nCurHeight, sal_True);
+ if (aDlgRowHeight.Execute())
+ {
+ sal_Int32 nValue = aDlgRowHeight.GetValue();
+ Any aNewHeight;
+ if ((sal_Int16)-1 == nValue)
+ { // set to default
+ Reference< XPropertyState > xPropState(xCols, UNO_QUERY);
+ if (xPropState.is())
+ {
+ try
+ {
+ aNewHeight = xPropState->getPropertyDefault(PROPERTY_ROW_HEIGHT);
+ }
+ catch(Exception&)
+ { }
+ }
+ }
+ else
+ aNewHeight <<= nValue;
+ try
+ {
+ xCols->setPropertyValue(PROPERTY_ROW_HEIGHT, aNewHeight);
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("setPropertyValue: PROPERTY_ROW_HEIGHT throws a exception");
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SbaGridControl::SetColAttrs(sal_uInt16 nColId)
+{
+ SvNumberFormatter* pFormatter = GetDatasourceFormatter();
+ if (!pFormatter)
+ return;
+
+ sal_uInt16 nModelPos = GetModelColumnPos(nColId);
+
+ // get the (UNO) column model
+ Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY);
+ Reference< XPropertySet > xAffectedCol;
+ if (xCols.is() && (nModelPos != (sal_uInt16)-1))
+ ::cppu::extractInterface(xAffectedCol,xCols->getByIndex(nModelPos));
+
+ // get the field the column is bound to
+ Reference< XPropertySet > xField = getField(nModelPos);
+ ::dbaui::callColumnFormatDialog(xAffectedCol,xField,pFormatter,this);//(Window::GetSettings().GetLanguage());
+}
+
+
+//------------------------------------------------------------------------------
+void SbaGridControl::SetBrowserAttrs()
+{
+ Reference< XPropertySet > xGridModel(GetPeer()->getColumns(), UNO_QUERY);
+ if (!xGridModel.is())
+ return;
+
+ try
+ {
+ PropertyValue aArg;
+ aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IntrospectedObject"));
+ aArg.Value <<= xGridModel;
+ Sequence< Any > aDialogArgs(1);
+ aDialogArgs[0] <<= aArg;
+
+ Reference< XInterface > xDialog = getServiceManager()->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.ControlFontDialog")),
+ aDialogArgs
+ );
+ if (!xDialog.is())
+ {
+ ShowServiceNotAvailableError(this, String::CreateFromAscii("com.sun.star.form.ControlFontDialog"), sal_True);
+ return;
+ }
+
+ Reference< XExecutableDialog > xExecute(xDialog, UNO_QUERY);
+ OSL_ENSURE(xExecute.is(), "SbaGridControl::SetBrowserAttrs: missing an interface on the dialog!");
+ if (xExecute.is())
+ xExecute->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+{
+ switch (nExecutionResult)
+ {
+ case ID_BROWSER_TABLEATTR:
+ SetBrowserAttrs();
+ break;
+ case ID_BROWSER_ROWHEIGHT:
+ SetRowHeight();
+ break;
+ case ID_BROWSER_COPY:
+ CopySelectedRowsToClipboard();
+ break;
+
+ default:
+ FmGridControl::PostExecuteRowContextMenu(nRow, rMenu, nExecutionResult);
+ break;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::Select()
+{
+ // irgendeine Selektion hat sich geaendert ....
+ FmGridControl::Select();
+
+ if (m_pMasterListener)
+ m_pMasterListener->SelectionChanged();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::CursorMoved()
+{
+ FmGridControl::CursorMoved();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus /*= sal_True*/ )
+{
+ FmGridControl::ActivateCell(nRow, nCol, bSetCellFocus);
+ if (m_pMasterListener)
+ m_pMasterListener->CellActivated();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::DeactivateCell(sal_Bool bUpdate /*= sal_True*/)
+{
+ FmGridControl::DeactivateCell(bUpdate);
+ if (m_pMasterListener)
+ m_pMasterListener->CellDeactivated();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::onRowChange()
+{
+ if ( m_pMasterListener )
+ m_pMasterListener->RowChanged();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::onColumnChange()
+{
+ if ( m_pMasterListener )
+ m_pMasterListener->ColumnChanged();
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::BeforeDrop()
+{
+ if (m_pMasterListener)
+ m_pMasterListener->BeforeDrop();
+}
+//---------------------------------------------------------------------------------------
+void SbaGridControl::AfterDrop()
+{
+ if (m_pMasterListener)
+ m_pMasterListener->AfterDrop();
+}
+
+
+//------------------------------------------------------------------------------
+Reference< XPropertySet > SbaGridControl::getField(sal_uInt16 nModelPos)
+{
+ Reference< XPropertySet > xEmptyReturn;
+ try
+ {
+ // first get the name of the column
+ Reference< XIndexAccess > xCols(GetPeer()->getColumns(), UNO_QUERY);
+ if ( xCols.is() && xCols->getCount() > nModelPos )
+ {
+ Reference< XPropertySet > xCol(xCols->getByIndex(nModelPos),UNO_QUERY);
+ if ( xCol.is() )
+ xEmptyReturn.set(xCol->getPropertyValue(PROPERTY_BOUNDFIELD),UNO_QUERY);
+ }
+ else
+ OSL_FAIL("SbaGridControl::getField getColumns returns NULL or ModelPos is > than count!");
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaGridControl::getField Exception occurred!");
+ }
+
+ return xEmptyReturn;
+}
+
+//---------------------------------------------------------------------------------------
+sal_Bool SbaGridControl::IsReadOnlyDB() const
+{
+ // assume yes if anything fails
+ sal_Bool bDBIsReadOnly = sal_True;
+
+ // the db is the implemented by the parent of the grid control's model ...
+ Reference< XChild > xColumns(GetPeer()->getColumns(), UNO_QUERY);
+ if (xColumns.is())
+ {
+ Reference< XRowSet > xDataSource(xColumns->getParent(), UNO_QUERY);
+ Reference< XChild > xConn(::dbtools::getConnection(xDataSource),UNO_QUERY);
+ if (xConn.is())
+ {
+ // ... and the RO-flag simply is implemented by a property
+ Reference< XPropertySet > xDbProps(xConn->getParent(), UNO_QUERY);
+ if (xDbProps.is())
+ {
+ Reference< XPropertySetInfo > xInfo = xDbProps->getPropertySetInfo();
+ if (xInfo->hasPropertyByName(PROPERTY_ISREADONLY))
+ bDBIsReadOnly = ::comphelper::getBOOL(xDbProps->getPropertyValue(PROPERTY_ISREADONLY));
+ }
+ }
+ }
+ return bDBIsReadOnly;
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::MouseButtonDown( const BrowserMouseEvent& rMEvt)
+{
+ long nRow = GetRowAtYPosPixel(rMEvt.GetPosPixel().Y());
+ sal_uInt16 nColPos = GetColumnAtXPosPixel(rMEvt.GetPosPixel().X());
+ sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1;
+ // 'the handle column' and 'no valid column' will both result in a view position of -1 !
+
+ sal_Bool bHitEmptySpace = (nRow > GetRowCount()) || (nViewPos == (sal_uInt16)-1);
+
+ if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1())
+ Control::MouseButtonDown(rMEvt);
+ else
+ FmGridControl::MouseButtonDown(rMEvt);
+}
+
+//---------------------------------------------------------------------------------------
+void SbaGridControl::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
+{
+ SolarMutexGuard aGuard;
+ // in the new DnD API, the solar mutex is not locked when StartDrag get's called
+
+ sal_Bool bHandled = sal_False;
+
+ do
+ {
+ // determine if dragging is allowed
+ // (Yes, this is controller (not view) functionality. But collecting and evaluating all the
+ // informations necessary via UNO would be quite difficult (if not impossible) so
+ // my laziness says 'do it here' ...)
+ long nRow = GetRowAtYPosPixel(_rPosPixel.Y());
+ sal_uInt16 nColPos = GetColumnAtXPosPixel(_rPosPixel.X());
+ sal_uInt16 nViewPos = (nColPos == BROWSER_INVALIDID) ? (sal_uInt16)-1 : nColPos-1;
+ // 'the handle column' and 'no valid column' will both result in a view position of -1 !
+
+ sal_Bool bCurrentRowVirtual = IsCurrentAppending() && IsModified();
+ // the current row doesn't really exist : the user's appendign a new one and already has entered some data,
+ // so the row contains data which has no counter part within the data source
+
+ long nCorrectRowCount = GetRowCount();
+ if (GetOptions() & OPT_INSERT)
+ --nCorrectRowCount; // there is a empty row for inserting records
+ if (bCurrentRowVirtual)
+ --nCorrectRowCount;
+
+ if ((nColPos == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount))
+ break;
+
+ sal_Bool bHitHandle = (nColPos == 0);
+
+ // check which kind of dragging has to be initiated
+ if ( bHitHandle // the handle column
+ // AND
+ && ( GetSelectRowCount() // at least one row is selected
+ // OR
+ || ( (nRow >= 0) // a row below the header
+ && !bCurrentRowVirtual // we aren't appending a new record
+ && (nRow != GetCurrentPos()) // a row which is not the current one
+ ) // OR
+ || ( (0 == GetSelectRowCount()) // no rows selected
+ && (-1 == nRow) // hit the header
+ )
+ )
+ )
+ { // => start dragging the row
+ if (GetDataWindow().IsMouseCaptured())
+ GetDataWindow().ReleaseMouse();
+
+ if (0 == GetSelectRowCount())
+ // no rows selected, but here in this branch
+ // -> the user started dragging the upper left corner, which symbolizes the whole table
+ SelectAll();
+
+ getMouseEvent().Clear();
+ DoRowDrag((sal_Int16)nRow);
+
+ bHandled = sal_True;
+ }
+ else if ( (nRow < 0) // the header
+ && (!bHitHandle) // non-handle column
+ && (nViewPos < GetViewColCount()) // valid (existing) column
+ )
+ { // => start dragging the column
+ if (GetDataWindow().IsMouseCaptured())
+ GetDataWindow().ReleaseMouse();
+
+ getMouseEvent().Clear();
+ DoColumnDrag(nViewPos);
+
+ bHandled = sal_True;
+ }
+ else if ( !bHitHandle // non-handle column
+ && (nRow >= 0) // non-header row
+ )
+ { // => start dragging the field content
+ if (GetDataWindow().IsMouseCaptured())
+ GetDataWindow().ReleaseMouse();
+
+ getMouseEvent().Clear();
+ DoFieldDrag(nViewPos, (sal_Int16)nRow);
+
+ bHandled = sal_True;
+ }
+ }
+ while (sal_False);
+
+ if (!bHandled)
+ FmGridControl::StartDrag(_nAction, _rPosPixel);
+}
+
+//------------------------------------------------------------------------------
+void SbaGridControl::Command(const CommandEvent& rEvt)
+{
+ FmGridControl::Command(rEvt);
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::DoColumnDrag(sal_uInt16 nColumnPos)
+{
+ Reference< XPropertySet > xDataSource(getDataSource(), UNO_QUERY);
+ OSL_ENSURE(xDataSource.is(), "SbaGridControl::DoColumnDrag : invalid data source !");
+
+ Reference< XPropertySet > xAffectedCol;
+ Reference< XPropertySet > xAffectedField;
+ Reference< XConnection > xActiveConnection;
+
+ // determine the field to drag
+ ::rtl::OUString sField;
+ try
+ {
+ xActiveConnection = ::dbtools::getConnection(Reference< XRowSet >(getDataSource(),UNO_QUERY));
+
+ sal_uInt16 nModelPos = GetModelColumnPos(GetColumnIdFromViewPos(nColumnPos));
+ Reference< XIndexContainer > xCols(GetPeer()->getColumns(), UNO_QUERY);
+ xAffectedCol.set(xCols->getByIndex(nModelPos),UNO_QUERY);
+ if (xAffectedCol.is())
+ {
+ xAffectedCol->getPropertyValue(PROPERTY_CONTROLSOURCE) >>= sField;
+ xAffectedField.set(xAffectedCol->getPropertyValue(PROPERTY_BOUNDFIELD),UNO_QUERY);
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaGridControl::DoColumnDrag : something went wrong while getting the column");
+ }
+ if (0 == sField.getLength())
+ return;
+
+ OColumnTransferable* pDataTransfer = new OColumnTransferable(xDataSource, sField, xAffectedField, xActiveConnection, CTF_FIELD_DESCRIPTOR | CTF_COLUMN_DESCRIPTOR);
+ Reference< XTransferable > xEnsureDelete = pDataTransfer;
+ pDataTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK);
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::CopySelectedRowsToClipboard()
+{
+ OSL_ENSURE( GetSelectRowCount() > 0, "SbaGridControl::CopySelectedRowsToClipboard: invalid call!" );
+ implTransferSelectedRows( (sal_Int16)FirstSelectedRow(), true );
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::DoRowDrag( sal_Int16 nRowPos )
+{
+ implTransferSelectedRows( nRowPos, false );
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag )
+{
+ Reference< XPropertySet > xForm( getDataSource(), UNO_QUERY );
+ OSL_ENSURE( xForm.is(), "SbaGridControl::implTransferSelectedRows: invalid form!" );
+
+ // build the sequence of numbers of selected rows
+ Sequence< Any > aSelectedRows;
+ sal_Bool bSelectionBookmarks = sal_True;
+
+ // collect the affected rows
+ if ((GetSelectRowCount() == 0) && (nRowPos >= 0))
+ {
+ aSelectedRows.realloc( 1 );
+ aSelectedRows[0] <<= (sal_Int32)(nRowPos + 1);
+ bSelectionBookmarks = sal_False;
+ }
+ else if ( !IsAllSelected() && GetSelectRowCount() )
+ {
+ aSelectedRows = getSelectionBookmarks();
+ bSelectionBookmarks = sal_True;
+ }
+
+ Reference< XResultSet> xRowSetClone;
+ try
+ {
+ ODataClipboard* pTransfer = new ODataClipboard( xForm, aSelectedRows, bSelectionBookmarks, getServiceManager() );
+
+ Reference< XTransferable > xEnsureDelete = pTransfer;
+ if ( _bTrueIfClipboardFalseIfDrag )
+ pTransfer->CopyToClipboard( this );
+ else
+ pTransfer->StartDrag(this, DND_ACTION_COPY | DND_ACTION_LINK);
+ }
+ catch(Exception&)
+ {
+ }
+}
+
+// -----------------------------------------------------------------------
+void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos)
+{
+ // the only thing to do here is dragging the pure cell text
+ // the old implementation copied a SBA_FIELDDATAEXCHANGE_FORMAT, too, (which was rather expensive to obtain),
+ // but we have no client for this DnD format anymore (the mail part of SO 5.2 was the only client)
+
+ ::rtl::OUString sCellText;
+ try
+ {
+ Reference< XGridFieldDataSupplier > xFieldData(static_cast< XGridPeer* >(GetPeer()), UNO_QUERY);
+ Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(::getCppuType(&sCellText));
+ if (aSupportingText.getConstArray()[nColumnPos])
+ {
+ Sequence< Any> aCellContents = xFieldData->queryFieldData(nRowPos, ::getCppuType(&sCellText));
+ sCellText = ::comphelper::getString(aCellContents.getConstArray()[nColumnPos]);
+ ::svt::OStringTransfer::StartStringDrag(sCellText, this, DND_ACTION_COPY);
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaGridControl::DoFieldDrag : could not retrieve the cell's contents !");
+ return;
+ }
+
+}
+/// unary_function Functor object for class ZZ returntype is void
+ struct SbaGridControlPrec : ::std::unary_function<DataFlavorExVector::value_type,bool>
+ {
+ sal_Bool bQueryDrop;
+ SbaGridControlPrec(sal_Bool _bQueryDrop)
+ : bQueryDrop(_bQueryDrop)
+ {
+ }
+
+ inline bool operator()(const DataFlavorExVector::value_type& _aType)
+ {
+ switch (_aType.mnSotId)
+ {
+ case SOT_FORMATSTR_ID_DBACCESS_TABLE: // table descriptor
+ case SOT_FORMATSTR_ID_DBACCESS_QUERY: // query descriptor
+ case SOT_FORMATSTR_ID_DBACCESS_COMMAND: // SQL command
+ return true;
+ }
+ return false;
+ }
+ };
+//------------------------------------------------------------------------------
+sal_Int8 SbaGridControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
+{
+ sal_Int8 nAction = DND_ACTION_NONE;
+
+ // we need a valid connection
+ if (!::dbtools::getConnection(Reference< XRowSet > (getDataSource(),UNO_QUERY)).is())
+ return nAction;
+
+ if ( IsDropFormatSupported( FORMAT_STRING ) ) do
+ { // odd construction, but spares us a lot of (explicit ;) goto's
+
+ if (!GetEmptyRow().Is())
+ // without an empty row we're not in update mode
+ break;
+
+ long nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False);
+ sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), sal_False);
+
+ long nCorrectRowCount = GetRowCount();
+ if (GetOptions() & OPT_INSERT)
+ --nCorrectRowCount; // there is a empty row for inserting records
+ if (IsCurrentAppending())
+ --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one
+
+ if ((nCol == BROWSER_INVALIDID) || (nRow >= nCorrectRowCount) || GetColumnId(nCol) == 0 )
+ // no valid cell under the mouse cursor
+ break;
+
+ Rectangle aRect = GetCellRect(nRow, nCol, sal_False);
+ if (!aRect.IsInside(rEvt.maPosPixel))
+ // not dropped within a cell (a cell isn't as wide as the column - the are small spaces)
+ break;
+
+ if ((IsModified() || (GetCurrentRow().Is() && GetCurrentRow()->IsModified())) && (GetCurrentPos() != nRow))
+ // there is a current and modified row or cell and he text is to be dropped into another one
+ break;
+
+ CellControllerRef xCurrentController = Controller();
+ if (xCurrentController.Is() && xCurrentController->IsModified() && ((nRow != GetCurRow()) || (nCol != GetCurColumnId())))
+ // the current controller is modified and the user wants to drop in another cell -> no chance
+ // (when leaving the modified cell a error may occur - this is deadly while dragging)
+ break;
+
+ Reference< XPropertySet > xField = getField(GetModelColumnPos(nCol));
+ if (!xField.is())
+ // the column is not valid bound (for instance a binary field)
+ break;
+
+ try
+ {
+ if (::comphelper::getBOOL(xField->getPropertyValue(PROPERTY_ISREADONLY)))
+ break;
+ }
+ catch (const Exception& e )
+ {
+ (void)e; // make compiler happy
+ // assume RO
+ break;
+ }
+
+ try
+ {
+ // assume that text can be dropped into a field if the column has a ::com::sun::star::awt::XTextComponent interface
+ Reference< XIndexAccess > xColumnControls((::com::sun::star::form::XGridPeer*)GetPeer(), UNO_QUERY);
+ if (xColumnControls.is())
+ {
+ Reference< ::com::sun::star::awt::XTextComponent > xColControl;
+ ::cppu::extractInterface(xColControl,xColumnControls->getByIndex(GetViewColumnPos(nCol)));
+ if (xColControl.is())
+ {
+ m_bActivatingForDrop = sal_True;
+ GoToRowColumnId(nRow, nCol);
+ m_bActivatingForDrop = sal_False;
+
+ nAction = DND_ACTION_COPY;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ } while (sal_False);
+
+ if(nAction != DND_ACTION_COPY && GetEmptyRow().Is())
+ {
+ const DataFlavorExVector& _rFlavors = GetDataFlavors();
+ if(::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(sal_True)) != _rFlavors.end())
+ nAction = DND_ACTION_COPY;
+ }
+
+/*
+ // check formats
+ SvDataObjectRef xDataObj = SvDataObject::PasteDragServer( rEvt );
+ if (!xDataObj.Is())
+ return sal_False;
+
+ const SvDataTypeList& rTypeList = xDataObj->GetTypeList();
+ if ((rTypeList.Get(Exchange::RegisterFormatName(String::CreateFromAscii(SBA_DATAEXCHANGE_FORMAT)))) )
+ {
+ bAllow = (GetOptions() & OPT_INSERT) && rEvt.GetColumnId() > 0 && rEvt.GetRow() >= 0;
+ ((BrowserDropEvent&)rEvt).SetAction(DROP_COPY);
+ }
+
+*/
+ return (DND_ACTION_NONE != nAction) ? nAction : FmGridControl::AcceptDrop(rEvt);
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 SbaGridControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
+{
+ // we need some properties of our data source
+ Reference< XPropertySet > xDataSource = getDataSource();
+ if (!xDataSource.is())
+ return DND_ACTION_NONE;
+
+ // we need a valid connection
+ if (!::dbtools::getConnection(Reference< XRowSet > (xDataSource,UNO_QUERY)).is())
+ return DND_ACTION_NONE;
+
+ if ( IsDropFormatSupported( FORMAT_STRING ) )
+ {
+ long nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False);
+ sal_uInt16 nCol = GetColumnAtXPosPixel(rEvt.maPosPixel.X(), sal_False);
+
+ long nCorrectRowCount = GetRowCount();
+ if (GetOptions() & OPT_INSERT)
+ --nCorrectRowCount; // there is a empty row for inserting records
+ if (IsCurrentAppending())
+ --nCorrectRowCount; // the current data record doesn't really exist, we are appending a new one
+
+ OSL_ENSURE((nCol != BROWSER_INVALIDID) && (nRow < nCorrectRowCount), "SbaGridControl::Drop : dropped on an invalid position !");
+ // AcceptDrop should have caught this
+
+ // from now we work with ids instead of positions
+ nCol = GetColumnId(nCol);
+
+ GoToRowColumnId(nRow, nCol);
+ if (!IsEditing())
+ ActivateCell();
+
+ CellControllerRef xCurrentController = Controller();
+ if (!xCurrentController.Is() || !xCurrentController->ISA(EditCellController))
+ return DND_ACTION_NONE;
+ Edit& rEdit = (Edit&)xCurrentController->GetWindow();
+
+ // get the dropped string
+ TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
+ String sDropped;
+ if ( !aDropped.GetString( FORMAT_STRING, sDropped ) )
+ return DND_ACTION_NONE;
+
+ rEdit.SetText( sDropped );
+ xCurrentController->SetModified();
+ rEdit.Modify();
+ // SetText itself doesn't call a Modify as it isn't a user interaction
+
+ return DND_ACTION_COPY;
+ }
+
+ if(GetEmptyRow().Is())
+ {
+ const DataFlavorExVector& _rFlavors = GetDataFlavors();
+ DataFlavorExVector::const_iterator aFind = ::std::find_if(_rFlavors.begin(),_rFlavors.end(),SbaGridControlPrec(sal_True));
+ if( aFind != _rFlavors.end())
+ {
+ TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
+ m_aDataDescriptor = ODataAccessObjectTransferable::extractObjectDescriptor(aDropped);
+ if (m_nAsyncDropEvent)
+ Application::RemoveUserEvent(m_nAsyncDropEvent);
+ m_nAsyncDropEvent = Application::PostUserEvent(LINK(this, SbaGridControl, AsynchDropEvent));
+ return DND_ACTION_COPY;
+ }
+ }
+
+ return DND_ACTION_NONE;
+}
+
+//------------------------------------------------------------------------------
+Reference< XPropertySet > SbaGridControl::getDataSource() const
+{
+ Reference< XPropertySet > xReturn;
+
+ Reference< XChild > xColumns(GetPeer()->getColumns(), UNO_QUERY);
+ Reference< XPropertySet > xDataSource;
+ if (xColumns.is())
+ xReturn = Reference< XPropertySet > (xColumns->getParent(), UNO_QUERY);
+
+ return xReturn;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(SbaGridControl, AsynchDropEvent, void*, /*EMPTY_ARG*/)
+{
+ m_nAsyncDropEvent = 0;
+
+ Reference< XPropertySet > xDataSource = getDataSource();
+ if ( xDataSource.is() )
+ {
+ sal_Bool bCountFinal = sal_False;
+ xDataSource->getPropertyValue(PROPERTY_ISROWCOUNTFINAL) >>= bCountFinal;
+ if ( !bCountFinal )
+ setDataSource(NULL); // deattach from grid control
+ Reference< XResultSetUpdate > xResultSetUpdate(xDataSource,UNO_QUERY);
+ ODatabaseImportExport* pImExport = new ORowSetImportExport(this,xResultSetUpdate,m_aDataDescriptor,getServiceManager());
+ Reference<XEventListener> xHolder = pImExport;
+ Hide();
+ try
+ {
+ pImExport->initialize(m_aDataDescriptor);
+ BeforeDrop();
+ if(!pImExport->Read())
+ {
+ String sError = String(ModuleRes(STR_NO_COLUMNNAME_MATCHING));
+ throwGenericSQLException(sError,NULL);
+ }
+ AfterDrop();
+ Show();
+ }
+ catch(const SQLException& e)
+ {
+ AfterDrop();
+ Show();
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,getServiceManager());
+ }
+ catch(const Exception& )
+ {
+ AfterDrop();
+ Show();
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if ( !bCountFinal )
+ setDataSource(Reference< XRowSet >(xDataSource,UNO_QUERY));
+ }
+ m_aDataDescriptor.clear();
+
+ return 0L;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SbaGridControl::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const
+{
+ ::rtl::OUString sRet;
+ if ( ::svt::BBTYPE_BROWSEBOX == eObjType )
+ {
+ SolarMutexGuard aGuard;
+ sRet = String(ModuleRes(STR_DATASOURCE_GRIDCONTROL_DESC));
+ }
+ else
+ sRet = FmGridControl::GetAccessibleObjectDescription( eObjType,_nPosition);
+ return sRet;
+}
+// -----------------------------------------------------------------------------
+void SbaGridControl::DeleteSelectedRows()
+{
+ FmGridControl::DeleteSelectedRows();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/sbagrid.src b/dbaccess/source/ui/browser/sbagrid.src
new file mode 100644
index 000000000000..b3fd77757364
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbagrid.src
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_BRW_HRC_
+#include "dbu_brw.hrc"
+#endif
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+
+Menu RID_SBA_GRID_COLCTXMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_BROWSER_COLATTRSET ;
+ HelpID = HID_BROWSER_COLUMNFORMAT ;
+ Text [ en-US ] = "Column ~Format..." ;
+ };
+ MenuItem
+ {
+ MID_COLUMN_WIDTH
+ HelpID = HID_BROWSER_COLUMNWIDTH;
+ };
+ MenuItem
+ {
+ Identifier = ID_BROWSER_COLUMNINFO ;
+ HelpID = HID_BROWSER_COLUMNINFO ;
+ Text [ en-US ] = "Copy Column D~escription";
+ };
+ };
+};
+
+Menu RID_SBA_GRID_ROWCTXMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_BROWSER_TABLEATTR ;
+ HelpID = HID_BROWSER_TABLEFORMAT ;
+ Text [ en-US ] = "Table Format..." ;
+ };
+ MenuItem
+ {
+ Identifier = ID_BROWSER_ROWHEIGHT ;
+ HelpID = HID_BROWSER_ROWHEIGHT ;
+ Text [ en-US ] = "Row Height..." ;
+ };
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
+ };
+};
+
+String RID_STR_UNDO_MODIFY_RECORD
+{
+ Text [ en-US ] = "Undo: Data Input";
+};
+
+String RID_STR_SAVE_CURRENT_RECORD
+{
+ Text [ en-US ] = "Save current record";
+};
+
+String STR_QRY_TITLE
+{
+ Text [ en-US ] = "Query #" ;
+};
+
+String STR_TBL_TITLE
+{
+ Text [ en-US ] = "Table #" ;
+};
+
+String STR_VIEW_TITLE
+{
+ Text [ en-US ] = "View #" ;
+};
+
+String STR_NAME_ALREADY_EXISTS
+{
+ Text [ en-US ] = "The name \"#\" already exists.";
+};
+
+
+String STR_NO_COLUMNNAME_MATCHING
+{
+ Text [ en-US ] = "No matching column names were found.";
+};
+
+String STR_ERROR_OCCURRED_WHILE_COPYING
+{
+ Text [ en-US ] = "An error occurred. Do you want to continue copying?";
+};
+
+String STR_DATASOURCE_GRIDCONTROL_NAME
+{
+ Text [ en-US ] = "Data source table view";
+};
+
+String STR_DATASOURCE_GRIDCONTROL_DESC
+{
+ Text [ en-US ] = "Shows the selected table or query.";
+};
diff --git a/dbaccess/source/ui/browser/sbamultiplex.cxx b/dbaccess/source/ui/browser/sbamultiplex.cxx
new file mode 100644
index 000000000000..65733d7ae563
--- /dev/null
+++ b/dbaccess/source/ui/browser/sbamultiplex.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "sbamultiplex.hxx"
+using namespace dbaui;
+
+//==================================================================
+// the listener multiplexers
+//==================================================================
+
+// XStatusListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXStatusMultiplexer, ::com::sun::star::frame::XStatusListener)
+
+void SAL_CALL SbaXStatusMultiplexer::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& e) throw (::com::sun::star::uno::RuntimeException)
+{
+ m_aLastKnownStatus = e;
+ m_aLastKnownStatus.Source = &m_rParent;
+ ::cppu::OInterfaceIteratorHelper aIt( *this );
+ while ( aIt.hasMoreElements() )
+ static_cast< ::com::sun::star::frame::XStatusListener* >( aIt.next() )->statusChanged( m_aLastKnownStatus );
+} \
+
+// LoadListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, loaded, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, unloaded, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, unloading, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, reloading, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener, reloaded, ::com::sun::star::lang::EventObject)
+
+// ::com::sun::star::sdbc::XRowSetListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, cursorMoved, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, rowChanged, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener, rowSetChanged, ::com::sun::star::lang::EventObject)
+
+// ::com::sun::star::sdb::XRowSetApproveListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveCursorMove, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveRowChange, ::com::sun::star::sdb::RowChangeEvent)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener, approveRowSetChange, ::com::sun::star::lang::EventObject)
+
+// ::com::sun::star::sdb::XSQLErrorListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener, errorOccured, ::com::sun::star::sdb::SQLErrorEvent)
+
+// ::com::sun::star::form::XDatabaseParameterListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener, approveParameter, ::com::sun::star::form::DatabaseParameterEvent)
+
+// ::com::sun::star::form::XSubmitListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener, approveSubmit, ::com::sun::star::lang::EventObject)
+
+// ::com::sun::star::form::XResetListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener)
+IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener, approveReset, ::com::sun::star::lang::EventObject)
+IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener, resetted, ::com::sun::star::lang::EventObject)
+
+// ::com::sun::star::beans::XPropertyChangeListener
+IMPLEMENT_PROPERTY_MULTIPLEXER(SbaXPropertyChangeMultiplexer, ::com::sun::star::beans::XPropertyChangeListener, propertyChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::uno::RuntimeException))
+
+// ::com::sun::star::beans::XVetoableChangeListener
+IMPLEMENT_PROPERTY_MULTIPLEXER(SbaXVetoableChangeMultiplexer, ::com::sun::star::beans::XVetoableChangeListener, vetoableChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException))
+
+// ::com::sun::star::beans::XPropertiesChangeListener
+IMPLEMENT_LISTENER_MULTIPLEXER_CORE(SbaXPropertiesChangeMultiplexer, ::com::sun::star::beans::XPropertiesChangeListener);
+void SbaXPropertiesChangeMultiplexer::propertiesChange(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent>& aEvts) throw(::com::sun::star::uno::RuntimeException)
+{
+ // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply
+ // forwards _all_ changes to _all_ listeners
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent> aMulti(aEvts);
+ ::com::sun::star::beans::PropertyChangeEvent* pMulti = aMulti.getArray();
+ for (sal_uInt16 i=0; i<aMulti.getLength(); ++i, ++pMulti)
+ pMulti->Source = &m_rParent;
+
+ ::cppu::OInterfaceIteratorHelper aIt(*this);
+ while (aIt.hasMoreElements())
+ ((::com::sun::star::beans::XPropertiesChangeListener*)aIt.next())->propertiesChange(aMulti);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
new file mode 100644
index 000000000000..216afb3caf2c
--- /dev/null
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -0,0 +1,3914 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "browserids.hxx"
+#include "dbaccess_helpid.hrc"
+#include "dbexchange.hxx"
+#include "dbtreelistbox.hxx"
+#include "dbtreemodel.hxx"
+#include "dbtreeview.hxx"
+#include "dbu_brw.hrc"
+#include "dbu_reghelper.hxx"
+#include "dbustrings.hrc"
+#include "dlgsave.hxx"
+#include "HtmlReader.hxx"
+#include "imageprovider.hxx"
+#include "listviewitems.hxx"
+#include "QEnumTypes.hxx"
+#include "RtfReader.hxx"
+#include "sbagrid.hrc"
+#include "sbagrid.hxx"
+#include "sqlmessage.hxx"
+#include "TokenWriter.hxx"
+#include "UITools.hxx"
+#include "unodatbr.hxx"
+#include "WColumnSelect.hxx"
+#include "WCopyTable.hxx"
+#include "WCPage.hxx"
+#include "WExtendPages.hxx"
+#include "WNameMatch.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/MouseWheelBehavior.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XBookmarksSupplier.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdb/XParametersSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/ui/XContextMenuInterceptor.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sot/storage.hxx>
+#include <svl/filenotation.hxx>
+#include <svl/intitem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svtools/svlbitm.hxx>
+#include <svtools/svtreebx.hxx>
+#include <svx/algitem.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <svx/databaseregistrationui.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <tools/multisel.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/confignode.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/split.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <vcl/wrkwin.hxx>
+#include <rtl/logfile.hxx>
+
+#include <memory>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdb::application;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::ui;
+using namespace ::dbtools;
+using namespace ::comphelper;
+using namespace ::svx;
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+
+//==================================================================
+//= SbaTableQueryBrowser
+//==================================================================
+// -------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_OBrowser()
+{
+ static OMultiInstanceAutoRegistration< SbaTableQueryBrowser > aAutoRegistration;
+}
+// -------------------------------------------------------------------------
+void SafeAddPropertyListener(const Reference< XPropertySet > & xSet, const ::rtl::OUString& rPropName, XPropertyChangeListener* pListener)
+{
+ Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
+ if (xInfo->hasPropertyByName(rPropName))
+ xSet->addPropertyChangeListener(rPropName, pListener);
+}
+
+// -------------------------------------------------------------------------
+void SafeRemovePropertyListener(const Reference< XPropertySet > & xSet, const ::rtl::OUString& rPropName, XPropertyChangeListener* pListener)
+{
+ Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
+ if (xInfo->hasPropertyByName(rPropName))
+ xSet->removePropertyChangeListener(rPropName, pListener);
+}
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SbaTableQueryBrowser::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL SbaTableQueryBrowser::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SbaTableQueryBrowser::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODatasourceBrowser"));
+}
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SbaTableQueryBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceBrowser"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL SbaTableQueryBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ SolarMutexGuard aGuard;
+ return *(new SbaTableQueryBrowser(_rxFactory));
+}
+
+DBG_NAME(SbaTableQueryBrowser);
+//------------------------------------------------------------------------------
+SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory >& _rM)
+ :SbaXDataBrowserController(_rM)
+ ,m_aSelectionListeners( getMutex() )
+ ,m_aContextMenuInterceptors( getMutex() )
+ ,m_aTableCopyHelper(this)
+ ,m_pTreeView(NULL)
+ ,m_pSplitter(NULL)
+ ,m_pTreeModel(NULL)
+ ,m_pCurrentlyDisplayed(NULL)
+ ,m_nAsyncDrop(0)
+ ,m_nBorder(1)
+ ,m_bQueryEscapeProcessing( sal_False )
+ ,m_bShowMenu(sal_False)
+ ,m_bInSuspend(sal_False)
+ ,m_bEnableBrowser(sal_True)
+{
+ DBG_CTOR(SbaTableQueryBrowser,NULL);
+}
+
+//------------------------------------------------------------------------------
+SbaTableQueryBrowser::~SbaTableQueryBrowser()
+{
+ DBG_DTOR(SbaTableQueryBrowser,NULL);
+ if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
+ {
+ OSL_FAIL("Please check who doesn't dispose this component!");
+ // increment ref count to prevent double call of Dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL SbaTableQueryBrowser::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ if ( _rType.equals( XScriptInvocationContext::static_type() ) )
+ {
+ OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::queryInterface: did not initialize this, yet!" );
+ if ( !!m_aDocScriptSupport && *m_aDocScriptSupport )
+ return makeAny( Reference< XScriptInvocationContext >( this ) );
+ return Any();
+ }
+
+ Any aReturn = SbaXDataBrowserController::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = SbaTableQueryBrowser_Base::queryInterface(_rType);
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL SbaTableQueryBrowser::getTypes( ) throw (RuntimeException)
+{
+ Sequence< Type > aTypes( ::comphelper::concatSequences(
+ SbaXDataBrowserController::getTypes(),
+ SbaTableQueryBrowser_Base::getTypes()
+ ) );
+
+ OSL_PRECOND( !!m_aDocScriptSupport, "SbaTableQueryBrowser::getTypes: did not initialize this, yet!" );
+ if ( !m_aDocScriptSupport || !*m_aDocScriptSupport )
+ {
+ Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ aStrippedTypes.getArray(),
+ ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
+ );
+ aTypes = aStrippedTypes;
+ }
+ return aTypes;
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL SbaTableQueryBrowser::getImplementationId( ) throw (RuntimeException)
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::disposing()
+{
+ SolarMutexGuard aGuard;
+ // doin' a lot of VCL stuff here -> lock the SolarMutex
+
+ // kiss our listeners goodbye
+ EventObject aEvt(*this);
+ m_aSelectionListeners.disposeAndClear(aEvt);
+ m_aContextMenuInterceptors.disposeAndClear(aEvt);
+
+ // reset the content's tree view: it holds a reference to our model which is to be deleted immediately,
+ // and it will live longer than we do.
+ if (getBrowserView())
+ getBrowserView()->setTreeView(NULL);
+
+ clearTreeModel();
+ // clear the tree model
+ {
+ ::std::auto_ptr<SvLBoxTreeList> aTemp(m_pTreeModel);
+ m_pTreeModel = NULL;
+ }
+
+ // remove ourself as status listener
+ implRemoveStatusListeners();
+
+ // remove the container listener from the database context
+ try
+ {
+ Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW );
+ xDatabaseRegistrations->removeDatabaseRegistrationsListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // check out from all the objects we are listening
+ // the frame
+ if (m_xCurrentFrameParent.is())
+ m_xCurrentFrameParent->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this);
+ SbaXDataBrowserController::disposing();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::Construct(Window* pParent)
+{
+ if ( !SbaXDataBrowserController::Construct( pParent ) )
+ return sal_False;
+
+ try
+ {
+ Reference< XDatabaseRegistrations > xDatabaseRegistrations( m_xDatabaseContext, UNO_QUERY_THROW );
+ xDatabaseRegistrations->addDatabaseRegistrationsListener( this );
+
+ // the collator for the string compares
+ m_xCollator = Reference< XCollator >( getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.Collator")) ), UNO_QUERY_THROW );
+ m_xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 );
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::Construct: could not create (or start listening at) the database context!");
+ }
+ // some help ids
+ if (getBrowserView() && getBrowserView()->getVclControl())
+ {
+
+ // create controls and set sizes
+ const long nFrameWidth = getBrowserView()->LogicToPixel( ::Size( 3, 0 ), MAP_APPFONT ).Width();
+
+ m_pSplitter = new Splitter(getBrowserView(),WB_HSCROLL);
+ m_pSplitter->SetPosSizePixel( ::Point(0,0), ::Size(nFrameWidth,0) );
+ m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
+
+ m_pTreeView = new DBTreeView(getBrowserView(),getORB(), WB_TABSTOP | WB_BORDER);
+ m_pTreeView->SetPreExpandHandler(LINK(this, SbaTableQueryBrowser, OnExpandEntry));
+
+ m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry));
+
+ m_pTreeView->getListBox().setContextMenuProvider( this );
+ m_pTreeView->getListBox().setControlActionListener( this );
+ m_pTreeView->SetHelpId(HID_CTL_TREEVIEW);
+
+ // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
+ m_pSplitter->SetSplitPosPixel( getBrowserView()->LogicToPixel( ::Size( 80, 0 ), MAP_APPFONT ).Width() );
+
+ getBrowserView()->setSplitter(m_pSplitter);
+ getBrowserView()->setTreeView(m_pTreeView);
+
+ // fill view with data
+ m_pTreeModel = new SvLBoxTreeList;
+ m_pTreeModel->SetSortMode(SortAscending);
+ m_pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare));
+ m_pTreeView->setModel(m_pTreeModel);
+ m_pTreeView->setSelChangeHdl( LINK( this, SbaTableQueryBrowser, OnSelectionChange ) );
+
+ // TODO
+ getBrowserView()->getVclControl()->GetDataWindow().SetUniqueId(UID_DATABROWSE_DATAWINDOW);
+ getBrowserView()->getVclControl()->SetHelpId(HID_CTL_TABBROWSER);
+ getBrowserView()->SetUniqueId(UID_CTL_CONTENT);
+ if (getBrowserView()->getVclControl()->GetHeaderBar())
+ getBrowserView()->getVclControl()->GetHeaderBar()->SetHelpId(HID_DATABROWSE_HEADER);
+ InvalidateFeature(ID_BROWSER_EXPLORER);
+ }
+
+ return sal_True;
+}
+// ---------------------------------------------------------------------------------------------------------------------
+namespace
+{
+ // -----------------------------------------------------------------------------------------------------------------
+ struct SelectValueByName : public ::std::unary_function< ::rtl::OUString, Any >
+ {
+ const Any& operator()( ::rtl::OUString const& i_name ) const
+ {
+ return m_rCollection.get( i_name );
+ }
+
+ SelectValueByName( ::comphelper::NamedValueCollection const& i_collection )
+ :m_rCollection( i_collection )
+ {
+ }
+
+ ::comphelper::NamedValueCollection const& m_rCollection;
+ };
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow()
+{
+ try
+ {
+ Reference< XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
+ sal_Bool bEscapeProcessing = sal_False;
+ OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+ if ( !bEscapeProcessing )
+ // don't touch or interpret anything if escape processing is disabled
+ return;
+
+ Reference< XSingleSelectQueryComposer > xComposer( createParser_nothrow() );
+ if ( !xComposer.is() )
+ // can't do anything. Already reported via assertion in createParser_nothrow.
+ return;
+
+ // the tables participating in the statement
+ const Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY_THROW );
+ const Reference< XNameAccess > xTableNames( xSuppTables->getTables(), UNO_QUERY_THROW );
+
+ // the columns participating in the statement
+ const Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY_THROW );
+ const Reference< XNameAccess > xColumnNames( xSuppColumns->getColumns(), UNO_QUERY_THROW );
+
+ // .............................................................................................................
+ // check if the order columns apply to tables which really exist in the statement
+ const Reference< XIndexAccess > xOrderColumns( xComposer->getOrderColumns(), UNO_SET_THROW );
+ const sal_Int32 nOrderColumns( xOrderColumns->getCount() );
+ bool invalidColumn = false;
+ for ( sal_Int32 c=0; ( c < nOrderColumns ) && !invalidColumn; ++c )
+ {
+ const Reference< XPropertySet > xOrderColumn( xOrderColumns->getByIndex(c), UNO_QUERY_THROW );
+ ::rtl::OUString sTableName;
+ OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName );
+ ::rtl::OUString sColumnName;
+ OSL_VERIFY( xOrderColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName );
+
+ if ( sTableName.getLength() == 0 )
+ {
+ if ( !xColumnNames->hasByName( sColumnName ) )
+ {
+ invalidColumn = true;
+ break;
+ }
+ }
+ else
+ {
+ if ( !xTableNames->hasByName( sTableName ) )
+ {
+ invalidColumn = true;
+ break;
+ }
+
+ const Reference< XColumnsSupplier > xSuppTableColumns( xTableNames->getByName( sTableName ), UNO_QUERY_THROW );
+ const Reference< XNameAccess > xTableColumnNames( xSuppTableColumns->getColumns(), UNO_QUERY_THROW );
+ if ( !xTableColumnNames->hasByName( sColumnName ) )
+ {
+ invalidColumn = true;
+ break;
+ }
+ }
+ }
+
+ if ( invalidColumn )
+ {
+ // reset the complete order statement at both the row set and the parser
+ const ::rtl::OUString sEmptyOrder;
+ xRowSetProps->setPropertyValue( PROPERTY_ORDER, makeAny( sEmptyOrder ) );
+ xComposer->setOrder( sEmptyOrder );
+ }
+
+ // .............................................................................................................
+ // check if the columns participating in the filter refer to existing tables
+ // TODO: there's no API at all for this. The method which comes nearest to what we need is
+ // "getStructuredFilter", but it returns pure column names only. That is, for a statement like
+ // "SELECT * FROM <table> WHERE <other_table>.<column> = <value>", it will return "<column>". But
+ // there's no API at all to retrieve the information about "<other_table>" - which is what would
+ // be needed here.
+ // That'd be a chance to replace getStructuredFilter with something more reasonable. This method
+ // has at least one other problem: For a clause like "<column> != <value>", it will return "<column>"
+ // as column name, "NOT_EQUAL" as operator, and "!= <value>" as value, effectively duplicating the
+ // information about the operator, and beding all clients to manually remove the "!=" from the value
+ // string.
+ // So, what really would be handy, is some
+ // XNormalizedFilter getNormalizedFilter();
+ // with
+ // interface XDisjunctiveFilterExpression
+ // {
+ // XConjunctiveFilterTerm getTerm( int index );
+ // }
+ // interface XConjunctiveFilterTerm
+ // {
+ // ComparisonPredicate getPredicate( int index );
+ // }
+ // struct ComparisonPredicate
+ // {
+ // XComparisonOperand Lhs;
+ // SQLFilterOperator Operator;
+ // XComparisonOperand Rhs;
+ // }
+ // interface XComparisonOperand
+ // {
+ // SQLFilterOperand Type;
+ // XPropertySet getColumn();
+ // string getLiteral();
+ // ...
+ // }
+ // enum SQLFilterOperand { Column, Literal, ... }
+ //
+ // ... or something like this ....
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::InitializeForm( const Reference< XPropertySet > & i_formProperties )
+{
+ if(!m_pCurrentlyDisplayed)
+ return sal_True;
+
+ // this method set all format settings from the orignal table or query
+ try
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ ENSURE_OR_RETURN_FALSE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" );
+ ENSURE_OR_RETURN_FALSE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" );
+
+ Reference< XPropertySetInfo > xPSI( pData->xObjectProperties->getPropertySetInfo(), UNO_SET_THROW );
+
+ ::comphelper::NamedValueCollection aPropertyValues;
+
+ const ::rtl::OUString aTransferProperties[] =
+ {
+ PROPERTY_APPLYFILTER,
+ PROPERTY_FILTER,
+ PROPERTY_HAVING_CLAUSE,
+ PROPERTY_ORDER
+ };
+ for ( size_t i=0; i < sizeof( aTransferProperties ) / sizeof( aTransferProperties[0] ); ++i )
+ {
+ if ( !xPSI->hasPropertyByName( aTransferProperties[i] ) )
+ continue;
+ aPropertyValues.put( aTransferProperties[i], pData->xObjectProperties->getPropertyValue( aTransferProperties[i] ) );
+ }
+
+ const ::std::vector< ::rtl::OUString > aNames( aPropertyValues.getNames() );
+ Sequence< ::rtl::OUString > aPropNames( aNames.size() );
+ ::std::copy( aNames.begin(), aNames.end(), aPropNames.getArray() );
+
+ Sequence< Any > aPropValues( aNames.size() );
+ ::std::transform( aNames.begin(), aNames.end(), aPropValues.getArray(), SelectValueByName( aPropertyValues ) );
+
+ Reference< XMultiPropertySet > xFormMultiSet( i_formProperties, UNO_QUERY_THROW );
+ xFormMultiSet->setPropertyValues( aPropNames, aPropValues );
+
+ impl_sanitizeRowSetClauses_nothrow();
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::initializePreviewMode()
+{
+ if ( getBrowserView() && getBrowserView()->getVclControl() )
+ {
+ getBrowserView()->getVclControl()->AlwaysEnableInput( sal_False );
+ getBrowserView()->getVclControl()->EnableInput( sal_False );
+ getBrowserView()->getVclControl()->ForceHideScrollbars( sal_True );
+ }
+ Reference< XPropertySet > xDataSourceSet(getRowSet(), UNO_QUERY);
+ if ( xDataSourceSet.is() )
+ {
+ xDataSourceSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowInserts")),makeAny(sal_False));
+ xDataSourceSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowUpdates")),makeAny(sal_False));
+ xDataSourceSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AllowDeletes")),makeAny(sal_False));
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::InitializeGridModel(const Reference< ::com::sun::star::form::XFormComponent > & xGrid)
+{
+ try
+ {
+ Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(xGrid, UNO_QUERY);
+ Reference< XNameContainer > xColContainer(xGrid, UNO_QUERY);
+ clearGridColumns( xColContainer );
+
+ Reference< XChild > xGridAsChild(xGrid, UNO_QUERY);
+ Reference< XLoadable > xFormAsLoadable;
+ if (xGridAsChild.is())
+ xFormAsLoadable = xFormAsLoadable.query(xGridAsChild->getParent());
+ if (xFormAsLoadable.is() && xFormAsLoadable->isLoaded())
+ {
+ // set the formats from the table
+ if(m_pCurrentlyDisplayed)
+ {
+ Sequence< ::rtl::OUString> aProperties(6 + ( m_bPreview ? 5 : 0 ));
+ Sequence< Any> aValues(7 + ( m_bPreview ? 5 : 0 ));
+
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" );
+ if ( !pData->xObjectProperties.is() )
+ return sal_False;
+
+ ::rtl::OUString* pStringIter = aProperties.getArray();
+ Any* pValueIter = aValues.getArray();
+ if ( m_bPreview )
+ {
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor"));
+ *pValueIter++ <<= sal_False;
+ *pStringIter++ = PROPERTY_BORDER;
+ *pValueIter++ <<= sal_Int16(0);
+ }
+
+ *pStringIter++ = PROPERTY_FONT;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_FONT);
+ *pStringIter++ = PROPERTY_TEXTEMPHASIS;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_TEXTEMPHASIS);
+ *pStringIter++ = PROPERTY_TEXTRELIEF;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_TEXTRELIEF);
+ if ( m_bPreview )
+ {
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasNavigationBar"));
+ *pValueIter++ <<= sal_False;
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasRecordMarker"));
+ *pValueIter++ <<= sal_False;
+ }
+ *pStringIter++ = PROPERTY_ROW_HEIGHT;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_ROW_HEIGHT);
+ if ( m_bPreview )
+ {
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tabstop"));
+ *pValueIter++ <<= sal_False;
+ }
+ *pStringIter++ = PROPERTY_TEXTCOLOR;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_TEXTCOLOR);
+ *pStringIter++ = PROPERTY_TEXTLINECOLOR;
+ *pValueIter++ = pData->xObjectProperties->getPropertyValue(PROPERTY_TEXTLINECOLOR);
+
+ Reference< XMultiPropertySet > xFormMultiSet(xGrid, UNO_QUERY);
+ xFormMultiSet->setPropertyValues(aProperties, aValues);
+ }
+
+
+ // get the formats supplier of the database we're working with
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = getNumberFormatter()->getNumberFormatsSupplier();
+
+ Reference<XConnection> xConnection;
+ Reference<XPropertySet> xRowSetProps(getRowSet(),UNO_QUERY);
+ xRowSetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
+ OSL_ENSURE(xConnection.is(),"A ActiveConnection should normaly exists!");
+
+ Reference<XChild> xChild(xConnection,UNO_QUERY);
+ Reference<XPropertySet> xDataSourceProp(xChild->getParent(),UNO_QUERY);
+ sal_Bool bSuppressVersionCol = sal_False;
+ OSL_VERIFY( xDataSourceProp->getPropertyValue( PROPERTY_SUPPRESSVERSIONCL ) >>= bSuppressVersionCol );
+
+ // insert the column into the gridcontrol so that we see something :-)
+ ::rtl::OUString aCurrentModelType;
+ Reference<XColumnsSupplier> xSupCols(getRowSet(),UNO_QUERY);
+ Reference<XNameAccess> xColumns = xSupCols->getColumns();
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+
+ ::rtl::OUString sDefaultProperty;
+ Reference< XPropertySet > xColumn;
+ Reference< XPropertySetInfo > xColPSI;
+ for (sal_uInt16 i=0; pIter != pEnd; ++i,++pIter)
+ {
+ xColumn.set( xColumns->getByName( *pIter ), UNO_QUERY_THROW );
+ xColPSI.set( xColumn->getPropertySetInfo(), UNO_SET_THROW );
+
+ // ignore the column when it is a rowversion one
+ if ( bSuppressVersionCol
+ && xColPSI->hasPropertyByName( PROPERTY_ISROWVERSION )
+ && ::cppu::any2bool( xColumn->getPropertyValue( PROPERTY_ISROWVERSION ) )
+ )
+ continue;
+
+ // use the result set column's type to determine the type of grid column to create
+ sal_Bool bFormattedIsNumeric = sal_True;
+ sal_Int32 nType = ::comphelper::getINT32( xColumn->getPropertyValue( PROPERTY_TYPE ) );
+
+ ::std::vector< NamedValue > aInitialValues;
+ ::std::vector< ::rtl::OUString > aCopyProperties;
+ Any aDefault;
+
+ switch(nType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ {
+ aCurrentModelType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CheckBox"));
+ aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualEffect" ) ), makeAny( VisualEffect::FLAT ) ) );
+ sDefaultProperty = PROPERTY_DEFAULTSTATE;
+
+ sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISNULLABLE ) >>= nNullable );
+ aInitialValues.push_back( NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TriState" ) ),
+ makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) )
+ ) );
+ if ( ColumnValue::NO_NULLS == nNullable )
+ aDefault <<= (sal_Int16)STATE_NOCHECK;
+ }
+ break;
+
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ aInitialValues.push_back( NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) ), makeAny( (sal_Bool)sal_True ) ) );
+ // NO break!
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ aCurrentModelType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TextField"));
+ sDefaultProperty = PROPERTY_DEFAULTTEXT;
+ break;
+
+ case DataType::VARCHAR:
+ case DataType::CHAR:
+ bFormattedIsNumeric = sal_False;
+ // NO break!
+ default:
+ aCurrentModelType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormattedField"));
+ sDefaultProperty = PROPERTY_EFFECTIVEDEFAULT;
+
+ if ( xSupplier.is() )
+ aInitialValues.push_back( NamedValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormatsSupplier")), makeAny( xSupplier ) ) );
+ aInitialValues.push_back( NamedValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TreatAsNumber")), makeAny( (sal_Bool)bFormattedIsNumeric ) ) );
+ aCopyProperties.push_back( PROPERTY_FORMATKEY );
+ break;
+ }
+
+ aInitialValues.push_back( NamedValue( PROPERTY_CONTROLSOURCE, makeAny( *pIter ) ) );
+ ::rtl::OUString sLabel;
+ xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
+ if ( sLabel.getLength() )
+ aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( sLabel ) ) );
+ else
+ aInitialValues.push_back( NamedValue( PROPERTY_LABEL, makeAny( *pIter ) ) );
+
+ Reference< XPropertySet > xGridCol( xColFactory->createColumn( aCurrentModelType ), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xGridColPSI( xGridCol->getPropertySetInfo(), UNO_SET_THROW );
+
+ // calculate the default
+ if ( xGridColPSI->hasPropertyByName( PROPERTY_CONTROLDEFAULT ) )
+ {
+ aDefault = xColumn->getPropertyValue( PROPERTY_CONTROLDEFAULT );
+ // default value
+ if ( nType == DataType::BIT || nType == DataType::BOOLEAN )
+ {
+ if ( aDefault.hasValue() )
+ aDefault <<= (comphelper::getString(aDefault).toInt32() == 0) ? (sal_Int16)STATE_NOCHECK : (sal_Int16)STATE_CHECK;
+ else
+ aDefault <<= ((sal_Int16)STATE_DONTKNOW);
+ }
+ }
+
+ if ( aDefault.hasValue() )
+ aInitialValues.push_back( NamedValue( sDefaultProperty, aDefault ) );
+
+ // transfer properties from the definition to the UNO-model :
+ aCopyProperties.push_back( PROPERTY_HIDDEN );
+ aCopyProperties.push_back( PROPERTY_WIDTH );
+
+ // help text to display for the column
+ Any aDescription;
+ if ( xColPSI->hasPropertyByName( PROPERTY_HELPTEXT ) )
+ aDescription = xColumn->getPropertyValue( PROPERTY_HELPTEXT );
+ ::rtl::OUString sTemp;
+ aDescription >>= sTemp;
+ if ( !sTemp.getLength() )
+ xColumn->getPropertyValue( PROPERTY_DESCRIPTION ) >>= sTemp;
+
+ aDescription <<= sTemp;
+ aInitialValues.push_back( NamedValue( PROPERTY_HELPTEXT, aDescription ) );
+
+ // ... horizontal justify
+ Any aAlign; aAlign <<= sal_Int16( 0 );
+ Any aColAlign( xColumn->getPropertyValue( PROPERTY_ALIGN ) );
+ if ( aColAlign.hasValue() )
+ aAlign <<= sal_Int16( ::comphelper::getINT32( aColAlign ) );
+ aInitialValues.push_back( NamedValue( PROPERTY_ALIGN, aAlign ) );
+
+ // don't allow the mouse to scroll in the cells
+ if ( xGridColPSI->hasPropertyByName( PROPERTY_MOUSE_WHEEL_BEHAVIOR ) )
+ aInitialValues.push_back( NamedValue( PROPERTY_MOUSE_WHEEL_BEHAVIOR, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ) );
+
+ // now set all those values
+ for ( ::std::vector< NamedValue >::const_iterator property = aInitialValues.begin();
+ property != aInitialValues.end();
+ ++property
+ )
+ {
+ xGridCol->setPropertyValue( property->Name, property->Value );
+ }
+ for ( ::std::vector< ::rtl::OUString >::const_iterator copyPropertyName = aCopyProperties.begin();
+ copyPropertyName != aCopyProperties.end();
+ ++copyPropertyName
+ )
+ xGridCol->setPropertyValue( *copyPropertyName, xColumn->getPropertyValue( *copyPropertyName ) );
+
+ xColContainer->insertByName(*pIter, makeAny(xGridCol));
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Reference<XPropertySet> getColumnHelper(SvLBoxEntry* _pCurrentlyDisplayed,const Reference<XPropertySet>& _rxSource)
+{
+ Reference<XPropertySet> xRet;
+ if(_pCurrentlyDisplayed)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pCurrentlyDisplayed->GetUserData());
+ Reference<XColumnsSupplier> xColumnsSup(pData->xObjectProperties,UNO_QUERY);
+ Reference<XNameAccess> xNames = xColumnsSup->getColumns();
+ ::rtl::OUString aName;
+ _rxSource->getPropertyValue(PROPERTY_NAME) >>= aName;
+ if(xNames.is() && xNames->hasByName(aName))
+ xRet.set(xNames->getByName(aName),UNO_QUERY);
+ }
+ return xRet;
+}
+
+// -----------------------------------------------------------------------
+void SbaTableQueryBrowser::transferChangedControlProperty(const ::rtl::OUString& _rProperty, const Any& _rNewValue)
+{
+ if(m_pCurrentlyDisplayed)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ Reference< XPropertySet > xObjectProps(pData->xObjectProperties, UNO_QUERY);
+ OSL_ENSURE(xObjectProps.is(),"SbaTableQueryBrowser::transferChangedControlProperty: no table/query object!");
+ if (xObjectProps.is())
+ xObjectProps->setPropertyValue(_rProperty, _rNewValue);
+ }
+}
+
+// -----------------------------------------------------------------------
+void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ SbaXDataBrowserController::propertyChange(evt);
+
+ try
+ {
+ Reference< XPropertySet > xSource(evt.Source, UNO_QUERY);
+ if (!xSource.is())
+ return;
+
+ // one of the many properties which require us to update the definition ?
+ // a column's width ?
+ else if (evt.PropertyName.equals(PROPERTY_WIDTH))
+ { // a column width has changed -> update the model
+ // (the update of the view is done elsewhere)
+ Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ if(xProp.is())
+ {
+ if(!evt.NewValue.hasValue())
+ xProp->setPropertyValue(PROPERTY_WIDTH,makeAny((sal_Int32)227));
+ else
+ xProp->setPropertyValue(PROPERTY_WIDTH,evt.NewValue);
+ }
+ }
+
+ // a column's 'visible' state ?
+ else if (evt.PropertyName.equals(PROPERTY_HIDDEN))
+ {
+ Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ if(xProp.is())
+ xProp->setPropertyValue(PROPERTY_HIDDEN,evt.NewValue);
+ }
+
+ // a columns alignment ?
+ else if (evt.PropertyName.equals(PROPERTY_ALIGN))
+ {
+ Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ try
+ {
+ if(xProp.is())
+ {
+ if(evt.NewValue.hasValue())
+ {
+ sal_Int16 nAlign = 0;
+ if(evt.NewValue >>= nAlign)
+ xProp->setPropertyValue(PROPERTY_ALIGN,makeAny(sal_Int32(nAlign)));
+ else
+ xProp->setPropertyValue(PROPERTY_ALIGN,evt.NewValue);
+ }
+ else
+ xProp->setPropertyValue(PROPERTY_ALIGN,makeAny(::com::sun::star::awt::TextAlign::LEFT));
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // a column's format ?
+ else if ( (evt.PropertyName.equals(PROPERTY_FORMATKEY))
+ && (TypeClass_LONG == evt.NewValue.getValueTypeClass())
+ )
+ {
+ // update the model (means the definition object)
+ Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ if(xProp.is())
+ xProp->setPropertyValue(PROPERTY_FORMATKEY,evt.NewValue);
+ }
+
+ // some table definition properties ?
+ // the height of the rows in the grid ?
+ else if (evt.PropertyName.equals(PROPERTY_ROW_HEIGHT))
+ {
+ if(m_pCurrentlyDisplayed)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ OSL_ENSURE( pData->xObjectProperties.is(), "No table available!" );
+
+ sal_Bool bDefault = !evt.NewValue.hasValue();
+ if (bDefault)
+ pData->xObjectProperties->setPropertyValue(PROPERTY_ROW_HEIGHT,makeAny((sal_Int32)45));
+ else
+ pData->xObjectProperties->setPropertyValue(PROPERTY_ROW_HEIGHT,evt.NewValue);
+ }
+ }
+
+ else if ( evt.PropertyName.equals(PROPERTY_FONT) // the font ?
+ || evt.PropertyName.equals(PROPERTY_TEXTCOLOR) // the text color ?
+ || evt.PropertyName.equals(PROPERTY_FILTER) // the filter ?
+ || evt.PropertyName.equals(PROPERTY_HAVING_CLAUSE) // the having clause ?
+ || evt.PropertyName.equals(PROPERTY_ORDER) // the sort ?
+ || evt.PropertyName.equals(PROPERTY_APPLYFILTER) // the appliance of the filter ?
+ || evt.PropertyName.equals(PROPERTY_TEXTLINECOLOR) // the text line color ?
+ || evt.PropertyName.equals(PROPERTY_TEXTEMPHASIS) // the text emphasis ?
+ || evt.PropertyName.equals(PROPERTY_TEXTRELIEF) // the text relief ?
+ )
+ {
+ transferChangedControlProperty(evt.PropertyName, evt.NewValue);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::suspend(sal_Bool bSuspend) throw( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( getView() && getView()->IsInModalMode() )
+ return sal_False;
+ sal_Bool bRet = sal_False;
+ if ( !m_bInSuspend )
+ {
+ m_bInSuspend = sal_True;
+ if ( rBHelper.bDisposed )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ bRet = SbaXDataBrowserController::suspend(bSuspend);
+ if ( bRet && getView() )
+ getView()->Hide();
+
+ m_bInSuspend = sal_False;
+ }
+
+ return bRet;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEvent ) throw(RuntimeException)
+{
+ // search the external dispatcher causing this call
+ Reference< XDispatch > xSource(_rEvent.Source, UNO_QUERY);
+ ExternalFeaturesMap::iterator aLoop;
+ for ( aLoop = m_aExternalFeatures.begin();
+ aLoop != m_aExternalFeatures.end();
+ ++aLoop
+ )
+ {
+ if ( _rEvent.FeatureURL.Complete == aLoop->second.aURL.Complete)
+ {
+ OSL_ENSURE( xSource.get() == aLoop->second.xDispatcher.get(), "SbaTableQueryBrowser::statusChanged: inconsistent!" );
+ // update the enabled state
+ aLoop->second.bEnabled = _rEvent.IsEnabled;
+
+ switch ( aLoop->first )
+ {
+ case ID_BROWSER_DOCUMENT_DATASOURCE:
+ {
+ // if it's the slot for the document data source, remember the state
+ Sequence< PropertyValue > aDescriptor;
+ #if OSL_DEBUG_LEVEL > 0
+ sal_Bool bProperFormat =
+ #endif
+ _rEvent.State >>= aDescriptor;
+ OSL_ENSURE(bProperFormat, "SbaTableQueryBrowser::statusChanged: need a data access descriptor here!");
+ m_aDocumentDataSource.initializeFrom(aDescriptor);
+
+ OSL_ENSURE( ( m_aDocumentDataSource.has(daDataSource)
+ || m_aDocumentDataSource.has(daDatabaseLocation)
+ )
+ && m_aDocumentDataSource.has(daCommand)
+ && m_aDocumentDataSource.has(daCommandType),
+ "SbaTableQueryBrowser::statusChanged: incomplete descriptor!");
+
+ // check if we know the object which is set as document data source
+ checkDocumentDataSource();
+ }
+ break;
+
+ default:
+ // update the toolbox
+ implCheckExternalSlot( aLoop->first );
+ break;
+ }
+ break;
+ }
+ }
+
+ OSL_ENSURE(aLoop != m_aExternalFeatures.end(), "SbaTableQueryBrowser::statusChanged: don't know who sent this!");
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::checkDocumentDataSource()
+{
+ SvLBoxEntry* pDataSourceEntry = NULL;
+ SvLBoxEntry* pContainerEntry = NULL;
+ SvLBoxEntry* pObjectEntry = getObjectEntry( m_aDocumentDataSource, &pDataSourceEntry, &pContainerEntry, sal_False );
+ sal_Bool bKnownDocDataSource = (NULL != pObjectEntry);
+ if (!bKnownDocDataSource)
+ {
+ if (NULL != pDataSourceEntry)
+ { // at least the data source is known
+ if (NULL != pContainerEntry)
+ bKnownDocDataSource = sal_True; // assume we know it.
+ // TODO: should we expand the object container? This may be too expensive just for checking ....
+ else
+ {
+ if ((NULL == pObjectEntry) && m_aDocumentDataSource.has(daCommandType) && m_aDocumentDataSource.has(daCommand))
+ { // maybe we have a command to be displayed ?
+ sal_Int32 nCommandType = CommandType::TABLE;
+ m_aDocumentDataSource[daCommandType] >>= nCommandType;
+
+ ::rtl::OUString sCommand;
+ m_aDocumentDataSource[daCommand] >>= sCommand;
+
+ bKnownDocDataSource = (CommandType::COMMAND == nCommandType) && (0 != sCommand.getLength());
+ }
+ }
+ }
+ }
+
+ if ( !bKnownDocDataSource )
+ m_aExternalFeatures[ ID_BROWSER_DOCUMENT_DATASOURCE ].bEnabled = sal_False;
+
+ // update the toolbox
+ implCheckExternalSlot(ID_BROWSER_DOCUMENT_DATASOURCE);
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::extractDescriptorProps(const ::svx::ODataAccessDescriptor& _rDescriptor, ::rtl::OUString& _rDataSource, ::rtl::OUString& _rCommand, sal_Int32& _rCommandType, sal_Bool& _rEscapeProcessing)
+{
+ _rDataSource = _rDescriptor.getDataSource();
+ if ( _rDescriptor.has(daCommand) )
+ _rDescriptor[daCommand] >>= _rCommand;
+ if ( _rDescriptor.has(daCommandType) )
+ _rDescriptor[daCommandType] >>= _rCommandType;
+
+ // escape processing is the only one allowed not to be present
+ _rEscapeProcessing = sal_True;
+ if (_rDescriptor.has(daEscapeProcessing))
+ _rEscapeProcessing = ::cppu::any2bool(_rDescriptor[daEscapeProcessing]);
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ bool getDataSourceDisplayName_isURL( const String& _rDS, String& _rDisplayName, String& _rUniqueId )
+ {
+ INetURLObject aURL( _rDS );
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ _rDisplayName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_WITH_CHARSET);
+ _rUniqueId = aURL.GetMainURL( INetURLObject::NO_DECODE );
+ return true;
+ }
+ _rDisplayName = _rDS;
+ _rUniqueId = String();
+ return false;
+ }
+
+ // .....................................................................
+ struct FilterByEntryDataId : public IEntryFilter
+ {
+ String sId;
+ FilterByEntryDataId( const String& _rId ) : sId( _rId ) { }
+
+ virtual ~FilterByEntryDataId() {}
+
+ virtual bool includeEntry( SvLBoxEntry* _pEntry ) const;
+ };
+
+ bool FilterByEntryDataId::includeEntry( SvLBoxEntry* _pEntry ) const
+ {
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pEntry->GetUserData() );
+ return ( !pData || ( pData->sAccessor == sId ) );
+ }
+}
+
+// -------------------------------------------------------------------------
+String SbaTableQueryBrowser::getDataSourceAcessor( SvLBoxEntry* _pDataSourceEntry ) const
+{
+ OSL_ENSURE( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry!" );
+
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() );
+ OSL_ENSURE( pData, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry data!" );
+ OSL_ENSURE( pData->eType == etDatasource, "SbaTableQueryBrowser::getDataSourceAcessor: entry does not denote a data source!" );
+ return pData->sAccessor.Len() ? pData->sAccessor : GetEntryText( _pDataSourceEntry );
+}
+
+// -------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::rtl::OUString& _rDataSource, const ::rtl::OUString& _rCommand, sal_Int32 _nCommandType,
+ SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry, sal_Bool _bExpandAncestors,
+ const SharedConnection& _rxConnection )
+{
+ if (_ppDataSourceEntry)
+ *_ppDataSourceEntry = NULL;
+ if (_ppContainerEntry)
+ *_ppContainerEntry = NULL;
+
+ SvLBoxEntry* pObject = NULL;
+ if ( m_pTreeView )
+ {
+ // look for the data source entry
+ String sDisplayName, sDataSourceId;
+ bool bIsDataSourceURL = getDataSourceDisplayName_isURL( _rDataSource, sDisplayName, sDataSourceId );
+ // the display name may differ from the URL for readability reasons
+ // #i33699#
+
+ FilterByEntryDataId aFilter( sDataSourceId );
+ SvLBoxEntry* pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter );
+ if ( !pDataSource ) // check if the data source name is a file location
+ {
+ if ( bIsDataSourceURL )
+ {
+ // special case, the data source is a URL
+ // add new entries to the list box model
+ implAddDatasource( _rDataSource, _rxConnection );
+ pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter );
+ OSL_ENSURE( pDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" );
+ }
+ }
+ if (_ppDataSourceEntry)
+ // (caller wants to have it ...)
+ *_ppDataSourceEntry = pDataSource;
+
+ if (pDataSource)
+ {
+ // expand if required so
+ if (_bExpandAncestors)
+ m_pTreeView->getListBox().Expand(pDataSource);
+
+ // look for the object container
+ SvLBoxEntry* pCommandType = NULL;
+ switch (_nCommandType)
+ {
+ case CommandType::TABLE:
+ pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_TABLES);
+ break;
+
+ case CommandType::QUERY:
+ pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_QUERIES);
+ break;
+ }
+
+ if (_ppContainerEntry)
+ *_ppContainerEntry = pCommandType;
+
+ if (pCommandType)
+ {
+ // expand if required so
+ if (_bExpandAncestors)
+ {
+ m_pTreeView->getListBox().Expand(pCommandType);
+ }
+
+ // look for the object
+ ::rtl::OUString sCommand = _rCommand;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ ::rtl::OUString sPath = sCommand.getToken( 0, '/', nIndex );
+ pObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, pCommandType);
+ pCommandType = pObject;
+ if ( nIndex >= 0 )
+ {
+ if (ensureEntryObject(pObject))
+ {
+ DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( pObject->GetUserData() );
+ Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY );
+ sal_Int32 nIndex2 = nIndex;
+ sPath = sCommand.getToken( 0, '/', nIndex2 );
+ try
+ {
+ if ( xCollection->hasByName(sPath) )
+ {
+ if(!m_pTreeView->getListBox().GetEntryPosByName(sPath,pObject))
+ {
+ Reference<XNameAccess> xChild(xCollection->getByName(sPath),UNO_QUERY);
+ DBTreeListUserData* pEntryData = new DBTreeListUserData;
+ pEntryData->eType = etQuery;
+ if ( xChild.is() )
+ {
+ pEntryData->eType = etQueryContainer;
+ }
+ implAppendEntry( pObject, sPath, pEntryData, pEntryData->eType );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::populateTree: could not fill the tree");
+ }
+ }
+ }
+ }
+ while ( nIndex >= 0 );
+ }
+ }
+ }
+ return pObject;
+}
+
+// -------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::getObjectEntry(const ::svx::ODataAccessDescriptor& _rDescriptor,
+ SvLBoxEntry** _ppDataSourceEntry, SvLBoxEntry** _ppContainerEntry,
+ sal_Bool _bExpandAncestors)
+{
+ // extract the props from the descriptor
+ ::rtl::OUString sDataSource;
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ sal_Bool bEscapeProcessing = sal_True;
+ extractDescriptorProps(_rDescriptor, sDataSource, sCommand, nCommandType, bEscapeProcessing);
+
+ return getObjectEntry( sDataSource, sCommand, nCommandType, _ppDataSourceEntry, _ppContainerEntry, _bExpandAncestors, SharedConnection() );
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::connectExternalDispatches()
+{
+ Reference< XDispatchProvider > xProvider( getFrame(), UNO_QUERY );
+ OSL_ENSURE(xProvider.is(), "SbaTableQueryBrowser::connectExternalDispatches: no DispatchProvider !");
+ if (xProvider.is())
+ {
+ if ( m_aExternalFeatures.empty() )
+ {
+ const sal_Char* pURLs[] = {
+ ".uno:DataSourceBrowser/DocumentDataSource",
+ ".uno:DataSourceBrowser/FormLetter",
+ ".uno:DataSourceBrowser/InsertColumns",
+ ".uno:DataSourceBrowser/InsertContent",
+ };
+ const sal_uInt16 nIds[] = {
+ ID_BROWSER_DOCUMENT_DATASOURCE,
+ ID_BROWSER_FORMLETTER,
+ ID_BROWSER_INSERTCOLUMNS,
+ ID_BROWSER_INSERTCONTENT
+ };
+
+ for ( size_t i=0; i < SAL_N_ELEMENTS( pURLs ); ++i )
+ {
+ URL aURL;
+ aURL.Complete = ::rtl::OUString::createFromAscii( pURLs[i] );
+ if ( m_xUrlTransformer.is() )
+ m_xUrlTransformer->parseStrict( aURL );
+ m_aExternalFeatures[ nIds[ i ] ] = ExternalFeature( aURL );
+ }
+ }
+
+ for ( ExternalFeaturesMap::iterator feature = m_aExternalFeatures.begin();
+ feature != m_aExternalFeatures.end();
+ ++feature
+ )
+ {
+ feature->second.xDispatcher = xProvider->queryDispatch(
+ feature->second.aURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_parent")), FrameSearchFlag::PARENT
+ );
+
+ if ( feature->second.xDispatcher.get() == static_cast< XDispatch* >( this ) )
+ {
+ OSL_FAIL( "SbaTableQueryBrowser::connectExternalDispatches: this should not happen anymore!" );
+ // (nowadays, the URLs aren't in our SupportedFeatures list anymore, so we should
+ // not supply a dispatcher for this)
+ feature->second.xDispatcher.clear();
+ }
+
+ if ( feature->second.xDispatcher.is() )
+ {
+ try
+ {
+ feature->second.xDispatcher->addStatusListener( this, feature->second.aURL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ implCheckExternalSlot( feature->first );
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::implCheckExternalSlot( sal_uInt16 _nId )
+{
+ if ( !m_xMainToolbar.is() )
+ return;
+
+ Window* pToolboxWindow = VCLUnoHelper::GetWindow( m_xMainToolbar );
+ ToolBox* pToolbox = dynamic_cast< ToolBox* >( pToolboxWindow );
+ OSL_ENSURE( pToolbox, "SbaTableQueryBrowser::implCheckExternalSlot: cannot obtain the toolbox window!" );
+
+ // check if we have to hide this item from the toolbox
+ if ( pToolbox )
+ {
+ sal_Bool bHaveDispatcher = m_aExternalFeatures[ _nId ].xDispatcher.is();
+ if ( bHaveDispatcher != pToolbox->IsItemVisible( _nId ) )
+ bHaveDispatcher ? pToolbox->ShowItem( _nId ) : pToolbox->HideItem( _nId );
+ }
+
+ // and invalidate this feature in general
+ InvalidateFeature( _nId );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::disposing( const EventObject& _rSource ) throw(RuntimeException)
+{
+ // our frame ?
+ Reference< ::com::sun::star::frame::XFrame > xSourceFrame(_rSource.Source, UNO_QUERY);
+ if (m_xCurrentFrameParent.is() && (xSourceFrame == m_xCurrentFrameParent))
+ m_xCurrentFrameParent->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this);
+ else
+ {
+ // search the external dispatcher causing this call in our map
+ Reference< XDispatch > xSource(_rSource.Source, UNO_QUERY);
+ if(xSource.is())
+ {
+ for ( ExternalFeaturesMap::iterator aLoop = m_aExternalFeatures.begin();
+ aLoop != m_aExternalFeatures.end();
+ ++aLoop
+ )
+ {
+ if ( aLoop->second.xDispatcher.get() == xSource.get() )
+ {
+ ExternalFeaturesMap::iterator aPrevious = aLoop;
+ --aPrevious;
+
+ // remove it
+ m_aExternalFeatures.erase( aLoop );
+
+ // maybe update the UI
+ implCheckExternalSlot(aLoop->first);
+
+ // continue, the same XDispatch may be resposible for more than one URL
+ aLoop = aPrevious;
+ }
+ }
+ }
+ else
+ {
+ Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
+ if ( xCon.is() && m_pTreeView )
+ { // our connection is in dispose so we have to find the entry equal with this connection
+ // and close it what means to collapse the entry
+ // get the top-level representing the removed data source
+ SvLBoxEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(NULL);
+ while (pDSLoop)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData());
+ if ( pData && pData->xConnection == xCon )
+ {
+ // we set the connection to null to avoid a second disposing of the connection
+ pData->xConnection.clear();
+ closeConnection(pDSLoop,sal_False);
+ break;
+ }
+
+ pDSLoop = m_pTreeView->getListBox().NextSibling(pDSLoop);
+ }
+ }
+ else
+ SbaXDataBrowserController::disposing(_rSource);
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::implRemoveStatusListeners()
+{
+ // clear all old dispatches
+ for ( ExternalFeaturesMap::const_iterator aLoop = m_aExternalFeatures.begin();
+ aLoop != m_aExternalFeatures.end();
+ ++aLoop
+ )
+ {
+ if ( aLoop->second.xDispatcher.is() )
+ {
+ try
+ {
+ aLoop->second.xDispatcher->removeStatusListener( this, aLoop->second.aURL );
+ }
+ catch (Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::implRemoveStatusListeners: could not remove a status listener!");
+ }
+ }
+ }
+ m_aExternalFeatures.clear();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL SbaTableQueryBrowser::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // doin' a lot of VCL stuff here -> lock the SolarMutex
+
+ Sequence< PropertyValue > aDescriptorSequence;
+ if (!(_rSelection >>= aDescriptorSequence))
+ throw IllegalArgumentException(::rtl::OUString(), *this, 1);
+ // TODO: error message
+
+ ODataAccessDescriptor aDescriptor;
+ try
+ {
+ aDescriptor = ODataAccessDescriptor(aDescriptorSequence);
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::select: could not extract the descriptor!");
+ }
+
+ // check the precense of the props we need
+ if ( !(aDescriptor.has(daDataSource) || aDescriptor.has(daDatabaseLocation)) || !aDescriptor.has(daCommand) || !aDescriptor.has(daCommandType))
+ throw IllegalArgumentException(::rtl::OUString(), *this, 1);
+ // TODO: error message
+
+ return implSelect(aDescriptor,sal_True);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL SbaTableQueryBrowser::getSelection( ) throw (RuntimeException)
+{
+ Any aReturn;
+
+ try
+ {
+ Reference< XLoadable > xLoadable(getRowSet(), UNO_QUERY);
+ if (xLoadable.is() && xLoadable->isLoaded())
+ {
+ Reference< XPropertySet > aFormProps(getRowSet(), UNO_QUERY);
+ ODataAccessDescriptor aDescriptor(aFormProps);
+ // remove properties which are not part of our "selection"
+ aDescriptor.erase(daConnection);
+ aDescriptor.erase(daCursor);
+
+ aReturn <<= aDescriptor.createPropertyValueSequence();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aReturn;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aSelectionListeners.addInterface(_rxListener);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aSelectionListeners.removeInterface(_rxListener);
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::attachFrame(const Reference< ::com::sun::star::frame::XFrame > & _xFrame) throw( RuntimeException )
+{
+ implRemoveStatusListeners();
+
+ if (m_xCurrentFrameParent.is())
+ m_xCurrentFrameParent->removeFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this);
+
+ SbaXDataBrowserController::attachFrame(_xFrame);
+
+ Reference< XFrame > xCurrentFrame( getFrame() );
+ if ( xCurrentFrame.is() )
+ {
+ m_xCurrentFrameParent = xCurrentFrame->findFrame(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_parent")),FrameSearchFlag::PARENT);
+ if ( m_xCurrentFrameParent.is() )
+ m_xCurrentFrameParent->addFrameActionListener((::com::sun::star::frame::XFrameActionListener*)this);
+
+ // obtain our toolbox
+ try
+ {
+ Reference< XPropertySet > xFrameProps( m_aCurrentFrame.getFrame(), UNO_QUERY_THROW );
+ Reference< XLayoutManager > xLayouter(
+ xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ),
+ UNO_QUERY );
+
+ if ( xLayouter.is() )
+ {
+ Reference< XUIElement > xUI(
+ xLayouter->getElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/toolbar" ) ) ),
+ UNO_SET_THROW );
+ m_xMainToolbar = m_xMainToolbar.query( xUI->getRealInterface() );
+ OSL_ENSURE( m_xMainToolbar.is(), "SbaTableQueryBrowser::attachFrame: where's my toolbox?" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // get the dispatchers for the external slots
+ connectExternalDispatches();
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::addModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
+{
+ SbaXDataBrowserController::addModelListeners(_xGridControlModel);
+ Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY);
+ if (xSourceSet.is())
+ {
+ xSourceSet->addPropertyChangeListener(PROPERTY_ROW_HEIGHT, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->addPropertyChangeListener(PROPERTY_FONT, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->addPropertyChangeListener(PROPERTY_TEXTCOLOR, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->addPropertyChangeListener(PROPERTY_TEXTLINECOLOR, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->addPropertyChangeListener(PROPERTY_TEXTEMPHASIS, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->addPropertyChangeListener(PROPERTY_TEXTRELIEF, static_cast<XPropertyChangeListener*>(this));
+ }
+
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::removeModelListeners(const Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel)
+{
+ SbaXDataBrowserController::removeModelListeners(_xGridControlModel);
+ Reference< XPropertySet > xSourceSet(_xGridControlModel, UNO_QUERY);
+ if (xSourceSet.is())
+ {
+ xSourceSet->removePropertyChangeListener(PROPERTY_ROW_HEIGHT, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_FONT, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_TEXTCOLOR, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_TEXTLINECOLOR, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_TEXTEMPHASIS, static_cast<XPropertyChangeListener*>(this));
+ xSourceSet->removePropertyChangeListener(PROPERTY_TEXTRELIEF, static_cast<XPropertyChangeListener*>(this));
+ }
+}
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::RowChanged()
+{
+ if(getBrowserView())
+ {
+ SbaGridControl* pControl = getBrowserView()->getVclControl();
+ if (!pControl->IsEditing())
+ InvalidateFeature(ID_BROWSER_COPY);
+ }
+ SbaXDataBrowserController::RowChanged();
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::ColumnChanged()
+{
+ if(getBrowserView())
+ {
+ SbaGridControl* pControl = getBrowserView()->getVclControl();
+ if (!pControl->IsEditing())
+ InvalidateFeature(ID_BROWSER_COPY);
+ }
+ SbaXDataBrowserController::ColumnChanged();
+}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::AddColumnListener(const Reference< XPropertySet > & xCol)
+{
+ SbaXDataBrowserController::AddColumnListener(xCol);
+ SafeAddPropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this));
+ SafeAddPropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this));
+ SafeAddPropertyListener(xCol, PROPERTY_ALIGN, static_cast<XPropertyChangeListener*>(this));
+ SafeAddPropertyListener(xCol, PROPERTY_FORMATKEY, static_cast<XPropertyChangeListener*>(this));
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::RemoveColumnListener(const Reference< XPropertySet > & xCol)
+{
+ SbaXDataBrowserController::RemoveColumnListener(xCol);
+ SafeRemovePropertyListener(xCol, PROPERTY_WIDTH, static_cast<XPropertyChangeListener*>(this));
+ SafeRemovePropertyListener(xCol, PROPERTY_HIDDEN, static_cast<XPropertyChangeListener*>(this));
+ SafeRemovePropertyListener(xCol, PROPERTY_ALIGN, static_cast<XPropertyChangeListener*>(this));
+ SafeRemovePropertyListener(xCol, PROPERTY_FORMATKEY, static_cast<XPropertyChangeListener*>(this));
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::criticalFail()
+{
+ SbaXDataBrowserController::criticalFail();
+ unloadAndCleanup( sal_False );
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::LoadFinished(sal_Bool _bWasSynch)
+{
+ SbaXDataBrowserController::LoadFinished(_bWasSynch);
+
+ m_sQueryCommand = ::rtl::OUString();
+ m_bQueryEscapeProcessing = sal_False;
+
+ if (isValid() && !loadingCancelled())
+ {
+ // did we load a query?
+ sal_Bool bTemporary; // needed because we m_bQueryEscapeProcessing is only one bit wide (and we want to pass it by reference)
+ if ( implGetQuerySignature( m_sQueryCommand, bTemporary ) )
+ m_bQueryEscapeProcessing = bTemporary;
+ }
+
+ // if the form has been loaded, this means that our "selection" has changed
+ EventObject aEvent( *this );
+ m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::getExternalSlotState( sal_uInt16 _nId ) const
+{
+ sal_Bool bEnabled = sal_False;
+ ExternalFeaturesMap::const_iterator aPos = m_aExternalFeatures.find( _nId );
+ if ( ( m_aExternalFeatures.end() != aPos ) && aPos->second.xDispatcher.is() )
+ bEnabled = aPos->second.bEnabled;
+ return bEnabled;
+}
+
+//------------------------------------------------------------------------------
+FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
+{
+ FeatureState aReturn;
+ // (disabled automatically)
+
+ // no chance without a view
+ if (!getBrowserView() || !getBrowserView()->getVclControl())
+ return aReturn;
+
+ switch ( nId )
+ {
+ case ID_TREE_ADMINISTRATE:
+ aReturn.bEnabled = true;
+ return aReturn;
+
+ case ID_BROWSER_CLOSE:
+ // the close button should always be enabled
+ aReturn.bEnabled = !m_bEnableBrowser;
+ return aReturn;
+
+ // "toggle explorer" is always enabled (if we have a explorer)
+ case ID_BROWSER_EXPLORER:
+ aReturn.bEnabled = m_bEnableBrowser;
+ aReturn.bChecked = haveExplorer();
+ return aReturn;
+
+ case ID_BROWSER_REMOVEFILTER:
+ return SbaXDataBrowserController::GetState( nId );
+
+ case ID_BROWSER_COPY:
+ if ( !m_pTreeView->HasChildPathFocus() )
+ // handled below
+ break;
+ // NO break!
+ case ID_TREE_CLOSE_CONN:
+ case ID_TREE_EDIT_DATABASE:
+ {
+ SvLBoxEntry* pCurrentEntry( m_pTreeView->getListBox().GetCurEntry() );
+ EntryType eType = getEntryType( pCurrentEntry );
+ if ( eType == etUnknown )
+ return aReturn;
+
+ SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent( pCurrentEntry );
+ DBTreeListUserData* pDSData
+ = pDataSourceEntry
+ ? static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() )
+ : NULL;
+
+ if ( nId == ID_TREE_CLOSE_CONN )
+ {
+ aReturn.bEnabled = ( pDSData != NULL ) && pDSData->xConnection.is();
+ }
+ else if ( nId == ID_TREE_EDIT_DATABASE )
+ {
+ ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory( getORB(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Common" ) ) ) );
+ sal_Bool bHaveEditDatabase( sal_True );
+ OSL_VERIFY( aConfig.getNodeValue( "EditDatabaseFromDataSourceView" ) >>= bHaveEditDatabase );
+ aReturn.bEnabled = getORB().is() && ( pDataSourceEntry != NULL ) && bHaveEditDatabase;
+ }
+ else if ( nId == ID_BROWSER_COPY )
+ {
+ aReturn.bEnabled = isEntryCopyAllowed( pCurrentEntry );
+ }
+
+ return aReturn;
+ }
+ }
+
+ // all slots not handled above are not available if no form is loaded
+ if (!isLoaded())
+ return aReturn;
+
+ try
+ {
+ sal_Bool bHandled = sal_False;
+ switch (nId)
+ {
+ case ID_BROWSER_DOCUMENT_DATASOURCE:
+ // the slot is enabled if we have an external dispatcher able to handle it,
+ // and the dispatcher must have enabled the slot in general
+ aReturn.bEnabled = getExternalSlotState( ID_BROWSER_DOCUMENT_DATASOURCE );
+ bHandled = sal_True;
+ break;
+ case ID_BROWSER_REFRESH:
+ aReturn.bEnabled = sal_True;
+ bHandled = sal_True;
+ break;
+ }
+
+ if (bHandled)
+ return aReturn;
+
+ // no chance without valid models
+ if (isValid() && !isValidCursor() && nId != ID_BROWSER_CLOSE)
+ return aReturn;
+
+ switch (nId)
+ {
+ case ID_BROWSER_INSERTCOLUMNS:
+ case ID_BROWSER_INSERTCONTENT:
+ case ID_BROWSER_FORMLETTER:
+ {
+ // the slot is enabled if we have an external dispatcher able to handle it,
+ // and the dispatcher must have enabled the slot in general
+ aReturn.bEnabled = getExternalSlotState( nId );
+
+ // for the Insert* slots, we need at least one selected row
+ if (ID_BROWSER_FORMLETTER != nId)
+ aReturn.bEnabled = aReturn.bEnabled && getBrowserView()->getVclControl()->GetSelectRowCount();
+
+ // disabled for native queries which are not saved within the database
+ Reference< XPropertySet > xDataSource(getRowSet(), UNO_QUERY);
+ try
+ {
+ aReturn.bEnabled = aReturn.bEnabled && xDataSource.is();
+
+ if (xDataSource.is())
+ {
+ sal_Int32 nType = ::comphelper::getINT32(xDataSource->getPropertyValue(PROPERTY_COMMAND_TYPE));
+ aReturn.bEnabled = aReturn.bEnabled && ((::comphelper::getBOOL(xDataSource->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) || (nType == ::com::sun::star::sdb::CommandType::QUERY)));
+ }
+ }
+ catch(DisposedException&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::GetState: object already disposed!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ break;
+
+ case ID_BROWSER_TITLE:
+ {
+ Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
+ sal_Int32 nCommandType = CommandType::TABLE;
+ xProp->getPropertyValue(PROPERTY_COMMAND_TYPE) >>= nCommandType;
+ String sTitle;
+ switch (nCommandType)
+ {
+ case CommandType::TABLE:
+ sTitle = String(ModuleRes(STR_TBL_TITLE)); break;
+ case CommandType::QUERY:
+ case CommandType::COMMAND:
+ sTitle = String(ModuleRes(STR_QRY_TITLE)); break;
+ default:
+ OSL_FAIL("SbaTableQueryBrowser::GetState: unknown command type!");
+ }
+ ::rtl::OUString aName;
+ xProp->getPropertyValue(PROPERTY_COMMAND) >>= aName;
+ String sObject(aName.getStr());
+
+ sTitle.SearchAndReplace('#',sObject);
+ aReturn.sTitle = sTitle;
+ aReturn.bEnabled = sal_True;
+ }
+ break;
+ case ID_BROWSER_TABLEATTR:
+ case ID_BROWSER_ROWHEIGHT:
+ case ID_BROWSER_COLATTRSET:
+ case ID_BROWSER_COLWIDTH:
+ aReturn.bEnabled = getBrowserView() && getBrowserView()->getVclControl() && isValid() && isValidCursor();
+ // aReturn.bEnabled &= getDefinition() && !getDefinition()->GetDatabase()->IsReadOnly();
+ break;
+
+ case ID_BROWSER_COPY:
+ OSL_ENSURE( !m_pTreeView->HasChildPathFocus(), "SbaTableQueryBrowser::GetState( ID_BROWSER_COPY ): this should have been handled above!" );
+ if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing())
+ {
+ SbaGridControl* pControl = getBrowserView()->getVclControl();
+ if ( pControl->GetSelectRowCount() )
+ {
+ aReturn.bEnabled = m_aCurrentFrame.isActive();
+ break;
+ }
+ else
+ aReturn.bEnabled = pControl->canCopyCellText(pControl->GetCurRow(), pControl->GetCurColumnId());
+ break;
+ }
+ // NO break here
+ default:
+ return SbaXDataBrowserController::GetState(nId);
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aReturn;
+
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch (nId)
+ {
+ default:
+ SbaXDataBrowserController::Execute(nId,aArgs);
+ break;
+
+ case ID_TREE_EDIT_DATABASE:
+ implAdministrate( m_pTreeView->getListBox().GetCurEntry() );
+ break;
+
+ case ID_TREE_CLOSE_CONN:
+ openHelpAgent( HID_DSBROWSER_DISCONNECTING );
+ closeConnection( m_pTreeView->getListBox().GetRootLevelParent( m_pTreeView->getListBox().GetCurEntry() ) );
+ break;
+
+ case ID_TREE_ADMINISTRATE:
+ ::svx::administrateDatabaseRegistration( getView() );
+ break;
+
+ case ID_BROWSER_REFRESH:
+ {
+ if ( !SaveModified( ) )
+ // nothing to do
+ break;
+
+ sal_Bool bFullReinit = sal_False;
+ // check if the query signature (if the form is based on a query) has changed
+ if ( m_sQueryCommand.getLength() )
+ {
+ ::rtl::OUString sNewQueryCommand;
+ sal_Bool bNewQueryEP;
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bIsQuery =
+#endif
+ implGetQuerySignature( sNewQueryCommand, bNewQueryEP );
+ OSL_ENSURE( bIsQuery, "SbaTableQueryBrowser::Execute: was a query before, but is not anymore?" );
+
+ bFullReinit = ( sNewQueryCommand != m_sQueryCommand ) || ( m_bQueryEscapeProcessing != bNewQueryEP );
+ }
+ if ( !bFullReinit )
+ {
+ // let the base class do a simple reload
+ SbaXDataBrowserController::Execute(nId,aArgs);
+ break;
+ }
+ // NO break here!
+ }
+
+ case ID_BROWSER_REFRESH_REBUILD:
+ {
+ if ( !SaveModified() )
+ // nothing to do
+ break;
+
+ SvLBoxEntry* pSelected = m_pCurrentlyDisplayed;
+ // unload
+ unloadAndCleanup( sal_False );
+
+ // reselect the entry
+ if ( pSelected )
+ {
+ implSelect( pSelected );
+ }
+ else
+ {
+ Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
+ implSelect(::svx::ODataAccessDescriptor(xProp));
+ }
+ }
+ break;
+
+ case ID_BROWSER_EXPLORER:
+ toggleExplorer();
+ break;
+
+ case ID_BROWSER_DOCUMENT_DATASOURCE:
+ implSelect(m_aDocumentDataSource);
+ break;
+
+ case ID_BROWSER_INSERTCOLUMNS:
+ case ID_BROWSER_INSERTCONTENT:
+ case ID_BROWSER_FORMLETTER:
+ if (getBrowserView() && isValidCursor())
+ {
+ // the URL the slot id is assigned to
+ OSL_ENSURE( m_aExternalFeatures.find( nId ) != m_aExternalFeatures.end(),
+ "SbaTableQueryBrowser::Execute( ID_BROWSER_?): how could this ever be enabled?" );
+ URL aParentUrl = m_aExternalFeatures[ nId ].aURL;
+
+ // let the dispatcher execute the slot
+ Reference< XDispatch > xDispatch( m_aExternalFeatures[ nId ].xDispatcher );
+ if (xDispatch.is())
+ {
+ // set the properties for the dispatch
+
+ // first fill the selection
+ SbaGridControl* pGrid = getBrowserView()->getVclControl();
+ MultiSelection* pSelection = (MultiSelection*)pGrid->GetSelection();
+ Sequence< Any > aSelection;
+ if ( !pGrid->IsAllSelected() )
+ { // transfer the selected rows only if not all rows are selected
+ // (all rows means the whole table)
+ // #i3832#
+ if (pSelection != NULL)
+ {
+ aSelection.realloc(pSelection->GetSelectCount());
+ long nIdx = pSelection->FirstSelected();
+ Any* pSelectionNos = aSelection.getArray();
+ while (nIdx >= 0)
+ {
+ *pSelectionNos++ <<= (sal_Int32)(nIdx + 1);
+ nIdx = pSelection->NextSelected();
+ }
+ }
+ }
+
+ Reference< XResultSet > xCursorClone;
+ try
+ {
+ Reference< XResultSetAccess > xResultSetAccess(getRowSet(),UNO_QUERY);
+ if (xResultSetAccess.is())
+ xCursorClone = xResultSetAccess->createResultSet();
+ }
+ catch(DisposedException&)
+ {
+ OSL_FAIL("Object already disposed!");
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::Execute(ID_BROWSER_?): could not clone the cursor!");
+ }
+
+ Reference<XPropertySet> xProp(getRowSet(),UNO_QUERY);
+
+ try
+ {
+ ODataAccessDescriptor aDescriptor;
+ ::rtl::OUString sDataSourceName;
+ xProp->getPropertyValue(PROPERTY_DATASOURCENAME) >>= sDataSourceName;
+
+ aDescriptor.setDataSource(sDataSourceName);
+ aDescriptor[daCommand] = xProp->getPropertyValue(PROPERTY_COMMAND);
+ aDescriptor[daCommandType] = xProp->getPropertyValue(PROPERTY_COMMAND_TYPE);
+ aDescriptor[daConnection] = xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION);
+ aDescriptor[daCursor] <<= xCursorClone;
+ if ( aSelection.getLength() )
+ {
+ aDescriptor[daSelection] <<= aSelection;
+ aDescriptor[daBookmarkSelection] <<= sal_False;
+ // these are selection indicies
+ // before we change this, all clients have to be adjusted
+ // so that they recognize the new BookmarkSelection property!
+ }
+
+ xDispatch->dispatch(aParentUrl, aDescriptor.createPropertyValueSequence());
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ break;
+
+ case ID_BROWSER_CLOSE:
+ closeTask();
+ // if it's not 0, such a async close is already pending
+ break;
+
+ case ID_BROWSER_COPY:
+ if(m_pTreeView->HasChildPathFocus())
+ {
+ copyEntry(m_pTreeView->getListBox().GetCurEntry());
+ }
+ else if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing() && getBrowserView()->getVclControl()->GetSelectRowCount() < 1)
+ {
+ SbaGridControl* pControl = getBrowserView()->getVclControl();
+ pControl->copyCellText(pControl->GetCurRow(), pControl->GetCurColumnId());
+ }
+ else
+ SbaXDataBrowserController::Execute(nId,aArgs);
+ break;
+ }
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection )
+{
+ Image a, b, c;
+ String d, e;
+ implAddDatasource( _rDataSourceName, a, d, b, e, c, _rxConnection );
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::implAddDatasource(const String& _rDbName, Image& _rDbImage,
+ String& _rQueryName, Image& _rQueryImage, String& _rTableName, Image& _rTableImage,
+ const SharedConnection& _rxConnection)
+{
+ SolarMutexGuard aGuard;
+ // initialize the names/images if necessary
+ if (!_rQueryName.Len())
+ _rQueryName = String(ModuleRes(RID_STR_QUERIES_CONTAINER));
+ if (!_rTableName.Len())
+ _rTableName = String(ModuleRes(RID_STR_TABLES_CONTAINER));
+
+ ImageProvider aImageProvider;
+ if (!_rQueryImage)
+ _rQueryImage = aImageProvider.getFolderImage( DatabaseObject::QUERY );
+ if (!_rTableImage)
+ _rTableImage = aImageProvider.getFolderImage( DatabaseObject::TABLE );
+
+ if (!_rDbImage)
+ _rDbImage = aImageProvider.getDatabaseImage();
+
+ // add the entry for the data source
+ // special handling for data sources denoted by URLs - we do not want to display this ugly URL, do we?
+ // #i33699#
+ String sDSDisplayName, sDataSourceId;
+ getDataSourceDisplayName_isURL( _rDbName, sDSDisplayName, sDataSourceId );
+
+ SvLBoxEntry* pDatasourceEntry = m_pTreeView->getListBox().InsertEntry( sDSDisplayName, _rDbImage, _rDbImage, NULL, sal_False );
+ DBTreeListUserData* pDSData = new DBTreeListUserData;
+ pDSData->eType = etDatasource;
+ pDSData->sAccessor = sDataSourceId;
+ pDSData->xConnection = _rxConnection;
+ pDatasourceEntry->SetUserData(pDSData);
+
+ // the child for the queries container
+ {
+ DBTreeListUserData* pQueriesData = new DBTreeListUserData;
+ pQueriesData->eType = etQueryContainer;
+
+ m_pTreeView->getListBox().InsertEntry(
+ _rQueryName, _rQueryImage, _rQueryImage, pDatasourceEntry,
+ sal_True /*ChildsOnDemand*/, LIST_APPEND, pQueriesData );
+ }
+
+ // the child for the tables container
+ {
+ DBTreeListUserData* pTablesData = new DBTreeListUserData;
+ pTablesData->eType = etTableContainer;
+
+ m_pTreeView->getListBox().InsertEntry(
+ _rTableName, _rTableImage, _rTableImage, pDatasourceEntry,
+ sal_True /*ChildsOnDemand*/, LIST_APPEND, pTablesData );
+ }
+
+}
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::initializeTreeModel()
+{
+ if (m_xDatabaseContext.is())
+ {
+ Image aDBImage, aQueriesImage, aTablesImage;
+ String sQueriesName, sTablesName;
+
+ // fill the model with the names of the registered datasources
+ Sequence< ::rtl::OUString > aDatasources = m_xDatabaseContext->getElementNames();
+ const ::rtl::OUString* pIter = aDatasources.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aDatasources.getLength();
+ for (; pIter != pEnd; ++pIter)
+ implAddDatasource( *pIter, aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, SharedConnection() );
+ }
+}
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess,
+ SvLBoxEntry* _pParent,
+ EntryType _eEntryType)
+{
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pParent->GetUserData());
+ if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
+ pData->xContainer = _xNameAccess;
+
+ try
+ {
+ Sequence< ::rtl::OUString > aNames = _xNameAccess->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for (; pIter != pEnd; ++pIter)
+ {
+ if( !m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent))
+ {
+ Reference<XNameAccess> xChild(_xNameAccess->getByName(*pIter),UNO_QUERY);
+ DBTreeListUserData* pEntryData = new DBTreeListUserData;
+ pEntryData->eType = _eEntryType;
+ if ( _eEntryType == etQuery && xChild.is() )
+ {
+ pEntryData->eType = etQueryContainer;
+ }
+ implAppendEntry( _pParent, *pIter, pEntryData, pEntryData->eType );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::populateTree: could not fill the tree");
+ }
+}
+
+//------------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::implAppendEntry( SvLBoxEntry* _pParent, const String& _rName, void* _pUserData, EntryType _eEntryType )
+{
+ ::std::auto_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) );
+
+ Image aImage;
+ pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage );
+
+ SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, _eEntryType == etQueryContainer , LIST_APPEND, _pUserData );
+
+ m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage );
+ m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage );
+
+ return pNewEntry;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvLBoxEntry*, _pParent)
+{
+ if (_pParent->HasChilds())
+ // nothing to to ...
+ return 1L;
+
+ SvLBoxEntry* pFirstParent = m_pTreeView->getListBox().GetRootLevelParent(_pParent);
+ OSL_ENSURE(pFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!");
+
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >(_pParent->GetUserData());
+ OSL_ENSURE(pData,"SbaTableQueryBrowser::OnExpandEntry: No user data!");
+#if OSL_DEBUG_LEVEL > 0
+ SvLBoxString* pString = static_cast<SvLBoxString*>(pFirstParent->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
+ OSL_ENSURE(pString,"SbaTableQueryBrowser::OnExpandEntry: No string item!");
+#endif
+
+ if (etTableContainer == pData->eType)
+ {
+ WaitObject aWaitCursor(getBrowserView());
+
+ // it could be that we already have a connection
+ SharedConnection xConnection;
+ ensureConnection( pFirstParent, xConnection );
+
+ if ( xConnection.is() )
+ {
+ SQLExceptionInfo aInfo;
+ try
+ {
+ Reference< XWarningsSupplier > xWarnings(xConnection, UNO_QUERY);
+ if (xWarnings.is())
+ xWarnings->clearWarnings();
+
+ // first insert the views because the tables can also include
+ // views but that time the bitmap is the wrong one
+ // the nameaccess will be overwriten in populateTree
+ Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY);
+ if(xViewSup.is())
+ populateTree( xViewSup->getViews(), _pParent, etTableOrView );
+
+ Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
+ if(xTabSup.is())
+ {
+ populateTree( xTabSup->getTables(), _pParent, etTableOrView );
+ Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY);
+ if(xCont.is())
+ // add as listener to know when elements are inserted or removed
+ xCont->addContainerListener(this);
+ }
+
+ if (xWarnings.is())
+ {
+ SQLExceptionInfo aWarnings(xWarnings->getWarnings());
+ if (aWarnings.isValid() && sal_False)
+ {
+ SQLContext aContext;
+ aContext.Message = String(ModuleRes(STR_OPENTABLES_WARNINGS));
+ aContext.Details = String(ModuleRes(STR_OPENTABLES_WARNINGS_DETAILS));
+ aContext.NextException = aWarnings.get();
+ aWarnings = aContext;
+ showError(aWarnings);
+ }
+ // TODO: we need a better concept for these warnings:
+ // something like "don't show any warnings for this datasource, again" would be nice
+ // But this requires an extension of the InteractionHandler and an additional property on the data source
+ }
+ }
+ catch(const SQLContext& e) { aInfo = e; }
+ catch(const SQLWarning& e) { aInfo = e; }
+ catch(const SQLException& e) { aInfo = e; }
+ catch(const WrappedTargetException& e)
+ {
+ SQLException aSql;
+ if(e.TargetException >>= aSql)
+ aInfo = aSql;
+ else
+ OSL_FAIL("SbaTableQueryBrowser::OnExpandEntry: something strange happended!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if (aInfo.isValid())
+ showError(aInfo);
+ }
+ else
+ return 0L;
+ // 0 indicates that an error occurred
+ }
+ else
+ { // we have to expand the queries or bookmarks
+ if (ensureEntryObject(_pParent))
+ {
+ DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( _pParent->GetUserData() );
+ Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY );
+ populateTree( xCollection, _pParent, etQuery );
+ }
+ }
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::ensureEntryObject( SvLBoxEntry* _pEntry )
+{
+ OSL_ENSURE(_pEntry, "SbaTableQueryBrowser::ensureEntryObject: invalid argument!");
+ if (!_pEntry)
+ return sal_False;
+
+ EntryType eType = getEntryType( _pEntry );
+
+ // the user data of the entry
+ DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+ OSL_ENSURE(pEntryData,"ensureEntryObject: user data should already be set!");
+
+ SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(_pEntry);
+
+ sal_Bool bSuccess = sal_False;
+ switch (eType)
+ {
+ case etQueryContainer:
+ if ( pEntryData->xContainer.is() )
+ {
+ // nothing to do
+ bSuccess = sal_True;
+ break;
+ }
+
+ {
+ SvLBoxEntry* pParent = m_pTreeView->getListBox().GetParent(_pEntry);
+ if ( pParent != pDataSourceEntry )
+ {
+ SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ OSL_ENSURE(pString,"There must be a string item!");
+ ::rtl::OUString aName(pString->GetText());
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pParent->GetUserData());
+ try
+ {
+ Reference< XNameAccess > xNameAccess(pData->xContainer,UNO_QUERY);
+ if ( xNameAccess.is() )
+ pEntryData->xContainer.set(xNameAccess->getByName(aName),UNO_QUERY);
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ bSuccess = pEntryData->xContainer.is();
+ }
+ else
+ {
+ try
+ {
+ Reference< XQueryDefinitionsSupplier > xQuerySup;
+ m_xDatabaseContext->getByName( getDataSourceAcessor( pDataSourceEntry ) ) >>= xQuerySup;
+ if (xQuerySup.is())
+ {
+ Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions();
+ Reference< XContainer > xCont(xQueryDefs, UNO_QUERY);
+ if (xCont.is())
+ // add as listener to get notified if elements are inserted or removed
+ xCont->addContainerListener(this);
+
+ pEntryData->xContainer = xQueryDefs;
+ bSuccess = pEntryData->xContainer.is();
+ }
+ else {
+ OSL_FAIL("SbaTableQueryBrowser::ensureEntryObject: no XQueryDefinitionsSupplier interface!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ break;
+
+ default:
+ OSL_FAIL("SbaTableQueryBrowser::ensureEntryObject: ooops ... missing some implementation here!");
+ // TODO ...
+ break;
+ }
+
+ return bSuccess;
+}
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::implSelect(const ::svx::ODataAccessDescriptor& _rDescriptor,sal_Bool _bSelectDirect)
+{
+ // extract the props
+ ::rtl::OUString sDataSource;
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ sal_Bool bEscapeProcessing = sal_True;
+ extractDescriptorProps(_rDescriptor, sDataSource, sCommand, nCommandType, bEscapeProcessing);
+
+ // select it
+ return implSelect( sDataSource, sCommand, nCommandType, bEscapeProcessing, SharedConnection(), _bSelectDirect );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::implLoadAnything(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand,
+ const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing, const SharedConnection& _rxConnection)
+{
+ try
+ {
+ Reference<XPropertySet> xProp( getRowSet(), UNO_QUERY_THROW );
+ Reference< XLoadable > xLoadable( xProp, UNO_QUERY_THROW );
+ // the values allowing the RowSet to re-execute
+ xProp->setPropertyValue(PROPERTY_DATASOURCENAME, makeAny(_rDataSourceName));
+ if(_rxConnection.is())
+ xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _rxConnection.getTyped() ) );
+
+ // set this _before_ setting the connection, else the rowset would rebuild it ...
+ xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(_nCommandType));
+ xProp->setPropertyValue(PROPERTY_COMMAND, makeAny(_rCommand));
+ xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, ::cppu::bool2any(_bEscapeProcessing));
+ if ( m_bPreview )
+ {
+ xProp->setPropertyValue(PROPERTY_FETCHDIRECTION, makeAny(FetchDirection::FORWARD));
+ }
+
+ // the formatter depends on the data source we're working on, so rebuild it here ...
+ initFormatter();
+
+ // switch the grid to design mode while loading
+ getBrowserView()->getGridControl()->setDesignMode(sal_True);
+ InitializeForm( xProp );
+
+ sal_Bool bSuccess = sal_True;
+
+ {
+ {
+ Reference< XNameContainer > xColContainer(getFormComponent(), UNO_QUERY);
+ // first we have to clear the grid
+ clearGridColumns(xColContainer);
+ }
+ FormErrorHelper aHelper(this);
+ // load the form
+ bSuccess = reloadForm(xLoadable);
+
+ // initialize the model
+ InitializeGridModel(getFormComponent());
+
+ Any aVal = xProp->getPropertyValue(PROPERTY_ISNEW);
+ if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
+ {
+ // then set the default values and the parameters given from the parent
+ Reference< XReset> xReset(xProp, UNO_QUERY);
+ xReset->reset();
+ }
+
+ if ( m_bPreview )
+ initializePreviewMode();
+
+ LoadFinished(sal_True);
+ }
+
+ InvalidateAll();
+ return bSuccess;
+ }
+ catch( const SQLException& e )
+ {
+ Any aException( ::cppu::getCaughtException() );
+ showError( SQLExceptionInfo( aException ) );
+ }
+ catch( const WrappedTargetException& e )
+ {
+ SQLException aSql;
+ if ( e.TargetException.isExtractableTo( ::cppu::UnoType< SQLException >::get() ) )
+ showError( SQLExceptionInfo( e.TargetException ) );
+ else
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ InvalidateAll();
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::implSelect(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand,
+ const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing,
+ const SharedConnection& _rxConnection
+ ,sal_Bool _bSelectDirect)
+{
+ if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != _nCommandType))
+ {
+ SvLBoxEntry* pDataSource = NULL;
+ SvLBoxEntry* pCommandType = NULL;
+ SvLBoxEntry* pCommand = getObjectEntry( _rDataSourceName, _rCommand, _nCommandType, &pDataSource, &pCommandType, sal_True, _rxConnection );
+
+ if (pCommand)
+ {
+ bool bSuccess = true;
+ if ( _bSelectDirect )
+ {
+ bSuccess = implSelect( pCommand );
+ }
+ else
+ {
+ m_pTreeView->getListBox().Select( pCommand );
+ }
+
+ if ( bSuccess )
+ {
+ m_pTreeView->getListBox().MakeVisible(pCommand);
+ m_pTreeView->getListBox().SetCursor(pCommand);
+ }
+ }
+ else if (!pCommandType)
+ {
+ if ( m_pCurrentlyDisplayed )
+ { // tell the old entry (if any) it has been deselected
+ selectPath(m_pCurrentlyDisplayed, sal_False);
+ m_pCurrentlyDisplayed = NULL;
+ }
+
+ // we have a command and need to display this in the rowset
+ return implLoadAnything(_rDataSourceName, _rCommand, _nCommandType, _bEscapeProcessing, _rxConnection);
+ }
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(SbaTableQueryBrowser, OnSelectionChange, void*, /*NOINTERESTEDIN*/)
+{
+ return implSelect( m_pTreeView->getListBox().FirstSelected() ) ? 1L : 0L;
+}
+//------------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::implGetConnectionEntry(SvLBoxEntry* _pEntry) const
+{
+ SvLBoxEntry* pCurrentEntry = _pEntry;
+ DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
+ while(pEntryData->eType != etDatasource )
+ {
+ pCurrentEntry = m_pTreeModel->GetParent(pCurrentEntry);
+ pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
+ }
+ return pCurrentEntry;
+}
+//------------------------------------------------------------------------------
+bool SbaTableQueryBrowser::implSelect( SvLBoxEntry* _pEntry )
+{
+ if ( !_pEntry )
+ return false;
+
+ DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( _pEntry->GetUserData() );
+ switch (pEntryData->eType)
+ {
+ case etTableOrView:
+ case etQuery:
+ break;
+ default:
+ // nothing to do
+ return false;
+ }
+
+ OSL_ENSURE(m_pTreeModel->HasParent(_pEntry), "SbaTableQueryBrowser::implSelect: invalid entry (1)!");
+ OSL_ENSURE(m_pTreeModel->HasParent(m_pTreeModel->GetParent(_pEntry)), "SbaTableQueryBrowser::implSelect: invalid entry (2)!");
+
+ // get the entry for the tables or queries
+ SvLBoxEntry* pContainer = m_pTreeModel->GetParent(_pEntry);
+ DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
+
+ // get the entry for the datasource
+ SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer);
+ DBTreeListUserData* pConData = static_cast<DBTreeListUserData*>(pConnection->GetUserData());
+
+ // reinitialize the rowset
+ // but first check if it is necessary
+ // get all old properties
+ Reference<XPropertySet> xRowSetProps(getRowSet(),UNO_QUERY);
+ ::rtl::OUString aOldName;
+ xRowSetProps->getPropertyValue(PROPERTY_COMMAND) >>= aOldName;
+ sal_Int32 nOldType = 0;
+ xRowSetProps->getPropertyValue(PROPERTY_COMMAND_TYPE) >>= nOldType;
+ Reference<XConnection> xOldConnection(xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+
+ // the name of the table or query
+ SvLBoxString* pString = (SvLBoxString*)_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ OSL_ENSURE(pString,"There must be a string item!");
+ const ::rtl::OUString sSimpleName = pString->GetText();
+ ::rtl::OUStringBuffer sNameBuffer(sSimpleName);
+ if ( etQueryContainer == pContainerData->eType )
+ {
+ SvLBoxEntry* pTemp = pContainer;
+ while( m_pTreeModel->GetParent(pTemp) != pConnection )
+ {
+ sNameBuffer.insert(0,sal_Unicode('/'));
+ pString = (SvLBoxString*)pTemp->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING);
+ OSL_ENSURE(pString,"There must be a string item!");
+ sNameBuffer.insert(0,pString->GetText());
+ pTemp = m_pTreeModel->GetParent(pTemp);
+ }
+ }
+ ::rtl::OUString aName = sNameBuffer.makeStringAndClear();
+
+ sal_Int32 nCommandType = ( etTableContainer == pContainerData->eType)
+ ? CommandType::TABLE
+ : CommandType::QUERY;
+
+ // check if need to rebuild the rowset
+ sal_Bool bRebuild = ( xOldConnection != pConData->xConnection )
+ || ( nOldType != nCommandType )
+ || ( aName != aOldName );
+
+ Reference< ::com::sun::star::form::XLoadable > xLoadable = getLoadable();
+ bRebuild |= !xLoadable->isLoaded();
+ bool bSuccess = true;
+ if ( bRebuild )
+ {
+ try
+ {
+ WaitObject aWaitCursor(getBrowserView());
+
+ // tell the old entry it has been deselected
+ selectPath(m_pCurrentlyDisplayed, sal_False);
+ m_pCurrentlyDisplayed = NULL;
+
+ // not really loaded
+ m_pCurrentlyDisplayed = _pEntry;
+ // tell the new entry it has been selected
+ selectPath(m_pCurrentlyDisplayed, sal_True);
+
+ // get the name of the data source currently selected
+ ensureConnection( m_pCurrentlyDisplayed, pConData->xConnection );
+
+ if ( !pConData->xConnection.is() )
+ {
+ unloadAndCleanup( sal_False );
+ return false;
+ }
+
+ Reference<XNameAccess> xNameAccess;
+ switch(nCommandType)
+ {
+ case CommandType::TABLE:
+ {
+ // only for tables
+ if ( !pContainerData->xContainer.is() )
+ {
+ Reference<XTablesSupplier> xSup( pConData->xConnection, UNO_QUERY );
+ if(xSup.is())
+ xNameAccess = xSup->getTables();
+
+ pContainerData->xContainer = xNameAccess;
+ }
+ else
+ xNameAccess.set( pContainerData->xContainer, UNO_QUERY );
+ }
+ break;
+ case CommandType::QUERY:
+ {
+ if ( pContainerData->xContainer.is() )
+ xNameAccess.set( pContainerData->xContainer, UNO_QUERY );
+ else
+ {
+ Reference<XQueriesSupplier> xSup( pConData->xConnection, UNO_QUERY );
+ if(xSup.is())
+ xNameAccess = xSup->getQueries();
+ }
+ }
+ break;
+ }
+ String sStatus(ModuleRes( CommandType::TABLE == nCommandType ? STR_LOADING_TABLE : STR_LOADING_QUERY ));
+ sStatus.SearchAndReplaceAscii("$name$", aName);
+ BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sStatus);
+
+ if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName))
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+ if ( !pData->xObjectProperties.is() )
+ {
+ Reference<XInterface> xObject;
+ if(xNameAccess->getByName(sSimpleName) >>= xObject) // remember the table or query object
+ {
+ pData->xObjectProperties = pData->xObjectProperties.query( xObject );
+ // if the query contains a parameterized statement and preview is enabled we won't get any data.
+ if ( m_bPreview && nCommandType == CommandType::QUERY && xObject.is() )
+ {
+ ::rtl::OUString sSql;
+ Reference<XPropertySet> xObjectProps(xObject,UNO_QUERY);
+ xObjectProps->getPropertyValue(PROPERTY_COMMAND) >>= sSql;
+ Reference< XMultiServiceFactory > xFactory( pConData->xConnection, UNO_QUERY );
+ if (xFactory.is())
+ {
+ try
+ {
+ Reference<XSingleSelectQueryAnalyzer> xAnalyzer(xFactory->createInstance(SERVICE_NAME_SINGLESELECTQUERYCOMPOSER),UNO_QUERY);
+ if ( xAnalyzer.is() )
+ {
+ xAnalyzer->setQuery(sSql);
+ Reference<XParametersSupplier> xParSup(xAnalyzer,UNO_QUERY);
+ if ( xParSup->getParameters()->getCount() > 0 )
+ {
+ String sFilter = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "));
+ sFilter = sFilter + xAnalyzer->getFilter();
+ String sReplace(sSql);
+ sReplace.SearchAndReplace(sFilter,String());
+ xAnalyzer->setQuery(sReplace);
+ Reference<XSingleSelectQueryComposer> xComposer(xAnalyzer,UNO_QUERY);
+ xComposer->setFilter(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0=1")));
+ aName = xAnalyzer->getQuery();
+ nCommandType = CommandType::COMMAND;
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ String sDataSourceName( getDataSourceAcessor( pConnection ) );
+ bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, sal_True, pConData->xConnection );
+ if ( !bSuccess )
+ { // clean up
+ criticalFail();
+ }
+ }
+ catch(const SQLException& e)
+ {
+ showError(SQLExceptionInfo(e));
+ // reset the values
+ xRowSetProps->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
+ xRowSetProps->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,Any());
+ }
+ catch(WrappedTargetException& e)
+ {
+ SQLException aSql;
+ if(e.TargetException >>= aSql)
+ showError(SQLExceptionInfo(aSql));
+ else
+ OSL_FAIL("SbaTableQueryBrowser::implSelect: something strange happended!");
+ // reset the values
+ xRowSetProps->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
+ xRowSetProps->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,Any());
+ }
+ catch(Exception&)
+ {
+ // reset the values
+ xRowSetProps->setPropertyValue(PROPERTY_DATASOURCENAME,Any());
+ xRowSetProps->setPropertyValue(PROPERTY_ACTIVE_CONNECTION,Any());
+ }
+ }
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------------
+SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess)
+{
+ DBTreeListBox& rListBox = m_pTreeView->getListBox();
+ SvLBoxEntry* pContainer = NULL;
+ SvLBoxEntry* pDSLoop = rListBox.FirstChild(NULL);
+ while (pDSLoop)
+ {
+ pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_QUERIES);
+ DBTreeListUserData* pQueriesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
+ if ( pQueriesData && pQueriesData->xContainer == _rxNameAccess )
+ break;
+
+ pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_TABLES);
+ DBTreeListUserData* pTablesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
+ if ( pTablesData && pTablesData->xContainer == _rxNameAccess )
+ break;
+
+ pDSLoop = rListBox.NextSibling(pDSLoop);
+ pContainer = NULL;
+ }
+ return pContainer;
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
+ // first search for a definition container where we can insert this element
+
+ SvLBoxEntry* pEntry = getEntryFromContainer(xNames);
+ if(pEntry) // found one
+ {
+ // insert the new entry into the tree
+ DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pEntry->GetUserData());
+ OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!");
+
+ DBTreeListUserData* pNewData = new DBTreeListUserData;
+ sal_Bool bIsTable = etTableContainer == pContainerData->eType;
+ if ( bIsTable )
+ {
+ _rEvent.Element >>= pNewData->xObjectProperties;// remember the new element
+ pNewData->eType = etTableOrView;
+ }
+ else
+ {
+ if ((sal_Int32)m_pTreeView->getListBox().GetChildCount(pEntry) < ( xNames->getElementNames().getLength() - 1 ) )
+ {
+ // the item inserts its children on demand, but it has not been expanded yet. So ensure here and
+ // now that it has all items
+ populateTree(xNames, pEntry, etQuery );
+ }
+ pNewData->eType = etQuery;
+ }
+ implAppendEntry( pEntry, ::comphelper::getString( _rEvent.Accessor ), pNewData, pNewData->eType );
+ }
+ else
+ SbaXDataBrowserController::elementInserted(_rEvent);
+}
+// -------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const String& _sName,SvLBoxEntry* _pContainer)
+{
+ return m_pCurrentlyDisplayed
+ && getEntryType(m_pCurrentlyDisplayed) == getChildType(_pContainer)
+ && m_pTreeView->getListBox().GetParent(m_pCurrentlyDisplayed) == _pContainer
+ && m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed) == _sName;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
+ // get the top-level representing the removed data source
+ // and search for the queries and tables
+ SvLBoxEntry* pContainer = getEntryFromContainer(xNames);
+ if ( pContainer )
+ { // a query or table has been removed
+ String aName = ::comphelper::getString(_rEvent.Accessor).getStr();
+
+ if ( isCurrentlyDisplayedChanged( aName, pContainer) )
+ { // the element displayed currently has been replaced
+
+ // we need to remember the old value
+ SvLBoxEntry* pTemp = m_pCurrentlyDisplayed;
+
+ // unload
+ unloadAndCleanup( sal_False ); // don't dispose the connection
+
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData());
+ pTemp->SetUserData(NULL);
+ delete pData;
+ // the data could be null because we have a table which isn't correct
+ m_pTreeModel->Remove(pTemp);
+ }
+ else
+ {
+ // remove the entry from the model
+ SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer);
+ while(pChild)
+ {
+ if (m_pTreeView->getListBox().GetEntryText(pChild) == aName)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData());
+ pChild->SetUserData(NULL);
+ delete pData;
+ m_pTreeModel->Remove(pChild);
+ break;
+ }
+ pChild = m_pTreeModel->NextSibling(pChild);
+ }
+ }
+
+ // maybe the object which is part of the document data source has been removed
+ checkDocumentDataSource();
+ }
+ else
+ SbaXDataBrowserController::elementRemoved(_rEvent);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEvent ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
+ SvLBoxEntry* pContainer = getEntryFromContainer(xNames);
+ if ( pContainer )
+ { // a table or query as been replaced
+ String aName = ::comphelper::getString(_rEvent.Accessor).getStr();
+
+ if ( isCurrentlyDisplayedChanged( aName, pContainer) )
+ { // the element displayed currently has been replaced
+
+ // we need to remember the old value
+ SvLBoxEntry* pTemp = m_pCurrentlyDisplayed;
+ unloadAndCleanup( sal_False ); // don't dispose the connection
+
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData());
+ if (pData)
+ {
+ if ( etTableOrView == pData->eType )
+ { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
+ _rEvent.Element >>= pData->xObjectProperties; // remember the new element
+ }
+ else
+ {
+ pTemp->SetUserData(NULL);
+ delete pData;
+ }
+ }
+ }
+ else
+ {
+ // find the entry for this name
+ SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer);
+ while(pChild)
+ {
+ if (m_pTreeView->getListBox().GetEntryText(pChild) == aName)
+ {
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData());
+ if (pData)
+ {
+ if ( etTableOrView == pData->eType )
+ { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
+ _rEvent.Element >>= pData->xObjectProperties; // remember the new element
+ }
+ else
+ {
+ pChild->SetUserData(NULL);
+ delete pData;
+ }
+ }
+ break;
+ }
+ pChild = m_pTreeModel->NextSibling(pChild);
+ }
+ }
+
+ // maybe the object which is part of the document data source has been removed
+ checkDocumentDataSource();
+ }
+ else if (xNames.get() == m_xDatabaseContext.get())
+ { // a datasource has been replaced in the context
+ OSL_FAIL("SbaTableQueryBrowser::elementReplaced: no support for replaced data sources!");
+ // very suspicious: the database context should not allow to replace data source, only to register
+ // and revoke them
+ }
+ else
+ SbaXDataBrowserController::elementReplaced(_rEvent);
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnection )
+{
+ // remove as event listener
+ Reference< XComponent > xComponent( _rxConnection, UNO_QUERY );
+ if ( xComponent.is() )
+ {
+ Reference< XEventListener > xListener( static_cast< ::cppu::OWeakObject* >( this ), UNO_QUERY );
+ xComponent->removeEventListener( xListener );
+ }
+
+ try
+ {
+ // temporary (hopefully!) hack for #i55274#
+ Reference< XFlushable > xFlush( _rxConnection, UNO_QUERY );
+ if ( xFlush.is() )
+ xFlush->flush();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // clear
+ _rxConnection.clear();
+ // will implicitly dispose if we have the ownership, since xConnection is a SharedConnection
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::disposeConnection( SvLBoxEntry* _pDSEntry )
+{
+ OSL_ENSURE( _pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" );
+ OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::disposeConnection: invalid entry (not top-level)!" );
+
+ if ( _pDSEntry )
+ {
+ DBTreeListUserData* pTreeListData = static_cast< DBTreeListUserData* >( _pDSEntry->GetUserData() );
+ if ( pTreeListData )
+ impl_releaseConnection( pTreeListData->xConnection );
+ }
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::closeConnection(SvLBoxEntry* _pDSEntry,sal_Bool _bDisposeConnection)
+{
+ OSL_ENSURE(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!");
+ OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!");
+
+ // if one of the entries of the given DS is displayed currently, unload the form
+ if (m_pCurrentlyDisplayed && (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == _pDSEntry))
+ unloadAndCleanup(_bDisposeConnection);
+
+ // collapse the query/table container
+ for (SvLBoxEntry* pContainers = m_pTreeModel->FirstChild(_pDSEntry); pContainers; pContainers= m_pTreeModel->NextSibling(pContainers))
+ {
+ SvLBoxEntry* pElements = m_pTreeModel->FirstChild(pContainers);
+ if ( pElements )
+ m_pTreeView->getListBox().Collapse(pContainers);
+ m_pTreeView->getListBox().EnableExpandHandler(pContainers);
+ // and delete their children (they are connection-relative)
+ for (; pElements; )
+ {
+ SvLBoxEntry* pRemove = pElements;
+ pElements= m_pTreeModel->NextSibling(pElements);
+ DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pRemove->GetUserData());
+ pRemove->SetUserData(NULL);
+ delete pData;
+ m_pTreeModel->Remove(pRemove);
+ }
+ }
+ // collapse the entry itself
+ m_pTreeView->getListBox().Collapse(_pDSEntry);
+
+ // dispose/reset the connection
+ if ( _bDisposeConnection )
+ disposeConnection( _pDSEntry );
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::unloadAndCleanup( sal_Bool _bDisposeConnection )
+{
+ if (!m_pCurrentlyDisplayed)
+ // nothing to do
+ return;
+
+ SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed);
+
+ // de-select the path for the currently displayed table/query
+ if (m_pCurrentlyDisplayed)
+ {
+ selectPath(m_pCurrentlyDisplayed, sal_False);
+ }
+ m_pCurrentlyDisplayed = NULL;
+
+ try
+ {
+ // get the active connection. We need to dispose it.
+ Reference< XPropertySet > xRowSetProps(getRowSet(),UNO_QUERY);
+ Reference< XConnection > xConn;
+ xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION) >>= xConn;
+#if OSL_DEBUG_LEVEL > 1
+ {
+ Reference< XComponent > xComp;
+ ::cppu::extractInterface(xComp, xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION));
+ }
+#endif
+
+ // unload the form
+ Reference< XLoadable > xLoadable = getLoadable();
+ if (xLoadable->isLoaded())
+ xLoadable->unload();
+
+ // clear the grid control
+ Reference< XNameContainer > xConta(getControlModel(),UNO_QUERY);
+ clearGridColumns(xConta);
+
+ // dispose the connection
+ if(_bDisposeConnection)
+ disposeConnection( pDSEntry );
+ }
+ catch(SQLException& e)
+ {
+ showError(SQLExceptionInfo(e));
+ }
+ catch(WrappedTargetException& e)
+ {
+ SQLException aSql;
+ if(e.TargetException >>= aSql)
+ showError(SQLExceptionInfo(aSql));
+ else
+ OSL_FAIL("SbaTableQueryBrowser::unloadAndCleanup: something strange happended!");
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::unloadAndCleanup: could not reset the form");
+ }
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ Reference< XInterface > lcl_getDataSource( const Reference< XNameAccess >& _rxDatabaseContext,
+ const ::rtl::OUString& _rDataSourceName, const Reference< XConnection >& _rxConnection )
+ {
+ Reference< XDataSource > xDataSource;
+ try
+ {
+ if ( _rDataSourceName.getLength() && _rxDatabaseContext->hasByName( _rDataSourceName ) )
+ xDataSource.set( _rxDatabaseContext->getByName( _rDataSourceName ), UNO_QUERY_THROW );
+
+ if ( !xDataSource.is() )
+ {
+ Reference< XChild > xConnAsChild( _rxConnection, UNO_QUERY );
+ if ( xConnAsChild.is() )
+ xDataSource.set( xConnAsChild->getParent(), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xDataSource.get();
+ }
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::impl_initialize()
+{
+ SolarMutexGuard aGuard;
+ // doin' a lot of VCL stuff here -> lock the SolarMutex
+
+ // first initialize the parent
+ SbaXDataBrowserController::impl_initialize();
+
+ Reference<XConnection> xForeignConnection;
+ Reference< XFrame > xFrame;
+
+ ::rtl::OUString aTableName, aCatalogName, aSchemaName;
+
+ sal_Bool bEsacpeProcessing = sal_True;
+ sal_Int32 nInitialDisplayCommandType = CommandType::COMMAND;
+ ::rtl::OUString sInitialDataSourceName;
+ ::rtl::OUString sInitialCommand;
+
+ const NamedValueCollection& rArguments( getInitParams() );
+
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_DATASOURCENAME, sInitialDataSourceName );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND_TYPE, nInitialDisplayCommandType );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND, sInitialCommand );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xForeignConnection );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_UPDATE_CATALOGNAME, aCatalogName );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_UPDATE_SCHEMANAME, aSchemaName );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_UPDATE_TABLENAME, aTableName );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, bEsacpeProcessing );
+ rArguments.get_ensureType( "Frame", xFrame );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_SHOWMENU, m_bShowMenu );
+
+ // disable the browser if either of ShowTreeViewButton (compatibility name) or EnableBrowser
+ // is present and set to FALSE
+ sal_Bool bDisableBrowser = ( sal_False == rArguments.getOrDefault( "ShowTreeViewButton", sal_True ) ) // compatibility name
+ || ( sal_False == rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ENABLE_BROWSER, sal_True ) );
+ OSL_ENSURE( !rArguments.has( "ShowTreeViewButton" ),
+ "SbaTableQueryBrowser::impl_initialize: ShowTreeViewButton is superseded by EnableBrowser!" );
+ m_bEnableBrowser = !bDisableBrowser;
+
+ // hide the tree view it is disabled in general, or if the settings tell to hide it initially
+ sal_Bool bHideTreeView = ( !m_bEnableBrowser )
+ || ( sal_False == rArguments.getOrDefault( "ShowTreeView", sal_True ) ) // compatibility name
+ || ( sal_False == rArguments.getOrDefault( (::rtl::OUString)PROPERTY_SHOW_BROWSER, sal_True ) );
+ OSL_ENSURE( !rArguments.has( "ShowTreeView" ),
+ "SbaTableQueryBrowser::impl_initialize: ShowTreeView is superseded by ShowBrowser!" );
+
+ if ( bHideTreeView )
+ hideExplorer();
+ else
+ showExplorer();
+
+ if ( m_bPreview )
+ {
+ try
+ {
+ Sequence< ::rtl::OUString> aProperties(5);
+ Sequence< Any> aValues(5);
+
+ ::rtl::OUString* pStringIter = aProperties.getArray();
+ Any* pValueIter = aValues.getArray();
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AlwaysShowCursor"));
+ *pValueIter++ <<= sal_False;
+ *pStringIter++ = PROPERTY_BORDER;
+ *pValueIter++ <<= sal_Int16(0);
+
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasNavigationBar"));
+ *pValueIter++ <<= sal_False;
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasRecordMarker"));
+ *pValueIter++ <<= sal_False;
+
+ *pStringIter++ = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tabstop"));
+ *pValueIter++ <<= sal_False;
+
+ Reference< XMultiPropertySet > xFormMultiSet(getFormComponent(), UNO_QUERY);
+ if ( xFormMultiSet.is() )
+ xFormMultiSet->setPropertyValues(aProperties, aValues);
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // are we loaded into a (sub)frame of an embedded document (i.e. a form belonging to a database
+ // document)?
+ sal_Bool bSubFrameOfEmbeddedDocument = sal_False;
+ if ( xFrame.is() )
+ {
+ Reference<XFramesSupplier> xSup = xFrame->getCreator();
+ Reference<XController> xCont = xSup.is() ? xSup->getController() : Reference<XController>();
+
+ bSubFrameOfEmbeddedDocument = xCont.is() && ::dbtools::isEmbeddedInDatabase( xCont->getModel(), xForeignConnection );
+ }
+
+ // if we have a connection at this point, it was either passed from outside, our
+ // determined from a outer DB document. In both cases, do not dispose it later on.
+ SharedConnection xConnection( xForeignConnection, SharedConnection::NoTakeOwnership );
+
+ // should we display all registered databases in the left hand side tree?
+ // or only *one* special?
+ sal_Bool bLimitedTreeEntries = sal_False;
+ // if we're part of a frame which is a secondary frame of a database document, then only
+ // display the database for this document, not all registered ones
+ bLimitedTreeEntries |= bSubFrameOfEmbeddedDocument;
+ // if the tree view is not to be displayed at all, then only display the data source
+ // which was given as initial selection
+ bLimitedTreeEntries |= ( m_bEnableBrowser != sal_True );
+
+ if ( bLimitedTreeEntries )
+ {
+ if ( xConnection.is() )
+ {
+ startConnectionListening( xConnection );
+
+ // if no initial name was given, try to obtain one from the data source
+ if ( !sInitialDataSourceName.getLength() )
+ {
+ Reference< XChild > xChild( xConnection, UNO_QUERY );
+ Reference< XPropertySet > xDataSourceProperties;
+ if ( xChild.is() )
+ xDataSourceProperties = xDataSourceProperties.query( xChild->getParent() );
+ if ( xDataSourceProperties.is() )
+ {
+ try
+ {
+ OSL_VERIFY( xDataSourceProperties->getPropertyValue( PROPERTY_NAME ) >>= sInitialDataSourceName );
+ }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "SbaTableQueryBrowser::impl_initialize: a connection parent which does not have a 'Name'!??" );
+ }
+ }
+ }
+ }
+
+ implAddDatasource( sInitialDataSourceName, xConnection );
+ m_pTreeView->getListBox().Expand( m_pTreeView->getListBox().First() );
+ }
+ else
+ initializeTreeModel();
+
+ if ( m_bEnableBrowser )
+ {
+ m_aDocScriptSupport = ::boost::optional< bool >( false );
+ }
+ else
+ {
+ // we are not used as "browser", but as mere view for a single table/query/command. In particular,
+ // there is a specific database document which we belong to.
+ Reference< XOfficeDatabaseDocument > xDocument( getDataSourceOrModel(
+ lcl_getDataSource( m_xDatabaseContext, sInitialDataSourceName, xConnection ) ), UNO_QUERY );
+ m_aDocScriptSupport = ::boost::optional< bool >( Reference< XEmbeddedScripts >( xDocument, UNO_QUERY ).is() );
+ }
+
+ if ( implSelect( sInitialDataSourceName, sInitialCommand, nInitialDisplayCommandType, bEsacpeProcessing, xConnection, sal_True ) )
+ {
+ try
+ {
+ Reference< XPropertySet > xRowSetProps(getRowSet(), UNO_QUERY);
+ xRowSetProps->setPropertyValue(PROPERTY_UPDATE_CATALOGNAME,makeAny(aCatalogName));
+ xRowSetProps->setPropertyValue(PROPERTY_UPDATE_SCHEMANAME,makeAny(aSchemaName));
+ xRowSetProps->setPropertyValue(PROPERTY_UPDATE_TABLENAME,makeAny(aTableName));
+
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("SbaTableQueryBrowser::impl_initialize: could not set the update related names!");
+ }
+ }
+
+ InvalidateAll();
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::haveExplorer() const
+{
+ return m_pTreeView && m_pTreeView->IsVisible();
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::hideExplorer()
+{
+ if (!haveExplorer())
+ return;
+ if (!getBrowserView())
+ return;
+
+ m_pTreeView->Hide();
+ m_pSplitter->Hide();
+ getBrowserView()->Resize();
+
+ InvalidateFeature(ID_BROWSER_EXPLORER);
+}
+
+// -------------------------------------------------------------------------
+void SbaTableQueryBrowser::showExplorer()
+{
+ if (haveExplorer())
+ return;
+
+ if (!getBrowserView())
+ return;
+
+ m_pTreeView->Show();
+ m_pSplitter->Show();
+ getBrowserView()->Resize();
+
+ InvalidateFeature(ID_BROWSER_EXPLORER);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection)
+{
+ SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(_pAnyEntry);
+ DBTreeListUserData* pDSData =
+ pDSEntry
+ ? static_cast<DBTreeListUserData*>(pDSEntry->GetUserData())
+ : NULL;
+
+ return ensureConnection( pDSEntry, pDSData, _rConnection );
+}
+
+// -----------------------------------------------------------------------------
+::std::auto_ptr< ImageProvider > SbaTableQueryBrowser::getImageProviderFor( SvLBoxEntry* _pAnyEntry )
+{
+ ::std::auto_ptr< ImageProvider > pImageProvider( new ImageProvider );
+ SharedConnection xConnection;
+ if ( getExistentConnectionFor( _pAnyEntry, xConnection ) )
+ pImageProvider.reset( new ImageProvider( xConnection ) );
+ return pImageProvider;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection )
+{
+ SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent( _pAnyEntry );
+ DBTreeListUserData* pDSData =
+ pDSEntry
+ ? static_cast< DBTreeListUserData* >( pDSEntry->GetUserData() )
+ : NULL;
+ if ( pDSData )
+ _rConnection = pDSData->xConnection;
+ return _rConnection.is();
+}
+
+#if OSL_DEBUG_LEVEL > 0
+// -----------------------------------------------------------------------------
+bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const
+{
+ return m_pTreeModel->GetRootLevelParent( _pEntry ) == _pEntry;
+}
+#endif
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::ensureConnection( SvLBoxEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection )
+{
+ OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" );
+ if(_pDSEntry)
+ {
+ DBTreeListUserData* pTreeListData = static_cast<DBTreeListUserData*>(pDSData);
+ ::rtl::OUString aDSName = GetEntryText(_pDSEntry);
+
+ if ( pTreeListData )
+ _rConnection = pTreeListData->xConnection;
+
+ if ( !_rConnection.is() && pTreeListData )
+ {
+ // show the "connecting to ..." status
+ String sConnecting(ModuleRes(STR_CONNECTING_DATASOURCE));
+ sConnecting.SearchAndReplaceAscii("$name$", aDSName);
+ BrowserViewStatusDisplay aShowStatus(static_cast<UnoDataBrowserView*>(getView()), sConnecting);
+
+ // build a string showing context information in case of error
+ String sConnectingContext( ModuleRes( STR_COULDNOTCONNECT_DATASOURCE ) );
+ sConnectingContext.SearchAndReplaceAscii("$name$", aDSName);
+
+ // connect
+ _rConnection.reset(
+ connect( getDataSourceAcessor( _pDSEntry ), sConnectingContext, NULL ),
+ SharedConnection::TakeOwnership
+ );
+
+ // remember the connection
+ pTreeListData->xConnection = _rConnection;
+ }
+ }
+
+ return _rConnection.is();
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData*, _pSortData )
+{
+ SvLBoxEntry* pLHS = static_cast<SvLBoxEntry*>(_pSortData->pLeft);
+ SvLBoxEntry* pRHS = static_cast<SvLBoxEntry*>(_pSortData->pRight);
+ OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
+ // we want the table entry and the end so we have to do a check
+
+ if (isContainer(pRHS))
+ {
+ // don't use getEntryType (directly or indirecly) for the LHS:
+ // LHS is currently beeing inserted, so it is not "completely valid" at the moment
+
+ const EntryType eRight = getEntryType(pRHS);
+ if (etTableContainer == eRight)
+ // every other container should be placed _before_ the bookmark container
+ return -1;
+
+ const String sLeft = m_pTreeView->getListBox().GetEntryText(pLHS);
+
+ EntryType eLeft = etTableContainer;
+ if (String(ModuleRes(RID_STR_TABLES_CONTAINER)) == sLeft)
+ eLeft = etTableContainer;
+ else if (String(ModuleRes(RID_STR_QUERIES_CONTAINER)) == sLeft)
+ eLeft = etQueryContainer;
+
+ if ( eLeft == eRight )
+ return COMPARE_EQUAL;
+
+ if ( ( eLeft == etTableContainer ) && ( eRight == etQueryContainer ) )
+ return COMPARE_GREATER;
+
+ if ( ( eLeft == etQueryContainer ) && ( eRight == etTableContainer ) )
+ return COMPARE_LESS;
+
+ OSL_FAIL( "SbaTableQueryBrowser::OnTreeEntryCompare: unexpected case!" );
+ return COMPARE_EQUAL;
+ }
+
+ SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
+
+ String sLeftText = pLeftTextItem->GetText();
+ String sRightText = pRightTextItem->GetText();
+
+ sal_Int32 nCompareResult = 0; // equal by default
+
+ if (m_xCollator.is())
+ {
+ try
+ {
+ nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ else
+ // default behaviour if we do not have a collator -> do the simple string compare
+ nCompareResult = sLeftText.CompareTo(sRightText);
+
+ return nCompareResult;
+}
+
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::implAdministrate( SvLBoxEntry* _pApplyTo )
+{
+ OSL_PRECOND( _pApplyTo, "SbaTableQueryBrowser::implAdministrate: illegal entry!" );
+ if ( !_pApplyTo )
+ return;
+
+ try
+ {
+ // get the desktop object
+ sal_Int32 nFrameSearchFlag = FrameSearchFlag::ALL | FrameSearchFlag::GLOBAL ;
+ Reference< XComponentLoader > xFrameLoader(getORB()->createInstance(SERVICE_FRAME_DESKTOP),UNO_QUERY);
+
+ if ( xFrameLoader.is() )
+ {
+ // the initial selection
+ SvLBoxEntry* pTopLevelSelected = _pApplyTo;
+ while (pTopLevelSelected && m_pTreeView->getListBox().GetParent(pTopLevelSelected))
+ pTopLevelSelected = m_pTreeView->getListBox().GetParent(pTopLevelSelected);
+ ::rtl::OUString sInitialSelection;
+ if (pTopLevelSelected)
+ sInitialSelection = getDataSourceAcessor( pTopLevelSelected );
+
+ Reference< XDataSource > xDataSource( getDataSourceByName( sInitialSelection, getView(), getORB(), NULL ) );
+ Reference< XModel > xDocumentModel( getDataSourceOrModel( xDataSource ), UNO_QUERY );
+
+ if ( xDocumentModel.is() )
+ {
+ Reference< XInteractionHandler > xInteractionHandler(
+ getORB()->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) ),
+ UNO_QUERY );
+ OSL_ENSURE( xInteractionHandler.is(), "SbaTableQueryBrowser::implAdministrate: no interaction handler available!" );
+
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "Model", xDocumentModel );
+ aLoadArgs.put( "InteractionHandler", xInteractionHandler );
+ aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
+
+ Sequence< PropertyValue > aLoadArgPV;
+ aLoadArgs >>= aLoadArgPV;
+
+ xFrameLoader->loadComponentFromURL(
+ xDocumentModel->getURL(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_default")),
+ nFrameSearchFlag,
+ aLoadArgPV
+ );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const
+{
+ const DBTreeListUserData* pData = static_cast< const DBTreeListUserData* >( _pEntry->GetUserData() );
+ if ( ( pData->eType == etDatasource ) && pData->sAccessor.Len() )
+ {
+ _rText = ::svt::OFileNotation( pData->sAccessor ).get( ::svt::OFileNotation::N_SYSTEM );
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const
+{
+ OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl,
+ "SbaTableQueryBrowser::getContextMenu: where does this come from?" );
+ if ( &m_pTreeView->getListBox() != &_rControl )
+ return NULL;
+
+ return new PopupMenu( ModuleRes( MENU_BROWSER_DEFAULTCONTEXT ) );
+}
+
+// -----------------------------------------------------------------------------
+IController& SbaTableQueryBrowser::getCommandController()
+{
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+::cppu::OInterfaceContainerHelper* SbaTableQueryBrowser::getContextMenuInterceptors()
+{
+ return &m_aContextMenuInterceptors;
+}
+
+// -----------------------------------------------------------------------------
+Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
+{
+ OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl,
+ "SbaTableQueryBrowser::getCurrentSelection: where does this come from?" );
+
+ if ( &m_pTreeView->getListBox() != &_rControl )
+ return Any();
+
+ SvLBoxEntry* pSelected = m_pTreeView->getListBox().FirstSelected();
+ if ( !pSelected )
+ return Any();
+
+ OSL_ENSURE( m_pTreeView->getListBox().NextSelected( pSelected ) == NULL,
+ "SbaTableQueryBrowser::getCurrentSelection: single-selection is expected here!" );
+
+ NamedDatabaseObject aSelectedObject;
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pSelected->GetUserData() );
+ aSelectedObject.Type = static_cast< sal_Int32 >( pData->eType );
+
+ switch ( aSelectedObject.Type )
+ {
+ case DatabaseObject::QUERY:
+ case DatabaseObject::TABLE:
+ aSelectedObject.Name = m_pTreeView->getListBox().GetEntryText( pSelected );
+ break;
+
+ case DatabaseObjectContainer::DATA_SOURCE:
+ case DatabaseObjectContainer::QUERIES:
+ case DatabaseObjectContainer::TABLES:
+ aSelectedObject.Name = getDataSourceAcessor( pSelected );
+ break;
+
+ default:
+ OSL_FAIL( "SbaTableQueryBrowser::getCurrentSelection: invalid (unexpected) object type!" );
+ break;
+ }
+
+ return makeAny( aSelectedObject );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand, sal_Bool& _bEscapeProcessing )
+{
+ _rCommand = ::rtl::OUString();
+ _bEscapeProcessing = sal_False;
+
+ try
+ {
+ // contain the dss (data source signature) of the form
+ ::rtl::OUString sDataSourceName;
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ Reference< XPropertySet > xRowsetProps( getRowSet(), UNO_QUERY );
+ ODataAccessDescriptor aDesc( xRowsetProps );
+ sDataSourceName = aDesc.getDataSource();
+ aDesc[ daCommand ] >>= sCommand;
+ aDesc[ daCommandType ] >>= nCommandType;
+
+ // do we need to do anything?
+ if ( CommandType::QUERY != nCommandType )
+ return sal_False;
+
+ // get the query object
+ Reference< XQueryDefinitionsSupplier > xSuppQueries;
+ Reference< XNameAccess > xQueries;
+ Reference< XPropertySet > xQuery;
+ m_xDatabaseContext->getByName( sDataSourceName ) >>= xSuppQueries;
+ if ( xSuppQueries.is() )
+ xQueries = xSuppQueries->getQueryDefinitions();
+ if ( xQueries.is() )
+ xQueries->getByName( sCommand ) >>= xQuery;
+ OSL_ENSURE( xQuery.is(), "SbaTableQueryBrowser::implGetQuerySignature: could not retrieve the query object!" );
+
+ // get the two properties we need
+ if ( xQuery.is() )
+ {
+ xQuery->getPropertyValue( PROPERTY_COMMAND ) >>= _rCommand;
+ _bEscapeProcessing = ::cppu::any2bool( xQuery->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) );
+ return sal_True;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_False;
+}
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( RuntimeException )
+{
+ if (aEvent.Frame == m_xCurrentFrameParent)
+ {
+ if(aEvent.Action == FrameAction_COMPONENT_DETACHING)
+ implRemoveStatusListeners();
+ else if (aEvent.Action == FrameAction_COMPONENT_REATTACHED)
+ connectExternalDispatches();
+ }
+ else
+ SbaXDataBrowserController::frameAction(aEvent);
+
+}
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _xColContainer)
+{
+ // first we have to clear the grid
+ Sequence< ::rtl::OUString > aNames = _xColContainer->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ Reference< XInterface > xColumn;
+ for (; pIter != pEnd;++pIter)
+ {
+ _xColContainer->getByName(*pIter) >>= xColumn;
+ _xColContainer->removeByName(*pIter);
+ ::comphelper::disposeComponent(xColumn);
+ }
+}
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
+{
+ if ( m_bShowMenu )
+ {
+ OGenericUnoController::loadMenu(_xFrame);
+ }
+ else if ( !m_bPreview )
+ {
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = getLayoutManager(_xFrame);
+
+ if ( xLayoutManager.is() )
+ {
+ xLayoutManager->lock();
+ xLayoutManager->createElement( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/toolbar" )));
+ xLayoutManager->unlock();
+ xLayoutManager->doLayout();
+ }
+ onLoadedMenu( xLayoutManager );
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SbaTableQueryBrowser::getPrivateTitle() const
+{
+ ::rtl::OUString sTitle;
+ if ( m_pCurrentlyDisplayed )
+ {
+ SvLBoxEntry* pContainer = m_pTreeModel->GetParent(m_pCurrentlyDisplayed);
+ // get the entry for the datasource
+ SvLBoxEntry* pConnection = implGetConnectionEntry(pContainer);
+ ::rtl::OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed);
+ sTitle = GetEntryText( pConnection );
+ INetURLObject aURL(sTitle);
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ sTitle = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_WITH_CHARSET);
+ if ( sName.getLength() )
+ {
+ sName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - "));
+ sName += sTitle;
+ sTitle = sName;
+ }
+ }
+
+ return sTitle;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SbaTableQueryBrowser::preReloadForm()
+{
+ sal_Bool bIni = sal_False;
+ if ( !m_pCurrentlyDisplayed )
+ {
+ // switch the grid to design mode while loading
+ getBrowserView()->getGridControl()->setDesignMode(sal_True);
+ // we had an invalid statement so we need to connect the column models
+ Reference<XPropertySet> xRowSetProps(getRowSet(),UNO_QUERY);
+ ::svx::ODataAccessDescriptor aDesc(xRowSetProps);
+ // extract the props
+ ::rtl::OUString sDataSource;
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ sal_Bool bEscapeProcessing = sal_True;
+ extractDescriptorProps(aDesc, sDataSource, sCommand, nCommandType, bEscapeProcessing);
+ if ( sDataSource.getLength() && sCommand.getLength() && (-1 != nCommandType) )
+ {
+ SvLBoxEntry* pDataSource = NULL;
+ SvLBoxEntry* pCommandType = NULL;
+ m_pCurrentlyDisplayed = getObjectEntry( sDataSource, sCommand, nCommandType, &pDataSource, &pCommandType, sal_True, SharedConnection() );
+ bIni = sal_True;
+ }
+ }
+ return bIni;
+}
+
+// -----------------------------------------------------------------------------
+void SbaTableQueryBrowser::postReloadForm()
+{
+ InitializeGridModel(getFormComponent());
+ LoadFinished(sal_True);
+}
+
+//------------------------------------------------------------------------------
+Reference< XEmbeddedScripts > SAL_CALL SbaTableQueryBrowser::getScriptContainer() throw (RuntimeException)
+{
+ // update our database document
+ Reference< XModel > xDocument;
+ try
+ {
+ Reference< XPropertySet > xCursorProps( getRowSet(), UNO_QUERY_THROW );
+ Reference< XConnection > xConnection( xCursorProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ), UNO_QUERY );
+ if ( xConnection.is() )
+ {
+ Reference< XChild > xChild( xConnection, UNO_QUERY_THROW );
+ Reference< XDocumentDataSource > xDataSource( xChild->getParent(), UNO_QUERY_THROW );
+ xDocument.set( xDataSource->getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ Reference< XEmbeddedScripts > xScripts( xDocument, UNO_QUERY );
+ OSL_ENSURE( xScripts.is() || !xDocument.is(),
+ "SbaTableQueryBrowser::getScriptContainer: invalid database document!" );
+ return xScripts;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
+{
+ if ( _Interceptor.is() )
+ m_aContextMenuInterceptors.addInterface( _Interceptor );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException)
+{
+ if ( _Interceptor.is() )
+ m_aContextMenuInterceptors.removeInterface( _Interceptor );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::registeredDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ implAddDatasource( _Event.Name, SharedConnection() );
+}
+
+//------------------------------------------------------------------------------
+void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const String& _rDataSourceName )
+{
+ // get the top-level representing the removed data source
+ SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().FirstChild( NULL );
+ while ( pDataSourceEntry )
+ {
+ if ( m_pTreeView->getListBox().GetEntryText( pDataSourceEntry ) == _rDataSourceName )
+ break;
+
+ pDataSourceEntry = m_pTreeView->getListBox().NextSibling( pDataSourceEntry );
+ }
+
+ OSL_ENSURE( pDataSourceEntry, "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: do not know this data source!" );
+ if ( !pDataSourceEntry )
+ return;
+
+ if ( isSelected( pDataSourceEntry ) )
+ { // a table or query belonging to the deleted data source is currently beeing displayed.
+ OSL_ENSURE( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) == pDataSourceEntry,
+ "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (1)!" );
+ unloadAndCleanup( sal_True );
+ }
+ else
+ OSL_ENSURE(
+ ( NULL == m_pCurrentlyDisplayed )
+ || ( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) != pDataSourceEntry ),
+ "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (2)!");
+
+ // delete any user data of the child entries of the to-be-removed entry
+ SvTreeEntryList* pList = m_pTreeModel->GetChildList( pDataSourceEntry );
+ if ( pList )
+ {
+ SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>( pList->First() );
+ while ( pEntryLoop )
+ {
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pEntryLoop->GetUserData() );
+ pEntryLoop->SetUserData( NULL );
+ delete pData;
+ pEntryLoop = static_cast< SvLBoxEntry* >( pList->Next() );
+ }
+ }
+
+ // remove the entry
+ DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() );
+ pDataSourceEntry->SetUserData( NULL );
+ delete pData;
+ m_pTreeModel->Remove( pDataSourceEntry );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::revokedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ impl_cleanupDataSourceEntry( _Event.Name );
+
+ // maybe the object which is part of the document data source has been removed
+ checkDocumentDataSource();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL SbaTableQueryBrowser::changedDatabaseLocation( const DatabaseRegistrationEvent& _Event ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // in case the data source was expanded, and connected, we need to clean it up
+ // for simplicity, just do as if the data source were completely removed and re-added
+ impl_cleanupDataSourceEntry( _Event.Name );
+ implAddDatasource( _Event.Name, SharedConnection() );
+}
+
+
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx
new file mode 100644
index 000000000000..36c89d858be5
--- /dev/null
+++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ColumnControlWindow.hxx"
+#include "FieldControls.hxx"
+#include <unotools/syslocale.hxx>
+#include <connectivity/dbtools.hxx>
+#include "UITools.hxx"
+#include "dbu_resource.hrc"
+
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+//========================================================================
+// OColumnControlWindow
+DBG_NAME(OColumnControlWindow)
+//========================================================================
+OColumnControlWindow::OColumnControlWindow(Window* pParent
+ ,const Reference<XMultiServiceFactory>& _rxFactory)
+ : OFieldDescControl(pParent,NULL)
+ , m_xORB(_rxFactory)
+ , m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ , m_bAutoIncrementEnabled(sal_True)
+{
+ DBG_CTOR(OColumnControlWindow,NULL);
+
+ setRightAligned();
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+}
+// -----------------------------------------------------------------------------
+OColumnControlWindow::~OColumnControlWindow()
+{
+
+ DBG_DTOR(OColumnControlWindow,NULL);
+}
+// -----------------------------------------------------------------------
+void OColumnControlWindow::ActivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OColumnControlWindow::DeactivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnControlWindow::CellModified(long /*nRow*/, sal_uInt16 /*nColId*/ )
+{
+ saveCurrentFieldDescData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::lang::Locale OColumnControlWindow::GetLocale() const
+{
+ return m_aLocale;
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
+{
+ if ( !m_xFormatter.is() )
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(m_xConnection, sal_True,m_xORB));
+
+ if ( xSupplier.is() )
+ {
+ // create a new formatter
+ m_xFormatter.set( m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return m_xFormatter;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
+{
+ return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
+{
+ return &m_aDestTypeInfo;
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> OColumnControlWindow::getMetaData()
+{
+ if ( m_xConnection.is() )
+ return m_xConnection->getMetaData();
+ return Reference< XDatabaseMetaData>();
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection> OColumnControlWindow::getConnection()
+{
+ return m_xConnection;
+}
+// -----------------------------------------------------------------------------
+void OColumnControlWindow::setConnection(const Reference< XConnection>& _xCon)
+{
+ m_xConnection = _xCon;
+ m_xFormatter = NULL;
+ m_aDestTypeInfoIndex.clear();
+ m_aDestTypeInfo.clear();
+
+ if ( m_xConnection.is() )
+ {
+ Init();
+
+ ::dbaui::fillTypeInfo(m_xConnection,m_sTypeNames,m_aDestTypeInfo,m_aDestTypeInfoIndex);
+ // read autoincrement value set in the datasource
+ ::dbaui::fillAutoIncrementValue(m_xConnection,m_bAutoIncrementEnabled,m_sAutoIncrementValue);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OColumnControlWindow::isAutoIncrementValueEnabled() const
+{
+ return m_bAutoIncrementEnabled;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OColumnControlWindow::getAutoIncrementValue() const
+{
+ return m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OColumnControlWindow::getDefaultTyp() const
+{
+ if ( !m_pTypeInfo.get() )
+ {
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+ }
+ return m_pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
new file mode 100644
index 000000000000..c30b36782582
--- /dev/null
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -0,0 +1,1941 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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"
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+
+#include "FieldDescControl.hxx"
+#include "FieldControls.hxx"
+#include <tools/diagnose_ex.h>
+#include "TableDesignHelpBar.hxx"
+#include <vcl/scrbar.hxx>
+#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/msgbox.hxx>
+#include <vector>
+#include "FieldDescriptions.hxx"
+#include "dlgattr.hxx"
+#include <svx/numfmtsh.hxx>
+#include <svx/svxids.hrc>
+#include <svx/algitem.hxx>
+#include <svl/itempool.hxx>
+#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svl/zforlist.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/rngitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/numuno.hxx>
+#include <svtools/transfer.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatPreviewer.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "QEnumTypes.hxx"
+#include "dbaccess_helpid.hrc"
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <comphelper/numbers.hxx>
+#include "UITools.hxx"
+#include <memory>
+#include "dbu_control.hrc"
+#include "dbu_tbl.hrc"
+#include <osl/diagnose.h>
+
+
+using namespace dbaui;
+using namespace dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::util;
+
+//==================================================================
+
+// fuer die Controls auf der OFieldDescGenPage
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 4
+#define CONTROL_WIDTH_1 160 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - 20 - 5)
+
+#define SBA_DEF_RANGEFORMAT (100 + 143) // RangeItem
+#define SBA_DEF_FMTVALUE (100 + 144) // SfxULONG, Format
+#define SBA_ATTR_ALIGN_HOR_JUSTIFY (100 + 145) // SvxHorJustifyItem
+
+#define HSCROLL_STEP 20
+
+
+namespace
+{
+ // -----------------------------------------------------------------------------
+ double checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference< ::com::sun::star::util::XNumberFormatter>& _xNumberFormatter)
+ {
+ double nValue = _nValue;
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(_xNumberFormatter,_nFormatKey);
+ if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE
+ || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
+ {
+ nValue = DBTypeConversion::toStandardDbDate(DBTypeConversion::getNULLDate(_xNumberFormatter->getNumberFormatsSupplier()),nValue);
+ }
+
+ return nValue;
+ }
+ // -----------------------------------------------------------------------------
+ template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText)
+ {
+ if ( *_pControl )
+ {
+ --_nPos;
+ (*_pControl)->Hide();
+ (*_pControlText)->Hide();
+ delete *_pControl;
+ delete *_pControlText;
+ (*_pControl) = NULL;
+ (*_pControlText) = NULL;
+ }
+ }
+
+}
+
+//==================================================================
+// class OFieldDescControl
+//==================================================================
+
+DBG_NAME(OFieldDescControl)
+
+//==================================================================
+OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar)
+ :TabPage( pParent, rResId )
+ ,pHelp( pHelpBar )
+ ,pLastFocusWindow(NULL)
+ ,m_pActFocusWindow(NULL)
+ ,pDefaultText(NULL)
+ ,pRequiredText(NULL)
+ ,pAutoIncrementText(NULL)
+ ,pTextLenText(NULL)
+ ,pNumTypeText(NULL)
+ ,pLengthText(NULL)
+ ,pScaleText(NULL)
+ ,pFormatText(NULL)
+ ,pBoolDefaultText(NULL)
+ ,m_pColumnNameText(NULL)
+ ,m_pTypeText(NULL)
+ ,m_pAutoIncrementValueText(NULL)
+ ,pRequired(NULL)
+ ,pNumType(NULL)
+ ,pAutoIncrement(NULL)
+ ,pDefault(NULL)
+ ,pTextLen(NULL)
+ ,pLength(NULL)
+ ,pScale(NULL)
+ ,pFormatSample(NULL)
+ ,pBoolDefault(NULL)
+ ,m_pColumnName(NULL)
+ ,m_pType(NULL)
+ ,m_pAutoIncrementValue(NULL)
+ ,pFormat(NULL)
+ ,m_pVertScroll( NULL )
+ ,m_pHorzScroll( NULL )
+ ,m_pPreviousType()
+ ,nCurChildId(1)
+ ,m_nPos(-1)
+ ,aYes(ModuleRes(STR_VALUE_YES))
+ ,aNo(ModuleRes(STR_VALUE_NO))
+ ,m_nOldVThumb( 0 )
+ ,m_nOldHThumb( 0 )
+ ,m_nWidth(50)
+ ,nDelayedGrabFocusEvent(0)
+ ,m_bAdded(sal_False)
+ ,m_bRightAligned(false)
+ ,pActFieldDescr(NULL)
+{
+ DBG_CTOR(OFieldDescControl,NULL);
+
+ Contruct();
+}
+//------------------------------------------------------------------------------
+OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar )
+ :TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL )
+ ,pHelp( pHelpBar )
+ ,pLastFocusWindow(NULL)
+ ,m_pActFocusWindow(NULL)
+ ,pDefaultText(NULL)
+ ,pRequiredText(NULL)
+ ,pAutoIncrementText(NULL)
+ ,pTextLenText(NULL)
+ ,pNumTypeText(NULL)
+ ,pLengthText(NULL)
+ ,pScaleText(NULL)
+ ,pFormatText(NULL)
+ ,pBoolDefaultText(NULL)
+ ,m_pColumnNameText(NULL)
+ ,m_pTypeText(NULL)
+ ,m_pAutoIncrementValueText(NULL)
+ ,pRequired(NULL)
+ ,pNumType(NULL)
+ ,pAutoIncrement(NULL)
+ ,pDefault(NULL)
+ ,pTextLen(NULL)
+ ,pLength(NULL)
+ ,pScale(NULL)
+ ,pFormatSample(NULL)
+ ,pBoolDefault(NULL)
+ ,m_pColumnName(NULL)
+ ,m_pType(NULL)
+ ,m_pAutoIncrementValue(NULL)
+ ,pFormat(NULL)
+ ,m_pVertScroll( NULL )
+ ,m_pHorzScroll( NULL )
+ ,m_pPreviousType()
+ ,nCurChildId(1)
+ ,m_nPos(-1)
+ ,aYes(ModuleRes(STR_VALUE_YES))
+ ,aNo(ModuleRes(STR_VALUE_NO))
+ ,m_nOldVThumb( 0 )
+ ,m_nOldHThumb( 0 )
+ ,m_nWidth(50)
+ ,nDelayedGrabFocusEvent(0)
+ ,m_bAdded(sal_False)
+ ,m_bRightAligned(false)
+ ,pActFieldDescr(NULL)
+{
+ DBG_CTOR(OFieldDescControl,NULL);
+ Contruct();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::Contruct()
+{
+ m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG);
+ m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG);
+ m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
+ m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
+ m_pVertScroll->Show();
+ m_pHorzScroll->Show();
+
+ m_pVertScroll->EnableClipSiblings();
+ m_pHorzScroll->EnableClipSiblings();
+
+ m_pVertScroll->SetLineSize(1);
+ m_pVertScroll->SetPageSize(1);
+ m_pHorzScroll->SetLineSize(1);
+ m_pHorzScroll->SetPageSize(1);
+
+ m_nOldVThumb = m_nOldHThumb = 0;
+}
+
+//------------------------------------------------------------------------------
+OFieldDescControl::~OFieldDescControl()
+{
+ DBG_DTOR(OFieldDescControl,NULL);
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pVertScroll);
+ m_pVertScroll = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHorzScroll);
+ m_pHorzScroll = NULL;
+ }
+ if ( m_bAdded )
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ pLastFocusWindow = NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpNumType );
+ DeactivateAggregate( tpScale );
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpBoolDefault );
+ DeactivateAggregate( tpColumnName );
+ DeactivateAggregate( tpType );
+ DeactivateAggregate( tpAutoIncrementValue );
+
+ if(nDelayedGrabFocusEvent)
+ Application::RemoveUserEvent(nDelayedGrabFocusEvent);
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::BoolStringPersistent(const String& rUIString) const
+{
+ static String aZero('0');
+ static String aOne('1');
+
+ if (rUIString == aNo)
+ return aZero;
+ if (rUIString == aYes)
+ return aOne;
+ return String();
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::BoolStringUI(const String& rPersistentString) const
+{
+ static String aZero('0');
+ static String aOne('1');
+ static String aNone(ModuleRes(STR_VALUE_NONE));
+
+ // aeltere Versionen haben eventuell einen sprachabhaengigen String als Default gespeichert
+ if (rPersistentString.Equals(aYes) || rPersistentString.Equals(aNo))
+ return rPersistentString;
+
+ if (rPersistentString == aZero)
+ return aNo;
+ if (rPersistentString == aOne)
+ return aYes;
+
+ return aNone;
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::Init()
+{
+ Reference< ::com::sun::star::util::XNumberFormatter > xFormatter = GetFormatter();
+ ::dbaui::setEvalDateFormatForFormatter(xFormatter);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnScroll, ScrollBar*, /*pBar*/)
+{
+ ScrollAllAggregates();
+ return 0;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ void getMaxXPosition(Window* _pWindow,long& _rnMaxXPosition)
+ {
+ if (_pWindow)
+ {
+ long nTemp = _pWindow->GetSizePixel().Width() + _pWindow->GetPosPixel().X();
+ _rnMaxXPosition = ::std::max(_rnMaxXPosition, nTemp);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::CheckScrollBars()
+{
+ // ein paar Berechnungen zur neuen Position der ScrollBars
+ Size szOverallSize = GetSizePixel();
+ long nHScrollHeight = m_pHorzScroll->GetSizePixel().Height();
+ long nVScrollWidth = m_pVertScroll->GetSizePixel().Width();
+
+ long nNewHWidth = szOverallSize.Width() - nVScrollWidth;
+ long nNewVHeight = szOverallSize.Height() - nHScrollHeight;
+
+ sal_Bool bNeedHScrollBar(sal_False), bNeedVScrollBar(sal_False);
+
+ // die Bereiche anpassen
+ // brauche ich ScrollBars eigentlich ?
+ // horizontal :
+ long lMaxXPosition = 0;
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(ppAggregates); ++i)
+ getMaxXPosition(ppAggregates[i],lMaxXPosition);
+
+ if (m_pHorzScroll)
+ lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP;
+
+ long lMaxXAvailable = szOverallSize.Width();
+ bNeedHScrollBar = lMaxXPosition > lMaxXAvailable;
+ // aendert sich vielleicht noch
+
+ // vertikal
+ // wieviel Controls habe ich
+ sal_uInt16 nActive = CountActiveAggregates();
+ // welches ist das letzte, was ganz drauf passt ?
+ sal_uInt16 nLastVisible;
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ if (bNeedHScrollBar)
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
+ else
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y) / (nControl_Spacing_y + nControlHeight));
+ bNeedVScrollBar = nActive>nLastVisible;
+
+ if (bNeedVScrollBar)
+ {
+ // in die urspruengliche Berechnung von lMaxXAvailable ist nicht mit eingegangen, dass ich eine VScrollBar habe, also muss ich
+ // das nachholen
+ lMaxXAvailable -= nVScrollWidth;
+ if (!bNeedHScrollBar && (lMaxXPosition > lMaxXAvailable))
+ {
+ // durch die vertikale brauche ich jetzt ploetzlich doch eine horizontale
+ bNeedHScrollBar = sal_True;
+ // nLastVisible anpassen
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
+ // bNeedVScrollBar aendert sich nicht : es ist schon auf sal_True und nLastVisible wird hoechstens kleiner
+ }
+ }
+
+ // jetzt kann ich sie wirklich positionieren und ihre Parameter setzen
+ if (bNeedVScrollBar)
+ {
+ m_pVertScroll->Show();
+ m_pVertScroll->SetRangeMax(nActive - nLastVisible);
+
+ m_pVertScroll->SetPosSizePixel( Point(nNewHWidth, 0), Size(nVScrollWidth, szOverallSize.Height()) );
+ }
+ else
+ {
+ m_pVertScroll->Hide();
+ m_pVertScroll->SetRangeMax(0);
+ m_pVertScroll->SetThumbPos(0);
+ }
+
+ if (bNeedHScrollBar)
+ {
+ m_pHorzScroll->Show();
+ m_pHorzScroll->SetRangeMax((lMaxXPosition - lMaxXAvailable + HSCROLL_STEP - 1 )/HSCROLL_STEP);
+
+ m_pHorzScroll->SetPosSizePixel( Point(0, nNewVHeight), Size(bNeedVScrollBar ? nNewHWidth : szOverallSize.Width(), nHScrollHeight) );
+ }
+ else
+ {
+ m_pHorzScroll->Hide();
+ m_pHorzScroll->SetRangeMax(0);
+ m_pHorzScroll->SetThumbPos(0);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::Resize()
+{
+ CheckScrollBars();
+ ScrollAllAggregates();
+}
+
+//------------------------------------------------------------------------------
+inline void OFieldDescControl::ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY)
+{
+ if (!pText)
+ return;
+ pText->SetPosPixel(pText->GetPosPixel() + Point(nDeltaX, nDeltaY));
+ pInput->SetPosPixel(pInput->GetPosPixel() + Point(nDeltaX, nDeltaY));
+ if (pButton)
+ pButton->SetPosPixel(pButton->GetPosPixel() + Point(nDeltaX, nDeltaY));
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::ScrollAllAggregates()
+{
+ long nDeltaX = 0, nDeltaY = 0;
+ if (m_nOldHThumb != m_pHorzScroll->GetThumbPos())
+ {
+ nDeltaX = (m_nOldHThumb - m_pHorzScroll->GetThumbPos()) * HSCROLL_STEP;
+ m_nOldHThumb = m_pHorzScroll->GetThumbPos();
+ }
+
+ if (m_nOldVThumb != m_pVertScroll->GetThumbPos())
+ {
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (nControl_Spacing_y + nControlHeight);
+ m_nOldVThumb = m_pVertScroll->GetThumbPos();
+ }
+
+ if (nDeltaX || nDeltaY)
+ {
+ Control* ppAggregates[] = { pRequired, pNumType
+ , pAutoIncrement, pDefault
+ , pTextLen, pLength
+ , pScale, m_pColumnName
+ , m_pType, m_pAutoIncrementValue};
+ Control* ppAggregatesText[] = { pRequiredText, pNumTypeText
+ , pAutoIncrementText, pDefaultText
+ , pTextLenText, pLengthText
+ , pScaleText, m_pColumnNameText
+ , m_pTypeText, m_pAutoIncrementValueText};
+ OSL_ENSURE(SAL_N_ELEMENTS(ppAggregates) == SAL_N_ELEMENTS(ppAggregatesText),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(ppAggregates); ++i)
+ ScrollAggregate(ppAggregatesText[i],ppAggregates[i],NULL,nDeltaX, nDeltaY);
+
+ ScrollAggregate(pFormatText,pFormatSample,pFormat,nDeltaX, nDeltaY);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 OFieldDescControl::CountActiveAggregates() const
+{
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ sal_uInt16 nVisibleAggregates = 0;
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(ppAggregates); ++i)
+ if (ppAggregates[i])
+ ++nVisibleAggregates;
+ return nVisibleAggregates;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OFieldDescControl::GetMaxControlHeight() const
+{
+ Size aHeight;
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(ppAggregates); ++i)
+ {
+ if ( ppAggregates[i] )
+ {
+ const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ }
+ }
+
+ return aHeight.Height();
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls enablen/disablen
+ Control* ppAggregates[] = { pRequired, pNumType
+ , pAutoIncrement, pDefault
+ , pTextLen, pLength
+ , pScale, m_pColumnName
+ , m_pType, m_pAutoIncrementValue
+ , pFormat};
+ Control* ppAggregatesText[] = { pRequiredText, pNumTypeText
+ , pAutoIncrementText, pDefaultText
+ , pTextLenText, pLengthText
+ , pScaleText, m_pColumnNameText
+ , m_pTypeText, m_pAutoIncrementValueText
+ , pFormatText};
+
+ OSL_ENSURE(SAL_N_ELEMENTS(ppAggregates) == SAL_N_ELEMENTS(ppAggregatesText),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(ppAggregates); ++i)
+ {
+ if ( ppAggregatesText[i] )
+ ppAggregatesText[i]->Enable( !bReadOnly );
+ if ( ppAggregates[i] )
+ ppAggregates[i]->Enable( !bReadOnly );
+ }
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::GetControlText( sal_uInt16 nControlId )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls auslesen
+ switch( nControlId )
+ {
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ if (pBoolDefault)
+ return pBoolDefault->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_DEFAULT:
+ if (pDefault)
+ return pDefault->GetText();
+ break;
+ case FIELD_PROPERTY_REQUIRED:
+ if (pRequired)
+ return pRequired->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_TEXTLEN:
+ if (pTextLen)
+ return String::CreateFromInt64(pTextLen->GetValue());
+ case FIELD_PROPERTY_NUMTYPE:
+ if (pNumType)
+ return pNumType->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_AUTOINC:
+ if (pAutoIncrement)
+ return pAutoIncrement->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_LENGTH:
+ if (pLength)
+ return pLength->GetText();
+ break;
+ case FIELD_PROPERTY_SCALE:
+ if (pScale)
+ return pScale->GetText();
+ break;
+ case FIELD_PROPERTY_FORMAT:
+ if (pFormatSample)
+ return pFormatSample->GetText();
+ break;
+ case FIELD_PRPOERTY_COLUMNNAME:
+ if(m_pColumnName)
+ return m_pColumnName->GetText();
+ case FIELD_PRPOERTY_TYPE:
+ if(m_pType)
+ return m_pType->GetSelectEntry();
+ break;
+ case FIELD_PRPOERTY_AUTOINCREMENT:
+ if(m_pAutoIncrementValue)
+ return m_pAutoIncrementValue->GetText();
+ }
+
+ return String();
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetControlText( sal_uInt16 nControlId, const String& rText )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls setzen
+ switch( nControlId )
+ {
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ if (pBoolDefault)
+ {
+ String sOld = pBoolDefault->GetSelectEntry();
+ pBoolDefault->SelectEntry(rText);
+ if (!sOld.Equals(rText))
+ LINK(this, OFieldDescControl, ChangeHdl).Call(pBoolDefault);
+ }
+ break;
+ case FIELD_PROPERTY_DEFAULT:
+ if (pDefault)
+ {
+ pDefault->SetText(rText);
+ UpdateFormatSample(pActFieldDescr);
+ }
+ break;
+
+ case FIELD_PROPERTY_REQUIRED:
+ if (pRequired)
+ pRequired->SelectEntry(rText);
+ break;
+
+
+ case FIELD_PROPERTY_TEXTLEN:
+ if (pTextLen)
+ pTextLen->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ if (pNumType)
+ pNumType->SelectEntry(rText);
+ break;
+
+ case FIELD_PROPERTY_AUTOINC:
+ if (pAutoIncrement)
+ {
+ String sOld = pAutoIncrement->GetSelectEntry();
+ pAutoIncrement->SelectEntry(rText);
+ if (!sOld.Equals(rText))
+ LINK(this, OFieldDescControl, ChangeHdl).Call(pAutoIncrement);
+ }
+ break;
+
+ case FIELD_PROPERTY_LENGTH:
+ if (pLength)
+ pLength->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_SCALE:
+ if (pScale)
+ pScale->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ if (pActFieldDescr)
+ UpdateFormatSample(pActFieldDescr);
+ break;
+ case FIELD_PRPOERTY_COLUMNNAME:
+ if(m_pColumnName)
+ m_pColumnName->SetText(rText);
+ break;
+ case FIELD_PRPOERTY_TYPE:
+ if(m_pType)
+ m_pType->SelectEntry(rText);
+ break;
+ case FIELD_PRPOERTY_AUTOINCREMENT:
+ if(m_pAutoIncrementValue)
+ m_pAutoIncrementValue->SetText(rText);
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( OFieldDescControl, FormatClickHdl, Button *, /*pButton*/ )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Temporaere Column erzeugen, mit der Datenaustausch mit Dialog erfolgt
+ if( !pActFieldDescr )
+ return 0;
+
+ sal_Int32 nOldFormatKey(pActFieldDescr->GetFormatKey());
+ SvxCellHorJustify rOldJustify = pActFieldDescr->GetHorJustify();
+ Reference< XNumberFormatsSupplier > xSupplier = GetFormatter()->getNumberFormatsSupplier();
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+
+ SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
+ sal_uInt16 nFlags;
+ if(::dbaui::callColumnFormatDialog(this,pFormatter,pActFieldDescr->GetType(),nOldFormatKey,rOldJustify,nFlags,sal_True))
+ {
+ sal_Bool bModified = sal_False;
+ if(nOldFormatKey != pActFieldDescr->GetFormatKey())
+ {
+ pActFieldDescr->SetFormatKey( nOldFormatKey );
+ bModified = sal_True;
+ }
+ if(rOldJustify != pActFieldDescr->GetHorJustify())
+ {
+ pActFieldDescr->SetHorJustify( rOldJustify );
+ bModified = sal_True;
+ }
+
+ if(bModified)
+ {
+ SetModified(sal_True);
+ UpdateFormatSample(pActFieldDescr);
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+void OFieldDescControl::SetModified(sal_Bool /*bModified*/)
+{
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OFieldDescControl, ChangeHdl, ListBox *, pListBox )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ if ( !pActFieldDescr )
+ return 0;
+
+ if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
+ SetModified(sal_True);
+
+ // Sonderbehandlund f"ur Bool Felder
+ if(pListBox == pRequired && pBoolDefault )
+ {
+ // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
+ String sDef = BoolStringUI(::comphelper::getString(pActFieldDescr->GetControlDefault()));
+
+ if(pRequired->GetSelectEntryPos() == 0) // JA
+ {
+ pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
+ if (!sDef.Equals(aYes) && !sDef.Equals(aNo))
+ pBoolDefault->SelectEntryPos(1); // nein als Default
+ else
+ pBoolDefault->SelectEntry(sDef);
+ }
+ else if(pBoolDefault->GetEntryCount() < 3)
+ {
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->SelectEntry(sDef);
+ }
+ }
+
+ // nur fuer AutoIncrement eine Sonderbehandlung
+ if (pListBox == pAutoIncrement)
+ {
+ if(pListBox->GetSelectEntryPos() == 1)
+ { // no
+ DeactivateAggregate( tpAutoIncrementValue );
+ if(pActFieldDescr->IsPrimaryKey())
+ DeactivateAggregate( tpRequired );
+ else if( pActFieldDescr->getTypeInfo()->bNullable )
+ {
+ ActivateAggregate( tpRequired );
+ if(pRequired)
+ {
+ if( pActFieldDescr->IsNullable() )
+ pRequired->SelectEntryPos( 1 ); // no
+ else
+ pRequired->SelectEntryPos( 0 ); // yes
+ }
+ }
+ ActivateAggregate( tpDefault );
+ }
+ else
+ {
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ ActivateAggregate( tpAutoIncrementValue );
+ }
+ // und jetzt alle nach oben schieben
+ ArrangeAggregates();
+ }
+
+ if(pListBox == m_pType)
+ {
+ TOTypeInfoSP pTypeInfo = getTypeInfo(m_pType->GetSelectEntryPos());
+ pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False); // SetType(pTypeInfo);
+
+ DisplayData(pActFieldDescr);
+ CellModified(-1, m_pType->GetPos());
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+// alle Control neu anordnen, so dass sie in fester Reihenfolge und wirklich
+// OBEN auf der DescriptionPage stehen
+void OFieldDescControl::ArrangeAggregates()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ // die Beschreibung eines Controls
+ struct AGGREGATE_DESCRIPTION
+ {
+ Control* pctrlInputControl; // das eigentliche Control zur Eingabe
+ Control* pctrlTextControl; // das Label dazu
+ sal_uInt16 nPosSizeArgument; // das zweite Argument fuer SetPosSize
+ };
+ AGGREGATE_DESCRIPTION adAggregates[] = {
+ { m_pColumnName, m_pColumnNameText, 1},
+ { m_pType, m_pTypeText, 1},
+ { pAutoIncrement, pAutoIncrementText, 1 },
+ { m_pAutoIncrementValue, m_pAutoIncrementValueText, 3 },
+ { pNumType, pNumTypeText, 1 },
+ { pRequired, pRequiredText, 1 },
+ { pTextLen, pTextLenText, 1 },
+ { pLength, pLengthText, 1 },
+ { pScale, pScaleText, 1 },
+ { pDefault, pDefaultText, 3 },
+ { pFormatSample, pFormatText, 4 },
+ { pBoolDefault, pBoolDefaultText, 1 },
+ };
+
+ long nMaxWidth = 0;
+ for (size_t i=0; i < SAL_N_ELEMENTS(adAggregates); i++)
+ {
+ if (adAggregates[i].pctrlTextControl)
+ {
+ nMaxWidth = ::std::max<long>(OutputDevice::GetTextWidth(adAggregates[i].pctrlTextControl->GetText()),nMaxWidth);
+ }
+ }
+
+ OSL_ENSURE(nMaxWidth != 0,"Invalid width!");
+
+ // und los ...
+ int nCurrentControlPos = 0;
+ Control* pZOrderPredecessor = NULL;
+ for (size_t i=0; i < SAL_N_ELEMENTS(adAggregates); i++)
+ {
+ if (adAggregates[i].pctrlInputControl)
+ {
+ SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0);
+ SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument);
+
+ // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie
+ // hier angeordnet wurden
+ adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST);
+ adAggregates[i].pctrlInputControl->SetZOrder(adAggregates[i].pctrlTextControl, WINDOW_ZORDER_BEHIND );
+ pZOrderPredecessor = adAggregates[i].pctrlInputControl;
+
+ if (adAggregates[i].pctrlInputControl == pFormatSample)
+ {
+ pFormat->SetZOrder(pZOrderPredecessor, WINDOW_ZORDER_BEHIND);
+ pZOrderPredecessor = pFormat;
+ }
+
+ ++nCurrentControlPos;
+ }
+ }
+
+ // eine Sonderbehandlung fuer die Format-Controls
+ if (pFormat)
+ {
+ Point ptSamplePos(pFormatSample->GetPosPixel());
+ Size szSampleSize(pFormatSample->GetSizePixel());
+ pFormat->SetPosPixel(Point(ptSamplePos.X() + szSampleSize.Width() + 5, ptSamplePos.Y()));
+ }
+
+ // als letztes noch die ScrollBars in der ZOrder ganz nach oben
+ m_pVertScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+ m_pHorzScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::ActivateAggregate( EControlType eType )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls erzeugen
+ switch( eType )
+ {
+ case tpDefault:
+ if( pDefault )
+ return;
+ m_nPos++;
+ pDefaultText = CreateText(STR_DEFAULT_VALUE);
+ pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER );
+ InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false);
+ break;
+ case tpAutoIncrementValue:
+ if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() )
+ return;
+ m_nPos++;
+ m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE);
+ m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER );
+ m_pAutoIncrementValue->SetText( getAutoIncrementValue() );
+ InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false);
+ break;
+
+ case tpRequired:
+ {
+ if( pRequired )
+ return;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData();
+
+ if(xMetaData.is() && xMetaData->supportsNonNullableColumns())
+ {
+ m_nPos++;
+ pRequiredText = CreateText(STR_FIELD_REQUIRED);
+ pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN);
+
+ pRequired->InsertEntry( aYes );
+ pRequired->InsertEntry( aNo );
+ pRequired->SelectEntryPos(1);
+
+ InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true);
+ }
+ }
+ break;
+ case tpAutoIncrement:
+ {
+ if( pAutoIncrement )
+ return;
+ m_nPos++;
+ pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT);
+ pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN );
+ pAutoIncrement->InsertEntry( aYes );
+ pAutoIncrement->InsertEntry( aNo );
+ pAutoIncrement->SelectEntryPos(0);
+ InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true);
+ }
+ break;
+ case tpTextLen:
+ if( pTextLen )
+ return;
+ m_nPos++;
+ pTextLenText = CreateText(STR_TEXT_LENGTH);
+ pTextLen = CreateNumericControl(STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN,HID_TAB_ENT_TEXT_LEN);
+ break;
+
+ case tpType:
+ if( m_pType)
+ return;
+ m_nPos++;
+ m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE);
+ m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN );
+ m_pType->SetDropDownLineCount(20);
+ {
+ const OTypeInfoMap* pTypeInfo = getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter)
+ m_pType->InsertEntry( aIter->second->aUIName );
+ }
+ m_pType->SelectEntryPos(0);
+ InitializeControl(m_pType,HID_TAB_ENT_TYPE,true);
+ break;
+ case tpColumnName:
+ if( m_pColumnName )
+ return;
+ m_nPos++;
+ {
+ sal_uInt32 nMax = EDIT_NOLIMIT;
+ ::rtl::OUString aTmpString;
+ try
+ {
+ Reference< XDatabaseMetaData> xMetaData = getMetaData();
+ if ( xMetaData.is() )
+ {
+ nMax = xMetaData->getMaxColumnNameLength();
+ aTmpString = xMetaData->getExtraNameCharacters();
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME);
+ m_pColumnName = new OPropColumnEditCtrl( this,
+ aTmpString,
+ STR_HELP_DEFAULT_VALUE,
+ FIELD_PRPOERTY_COLUMNNAME,
+ WB_BORDER );
+ m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT));
+ m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) );
+ }
+
+ InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false);
+ break;
+ case tpNumType:
+ if( pNumType )
+ return;
+ m_nPos++;
+ pNumTypeText = CreateText(STR_NUMERIC_TYPE);
+
+ pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN );
+ pNumType->SetDropDownLineCount(5);
+
+ pNumType->InsertEntry( String::CreateFromAscii("Byte") );
+ pNumType->InsertEntry( String::CreateFromAscii("SmallInt") );
+ pNumType->InsertEntry( String::CreateFromAscii("Integer") );
+ pNumType->InsertEntry( String::CreateFromAscii("Single") );
+ pNumType->InsertEntry( String::CreateFromAscii("Double") );
+ pNumType->SelectEntryPos(2);
+ InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true);
+ break;
+
+ case tpLength:
+ if( pLength )
+ return;
+ m_nPos++;
+ pLengthText = CreateText(STR_LENGTH);
+ pLength = CreateNumericControl(STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH,HID_TAB_ENT_LEN);
+ break;
+
+ case tpScale:
+ if( pScale )
+ return;
+ m_nPos++;
+ pScaleText = CreateText(STR_SCALE);
+ pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE);
+ break;
+
+ case tpFormat:
+ if (!pFormat)
+ {
+ m_nPos++;
+ pFormatText = CreateText(STR_FORMAT);
+
+ pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER );
+ pFormatSample->SetReadOnly(sal_True);
+ pFormatSample->Enable(sal_False);
+ InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false);
+
+ pFormat = new PushButton( this, ModuleRes(PB_FORMAT) );
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ pFormat->SetSizePixel(Size(nControlHeight, nControlHeight));
+ pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) );
+ InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false);
+ }
+
+ UpdateFormatSample(pActFieldDescr);
+ break;
+ case tpBoolDefault:
+ if (pBoolDefault)
+ return;
+
+ m_nPos++;
+ pBoolDefaultText = CreateText(STR_DEFAULT_VALUE);
+ pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN );
+ pBoolDefault->SetDropDownLineCount(3);
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->InsertEntry(aYes);
+ pBoolDefault->InsertEntry(aNo);
+
+ InitializeControl(pBoolDefault,HID_TAB_ENT_BOOL_DEFAULT,false);
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::InitializeControl(Control* _pControl,const ::rtl::OString& _sHelpId,bool _bAddChangeHandler)
+{
+ _pControl->SetHelpId(_sHelpId);
+ if ( _bAddChangeHandler )
+ ((OPropListBoxCtrl*)_pControl)->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl));
+
+ _pControl->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot));
+ _pControl->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost));
+ _pControl->EnableClipSiblings();
+}
+// -----------------------------------------------------------------------------
+FixedText* OFieldDescControl::CreateText(sal_uInt16 _nTextRes)
+{
+ FixedText* pFixedText = new FixedText( this );
+ pFixedText->SetText( ModuleRes(_nTextRes) );
+ pFixedText->EnableClipSiblings();
+ return pFixedText;
+}
+// -----------------------------------------------------------------------------
+OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId)
+{
+ OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER );
+ pControl->SetDecimalDigits(0);
+ pControl->SetMin(0);
+ pControl->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig
+ pControl->SetStrictFormat(sal_True);
+
+ InitializeControl(pControl,_sHelpId,false);
+
+ return pControl;
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::DeactivateAggregate( EControlType eType )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ pLastFocusWindow = NULL;
+ //////////////////////////////////////////////////////////////////////
+ // Controls zerstoeren
+ switch( eType )
+ {
+ case tpDefault:
+ lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText);
+ break;
+
+ case tpAutoIncrementValue:
+ lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText);
+ break;
+
+ case tpColumnName:
+ lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText);
+ break;
+
+ case tpType:
+ lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText);
+ break;
+
+ case tpAutoIncrement:
+ lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText);
+ break;
+
+ case tpRequired:
+ lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText);
+ break;
+
+ case tpTextLen:
+ lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText);
+ break;
+
+ case tpNumType:
+ lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText);
+ break;
+
+ case tpLength:
+ lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText);
+ break;
+
+ case tpScale:
+ lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText);
+ break;
+
+ case tpFormat:
+ // TODO: we have to check if we have to increment m_nPos again
+ lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText);
+ if ( pFormatSample )
+ {
+ pFormatSample->Hide();
+ delete pFormatSample;
+ pFormatSample = NULL;
+ }
+ break;
+ case tpBoolDefault:
+ lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText);
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+
+ //////////////////////////////////////////////////////////////////////
+ // Groesse ermitteln
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ Size aSize(0,nControlHeight);
+ if ( isRightAligned() && nCol )
+ aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width();
+ else
+ {
+ switch( nCol )
+ {
+ case 0:
+ default:
+ aSize.Width() = CONTROL_WIDTH_1;
+ break;
+ case 1:
+ aSize.Width() = CONTROL_WIDTH_2;
+ break;
+ case 3:
+ aSize.Width() = CONTROL_WIDTH_3;
+ break;
+ case 4:
+ aSize.Width() = CONTROL_WIDTH_4;
+ break;
+ }
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Position ermitteln
+ Point aPosition;
+ switch( nCol )
+ {
+ case 0:
+ aPosition.X() = 0;
+ aPosition.Y() = 1;
+ break;
+ case 1:
+ case 3:
+ case 4:
+ if ( isRightAligned() )
+ {
+ Size aOwnSize = GetSizePixel();
+ aPosition.X() = aOwnSize.Width() - aSize.Width();
+ }
+ else
+ aPosition.X() = CONTROL_WIDTH_1 + CONTROL_SPACING_X;
+ break;
+ default:
+ aPosition.X() = 0;
+ }
+
+ (*ppControl)->SetSizePixel( aSize );
+ aSize = (*ppControl)->GetSizePixel( );
+
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ aPosition.Y() += ((nRow+1)*nControl_Spacing_y) +
+ (nRow*nControlHeight);
+
+ //////////////////////////////////////////////////////////////////////
+ // Control anzeigen
+ (*ppControl)->SetPosSizePixel( aPosition, aSize );
+ aSize = (*ppControl)->GetSizePixel();
+
+ (*ppControl)->Show();
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ pActFieldDescr = pFieldDescr;
+ if(!pFieldDescr)
+ {
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpNumType );
+ DeactivateAggregate( tpScale );
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpBoolDefault );
+ DeactivateAggregate( tpColumnName );
+ DeactivateAggregate( tpType );
+ DeactivateAggregate( tpAutoIncrementValue );
+ m_pPreviousType = TOTypeInfoSP();
+ //////////////////////////////////////////////////////////////////////
+ // Zeiger des gespeicherten Focus zuruecksetzen
+ pLastFocusWindow = NULL;
+ if ( m_bAdded )
+ {
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_bAdded = sal_False;
+ }
+ return;
+ }
+
+ if ( !m_bAdded )
+ {
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::AddWindow));
+ m_bAdded = sal_True;
+ }
+
+ TOTypeInfoSP pFieldType;
+ if( pFieldDescr )
+ pFieldType = pFieldDescr->getTypeInfo();
+
+ ActivateAggregate( tpColumnName );
+ ActivateAggregate( tpType );
+
+ OSL_ENSURE(pFieldType.get(),"We need a type information here!");
+ //////////////////////////////////////////////////////////////////////
+ // Wenn sich der Typ geaendert hat, Controls austauschen
+ if( m_pPreviousType != pFieldType )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Zeiger des gespeicherten Focus zuruecksetzen
+ pLastFocusWindow = NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls, die nicht mehr angezeigt werden duerfen
+ DeactivateAggregate( tpNumType );
+
+ //////////////////////////////////////////////////////////////////////
+ // determine which controls we should show and which not
+
+ // 1. the required control
+ if ( pFieldType->bNullable )
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+
+ // 2. the autoincrement
+ if ( pFieldType->bAutoIncrement )
+ {
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ ActivateAggregate( tpAutoIncrement );
+ ActivateAggregate( tpAutoIncrementValue );
+ }
+ else
+ {
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpAutoIncrementValue );
+ if(pFieldType->bNullable)
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+ ActivateAggregate( tpDefault );
+ }
+ // 3. the scale and precision
+ if (pFieldType->nPrecision)
+ {
+ ActivateAggregate( tpLength );
+ pLength->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
+ pLength->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
+ }
+ else
+ DeactivateAggregate( tpLength );
+
+ if (pFieldType->nMaximumScale)
+ {
+ ActivateAggregate( tpScale );
+ pScale->SetMax(::std::max<sal_Int32>(pFieldType->nMaximumScale,pFieldDescr->GetScale()));
+ pScale->SetMin(pFieldType->nMinimumScale);
+ static const ::rtl::OUString s_sPRECISION(RTL_CONSTASCII_USTRINGPARAM("PRECISION"));
+ pScale->SetSpecialReadOnly(pFieldType->aCreateParams.getLength() == 0 || pFieldType->aCreateParams == s_sPRECISION);
+ }
+ else
+ DeactivateAggregate( tpScale );
+
+ // and now look for type specific things
+ switch( pFieldType->nType )
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpDefault );
+ ActivateAggregate( tpFormat );
+ if (pFieldType->nPrecision)
+ {
+ ActivateAggregate( tpTextLen );
+ pTextLen->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
+ pTextLen->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
+ }
+ else
+ DeactivateAggregate( tpTextLen );
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ DeactivateAggregate( tpLength ); // we don't need a length for date types
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpDefault );
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::BIT:
+ if ( pFieldType->aCreateParams.getLength() )
+ {
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+ break;
+ }
+ // run through
+ case DataType::BOOLEAN:
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpDefault );
+
+ ActivateAggregate( tpBoolDefault );
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::DOUBLE:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::REAL:
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::SQLNULL:
+ case DataType::OBJECT:
+ case DataType::DISTINCT:
+ case DataType::STRUCT:
+ case DataType::ARRAY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::REF:
+ case DataType::OTHER:
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ break;
+ default:
+ OSL_FAIL("Unknown type");
+ }
+ m_pPreviousType = pFieldType;
+ }
+ if(pFieldDescr)
+ {
+ if(pFieldDescr->IsPrimaryKey())
+ {
+ DeactivateAggregate( tpRequired );
+ }
+ else if ( !pAutoIncrement && pFieldType.get() )
+ {
+ if ( pFieldType->bNullable )
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Controls initialisieren
+ if( pAutoIncrement )
+ {
+ if ( pFieldDescr->IsAutoIncrement() )
+ {
+ pAutoIncrement->SelectEntryPos( 0 ); // yes
+ ActivateAggregate( tpAutoIncrementValue );
+ if ( m_pAutoIncrementValue )
+ m_pAutoIncrementValue->SetText(pFieldDescr->GetAutoIncrementValue());
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ }
+ else
+ {
+ // disable autoincrement value because it should only be visible when autoincrement is to true
+ DeactivateAggregate( tpAutoIncrementValue );
+ pAutoIncrement->SelectEntryPos( 1 ); // no
+ ActivateAggregate( tpDefault );
+ // hat Auswirkungen auf pRequired
+ if(!pFieldDescr->IsPrimaryKey())
+ ActivateAggregate( tpRequired );
+ }
+ }
+
+ if( pDefault )
+ {
+ pDefault->SetText( getControlDefault(pFieldDescr) );
+ pDefault->ClearModifyFlag();
+ }
+
+ if( pBoolDefault )
+ {
+ // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
+ ::rtl::OUString sValue;
+ pFieldDescr->GetControlDefault() >>= sValue;
+ String sDef = BoolStringUI(sValue);
+
+ // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf
+ if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() )
+ {
+ pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // der Typ sagt das
+
+ pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
+ if ( !sDef.Equals(aYes) && !sDef.Equals(aNo) )
+ pBoolDefault->SelectEntryPos(1); // nein als Default
+ else
+ pBoolDefault->SelectEntry(sDef);
+
+ pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(BoolStringPersistent(pBoolDefault->GetSelectEntry()))));
+ }
+ else if(pBoolDefault->GetEntryCount() < 3)
+ {
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->SelectEntry(sDef);
+ }
+ else
+ pBoolDefault->SelectEntry(sDef);
+ }
+
+ if( pRequired )
+ {
+ if( pFieldDescr->IsNullable() )
+ pRequired->SelectEntryPos( 1 ); // no
+ else
+ pRequired->SelectEntryPos( 0 ); // yes
+ }
+
+ if( pTextLen )
+ {
+ pTextLen->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
+ pTextLen->ClearModifyFlag();
+ }
+
+ if( pNumType )
+ {
+ OSL_FAIL("OFieldDescControl::DisplayData: invalid num type!");
+ }
+
+ if( pLength )
+ pLength->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
+
+ if( pScale )
+ pScale->SetText( String::CreateFromInt32(pFieldDescr->GetScale()) );
+
+ if( pFormat )
+ UpdateFormatSample(pFieldDescr);
+
+ if(m_pColumnName)
+ m_pColumnName->SetText(pFieldDescr->GetName());
+
+ if(m_pType)
+ {
+ sal_uInt16 nPos = pFieldType.get() ? m_pType->GetEntryPos(String(pFieldDescr->getTypeInfo()->aUIName)) : LISTBOX_ENTRY_NOTFOUND;
+ if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ {
+ const OTypeInfoMap* pMap = getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType.get() ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType());
+ if(aIter == pMap->end() && !pMap->empty())
+ {
+ aIter = pMap->begin();
+ if(pFieldDescr->GetPrecision() > aIter->second->nPrecision)
+ pFieldDescr->SetPrecision(aIter->second->nPrecision);
+ if(pFieldDescr->GetScale() > aIter->second->nMaximumScale)
+ pFieldDescr->SetScale(0);
+ if(!aIter->second->bNullable && pFieldDescr->IsNullable())
+ pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
+ if(!aIter->second->bAutoIncrement && pFieldDescr->IsAutoIncrement())
+ pFieldDescr->SetAutoIncrement(sal_False);
+ }
+ if ( aIter != pMap->end() )
+ {
+ pFieldDescr->SetType(aIter->second);
+ }
+ }
+ m_pType->SelectEntry(pFieldDescr->getTypeInfo()->aUIName);
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls Enablen/Disablen
+ sal_Bool bRead(IsReadOnly());
+
+
+ ArrangeAggregates();
+ CheckScrollBars();
+ ScrollAllAggregates();
+
+ SetReadOnly( bRead );
+}
+//------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, DelayedGrabFocus, Control**, ppControl)
+{
+ nDelayedGrabFocusEvent = 0;
+ if (*ppControl)
+ (*ppControl)->GrabFocus();
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl )
+{
+ String strHelpText;
+ OPropNumericEditCtrl* pNumeric = dynamic_cast< OPropNumericEditCtrl* >( pControl );
+ if ( pNumeric )
+ {
+ pNumeric->SaveValue();
+ strHelpText = pNumeric->GetHelp();
+ }
+
+ OPropColumnEditCtrl* pColumn = dynamic_cast< OPropColumnEditCtrl* >( pControl );
+ if ( pColumn )
+ {
+ pColumn->SaveValue();
+ strHelpText = pColumn->GetHelp();
+ }
+
+ OPropEditCtrl* pEdit = dynamic_cast< OPropEditCtrl* >( pControl );
+ if ( pEdit )
+ {
+ pEdit->SaveValue();
+ strHelpText = pEdit->GetHelp();
+ }
+
+ OPropListBoxCtrl* pListBox = dynamic_cast< OPropListBoxCtrl* >( pControl );
+ if ( pListBox )
+ {
+ pListBox->SaveValue();
+ strHelpText = pListBox->GetHelp();
+ }
+
+ if (pControl == pFormat)
+ strHelpText =String(ModuleRes(STR_HELP_FORMAT_BUTTON));
+
+ if (strHelpText.Len() && (pHelp != NULL))
+ pHelp->SetHelpText(strHelpText);
+
+ m_pActFocusWindow = pControl;
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnControlFocusLost, Control*, pControl )
+{
+ if ((pControl == pLength) || (pControl == pTextLen) || (pControl == pScale))
+ {
+ OPropNumericEditCtrl* pConverted = (OPropNumericEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ if(pControl == m_pColumnName)
+ {
+ OPropColumnEditCtrl* pConverted = (OPropColumnEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ else if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pAutoIncrementValue) )
+ {
+ OPropEditCtrl* pConverted = (OPropEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType))
+ {
+ OPropListBoxCtrl* pConverted = (OPropListBoxCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+
+ if (pControl == pDefault)
+ UpdateFormatSample(pActFieldDescr);
+
+ implFocusLost(pControl);
+
+ return 0L;
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ if( !pFieldDescr )
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls auslesen
+ ::rtl::OUString sDefault;
+ if (pDefault)
+ {
+ sDefault = pDefault->GetText();
+ }
+ else if (pBoolDefault)
+ {
+ sDefault = BoolStringPersistent(pBoolDefault->GetSelectEntry());
+ }
+
+ if ( sDefault.getLength() )
+ {
+ sal_uInt32 nFormatKey;
+ try
+ {
+ if ( isTextFormat(pFieldDescr,nFormatKey) || pBoolDefault )
+ {
+ pFieldDescr->SetControlDefault(makeAny(sDefault));
+ }
+ else
+ {
+ try
+ {
+ double nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
+ nValue = checkDoubleForDateFormat(nValue,nFormatKey,GetFormatter());
+ pFieldDescr->SetControlDefault(makeAny(nValue));
+ }
+ catch(const Exception&)
+ {
+ if ( sDefault.getLength() )
+ pFieldDescr->SetControlDefault(makeAny(sDefault));
+ else
+ pFieldDescr->SetControlDefault(Any());
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ else
+ pFieldDescr->SetControlDefault(Any());
+
+ if((pRequired && pRequired->GetSelectEntryPos() == 0) || pFieldDescr->IsPrimaryKey() || (pBoolDefault && pBoolDefault->GetEntryCount() == 2)) // yes
+ pFieldDescr->SetIsNullable( ColumnValue::NO_NULLS );
+ else
+ pFieldDescr->SetIsNullable( ColumnValue::NULLABLE );
+
+ if ( pAutoIncrement )
+ pFieldDescr->SetAutoIncrement( pAutoIncrement->GetSelectEntryPos() == 0 );
+
+ if( pTextLen )
+ pFieldDescr->SetPrecision( static_cast<sal_Int32>(pTextLen->GetValue()) );
+ else if( pLength )
+ pFieldDescr->SetPrecision( static_cast<sal_Int32>(pLength->GetValue()) );
+ if( pScale )
+ pFieldDescr->SetScale( static_cast<sal_Int32>(pScale->GetValue()) );
+
+ if(m_pColumnName)
+ pFieldDescr->SetName(m_pColumnName->GetText());
+
+ if ( m_pAutoIncrementValue && isAutoIncrementValueEnabled() )
+ pFieldDescr->SetAutoIncrementValue(m_pAutoIncrementValue->GetText());
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr)
+{
+ if ( pFieldDescr && pFormatSample )
+ pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False));
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::GetFocus()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Setzt den Focus auf das zuletzt aktive Control
+ TabPage::GetFocus();
+ if( pLastFocusWindow )
+ {
+ pLastFocusWindow->GrabFocus();
+ pLastFocusWindow = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::implFocusLost(Window* _pWhich)
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ OSL_ENSURE(!_pWhich || IsChild(_pWhich), "OFieldDescControl::implFocusLost : invalid window !");
+
+ //////////////////////////////////////////////////////////////////////
+ // Das aktive Control merken
+ if (!pLastFocusWindow)
+ pLastFocusWindow = _pWhich;
+
+ //////////////////////////////////////////////////////////////////////
+ // HelpText zuruecksetzen
+ if (pHelp && !pHelp->HasChildPathFocus())
+ pHelp->SetHelpText( String() );
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::LoseFocus()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+
+ implFocusLost(NULL);
+
+ TabPage::LoseFocus();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isCopyAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue) &&
+ static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
+
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isCutAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue) &&
+ static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isPasteAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue);
+ if ( bAllowed )
+ {
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ bAllowed = aTransferData.HasFormat(SOT_FORMAT_STRING);
+ }
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::cut()
+{
+ if(isCutAllowed())
+ static_cast<Edit*>(m_pActFocusWindow)->Cut();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::copy()
+{
+ if(isCopyAllowed()) // this only checks if the focus window is valid
+ static_cast<Edit*>(m_pActFocusWindow)->Copy();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::paste()
+{
+ if(m_pActFocusWindow) // this only checks if the focus window is valid
+ static_cast<Edit*>(m_pActFocusWindow)->Paste();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const
+{
+ _nFormatKey = _pFieldDescr->GetFormatKey();
+ sal_Bool bTextFormat = sal_True;
+
+ try
+ {
+ if (!_nFormatKey)
+ {
+ Reference< ::com::sun::star::util::XNumberFormatTypes> xNumberTypes(GetFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY);
+ OSL_ENSURE(xNumberTypes.is(),"XNumberFormatTypes is null!");
+
+ _nFormatKey = ::dbtools::getDefaultNumberFormat( _pFieldDescr->GetType(),
+ _pFieldDescr->GetScale(),
+ _pFieldDescr->IsCurrency(),
+ xNumberTypes,
+ GetLocale());
+ }
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(GetFormatter(),_nFormatKey);
+ bTextFormat = (nNumberFormat == ::com::sun::star::util::NumberFormat::TEXT);
+ }
+ catch(const Exception&)
+ {
+
+ }
+
+ return bTextFormat;
+}
+// -----------------------------------------------------------------------------
+String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck) const
+{
+ ::rtl::OUString sDefault;
+ sal_Bool bCheck = !_bCheck || _pFieldDescr->GetControlDefault().hasValue();
+ if ( bCheck )
+ {
+ sal_uInt32 nFormatKey;
+ sal_Bool bTextFormat = sal_False;
+ double nValue = 0.0;
+
+ try
+ {
+ bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
+ if ( _pFieldDescr->GetControlDefault() >>= sDefault )
+ {
+ if ( !bTextFormat )
+ {
+ if ( sDefault.getLength() )
+ {
+ try
+ {
+ nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
+ }
+ catch(const Exception&)
+ {
+ return ::rtl::OUString(); // return empty string for format example
+ }
+ }
+ }
+ }
+ else
+ _pFieldDescr->GetControlDefault() >>= nValue;
+
+
+ Reference< ::com::sun::star::util::XNumberFormatter> xNumberFormatter = GetFormatter();
+ Reference<XPropertySet> xFormSet = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey);
+ OSL_ENSURE(xFormSet.is(),"XPropertySet is null!");
+ ::rtl::OUString sFormat;
+ xFormSet->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormatString"))) >>= sFormat;
+
+ if ( !bTextFormat )
+ {
+ Locale aLocale;
+ ::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale;
+
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(xNumberFormatter,nFormatKey);
+ if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE
+ || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
+ {
+ nValue = DBTypeConversion::toNullDate(DBTypeConversion::getNULLDate(xNumberFormatter->getNumberFormatsSupplier()),nValue);
+ }
+
+
+
+ Reference< ::com::sun::star::util::XNumberFormatPreviewer> xPreViewer(xNumberFormatter,UNO_QUERY);
+ OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!");
+ sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True);
+ }
+ else if ( !_bCheck || (sDefault.getLength() != 0) )
+ sDefault = xNumberFormatter->formatString(nFormatKey,(sDefault.getLength() != 0 )? sDefault : sFormat);
+ }
+ catch(const Exception&)
+ {
+
+ }
+ }
+
+ return sDefault;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
new file mode 100644
index 000000000000..df2ac9b6e4b6
--- /dev/null
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -0,0 +1,717 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RelationControl.hxx"
+#include "RelationControl.hrc"
+
+#include <svtools/editbrowsebox.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <tools/diagnose_ex.h>
+#include "TableConnectionData.hxx"
+#include "TableConnection.hxx"
+#include "TableWindow.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "UITools.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "RelControliFace.hxx"
+#include "dbu_control.hrc"
+#include "dbaccess_helpid.hrc"
+#include <osl/diagnose.h>
+
+#include <algorithm>
+
+#define SOURCE_COLUMN 1
+#define DEST_COLUMN 2
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace svt;
+
+ typedef ::svt::EditBrowseBox ORelationControl_Base;
+ class ORelationControl : public ORelationControl_Base
+ {
+ friend class OTableListBoxControl;
+
+ ::std::auto_ptr< ::svt::ListBoxControl> m_pListCell;
+ TTableConnectionData::value_type m_pConnData;
+ const OJoinTableView::OTableWindowMap* m_pTableMap;
+ OTableListBoxControl* m_pBoxControl;
+ long m_nDataPos;
+ Reference< XPropertySet> m_xSourceDef;
+ Reference< XPropertySet> m_xDestDef;
+
+
+ void fillListBox(const Reference< XPropertySet>& _xDest,long nRow,sal_uInt16 nColumnId);
+ /** returns the column id for the editbrowsebox
+ @param _nColId
+ the column id SOURCE_COLUMN or DEST_COLUMN
+
+ @return the current column id eihter SOURCE_COLUMN or DEST_COLUMN depends on the connection data
+ */
+ sal_uInt16 getColumnIdent( sal_uInt16 _nColId ) const;
+ public:
+ ORelationControl( OTableListBoxControl* pParent,const OJoinTableView::OTableWindowMap* _pTableMap );
+ virtual ~ORelationControl();
+
+ /** searches for a connection between these two tables
+ @param _pSource
+ the left table
+ @param _pDest
+ the right window
+ */
+ void setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest);
+
+ /** allows to access the connection data from outside
+
+ @return rthe connection data
+ */
+ inline TTableConnectionData::value_type getData() const { return m_pConnData; }
+
+ void lateInit();
+
+ protected:
+ virtual void Resize();
+
+ virtual long PreNotify(NotifyEvent& rNEvt );
+
+ virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
+
+ virtual void Init(const TTableConnectionData::value_type& _pConnData);
+ virtual void Init() { ORelationControl_Base::Init(); }
+ virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
+ virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
+ virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
+ virtual sal_Bool SeekRow( long nRow );
+ virtual sal_Bool SaveModified();
+ virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
+
+ virtual void CellModified();
+
+ DECL_LINK( AsynchDeactivate, void* );
+ private:
+
+ DECL_LINK( AsynchActivate, void* );
+
+ };
+
+ //========================================================================
+ // class ORelationControl
+ //========================================================================
+ DBG_NAME(ORelationControl)
+ //------------------------------------------------------------------------
+ ORelationControl::ORelationControl( OTableListBoxControl* pParent ,const OJoinTableView::OTableWindowMap* _pTableMap)
+ :EditBrowseBox( pParent, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE, WB_TABSTOP | WB_BORDER | BROWSER_AUTOSIZE_LASTCOL)
+ ,m_pTableMap(_pTableMap)
+ ,m_pBoxControl(pParent)
+ ,m_xSourceDef( NULL )
+ ,m_xDestDef( NULL )
+ {
+ DBG_CTOR(ORelationControl,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ ORelationControl::~ORelationControl()
+ {
+ DBG_DTOR(ORelationControl,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void ORelationControl::Init(const TTableConnectionData::value_type& _pConnData)
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+
+ m_pConnData = _pConnData;
+ OSL_ENSURE(m_pConnData, "No data supplied!");
+
+ m_pConnData->normalizeLines();
+ }
+ //------------------------------------------------------------------------------
+ void ORelationControl::lateInit()
+ {
+ if ( !m_pConnData.get() )
+ return;
+ m_xSourceDef = m_pConnData->getReferencingTable()->getTable();
+ m_xDestDef = m_pConnData->getReferencedTable()->getTable();
+
+ if ( ColCount() == 0 )
+ {
+ InsertDataColumn( SOURCE_COLUMN, m_pConnData->getReferencingTable()->GetWinName(), 100);
+ InsertDataColumn( DEST_COLUMN, m_pConnData->getReferencedTable()->GetWinName(), 100);
+ // wenn es die Defs noch nicht gibt, dann muessen sie noch mit SetSource-/-DestDef gesetzt werden !
+
+ m_pListCell.reset( new ListBoxControl( &GetDataWindow() ) );
+
+ //////////////////////////////////////////////////////////////////////
+ // set browse mode
+ SetMode( BROWSER_COLUMNSELECTION |
+ BROWSER_HLINESFULL |
+ BROWSER_VLINESFULL |
+ BROWSER_HIDECURSOR |
+ BROWSER_HIDESELECT |
+ BROWSER_AUTO_HSCROLL |
+ BROWSER_AUTO_VSCROLL);
+ }
+ else
+ // not the first call
+ RowRemoved(0, GetRowCount());
+
+ RowInserted(0, m_pConnData->GetConnLineDataList()->size() + 1, sal_True); // add one extra row
+ }
+ //------------------------------------------------------------------------------
+ void ORelationControl::Resize()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ EditBrowseBox::Resize();
+ long nOutputWidth = GetOutputSizePixel().Width();
+ SetColumnWidth(1, (nOutputWidth / 2));
+ SetColumnWidth(2, (nOutputWidth / 2));
+ }
+
+ //------------------------------------------------------------------------------
+ long ORelationControl::PreNotify(NotifyEvent& rNEvt)
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() )
+ PostUserEvent(LINK(this, ORelationControl, AsynchDeactivate));
+ else if (rNEvt.GetType() == EVENT_GETFOCUS)
+ PostUserEvent(LINK(this, ORelationControl, AsynchActivate));
+
+ return EditBrowseBox::PreNotify(rNEvt);
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(ORelationControl, AsynchActivate, void*, EMPTYARG)
+ {
+ ActivateCell();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(ORelationControl, AsynchDeactivate, void*, EMPTYARG)
+ {
+ DeactivateCell();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Bool ORelationControl::IsTabAllowed(sal_Bool bForward) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ long nRow = GetCurRow();
+ sal_uInt16 nCol = GetCurColumnId();
+
+ sal_Bool bRet = !(( ( bForward && (nCol == DEST_COLUMN) && (nRow == GetRowCount() - 1)))
+ || (!bForward && (nCol == SOURCE_COLUMN) && (nRow == 0)));
+
+ return bRet && EditBrowseBox::IsTabAllowed(bForward);
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Bool ORelationControl::SaveModified()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ sal_Int32 nRow = GetCurRow();
+ if ( nRow != BROWSER_ENDOFSELECTION )
+ {
+ String sFieldName(m_pListCell->GetSelectEntry());
+ OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
+ if ( pLines->size() <= static_cast<sal_uInt32>(nRow) )
+ {
+ pLines->push_back(new OConnectionLineData());
+ nRow = pLines->size() - 1;
+ }
+
+ OConnectionLineDataRef pConnLineData = (*pLines)[nRow];
+
+ switch( getColumnIdent( GetCurColumnId() ) )
+ {
+ case SOURCE_COLUMN:
+ pConnLineData->SetSourceFieldName( sFieldName );
+ break;
+ case DEST_COLUMN:
+ pConnLineData->SetDestFieldName( sFieldName );
+ break;
+ }
+ }
+
+ return sal_True;
+ }
+ //------------------------------------------------------------------------------
+ sal_uInt16 ORelationControl::getColumnIdent( sal_uInt16 _nColId ) const
+ {
+ sal_uInt16 nId = _nColId;
+ if ( m_pConnData->getReferencingTable() != m_pBoxControl->getReferencingTable() )
+ nId = ( _nColId == SOURCE_COLUMN) ? DEST_COLUMN : SOURCE_COLUMN;
+ return nId;
+ }
+
+ //------------------------------------------------------------------------------
+ String ORelationControl::GetCellText( long nRow, sal_uInt16 nColId ) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ String sText;
+ if ( m_pConnData->GetConnLineDataList()->size() > static_cast<size_t>(nRow) )
+ {
+ OConnectionLineDataRef pConnLineData = (*m_pConnData->GetConnLineDataList())[nRow];
+ switch( getColumnIdent( nColId ) )
+ {
+ case SOURCE_COLUMN:
+ sText = pConnLineData->GetSourceFieldName();
+ break;
+ case DEST_COLUMN:
+ sText = pConnLineData->GetDestFieldName();
+ break;
+ }
+ }
+ return sText;
+ }
+
+ //------------------------------------------------------------------------------
+ void ORelationControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+
+ rtl::OString sHelpId( HID_RELATIONDIALOG_LEFTFIELDCELL );
+
+ Reference< XPropertySet> xDef;
+ switch ( getColumnIdent(nColumnId) )
+ {
+ case SOURCE_COLUMN:
+ xDef = m_xSourceDef;
+ sHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
+ break;
+ case DEST_COLUMN:
+ xDef = m_xDestDef;
+ sHelpId = HID_RELATIONDIALOG_RIGHTFIELDCELL;
+ break;
+ default:
+ // ?????????
+ break;
+ }
+
+ if ( xDef.is() )
+ {
+ fillListBox(xDef,nRow,nColumnId);
+ String sName = GetCellText( nRow, nColumnId );
+ m_pListCell->SelectEntry( sName );
+ if ( m_pListCell->GetSelectEntry() != sName )
+ {
+ m_pListCell->InsertEntry( sName );
+ m_pListCell->SelectEntry( sName );
+ }
+
+ m_pListCell->SetHelpId(sHelpId);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ CellController* ORelationControl::GetController( long /*nRow*/, sal_uInt16 /*nColumnId*/ )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ return new ListBoxCellController( m_pListCell.get() );
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Bool ORelationControl::SeekRow( long nRow )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ m_nDataPos = nRow;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void ORelationControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ String aText =const_cast< ORelationControl*>(this)->GetCellText( m_nDataPos, nColumnId );
+
+ Point aPos( rRect.TopLeft() );
+ Size aTextSize( GetDataWindow().GetTextHeight(),GetDataWindow().GetTextWidth( aText ));
+
+ if( aPos.X() < rRect.Right() || aPos.X() + aTextSize.Width() > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + aTextSize.Height() > rRect.Bottom() )
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText( aPos, aText );
+
+ if( rDev.IsClipRegion() )
+ rDev.SetClipRegion();
+ }
+ // -----------------------------------------------------------------------------
+ void ORelationControl::fillListBox(const Reference< XPropertySet>& _xDest,long /*_nRow*/,sal_uInt16 /*nColumnId*/)
+ {
+ m_pListCell->Clear();
+ try
+ {
+ if ( _xDest.is() )
+ {
+ //sal_Int32 nRows = GetRowCount();
+ Reference<XColumnsSupplier> xSup(_xDest,UNO_QUERY);
+ Reference<XNameAccess> xColumns = xSup->getColumns();
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ m_pListCell->InsertEntry( *pIter );
+ }
+ m_pListCell->InsertEntry(String(), 0);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void ORelationControl::setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest)
+ {
+ // wenn ich hier gerade editiere, ausblenden
+ sal_Bool bWasEditing = IsEditing();
+ if ( bWasEditing )
+ DeactivateCell();
+
+ if ( _pSource && _pDest )
+ {
+ m_xSourceDef = _pSource->GetTable();
+ SetColumnTitle(1, _pSource->GetName());
+
+
+ m_xDestDef = _pDest->GetTable();
+ SetColumnTitle(2, _pDest->GetName());
+
+ const OJoinTableView* pView = _pSource->getTableView();
+ OTableConnection* pConn = pView->GetTabConn(_pSource,_pDest);
+ if ( pConn && !m_pConnData->GetConnLineDataList()->empty() )
+ {
+ m_pConnData->CopyFrom(*pConn->GetData());
+ m_pBoxControl->getContainer()->notifyConnectionChange();
+ }
+ else
+ {
+ // no connection found so we clear our data
+ OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
+ ::std::for_each(pLines->begin(),
+ pLines->end(),
+ OUnaryRefFunctor<OConnectionLineData>( ::std::mem_fun(&OConnectionLineData::Reset))
+ );
+
+ m_pConnData->setReferencingTable(_pSource->GetData());
+ m_pConnData->setReferencedTable(_pDest->GetData());
+ }
+ m_pConnData->normalizeLines();
+
+ }
+ // neu zeichnen
+ Invalidate();
+
+ if ( bWasEditing )
+ {
+ GoToRow(0);
+ ActivateCell();
+ }
+ }
+ //------------------------------------------------------------------------
+ void ORelationControl::CellModified()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ EditBrowseBox::CellModified();
+ SaveModified();
+ static_cast<OTableListBoxControl*>(GetParent())->NotifyCellChange();
+ }
+ //========================================================================
+ // class OTableListBoxControl
+DBG_NAME(OTableListBoxControl)
+
+//========================================================================
+
+OTableListBoxControl::OTableListBoxControl( Window* _pParent
+ ,const ResId& _rResId
+ ,const OJoinTableView::OTableWindowMap* _pTableMap
+ ,IRelationControlInterface* _pParentDialog)
+ : Window(_pParent,_rResId)
+ , m_aFL_InvolvedTables( this, ResId(FL_INVOLVED_TABLES,*_rResId.GetResMgr()))
+ , m_lmbLeftTable( this, ResId(LB_LEFT_TABLE,*_rResId.GetResMgr()))
+ , m_lmbRightTable( this, ResId(LB_RIGHT_TABLE,*_rResId.GetResMgr()))
+ , m_aFL_InvolvedFields( this, ResId(FL_INVOLVED_FIELDS,*_rResId.GetResMgr()))
+ , m_pTableMap(_pTableMap)
+ , m_pParentDialog(_pParentDialog)
+ {
+ m_pRC_Tables = new ORelationControl( this,m_pTableMap );
+ m_pRC_Tables->SetHelpId(HID_RELDLG_KEYFIELDS);
+ m_pRC_Tables->Init( );
+ m_pRC_Tables->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
+
+ lateUIInit();
+
+ Link aLink(LINK(this, OTableListBoxControl, OnTableChanged));
+ m_lmbLeftTable.SetSelectHdl(aLink);
+ m_lmbRightTable.SetSelectHdl(aLink);
+
+ FreeResource();
+ DBG_CTOR(OTableListBoxControl,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ OTableListBoxControl::~OTableListBoxControl()
+ {
+ ORelationControl* pTemp = m_pRC_Tables;
+ m_pRC_Tables = NULL;
+ delete pTemp;
+ DBG_DTOR(OTableListBoxControl,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::fillListBoxes()
+ {
+ OSL_ENSURE( !m_pTableMap->empty(), "OTableListBoxControl::fillListBoxes: no table window!");
+ OTableWindow* pInitialLeft = NULL;
+ OTableWindow* pInitialRight = NULL;
+
+ // die Namen aller TabWins einsammeln
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
+ OJoinTableView::OTableWindowMap::const_iterator aEnd = m_pTableMap->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ m_lmbLeftTable.InsertEntry(aIter->first);
+ m_lmbRightTable.InsertEntry(aIter->first);
+
+ if (!pInitialLeft)
+ {
+ pInitialLeft = aIter->second;
+ m_strCurrentLeft = aIter->first;
+ }
+ else if (!pInitialRight)
+ {
+ pInitialRight = aIter->second;
+ m_strCurrentRight = aIter->first;
+ }
+ }
+
+ if ( !pInitialRight )
+ {
+ pInitialRight = pInitialLeft;
+ m_strCurrentRight = m_strCurrentLeft;
+ }
+
+ // die entsprechenden Defs an mein Controls
+ m_pRC_Tables->setWindowTables(pInitialLeft,pInitialRight);
+
+ // die in einer ComboBox ausgewaehlte Tabelle darf nicht in der anderen zur Verfuegung stehen
+
+ if ( m_pTableMap->size() > 2 )
+ {
+ m_lmbLeftTable.RemoveEntry(m_strCurrentRight);
+ m_lmbRightTable.RemoveEntry(m_strCurrentLeft);
+ }
+
+ // links das erste, rechts das zweite selektieren
+ m_lmbLeftTable.SelectEntry(m_strCurrentLeft);
+ m_lmbRightTable.SelectEntry(m_strCurrentRight);
+
+ m_lmbLeftTable.GrabFocus();
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( OTableListBoxControl, OnTableChanged, ListBox*, pListBox )
+ {
+ String strSelected(pListBox->GetSelectEntry());
+ OTableWindow* pLeft = NULL;
+ OTableWindow* pRight = NULL;
+
+ // eine Sonderbehandlung : wenn es nur zwei Tabellen gibt, muss ich bei Wechsel in einer LB auch in der anderen umschalten
+ if ( m_pTableMap->size() == 2 )
+ {
+ ListBox* pOther;
+ if ( pListBox == &m_lmbLeftTable )
+ pOther = &m_lmbRightTable;
+ else
+ pOther = &m_lmbLeftTable;
+ pOther->SelectEntryPos(1 - pOther->GetSelectEntryPos());
+
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
+ OTableWindow* pFirst = aIter->second;
+ ++aIter;
+ OTableWindow* pSecond = aIter->second;
+
+ if ( m_lmbLeftTable.GetSelectEntry() == String(pFirst->GetName()) )
+ {
+ pLeft = pFirst;
+ pRight = pSecond;
+ }
+ else
+ {
+ pLeft = pSecond;
+ pRight = pFirst;
+ }
+ }
+ else
+ {
+ // zuerst brauche ich die TableDef zur Tabelle, dazu das TabWin
+ OJoinTableView::OTableWindowMap::const_iterator aFind = m_pTableMap->find(strSelected);
+ OTableWindow* pLoop = NULL;
+ if( aFind != m_pTableMap->end() )
+ pLoop = aFind->second;
+ OSL_ENSURE(pLoop != NULL, "ORelationDialog::OnTableChanged : ungueltiger Eintrag in ListBox !");
+ // da ich die ListBoxen selber mit eben diesen Tabellennamen, mit denen ich sie jetzt vergleiche, gefuellt habe,
+ // MUSS ich strSelected finden
+ if (pListBox == &m_lmbLeftTable)
+ {
+ // den vorher links selektierten Eintrag wieder rein rechts
+ m_lmbRightTable.InsertEntry(m_strCurrentLeft);
+ // und den jetzt selektierten raus
+ m_lmbRightTable.RemoveEntry(strSelected);
+ m_strCurrentLeft = strSelected;
+
+ pLeft = pLoop;
+
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbRightTable.GetSelectEntry());
+ OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
+ if ( aIter != m_pTableMap->end() )
+ pRight = aIter->second;
+
+ m_lmbLeftTable.GrabFocus();
+ }
+ else
+ {
+ // den vorher rechts selektierten Eintrag wieder rein links
+ m_lmbLeftTable.InsertEntry(m_strCurrentRight);
+ // und den jetzt selektierten raus
+ m_lmbLeftTable.RemoveEntry(strSelected);
+ m_strCurrentRight = strSelected;
+
+ pRight = pLoop;
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbLeftTable.GetSelectEntry());
+ OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
+ if ( aIter != m_pTableMap->end() )
+ pLeft = aIter->second;
+ }
+ }
+
+ pListBox->GrabFocus();
+
+ m_pRC_Tables->setWindowTables(pLeft,pRight);
+
+ NotifyCellChange();
+ return 0;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::NotifyCellChange()
+ {
+ // den Ok-Button en- oder disablen, je nachdem, ob ich eine gueltige Situation habe
+ TTableConnectionData::value_type pConnData = m_pRC_Tables->getData();
+ const OConnectionLineDataVec* pLines = pConnData->GetConnLineDataList();
+ m_pParentDialog->setValid(!pLines->empty());
+
+ if ( pLines->size() >= static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) )
+ {
+ m_pRC_Tables->DeactivateCell();
+ m_pRC_Tables->RowInserted(m_pRC_Tables->GetRowCount(), pLines->size() - static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) + 1, sal_True);
+ m_pRC_Tables->ActivateCell();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void fillEntryAndDisable(ListBox& _rListBox,const String& _sEntry)
+ {
+ _rListBox.InsertEntry(_sEntry);
+ _rListBox.SelectEntryPos(0);
+ _rListBox.Disable();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::fillAndDisable(const TTableConnectionData::value_type& _pConnectionData)
+ {
+ fillEntryAndDisable(m_lmbLeftTable,_pConnectionData->getReferencingTable()->GetWinName());
+ fillEntryAndDisable(m_lmbRightTable,_pConnectionData->getReferencedTable()->GetWinName());
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::Init(const TTableConnectionData::value_type& _pConnData)
+ {
+ m_pRC_Tables->Init(_pConnData);
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::lateUIInit(Window* _pTableSeparator)
+ {
+ const sal_Int32 nDiff = LogicToPixel( Point(0,6), MAP_APPFONT ).Y();
+ Point aDlgPoint = LogicToPixel( Point(12,43), MAP_APPFONT );
+ if ( _pTableSeparator )
+ {
+ _pTableSeparator->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
+ m_pRC_Tables->SetZOrder(_pTableSeparator, WINDOW_ZORDER_BEHIND);
+ _pTableSeparator->SetPosPixel(Point(0,m_aFL_InvolvedFields.GetPosPixel().Y()));
+ const Size aSize = _pTableSeparator->GetSizePixel();
+ aDlgPoint.Y() = _pTableSeparator->GetPosPixel().Y() + aSize.Height();
+ m_aFL_InvolvedFields.SetPosPixel(Point(m_aFL_InvolvedFields.GetPosPixel().X(),aDlgPoint.Y()));
+ aDlgPoint.Y() += nDiff + m_aFL_InvolvedFields.GetSizePixel().Height();
+ }
+ //////////////////////////////////////////////////////////////////////
+ // positing BrowseBox control
+ const Size aCurrentSize = GetSizePixel();
+ Size aDlgSize = LogicToPixel( Size(24,0), MAP_APPFONT );
+ aDlgSize.Width() = aCurrentSize.Width() - aDlgSize.Width();
+ aDlgSize.Height() = aCurrentSize.Height() - aDlgPoint.Y() - nDiff;
+
+ m_pRC_Tables->SetPosSizePixel( aDlgPoint, aDlgSize );
+ m_pRC_Tables->Show();
+
+ lateInit();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::lateInit()
+ {
+ m_pRC_Tables->lateInit();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableListBoxControl::SaveModified()
+ {
+ sal_Bool bRet = m_pRC_Tables->SaveModified();
+ m_pRC_Tables->getData()->normalizeLines();
+ return bRet;
+ }
+ // -----------------------------------------------------------------------------
+ TTableWindowData::value_type OTableListBoxControl::getReferencingTable() const
+ {
+ return m_pRC_Tables->getData()->getReferencingTable();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::enableRelation(bool _bEnable)
+ {
+ if ( !_bEnable )
+ PostUserEvent(LINK(m_pRC_Tables, ORelationControl, AsynchDeactivate));
+ m_pRC_Tables->Enable(_bEnable);
+
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/ScrollHelper.cxx b/dbaccess/source/ui/control/ScrollHelper.cxx
new file mode 100644
index 000000000000..47cac018ffc5
--- /dev/null
+++ b/dbaccess/source/ui/control/ScrollHelper.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ScrollHelper.hxx"
+#include <tools/debug.hxx>
+
+#define LISTBOX_SCROLLING_AREA 12
+namespace dbaui
+{
+DBG_NAME(OScrollHelper)
+
+// -----------------------------------------------------------------------------
+
+
+ OScrollHelper::OScrollHelper()
+ {
+ DBG_CTOR(OScrollHelper,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ OScrollHelper::~OScrollHelper()
+ {
+
+ DBG_DTOR(OScrollHelper,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ void OScrollHelper::scroll(const Point& _rPoint, const Size& _rOutputSize)
+ {
+ // Scrolling Areas
+ Rectangle aScrollArea( Point(0, _rOutputSize.Height() - LISTBOX_SCROLLING_AREA),
+ Size(_rOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
+
+ Link aToCall;
+ // if pointer in bottom area begin scroll
+ if( aScrollArea.IsInside(_rPoint) )
+ aToCall = m_aUpScroll;
+ else
+ {
+ aScrollArea.SetPos(Point(0,0));
+ // if pointer in top area begin scroll
+ if( aScrollArea.IsInside(_rPoint) )
+ aToCall = m_aDownScroll;
+ }
+ if ( aToCall.IsSet() )
+ aToCall.Call( NULL );
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
new file mode 100644
index 000000000000..5acc67d433a6
--- /dev/null
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "SqlNameEdit.hxx"
+namespace dbaui
+{
+ //------------------------------------------------------------------
+ sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const ::rtl::OUString& _sAllowedChars)
+ {
+ return (
+ (_cChar >= 'A' && _cChar <= 'Z') ||
+ _cChar == '_' ||
+ _sAllowedChars.indexOf(_cChar) != -1 ||
+ (!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
+ (!_bUpperCase && (_cChar >= 'a' && _cChar <= 'z'))
+ );
+ }
+ //------------------------------------------------------------------
+ sal_Bool OSQLNameChecker::checkString( const ::rtl::OUString& _sOldValue,
+ const ::rtl::OUString& _sToCheck,
+ ::rtl::OUString& _rsCorrected)
+ {
+ sal_Bool bCorrected = sal_False;
+ if ( m_bCheck )
+ {
+ XubString sSavedValue = _sOldValue;
+ XubString sText = _sToCheck;
+ xub_StrLen nMatch = 0;
+ for ( xub_StrLen i=nMatch;i < sText.Len(); ++i )
+ {
+ if ( !isCharOk( sText.GetBuffer()[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) )
+ {
+ _rsCorrected += sText.Copy( nMatch, i - nMatch );
+ bCorrected = sal_True;
+ nMatch = i + 1;
+ }
+ }
+ _rsCorrected += sText.Copy( nMatch, sText.Len() - nMatch );
+ }
+ return bCorrected;
+ }
+ //------------------------------------------------------------------
+ void OSQLNameEdit::Modify()
+ {
+ ::rtl::OUString sCorrected;
+ if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
+ {
+ Selection aSel = GetSelection();
+ aSel.setMax( aSel.getMin() );
+ SetText( sCorrected, aSel );
+
+ SaveValue();
+ }
+ Edit::Modify();
+ }
+ //------------------------------------------------------------------
+ void OSQLNameComboBox::Modify()
+ {
+ ::rtl::OUString sCorrected;
+ if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
+ {
+ Selection aSel = GetSelection();
+ aSel.setMax( aSel.getMin() );
+ SetText( sCorrected );
+
+ SaveValue();
+ }
+ ComboBox::Modify();
+ }
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx
new file mode 100644
index 000000000000..afb6fa777352
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx
@@ -0,0 +1,500 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableGrantCtrl.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#include "dbu_control.hrc"
+#include "UITools.hxx"
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::dbaui;
+using namespace ::svt;
+
+const sal_uInt16 COL_TABLE_NAME = 1;
+const sal_uInt16 COL_SELECT = 2;
+const sal_uInt16 COL_INSERT = 3;
+const sal_uInt16 COL_DELETE = 4;
+const sal_uInt16 COL_UPDATE = 5;
+const sal_uInt16 COL_ALTER = 6;
+const sal_uInt16 COL_REF = 7;
+const sal_uInt16 COL_DROP = 8;
+
+DBG_NAME(OTableGrantControl)
+
+//================================================================================
+// OTableGrantControl
+//================================================================================
+OTableGrantControl::OTableGrantControl( Window* pParent,const ResId& _RsId)
+ :EditBrowseBox( pParent,_RsId, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE )
+ ,m_pCheckCell( NULL )
+ ,m_pEdit( NULL )
+ ,m_nDataPos( 0 )
+ ,m_bEnable(sal_True)
+ ,m_nDeactivateEvent(0)
+{
+ DBG_CTOR(OTableGrantControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Spalten einfuegen
+ sal_uInt16 i=1;
+ InsertDataColumn( i, String(ModuleRes(STR_TABLE_PRIV_NAME) ), 75);
+ FreezeColumn(i++);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_SELECT)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_INSERT)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DELETE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_UPDATE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_ALTER)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_REFERENCE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DROP)), 75);
+
+ while(--i)
+ SetColumnWidth(i,GetAutoColumnWidth(i));
+}
+
+//------------------------------------------------------------------------
+OTableGrantControl::~OTableGrantControl()
+{
+ DBG_DTOR(OTableGrantControl,NULL);
+ if (m_nDeactivateEvent)
+ {
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = 0;
+ }
+
+ delete m_pCheckCell;
+ delete m_pEdit;
+
+ m_xTables = NULL;
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setTablesSupplier(const Reference< XTablesSupplier >& _xTablesSup)
+{
+ // first we need the users
+ Reference< XUsersSupplier> xUserSup(_xTablesSup,UNO_QUERY);
+ if(xUserSup.is())
+ m_xUsers = xUserSup->getUsers();
+
+ // second we need the tables to determine which privileges the user has
+ if(_xTablesSup.is())
+ m_xTables = _xTablesSup->getTables();
+
+ if(m_xTables.is())
+ m_aTableNames = m_xTables->getElementNames();
+
+ OSL_ENSURE(m_xUsers.is(),"No user access supported!");
+ OSL_ENSURE(m_xTables.is(),"No tables supported!");
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setORB(const Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB)
+{
+ m_xORB = _xORB;
+}
+//------------------------------------------------------------------------
+void OTableGrantControl::UpdateTables()
+{
+ RemoveRows();
+
+ if(m_xTables.is())
+ RowInserted(0, m_aTableNames.getLength());
+ // m_bEnable = m_xDb->GetUser() != ((OUserAdmin*)GetParent())->GetUser();
+}
+//------------------------------------------------------------------------
+void OTableGrantControl::Init()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::Init();
+
+ //////////////////////////////////////////////////////////////////////
+ // ComboBox instanzieren
+ if(!m_pCheckCell)
+ {
+ m_pCheckCell = new CheckBoxControl( &GetDataWindow() );
+ m_pCheckCell->GetBox().EnableTriState(sal_False);
+
+ m_pEdit = new Edit( &GetDataWindow() );
+ m_pEdit->SetReadOnly();
+ m_pEdit->Enable(sal_False);
+ }
+
+ UpdateTables();
+ //////////////////////////////////////////////////////////////////////
+ // Browser Mode setzen
+ BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL |
+ BROWSER_HIDECURSOR | BROWSER_HIDESELECT;
+
+ SetMode(nMode);
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::Resize()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::Resize();
+}
+
+//------------------------------------------------------------------------------
+long OTableGrantControl::PreNotify(NotifyEvent& rNEvt)
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS)
+ if (!HasChildPathFocus())
+ {
+ if (m_nDeactivateEvent)
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchDeactivate));
+ }
+ if (rNEvt.GetType() == EVENT_GETFOCUS)
+ {
+ if (m_nDeactivateEvent)
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchActivate));
+ }
+ return EditBrowseBox::PreNotify(rNEvt);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OTableGrantControl, AsynchActivate, void*, EMPTYARG)
+{
+ m_nDeactivateEvent = 0;
+ ActivateCell();
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OTableGrantControl, AsynchDeactivate, void*, EMPTYARG)
+{
+ m_nDeactivateEvent = 0;
+ DeactivateCell();
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableGrantControl::IsTabAllowed(sal_Bool bForward) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ long nRow = GetCurRow();
+ sal_uInt16 nCol = GetCurColumnId();
+
+ if (bForward && (nCol == 2) && (nRow == GetRowCount() - 1))
+ return sal_False;
+
+ if (!bForward && (nCol == 1) && (nRow == 0))
+ return sal_False;
+
+ return EditBrowseBox::IsTabAllowed(bForward);
+}
+//------------------------------------------------------------------------------
+#define GRANT_REVOKE_RIGHT(what) \
+ if(m_pCheckCell->GetBox().IsChecked()) \
+ xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,what);\
+ else \
+ xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,what)
+
+//------------------------------------------------------------------------------
+sal_Bool OTableGrantControl::SaveModified()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ sal_Int32 nRow = GetCurRow();
+ if(nRow == -1 || nRow >= m_aTableNames.getLength())
+ return sal_False;
+
+ ::rtl::OUString sTableName = m_aTableNames[nRow];
+ sal_Bool bErg = sal_True;
+ try
+ {
+
+ if ( m_xUsers->hasByName(m_sUserName) )
+ {
+ Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
+ if ( xAuth.is() )
+ {
+ switch( GetCurColumnId() )
+ {
+ case COL_INSERT:
+ GRANT_REVOKE_RIGHT(Privilege::INSERT);
+ break;
+ case COL_DELETE:
+ GRANT_REVOKE_RIGHT(Privilege::DELETE);
+ break;
+ case COL_UPDATE:
+ GRANT_REVOKE_RIGHT(Privilege::UPDATE);
+ break;
+ case COL_ALTER:
+ GRANT_REVOKE_RIGHT(Privilege::ALTER);
+ break;
+ case COL_SELECT:
+ GRANT_REVOKE_RIGHT(Privilege::SELECT);
+ break;
+ case COL_REF:
+ GRANT_REVOKE_RIGHT(Privilege::REFERENCE);
+ break;
+ case COL_DROP:
+ GRANT_REVOKE_RIGHT(Privilege::DROP);
+ break;
+ }
+ fillPrivilege(nRow);
+ }
+ }
+ }
+ catch(SQLException& e)
+ {
+ bErg = sal_False;
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
+ }
+ if(bErg && Controller().Is())
+ Controller()->ClearModified();
+ if(!bErg)
+ UpdateTables();
+
+ return bErg;
+}
+
+//------------------------------------------------------------------------------
+String OTableGrantControl::GetCellText( long nRow, sal_uInt16 nColId ) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ if(COL_TABLE_NAME == nColId)
+ return m_aTableNames[nRow];
+
+ sal_Int32 nPriv = 0;
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ if(aFind != m_aPrivMap.end())
+ nPriv = aFind->second.nRights;
+
+ return String::CreateFromInt32(isAllowed(nColId,nPriv) ? 1 :0);
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ String sTablename = m_aTableNames[nRow];
+ // special case for tablename
+ if(nColumnId == COL_TABLE_NAME)
+ m_pEdit->SetText(sTablename);
+ else
+ {
+ // get the privileges from the user
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ m_pCheckCell->GetBox().Check(aFind != m_aPrivMap.end() ? isAllowed(nColumnId,aFind->second.nRights) : sal_False);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::fillPrivilege(sal_Int32 _nRow) const
+{
+
+ if ( m_xUsers->hasByName(m_sUserName) )
+ {
+ try
+ {
+ Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
+ if ( xAuth.is() )
+ {
+ // get the privileges
+ TPrivileges nRights;
+ nRights.nRights = xAuth->getPrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
+ if(m_xGrantUser.is())
+ nRights.nWithGrant = m_xGrantUser->getGrantablePrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
+ else
+ nRights.nWithGrant = 0;
+
+ m_aPrivMap[m_aTableNames[_nRow]] = nRights;
+ }
+ }
+ catch(SQLException& e)
+ {
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
+ }
+ catch(Exception& )
+ {
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableGrantControl::isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege) const
+{
+ sal_Bool bAllowed = sal_False;
+ switch (_nColumnId)
+ {
+ case COL_INSERT:
+ bAllowed = (Privilege::INSERT & _nPrivilege) == Privilege::INSERT;
+ break;
+ case COL_DELETE:
+ bAllowed = (Privilege::DELETE & _nPrivilege) == Privilege::DELETE;
+ break;
+ case COL_UPDATE:
+ bAllowed = (Privilege::UPDATE & _nPrivilege) == Privilege::UPDATE;
+ break;
+ case COL_ALTER:
+ bAllowed = (Privilege::ALTER & _nPrivilege) == Privilege::ALTER;
+ break;
+ case COL_SELECT:
+ bAllowed = (Privilege::SELECT & _nPrivilege) == Privilege::SELECT;
+ break;
+ case COL_REF:
+ bAllowed = (Privilege::REFERENCE & _nPrivilege) == Privilege::REFERENCE;
+ break;
+ case COL_DROP:
+ bAllowed = (Privilege::DROP & _nPrivilege) == Privilege::DROP;
+ break;
+ }
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setUserName(const ::rtl::OUString _sUserName)
+{
+ m_sUserName = _sUserName;
+ m_aPrivMap = TTablePrivilegeMap();
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setGrantUser(const Reference< XAuthorizable>& _xGrantUser)
+{
+ OSL_ENSURE(_xGrantUser.is(),"OTableGrantControl::setGrantUser: GrantUser is null!");
+ m_xGrantUser = _xGrantUser;
+}
+//------------------------------------------------------------------------------
+CellController* OTableGrantControl::GetController( long nRow, sal_uInt16 nColumnId )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ CellController* pController = NULL;
+ switch( nColumnId )
+ {
+ case COL_TABLE_NAME:
+ break;
+ case COL_INSERT:
+ case COL_DELETE:
+ case COL_UPDATE:
+ case COL_ALTER:
+ case COL_SELECT:
+ case COL_REF:
+ case COL_DROP:
+ {
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ if(aFind != m_aPrivMap.end() && isAllowed(nColumnId,aFind->second.nWithGrant))
+ pController = new CheckBoxCellController( m_pCheckCell );
+ }
+ break;
+ default:
+ ;
+ }
+ return pController;
+}
+//------------------------------------------------------------------------------
+sal_Bool OTableGrantControl::SeekRow( long nRow )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ m_nDataPos = nRow;
+
+ return (nRow <= m_aTableNames.getLength());
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ if(nColumnId != COL_TABLE_NAME)
+ {
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(m_nDataPos);
+ if(aFind != m_aPrivMap.end())
+ PaintTristate(rDev, rRect, isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK,isAllowed(nColumnId,aFind->second.nWithGrant));
+ else
+ PaintTristate(rDev, rRect, STATE_NOCHECK,sal_False);
+ }
+ else
+ {
+ String aText(((OTableGrantControl*)this)->GetCellText( m_nDataPos, nColumnId ));
+ Point aPos( rRect.TopLeft() );
+ sal_Int32 nWidth = GetDataWindow().GetTextWidth( aText );
+ sal_Int32 nHeight = GetDataWindow().GetTextHeight();
+
+ if( aPos.X() < rRect.Right() || aPos.X() + nWidth > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + nHeight > rRect.Bottom() )
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText( aPos, aText );
+ }
+
+ if( rDev.IsClipRegion() )
+ rDev.SetClipRegion();
+}
+
+//------------------------------------------------------------------------
+void OTableGrantControl::CellModified()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::CellModified();
+ SaveModified();
+}
+// -----------------------------------------------------------------------------
+OTableGrantControl::TTablePrivilegeMap::const_iterator OTableGrantControl::findPrivilege(sal_Int32 _nRow) const
+{
+ TTablePrivilegeMap::const_iterator aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
+ if(aFind == m_aPrivMap.end())
+ {
+ fillPrivilege(_nRow);
+ aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
+ }
+ return aFind;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > OTableGrantControl::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
+{
+ sal_uInt16 nColumnId = GetColumnId( _nColumnPos );
+ if(nColumnId != COL_TABLE_NAME)
+ {
+ TriState eState = STATE_NOCHECK;
+ sal_Bool bEnable = sal_False;
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(_nRow);
+ if(aFind != m_aPrivMap.end())
+ {
+ eState = isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK;
+ bEnable = isAllowed(nColumnId,aFind->second.nWithGrant);
+ }
+ else
+ eState = STATE_NOCHECK;
+
+ return EditBrowseBox::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,eState,bEnable );
+ }
+ return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.src b/dbaccess/source/ui/control/TableGrantCtrl.src
new file mode 100644
index 000000000000..8b870e4927b6
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.src
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+
+String STR_TABLE_PRIV_NAME
+{
+ Text [ en-US ] = "Table name";
+};
+
+String STR_TABLE_PRIV_INSERT
+{
+ Text [ en-US ] = "Insert data";
+};
+
+String STR_TABLE_PRIV_DELETE
+{
+ Text [ en-US ] = "Delete data";
+};
+
+String STR_TABLE_PRIV_UPDATE
+{
+ Text [ en-US ] = "Modify data";
+};
+
+String STR_TABLE_PRIV_ALTER
+{
+ Text [ en-US ] = "Alter structure";
+};
+
+String STR_TABLE_PRIV_SELECT
+{
+ Text [ en-US ] = "Read data";
+};
+
+String STR_TABLE_PRIV_REFERENCE
+{
+ Text [ en-US ] = "Modify references";
+};
+
+String STR_TABLE_PRIV_DROP
+{
+ Text [ en-US ] = "Drop structure";
+};
diff --git a/dbaccess/source/ui/control/VertSplitView.cxx b/dbaccess/source/ui/control/VertSplitView.cxx
new file mode 100644
index 000000000000..929b5c050743
--- /dev/null
+++ b/dbaccess/source/ui/control/VertSplitView.cxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "VertSplitView.hxx"
+
+#include <tools/debug.hxx>
+
+#define SPLITTER_WIDTH 80
+
+using namespace ::dbaui;
+
+//==================================================================
+// class OSplitterView
+//==================================================================
+DBG_NAME(OSplitterView)
+OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER
+ ,m_pSplitter( NULL )
+ ,m_pLeft(NULL)
+ ,m_pRight(NULL)
+ ,m_bVertical(_bVertical)
+{
+ DBG_CTOR(OSplitterView,NULL);
+ ImplInitSettings( sal_True, sal_True, sal_True );
+}
+// -----------------------------------------------------------------------------
+OSplitterView::~OSplitterView()
+{
+ DBG_DTOR(OSplitterView,NULL);
+ m_pRight = m_pLeft = NULL;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ )
+{
+ OSL_ENSURE(m_pSplitter, "Splitter is NULL!");
+ if ( m_bVertical )
+ {
+ long nPosY = m_pSplitter->GetPosPixel().Y();
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nPosY ) );
+ }
+ else
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
+
+ Resize();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetPointFont( aFont );
+// Set/*Zoomed*/PointFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetFaceColor() );
+ }
+}
+// -----------------------------------------------------------------------
+void OSplitterView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::GetFocus()
+{
+ Window::GetFocus();
+
+ // forward the focus to the current cell of the editor control
+ if ( m_pLeft )
+ m_pLeft->GrabFocus();
+ else if ( m_pRight )
+ m_pRight->GrabFocus();
+}
+
+// -------------------------------------------------------------------------
+void OSplitterView::Resize()
+{
+ Window::Resize();
+ OSL_ENSURE( m_pRight, "No init called!");
+
+ Point aSplitPos;
+ Size aSplitSize;
+ Point aPlaygroundPos( 0,0 );
+ Size aPlaygroundSize( GetOutputSizePixel() );
+
+ if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter )
+ {
+ aSplitPos = m_pSplitter->GetPosPixel();
+ aSplitSize = m_pSplitter->GetOutputSizePixel();
+ if ( m_bVertical )
+ {
+ // calculate the splitter pos and size
+ aSplitPos.Y() = aPlaygroundPos.Y();
+ aSplitSize.Height() = aPlaygroundSize.Height();
+
+ if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() ))
+ aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width();
+
+ if( aSplitPos.X() <= aPlaygroundPos.X() )
+ aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.3);
+
+ // the tree pos and size
+ Point aTreeViewPos( aPlaygroundPos );
+ Size aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() );
+
+ // set the size of treelistbox
+ m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
+
+ //set the size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) );
+ m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
+ }
+ else
+ {
+ aSplitPos.X() = aPlaygroundPos.X();
+ aSplitSize.Width() = aPlaygroundSize.Width();
+
+ if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
+ aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
+
+ if( aSplitPos.Y() <= aPlaygroundPos.Y() )
+ aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3);
+
+ // the tree pos and size
+ Point aTreeViewPos( aPlaygroundPos );
+ Size aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y());
+
+ // set the size of treelistbox
+ m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
+
+ //set the size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) );
+ m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
+ }
+ }
+
+ if ( m_pRight )
+ {
+ if ( m_bVertical )
+ m_pRight->SetPosSizePixel( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(),
+ aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height());
+ else
+ m_pRight->SetPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(),
+ aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y());
+ }
+
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::set(Window* _pRight,Window* _pLeft)
+{
+ m_pLeft = _pLeft;
+ m_pRight = _pRight;
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::setSplitter(Splitter* _pSplitter)
+{
+ m_pSplitter = _pSplitter;
+ if ( m_pSplitter )
+ {
+ m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() );
+ m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) );
+ m_pSplitter->Show();
+ LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx
new file mode 100644
index 000000000000..cc092ccfe3b3
--- /dev/null
+++ b/dbaccess/source/ui/control/charsetlistbox.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "charsetlistbox.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= CharSetListBox
+ //====================================================================
+ //--------------------------------------------------------------------
+ CharSetListBox::CharSetListBox( Window* _pParent, const ResId& _rResId )
+ :ListBox( _pParent, _rResId )
+ {
+ SetDropDownLineCount( 20 );
+
+ OCharsetDisplay::const_iterator charSet = m_aCharSets.begin();
+ while ( charSet != m_aCharSets.end() )
+ {
+ InsertEntry( (*charSet).getDisplayName() );
+ ++charSet;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ CharSetListBox::~CharSetListBox()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void CharSetListBox::SelectEntryByIanaName( const String& _rIanaName )
+ {
+ OCharsetDisplay::const_iterator aFind = m_aCharSets.findIanaName( _rIanaName );
+ if (aFind == m_aCharSets.end())
+ {
+ OSL_FAIL( "CharSetListBox::SelectEntryByIanaName: unknown charset falling back to system language!" );
+ aFind = m_aCharSets.findEncoding( RTL_TEXTENCODING_DONTKNOW );
+ }
+
+ if ( aFind == m_aCharSets.end() )
+ {
+ SelectEntry( String() );
+ }
+ else
+ {
+ String sDisplayName = (*aFind).getDisplayName();
+ if ( LISTBOX_ENTRY_NOTFOUND == GetEntryPos( sDisplayName ) )
+ {
+ // in our settings, there was an encoding selected which is not valid for the current
+ // data source type
+ // This is worth at least an assertion.
+ OSL_FAIL( "CharSetListBox::SelectEntryByIanaName: invalid character set!" );
+ sDisplayName = String();
+ }
+
+ SelectEntry( sDisplayName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool CharSetListBox::StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId )
+ {
+ bool bChangedSomething = false;
+ if ( GetSelectEntryPos() != GetSavedValue() )
+ {
+ OCharsetDisplay::const_iterator aFind = m_aCharSets.findDisplayName( GetSelectEntry() );
+ OSL_ENSURE( aFind != m_aCharSets.end(), "CharSetListBox::StoreSelectedCharSet: could not translate the selected character set!" );
+ if ( aFind != m_aCharSets.end() )
+ {
+ _rSet.Put( SfxStringItem( _nItemId, (*aFind).getIanaName() ) );
+ bChangedSomething = true;
+ }
+ }
+ return bChangedSomething;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx
new file mode 100644
index 000000000000..d649647e70b0
--- /dev/null
+++ b/dbaccess/source/ui/control/curledit.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "curledit.hxx"
+#include <vcl/svapp.hxx>
+#include <osl/diagnose.h>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ DBG_NAME(OConnectionURLEdit)
+//=========================================================================
+//= OConnectionURLEdit
+//=========================================================================
+OConnectionURLEdit::OConnectionURLEdit(Window* _pParent, const ResId& _rResId,sal_Bool _bShowPrefix)
+ :Edit(_pParent, _rResId)
+ ,m_pTypeCollection(NULL)
+ ,m_pForcedPrefix(NULL)
+ ,m_bShowPrefix(_bShowPrefix)
+{
+ DBG_CTOR(OConnectionURLEdit ,NULL);
+}
+
+//-------------------------------------------------------------------------
+OConnectionURLEdit::~OConnectionURLEdit()
+{
+ DBG_DTOR(OConnectionURLEdit ,NULL);
+ // delete my sub controls
+ Edit* pSubEdit = GetSubEdit();
+ SetSubEdit(NULL);
+ delete pSubEdit;
+ delete m_pForcedPrefix;
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetTextNoPrefix(const String& _rText)
+{
+ OSL_ENSURE(GetSubEdit(), "OConnectionURLEdit::SetTextNoPrefix: have no current type, not changing the text!");
+ if (GetSubEdit())
+ GetSubEdit()->SetText(_rText);
+}
+
+//-------------------------------------------------------------------------
+String OConnectionURLEdit::GetTextNoPrefix() const
+{
+ if (GetSubEdit())
+ return GetSubEdit()->GetText();
+ return GetText();
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetText(const String& _rStr)
+{
+ Selection aNoSelection(0,0);
+ SetText(_rStr, aNoSelection);
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetText(const String& _rStr, const Selection& /*_rNewSelection*/)
+{
+ // create new sub controls, if necessary
+ if (!GetSubEdit())
+ SetSubEdit(new Edit(this, 0));
+ if ( !m_pForcedPrefix )
+ {
+ m_pForcedPrefix = new FixedText(this, WB_VCENTER);
+
+ // we use a gray background for the fixed text
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ m_pForcedPrefix->SetBackground(Wallpaper(aSystemStyle.GetDialogColor()));
+ }
+
+ m_pForcedPrefix->Show(m_bShowPrefix);
+
+ sal_Bool bIsEmpty = 0 == _rStr.Len();
+ // calc the prefix
+ String sPrefix;
+ if (!bIsEmpty)
+ {
+ // determine the type of the new URL described by the new text
+ sPrefix = m_pTypeCollection->getPrefix(_rStr);
+ }
+
+ // the fixed text gets the prefix
+ if ( m_pForcedPrefix )
+ m_pForcedPrefix->SetText(sPrefix);
+
+ // both subs have to be resized according to the text len of the prefix
+ Size aMySize = GetSizePixel();
+ sal_Int32 nTextWidth = 0;
+ if ( m_pForcedPrefix && m_bShowPrefix)
+ {
+ nTextWidth = m_pForcedPrefix->GetTextWidth(sPrefix) + 2;
+ m_pForcedPrefix->SetPosSizePixel(Point(0, -2), Size(nTextWidth, aMySize.Height()));
+ }
+ GetSubEdit()->SetPosSizePixel(Point(nTextWidth, -2), Size(aMySize.Width() - nTextWidth - 4, aMySize.Height()));
+ // -2 because the edit has a frame which is 2 pixel wide ... should not be necessary, but I don't fully understand this ....
+
+ // show the sub controls (in case they were just created)
+ GetSubEdit()->Show();
+
+ // do the real SetTex
+// Edit::SetText(bIsEmpty ? _rStr : m_pTypeCollection->cutPrefix(_rStr), _rNewSelection);
+ String sNewText( _rStr );
+ if ( !bIsEmpty )
+ sNewText = m_pTypeCollection->cutPrefix( _rStr );
+ Edit::SetText( sNewText );
+}
+
+//-------------------------------------------------------------------------
+String OConnectionURLEdit::GetText() const
+{
+ if ( m_pForcedPrefix )
+ return m_pForcedPrefix->GetText() += Edit::GetText();
+ return Edit::GetText();
+}
+// -----------------------------------------------------------------------------
+void OConnectionURLEdit::ShowPrefix(sal_Bool _bShowPrefix)
+{
+ m_bShowPrefix = _bShowPrefix;
+ if ( m_pForcedPrefix )
+ m_pForcedPrefix->Show(m_bShowPrefix);
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
new file mode 100644
index 000000000000..fe9da7403ab3
--- /dev/null
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -0,0 +1,725 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbtreelistbox.hxx"
+#include "dbu_resource.hrc"
+#include "browserids.hxx"
+#include "listviewitems.hxx"
+#include "callbacks.hxx"
+
+#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hdl>
+#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
+#include <com/sun/star/ui/XContextMenuInterceptor.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <vcl/help.hxx>
+#include "tabletree.hrc"
+#include "IController.hxx"
+#include <framework/actiontriggerhelper.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <framework/imageproducer.hxx>
+#include <vcl/svapp.hxx>
+#include <memory>
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::view;
+
+DBG_NAME(DBTreeListBox)
+#define SPACEBETWEENENTRIES 4
+//========================================================================
+// class DBTreeListBox
+//========================================================================
+//------------------------------------------------------------------------
+DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle ,sal_Bool _bHandleEnterKey)
+ :SvTreeListBox(pParent,nWinStyle)
+ ,m_pDragedEntry(NULL)
+ ,m_pActionListener(NULL)
+ ,m_pContextMenuProvider( NULL )
+ ,m_bHandleEnterKey(_bHandleEnterKey)
+ ,m_xORB(_rxORB)
+{
+ DBG_CTOR(DBTreeListBox,NULL);
+ init();
+}
+// -----------------------------------------------------------------------------
+DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId,sal_Bool _bHandleEnterKey)
+ :SvTreeListBox(pParent,rResId)
+ ,m_pDragedEntry(NULL)
+ ,m_pActionListener(NULL)
+ ,m_pContextMenuProvider( NULL )
+ ,m_bHandleEnterKey(_bHandleEnterKey)
+ ,m_xORB(_rxORB)
+{
+ DBG_CTOR(DBTreeListBox,NULL);
+ init();
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::init()
+{
+ sal_uInt16 nSize = SPACEBETWEENENTRIES;
+ SetSpaceBetweenEntries(nSize);
+
+ m_aTimer.SetTimeout(900);
+ m_aTimer.SetTimeoutHdl(LINK(this, DBTreeListBox, OnTimeOut));
+
+ m_aScrollHelper.setUpScrollMethod( LINK(this, DBTreeListBox, ScrollUpHdl) );
+ m_aScrollHelper.setDownScrollMethod( LINK(this, DBTreeListBox, ScrollDownHdl) );
+
+ SetNodeDefaultImages( );
+
+ EnableContextMenuHandling();
+
+ SetStyle( GetStyle() | WB_QUICK_SEARCH );
+}
+//------------------------------------------------------------------------
+DBTreeListBox::~DBTreeListBox()
+{
+ DBG_DTOR(DBTreeListBox,NULL);
+ implStopSelectionTimer();
+}
+//------------------------------------------------------------------------
+SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvLBoxEntry* pStart, const IEntryFilter* _pFilter ) const
+{
+ SvLBoxTreeList* myModel = GetModel();
+ SvTreeEntryList* pChilds = myModel->GetChildList(pStart);
+ SvLBoxEntry* pEntry = NULL;
+ if ( pChilds )
+ {
+ sal_uLong nCount = pChilds->Count();
+ for (sal_uLong i=0; i < nCount; ++i)
+ {
+ pEntry = static_cast<SvLBoxEntry*>(pChilds->GetObject(i));
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if ( pItem->GetText().Equals(aName) )
+ {
+ if ( !_pFilter || _pFilter->includeEntry( pEntry ) )
+ // found
+ break;
+ }
+ pEntry = NULL;
+ }
+ }
+
+ return pEntry;
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::EnableExpandHandler(SvLBoxEntry* _pEntry)
+{
+ LINK(this, DBTreeListBox, OnResetEntry).Call(_pEntry);
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
+{
+ if (m_aPreExpandHandler.IsSet())
+ {
+ if (!m_aPreExpandHandler.Call(pParent))
+ {
+ // an error occurred. The method calling us will reset the entry flags, so it can't be expanded again.
+ // But we want that the user may do a second try (i.e. because he misstypes a password in this try), so
+ // we have to reset these flags controlling the expand ability
+ PostUserEvent(LINK(this, DBTreeListBox, OnResetEntry), pParent);
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, const Image& _rCollEntryBmp, const Image& _rExpEntryBmp, SvLBoxButtonKind eButtonKind)
+{
+ SvTreeListBox::InitEntry( _pEntry, aStr, _rCollEntryBmp,_rExpEntryBmp, eButtonKind);
+ SvLBoxItem* pTextItem(_pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ SvLBoxString* pString = new OBoldListboxString( _pEntry, 0, aStr );
+ _pEntry->ReplaceItem( pString,_pEntry->GetPos(pTextItem));
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::implStopSelectionTimer()
+{
+ if ( m_aTimer.IsActive() )
+ m_aTimer.Stop();
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::implStartSelectionTimer()
+{
+ implStopSelectionTimer();
+ m_aTimer.Start();
+}
+
+// -----------------------------------------------------------------------------
+
+void DBTreeListBox::DeselectHdl()
+{
+ m_aSelectedEntries.erase( GetHdlEntry() );
+ SvTreeListBox::DeselectHdl();
+ implStartSelectionTimer();
+}
+// -------------------------------------------------------------------------
+void DBTreeListBox::SelectHdl()
+{
+ m_aSelectedEntries.insert( GetHdlEntry() );
+ SvTreeListBox::SelectHdl();
+ implStartSelectionTimer();
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ sal_Bool bHitEmptySpace = (NULL == GetEntry(rMEvt.GetPosPixel(), sal_True));
+ if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1())
+ Control::MouseButtonDown(rMEvt);
+ else
+ SvTreeListBox::MouseButtonDown(rMEvt);
+}
+
+// -------------------------------------------------------------------------
+IMPL_LINK(DBTreeListBox, OnResetEntry, SvLBoxEntry*, pEntry)
+{
+ // set the flag which allows if the entry can be expanded
+ pEntry->SetFlags( (pEntry->GetFlags() & ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN)) | SV_ENTRYFLAG_CHILDS_ON_DEMAND );
+ // redraw the entry
+ GetModel()->InvalidateEntry( pEntry );
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
+{
+ SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
+
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
+ {
+ SvLBoxItem* pTextItem = static_cast< SvLBoxEntry* >( _pEntry )->GetFirstItem( SV_ITEM_ID_BOLDLBSTRING );
+ if ( pTextItem && !static_cast< OBoldListboxString* >( pTextItem )->isEmphasized() )
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
+ // ehm - why?
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void DBTreeListBox::ModelHasRemoved( SvListEntry* _pEntry )
+{
+ SvTreeListBox::ModelHasRemoved(_pEntry);
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int8 DBTreeListBox::AcceptDrop( const AcceptDropEvent& _rEvt )
+{
+ sal_Int8 nDropOption = DND_ACTION_NONE;
+ if ( m_pActionListener )
+ {
+ SvLBoxEntry* pDroppedEntry = GetEntry(_rEvt.maPosPixel);
+ // check if drag is on child entry, which is not allowed
+ SvLBoxEntry* pParent = NULL;
+ if ( _rEvt.mnAction & DND_ACTION_MOVE )
+ {
+ if ( !m_pDragedEntry ) // no entry to move
+ {
+ nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
+ m_aMousePos = _rEvt.maPosPixel;
+ m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
+ return nDropOption;
+ }
+
+ pParent = pDroppedEntry ? GetParent(pDroppedEntry) : NULL;
+ while ( pParent && pParent != m_pDragedEntry )
+ pParent = GetParent(pParent);
+ }
+
+ if ( !pParent )
+ {
+ nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
+ // check if move is allowed
+ if ( nDropOption & DND_ACTION_MOVE )
+ {
+ if ( m_pDragedEntry == pDroppedEntry || GetEntryPosByName(GetEntryText(m_pDragedEntry),pDroppedEntry) )
+ nDropOption = nDropOption & ~DND_ACTION_MOVE;//DND_ACTION_NONE;
+ }
+ m_aMousePos = _rEvt.maPosPixel;
+ m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
+ }
+ }
+
+ return nDropOption;
+}
+
+// -------------------------------------------------------------------------
+sal_Int8 DBTreeListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
+{
+ if ( m_pActionListener )
+ return m_pActionListener->executeDrop( _rEvt );
+
+ return DND_ACTION_NONE;
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
+{
+ if ( m_pActionListener )
+ {
+ m_pDragedEntry = GetEntry(_rPosPixel);
+ if ( m_pDragedEntry && m_pActionListener->requestDrag( _nAction, _rPosPixel ) )
+ {
+ // if the (asynchronous) drag started, stop the selection timer
+ implStopSelectionTimer();
+ // and stop selecting entries by simply moving the mouse
+ EndSelection();
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::RequestHelp( const HelpEvent& rHEvt )
+{
+ if ( !m_pActionListener )
+ {
+ SvTreeListBox::RequestHelp( rHEvt );
+ return;
+ }
+
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ SvLBoxEntry* pEntry = GetEntry( aPos );
+ if( pEntry )
+ {
+ String sQuickHelpText;
+ if ( m_pActionListener->requestQuickHelp( pEntry, sQuickHelpText ) )
+ {
+ Size aSize( GetOutputSizePixel().Width(), GetEntryHeight() );
+ Rectangle aScreenRect( OutputToScreenPixel( GetEntryPosition( pEntry ) ), aSize );
+
+ Help::ShowQuickHelp( this, aScreenRect,
+ sQuickHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
+ return;
+ }
+ }
+ }
+
+ SvTreeListBox::RequestHelp( rHEvt );
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ sal_Bool bHandled = sal_False;
+
+ if(eFunc != KEYFUNC_DONTKNOW)
+ {
+ switch(eFunc)
+ {
+ case KEYFUNC_CUT:
+ bHandled = ( m_aCutHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aCutHandler.Call( NULL );
+ break;
+ case KEYFUNC_COPY:
+ bHandled = ( m_aCopyHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aCopyHandler.Call( NULL );
+ break;
+ case KEYFUNC_PASTE:
+ bHandled = ( m_aPasteHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aPasteHandler.Call( NULL );
+ break;
+ case KEYFUNC_DELETE:
+ bHandled = ( m_aDeleteHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aDeleteHandler.Call( NULL );
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ( KEY_RETURN == nCode )
+ {
+ bHandled = m_bHandleEnterKey;
+ if ( m_aEnterKeyHdl.IsSet() )
+ m_aEnterKeyHdl.Call(this);
+ // this is a HACK. If the data source browser is opened in the "beamer", while the main frame
+ // contains a writer document, then pressing enter in the DSB would be rerouted to the writer
+ // document if we would not do this hack here.
+ // The problem is that the Writer uses RETURN as _accelerator_ (which is quite weird itself),
+ // so the SFX framework is _obligated_ to pass it to the Writer if nobody else handled it. There
+ // is no chance to distinguish between
+ // "accelerators which are to be executed if the main document has the focus"
+ // and
+ // "accelerators which are always to be executed"
+ //
+ // Thus we cannot prevent the handling of this key in the writer without declaring the key event
+ // as "handled" herein.
+ //
+ // The bad thing about this approach is that it does not scale. Every other accelerator which
+ // is used by the document will raise a similar bug once somebody discovers it.
+ // If this is the case, we should discuss a real solution with the framework (SFX) and the
+ // applications.
+ }
+
+ if ( !bHandled )
+ SvTreeListBox::KeyInput(rKEvt);
+}
+// -----------------------------------------------------------------------------
+sal_Bool DBTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& /*_aSelection*/)
+{
+ return m_aEditingHandler.Call(pEntry) != 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool DBTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
+{
+ DBTreeEditedEntry aEntry;
+ aEntry.pEntry = pEntry;
+ aEntry.aNewText =rNewText;
+ if(m_aEditedHandler.Call(&aEntry) != 0)
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( pEntry );
+ }
+ SetEntryText(pEntry,aEntry.aNewText);
+
+ return sal_False; // we never want that the base change our text
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool DBTreeListBox::DoubleClickHdl()
+{
+ long nResult = aDoubleClickHdl.Call( this );
+ // continue default processing if the DoubleClickHandler didn't handle it
+ return nResult == 0;
+}
+
+// -----------------------------------------------------------------------------
+void scrollWindow(DBTreeListBox* _pListBox, const Point& _rPos,sal_Bool _bUp)
+{
+ SvLBoxEntry* pEntry = _pListBox->GetEntry( _rPos );
+ if( pEntry && pEntry != _pListBox->Last() )
+ {
+ _pListBox->ScrollOutputArea( _bUp ? -1 : 1 );
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( DBTreeListBox, ScrollUpHdl, SvTreeListBox*, /*pBox*/ )
+{
+ scrollWindow(this,m_aMousePos,sal_True);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DBTreeListBox, ScrollDownHdl, SvTreeListBox*, /*pBox*/ )
+{
+ scrollWindow(this,m_aMousePos,sal_False);
+ return 0;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_enableEntries( PopupMenu* _pPopup, IController& _rController )
+ {
+ if ( !_pPopup )
+ return;
+
+ sal_uInt16 nCount = _pPopup->GetItemCount();
+ for (sal_uInt16 i=0; i < nCount; ++i)
+ {
+ if ( _pPopup->GetItemType(i) != MENUITEM_SEPARATOR )
+ {
+ sal_uInt16 nId = _pPopup->GetItemId(i);
+ PopupMenu* pSubPopUp = _pPopup->GetPopupMenu(nId);
+ if ( pSubPopUp )
+ {
+ lcl_enableEntries( pSubPopUp, _rController );
+ _pPopup->EnableItem(nId,pSubPopUp->HasValidEntries());
+ }
+ else
+ {
+ ::rtl::OUString sCommandURL( _pPopup->GetItemCommand( nId ) );
+ bool bEnabled = ( sCommandURL.getLength() )
+ ? _rController.isCommandEnabled( sCommandURL )
+ : _rController.isCommandEnabled( nId );
+ _pPopup->EnableItem( nId, bEnabled );
+ }
+ }
+ }
+
+ _pPopup->RemoveDisabledEntries();
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_adjustMenuItemIDs( Menu& _rMenu, IController& _rCommandController )
+ {
+ sal_uInt16 nCount = _rMenu.GetItemCount();
+ for ( sal_uInt16 pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ sal_uInt16 nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_adjustMenuItemIDs( *pPopup, _rCommandController );
+ continue;
+ }
+
+ const sal_uInt16 nCommandId = _rCommandController.registerCommandURL( aCommand );
+ _rMenu.InsertItem( nCommandId, _rMenu.GetItemText( nId ), _rMenu.GetItemImage( nId ),
+ _rMenu.GetItemBits( nId ), pos );
+
+ // more things to preserve:
+ // - the help command
+ ::rtl::OUString sHelpURL = _rMenu.GetHelpCommand( nId );
+ if ( sHelpURL.getLength() )
+ _rMenu.SetHelpCommand( nCommandId, sHelpURL );
+
+ // remove the "old" item
+ _rMenu.RemoveItem( pos+1 );
+ }
+ }
+ void lcl_insertMenuItemImages( Menu& _rMenu, IController& _rCommandController )
+ {
+ uno::Reference< frame::XController > xController = _rCommandController.getXController();
+ uno::Reference< frame::XFrame> xFrame;
+ if ( xController.is() )
+ xFrame = xController->getFrame();
+ sal_uInt16 nCount = _rMenu.GetItemCount();
+ for ( sal_uInt16 pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ sal_uInt16 nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_insertMenuItemImages( *pPopup, _rCommandController );
+ continue;
+ }
+
+ if ( xFrame.is() )
+ _rMenu.SetItemImage(nId,framework::GetImageFromURL(xFrame,aCommand,sal_False));
+ }
+ }
+ // =========================================================================
+ // = SelectionSupplier
+ // =========================================================================
+ typedef ::cppu::WeakImplHelper1 < XSelectionSupplier
+ > SelectionSupplier_Base;
+ class SelectionSupplier : public SelectionSupplier_Base
+ {
+ public:
+ SelectionSupplier( const Any& _rSelection )
+ :m_aSelection( _rSelection )
+ {
+ }
+
+ virtual ::sal_Bool SAL_CALL select( const Any& xSelection ) throw (IllegalArgumentException, RuntimeException);
+ virtual Any SAL_CALL getSelection( ) throw (RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
+
+ protected:
+ virtual ~SelectionSupplier()
+ {
+ }
+
+ private:
+ Any m_aSelection;
+ };
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL SelectionSupplier::select( const Any& /*_Selection*/ ) throw (IllegalArgumentException, RuntimeException)
+ {
+ throw IllegalArgumentException();
+ // API bug: this should be a NoSupportException
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SelectionSupplier::getSelection( ) throw (RuntimeException)
+ {
+ return m_aSelection;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SelectionSupplier::addSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
+ {
+ OSL_FAIL( "SelectionSupplier::removeSelectionChangeListener: no support!" );
+ // API bug: this should be a NoSupportException
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SelectionSupplier::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
+ {
+ OSL_FAIL( "SelectionSupplier::removeSelectionChangeListener: no support!" );
+ // API bug: this should be a NoSupportException
+ }
+}
+
+// -----------------------------------------------------------------------------
+PopupMenu* DBTreeListBox::CreateContextMenu( void )
+{
+ ::std::auto_ptr< PopupMenu > pContextMenu;
+
+ if ( !m_pContextMenuProvider )
+ return pContextMenu.release();
+
+ // the basic context menu
+ pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) );
+ // disable what is not available currently
+ lcl_enableEntries( pContextMenu.get(), m_pContextMenuProvider->getCommandController() );
+ // set images
+ lcl_insertMenuItemImages( *pContextMenu, m_pContextMenuProvider->getCommandController() );
+ // allow context menu interception
+ ::cppu::OInterfaceContainerHelper* pInterceptors = m_pContextMenuProvider->getContextMenuInterceptors();
+ if ( !pInterceptors || !pInterceptors->getLength() )
+ return pContextMenu.release();
+
+ ContextMenuExecuteEvent aEvent;
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
+ aEvent.ExecutePosition.X = -1;
+ aEvent.ExecutePosition.Y = -1;
+ aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
+ m_xORB, pContextMenu.get(), 0 );
+ aEvent.Selection = new SelectionSupplier( m_pContextMenuProvider->getCurrentSelection( *this ) );
+
+ ::cppu::OInterfaceIteratorHelper aIter( *pInterceptors );
+ bool bModifiedMenu = false;
+ bool bAskInterceptors = true;
+ while ( aIter.hasMoreElements() && bAskInterceptors )
+ {
+ Reference< XContextMenuInterceptor > xInterceptor( aIter.next(), UNO_QUERY );
+ if ( !xInterceptor.is() )
+ continue;
+
+ try
+ {
+ ContextMenuInterceptorAction eAction = xInterceptor->notifyContextMenuExecute( aEvent );
+ switch ( eAction )
+ {
+ case ContextMenuInterceptorAction_CANCELLED:
+ return NULL;
+
+ case ContextMenuInterceptorAction_EXECUTE_MODIFIED:
+ bModifiedMenu = true;
+ bAskInterceptors = false;
+ break;
+
+ case ContextMenuInterceptorAction_CONTINUE_MODIFIED:
+ bModifiedMenu = true;
+ bAskInterceptors = true;
+ break;
+
+ default:
+ OSL_FAIL( "DBTreeListBox::CreateContextMenu: unexpected return value of the interceptor call!" );
+
+ case ContextMenuInterceptorAction_IGNORED:
+ break;
+ }
+ }
+ catch( const DisposedException& e )
+ {
+ if ( e.Context == xInterceptor )
+ aIter.remove();
+ }
+ }
+
+ if ( bModifiedMenu )
+ {
+ // the interceptor(s) modified the menu description => create a new PopupMenu
+ PopupMenu* pModifiedMenu = new PopupMenu;
+ ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(
+ pModifiedMenu, aEvent.ActionTriggerContainer );
+ aEvent.ActionTriggerContainer.clear();
+ pContextMenu.reset( pModifiedMenu );
+
+ // the interceptors only know command URLs, but our menus primarily work
+ // with IDs -> we need to translate the commands to IDs
+ lcl_adjustMenuItemIDs( *pModifiedMenu, m_pContextMenuProvider->getCommandController() );
+ }
+
+ return pContextMenu.release();
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeListBox::ExcecuteContextMenuAction( sal_uInt16 _nSelectedPopupEntry )
+{
+ if ( m_pContextMenuProvider && _nSelectedPopupEntry )
+ m_pContextMenuProvider->getCommandController().executeChecked( _nSelectedPopupEntry, Sequence< PropertyValue >() );
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(DBTreeListBox, OnTimeOut, void*, /*EMPTY_ARG*/)
+{
+ implStopSelectionTimer();
+
+ m_aSelChangeHdl.Call( NULL );
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::StateChanged( StateChangedType nStateChange )
+{
+ if ( nStateChange == STATE_CHANGE_VISIBLE )
+ implStopSelectionTimer();
+}
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/listviewitems.cxx b/dbaccess/source/ui/control/listviewitems.cxx
new file mode 100644
index 000000000000..74193e682409
--- /dev/null
+++ b/dbaccess/source/ui/control/listviewitems.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "listviewitems.hxx"
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //========================================================================
+ // class OBoldListboxString
+ //========================================================================
+ //------------------------------------------------------------------------
+ void OBoldListboxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* _pViewData)
+ {
+ SvLBoxString::InitViewData( pView, pEntry, _pViewData );
+ if ( !m_bEmphasized )
+ return;
+ if (!_pViewData)
+ _pViewData = pView->GetViewDataItem( pEntry, this );
+ pView->Push(PUSH_ALL);
+ Font aFont( pView->GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ pView->SetFont( aFont );
+ _pViewData->aSize = Size(pView->GetTextWidth(GetText()), pView->GetTextHeight());
+ pView->Pop();
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt16 OBoldListboxString::IsA()
+ {
+ return SV_ITEM_ID_BOLDLBSTRING;
+ }
+
+ //------------------------------------------------------------------------
+ void OBoldListboxString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry )
+ {
+ if (m_bEmphasized)
+ {
+ rDev.Push(PUSH_ALL);
+ Font aFont( rDev.GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ rDev.SetFont( aFont );
+ Point aPos(rPos);
+ rDev.DrawText( aPos, GetText() );
+ rDev.Pop();
+ }
+ else
+ SvLBoxString::Paint(rPos, rDev, nFlags, pEntry);
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/makefile.mk b/dbaccess/source/ui/control/makefile.mk
new file mode 100644
index 000000000000..913a4752e544
--- /dev/null
+++ b/dbaccess/source/ui/control/makefile.mk
@@ -0,0 +1,78 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=uicontrols
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ TableGrantCtrl.src \
+ undosqledit.src \
+ tabletree.src
+
+# ... exception files .........................
+
+EXCEPTIONSFILES=\
+ $(SLO)$/ColumnControlWindow.obj \
+ $(SLO)$/FieldDescControl.obj \
+ $(SLO)$/RelationControl.obj \
+ $(SLO)$/SqlNameEdit.obj \
+ $(SLO)$/TableGrantCtrl.obj \
+ $(SLO)$/VertSplitView.obj \
+ $(SLO)$/charsetlistbox.obj \
+ $(SLO)$/curledit.obj \
+ $(SLO)$/dbtreelistbox.obj \
+ $(SLO)$/listviewitems.obj \
+ $(SLO)$/marktree.obj \
+ $(SLO)$/opendoccontrols.obj \
+ $(SLO)$/sqledit.obj \
+ $(SLO)$/statusbarontroller.obj \
+ $(SLO)$/tabletree.obj \
+ $(SLO)$/toolboxcontroller.obj \
+ $(SLO)$/undosqledit.obj
+
+# ... object files ............................
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/ScrollHelper.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ui/control/marktree.cxx b/dbaccess/source/ui/control/marktree.cxx
new file mode 100644
index 000000000000..e97f8a4a33fc
--- /dev/null
+++ b/dbaccess/source/ui/control/marktree.cxx
@@ -0,0 +1,242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "marktree.hxx"
+#include "dbu_control.hrc"
+#include <vcl/svapp.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+//.........................................................................
+#define SPACEBETWEENENTRIES 4
+//========================================================================
+//= OMarkableTreeListBox
+//========================================================================
+DBG_NAME(OMarkableTreeListBox)
+//------------------------------------------------------------------------
+OMarkableTreeListBox::OMarkableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle )
+ : DBTreeListBox(pParent,_rxORB,nWinStyle)
+{
+ DBG_CTOR(OMarkableTreeListBox,NULL);
+
+ InitButtonData();
+}
+//------------------------------------------------------------------------
+OMarkableTreeListBox::OMarkableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId)
+ : DBTreeListBox(pParent,_rxORB,rResId)
+{
+ DBG_CTOR(OMarkableTreeListBox,NULL);
+
+ InitButtonData();
+}
+//------------------------------------------------------------------------
+OMarkableTreeListBox::~OMarkableTreeListBox()
+{
+ delete m_pCheckButton;
+
+ DBG_DTOR(OMarkableTreeListBox,NULL);
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::Paint(const Rectangle& _rRect)
+{
+ if (!IsEnabled())
+ {
+ Font aOldFont = GetFont();
+ Font aNewFont(aOldFont);
+
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ aNewFont.SetColor(aSystemStyle.GetDisableColor());
+
+ SetFont(aNewFont);
+ DBTreeListBox::Paint(_rRect);
+ SetFont(aOldFont);
+ }
+ else
+ DBTreeListBox::Paint(_rRect);
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::InitButtonData()
+{
+ m_pCheckButton = new SvLBoxButtonData( this );
+ EnableCheckButton( m_pCheckButton );
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ // nur wenn space
+ if (rKEvt.GetKeyCode().GetCode() == KEY_SPACE && !rKEvt.GetKeyCode().IsShift() && !rKEvt.GetKeyCode().IsMod1())
+ {
+ SvLBoxEntry* pCurrentHandlerEntry = GetHdlEntry();
+ if(pCurrentHandlerEntry)
+ {
+ SvButtonState eState = GetCheckButtonState( pCurrentHandlerEntry);
+ if(eState == SV_BUTTON_CHECKED)
+ SetCheckButtonState( pCurrentHandlerEntry, SV_BUTTON_UNCHECKED);
+ else
+ SetCheckButtonState( pCurrentHandlerEntry, SV_BUTTON_CHECKED);
+
+ CheckButtonHdl();
+ }
+ else
+ DBTreeListBox::KeyInput(rKEvt);
+ }
+ else
+ DBTreeListBox::KeyInput(rKEvt);
+
+}
+//------------------------------------------------------------------------
+SvButtonState OMarkableTreeListBox::implDetermineState(SvLBoxEntry* _pEntry)
+{
+ SvButtonState eState = GetCheckButtonState(_pEntry);
+ if (!GetModel()->HasChilds(_pEntry))
+ // nothing to do in this bottom-up routine if there are no children ...
+ return eState;
+#ifdef DBG_UTIL
+ String sEntryText =GetEntryText(_pEntry);
+#endif
+
+ // loop through the children and check their states
+ sal_uInt16 nCheckedChildren = 0;
+ sal_uInt16 nChildrenOverall = 0;
+
+ SvLBoxEntry* pChildLoop = GetModel()->FirstChild(_pEntry);
+ while (pChildLoop)
+ {
+#ifdef DBG_UTIL
+ String sChildText =GetEntryText(pChildLoop);
+#endif
+ SvButtonState eChildState = implDetermineState(pChildLoop);
+ if (SV_BUTTON_TRISTATE == eChildState)
+ break;
+
+ if (SV_BUTTON_CHECKED == eChildState)
+ ++nCheckedChildren;
+ ++nChildrenOverall;
+
+ pChildLoop = GetModel()->NextSibling(pChildLoop);
+ }
+
+ if (pChildLoop)
+ {
+ // we did not finish the loop because at least one of the children is in tristate
+ eState = SV_BUTTON_TRISTATE;
+
+ // but this means that we did not finish all the siblings of pChildLoop,
+ // so their checking may be incorrect at the moment
+ // -> correct this
+ while (pChildLoop)
+ {
+ implDetermineState(pChildLoop);
+ pChildLoop = GetModel()->NextSibling(pChildLoop);
+ }
+ }
+ else
+ // none if the children are in tristate
+ if (nCheckedChildren)
+ // we have at least one child checked
+ if (nCheckedChildren != nChildrenOverall)
+ // not all children are checked
+ eState = SV_BUTTON_TRISTATE;
+ else
+ // all children are checked
+ eState = SV_BUTTON_CHECKED;
+ else
+ // no children are checked
+ eState = SV_BUTTON_UNCHECKED;
+
+ // finally set the entry to the state we just determined
+ SetCheckButtonState(_pEntry, eState);
+
+ // outta here
+ return eState;
+}
+
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::CheckButtons()
+{
+ SvLBoxEntry* pEntry = GetModel()->First();
+ while (pEntry)
+ {
+ implDetermineState(pEntry);
+ pEntry = GetModel()->NextSibling(pEntry);
+ }
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::CheckButtonHdl()
+{
+ checkedButton_noBroadcast(GetHdlEntry());
+ if (m_aCheckButtonHandler.IsSet())
+ m_aCheckButtonHandler.Call(this);
+}
+
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::checkedButton_noBroadcast(SvLBoxEntry* _pEntry)
+{
+ SvButtonState eState = GetCheckButtonState( _pEntry);
+ if (GetModel()->HasChilds(_pEntry)) // Falls Kinder, dann diese auch checken
+ {
+ SvLBoxEntry* pChildEntry = GetModel()->Next(_pEntry);
+ SvLBoxEntry* pSiblingEntry = GetModel()->NextSibling(_pEntry);
+ while(pChildEntry && pChildEntry != pSiblingEntry)
+ {
+ SetCheckButtonState(pChildEntry, eState);
+ pChildEntry = GetModel()->Next(pChildEntry);
+ }
+ }
+
+ SvLBoxEntry* pEntry = IsSelected(_pEntry) ? FirstSelected() : NULL;
+ while(pEntry)
+ {
+ SetCheckButtonState(pEntry,eState);
+ if(GetModel()->HasChilds(pEntry)) // Falls Kinder, dann diese auch checken
+ {
+ SvLBoxEntry* pChildEntry = GetModel()->Next(pEntry);
+ SvLBoxEntry* pSiblingEntry = GetModel()->NextSibling(pEntry);
+ while(pChildEntry && pChildEntry != pSiblingEntry)
+ {
+ SetCheckButtonState(pChildEntry,eState);
+ pChildEntry = GetModel()->Next(pChildEntry);
+ }
+ }
+ pEntry = NextSelected(pEntry);
+ }
+ CheckButtons();
+}
+
+//------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
new file mode 100644
index 000000000000..e02b7c000501
--- /dev/null
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -0,0 +1,335 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "opendoccontrols.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/ui/XImageManager.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/help.hxx>
+#include <unotools/historyoptions.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/filenotation.hxx>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ namespace
+ {
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
+ using ::com::sun::star::ui::XUIConfigurationManager;
+ using ::com::sun::star::ui::XImageManager;
+ using ::com::sun::star::graphic::XGraphic;
+
+ String GetCommandText( const sal_Char* _pCommandURL, const ::rtl::OUString& _rModuleName )
+ {
+ ::rtl::OUString sLabel;
+ if ( !_pCommandURL || !*_pCommandURL )
+ return sLabel;
+
+ Reference< XNameAccess > xUICommandLabels;
+ ::rtl::OUString sCommandURL = ::rtl::OUString::createFromAscii( _pCommandURL );
+
+ try
+ {
+ do
+ {
+ // Retrieve popup menu labels
+ Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ if ( !xFactory.is() )
+ break;
+
+ Reference< XNameAccess> xNameAccess;
+ xNameAccess = xNameAccess.query( xFactory->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) )
+ ) );
+ if ( !xNameAccess.is() )
+ break;
+
+ xNameAccess->getByName( _rModuleName ) >>= xUICommandLabels;
+ if ( !xUICommandLabels.is() )
+ break;
+
+ Sequence< PropertyValue > aProperties;
+ if ( !( xUICommandLabels->getByName(sCommandURL) >>= aProperties ) )
+ break;
+
+ sal_Int32 nCount( aProperties.getLength() );
+ for ( sal_Int32 i=0; i<nCount; ++i )
+ {
+ ::rtl::OUString sPropertyName( aProperties[i].Name );
+ if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Label" ) ) )
+ {
+ aProperties[i].Value >>= sLabel;
+ break;
+ }
+ }
+ }
+ while ( false );
+ }
+ catch( Exception& rException )
+ {
+ (void)rException;
+ }
+
+ return sLabel;
+ }
+
+ Image GetCommandIcon( const sal_Char* _pCommandURL, const ::rtl::OUString& _rModuleName )
+ {
+ Image aIcon;
+ if ( !_pCommandURL || !*_pCommandURL )
+ return aIcon;
+
+ Reference< XNameAccess > xUICommandLabels;
+ ::rtl::OUString sCommandURL = ::rtl::OUString::createFromAscii( _pCommandURL );
+ try
+ {
+ do
+ {
+ // Retrieve popup menu labels
+ Reference< XMultiServiceFactory> xFactory( ::comphelper::getProcessServiceFactory() );
+ if ( !xFactory.is() )
+ break;
+
+ Reference< XModuleUIConfigurationManagerSupplier > xSupplier(
+ xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ),
+ UNO_QUERY_THROW );
+
+ Reference< XUIConfigurationManager > xManager( xSupplier->getUIConfigurationManager( _rModuleName ) );
+ Reference< XImageManager > xImageManager;
+ if ( xManager.is() )
+ xImageManager = xImageManager.query( xManager->getImageManager() );
+ if ( !xImageManager.is() )
+ break;
+
+ Sequence< ::rtl::OUString > aCommandList( &sCommandURL, 1 );
+ Sequence<Reference< XGraphic> > xIconList( xImageManager->getImages( 0, aCommandList ) );
+ if ( !xIconList.hasElements() )
+ break;
+
+ aIcon = Graphic( xIconList[0] ).GetBitmapEx();
+ }
+ while ( false );
+ }
+ catch ( Exception& rException )
+ {
+ (void)rException;
+ }
+
+ return aIcon;
+ }
+
+
+ }
+
+ //====================================================================
+ //= OpenButton
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenDocumentButton::OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId )
+ :PushButton( _pParent, _rResId )
+ {
+ impl_init( _pAsciiModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentButton::impl_init( const sal_Char* _pAsciiModuleName )
+ {
+ OSL_ENSURE( _pAsciiModuleName, "OpenDocumentButton::impl_init: invalid module name!" );
+ m_sModule = ::rtl::OUString::createFromAscii( _pAsciiModuleName );
+
+ // our label should equal the UI text of the "Open" command
+ String sLabel( GetCommandText( ".uno:Open", m_sModule ) );
+ sLabel.SearchAndReplaceAllAscii( "~", String() );
+ sLabel.Insert( (sal_Unicode)' ', 0 );
+ SetText( sLabel );
+
+ // Place icon left of text and both centered in the button.
+ SetModeImage( GetCommandIcon( ".uno:Open", m_sModule ) );
+ EnableImageDisplay( sal_True );
+ EnableTextDisplay( sal_True );
+ SetImageAlign( IMAGEALIGN_LEFT );
+ SetStyle( GetStyle() | WB_CENTER );
+ }
+
+ //====================================================================
+ //= OpenDocumentListBox
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenDocumentListBox::OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId )
+ :ListBox( _pParent, _rResId )
+ {
+ impl_init( _pAsciiModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentListBox::impl_init( const sal_Char* _pAsciiModuleName )
+ {
+ OSL_ENSURE( _pAsciiModuleName, "OpenDocumentListBox::impl_init: invalid module name!" );
+
+ Sequence< Sequence< PropertyValue> > aHistory = SvtHistoryOptions().GetList( ePICKLIST );
+ Reference< XNameAccess > xFilterFactory;
+ xFilterFactory = xFilterFactory.query( ::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ) ) );
+
+ sal_uInt32 nCount = aHistory.getLength();
+ for ( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
+ {
+ try
+ {
+ // Get the current history item's properties.
+ ::comphelper::SequenceAsHashMap aItemProperties( aHistory[ nItem ] );
+ ::rtl::OUString sURL = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_URL, ::rtl::OUString() );
+ ::rtl::OUString sFilter = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_FILTER, ::rtl::OUString() );
+ String sTitle = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_TITLE, ::rtl::OUString() );
+ ::rtl::OUString sPassword = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_PASSWORD, ::rtl::OUString() );
+
+ // If the entry is an impress file then insert it into the
+ // history list and the list box.
+ Sequence< PropertyValue > aProps;
+ xFilterFactory->getByName( sFilter ) >>= aProps;
+
+ ::comphelper::SequenceAsHashMap aFilterProperties( aProps );
+ ::rtl::OUString sDocumentService = aFilterProperties.getUnpackedValueOrDefault(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" ) ), ::rtl::OUString() );
+ if ( sDocumentService.equalsAscii( _pAsciiModuleName ) )
+ {
+ // yes, it's a Base document
+ INetURLObject aURL;
+ aURL.SetSmartURL( sURL );
+ // The password is set only when it is not empty.
+ if ( sPassword.getLength() > 0 )
+ aURL.SetPass( sPassword );
+
+ if ( !sTitle.Len() )
+ sTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
+
+ String sDecodedURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ sal_uInt16 nPos = InsertEntry( sTitle );
+ m_aURLs.insert( MapIndexToStringPair::value_type( nPos, StringPair( sDecodedURL, sFilter ) ) );
+ }
+ }
+ catch( Exception& rException )
+ {
+ (void)rException;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentURL() const
+ {
+ String sURL;
+ sal_uInt16 nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sURL = impl_getDocumentAtIndex( nSelected ).first;
+ return sURL;
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentFilter() const
+ {
+ String sFilter;
+ sal_uInt16 nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sFilter = impl_getDocumentAtIndex( nSelected ).second;
+ return sFilter;
+ }
+
+ //--------------------------------------------------------------------
+ OpenDocumentListBox::StringPair OpenDocumentListBox::impl_getDocumentAtIndex( sal_uInt16 _nListIndex, bool _bSystemNotation ) const
+ {
+ MapIndexToStringPair::const_iterator pos = m_aURLs.find( _nListIndex );
+ OSL_ENSURE( pos != m_aURLs.end(), "OpenDocumentListBox::impl_getDocumentAtIndex: invalid index!" );
+
+ StringPair aDocumentDescriptor;
+ if ( pos != m_aURLs.end() )
+ {
+ aDocumentDescriptor = pos->second;
+ if ( _bSystemNotation && aDocumentDescriptor.first.Len() )
+ {
+ ::svt::OFileNotation aNotation( aDocumentDescriptor.first );
+ aDocumentDescriptor.first = aNotation.get( ::svt::OFileNotation::N_SYSTEM );
+ }
+ }
+ return aDocumentDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentListBox::RequestHelp( const HelpEvent& _rHEvt )
+ {
+ if( !( _rHEvt.GetMode() & HELPMODE_QUICK ) )
+ return;
+ if ( !IsEnabled() )
+ return;
+
+ Point aRequestPos( ScreenToOutputPixel( _rHEvt.GetMousePosPixel() ) );
+ sal_uInt16 nItemIndex = LISTBOX_ENTRY_NOTFOUND;
+ if ( GetIndexForPoint( aRequestPos, nItemIndex ) != -1 )
+ {
+ Rectangle aItemRect( GetBoundingRectangle( nItemIndex ) );
+ aItemRect = Rectangle(
+ OutputToScreenPixel( aItemRect.TopLeft() ),
+ OutputToScreenPixel( aItemRect.BottomRight() ) );
+ String sHelpText = impl_getDocumentAtIndex( nItemIndex, true ).first;
+ Help::ShowQuickHelp( this, aItemRect, sHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
+ }
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
new file mode 100644
index 000000000000..1caa8917be8b
--- /dev/null
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "sqledit.hxx"
+#include "QueryTextView.hxx"
+#include "querycontainerwindow.hxx"
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "browserids.hxx"
+#include "querycontroller.hxx"
+#include "undosqledit.hxx"
+#include "QueryDesignView.hxx"
+
+#include <svl/smplhint.hxx>
+
+//////////////////////////////////////////////////////////////////////////
+// OSqlEdit
+//------------------------------------------------------------------------------
+using namespace dbaui;
+
+DBG_NAME(OSqlEdit)
+OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) :
+ MultiLineEditSyntaxHighlight( pParent, nWinStyle )
+ ,m_pView(pParent)
+ ,m_bAccelAction( sal_False )
+ ,m_bStopTimer(sal_False )
+{
+ DBG_CTOR(OSqlEdit,NULL);
+ SetHelpId( HID_CTL_QRYSQLEDIT );
+ SetModifyHdl( LINK(this, OSqlEdit, ModifyHdl) );
+
+ m_timerUndoActionCreation.SetTimeout(1000);
+ m_timerUndoActionCreation.SetTimeoutHdl(LINK(this, OSqlEdit, OnUndoActionTimer));
+
+ m_timerInvalidate.SetTimeout(200);
+ m_timerInvalidate.SetTimeoutHdl(LINK(this, OSqlEdit, OnInvalidateTimer));
+ m_timerInvalidate.Start();
+
+ ImplSetFont();
+ // listen for change of Font and Color Settings
+ m_SourceViewConfig.AddListener( this );
+ m_ColorConfig.AddListener(this);
+
+ //#i97044#
+ EnableFocusSelectionHide( sal_False );
+}
+
+//------------------------------------------------------------------------------
+OSqlEdit::~OSqlEdit()
+{
+ DBG_DTOR(OSqlEdit,NULL);
+ if (m_timerUndoActionCreation.IsActive())
+ m_timerUndoActionCreation.Stop();
+ m_SourceViewConfig.RemoveListener(this);
+ m_ColorConfig.RemoveListener(this);
+}
+//------------------------------------------------------------------------------
+void OSqlEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+
+ // Ist dies ein Cut, Copy, Paste Event?
+ KeyFuncType aKeyFunc = rKEvt.GetKeyCode().GetFunction();
+ if( (aKeyFunc==KEYFUNC_CUT)||(aKeyFunc==KEYFUNC_COPY)||(aKeyFunc==KEYFUNC_PASTE) )
+ m_bAccelAction = sal_True;
+
+ MultiLineEditSyntaxHighlight::KeyInput( rKEvt );
+
+ if( m_bAccelAction )
+ m_bAccelAction = sal_False;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OSqlEdit::IsInAccelAct()
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ // Das Cut, Copy, Paste per Accel. fuehrt neben der Aktion im Edit im View
+ // auch die entsprechenden Slots aus. Die Aktionen finden also zweimal statt.
+ // Um dies zu verhindern, kann im View beim SlotExec diese Funktion
+ // aufgerufen werden.
+
+ return m_bAccelAction;
+}
+
+//------------------------------------------------------------------------------
+void OSqlEdit::GetFocus()
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ m_strOrigText =GetText();
+ MultiLineEditSyntaxHighlight::GetFocus();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, OnUndoActionTimer, void*, EMPTYARG)
+{
+ String aText =GetText();
+ if(aText != m_strOrigText)
+ {
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ SfxUndoManager& rUndoMgr = rController.GetUndoManager();
+ OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this );
+
+ pUndoAct->SetOriginalText( m_strOrigText );
+ rUndoMgr.AddUndoAction( pUndoAct );
+
+ rController.InvalidateFeature(SID_UNDO);
+ rController.InvalidateFeature(SID_REDO);
+
+ m_strOrigText =aText;
+ }
+
+ return 0L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, OnInvalidateTimer, void*, EMPTYARG)
+{
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+ if(!m_bStopTimer)
+ m_timerInvalidate.Start();
+ return 0L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, ModifyHdl, void*, /*EMPTYTAG*/)
+{
+ if (m_timerUndoActionCreation.IsActive())
+ m_timerUndoActionCreation.Stop();
+ m_timerUndoActionCreation.Start();
+
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ if (!rController.isModified())
+ rController.setModified( sal_True );
+
+ rController.InvalidateFeature(SID_SBA_QRY_EXECUTE);
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+
+ m_lnkTextModifyHdl.Call(NULL);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OSqlEdit::SetText(const String& rNewText)
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ if (m_timerUndoActionCreation.IsActive())
+ { // die noch anstehenden Undo-Action erzeugen
+ m_timerUndoActionCreation.Stop();
+ LINK(this, OSqlEdit, OnUndoActionTimer).Call(NULL);
+ }
+
+ MultiLineEditSyntaxHighlight::SetText(rNewText);
+ m_strOrigText =rNewText;
+}
+// -----------------------------------------------------------------------------
+void OSqlEdit::stopTimer()
+{
+ m_bStopTimer = sal_True;
+ if (m_timerInvalidate.IsActive())
+ m_timerInvalidate.Stop();
+}
+// -----------------------------------------------------------------------------
+void OSqlEdit::startTimer()
+{
+ m_bStopTimer = sal_False;
+ if (!m_timerInvalidate.IsActive())
+ m_timerInvalidate.Start();
+}
+
+void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, sal_uInt32 )
+{
+ if ( pOption == &m_SourceViewConfig )
+ ImplSetFont();
+ else if ( pOption == &m_ColorConfig )
+ MultiLineEditSyntaxHighlight::UpdateData();
+}
+
+void OSqlEdit::ImplSetFont()
+{
+ AllSettings aSettings = GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ String sFontName = m_SourceViewConfig.GetFontName();
+ if ( !sFontName.Len() )
+ {
+ Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
+ sFontName = aTmpFont.GetName();
+ }
+ Size aFontSize( 0, m_SourceViewConfig.GetFontHeight() );
+ Font aFont( sFontName, aFontSize );
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ SetSettings(aSettings);
+}
+//==============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/statusbarontroller.cxx b/dbaccess/source/ui/control/statusbarontroller.cxx
new file mode 100644
index 000000000000..37cb9c85f990
--- /dev/null
+++ b/dbaccess/source/ui/control/statusbarontroller.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "statusbarontroller.hxx"
+#include "dbu_reghelper.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OStatusbarController()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OStatusbarController> aAutoRegistration;
+}
+namespace dbaui
+{
+ using namespace svt;
+ using namespace com::sun::star::uno;
+ using namespace com::sun::star::beans;
+ using namespace com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+
+ IMPLEMENT_SERVICE_INFO1_STATIC(OStatusbarController,"com.sun.star.sdb.ApplicationStatusbarController","com.sun.star.frame.StatusbarController")
+ IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController,StatusbarController,OStatusbarController_BASE)
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
new file mode 100644
index 000000000000..c1c12947cb9b
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -0,0 +1,685 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "tabletree.hxx"
+#include "tabletree.hrc"
+#include "imageprovider.hxx"
+#include "moduledbu.hxx"
+#include "dbu_control.hrc"
+#include <vcl/menu.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/types.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "commontypes.hxx"
+#include "listviewitems.hxx"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
+#include <connectivity/dbmetadata.hxx>
+
+#include <algorithm>
+#include <o3tl/compat_functional.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb::application;
+
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+
+//========================================================================
+//= OTableTreeListBox
+//========================================================================
+OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle,sal_Bool _bVirtualRoot )
+ :OMarkableTreeListBox(pParent,_rxORB,nWinStyle)
+ ,m_pImageProvider( new ImageProvider )
+ ,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
+{
+ implSetDefaultImages();
+}
+//------------------------------------------------------------------------
+OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId ,sal_Bool _bVirtualRoot)
+ :OMarkableTreeListBox(pParent,_rxORB,rResId)
+ ,m_pImageProvider( new ImageProvider )
+ ,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
+{
+ implSetDefaultImages();
+}
+
+// -----------------------------------------------------------------------------
+OTableTreeListBox::~OTableTreeListBox()
+{
+}
+
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::implSetDefaultImages()
+{
+ ImageProvider aImageProvider;
+ SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE ) );
+ SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE ) );
+}
+
+// -----------------------------------------------------------------------------
+bool OTableTreeListBox::isFolderEntry( const SvLBoxEntry* _pEntry ) const
+{
+ sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
+ if ( ( nEntryType == DatabaseObjectContainer::TABLES )
+ || ( nEntryType == DatabaseObjectContainer::CATALOG )
+ || ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ )
+ return true;
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::notifyHiContrastChanged()
+{
+ implSetDefaultImages();
+
+ SvLBoxEntry* pEntryLoop = First();
+ while (pEntryLoop)
+ {
+ sal_uInt16 nCount = pEntryLoop->ItemCount();
+ for (sal_uInt16 i=0;i<nCount;++i)
+ {
+ SvLBoxItem* pItem = pEntryLoop->GetItem(i);
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXCONTEXTBMP)
+ {
+ SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
+
+ Image aImage;
+ if ( isFolderEntry( pEntryLoop ) )
+ {
+ aImage = m_pImageProvider->getFolderImage( DatabaseObject::TABLE );
+ }
+ else
+ {
+ String sCompleteName( getQualifiedTableName( pEntryLoop ) );
+ m_pImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage );
+ }
+
+ pContextBitmapItem->SetBitmap1( aImage );
+ pContextBitmapItem->SetBitmap2( aImage );
+ break;
+ }
+ }
+ pEntryLoop = Next(pEntryLoop);
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rxConnection )
+{
+ m_xConnection = _rxConnection;
+ m_pImageProvider.reset( new ImageProvider( m_xConnection ) );
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection ) throw(SQLException)
+{
+ Sequence< ::rtl::OUString > sTables, sViews;
+
+ String sCurrentActionError;
+ try
+ {
+ Reference< XTablesSupplier > xTableSupp( _rxConnection, UNO_QUERY_THROW );
+ sCurrentActionError = String(ModuleRes(STR_NOTABLEINFO));
+
+ Reference< XNameAccess > xTables,xViews;
+
+ Reference< XViewsSupplier > xViewSupp( _rxConnection, UNO_QUERY );
+ if ( xViewSupp.is() )
+ {
+ xViews = xViewSupp->getViews();
+ if (xViews.is())
+ sViews = xViews->getElementNames();
+ }
+
+ xTables = xTableSupp->getTables();
+ if (xTables.is())
+ sTables = xTables->getElementNames();
+ }
+ catch(RuntimeException&)
+ {
+ OSL_FAIL("OTableTreeListBox::UpdateTableList : caught an RuntimeException!");
+ }
+ catch ( const SQLException& )
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ // a non-SQLException exception occurred ... simply throw an SQLException
+ SQLException aInfo;
+ aInfo.Message = sCurrentActionError;
+ throw aInfo;
+ }
+
+ UpdateTableList( _rxConnection, sTables, sViews );
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ struct OViewSetter : public ::std::unary_function< OTableTreeListBox::TNames::value_type, bool>
+ {
+ const Sequence< ::rtl::OUString> m_aViews;
+ ::comphelper::TStringMixEqualFunctor m_aEqualFunctor;
+
+ OViewSetter(const Sequence< ::rtl::OUString>& _rViews,sal_Bool _bCase) : m_aViews(_rViews),m_aEqualFunctor(_bCase){}
+ OTableTreeListBox::TNames::value_type operator() (const ::rtl::OUString& lhs)
+ {
+ OTableTreeListBox::TNames::value_type aRet;
+ aRet.first = lhs;
+ const ::rtl::OUString* pIter = m_aViews.getConstArray();
+ const ::rtl::OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength();
+ aRet.second = (::std::find_if(pIter,pEnd,::std::bind2nd(m_aEqualFunctor,lhs)) != pEnd);
+
+ return aRet;
+ }
+ };
+
+}
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList(
+ const Reference< XConnection >& _rxConnection,
+ const Sequence< ::rtl::OUString>& _rTables,
+ const Sequence< ::rtl::OUString>& _rViews
+ )
+{
+ TNames aTables;
+ aTables.resize(_rTables.getLength());
+ const ::rtl::OUString* pIter = _rTables.getConstArray();
+ const ::rtl::OUString* pEnd = _rTables.getConstArray() + _rTables.getLength();
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ ::std::transform( pIter, pEnd,
+ aTables.begin(), OViewSetter( _rViews, xMeta->supportsMixedCaseQuotedIdentifiers() ) );
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ UpdateTableList( _rxConnection, aTables );
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ ::std::vector< ::rtl::OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex )
+ {
+ ::std::vector< ::rtl::OUString > aStrings;
+ Reference< XRow > xRow( _rxMetaDataResult, UNO_QUERY_THROW );
+ while ( _rxMetaDataResult->next() )
+ aStrings.push_back( xRow->getString( _nColumnIndex ) );
+ return aStrings;
+ }
+
+ bool lcl_shouldDisplayEmptySchemasAndCatalogs( const Reference< XConnection >& _rxConnection )
+ {
+ ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
+ return aMetaData.displayEmptyTableFolders();
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables )
+{
+ implOnNewConnection( _rxConnection );
+
+ // throw away all the old stuff
+ Clear();
+
+ try
+ {
+ if (haveVirtualRoot())
+ {
+ String sRootEntryText;
+ TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::o3tl::select2nd<TNames::value_type>()));
+ TNames::const_iterator aTables = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::o3tl::select2nd<TNames::value_type>()));
+
+ if ( aViews == _rTables.end() )
+ sRootEntryText = String(ModuleRes(STR_ALL_TABLES));
+ else if ( aTables == _rTables.end() )
+ sRootEntryText = String(ModuleRes(STR_ALL_VIEWS));
+ else
+ sRootEntryText = String(ModuleRes(STR_ALL_TABLES_AND_VIEWS));
+ InsertEntry( sRootEntryText, NULL, sal_False, LIST_APPEND, reinterpret_cast< void* >( DatabaseObjectContainer::TABLES ) );
+ }
+
+ if ( _rTables.empty() )
+ // nothing to do (besides inserting the root entry)
+ return;
+
+ // get the table/view names
+ TNames::const_iterator aIter = _rTables.begin();
+ TNames::const_iterator aEnd = _rTables.end();
+
+ Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ // add the entry
+ implAddEntry(
+ xMeta,
+ aIter->first,
+ sal_False
+ );
+ }
+
+ if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) )
+ {
+ sal_Bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation();
+ sal_Bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation();
+
+ if ( bSupportsCatalogs || bSupportsSchemas )
+ {
+ // we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a
+ // composed name. Otherwise, we display empty schematas. (also see the tree structure explained in
+ // implAddEntry)
+ bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart();
+
+ ::std::vector< ::rtl::OUString > aFolderNames( lcl_getMetaDataStrings_throw(
+ bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) );
+ sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+
+ SvLBoxEntry* pRootEntry = getAllObjectsEntry();
+ for ( ::std::vector< ::rtl::OUString >::const_iterator folder = aFolderNames.begin();
+ folder != aFolderNames.end();
+ ++folder
+ )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( *folder, pRootEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( *folder, pRootEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderType ) );
+ }
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+//------------------------------------------------------------------------
+sal_Bool OTableTreeListBox::isWildcardChecked(SvLBoxEntry* _pEntry) const
+{
+ if (_pEntry)
+ {
+ OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
+ if (pTextItem)
+ return pTextItem->isEmphasized();
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::checkWildcard(SvLBoxEntry* _pEntry)
+{
+ SetCheckButtonState(_pEntry, SV_BUTTON_CHECKED);
+ checkedButton_noBroadcast(_pEntry);
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::getAllObjectsEntry() const
+{
+ return haveVirtualRoot() ? First() : NULL;
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::checkedButton_noBroadcast(SvLBoxEntry* _pEntry)
+{
+ OMarkableTreeListBox::checkedButton_noBroadcast(_pEntry);
+
+ // if an entry has children, it makes a difference if the entry is checked
+ // because all children are checked or if the user checked it explicitly.
+ // So we track explicit (un)checking
+
+ SvButtonState eState = GetCheckButtonState(_pEntry);
+ OSL_ENSURE(SV_BUTTON_TRISTATE != eState, "OTableTreeListBox::CheckButtonHdl: user action which lead to TRISTATE?");
+ implEmphasize(_pEntry, SV_BUTTON_CHECKED == eState);
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants, sal_Bool _bUpdateAncestors)
+{
+ OSL_ENSURE(_pEntry, "OTableTreeListBox::implEmphasize: invalid entry (NULL)!");
+
+ // special emphasizing handling for the "all objects" entry
+ sal_Bool bAllObjectsEntryAffected = haveVirtualRoot() && (getAllObjectsEntry() == _pEntry);
+ if ( GetModel()->HasChilds(_pEntry) // the entry has children
+ || bAllObjectsEntryAffected // or it is the "all objects" entry
+ )
+ {
+ OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
+ if (pTextItem)
+ pTextItem->emphasize(_bChecked);
+
+ if (bAllObjectsEntryAffected)
+ InvalidateEntry(_pEntry);
+ }
+
+ if (_bUpdateDescendants)
+ {
+ // remove the mark for all children of the checked entry
+ SvLBoxEntry* pChildLoop = FirstChild(_pEntry);
+ while (pChildLoop)
+ {
+ if (GetModel()->HasChilds(pChildLoop))
+ implEmphasize(pChildLoop, sal_False, sal_True, sal_False);
+ pChildLoop = NextSibling(pChildLoop);
+ }
+ }
+
+ if (_bUpdateAncestors)
+ {
+ // remove the mark for all ancestors of the entry
+ if (GetModel()->HasParent(_pEntry))
+ implEmphasize(GetParent(_pEntry), sal_False, sal_False, sal_True);
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind)
+{
+ OMarkableTreeListBox::InitEntry(_pEntry, _rString, _rCollapsedBitmap, _rExpandedBitmap, _eButtonKind);
+
+ // replace the text item with our own one
+ SvLBoxItem* pTextItem = _pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING);
+ OSL_ENSURE(pTextItem, "OTableTreeListBox::InitEntry: no text item!?");
+ sal_uInt16 nTextPos = _pEntry->GetPos(pTextItem);
+ OSL_ENSURE(((sal_uInt16)-1) != nTextPos, "OTableTreeListBox::InitEntry: no text item pos!");
+
+ _pEntry->ReplaceItem(new OBoldListboxString(_pEntry, 0, _rString), nTextPos);
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::implAddEntry(
+ const Reference< XDatabaseMetaData >& _rxMeta,
+ const ::rtl::OUString& _rTableName,
+ sal_Bool _bCheckName
+ )
+{
+ OSL_PRECOND( _rxMeta.is(), "OTableTreeListBox::implAddEntry: invalid meta data!" );
+ if ( !_rxMeta.is() )
+ return NULL;
+
+ // split the complete name into it's components
+ ::rtl::OUString sCatalog, sSchema, sName;
+ qualifiedNameComponents( _rxMeta, _rTableName, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+
+ SvLBoxEntry* pParentEntry = getAllObjectsEntry();
+
+ // if the DB uses catalog at the start of identifiers, then our hierarchy is
+ // catalog
+ // +- schema
+ // +- table
+ // else it is
+ // schema
+ // +- catalog
+ // +- table
+ sal_Bool bCatalogAtStart = _rxMeta->isCatalogAtStart();
+ const ::rtl::OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema;
+ const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+ const ::rtl::OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog;
+ const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
+
+ if ( rFirstName.getLength() )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( rFirstName, pParentEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( rFirstName, pParentEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ if ( rSecondName.getLength() )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( rSecondName, pParentEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ SvLBoxEntry* pRet = NULL;
+ if ( !_bCheckName || !GetEntryPosByName( sName, pParentEntry ) )
+ {
+ pRet = InsertEntry( sName, pParentEntry, sal_False, LIST_APPEND );
+
+ Image aImage;
+ m_pImageProvider->getImages( _rTableName, DatabaseObject::TABLE, aImage );
+
+ SetExpandedEntryBmp( pRet, aImage );
+ SetCollapsedEntryBmp( pRet, aImage );
+ }
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+NamedDatabaseObject OTableTreeListBox::describeObject( SvLBoxEntry* _pEntry )
+{
+ NamedDatabaseObject aObject;
+
+ sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
+
+ if ( nEntryType == DatabaseObjectContainer::TABLES )
+ {
+ aObject.Type = DatabaseObjectContainer::TABLES;
+ }
+ else if ( ( nEntryType == DatabaseObjectContainer::CATALOG )
+ || ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ )
+ {
+ SvLBoxEntry* pParent = GetParent( _pEntry );
+ sal_Int32 nParentEntryType = pParent ? reinterpret_cast< sal_IntPtr >( pParent->GetUserData() ) : -1;
+
+ ::rtl::OUStringBuffer buffer;
+ if ( nEntryType == DatabaseObjectContainer::CATALOG )
+ {
+ if ( nParentEntryType == DatabaseObjectContainer::SCHEMA )
+ {
+ buffer.append( GetEntryText( pParent ) );
+ buffer.append( sal_Unicode( '.' ) );
+ }
+ buffer.append( GetEntryText( _pEntry ) );
+ }
+ else if ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ {
+ if ( nParentEntryType == DatabaseObjectContainer::CATALOG )
+ {
+ buffer.append( GetEntryText( pParent ) );
+ buffer.append( sal_Unicode( '.' ) );
+ }
+ buffer.append( GetEntryText( _pEntry ) );
+ }
+ }
+ else
+ {
+ aObject.Type = DatabaseObject::TABLE;
+ aObject.Name = getQualifiedTableName( _pEntry );
+ }
+
+ return aObject;
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::addedTable( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( impl_getAndAssertMetaData( xMeta ) )
+ return implAddEntry( xMeta, _rName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+bool OTableTreeListBox::impl_getAndAssertMetaData( Reference< XDatabaseMetaData >& _out_rMetaData ) const
+{
+ if ( m_xConnection.is() )
+ _out_rMetaData = m_xConnection->getMetaData();
+ OSL_PRECOND( _out_rMetaData.is(), "OTableTreeListBox::impl_getAndAssertMetaData: invalid current connection!" );
+ return _out_rMetaData.is();
+}
+
+//------------------------------------------------------------------------
+String OTableTreeListBox::getQualifiedTableName( SvLBoxEntry* _pEntry ) const
+{
+ OSL_PRECOND( !isFolderEntry( _pEntry ), "OTableTreeListBox::getQualifiedTableName: folder entries not allowed here!" );
+
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( !impl_getAndAssertMetaData( xMeta ) )
+ return String();
+
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+
+ SvLBoxEntry* pSchema = GetParent( _pEntry );
+ if ( pSchema )
+ {
+ SvLBoxEntry* pCatalog = GetParent( pSchema );
+ if ( pCatalog
+ || ( xMeta->supportsCatalogsInDataManipulation()
+ && !xMeta->supportsSchemasInDataManipulation()
+ ) // here we support catalog but no schema
+ )
+ {
+ if ( pCatalog == NULL )
+ {
+ pCatalog = pSchema;
+ pSchema = NULL;
+ }
+ sCatalog = GetEntryText( pCatalog );
+ }
+ if ( pSchema )
+ sSchema = GetEntryText(pSchema);
+ }
+ sTable = GetEntryText( _pEntry );
+
+ return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return String();
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::getEntryByQualifiedName( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( !impl_getAndAssertMetaData( xMeta ) )
+ return NULL;
+
+ // split the complete name into it's components
+ ::rtl::OUString sCatalog, sSchema, sName;
+ qualifiedNameComponents(xMeta, _rName, sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
+
+ SvLBoxEntry* pParent = getAllObjectsEntry();
+ SvLBoxEntry* pCat = NULL;
+ SvLBoxEntry* pSchema = NULL;
+ if ( sCatalog.getLength() )
+ {
+ pCat = GetEntryPosByName(sCatalog, pParent);
+ if ( pCat )
+ pParent = pCat;
+ }
+
+ if ( sSchema.getLength() )
+ {
+ pSchema = GetEntryPosByName(sSchema, pParent);
+ if ( pSchema )
+ pParent = pSchema;
+ }
+
+ return GetEntryPosByName(sName, pParent);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+//------------------------------------------------------------------------
+void OTableTreeListBox::removedTable( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ SvLBoxEntry* pEntry = getEntryByQualifiedName( _rName );
+ if ( pEntry )
+ GetModel()->Remove( pEntry );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/tabletree.hrc b/dbaccess/source/ui/control/tabletree.hrc
new file mode 100644
index 000000000000..1566e1ec10ce
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLETREE_HRC_
+#define _DBAUI_TABLETREE_HRC_
+
+//------------------------------------------------------------------------
+//- menu ids
+
+#define MID_SORT_ASCENDING 1
+#define MID_SORT_DECENDING 2
+
+#endif // _DBAUI_TABLETREE_HRC_
diff --git a/dbaccess/source/ui/control/tabletree.src b/dbaccess/source/ui/control/tabletree.src
new file mode 100644
index 000000000000..71f3945e245e
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.src
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#include "browserids.hxx"
+
+Menu MENU_TABLETREE_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MID_SORT_ASCENDING;
+ Text [ en-US ] = "Sort Ascending";
+ };
+ MenuItem
+ {
+ Identifier = MID_SORT_DECENDING;
+ Text [ en-US ] = "Sort Descending";
+ };
+ };
+};
+
+String STR_COULDNOTCREATE_DRIVERMANAGER
+{
+ Text [ en-US ] = "Cannot connect to the SDBC driver manager (#servicename#).";
+};
+
+String STR_NOREGISTEREDDRIVER
+{
+ Text [ en-US ] = "A driver is not registered for the URL #connurl#.";
+};
+
+String STR_COULDNOTCONNECT
+{
+ Text [ en-US ] = "No connection could be established for the URL #connurl#.";
+};
+
+String STR_COULDNOTCONNECT_PLEASECHECK
+{
+ Text [ en-US ] = "Please check the current settings, for example user name and password.";
+};
+
+String STR_NOTABLEINFO
+{
+ Text [ en-US ] = "Successfully connected, but information about database tables is not available.";
+};
+
+String STR_ALL_TABLES
+{
+ Text [ en-US ] = "All tables";
+};
+
+String STR_ALL_VIEWS
+{
+ Text [ en-US ] = "All views";
+};
+
+String STR_ALL_TABLES_AND_VIEWS
+{
+ Text [ en-US ] = "All tables and views";
+};
diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx
new file mode 100644
index 000000000000..5f36c9678b99
--- /dev/null
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "toolboxcontroller.hxx"
+#include <com/sun/star/ui/ImageType.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/menu.hxx>
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XImageManager.hpp>
+#include <com/sun/star/ui/ImageType.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+#include "dbu_resource.hrc"
+#include <svtools/miscopt.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <tools/diagnose_ex.h>
+#include <svtools/menuoptions.hxx>
+#include <osl/mutex.hxx>
+#include "dbu_reghelper.hxx"
+#include "UITools.hxx"
+
+
+extern "C" void SAL_CALL createRegistryInfo_OToolboxController()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OToolboxController> aAutoRegistration;
+}
+namespace dbaui
+{
+ using namespace svt;
+ using namespace ::com::sun::star::graphic;
+ using namespace com::sun::star::uno;
+ using namespace com::sun::star::beans;
+ using namespace com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::ui;
+
+ namespace
+ {
+ void lcl_copy(Menu* _pMenu,sal_uInt16 _nMenuId,sal_uInt16 _nMenuPos,ToolBox* _pToolBox,sal_uInt16 _nToolId,const ::rtl::OUString& _sCommand)
+ {
+ if ( _pMenu->GetItemType(_nMenuPos) != MENUITEM_STRING )
+ _pToolBox->SetItemImage(_nToolId, _pMenu->GetItemImage(_nMenuId));
+ _pToolBox->SetItemCommand( _nToolId, _sCommand);
+ _pToolBox->SetHelpId(_nToolId, _pMenu->GetHelpId(_nMenuId));
+ _pToolBox->SetHelpText(_nToolId, _pMenu->GetHelpText(_nMenuId));
+ _pToolBox->SetQuickHelpText(_nToolId, _pMenu->GetTipHelpText(_nMenuId));
+ _pToolBox->SetItemText(_nToolId, _pMenu->GetItemText(_nMenuId));
+ }
+ }
+
+ OToolboxController::OToolboxController(const Reference< XMultiServiceFactory >& _rxORB)
+ : m_nToolBoxId(1)
+ {
+ osl_incrementInterlockedCount(&m_refCount);
+ m_xServiceManager = _rxORB;
+ osl_decrementInterlockedCount(&m_refCount);
+
+ }
+ // -----------------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC(OToolboxController,"com.sun.star.sdb.ApplicationToolboxController","com.sun.star.frame.ToolboxController")
+ // -----------------------------------------------------------------------------
+ // XInterface
+ Any SAL_CALL OToolboxController::queryInterface( const Type& _rType ) throw (RuntimeException)
+ {
+ Any aReturn = ToolboxController::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = TToolboxController_BASE::queryInterface(_rType);
+ return aReturn;
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::acquire() throw ()
+ {
+ ToolboxController::acquire();
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::release() throw ()
+ {
+ ToolboxController::release();
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ ToolboxController::initialize(_rArguments);
+ SolarMutexGuard aSolarMutexGuard;
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( m_aCommandURL.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(".uno:DBNewForm")) )
+ {
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewForm")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewView")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewViewSQL")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuery")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuerySql")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewReport")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewReportAutoPilot")),sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewTable")) ,sal_True));
+ }
+ else
+ {
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Refresh")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBRebuildData")) ,sal_True));
+ }
+
+ TCommandState::iterator aIter = m_aStates.begin();
+ TCommandState::iterator aEnd = m_aStates.end();
+ for (; aIter != aEnd; ++aIter)
+ addStatusListener(aIter->first);
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ if ( pToolBox )
+ {
+ sal_uInt16 nCount = pToolBox->GetItemCount();
+ for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
+ {
+ sal_uInt16 nItemId = pToolBox->GetItemId(nPos);
+ if ( pToolBox->GetItemCommand(nItemId) == String(m_aCommandURL) )
+ {
+ m_nToolBoxId = nItemId;
+ break;
+ }
+ }
+
+ // check if paste special is allowed, when not don't add DROPDOWN
+ pToolBox->SetItemBits(m_nToolBoxId,pToolBox->GetItemBits(m_nToolBoxId) | TIB_DROPDOWN);
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
+ {
+ SolarMutexGuard aSolarMutexGuard;
+ ::osl::MutexGuard aGuard(m_aMutex);
+ TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete );
+ if ( aFind != m_aStates.end() )
+ {
+ aFind->second = Event.IsEnabled;
+ if ( m_aCommandURL == aFind->first && !Event.IsEnabled )
+ {
+ ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+ sal_uInt16 nCount = pMenu->GetItemCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ sal_uInt16 nItemId = pMenu->GetItemId(i);
+ aFind = m_aStates.find(pMenu->GetItemCommand(nItemId));
+ if ( aFind != m_aStates.end() && aFind->second )
+ {
+ m_aCommandURL = aFind->first;
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ lcl_copy(pMenu.get(),nItemId,i,pToolBox,m_nToolBoxId, m_aCommandURL);
+ break;
+ }
+ }
+ }
+ }
+ }
+ // -----------------------------------------------------------------------------
+ ::std::auto_ptr<PopupMenu> OToolboxController::getMenu()
+ {
+ ::std::auto_ptr<PopupMenu> pMenu;
+ if ( m_aStates.size() > 2 )
+ {
+ pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_APP_NEW ) ) );
+
+ try
+ {
+ Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(getServiceManager()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),UNO_QUERY);
+ Reference<XUIConfigurationManager> xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument")));
+ Reference<XImageManager> xImageMgr(xUIConfigMgr->getImageManager(),UNO_QUERY);
+
+
+ short nImageType = hasBigImages() ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT;
+
+ Sequence< ::rtl::OUString> aSeq(1);
+ sal_uInt16 nCount = pMenu->GetItemCount();
+ for (sal_uInt16 nPos = 0; nPos < nCount; ++nPos)
+ {
+ if ( pMenu->GetItemType( nPos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ sal_uInt16 nItemId = pMenu->GetItemId(nPos);
+ aSeq[0] = pMenu->GetItemCommand(nItemId);
+ Sequence< Reference<XGraphic> > aImages = xImageMgr->getImages(nImageType,aSeq);
+
+ Image aImage(aImages[0]);
+ pMenu->SetItemImage(nItemId,aImage);
+ TCommandState::iterator aFind = m_aStates.find( aSeq[0] );
+ if ( aFind != m_aStates.end() )
+ {
+ pMenu->EnableItem(nItemId,aFind->second);
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ {
+ pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_REFRESH_DATA ) ) );
+ }
+ return pMenu;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< ::com::sun::star::awt::XWindow > SAL_CALL OToolboxController::createPopupWindow() throw (RuntimeException)
+ {
+ // execute the menu
+ SolarMutexGuard aSolarMutexGuard;
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+
+ sal_uInt16 nSelected = pMenu->Execute(pToolBox, pToolBox->GetItemRect( m_nToolBoxId ),POPUPMENU_EXECUTE_DOWN);
+ // "cleanup" the toolbox state
+ Point aPoint = pToolBox->GetItemRect( m_nToolBoxId ).TopLeft();
+ MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
+ pToolBox->MouseMove( aLeave );
+ pToolBox->SetItemDown( m_nToolBoxId, sal_False);
+
+ if ( nSelected )
+ {
+ m_aCommandURL = pMenu->GetItemCommand(nSelected);
+ lcl_copy(pMenu.get(),nSelected,pMenu->GetItemPos(nSelected),pToolBox,m_nToolBoxId, m_aCommandURL);
+
+ Reference<XDispatch> xDispatch = m_aListenerMap.find(m_aCommandURL)->second;
+ if ( xDispatch.is() )
+ {
+ URL aUrl;
+ Sequence < PropertyValue > aArgs;
+ aUrl.Complete = m_aCommandURL;
+ OSL_ENSURE(aUrl.Complete.getLength(),"Command is empty!");
+ if ( getURLTransformer().is() )
+ getURLTransformer()->parseStrict(aUrl);
+ xDispatch->dispatch(aUrl,aArgs);
+
+ }
+ }
+ return Reference< ::com::sun::star::awt::XWindow >();
+ }
+ // -----------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------
+//..........................................................................
+} // dbaui
+//..........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/undosqledit.cxx b/dbaccess/source/ui/control/undosqledit.cxx
new file mode 100644
index 000000000000..39e44be96f3f
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "undosqledit.hxx"
+#include "sqledit.hxx"
+
+namespace dbaui
+{
+//------------------------------------------------------------------------------
+void OSqlEditUndoAct::ToggleText()
+{
+ String strNext = m_pOwner->GetText();
+ m_pOwner->SetText(m_strNextText);
+ m_strNextText =strNext;
+}
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/undosqledit.src b/dbaccess/source/ui/control/undosqledit.src
new file mode 100644
index 000000000000..aab44ad5e7db
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.src
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+
+String STR_QUERY_UNDO_MODIFYSQLEDIT
+{
+ Text [ en-US ] = "Modify SQL statement(s)" ;
+};
diff --git a/dbaccess/source/ui/dlg/AdabasPage.hrc b/dbaccess/source/ui/dlg/AdabasPage.hrc
new file mode 100644
index 000000000000..a36dbb25da27
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasPage.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_ADABASPAGE_HRC
+#define DBAUI_ADABASPAGE_HRC
+
+#define FT_CACHE_SIZE 1
+#define FT_DATA_INCREMENT 2
+#define FT_CTRLPASSWORD 3
+#define FT_CTRLUSERNAME 4
+
+
+#define NF_DATA_INCREMENT 1
+#define NF_CACHE_SIZE 2
+
+#define CB_SHUTDB 1
+
+#define FL_1 1
+
+#define PB_STAT 1
+
+#define ET_CTRLPASSWORD 1
+#define ET_CTRLUSERNAME 2
+
+#endif // DBAUI_ADABASPAGE_HRC
+
+
diff --git a/dbaccess/source/ui/dlg/AdabasStat.cxx b/dbaccess/source/ui/dlg/AdabasStat.cxx
new file mode 100644
index 000000000000..25710d04abfc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.cxx
@@ -0,0 +1,305 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <cppuhelper/exc_hlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "AdabasStat.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "AdabasStat.hrc"
+#include "dbu_dlg.hrc"
+#include "dbustrings.hrc"
+#include "UITools.hxx"
+#include <connectivity/dbtools.hxx>
+#include "sqlmessage.hxx"
+
+using namespace dbaui;
+DBG_NAME(OAdabasStatistics)
+namespace dbaui
+{
+ using namespace dbtools;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+
+
+
+OAdabasStatistics::OAdabasStatistics( Window* pParent,
+ const ::rtl::OUString& _rUser,
+ const Reference< ::com::sun::star::sdbc::XConnection >& _xCurrentConnection,
+ const Reference< XMultiServiceFactory >& _xFactory)
+ : ModalDialog( pParent, ModuleRes(DLG_ADABASSTAT) )
+ ,m_FL_FILES( this , ModuleRes(FL_FILES))
+ ,m_FT_SYSDEVSPACE( this , ModuleRes(FT_SYSDEVSPACE))
+ ,m_ET_SYSDEVSPACE( this , STR_ADABAS_HELP_SYSDEVSPACE,ModuleRes(ET_SYSDEVSPACE))
+ ,m_FT_TRANSACTIONLOG( this , ModuleRes(FT_TRANSACTIONLOG))
+ ,m_ET_TRANSACTIONLOG( this , STR_ADABAS_HELP_TRANSACT,ModuleRes(ET_TRANSACTIONLOG))
+ ,m_FT_DATADEVSPACE( this , ModuleRes(FT_DATADEVSPACE))
+ ,m_LB_DATADEVS( this , STR_ADABAS_HELP_DATADEVSPACES,ModuleRes(LB_DATADEVS))
+ ,m_FL_SIZES( this , ModuleRes(FL_SIZES))
+ ,m_FT_SIZE( this , ModuleRes(FT_SIZE))
+ ,m_ET_SIZE( this , STR_ADABAS_HELP_SIZE,ModuleRes(ET_SIZE))
+ ,m_FT_FREESIZE( this , ModuleRes(FT_FREESIZE))
+ ,m_ET_FREESIZE( this , STR_ADABAS_HELP_FREESIZE,ModuleRes(ET_FREESIZE))
+ ,m_FT_MEMORYUSING( this , ModuleRes(FT_MEMORYUSING))
+ ,m_ET_MEMORYUSING( this , STR_ADABAS_HELP_MEMORYUSING,ModuleRes(ET_MEMORYUSING))
+ ,m_PB_OK( this , ModuleRes(PB_OK))
+ ,m_xConnection(_xCurrentConnection)
+ ,m_bErrorShown(sal_False)
+{
+ DBG_CTOR(OAdabasStatistics,NULL);
+
+ FreeResource();
+
+ OSL_ENSURE(m_xConnection.is(),"No connection");
+ if(m_xConnection.is())
+ {
+ Reference<XStatement> xStmt;
+ Reference<XResultSet> xRes;
+
+ sal_Bool bCanSelect = sal_False;
+ ::rtl::OUString aStmt;
+ ::rtl::OUString sSchema = _rUser.toAsciiUpperCase();
+
+ Reference<XDatabaseMetaData> xMetaData;
+ // first read the sizes
+ try
+ {
+ xMetaData = m_xConnection->getMetaData();
+ bCanSelect = checkSystemTable(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SERVERDBSTATISTICS")), sSchema);
+
+ if(bCanSelect)
+ {
+ aStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT SERVERDBSIZE, UNUSEDPAGES FROM "));
+
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".\"SERVERDBSTATISTICS\""));
+
+ xStmt = m_xConnection->createStatement();
+ xRes = xStmt->executeQuery(aStmt);
+
+
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ // first the db sizes
+ if(xRes.is() && xRes->next())
+ {
+ double nUsedPages = xRow->getInt(1) / 256;
+ double nFreePages = xRow->getInt(2) / 256;
+
+ m_ET_SIZE.SetText(::rtl::OUString::valueOf((sal_Int32)nUsedPages));
+ m_ET_FREESIZE.SetText(::rtl::OUString::valueOf((sal_Int32)nFreePages));
+ m_ET_MEMORYUSING.SetValue(static_cast<sal_Int32>(((nUsedPages-nFreePages)/nUsedPages)*100));
+ }
+ else
+ showError();
+
+ xRow = NULL;
+ }
+ else
+ showError();
+ }
+ catch(const SQLException& )
+ {
+ ::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ), pParent, _xFactory );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ try
+ {
+ ::comphelper::disposeComponent(xStmt);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // now fill the datadev spaces
+ if(bCanSelect)
+ {
+ try
+ {
+ bCanSelect = checkSystemTable(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATADEVSPACES")), sSchema);
+
+ if(bCanSelect)
+ {
+ // then the db files
+ aStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT DEVSPACENAME FROM "));
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".\"DATADEVSPACES\""));
+ xStmt = m_xConnection->createStatement();
+ xRes = xStmt->executeQuery(aStmt);
+
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while(xRes.is() && xRes->next())
+ {
+ m_LB_DATADEVS.InsertEntry(xRow->getString(1));
+ }
+ if(!m_LB_DATADEVS.GetEntryCount())
+ showError();
+ }
+ else
+ showError();
+ }
+ catch(const SQLException& e)
+ {
+ ::dbaui::showError(SQLExceptionInfo(e),pParent,_xFactory);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ try
+ {
+ ::comphelper::disposeComponent(xStmt);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // now fill the sysdatadev spaces
+ if(bCanSelect)
+ {
+ try
+ {
+ bCanSelect = checkSystemTable(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONFIGURATION")), sSchema);
+
+ if(bCanSelect)
+ {
+ aStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".CONFIGURATION WHERE DESCRIPTION LIKE 'SYS%DEVSPACE%NAME'"));
+ xStmt = m_xConnection->createStatement();
+ xRes = xStmt->executeQuery(aStmt);
+ if(xRes.is() && xRes->next())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ m_ET_SYSDEVSPACE.SetText(xRow->getString(2));
+ }
+ else
+ showError();
+
+ aStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
+ aStmt += ::dbtools::quoteTableName(xMetaData,sSchema,::dbtools::eInDataManipulation);
+ aStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".CONFIGURATION WHERE DESCRIPTION = 'TRANSACTION LOG NAME'"));
+ xRes = xStmt->executeQuery(aStmt);
+ if(xRes.is() && xRes->next())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ m_ET_TRANSACTIONLOG.SetText(xRow->getString(2));
+ }
+ else
+ showError();
+ }
+ else
+ showError();
+ }
+ catch(const SQLException& e)
+ {
+ ::dbaui::showError(SQLExceptionInfo(e),pParent,_xFactory);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ try
+ {
+ ::comphelper::disposeComponent(xStmt);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+
+ m_ET_SYSDEVSPACE.SetSpecialReadOnly(sal_True);
+ m_ET_TRANSACTIONLOG.SetSpecialReadOnly(sal_True);
+ m_LB_DATADEVS.SetSpecialReadOnly(sal_True);
+ m_ET_SIZE.SetSpecialReadOnly(sal_True);
+ m_ET_FREESIZE.SetSpecialReadOnly(sal_True);
+ m_ET_MEMORYUSING.SetSpecialReadOnly(sal_True);
+}
+//------------------------------------------------------------------------
+OAdabasStatistics::~OAdabasStatistics()
+{
+ DBG_DTOR(OAdabasStatistics,NULL);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OAdabasStatistics::checkSystemTable(const ::rtl::OUString& _rsSystemTable, ::rtl::OUString& _rsSchemaName )
+{
+ sal_Bool bCanSelect = sal_False;
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ if ( xMeta.is() )
+ {
+ Reference<XResultSet> xRes = xMeta->getTablePrivileges(Any(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")), _rsSystemTable);
+ if(xRes.is())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ static const ::rtl::OUString sSelect(RTL_CONSTASCII_USTRINGPARAM("SELECT"));
+ // first the db sizes
+ while( xRow.is() && xRes->next() )
+ {
+ _rsSchemaName = xRow->getString(2);
+ if(sSelect == xRow->getString(6) && !xRow->wasNull())
+ {
+ bCanSelect = sal_True;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+ }
+
+ return bCanSelect;
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatistics::showError()
+{
+ if(!m_bErrorShown)
+ {
+ OSQLMessageBox aMsg(GetParent(),GetText(),String(ModuleRes(STR_ADABAS_ERROR_SYSTEMTABLES)));
+ aMsg.Execute();
+ m_bErrorShown = sal_True;
+ }
+}
+// -----------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/AdabasStat.hrc b/dbaccess/source/ui/dlg/AdabasStat.hrc
new file mode 100644
index 000000000000..32734ea9075a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.hrc
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_ADABASSTAT_HRC
+#define DBAUI_ADABASSTAT_HRC
+
+
+#define FT_SYSDEVSPACE 1
+#define FT_TRANSACTIONLOG 2
+#define FT_DATADEVSPACE 3
+#define FT_SIZE 4
+#define FT_FREESIZE 5
+#define FT_MEMORYUSING 6
+
+#define ET_SYSDEVSPACE 1
+#define ET_TRANSACTIONLOG 2
+#define ET_MEMORYUSING 3
+#define ET_SIZE 4
+#define ET_FREESIZE 5
+
+#define LB_DATADEVS 1
+
+#define PB_OK 1
+
+#define FL_FILES 1
+#define FL_SIZES 2
+
+
+#endif // DBAUI_ADABASSTAT_HRC
diff --git a/dbaccess/source/ui/dlg/AdabasStat.hxx b/dbaccess/source/ui/dlg/AdabasStat.hxx
new file mode 100644
index 000000000000..7bba19f59724
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBAUI_ADASTAT_HXX_
+#define _DBAUI_ADASTAT_HXX_
+
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include "FieldControls.hxx"
+#include <svtools/prgsbar.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace dbaui
+{
+ //========================================================================
+ // shows some statistics
+ //========================================================================
+ class OAdabasStatistics : public ModalDialog
+ {
+ protected:
+
+ FixedLine m_FL_FILES;
+ FixedText m_FT_SYSDEVSPACE;
+ OPropEditCtrl m_ET_SYSDEVSPACE;
+ FixedText m_FT_TRANSACTIONLOG;
+ OPropEditCtrl m_ET_TRANSACTIONLOG;
+ FixedText m_FT_DATADEVSPACE;
+ OPropListBoxCtrl m_LB_DATADEVS;
+ FixedLine m_FL_SIZES;
+ FixedText m_FT_SIZE;
+ OPropEditCtrl m_ET_SIZE;
+ FixedText m_FT_FREESIZE;
+ OPropEditCtrl m_ET_FREESIZE;
+ FixedText m_FT_MEMORYUSING;
+ OPropNumericEditCtrl m_ET_MEMORYUSING;
+
+ OKButton m_PB_OK;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection; /// valid as long as the page is active
+ sal_Bool m_bErrorShown; // true when we shown already the error
+
+ // check if the given table is accessable by the connected user
+ sal_Bool checkSystemTable(const ::rtl::OUString& _rsSystemTable, ::rtl::OUString& _rsSchemaName );
+ void showError();
+
+ public:
+ OAdabasStatistics( Window* pParent,
+ const ::rtl::OUString& _rUser,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xCurrentConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory);
+ ~OAdabasStatistics();
+
+ };
+}
+#endif //_DBAUI_ADASTAT_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/AdabasStat.src b/dbaccess/source/ui/dlg/AdabasStat.src
new file mode 100644
index 000000000000..476750f7b531
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AdabasStat.src
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_ADABASSTAT_HRC
+#include "AdabasStat.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#define WINDOW_SIZE_X 260
+#define WINDOW_SIZE_Y 190
+
+ModalDialog DLG_ADABASSTAT
+{
+ HelpID = "dbaccess:ModalDialog:DLG_ADABASSTAT";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedLine FL_FILES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12, 8 ) ;
+ Text [ en-US ] = "Database files";
+ };
+
+ FixedText FT_SYSDEVSPACE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "S~YSDEVSPACE:";
+ };
+
+ Edit ET_SYSDEVSPACE
+ {
+ HelpID = "dbaccess:Edit:DLG_ADABASSTAT:ET_SYSDEVSPACE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 14 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ ReadOnly = TRUE;
+ };
+
+ FixedText FT_TRANSACTIONLOG
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "~TRANSACTIONLOG:";
+ };
+
+ Edit ET_TRANSACTIONLOG
+ {
+ HelpID = "dbaccess:Edit:DLG_ADABASSTAT:ET_TRANSACTIONLOG";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 31 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ ReadOnly = TRUE;
+ };
+
+ FixedText FT_DATADEVSPACE
+ {
+ Pos = MAP_APPFONT ( 12 , 49 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "DATAD~EVSPACE:";
+ };
+
+ ListBox LB_DATADEVS
+ {
+ HelpID = "dbaccess:ListBox:DLG_ADABASSTAT:LB_DATADEVS";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 48 ) ;
+ Size = MAP_APPFONT ( 128 , 42 ) ;
+ TabStop = TRUE;
+ AutoHScroll = TRUE;
+ VScroll = TRUE;
+ HScroll = TRUE;
+ };
+ FixedLine FL_SIZES
+ {
+ Pos = MAP_APPFONT ( 6 , 99 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ;
+ Text [ en-US ] = "Database sizes";
+ };
+
+ FixedText FT_SIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "S~ize (MB):";
+ };
+
+ Edit ET_SIZE
+ {
+ HelpID = "dbaccess:Edit:DLG_ADABASSTAT:ET_SIZE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 109 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ ReadOnly = TRUE;
+ };
+
+ FixedText FT_FREESIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 127 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "~Free memory space (MB):";
+ };
+
+ Edit ET_FREESIZE
+ {
+ HelpID = "dbaccess:Edit:DLG_ADABASSTAT:ET_FREESIZE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 126 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ ReadOnly = TRUE;
+ };
+
+ FixedText FT_MEMORYUSING
+ {
+ Pos = MAP_APPFONT ( 12 , 144 ) ;
+ Size = MAP_APPFONT ( 102 , 10 ) ;
+ Text [ en-US ] = "~Memory utilization (in %):";
+ };
+
+ NumericField ET_MEMORYUSING
+ {
+ HelpID = "dbaccess:NumericField:DLG_ADABASSTAT:ET_MEMORYUSING";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 144 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ ReadOnly = TRUE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 56,WINDOW_SIZE_Y - 20 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+
+ Text [ en-US ] = "Database Statistics";
+};
+
+String STR_ADABAS_HELP_SYSDEVSPACE
+{
+ Text [ en-US ] = "Contains the system tables";
+};
+
+String STR_ADABAS_HELP_TRANSACT
+{
+ Text [ en-US ] = "Contains information about transaction";
+};
+
+String STR_ADABAS_HELP_DATADEVSPACES
+{
+ Text [ en-US ] = "Contains all data files";
+};
+
+String STR_ADABAS_HELP_SIZE
+{
+ Text [ en-US ] = "Total size of the database files";
+};
+
+String STR_ADABAS_HELP_FREESIZE
+{
+ Text [ en-US ] = "Currently available space before a new datadev file is created.";
+};
+
+String STR_ADABAS_HELP_MEMORYUSING
+{
+ Text [ en-US ] = "Currently used memory";
+};
+
+String STR_ADABAS_ERROR_SYSTEMTABLES
+{
+ Text [ en-US ] = "No information could be displayed because no access rights exist for the required system tables.";
+};
diff --git a/dbaccess/source/ui/dlg/AutoControls.src b/dbaccess/source/ui/dlg/AutoControls.src
new file mode 100644
index 000000000000..e43e2a13a7fb
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AutoControls.src
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+String STR_DBASE_PATH_OR_FILE
+{
+ Text[ en-US ] = "Path to the dBASE files";
+};
+
+String STR_FLAT_PATH_OR_FILE
+{
+ Text[ en-US ] = "Path to the text files";
+};
+
+String STR_CALC_PATH_OR_FILE
+{
+ Text[ en-US ] = "Path to the spreadsheet document";
+};
+
+String STR_NAME_OF_ODBC_DATASOURCE
+{
+ Text[ en-US ] = "Name of the ODBC data source on your system";
+};
+
+String STR_MYSQL_DATABASE_NAME
+{
+ Text[ en-US ] = "Name of the MySQL database";
+};
+
+String STR_ORACLE_DATABASE_NAME
+{
+ Text[ en-US ] = "Name of the Oracle database";
+};
+
+String STR_ADABAS_DATABASE_NAME
+{
+ Text[ en-US ] = "Name of the Adabas D database";
+};
+
+String STR_MSACCESS_MDB_FILE
+{
+ Text[ en-US ] = "Microsoft Access database file";
+};
+
+String STR_NO_ADDITIONAL_SETTINGS
+{
+ Text[ en-US ] = "No more settings are necessary. To verify that the connection is working, click the '%test' button.";
+};
+
+String STR_COMMONURL
+{
+ Text [ en-US ] = "Datasource URL" ;
+};
+
+String STR_HOSTNAME
+{
+ Text[ en-US ] = "~Host name";
+};
+
+String STR_MOZILLA_PROFILE_NAME
+{
+ Text[ en-US ] = "~Mozilla profile name";
+};
+
+String STR_THUNDERBIRD_PROFILE_NAME
+{
+ Text[ en-US ] = "~Thunderbird profile name";
+};
+
+// -------------------------------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc b/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc
new file mode 100644
index 000000000000..258eec3a2acf
--- /dev/null
+++ b/dbaccess/source/ui/dlg/AutoControls_tmpl.hrc
@@ -0,0 +1,517 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#define _DBAUI_AUTOCONTROLS_HRC_
+
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+
+#define CHECKBOX_HEIGHT 8
+#define FIXEDTEXT_HEIGHT 8
+#define RELATED_CONTROLS 4
+#define UNRELATED_CONTROLS 7
+#define EDIT_HEIGHT 12
+#define EDIT_X 101
+
+#define FT_AUTOJDBCDRIVERCLASS 80
+#define FT_AUTOFIELDSEPARATOR 81
+#define FT_AUTOTEXTSEPARATOR 82
+#define FT_AUTODECIMALSEPARATOR 83
+#define FT_AUTOTHOUSANDSSEPARATOR 84
+#define FT_AUTOPORTNUMBER 85
+#define FT_AUTOPORTNUMBERDEFAULT 86
+#define FT_AUTOBASEDN 87
+#define FT_AUTOHOSTNAME 88
+#define FT_AUTOBROWSEURL 89
+#define FT_AUTODATABASENAME 90
+#define FT_AUTOWIZARDHELPTEXT 91
+#define FT_AUTOWIZARDHEADER 92
+#define FT_AUTOEXTENSIONHEADER 93
+#define FT_AUTOOWNEXTENSIONAPPENDIX 94
+#define FT_CHARSET 95
+#define FT_SOCKET 96
+
+#define FL_AUTOSEPARATOR2 80
+#define FL_DATACONVERT 81
+#define FL_SEPARATOR1 82
+
+#define CB_AUTOHEADER 80
+
+#define PB_AUTOTESTDRIVERCLASS 80
+#define PB_AUTOBROWSEURL 81
+
+#define CM_AUTOFIELDSEPARATOR 80
+#define CM_AUTOTEXTSEPARATOR 81
+#define CM_AUTODECIMALSEPARATOR 82
+#define CM_AUTOTHOUSANDSSEPARATOR 83
+
+#define NF_AUTOPORTNUMBER 80
+
+#define ET_AUTOBASEDN 80
+#define ET_AUTOHOSTNAME 81
+#define ET_AUTODATABASENAME 82
+#define ET_AUTOBROWSEURL 83
+#define ET_AUTOJDBCDRIVERCLASS 84
+#define ET_AUTOOWNEXTENSION 85
+#define ET_SOCKET 86
+
+#define RB_AUTOACCESSCTEXTFILES 80
+#define RB_AUTOACCESSCCSVFILES 81
+#define RB_AUTOACCESSOTHERS 82
+
+#define LB_CHARSET 80
+
+#define STR_AUTOFIELDSEPARATORLIST 100
+#define STR_AUTOTEXTSEPARATORLIST 101
+#define STR_AUTOTEXT_FIELD_SEP_NONE 102
+#define STR_AUTODELIMITER_MISSING 103
+#define STR_AUTODELIMITER_MUST_DIFFER 104
+#define STR_AUTONO_WILDCARDS 105
+
+
+#define AUTO_WIZARDHELPTEXT( AUTO_LINECOUNT ) \
+ FixedText FT_AUTOWIZARDHEADER \
+ { \
+ Pos = MAP_APPFONT ( START_X , 8 ) ; \
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = ""; \
+ WordBreak = TRUE; \
+ }; \
+ \
+ FixedText FT_AUTOWIZARDHELPTEXT \
+ { \
+ Pos = MAP_APPFONT ( START_X , INIT_Y ) ; \
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , AUTO_LINECOUNT * FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = ""; \
+ WordBreak = TRUE; \
+ };
+
+// -------------------------------------------------------------------------------------------------
+
+
+#define AUTO_BROWSECONTROLGROUP( AUTO_X, AUTO_Y, AUTOPAGE_X, AUTO_HID, AUTO_HID2) \
+ FixedText FT_AUTOBROWSEURL { \
+ Pos = MAP_APPFONT ( AUTO_X , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - AUTO_X - 6 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = ""; \
+ }; \
+ \
+ \
+ Edit ET_AUTOBROWSEURL \
+ { \
+ Pos = MAP_APPFONT ( AUTO_X , AUTO_Y + FIXEDTEXT_HEIGHT + 3) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - AUTO_X - 6 - 3 - BUTTON_WIDTH , EDIT_HEIGHT ) ; \
+ HelpId = AUTO_HID; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ }; \
+ \
+ PushButton PB_AUTOBROWSEURL \
+ { \
+ Pos = MAP_APPFONT ( AUTOPAGE_X - BUTTON_WIDTH - 6 , AUTO_Y + FIXEDTEXT_HEIGHT + 2 ) ; \
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; \
+ HelpId = AUTO_HID2; \
+ TabStop = TRUE ; \
+ Text[ en-US ] = "Browse"; \
+ };
+
+// --------------------------------------------------------------------------------------------------
+
+
+#define AUTO_NAMECONTROLGROUP(AUTO_Y, AUTO_HID) \
+ FixedText FT_AUTODATABASENAME \
+ { \
+ Pos = MAP_APPFONT ( START_X , AUTO_Y + 2) ; \
+ Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Database name"; \
+ }; \
+ \
+ Edit ET_AUTODATABASENAME \
+ { \
+ Pos = MAP_APPFONT ( EDIT_X, AUTO_Y) ; \
+ Size = MAP_APPFONT ( 97, EDIT_HEIGHT ) ; \
+ HelpId = AUTO_HID; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ };
+
+// --------------------------------------------------------------------------------------------------
+
+
+#define AUTO_HOSTCONTROLGROUP(AUTO_Y, AUTO_HID) \
+ FixedText FT_AUTOHOSTNAME \
+ { \
+ Pos = MAP_APPFONT (START_X , AUTO_Y + 2 ) ; \
+ Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ); \
+ Text [ en-US ] = "Server" ; \
+ }; \
+ \
+ Edit ET_AUTOHOSTNAME \
+ { \
+ Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \
+ HelpId = AUTO_HID; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ };
+
+// --------------------------------------------------------------------------------------------------
+
+
+#define AUTO_BASEDNCONTROLGROUP(AUTO_Y, AUTO_HID) \
+ FixedText FT_AUTOBASEDN \
+ { \
+ Pos = MAP_APPFONT (START_X , AUTO_Y + 2 ) ; \
+ Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "Base ~DN" ; \
+ }; \
+ \
+ Edit ET_AUTOBASEDN \
+ { \
+ HelpId = AUTO_HID ; \
+ Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ }; \
+
+// --------------------------------------------------------------------------------------------------
+
+// MBA: the HID set in the FixText can't make any sense; in case this macro was called from within the
+// AUTOHELP_JDBCCONTROLGROUP, the FixText would have got the same HID as an EditField from the
+// also called AUTO_JDBCDRIVERCLASSGROUP macro; thus I conclude that we can remove the HID from the FixedText
+#define AUTO_PORTCONTROLGROUP(AUTO_Y, AUTO_HID) \
+ FixedText FT_AUTOPORTNUMBER \
+ { \
+ Pos = MAP_APPFONT (START_X , AUTO_Y +2) ; \
+ Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "~Port number" ; \
+ }; \
+ \
+ NumericField NF_AUTOPORTNUMBER \
+ { \
+ HelpId = AUTO_HID ; \
+ Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 22 , EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ NoThousandSep = TRUE; \
+ }; \
+ \
+ FixedText FT_AUTOPORTNUMBERDEFAULT \
+ { \
+ Pos = MAP_APPFONT (EDIT_X + 22 + UNRELATED_CONTROLS, AUTO_Y +2) ; \
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - EDIT_X - 22 - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "" ; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_CHARSET( AUTO_Y, AUTOPAGE_X ) \
+ FixedLine FL_DATACONVERT \
+ { \
+ Pos = MAP_APPFONT ( 4 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "Data conversion"; \
+ }; \
+ FixedText FT_CHARSET \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y + RELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "~Character set" ; \
+ }; \
+ ListBox LB_CHARSET \
+ { \
+ Border = TRUE ; \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + RELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - EDIT_X - 6 , 60 ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_CHARSET; \
+ DropDown = TRUE ; \
+ CurPos = 0 ; \
+ }; \
+
+// --------------------------------------------------------------------------------------------------
+#define AUTO_SEPARATORCONTROLGROUP(AUTO_Y,AUTOPAGE_X) \
+ \
+ FixedText FT_AUTOEXTENSIONHEADER \
+ { \
+ Pos = MAP_APPFONT ( START_X , AUTO_Y) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 2*START_X , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Specify the type of files you want to access" ; \
+ }; \
+ \
+ RadioButton RB_AUTOACCESSCTEXTFILES \
+ { \
+ HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSTXTFILES; \
+ Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + FIXEDTEXT_HEIGHT + RELATED_CONTROLS); \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Plain text files (*.txt)" ; \
+ }; \
+ \
+ RadioButton RB_AUTOACCESSCCSVFILES \
+ { \
+ HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSCSVFILES; \
+ Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + 2*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS); \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "'Comma separated value' files (*.csv)" ; \
+ }; \
+ \
+ RadioButton RB_AUTOACCESSOTHERS \
+ { \
+ HelpId = HID_PAGE_DBWIZARD_TEXT_RB_ACCESSOTHERFILES; \
+ Pos = MAP_APPFONT (START_X + 6 , AUTO_Y + 3*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS); \
+ Size = MAP_APPFONT ( 50 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Custom:" ; \
+ }; \
+ \
+ Edit ET_AUTOOWNEXTENSION \
+ { \
+ HelpId = HID_PAGE_DBWIZARD_TEXT_ET_OWNEXTENSION; \
+ Pos = MAP_APPFONT (START_X + 66, AUTO_Y + 3*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS - 2 ) ; \
+ Size = MAP_APPFONT ( 60, EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ }; \
+ \
+ FIXEDTEXT FT_AUTOOWNEXTENSIONAPPENDIX \
+ { \
+ Pos = MAP_APPFONT (START_X + 130 , AUTO_Y + 3 * ( FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ); \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 6 -(START_X + 130), FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Custom: *.abc" ; \
+ }; \
+ \
+ FixedLine FL_AUTOSEPARATOR2 \
+ { \
+ Pos = MAP_APPFONT ( START_X , AUTO_Y + 50) ; \
+ Size = MAP_APPFONT ( AUTOPAGE_X - 2 * START_X , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Row Format"; \
+ }; \
+ \
+ FixedText FT_AUTOFIELDSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( START_X + INDENTED_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Field separator" ; \
+ }; \
+ ComboBox CM_AUTOFIELDSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT - 2 ) ; \
+ Size = MAP_APPFONT ( 32 , 60 ) ; \
+ Text = ";" ; \
+ TabStop = TRUE ; \
+ DropDown = TRUE ; \
+ HelpId = HID_DSADMIN_FIELD_SEPARATOR; \
+ }; \
+ \
+ FixedText FT_AUTOTEXTSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + EDIT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Text separator" ; \
+ }; \
+ ComboBox CM_AUTOTEXTSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + EDIT_HEIGHT - 2 ) ; \
+ Size = MAP_APPFONT ( 32 , 60 ) ; \
+ Text = "\"" ; \
+ TabStop = TRUE ; \
+ DropDown = TRUE ; \
+ HelpId = HID_DSADMIN_TEXT_SEPARATOR; \
+ }; \
+ FixedText FT_AUTODECIMALSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + 2*EDIT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Decimal separator" ; \
+ }; \
+ ComboBox CM_AUTODECIMALSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + 2*EDIT_HEIGHT - 2 ) ; \
+ Size = MAP_APPFONT ( 32 , 60 ) ; \
+ TabStop = TRUE ; \
+ MaxTextLength = 1 ; \
+ DropDown = TRUE ; \
+ StringList = \
+ { \
+ "." ; \
+ "," ; \
+ ";" ; \
+ ":" ; \
+ }; \
+ HelpId = HID_DSADMIN_DECIMAL_SEPARATOR; \
+ }; \
+ FixedText FT_AUTOTHOUSANDSSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + 3*EDIT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Thousands separator" ; \
+ }; \
+ ComboBox CM_AUTOTHOUSANDSSEPARATOR \
+ { \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + 3*EDIT_HEIGHT - 2 ) ; \
+ Size = MAP_APPFONT ( 32 , 44 ) ; \
+ Text = "." ; \
+ TabStop = TRUE ; \
+ MaxTextLength = 1 ; \
+ DropDown = TRUE ; \
+ StringList = \
+ { \
+ "," ; \
+ "." ; \
+ }; \
+ HelpId = HID_DSADMIN_THOUSANDS_SEPARATOR; \
+ }; \
+ \
+ CheckBox CB_AUTOHEADER \
+ { \
+ TabStop = TRUE ; \
+ Pos = MAP_APPFONT ( START_X + INDENTED_X, AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*RELATED_CONTROLS + 4*EDIT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( 150 , CHECKBOX_HEIGHT ) ; \
+ HelpId = HID_DSADMIN_TEXT_HEADER; \
+ Text [ en-US ] = "~Text contains headers" ; \
+ }; \
+ \
+ AUTO_CHARSET( AUTO_Y + 50 + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*RELATED_CONTROLS + 4*EDIT_HEIGHT + CHECKBOX_HEIGHT + UNRELATED_CONTROLS, AUTOPAGE_X ) \
+ \
+ String STR_AUTOTEXT_FIELD_SEP_NONE \
+ { \
+ Text[ en-US ] = "{None}"; \
+ }; \
+ \
+ String STR_AUTOTEXTSEPARATORLIST \
+ { \
+ Text = "\"\t34\t'\t39" ; \
+ }; \
+ \
+ String STR_AUTOFIELDSEPARATORLIST \
+ { \
+ Text [ x-comment ] = "EM Dec 2002: \'Space\' refers to what you get when you hit the space bar on your keyboard."; \
+ Text [ en-US ] = ";\t59\t,\t44\t:\t58\t{Tab}\t9\t{Space}\t32" ; \
+ }; \
+ \
+ String STR_AUTODELIMITER_MISSING \
+ { \
+ Text[ en-US ] = "#1 must be set." ; \
+ }; \
+ String STR_AUTODELIMITER_MUST_DIFFER \
+ { \
+ Text[ en-US ] = "#1 and #2 must be different." ; \
+ }; \
+ String STR_AUTONO_WILDCARDS \
+ { \
+ Text[ en-US ] = "Wildcards such as ?,* are not allowed in #1." ; \
+ };
+
+
+#define NAMECONTROLGROUP_HEIGHT (FIXEDTEXT_HEIGHT + 2 + EDIT_HEIGHT)
+#define BROWSECONTROLGROUP_HEIGHT ( FIXEDTEXT_HEIGHT + 2 + BUTTON_HEIGHT)
+
+// --------------------------------------------------------------------------------------------------
+
+#define AUTO_HELP_BROWSECONTROLGROUP(AUTO_LINECOUNT, AUTO_HID, AUTO_HID2) \
+ AUTO_WIZARDHELPTEXT(AUTO_LINECOUNT) \
+ AUTO_BROWSECONTROLGROUP(START_X, INIT_Y + AUTO_LINECOUNT * FIXEDTEXT_HEIGHT + 2, WIZARD_PAGE_X, AUTO_HID, AUTO_HID2)
+
+
+// --------------------------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------------------------
+
+#define AUTO_JDBCDRIVERCLASSGROUP(AUTO_Y, AUTO_HID, AUTO_HID2) \
+ \
+ FixedText FT_AUTOJDBCDRIVERCLASS \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \
+ Size = MAP_APPFONT ( PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "JDBC d~river class"; \
+ }; \
+ \
+ Edit ET_AUTOJDBCDRIVERCLASS \
+ { \
+ Pos = MAP_APPFONT ( START_X, AUTO_Y + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ; \
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - BUTTON_WIDTH - RELATED_CONTROLS - UNRELATED_CONTROLS , EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ HelpId = AUTO_HID; \
+ }; \
+ \
+ PushButton PB_AUTOTESTDRIVERCLASS \
+ { \
+ TabStop = TRUE ; \
+ Pos = MAP_APPFONT ( WIZARD_PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , AUTO_Y + FIXEDTEXT_HEIGHT + 2) ; \
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; \
+ Size = MAP_APPFONT (50, 14); \
+ HelpId = AUTO_HID2; \
+ Text[ en-US ] = "Test class" ; \
+ };
+
+// --------------------------------------------------------------------------------------------------
+
+#define AUTO_SOCKETCONTROLGROUP(AUTO_Y) \
+ FixedText FT_SOCKET \
+ { \
+ Pos = MAP_APPFONT (START_X , AUTO_Y +2) ; \
+ Size = MAP_APPFONT ( EDIT_X - START_X - UNRELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "Socket" ; \
+ }; \
+ \
+ Edit ET_SOCKET \
+ { \
+ Pos = MAP_APPFONT (EDIT_X, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 97, EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ };
+
+
+#define AUTOHELP_JDBCCONTROLGROUP( AUTO_HID, AUTO_HID2, AUTO_HID3, AUTO_HID4, AUTO_HID5 ) \
+ AUTO_WIZARDHELPTEXT( 6 ) \
+ AUTO_NAMECONTROLGROUP( INIT_Y + 6 * FIXEDTEXT_HEIGHT + 2, AUTO_HID ) \
+ AUTO_HOSTCONTROLGROUP(96, AUTO_HID2) \
+ AUTO_PORTCONTROLGROUP(113, AUTO_HID3 ) \
+ AUTO_SOCKETCONTROLGROUP(129) \
+ AUTO_JDBCDRIVERCLASSGROUP(146, AUTO_HID4, AUTO_HID5)
+
+
+// --------------------------------------------------------------------------------------------------
+
+#endif
diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx
new file mode 100644
index 000000000000..89e3a8d8439a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/CollectionView.cxx
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "CollectionView.hxx"
+#include "CollectionView.hrc"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "moduledbu.hxx"
+#include "dbu_dlg.hrc"
+#include <comphelper/interaction.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svtools/QueryFolderName.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <vcl/msgbox.hxx>
+#include "dbustrings.hrc"
+#include "UITools.hxx"
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/InteractionClassification.hpp>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <unotools/viewoptions.hxx>
+#include <osl/thread.h>
+#include <connectivity/dbexception.hxx>
+
+#define FILEDIALOG_DEF_IMAGEBORDER 10
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::sdbc;
+using namespace comphelper;
+// -----------------------------------------------------------------------------
+DBG_NAME(OCollectionView)
+OCollectionView::OCollectionView( Window * pParent
+ ,const Reference< XContent>& _xContent
+ ,const ::rtl::OUString& _sDefaultName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
+ : ModalDialog( pParent, ModuleRes(DLG_COLLECTION_VIEW))
+ , m_aFTCurrentPath( this, ModuleRes( FT_EXPLORERFILE_CURRENTPATH ) )
+ , m_aNewFolder( this, ModuleRes( BTN_EXPLORERFILE_NEWFOLDER ) )
+ , m_aUp( this, ModuleRes( BTN_EXPLORERFILE_UP ) )
+ , m_aView( this, ModuleRes( CTRL_VIEW ) ,FILEVIEW_SHOW_TITLE )
+ , m_aFTName( this, ModuleRes( FT_EXPLORERFILE_FILENAME ) )
+ , m_aName( this, ModuleRes( ED_EXPLORERFILE_FILENAME ) )
+ , m_aFL( this, ModuleRes( FL_1 ) )
+ , m_aPB_OK( this, ModuleRes( BTN_EXPLORERFILE_SAVE ) )
+ , m_aPB_CANCEL( this, ModuleRes( PB_CANCEL ) )
+ , m_aPB_HELP( this, ModuleRes( PB_HELP ) )
+ , m_sPath( ModuleRes( STR_PATHNAME ) )
+ , m_xContent(_xContent)
+ , m_xORB(_xORB)
+ , m_bCreateForm(sal_True)
+{
+ DBG_CTOR(OCollectionView,NULL);
+ FreeResource();
+
+ OSL_ENSURE(m_xContent.is(),"No valid content!");
+ m_aView.Initialize(m_xContent,String());
+ m_aFTCurrentPath.SetStyle( m_aFTCurrentPath.GetStyle() | WB_PATHELLIPSIS );
+ initCurrentPath();
+
+ m_aName.SetText(_sDefaultName);
+ m_aName.GrabFocus();
+
+ m_aNewFolder.SetStyle( m_aNewFolder.GetStyle() | WB_NOPOINTERFOCUS );
+ m_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SC));
+ m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SC));
+
+ m_aView.SetDoubleClickHdl( LINK( this, OCollectionView, Dbl_Click_FileView ) );
+ m_aView.EnableAutoResize();
+ m_aUp.SetClickHdl( LINK( this, OCollectionView, Up_Click ) );
+ m_aNewFolder.SetClickHdl( LINK( this, OCollectionView, NewFolder_Click ) );
+ m_aPB_OK.SetClickHdl( LINK( this, OCollectionView, Save_Click ) );
+}
+// -----------------------------------------------------------------------------
+OCollectionView::~OCollectionView( )
+{
+ DBG_DTOR(OCollectionView,NULL);
+}
+// -----------------------------------------------------------------------------
+Reference< XContent> OCollectionView::getSelectedFolder() const
+{
+ return m_xContent;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG )
+{
+ ::rtl::OUString sName = m_aName.GetText();
+ if ( !sName.getLength() )
+ return 0;
+ try
+ {
+ ::rtl::OUString sSubFolder = m_aView.GetCurrentURL();
+ sal_Int32 nIndex = sName.lastIndexOf('/') + 1;
+ if ( nIndex )
+ {
+ if ( nIndex == 1 ) // special handling for root
+ {
+ Reference<XChild> xChild(m_xContent,UNO_QUERY);
+ Reference<XNameAccess> xNameAccess(xChild,UNO_QUERY);
+ while( xNameAccess.is() )
+ {
+ xNameAccess.set(xChild->getParent(),UNO_QUERY);
+ if ( xNameAccess.is() )
+ {
+ m_xContent.set(xNameAccess,UNO_QUERY);
+ xChild.set(m_xContent,UNO_QUERY);
+ }
+ }
+ m_aView.Initialize(m_xContent,String());
+ initCurrentPath();
+ }
+ sSubFolder = sName.copy(0,nIndex-1);
+ sName = sName.copy(nIndex);
+ Reference<XHierarchicalNameContainer> xHier(m_xContent,UNO_QUERY);
+ OSL_ENSURE(xHier.is(),"XHierarchicalNameContainer not supported!");
+ if ( sSubFolder.getLength() && xHier.is() )
+ {
+ if ( xHier->hasByHierarchicalName(sSubFolder) )
+ {
+ m_xContent.set(xHier->getByHierarchicalName(sSubFolder),UNO_QUERY);
+ }
+ else // sub folder doesn't exist
+ {
+ Sequence< Any > aValues(2);
+ PropertyValue aValue;
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceName"));
+ aValue.Value <<= sSubFolder;
+ aValues[0] <<= aValue;
+
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceType"));
+ aValue.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("folder"));
+ aValues[1] <<= aValue;
+
+ InteractionClassification eClass = InteractionClassification_ERROR;
+ ::com::sun::star::ucb::IOErrorCode eError = IOErrorCode_NOT_EXISTING_PATH;
+ ::rtl::OUString sTemp;
+ InteractiveAugmentedIOException aException(sTemp,Reference<XInterface>(),eClass,eError,aValues);
+
+
+ Reference<XInitialization> xIni(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))),UNO_QUERY);
+ if ( xIni.is() )
+ {
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= VCLUnoHelper::GetInterface( this );
+ Sequence< Any > aArgs(1);
+ aArgs[0] <<= makeAny(aValue);
+ xIni->initialize(aArgs);
+ OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aException));
+ Reference< XInteractionRequest > xRequest(pRequest);
+
+ OInteractionApprove* pApprove = new OInteractionApprove;
+ pRequest->addContinuation(pApprove);
+
+ Reference< XInteractionHandler > xHandler(xIni,UNO_QUERY);
+ xHandler->handle(xRequest);
+ }
+ return 0;
+ }
+ }
+ }
+ Reference<XNameContainer> xNameContainer(m_xContent,UNO_QUERY);
+ if ( xNameContainer.is() )
+ {
+ Reference< XContent> xContent;
+ if ( xNameContainer->hasByName(sName) )
+ {
+ QueryBox aBox( this, WB_YES_NO, ModuleRes( STR_ALREADYEXISTOVERWRITE ) );
+ if ( aBox.Execute() != RET_YES )
+ return 0;
+ }
+ m_aName.SetText(sName);
+ EndDialog( sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OCollectionView, NewFolder_Click, PushButton*, EMPTYARG )
+{
+ try
+ {
+ Reference<XHierarchicalNameContainer> xNameContainer(m_xContent,UNO_QUERY);
+ if ( dbaui::insertHierachyElement(this,m_xORB,xNameContainer,String(),m_bCreateForm) )
+ m_aView.Initialize(m_xContent,String());
+ }
+ catch( const SQLException& )
+ {
+ showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), this, m_xORB );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OCollectionView, Up_Click, PushButton*, EMPTYARG )
+{
+ try
+ {
+ Reference<XChild> xChild(m_xContent,UNO_QUERY);
+ if ( xChild.is() )
+ {
+ Reference<XNameAccess> xNameAccess(xChild->getParent(),UNO_QUERY);
+ if ( xNameAccess.is() )
+ {
+ m_xContent.set(xNameAccess,UNO_QUERY);
+ m_aView.Initialize(m_xContent,String());
+ initCurrentPath();
+ }
+ else
+ m_aUp.Disable();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OCollectionView, Dbl_Click_FileView, SvtFileView*, EMPTYARG )
+{
+ try
+ {
+ Reference<XNameAccess> xNameAccess(m_xContent,UNO_QUERY);
+ if ( xNameAccess.is() )
+ {
+ ::rtl::OUString sSubFolder = m_aView.GetCurrentURL();
+ sal_Int32 nIndex = sSubFolder.lastIndexOf('/') + 1;
+ sSubFolder = sSubFolder.getToken(0,'/',nIndex);
+ if ( sSubFolder.getLength() )
+ {
+ Reference< XContent> xContent;
+ if ( xNameAccess->hasByName(sSubFolder) )
+ xContent.set(xNameAccess->getByName(sSubFolder),UNO_QUERY);
+ if ( xContent.is() )
+ {
+ m_xContent = xContent;
+ m_aView.Initialize(m_xContent,String());
+ initCurrentPath();
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OCollectionView::initCurrentPath()
+{
+ sal_Bool bEnable = sal_False;
+ try
+ {
+ if ( m_xContent.is() )
+ {
+ const ::rtl::OUString sCID = m_xContent->getIdentifier()->getContentIdentifier();
+ const static ::rtl::OUString s_sFormsCID(RTL_CONSTASCII_USTRINGPARAM("private:forms"));
+ const static ::rtl::OUString s_sReportsCID(RTL_CONSTASCII_USTRINGPARAM("private:reports"));
+ m_bCreateForm = s_sFormsCID.compareTo(sCID) == 0;
+ ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM("/"));
+ if ( m_bCreateForm && sCID.getLength() != s_sFormsCID.getLength())
+ sPath = sCID.copy(s_sFormsCID.getLength());
+ else if ( !m_bCreateForm && sCID.getLength() != s_sReportsCID.getLength() )
+ sPath = sCID.copy(s_sReportsCID.getLength());
+
+ m_aFTCurrentPath.SetText(sPath);
+ Reference<XChild> xChild(m_xContent,UNO_QUERY);
+ bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_aUp.Enable(bEnable);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCollectionView::getName() const
+{
+ return m_aName.GetText();
+}
+// -----------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/CollectionView.hrc b/dbaccess/source/ui/dlg/CollectionView.hrc
new file mode 100644
index 000000000000..0a385ff7f23c
--- /dev/null
+++ b/dbaccess/source/ui/dlg/CollectionView.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_COLLECTIONVIEW_HRC
+#define DBAUI_COLLECTIONVIEW_HRC
+
+#define CTRL_VIEW 1
+
+#define PB_CANCEL 1
+#define PB_HELP 1
+
+#define ED_EXPLORERFILE_FILENAME 1
+
+#define FT_EXPLORERFILE_CURRENTPATH 1
+#define FT_EXPLORERFILE_FILENAME 2
+
+#define BTN_EXPLORERFILE_NEWFOLDER 1
+#define BTN_EXPLORERFILE_UP 2
+#define BTN_EXPLORERFILE_SAVE 3
+
+#define STR_PATHNAME 1
+
+#define FL_1 1
+
+#endif //DBAUI_COLLECTIONVIEW_HRC
+
diff --git a/dbaccess/source/ui/dlg/CollectionView.src b/dbaccess/source/ui/dlg/CollectionView.src
new file mode 100644
index 000000000000..e431a6502e81
--- /dev/null
+++ b/dbaccess/source/ui/dlg/CollectionView.src
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+#include "CollectionView.hrc"
+
+#define WIN_X 200
+#define WIN_Y 192
+
+#define CHECKBOX_HEIGHT 8
+#define FIXEDTEXT_HEIGHT 8
+#define RELATED_CONTROLS 4
+#define UNRELATED_CONTROLS 7
+#define EDIT_HEIGHT 12
+#define BUTTON_HEIGHT 14
+#define FIXEDLINE_HEIGHT 1
+#define IMG_SIZE 15
+
+ModalDialog DLG_COLLECTION_VIEW
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ HelpId = HID_EXPLORERDLG_COLLECTION ;
+
+ Size = MAP_APPFONT ( WIN_X , WIN_Y ) ;
+ Text [ en-US ] = "Save" ;
+
+ FixedText FT_EXPLORERFILE_CURRENTPATH
+ {
+ Pos = MAP_APPFONT ( UNRELATED_CONTROLS , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( 100 , FIXEDTEXT_HEIGHT ) ;
+ NoLabel = TRUE ;
+ };
+ ImageButton BTN_EXPLORERFILE_NEWFOLDER
+ {
+ HelpID = "dbaccess:ImageButton:DLG_COLLECTION_VIEW:BTN_EXPLORERFILE_NEWFOLDER";
+ TabStop = FALSE ;
+ Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - RELATED_CONTROLS - 2*IMG_SIZE, UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( IMG_SIZE , IMG_SIZE ) ;
+ QuickHelpText [ en-US ] = "Create New Directory" ;
+ };
+ ImageButton BTN_EXPLORERFILE_UP
+ {
+ HelpID = "dbaccess:ImageButton:DLG_COLLECTION_VIEW:BTN_EXPLORERFILE_UP";
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - IMG_SIZE, UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( IMG_SIZE , IMG_SIZE ) ;
+ QuickHelpText [ en-US ] = "Up One Level" ;
+ };
+
+ Control CTRL_VIEW
+ {
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( UNRELATED_CONTROLS , 2*UNRELATED_CONTROLS + IMG_SIZE) ;
+ Size = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS , WIN_Y - 6*UNRELATED_CONTROLS - BUTTON_HEIGHT - IMG_SIZE - EDIT_HEIGHT - FIXEDTEXT_HEIGHT) ;
+ Border = TRUE ;
+ };
+
+ FixedText FT_EXPLORERFILE_FILENAME
+ {
+ Pos = MAP_APPFONT ( UNRELATED_CONTROLS , WIN_Y - 3*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT - EDIT_HEIGHT ) ;
+ Size = MAP_APPFONT ( 50 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "File ~name:" ;
+ };
+ Edit ED_EXPLORERFILE_FILENAME
+ {
+ HelpID = "dbaccess:Edit:DLG_COLLECTION_VIEW:ED_EXPLORERFILE_FILENAME";
+ Pos = MAP_APPFONT ( RELATED_CONTROLS + UNRELATED_CONTROLS + 50 , WIN_Y - 3*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT - EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( WIN_X - RELATED_CONTROLS - 2*UNRELATED_CONTROLS - 50 , EDIT_HEIGHT ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+
+ FixedLine FL_1
+ {
+ Pos = MAP_APPFONT ( 0 , WIN_Y - 2*UNRELATED_CONTROLS - BUTTON_HEIGHT - FIXEDLINE_HEIGHT) ;
+ Size = MAP_APPFONT ( WIN_X , FIXEDLINE_HEIGHT ) ;
+ };
+
+ PushButton BTN_EXPLORERFILE_SAVE
+ {
+ HelpID = "dbaccess:PushButton:DLG_COLLECTION_VIEW:BTN_EXPLORERFILE_SAVE";
+ Pos = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS - RELATED_CONTROLS - 150, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ;
+ DefButton = TRUE ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Save" ;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( WIN_X - 2*UNRELATED_CONTROLS - 100, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ;
+ };
+
+ HelpButton PB_HELP
+ {
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( WIN_X - UNRELATED_CONTROLS - 50, WIN_Y - UNRELATED_CONTROLS - BUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( 50 , BUTTON_HEIGHT ) ;
+ };
+
+ String STR_PATHNAME
+ {
+ Text [ en-US ] = "~Path:" ;
+ };
+};
+
+String STR_NEW_FOLDER
+{
+ Text [ en-US ] = "Folder" ;
+};
+
+Image IMG_NAVIGATION_BTN_UP_SC
+{
+ ImageBitmap = Bitmap { File = "fp010"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image IMG_NAVIGATION_CREATEFOLDER_SC
+{
+ ImageBitmap = Bitmap { File = "fp015"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+String STR_ALREADYEXISTOVERWRITE
+{
+ Text [ en-US ] = "The file already exists. Overwrite?" ;
+};
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.cxx b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
new file mode 100644
index 000000000000..d2f87d016152
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.cxx
@@ -0,0 +1,905 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dsnItem.hxx"
+#include "ConnectionHelper.hxx"
+#include "AutoControls.hrc"
+#include "dbu_dlg.hrc"
+#include "dbu_misc.hrc"
+#include <svl/itemset.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dsitems.hxx"
+#include "dbaccess_helpid.hrc"
+#include "localresaccess.hxx"
+#include <osl/process.h>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include "dbadmin.hxx"
+#include <comphelper/types.hxx>
+#include <vcl/stdtext.hxx>
+#include "sqlmessage.hxx"
+#include "odbcconfig.hxx"
+#include "dsselect.hxx"
+#include <svl/filenotation.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#include "UITools.hxx"
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include "finteraction.hxx"
+#include <connectivity/CommonTools.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/docfilt.hxx>
+#if !defined(WINDOWS_VISTA_PSDK) && defined(WNT)
+#define _ADO_DATALINK_BROWSE_
+#endif
+
+#ifdef _ADO_DATALINK_BROWSE_
+#include <vcl/sysdata.hxx>
+#include "adodatalinks.hxx"
+#endif //_ADO_DATALINK_BROWSE_
+
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+#include <unotools/processfactory.hxx>
+
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::mozilla;
+ using namespace ::dbtools;
+ using namespace ::svt;
+
+
+DBG_NAME(OConnectionHelper)
+
+ OConnectionHelper::OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs)
+ :OGenericAdministrationPage(pParent, _rId, _rCoreAttrs)
+ ,m_aFT_Connection ( this, ResId( FT_AUTOBROWSEURL, *_rId.GetResMgr() ) )
+ ,m_aConnectionURL ( this, ResId( ET_AUTOBROWSEURL, *_rId.GetResMgr() ) )
+ ,m_aPB_Connection ( this, ResId( PB_AUTOBROWSEURL, *_rId.GetResMgr() ) )
+ {
+ DBG_CTOR(OConnectionHelper,NULL);
+
+ // extract the datasource type collection from the item set
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rCoreAttrs.GetItem(DSID_TYPECOLLECTION));
+ if (pCollectionItem)
+ m_pCollection = pCollectionItem->getCollection();
+ m_aPB_Connection.SetClickHdl(LINK(this, OConnectionHelper, OnBrowseConnections));
+ OSL_ENSURE(m_pCollection, "OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
+ m_aConnectionURL.SetTypeCollection(m_pCollection);
+ }
+
+
+ OConnectionHelper::~OConnectionHelper()
+ {
+
+ DBG_DTOR(OConnectionHelper,NULL);
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ m_aFT_Connection.Show();
+ m_aConnectionURL.Show();
+ m_aConnectionURL.ShowPrefix( ::dbaccess::DST_JDBC == m_pCollection->determineType(m_eType) );
+
+ sal_Bool bEnableBrowseButton = m_pCollection->supportsBrowsing( m_eType );
+ m_aPB_Connection.Show( bEnableBrowseButton );
+
+ SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+
+ // forward the values to the controls
+ if ( bValid )
+ {
+ String sUrl = pUrlItem->GetValue();
+ setURL( sUrl );
+
+ checkTestConnection();
+ m_aConnectionURL.ClearModifyFlag();
+ }
+
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ void OConnectionHelper::implUpdateURLDependentStates() const
+ {
+ OSL_PRECOND( m_pAdminDialog, "OConnectionHelper::implUpdateURLDependentStates: no admin dialog!" );
+ if ( !m_pAdminDialog )
+ return;
+
+ if ( m_pCollection->isFileSystemBased(m_eType) )
+ m_pAdminDialog->enableConfirmSettings( getURLNoPrefix().Len() > 0 );
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
+ switch ( eType )
+ {
+ case ::dbaccess::DST_DBASE:
+ case ::dbaccess::DST_FLAT:
+ {
+ try
+ {
+ ::rtl::OUString sFolderPickerService(SERVICE_UI_FOLDERPICKER);
+ Reference< XFolderPicker > xFolderPicker(m_xORB->createInstance(sFolderPickerService), UNO_QUERY);
+ if (!xFolderPicker.is())
+ {
+ ShowServiceNotAvailableError(GetParent(), sFolderPickerService, sal_True);
+ break;
+ }
+
+ sal_Bool bDoBrowse = sal_False;
+ String sOldPath = getURLNoPrefix();
+ do
+ {
+ if (sOldPath.Len())
+ xFolderPicker->setDisplayDirectory(sOldPath);
+ if (0 == xFolderPicker->execute())
+ // cancelled by the user
+ return 0L;
+
+ sOldPath = xFolderPicker->getDirectory();
+ switch (checkPathExistence(sOldPath))
+ {
+ case RET_RETRY:
+ bDoBrowse = sal_True;
+ break;
+ case RET_CANCEL:
+ return 0L;
+ default:
+ break;
+ }
+ }
+ while (bDoBrowse);
+
+ String sSelectedDirectory = xFolderPicker->getDirectory();
+ INetURLObject aSelectedDirectory( sSelectedDirectory, INetURLObject::WAS_ENCODED, RTL_TEXTENCODING_UTF8 );
+
+ // for UI purpose, we don't want to have the path encoded
+ sSelectedDirectory = aSelectedDirectory.GetMainURL( INetURLObject::DECODE_WITH_CHARSET, RTL_TEXTENCODING_UTF8 );
+
+ setURLNoPrefix( sSelectedDirectory );
+ SetRoadmapStateValue(sal_True);
+ callModifiedHdl();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ break;
+ case ::dbaccess::DST_CALC:
+ {
+ SvtModuleOptions aModule;
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN
+ ,aModule.GetFactoryEmptyDocumentURL(SvtModuleOptions::E_CALC)
+ ,SFX_FILTER_IMPORT);
+ askForFileName(aFileDlg);
+ }
+ break;
+ case ::dbaccess::DST_MSACCESS:
+ {
+ const ::rtl::OUString sExt(RTL_CONSTASCII_USTRINGPARAM("*.mdb"));
+ String sFilterName(ModuleRes (STR_MSACCESS_FILTERNAME));
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN);
+ aFileDlg.AddFilter(sFilterName,sExt);
+ aFileDlg.SetCurrentFilter(sFilterName);
+ askForFileName(aFileDlg);
+ }
+ break;
+ case ::dbaccess::DST_MSACCESS_2007:
+ {
+ const ::rtl::OUString sAccdb(RTL_CONSTASCII_USTRINGPARAM("*.accdb"));
+ String sFilterName2(ModuleRes (STR_MSACCESS_2007_FILTERNAME));
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK | WB_STDMODAL | WB_OPEN);
+ aFileDlg.AddFilter(sFilterName2,sAccdb);
+ aFileDlg.SetCurrentFilter(sFilterName2);
+ askForFileName(aFileDlg);
+ }
+ break;
+ case ::dbaccess::DST_ADABAS:
+ {
+ // collect all names from the config dir
+ // and all dir's of the DBWORK/wrk or DBROOT/wrk dir
+ // compare the names
+
+ // collect the names of the installed databases
+ StringBag aInstalledDBs;
+ ::rtl::OUString sAdabasConfigDir,sAdabasWorkDir,sRootDir;
+ ::rtl::OUString sEnvVarName(RTL_CONSTASCII_USTRINGPARAM("DBWORK"));
+ rtl_uString* pDbVar = NULL;
+ if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar)
+ {
+ sAdabasWorkDir = pDbVar;
+ String sURL;
+ utl::LocalFileHelper::ConvertPhysicalNameToURL(sAdabasWorkDir,sURL);
+ sAdabasWorkDir = sURL;
+ rtl_uString_release(pDbVar);
+ pDbVar = NULL;
+ }
+
+ sEnvVarName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBCONFIG"));
+ if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar)
+ {
+ sAdabasConfigDir = pDbVar;
+ String sURL;
+ utl::LocalFileHelper::ConvertPhysicalNameToURL(sAdabasConfigDir,sURL);
+ sAdabasConfigDir = sURL;
+ rtl_uString_release(pDbVar);
+ pDbVar = NULL;
+ }
+
+ sEnvVarName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
+ if(osl_getEnvironment(sEnvVarName.pData,&pDbVar) == osl_Process_E_None && pDbVar)
+ {
+ sRootDir = pDbVar;
+ String sURL;
+ utl::LocalFileHelper::ConvertPhysicalNameToURL(sRootDir,sURL);
+ sRootDir = sURL;
+ rtl_uString_release(pDbVar);
+ pDbVar = NULL;
+ }
+
+ sal_Bool bOldFashion = sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength();
+
+ if(!bOldFashion) // we have a normal adabas installation
+ { // so we check the local database names in $DBROOT/config
+ sAdabasConfigDir = sRootDir;
+ sAdabasWorkDir = sRootDir;
+ }
+
+ if(sAdabasConfigDir.getLength() && sAdabasWorkDir.getLength() && sRootDir.getLength())
+ {
+
+ aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
+
+ if(!aInstalledDBs.size() && bOldFashion)
+ {
+ sAdabasConfigDir = sRootDir;
+ sAdabasWorkDir = sRootDir;
+ aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
+ }
+
+ ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, true,m_pItemSetHelper->getWriteOutputSet());
+ if (RET_OK == aSelector.Execute())
+ {
+ setURLNoPrefix(aSelector.GetSelected());
+ SetRoadmapStateValue(sal_True);
+ callModifiedHdl();
+ }
+ }
+ else
+ {
+ LocalResourceAccess aLocRes( PAGE_CONNECTION, RSC_TABPAGE );
+ String sError = String(ModuleRes(STR_NO_ADABASE_DATASOURCES));
+ ErrorBox aBox(this, WB_OK, sError);
+ aBox.Execute();
+ }
+ }
+ break;
+ case ::dbaccess::DST_MYSQL_ODBC:
+ case ::dbaccess::DST_ODBC:
+ {
+ // collect all ODBC data source names
+ ::rtl::OUString sCurrDatasource = getURLNoPrefix();
+ ::rtl::OUString sDataSource;
+ if ( getSelectedDataSource(sDataSource,sCurrDatasource) && sDataSource.getLength() )
+ {
+ setURLNoPrefix(sDataSource);
+ SetRoadmapStateValue(sal_True);
+ callModifiedHdl();
+ }
+ else
+ return 1L;
+ }
+ break;
+#ifdef _ADO_DATALINK_BROWSE_
+ case ::dbaccess::DST_ADO:
+ {
+ ::rtl::OUString sOldDataSource=getURLNoPrefix();
+ ::rtl::OUString sNewDataSource;
+ HWND hWnd = GetParent()->GetSystemData()->hWnd;
+ sNewDataSource = getAdoDatalink((long)hWnd,sOldDataSource);
+ if ( sNewDataSource.getLength() )
+ {
+ setURLNoPrefix(sNewDataSource);
+ SetRoadmapStateValue(sal_True);
+ callModifiedHdl();
+ }
+ else
+ return 1L;
+ }
+ break;
+#endif
+ case ::dbaccess::DST_MOZILLA:
+ case ::dbaccess::DST_THUNDERBIRD:
+ {
+ MozillaProductType profileType = MozillaProductType_Mozilla;
+ if (eType == ::dbaccess::DST_THUNDERBIRD)
+ profileType = MozillaProductType_Thunderbird;
+
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ Reference<XMozillaBootstrap> xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+ OSL_ENSURE( xMozillaBootstrap.is(), "failed to create instance" );
+
+ if (xMozillaBootstrap.is())
+ {
+ // collect all Mozilla Profiles
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > list;
+
+ xMozillaBootstrap->getProfileList( profileType, list );
+ const ::rtl::OUString * pArray = list.getConstArray();
+
+ sal_Int32 count = list.getLength();
+
+ StringBag aProfiles;
+ for (sal_Int32 index=0; index < count; index++)
+ aProfiles.insert(pArray[index]);
+
+
+ // execute the select dialog
+ ODatasourceSelectDialog aSelector(GetParent(), aProfiles, eType);
+ ::rtl::OUString sOldProfile=getURLNoPrefix();
+
+ if (sOldProfile.getLength())
+ aSelector.Select(sOldProfile);
+ else
+ aSelector.Select(xMozillaBootstrap->getDefaultProfile(profileType));
+
+ if ( RET_OK == aSelector.Execute() )
+ setURLNoPrefix(aSelector.GetSelected());
+ break;
+ }
+ }
+ default:
+ break;
+ }
+
+ checkTestConnection();
+
+ return 0L;
+ }
+
+ //-------------------------------------------------------------------------
+
+ bool OConnectionHelper::checkTestConnection()
+ {
+ return true;
+ }
+
+ //-------------------------------------------------------------------------
+ void OConnectionHelper::impl_setURL( const String& _rURL, sal_Bool _bPrefix )
+ {
+ String sURL( _rURL );
+ OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
+
+ if ( m_pCollection && sURL.Len() )
+ {
+ if ( m_pCollection->isFileSystemBased( m_eType ) )
+ {
+ // get the two parts: prefix and file URL
+ String sTypePrefix, sFileURLEncoded;
+ if ( _bPrefix )
+ {
+ sTypePrefix = m_pCollection->getPrefix( m_eType );
+ sFileURLEncoded = m_pCollection->cutPrefix( sURL );
+ }
+ else
+ {
+ sFileURLEncoded = sURL;
+ }
+
+ // substitute any variables
+ sFileURLEncoded = SvtPathOptions().SubstituteVariable( sFileURLEncoded );
+
+ // decode the URL
+ sURL = sTypePrefix;
+ if ( sFileURLEncoded.Len() )
+ {
+ OFileNotation aFileNotation(sFileURLEncoded);
+ // set this decoded URL as text
+ sURL += String(aFileNotation.get(OFileNotation::N_SYSTEM));
+ }
+ }
+ }
+
+ if ( _bPrefix )
+ m_aConnectionURL.SetText( sURL );
+ else
+ m_aConnectionURL.SetTextNoPrefix( sURL );
+
+ implUpdateURLDependentStates();
+ }
+
+ //-------------------------------------------------------------------------
+ String OConnectionHelper::impl_getURL( sal_Bool _bPrefix ) const
+ {
+ // get the pure text
+ String sURL = _bPrefix ? m_aConnectionURL.GetText() : m_aConnectionURL.GetTextNoPrefix();
+
+ OSL_ENSURE( m_pCollection, "OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
+
+ if ( m_pCollection && sURL.Len() )
+ {
+ if ( m_pCollection->isFileSystemBased( m_eType ) )
+ {
+ // get the two parts: prefix and file URL
+ String sTypePrefix, sFileURLDecoded;
+ if ( _bPrefix )
+ {
+ sTypePrefix = m_pCollection->getPrefix( m_eType );
+ sFileURLDecoded = m_pCollection->cutPrefix( sURL );
+ }
+ else
+ {
+ sFileURLDecoded = sURL;
+ }
+
+ sURL = sTypePrefix;
+ if ( sFileURLDecoded.Len() )
+ {
+ OFileNotation aFileNotation( sFileURLDecoded, OFileNotation::N_SYSTEM );
+ sURL += String( aFileNotation.get( OFileNotation::N_URL ) );
+ }
+
+ // encode the URL
+ INetURLObject aFileURL( sFileURLDecoded, INetURLObject::ENCODE_ALL, RTL_TEXTENCODING_UTF8 );
+ sFileURLDecoded = aFileURL.GetMainURL( INetURLObject::NO_DECODE );
+ }
+ }
+ return sURL;
+ }
+
+ //-------------------------------------------------------------------------
+ void OConnectionHelper::setURL( const String& _rURL )
+ {
+ impl_setURL( _rURL, sal_True );
+ }
+
+ //-------------------------------------------------------------------------
+ String OConnectionHelper::getURLNoPrefix( ) const
+ {
+ return impl_getURL( sal_False );
+ }
+
+ //-------------------------------------------------------------------------
+ void OConnectionHelper::setURLNoPrefix( const String& _rURL )
+ {
+ impl_setURL( _rURL, sal_False );
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Int32 OConnectionHelper::checkPathExistence(const String& _rURL)
+ {
+ IS_PATH_EXIST e_exists = pathExists(_rURL, sal_False);
+ if (( e_exists == PATH_NOT_EXIST) || ( e_exists == PATH_NOT_KNOWN))
+ {
+ String sQuery(ModuleRes(STR_ASK_FOR_DIRECTORY_CREATION));
+ OFileNotation aTransformer(_rURL);
+ sQuery.SearchAndReplaceAscii("$path$", aTransformer.get(OFileNotation::N_SYSTEM));
+
+ m_bUserGrabFocus = sal_False;
+ QueryBox aQuery(GetParent(), WB_YES_NO | WB_DEF_YES, sQuery);
+ sal_Int32 nQueryResult = aQuery.Execute();
+ m_bUserGrabFocus = sal_True;
+
+ switch (nQueryResult)
+ {
+ case RET_YES:
+ {
+ sal_Bool bTryCreate = sal_False;
+ do
+ {
+ if ( !createDirectoryDeep(_rURL) )
+ { // could not create the directory
+ sQuery = String(ModuleRes(STR_COULD_NOT_CREATE_DIRECTORY));
+ sQuery.SearchAndReplaceAscii("$name$", aTransformer.get(OFileNotation::N_SYSTEM));
+
+ m_bUserGrabFocus = sal_False;
+ QueryBox aWhatToDo(GetParent(), WB_RETRY_CANCEL | WB_DEF_RETRY, sQuery);
+ nQueryResult = aWhatToDo.Execute();
+ m_bUserGrabFocus = sal_True;
+
+ if (RET_RETRY == nQueryResult)
+ bTryCreate = sal_True;
+ else
+ {
+ SetRoadmapStateValue(sal_False);
+ callModifiedHdl();
+ return RET_RETRY;
+ }
+ }
+ }
+ while (bTryCreate);
+ }
+ break;
+
+ case RET_NO:
+ callModifiedHdl();
+ return RET_OK;
+
+ default:
+ // cancelled
+ SetRoadmapStateValue(sal_False);
+ callModifiedHdl();
+ return RET_CANCEL;
+ }
+ }
+/* else
+ {
+ // TODO: error msg
+ return RET_CANCEL;
+ } */
+ SetRoadmapStateValue(sal_True);
+ callModifiedHdl();
+ return RET_OK;
+ }
+
+
+ //-------------------------------------------------------------------------
+ StringBag OConnectionHelper::getInstalledAdabasDBDirs(const String& _rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude)
+ {
+ INetURLObject aNormalizer;
+ aNormalizer.SetSmartProtocol(INET_PROT_FILE);
+ aNormalizer.SetSmartURL(_rPath);
+ String sAdabasConfigDir = aNormalizer.GetMainURL(INetURLObject::NO_DECODE);
+
+ ::ucbhelper::Content aAdabasConfigDir;
+ try
+ {
+ aAdabasConfigDir = ::ucbhelper::Content(sAdabasConfigDir, Reference< ::com::sun::star::ucb::XCommandEnvironment >());
+ }
+ catch(::com::sun::star::ucb::ContentCreationException&)
+ {
+ return StringBag();
+ }
+
+ StringBag aInstalledDBs;
+ sal_Bool bIsFolder = sal_False;
+ try
+ {
+ bIsFolder = aAdabasConfigDir.isFolder();
+ }
+ catch(Exception&) // the exception is thrown when the path doesn't exists
+ {
+ }
+ if (bIsFolder && aAdabasConfigDir.get().is())
+ { // we have a content for the directory, loop through all entries
+ Sequence< ::rtl::OUString > aProperties(1);
+ aProperties[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+
+ try
+ {
+ Reference< XResultSet > xFiles = aAdabasConfigDir.createCursor(aProperties, _reResultSetInclude);
+ Reference< XRow > xRow(xFiles, UNO_QUERY);
+ xFiles->beforeFirst();
+ while (xFiles->next())
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sName = xRow->getString(1);
+#endif
+ aInstalledDBs.insert(xRow->getString(1));
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("OConnectionHelper::getInstalledAdabasDBDirs: could not enumerate the adabas config files!");
+ }
+ }
+
+
+ return aInstalledDBs;
+ }
+ // -----------------------------------------------------------------------------
+ StringBag OConnectionHelper::getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir)
+ {
+ String sAdabasConfigDir(_rConfigDir),sAdabasWorkDir(_rWorkDir);
+
+ if (sAdabasConfigDir.Len() && ('/' == sAdabasConfigDir.GetBuffer()[sAdabasConfigDir.Len() - 1]))
+ sAdabasConfigDir.AppendAscii("config");
+ else
+ sAdabasConfigDir.AppendAscii("/config");
+
+ if (sAdabasWorkDir.Len() && ('/' == sAdabasWorkDir.GetBuffer()[sAdabasWorkDir.Len() - 1]))
+ sAdabasWorkDir.AppendAscii("wrk");
+ else
+ sAdabasWorkDir.AppendAscii("/wrk");
+ // collect the names of the installed databases
+ StringBag aInstalledDBs;
+ // collect the names of the installed databases
+ StringBag aConfigDBs,aWrkDBs;
+ aConfigDBs = getInstalledAdabasDBDirs(sAdabasConfigDir,::ucbhelper::INCLUDE_DOCUMENTS_ONLY);
+ aWrkDBs = getInstalledAdabasDBDirs(sAdabasWorkDir,::ucbhelper::INCLUDE_FOLDERS_ONLY);
+ ConstStringBagIterator aOuter = aConfigDBs.begin();
+ ConstStringBagIterator aOuterEnd = aConfigDBs.end();
+ for(;aOuter != aOuterEnd;++aOuter)
+ {
+ ConstStringBagIterator aInner = aWrkDBs.begin();
+ ConstStringBagIterator aInnerEnd = aWrkDBs.end();
+ for (;aInner != aInnerEnd; ++aInner)
+ {
+ if (aInner->equalsIgnoreAsciiCase(*aOuter))
+ {
+ aInstalledDBs.insert(*aInner);
+ break;
+ }
+ }
+ }
+ return aInstalledDBs;
+ }
+ // -----------------------------------------------------------------------------
+ IS_PATH_EXIST OConnectionHelper::pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const
+ {
+ ::ucbhelper::Content aCheckExistence;
+ sal_Bool bExists = sal_False;
+ IS_PATH_EXIST eExists = PATH_NOT_EXIST;
+ Reference< ::com::sun::star::task::XInteractionHandler > xInteractionHandler = Reference< ::com::sun::star::task::XInteractionHandler >(
+ m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler") ) ), UNO_QUERY );
+ OFilePickerInteractionHandler* pHandler = new OFilePickerInteractionHandler(xInteractionHandler);
+ xInteractionHandler = pHandler;
+
+ Reference< XCommandEnvironment > xCmdEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler, Reference< XProgressHandler >() );
+ try
+ {
+ aCheckExistence = ::ucbhelper::Content(_rURL, xCmdEnv );
+ bExists = bIsFile? aCheckExistence.isDocument(): aCheckExistence.isFolder();
+ eExists = bExists? PATH_EXIST: PATH_NOT_EXIST;
+ }
+ catch(const Exception&)
+ {
+ eExists = ( pHandler && pHandler->isDoesNotExist() ) ? PATH_NOT_EXIST: (bIsFile ? PATH_NOT_EXIST : PATH_NOT_KNOWN);
+ }
+ return eExists;
+ }
+ //-------------------------------------------------------------------------
+ long OConnectionHelper::PreNotify( NotifyEvent& _rNEvt )
+ {
+ if ( m_pCollection->isFileSystemBased(m_eType) )
+ {
+ switch (_rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus)
+ { // a descendant of the URL edit field got the focus
+ m_aConnectionURL.SaveValueNoPrefix();
+ }
+ break;
+
+ case EVENT_LOSEFOCUS:
+ if (m_aConnectionURL.IsWindowOrChild(_rNEvt.GetWindow()) && m_bUserGrabFocus)
+ { // a descendant of the URL edit field lost the focus
+ if (!commitURL())
+ return 1L; // handled
+ }
+ break;
+ }
+ }
+
+ return OGenericAdministrationPage::PreNotify( _rNEvt );
+ }
+
+ //-------------------------------------------------------------------------
+
+ sal_Bool OConnectionHelper::createDirectoryDeep(const String& _rPathURL)
+ {
+ ::rtl::OUString sPath(_rPathURL);
+
+ // get an URL object analyzing the URL for us ...
+ INetURLObject aParser;
+ aParser.SetURL(_rPathURL);
+
+ INetProtocol eProtocol = aParser.GetProtocol();
+
+ ::std::vector< ::rtl::OUString > aToBeCreated; // the to-be-created levels
+
+ // search a level which exists
+ IS_PATH_EXIST eParentExists = PATH_NOT_EXIST;
+ while ( eParentExists == PATH_NOT_EXIST && aParser.getSegmentCount())
+ {
+ aToBeCreated.push_back(aParser.getName()); // remember the local name for creation
+ aParser.removeSegment(); // cut the local name
+ eParentExists = pathExists(aParser.GetMainURL(INetURLObject::NO_DECODE), sal_False);
+ }
+
+ if (!aParser.getSegmentCount())
+ return sal_False;
+
+ // create all the missing levels
+ try
+ {
+ // the parent content
+ Reference< XCommandEnvironment > xEmptyEnv;
+ ::ucbhelper::Content aParent(aParser.GetMainURL(INetURLObject::NO_DECODE), xEmptyEnv);
+
+ ::rtl::OUString sContentType;
+ if ( INET_PROT_FILE == eProtocol )
+ {
+ sContentType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.staroffice.fsys-folder"));
+ // the file UCP currently does not support the ContentType property
+ }
+ else
+ {
+ Any aContentType = aParent.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContentType")) );
+ aContentType >>= sContentType;
+ }
+
+ // the properties which need to be set on the new content
+ Sequence< ::rtl::OUString > aNewDirectoryProperties(1);
+ aNewDirectoryProperties[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+
+ // the values to be set
+ Sequence< Any > aNewDirectoryAttributes(1);
+
+ // loop
+ for ( ::std::vector< ::rtl::OUString >::reverse_iterator aLocalName = aToBeCreated.rbegin();
+ aLocalName != aToBeCreated.rend();
+ ++aLocalName
+ )
+ {
+ aNewDirectoryAttributes[0] <<= *aLocalName;
+ if (!aParent.insertNewContent(sContentType, aNewDirectoryProperties, aNewDirectoryAttributes, aParent))
+ return sal_False;
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Connection));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPB_Connection));
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back( new OSaveValueWrapper<Edit>( &m_aConnectionURL ) );
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool OConnectionHelper::commitURL()
+ {
+ String sURL;
+ String sOldPath;
+ sOldPath = m_aConnectionURL.GetSavedValueNoPrefix();
+ sURL = m_aConnectionURL.GetTextNoPrefix();
+
+ if ( m_pCollection->isFileSystemBased(m_eType) )
+ {
+ if ( ( sURL != sOldPath ) && ( 0 != sURL.Len() ) )
+ { // the text changed since entering the control
+
+ // the path may be in system notation ....
+ OFileNotation aTransformer(sURL);
+ sURL = aTransformer.get(OFileNotation::N_URL);
+
+ const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
+
+ if ( ( ::dbaccess::DST_CALC == eType) || ( ::dbaccess::DST_MSACCESS == eType) || ( ::dbaccess::DST_MSACCESS_2007 == eType) )
+ {
+ if( pathExists(sURL, sal_True) == PATH_NOT_EXIST )
+ {
+ String sFile = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) );
+ sFile.SearchAndReplaceAscii("$file$", aTransformer.get(OFileNotation::N_SYSTEM));
+ OSQLWarningBox( this, sFile ).Execute();
+ setURLNoPrefix(sOldPath);
+ SetRoadmapStateValue(sal_False);
+ callModifiedHdl();
+ return sal_False;
+ }
+ }
+ else
+ {
+ switch (checkPathExistence(sURL))
+ {
+ case RET_RETRY:
+ m_bUserGrabFocus = sal_False;
+ m_aConnectionURL.GrabFocus();
+ m_bUserGrabFocus = sal_True;
+ return sal_False;
+
+ case RET_CANCEL:
+ setURLNoPrefix(sOldPath);
+ return sal_False;
+ }
+ }
+ }
+ }
+
+ setURLNoPrefix(sURL);
+ m_aConnectionURL.SaveValueNoPrefix();
+ return sal_True;
+ }
+ //-------------------------------------------------------------------------
+ void OConnectionHelper::askForFileName(::sfx2::FileDialogHelper& _aFileOpen)
+ {
+ String sOldPath = getURLNoPrefix();
+ if ( sOldPath.Len() )
+ _aFileOpen.SetDisplayDirectory(sOldPath);
+ else
+ _aFileOpen.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+ if (0 == _aFileOpen.Execute())
+ {
+ setURLNoPrefix(_aFileOpen.GetPath());
+ SetRoadmapStateValue(checkTestConnection());
+ callModifiedHdl();
+ }
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/ConnectionHelper.hxx b/dbaccess/source/ui/dlg/ConnectionHelper.hxx
new file mode 100644
index 000000000000..cd1e491dfb6b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionHelper.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_CONNECTIONHELPER_HXX
+#define DBAUI_CONNECTIONHELPER_HXX
+
+#include "adminpages.hxx"
+#include <ucbhelper/content.hxx>
+#include "curledit.hxx"
+#include <sfx2/filedlghelper.hxx>
+
+
+#define FILL_STRING_ITEM(editcontrol, itemset, itemid, modifiedflag) \
+ if (editcontrol.GetText() != editcontrol.GetSavedValue()) \
+ { \
+ itemset.Put(SfxStringItem(itemid, editcontrol.GetText())); \
+ modifiedflag = sal_True; \
+ }
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ enum IS_PATH_EXIST
+ {
+ PATH_NOT_EXIST = 0,
+ PATH_EXIST,
+ PATH_NOT_KNOWN
+ };
+
+ class IDatabaseSettingsDialog;
+
+ class OConnectionHelper : public OGenericAdministrationPage
+ {
+ sal_Bool m_bUserGrabFocus : 1;
+
+ public:
+ OConnectionHelper( Window* pParent, const ResId& _rId, const SfxItemSet& _rCoreAttrs);
+ virtual ~OConnectionHelper();
+ FixedText m_aFT_Connection;
+ OConnectionURLEdit m_aConnectionURL;
+ PushButton m_aPB_Connection;
+ ::rtl::OUString m_eType; // the type can't be changed in this class, so we hold it as member.
+
+ public:
+
+ // setting/retrieving the current connection URL
+ // necessary because for some types, the URL must be decoded for display purposes
+ ::dbaccess::ODsnTypeCollection* m_pCollection; /// the DSN type collection instance
+ virtual long PreNotify( NotifyEvent& _rNEvt );
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+
+ // setting/retrieving the current connection URL
+ // necessary because for some types, the URL must be decoded for display purposes
+ //String getURL( OConnectionURLEdit* _m_pConnection ) const;
+ //void setURL( const String& _rURL, OConnectionURLEdit* _m_pConnection );
+
+ String getURLNoPrefix( ) const;
+ void setURLNoPrefix( const String& _rURL );
+
+ /** checks if the path is existence
+ @param _rURL
+ The URL to check.
+ */
+ sal_Int32 checkPathExistence(const String& _rURL);
+
+
+ IS_PATH_EXIST pathExists(const ::rtl::OUString& _rURL, sal_Bool bIsFile) const;
+ sal_Bool createDirectoryDeep(const String& _rPathNormalized);
+ sal_Bool commitURL();
+
+ /** opens the FileOpen dialog and asks for a FileName
+ @param _aFileOpen
+ Executes the file open dialog, which must be filled from caller.
+ */
+ void askForFileName(::sfx2::FileDialogHelper& _aFileOpen);
+
+ virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
+ {
+ OGenericAdministrationPage::SetServiceFactory(_rxORB);
+ }
+
+ protected:
+ void setURL( const String& _rURL );
+ virtual bool checkTestConnection();
+
+ private:
+ DECL_LINK(OnBrowseConnections, PushButton*);
+ StringBag getInstalledAdabasDBDirs(const String &_rPath,const ::ucbhelper::ResultSetInclude& _reResultSetInclude);
+ StringBag getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);
+ String impl_getURL( sal_Bool _bPrefix ) const;
+ void impl_setURL( const String& _rURL, sal_Bool _bPrefix );
+ void implUpdateURLDependentStates() const;
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_CONNECTIONHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.cxx b/dbaccess/source/ui/dlg/ConnectionPage.cxx
new file mode 100644
index 000000000000..9e9f9cd027a9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.cxx
@@ -0,0 +1,378 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionPage.hxx"
+#include "ConnectionPage.hrc"
+#include "dbu_dlg.hrc"
+#include "dsmeta.hxx"
+#include <svl/itemset.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include "dsitems.hxx"
+#include "dbaccess_helpid.hrc"
+#include "localresaccess.hxx"
+#include <osl/process.h>
+#include <vcl/msgbox.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include "dbadmin.hxx"
+#include <comphelper/types.hxx>
+#include <vcl/stdtext.hxx>
+#include "sqlmessage.hxx"
+#include "odbcconfig.hxx"
+#include "dsselect.hxx"
+#include <svl/filenotation.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include "UITools.hxx"
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include "finteraction.hxx"
+#include <connectivity/CommonTools.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/docfilt.hxx>
+#include "dsnItem.hxx"
+#if defined(WNT)
+#define _ADO_DATALINK_BROWSE_
+#endif
+
+#ifdef _ADO_DATALINK_BROWSE_
+#include <vcl/sysdata.hxx>
+#include "adodatalinks.hxx"
+#endif //_ADO_DATALINK_BROWSE_
+
+#include "AutoControls.hrc"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::dbtools;
+ using namespace ::svt;
+
+ SfxTabPage* OConnectionTabPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OConnectionTabPage( pParent, _rAttrSet ) );
+ }
+ //========================================================================
+ //= OConnectionTabPage
+ //========================================================================
+ DBG_NAME(OConnectionTabPage)
+ OConnectionTabPage::OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs)
+ :OConnectionHelper(pParent, ModuleRes(PAGE_CONNECTION), _rCoreAttrs)
+ ,m_bUserGrabFocus(sal_True)
+ ,m_aFL1(this, ModuleRes(FL_SEPARATOR1))
+ ,m_aFL2(this, ModuleRes(FL_SEPARATOR2))
+ ,m_aUserNameLabel(this, ModuleRes(FT_USERNAME))
+ ,m_aUserName(this, ModuleRes(ET_USERNAME))
+ ,m_aPasswordRequired(this, ModuleRes(CB_PASSWORD_REQUIRED))
+ ,m_aFL3(this, ModuleRes(FL_SEPARATOR3))
+ ,m_aJavaDriverLabel(this, ModuleRes(FT_JDBCDRIVERCLASS))
+ ,m_aJavaDriver(this, ModuleRes(ET_JDBCDRIVERCLASS))
+ ,m_aTestJavaDriver(this, ModuleRes(PB_TESTDRIVERCLASS))
+ ,m_aTestConnection(this, ModuleRes(PB_TESTCONNECTION))
+ {
+ DBG_CTOR(OConnectionTabPage,NULL);
+ m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified));
+ m_aJavaDriver.SetModifyHdl(getControlModifiedLink());
+ m_aJavaDriver.SetModifyHdl(LINK(this, OConnectionTabPage, OnEditModified));
+ m_aUserName.SetModifyHdl(getControlModifiedLink());
+ m_aPasswordRequired.SetClickHdl(getControlModifiedLink());
+
+ m_aTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl));
+ m_aTestJavaDriver.SetClickHdl(LINK(this,OConnectionTabPage,OnTestJavaClickHdl));
+
+ FreeResource();
+
+ LayoutHelper::fitSizeRightAligned( m_aTestConnection );
+ }
+
+ // -----------------------------------------------------------------------
+ OConnectionTabPage::~OConnectionTabPage()
+ {
+ DBG_DTOR(OConnectionTabPage,NULL);
+ }
+
+ // -----------------------------------------------------------------------
+ void OConnectionTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ m_eType = m_pAdminDialog->getDatasourceType(_rSet);
+ OConnectionHelper::implInitControls( _rSet, _bSaveValue);
+
+ LocalResourceAccess aLocRes( PAGE_CONNECTION, RSC_TABPAGE );
+ ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(m_eType);
+ switch( eType )
+ {
+ case ::dbaccess::DST_DBASE:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_DBASE_PATH_OR_FILE)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_DBASE_PATH);
+ break;
+ case ::dbaccess::DST_FLAT:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_FLAT_PATH_OR_FILE)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_FLAT_PATH);
+ break;
+ case ::dbaccess::DST_CALC:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_CALC_PATH_OR_FILE)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_CALC_PATH);
+ break;
+ case ::dbaccess::DST_ADABAS:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_ADABAS_DATABASE_NAME)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_ADABAS_DATABASE);
+ break;
+ case ::dbaccess::DST_ADO:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL)));
+ break;
+ case ::dbaccess::DST_MSACCESS:
+ case ::dbaccess::DST_MSACCESS_2007:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_MSACCESS_MDB_FILE)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_MSACCESS_MDB_FILE);
+ break;
+ case ::dbaccess::DST_MYSQL_NATIVE:
+ case ::dbaccess::DST_MYSQL_JDBC:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_MYSQL_DATABASE_NAME)));
+ m_aConnectionURL.SetHelpId( HID_DSADMIN_MYSQL_DATABASE );
+ break;
+ case ::dbaccess::DST_ORACLE_JDBC:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_ORACLE_DATABASE_NAME)));
+ m_aConnectionURL.SetHelpId(HID_DSADMIN_ORACLE_DATABASE);
+ break;
+ case ::dbaccess::DST_MYSQL_ODBC:
+ case ::dbaccess::DST_ODBC:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_NAME_OF_ODBC_DATASOURCE)));
+ m_aConnectionURL.SetHelpId( eType == ::dbaccess::DST_MYSQL_ODBC ? HID_DSADMIN_MYSQL_ODBC_DATASOURCE : HID_DSADMIN_ODBC_DATASOURCE);
+ break;
+ case ::dbaccess::DST_LDAP:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_HOSTNAME)));
+ m_aConnectionURL.SetHelpId( HID_DSADMIN_LDAP_HOSTNAME );
+ break;
+ case ::dbaccess::DST_MOZILLA:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_MOZILLA_PROFILE_NAME)));
+ m_aConnectionURL.SetHelpId( HID_DSADMIN_MOZILLA_PROFILE_NAME );
+ break;
+ case ::dbaccess::DST_THUNDERBIRD:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_THUNDERBIRD_PROFILE_NAME)));
+ m_aConnectionURL.SetHelpId( HID_DSADMIN_THUNDERBIRD_PROFILE_NAME );
+ break;
+ case ::dbaccess::DST_OUTLOOK:
+ case ::dbaccess::DST_OUTLOOKEXP:
+ case ::dbaccess::DST_EVOLUTION:
+ case ::dbaccess::DST_EVOLUTION_GROUPWISE:
+ case ::dbaccess::DST_EVOLUTION_LDAP:
+ case ::dbaccess::DST_KAB:
+ case ::dbaccess::DST_MACAB:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_NO_ADDITIONAL_SETTINGS)));
+ {
+ String sText = m_aFT_Connection.GetText();
+ sText.SearchAndReplaceAscii("%test",m_aTestConnection.GetText());
+ String sTemp;
+ sText.SearchAndReplaceAscii("~",sTemp);
+ m_aFT_Connection.SetText(sText);
+ }
+ m_aConnectionURL.Hide();
+ break;
+ case ::dbaccess::DST_JDBC:
+ default:
+ m_aFT_Connection.SetText(String(ModuleRes(STR_COMMONURL)));
+ break;
+ }
+
+ ;
+ AuthenticationMode eAuthMode( DataSourceMetaData::getAuthentication( m_eType ) );
+ bool bShowUserAuthenfication = ( eAuthMode != AuthNone );
+ bool bShowUser = ( eAuthMode == AuthUserPwd );
+
+ m_aPB_Connection.SetHelpId(HID_DSADMIN_BROWSECONN);
+ m_aFL2.Show( bShowUserAuthenfication );
+ m_aUserNameLabel.Show( bShowUser && bShowUserAuthenfication );
+ m_aUserName.Show( bShowUser && bShowUserAuthenfication );
+ m_aPasswordRequired.Show( bShowUserAuthenfication );
+ if ( !bShowUser && bShowUserAuthenfication )
+ m_aPasswordRequired.SetPosPixel(m_aUserNameLabel.GetPosPixel());
+
+ // collect the items
+ SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
+
+ SFX_ITEMSET_GET(_rSet, pJdbcDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
+ SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
+
+ // forward the values to the controls
+ if ( bValid )
+ {
+ m_aUserName.SetText(pUidItem->GetValue());
+ m_aPasswordRequired.Check(pAllowEmptyPwd->GetValue());
+
+ String sUrl = pUrlItem->GetValue();
+ setURL( sUrl );
+
+ const sal_Bool bEnableJDBC = m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC;
+ if ( !pJdbcDrvItem->GetValue().Len() )
+ {
+ String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
+ if ( sDefaultJdbcDriverName.Len() )
+ {
+ m_aJavaDriver.SetText(sDefaultJdbcDriverName);
+ m_aJavaDriver.SetModifyFlag();
+ }
+ }
+ else
+ m_aJavaDriver.SetText(pJdbcDrvItem->GetValue());
+
+ m_aJavaDriverLabel.Show(bEnableJDBC);
+ m_aJavaDriver.Show(bEnableJDBC);
+ m_aTestJavaDriver.Show(bEnableJDBC);
+ m_aTestJavaDriver.Enable( m_aJavaDriver.GetText().Len() != 0);
+ m_aFL3.Show(bEnableJDBC);
+
+ checkTestConnection();
+
+ m_aUserName.ClearModifyFlag();
+ m_aConnectionURL.ClearModifyFlag();
+ m_aJavaDriver.ClearModifyFlag();
+ }
+ }
+ // -----------------------------------------------------------------------
+ void OConnectionTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL1));
+
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL2));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aJavaDriverLabel));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aTestJavaDriver));
+
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL3));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aUserNameLabel));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aTestConnection));
+ OConnectionHelper::fillWindows(_rControlList);
+
+ }
+ // -----------------------------------------------------------------------
+ void OConnectionTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aJavaDriver));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aUserName));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aPasswordRequired));
+ OConnectionHelper::fillControls(_rControlList);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OConnectionTabPage::FillItemSet(SfxItemSet& _rSet)
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ if (m_aUserName.GetText() != m_aUserName.GetSavedValue())
+ {
+ _rSet.Put(SfxStringItem(DSID_USER, m_aUserName.GetText()));
+ _rSet.Put(SfxStringItem(DSID_PASSWORD, String()));
+ bChangedSomething = sal_True;
+ }
+
+ fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
+
+ if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC )
+ {
+ fillString(_rSet,&m_aJavaDriver, DSID_JDBCDRIVERCLASS, bChangedSomething);
+ }
+
+ fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething);
+
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OConnectionTabPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if ( m_aJavaDriver.GetText().Len() )
+ {
+ ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
+ bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aJavaDriver.GetText());
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
+ OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+ aMsg.Execute();
+ return 0L;
+ }
+ // -----------------------------------------------------------------------
+ bool OConnectionTabPage::checkTestConnection()
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ sal_Bool bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
+ if ( m_pCollection->determineType(m_eType) == ::dbaccess::DST_JDBC )
+ bEnableTestConnection = bEnableTestConnection && (m_aJavaDriver.GetText().Len() != 0);
+ m_aTestConnection.Enable(bEnableTestConnection);
+ return true;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OConnectionTabPage, OnEditModified, Edit*, _pEdit)
+ {
+ if ( _pEdit == &m_aJavaDriver )
+ m_aTestJavaDriver.Enable( m_aJavaDriver.GetText().Len() != 0 );
+
+ checkTestConnection();
+ // tell the listener we were modified
+ callModifiedHdl();
+ return 0L;
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hrc b/dbaccess/source/ui/dlg/ConnectionPage.hrc
new file mode 100644
index 000000000000..347b0f0bac28
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.hrc
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_CONNECTIONPAGE_HRC
+#define DBAUI_CONNECTIONPAGE_HRC
+
+//========================================================================
+// control ids
+
+#define FT_USERNAME 1
+#define FT_JDBCDRIVERCLASS 2
+#define FT_DBASE_PATH_OR_FILE 3
+#define FT_NAME_OF_ODBC_DATASOURCE 4
+#define FT_MYSQL_DATABASE_NAME 5
+#define FT_MSACCESS_MDB_FILE 6
+#define FT_FLAT_PATH_OR_FILE 7
+#define FT_CALC_PATH_OR_FILE 8
+#define FT_ADABAS_DATABASE_NAME 9
+#define FT_NO_ADDITIONAL_SETTINGS 10
+#define FT_HOSTNAME 11
+#define FT_ORACLE_DATABASE_NAME 12
+
+#define ET_USERNAME 1
+#define ET_JDBCDRIVERCLASS 2
+
+#define PB_TESTDRIVERCLASS 1
+#define PB_TESTCONNECTION 2
+
+#define CB_PASSWORD_REQUIRED 1
+
+#define FL_SEPARATOR2 1
+#define FL_SEPARATOR3 2
+
+#endif // DBAUI_CONNECTIONPAGE_HRC
+
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.hxx b/dbaccess/source/ui/dlg/ConnectionPage.hxx
new file mode 100644
index 000000000000..bd0034a22a91
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_CONNECTIONPAGE_HXX
+#define DBAUI_CONNECTIONPAGE_HXX
+
+#include "ConnectionHelper.hxx"
+#include "adminpages.hxx"
+#include <ucbhelper/content.hxx>
+#include "curledit.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ class IDatabaseSettingsDialog;
+ //=========================================================================
+ //= OConnectionTabPage
+ //=========================================================================
+
+ /** implements the connection page of teh data source properties dialog.
+ */
+ class OConnectionTabPage : public OConnectionHelper
+ {
+ sal_Bool m_bUserGrabFocus : 1;
+ protected:
+ // connection
+ FixedLine m_aFL1;
+ // user authentification
+ FixedLine m_aFL2;
+ FixedText m_aUserNameLabel;
+ Edit m_aUserName;
+ CheckBox m_aPasswordRequired;
+
+ // jdbc driver
+ FixedLine m_aFL3;
+ FixedText m_aJavaDriverLabel;
+ Edit m_aJavaDriver;
+ PushButton m_aTestJavaDriver;
+
+ // connection test
+ PushButton m_aTestConnection;
+
+
+ // called when the test connection button was clicked
+ DECL_LINK(OnTestJavaClickHdl,PushButton*);
+ DECL_LINK(OnEditModified,Edit*);
+
+ public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
+ virtual sal_Bool FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ inline void enableConnectionURL() { m_aConnectionURL.SetReadOnly(sal_False); }
+ inline void disableConnectionURL() { m_aConnectionURL.SetReadOnly(); }
+
+ /** changes the connection URL.
+ <p>The new URL must be of the type which is currently selected, only the parts which do not
+ affect the type may be changed (compared to the previous URL).</p>
+ */
+ private:
+ OConnectionTabPage(Window* pParent, const SfxItemSet& _rCoreAttrs);
+ // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
+ virtual ~OConnectionTabPage();
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ /** enables the test connection button, if allowed
+ */
+ virtual bool checkTestConnection();
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DETAILPAGES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/ConnectionPage.src b/dbaccess/source/ui/dlg/ConnectionPage.src
new file mode 100644
index 000000000000..63c400b0a77a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPage.src
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBAUI_CONNECTIONPAGE_HRC
+#include "ConnectionPage.hrc"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+
+//.........................................................................
+TabPage PAGE_CONNECTION
+{
+ HelpID = "dbaccess:TabPage:PAGE_CONNECTION";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "General";
+ };
+
+ AUTO_BROWSECONTROLGROUP( 6, UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS, PAGE_X, HID_DSADMIN_URL_GENERAL, HID_DSADMIN_BROWSECONN)
+
+ FixedText FT_NO_ADDITIONAL_SETTINGS
+ {
+ Hide = TRUE;
+ WordBreak = TRUE;
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 12 , 3*FIXEDTEXT_HEIGHT ) ;
+ };
+
+ FixedText FT_HOSTNAME
+ {
+ Hide = TRUE;
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Host name";
+ };
+
+ FixedLine FL_SEPARATOR2
+ {
+ Pos = MAP_APPFONT ( 4 , 3*FIXEDTEXT_HEIGHT + 3*UNRELATED_CONTROLS + RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "User authentication";
+ };
+
+ FixedText FT_USERNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( 90 - 12 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~User name" ;
+ };
+
+ Edit ET_USERNAME
+ {
+ HelpID = "dbaccess:Edit:PAGE_CONNECTION:ET_USERNAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS -1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+
+ CheckBox CB_PASSWORD_REQUIRED
+ {
+ HelpID = "dbaccess:CheckBox:PAGE_CONNECTION:CB_PASSWORD_REQUIRED";
+ Pos = MAP_APPFONT ( 90 , 4*UNRELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( 105 , CHECKBOX_HEIGHT ) ;
+ Text [ en-US ] = "Password required";
+ };
+
+ FixedLine FL_SEPARATOR3
+ {
+ Pos = MAP_APPFONT ( 4 , 5*UNRELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + CHECKBOX_HEIGHT) ;
+
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "JDBC properties";
+ };
+
+ FixedText FT_JDBCDRIVERCLASS
+ {
+ Pos = MAP_APPFONT ( 6 , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT) ;
+
+ Size = MAP_APPFONT ( 90 - 12 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~JDBC driver class" ;
+ };
+
+ Edit ET_JDBCDRIVERCLASS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT -1) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_DRIVERCLASS;
+ };
+
+ PushButton PB_TESTDRIVERCLASS
+ {
+ HelpID = "dbaccess:PushButton:PAGE_CONNECTION:PB_TESTDRIVERCLASS";
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , 5*UNRELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT + 3*RELATED_CONTROLS + CHECKBOX_HEIGHT -2 ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ Text [ en-US ] = "Test Class" ;
+ };
+
+ PushButton PB_TESTCONNECTION
+ {
+ HelpID = "dbaccess:PushButton:PAGE_CONNECTION:PB_TESTCONNECTION";
+ Pos = MAP_APPFONT ( PAGE_X - 75 - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( 75 , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Test Connection";
+ };
+
+};
+
+String STR_NO_ADABASE_DATASOURCES
+{
+ Text [ en-US ] = "No Adabas D data sources were found on your system.";
+};
+
+String STR_CONNECTION_TEST
+{
+ Text [ en-US ] = "Connection Test";
+};
+
+String STR_CONNECTION_SUCCESS
+{
+ Text [ en-US ] = "The connection was established successfully.";
+};
+
+String STR_CONNECTION_NO_SUCCESS
+{
+ Text [ en-US ] = "The connection could not be established.";
+};
+
+String STR_JDBCDRIVER_SUCCESS
+{
+ Text [ en-US ] = "The JDBC driver was loaded successfully.";
+};
+
+String STR_JDBCDRIVER_NO_SUCCESS
+{
+ Text [ en-US ] = "The JDBC driver could not be loaded.";
+};
+
+String STR_MSACCESS_FILTERNAME
+{
+ Text [ en-US ] = "MS Access file";
+};
+
+String STR_MSACCESS_2007_FILTERNAME
+{
+ Text [ en-US ] = "MS Access 2007 file";
+};
diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx
new file mode 100644
index 000000000000..6ee4c808aeb5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.cxx
@@ -0,0 +1,244 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionPageSetup.hxx"
+#include "AutoControls.hrc"
+#include "dbadminsetup.hrc"
+#include "dbu_dlg.hrc"
+#include <svl/itemset.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dsitems.hxx"
+#include "dbaccess_helpid.hrc"
+#include "localresaccess.hxx"
+#include <osl/process.h>
+#include <vcl/msgbox.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include "dbadmin.hxx"
+#include "dbadmin.hrc"
+#include <comphelper/types.hxx>
+#include <vcl/stdtext.hxx>
+#include "sqlmessage.hxx"
+#include "odbcconfig.hxx"
+#include "dsselect.hxx"
+#include <svl/filenotation.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ucb/XProgressHandler.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include "UITools.hxx"
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include "finteraction.hxx"
+#include <connectivity/CommonTools.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/docfilt.hxx>
+#include <vcl/mnemonic.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::dbtools;
+ using namespace ::svt;
+
+
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_DBASE, _rAttrSet, STR_DBASE_HELPTEXT, STR_DBASE_HEADERTEXT, STR_DBASE_PATH_OR_FILE);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_MSACCESS, _rAttrSet, STR_MSACCESS_HELPTEXT, STR_MSACCESS_HEADERTEXT, STR_MSACCESS_MDB_FILE);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADABAS, _rAttrSet, STR_ADABAS_HELPTEXT, STR_ADABAS_HEADERTEXT, STR_ADABAS_DATABASE_NAME);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ADO, _rAttrSet, STR_ADO_HELPTEXT, STR_ADO_HEADERTEXT, STR_COMMONURL);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_ODBC, _rAttrSet, STR_ODBC_HELPTEXT, STR_ODBC_HEADERTEXT, STR_NAME_OF_ODBC_DATASOURCE);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+ OGenericAdministrationPage* OConnectionTabPageSetup::CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ OConnectionTabPageSetup* oDBWizardPage = new OConnectionTabPageSetup( pParent, PAGE_DBWIZARD_USERDEFINED, _rAttrSet, USHRT_MAX, USHRT_MAX, STR_COMMONURL);
+ oDBWizardPage->FreeResource();
+ return oDBWizardPage;
+ }
+
+
+ //========================================================================
+ //= OConnectionTabPageSetup
+ //========================================================================
+ DBG_NAME(OConnectionTabPageSetup)
+ OConnectionTabPageSetup::OConnectionTabPageSetup(Window* pParent, sal_uInt16 _rId, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId)
+ :OConnectionHelper(pParent, ModuleRes(_rId), _rCoreAttrs)
+ ,m_bUserGrabFocus(sal_True)
+ ,m_aFT_HelpText(this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
+ {
+ DBG_CTOR(OConnectionTabPageSetup, NULL);
+
+ if ( USHRT_MAX != _nHelpTextResId )
+ {
+ String sHelpText = String(ModuleRes(_nHelpTextResId));
+ m_aFT_HelpText.SetText(sHelpText);
+ }
+ else
+ m_aFT_HelpText.Hide();
+
+
+ if ( USHRT_MAX != _nHeaderResId )
+ SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderResId);
+
+ if ( USHRT_MAX != _nUrlResId )
+ {
+ String sLabelText = String(ModuleRes(_nUrlResId));
+ m_aFT_Connection.SetText(sLabelText);
+ if ( USHRT_MAX == _nHelpTextResId )
+ {
+ Point aPos = m_aFT_HelpText.GetPosPixel();
+ Point aFTPos = m_aFT_Connection.GetPosPixel();
+ Point aEDPos = m_aConnectionURL.GetPosPixel();
+ Point aPBPos = m_aPB_Connection.GetPosPixel();
+
+ aEDPos.Y() = aPos.Y() + aEDPos.Y() - aFTPos.Y();
+ aPBPos.Y() = aPos.Y() + aPBPos.Y() - aFTPos.Y();
+ aFTPos.Y() = aPos.Y();
+ m_aFT_Connection.SetPosPixel(aFTPos);
+ m_aConnectionURL.SetPosPixel(aEDPos);
+ m_aPB_Connection.SetPosPixel(aPBPos);
+ }
+ }
+ else
+ m_aFT_Connection.Hide();
+
+ m_aConnectionURL.SetModifyHdl(LINK(this, OConnectionTabPageSetup, OnEditModified));
+
+ SetRoadmapStateValue(sal_False);
+ }
+
+ // -----------------------------------------------------------------------
+ OConnectionTabPageSetup::~OConnectionTabPageSetup()
+ {
+ DBG_DTOR(OConnectionTabPageSetup,NULL);
+ }
+
+ // -----------------------------------------------------------------------
+ void OConnectionTabPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ m_eType = m_pAdminDialog->getDatasourceType(_rSet);
+ // special handling for oracle, this can only happen
+ // if the user enters the same url as used for Oracle and we are on the JDBC path
+ //! TODO
+ //if ( ::dbaccess::DST_ORACLE_JDBC == m_eType )
+ // m_eType = ::dbaccess::DST_JDBC;
+
+ OConnectionHelper::implInitControls(_rSet, _bSaveValue);
+
+ //! TODO
+ //if ( m_eType >= ::dbaccess::DST_USERDEFINE1 )
+ //{
+ // String sDisplayName = m_pCollection->getTypeDisplayName(m_eType);
+ // FixedText* ppTextControls[] ={&m_aFT_Connection};
+ // for (size_t i = 0; i < SAL_N_ELEMENTS(ppTextControls); ++i)
+ // {
+ // ppTextControls[i]->SetText(sDisplayName);
+ // }
+ //}
+
+ callModifiedHdl();
+ }
+ // -----------------------------------------------------------------------
+ sal_Bool OConnectionTabPageSetup::commitPage( ::svt::WizardTypes::CommitPageReason /*_eReason*/ )
+ {
+ return commitURL();
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OConnectionTabPageSetup::FillItemSet(SfxItemSet& _rSet)
+ {
+ sal_Bool bChangedSomething = sal_False;
+ fillString(_rSet,&m_aConnectionURL, DSID_CONNECTURL, bChangedSomething);
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ bool OConnectionTabPageSetup::checkTestConnection()
+ {
+ return !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OConnectionTabPageSetup, OnEditModified, Edit*, /*_pEdit*/)
+ {
+ SetRoadmapStateValue(checkTestConnection());
+ callModifiedHdl();
+ return 0L;
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx
new file mode 100644
index 000000000000..0fd31cf58101
--- /dev/null
+++ b/dbaccess/source/ui/dlg/ConnectionPageSetup.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#ifndef DBAUI_CONNECTIONPAGESETUP_HXX
+#define DBAUI_CONNECTIONPAGESETUP_HXX
+#include "ConnectionHelper.hxx"
+
+#include "adminpages.hxx"
+#include <ucbhelper/content.hxx>
+#include "curledit.hxx"
+
+#include <vcl/field.hxx>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ class IDatabaseSettingsDialog;
+ //=========================================================================
+ //= OConnectionTabPageSetup
+ //=========================================================================
+
+ /** implements the connection page of the data source properties dialog.
+ */
+ class OConnectionTabPageSetup : public OConnectionHelper
+ {
+ sal_Bool m_bUserGrabFocus : 1;
+ protected:
+
+ FixedText m_aFT_HelpText;
+
+ // called when the test connection button was clicked
+ DECL_LINK(OnEditModified,Edit*);
+
+ public:
+ static OGenericAdministrationPage* CreateDbaseTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateMSAccessTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateAdabasTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateADOTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateODBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateUserDefinedTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+
+
+ virtual sal_Bool FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+
+ inline void enableConnectionURL() { m_aConnectionURL.SetReadOnly(sal_False); }
+ inline void disableConnectionURL() { m_aConnectionURL.SetReadOnly(); }
+
+ /** changes the connection URL.
+ <p>The new URL must be of the type which is currently selected, only the parts which do not
+ affect the type may be changed (compared to the previous URL).</p>
+ */
+ void changeConnectionURL( const String& _rNewDSN );
+ String getConnectionURL( ) const;
+
+
+ protected:
+ OConnectionTabPageSetup(Window* pParent, sal_uInt16 _rId, const SfxItemSet& _rCoreAttrs, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderResId, sal_uInt16 _nUrlResId);
+ virtual bool checkTestConnection();
+ // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
+ virtual ~OConnectionTabPageSetup();
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
new file mode 100644
index 000000000000..d2b4bb956b67
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -0,0 +1,978 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "DBSetupConnectionPages.hxx"
+#include "sqlmessage.hxx"
+#include "dbu_resource.hrc"
+#include "AutoControls.hrc"
+#include "dbadminsetup.hrc"
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dsitems.hxx"
+#include "dsnItem.hxx"
+#include "dbaccess_helpid.hrc"
+#include "localresaccess.hxx"
+#include <vcl/msgbox.hxx>
+#include <vcl/mnemonic.hxx>
+#include <svl/cjkoptions.hxx>
+#include <jvmaccess/virtualmachine.hxx>
+#include <connectivity/CommonTools.hxx>
+#include "DriverSettings.hxx"
+#include "dbadmin.hxx"
+#include <comphelper/types.hxx>
+
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include "dbustrings.hrc"
+#include <svl/filenotation.hxx>
+
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include "finteraction.hxx"
+#include <connectivity/CommonTools.hxx>
+#include "dbaccess_helpid.hrc"
+#include <unotools/pathoptions.hxx>
+#include <svtools/roadmapwizard.hxx>
+#include "TextConnectionHelper.hxx"
+#include <osl/diagnose.h>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star;
+
+ OGenericAdministrationPage* OTextConnectionPageSetup::CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OTextConnectionPageSetup( pParent, _rAttrSet ) );
+ }
+
+
+ //========================================================================
+ //= OTextConnectionPageSetup
+ //========================================================================
+DBG_NAME(OTextConnectionPageSetup)
+//------------------------------------------------------------------------
+ OTextConnectionPageSetup::OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_TEXT, _rCoreAttrs, STR_TEXT_HELPTEXT, STR_TEXT_HEADERTEXT, STR_TEXT_PATH_OR_FILE)
+ {
+ DBG_CTOR(OTextConnectionPageSetup,NULL);
+
+ m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_SEPARATORS );
+ m_pTextConnectionHelper->SetClickHandler(LINK( this, OTextConnectionPageSetup, ImplGetExtensionHdl ) );
+
+ FreeResource();
+ }
+
+
+ // -----------------------------------------------------------------------
+ OTextConnectionPageSetup::~OTextConnectionPageSetup()
+ {
+ DELETEZ(m_pTextConnectionHelper);
+
+ DBG_DTOR(OTextConnectionPageSetup,NULL);
+ }
+
+ IMPL_LINK(OTextConnectionPageSetup, ImplGetExtensionHdl, OTextConnectionHelper*, /*_pTextConnectionHelper*/)
+ {
+ SetRoadmapStateValue((m_pTextConnectionHelper->GetExtension().Len() > 0) && OConnectionTabPageSetup::checkTestConnection());
+ callModifiedHdl();
+ return sal_True;
+ }
+
+
+ bool OTextConnectionPageSetup::checkTestConnection()
+ {
+ bool bDoEnable = OConnectionTabPageSetup::checkTestConnection();
+ bDoEnable = (m_pTextConnectionHelper->GetExtension().Len() > 0) && bDoEnable;
+ return bDoEnable;
+ }
+
+ // -----------------------------------------------------------------------
+ void OTextConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OConnectionTabPageSetup::fillControls(_rControlList);
+ m_pTextConnectionHelper->fillControls(_rControlList);
+ }
+ // -----------------------------------------------------------------------
+ void OTextConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OConnectionTabPageSetup::fillWindows(_rControlList);
+ m_pTextConnectionHelper->fillWindows(_rControlList);
+ }
+ // -----------------------------------------------------------------------
+ void OTextConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+ OConnectionTabPageSetup::implInitControls( _rSet, _bSaveValue);
+ m_pTextConnectionHelper->implInitControls(_rSet, bValid);
+ }
+
+
+ // -----------------------------------------------------------------------
+ sal_Bool OTextConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
+ bChangedSomething = m_pTextConnectionHelper->FillItemSet(_rSet, bChangedSomething);
+ return bChangedSomething;
+ }
+
+
+ sal_Bool OTextConnectionPageSetup::prepareLeave(){
+ return m_pTextConnectionHelper->prepareLeave();
+ }
+
+
+ OGenericAdministrationPage* OLDAPConnectionPageSetup::CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OLDAPConnectionPageSetup( pParent, _rAttrSet ) );
+ }
+
+
+ //========================================================================
+ //= OLDAPPageSetup
+ //========================================================================
+ OLDAPConnectionPageSetup::OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_LDAP), _rCoreAttrs)
+ ,m_aFTHeaderText (this, ModuleRes(FT_LDAP_HEADERTEXT))
+ ,m_aFTHelpText (this, ModuleRes(FT_LDAP_HELPTEXT))
+ ,m_aFTHostServer (this, ModuleRes(FT_AUTOHOSTNAME))
+ ,m_aETHostServer (this, ModuleRes(ET_AUTOHOSTNAME))
+ ,m_aFTBaseDN (this, ModuleRes(FT_AUTOBASEDN))
+ ,m_aETBaseDN (this, ModuleRes(ET_AUTOBASEDN))
+ ,m_aFTPortNumber (this, ModuleRes(FT_AUTOPORTNUMBER))
+ ,m_aNFPortNumber (this, ModuleRes(NF_AUTOPORTNUMBER))
+ ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
+ ,m_aCBUseSSL (this, ModuleRes(CB_WIZ_USESSL))
+ {
+ SetControlFontWeight(&m_aFTHeaderText);
+ m_aFTDefaultPortNumber.SetText(String(ModuleRes(STR_LDAP_DEFAULT)));
+ m_aETHostServer.SetModifyHdl(getControlModifiedLink());
+ m_aETBaseDN.SetModifyHdl(getControlModifiedLink());
+ m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
+ m_aCBUseSSL.SetToggleHdl(getControlModifiedLink());
+ SetRoadmapStateValue(sal_False);
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OLDAPConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = sal_False;
+ fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN, bChangedSomething);
+ fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
+
+ if ( m_aETHostServer.GetText() != m_aETHostServer.GetSavedValue() )
+ {
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
+ ::dbaccess::ODsnTypeCollection* pCollection = NULL;
+ if (pCollectionItem)
+ pCollection = pCollectionItem->getCollection();
+ OSL_ENSURE(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
+
+ String sUrl = pCollection->getPrefix( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:ldap:")));
+ sUrl += m_aETHostServer.GetText();
+ _rSet.Put(SfxStringItem(DSID_CONNECTURL, sUrl));
+ bChangedSomething = sal_True;
+ }
+
+ fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ void OLDAPConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostServer));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL));
+ }
+ // -----------------------------------------------------------------------
+ void OLDAPConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostServer));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTBaseDN));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
+ }
+ // -----------------------------------------------------------------------
+ void OLDAPConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+
+ SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True);
+ SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
+
+ if ( bValid )
+ {
+ m_aETBaseDN.SetText(pBaseDN->GetValue());
+ m_aNFPortNumber.SetValue(pPortNumber->GetValue());
+ }
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ callModifiedHdl();
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OLDAPConnectionPageSetup, OnEditModified, Edit*, /*_pEdit*/)
+ {
+ sal_Bool bRoadmapState = ((m_aETHostServer.GetText().Len() != 0 ) && ( m_aETBaseDN.GetText().Len() != 0 ) && (m_aFTPortNumber.GetText().Len() != 0 ));
+ SetRoadmapStateValue(bRoadmapState);
+ callModifiedHdl();
+ return 0L;
+ }
+
+
+ // ----------------------------------------------------------------------- //OGenericAdministrationPage*
+ OMySQLIntroPageSetup* OMySQLIntroPageSetup::CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OMySQLIntroPageSetup( _pParent, _rAttrSet) );
+ }
+
+DBG_NAME(OMySQLIntroPageSetup)
+
+ OMySQLIntroPageSetup::OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_MYSQL_INTRO), _rCoreAttrs)
+ ,m_aRB_ODBCDatabase(this, ModuleRes(RB_CONNECTVIAODBC))
+ ,m_aRB_JDBCDatabase(this, ModuleRes(RB_CONNECTVIAJDBC))
+ ,m_aRB_NATIVEDatabase(this, ModuleRes(RB_CONNECTVIANATIVE))
+ ,m_aFT_ConnectionMode(this, ModuleRes(FT_MYSQLCONNECTIONMODE))
+ ,m_aFT_Helptext(this, ModuleRes(FT_MYSQL_HELPTEXT))
+ ,m_aFT_Headertext(this, ModuleRes(FT_MYSQL_HEADERTEXT))
+ {
+ DBG_CTOR(OMySQLIntroPageSetup,NULL);
+
+ SetControlFontWeight(&m_aFT_Headertext);
+ m_aRB_ODBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
+ m_aRB_JDBCDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
+ m_aRB_NATIVEDatabase.SetToggleHdl(LINK(this, OMySQLIntroPageSetup, OnSetupModeSelected));
+ FreeResource();
+ }
+
+ IMPL_LINK(OMySQLIntroPageSetup, OnSetupModeSelected, RadioButton*, /*_pBox*/)
+ {
+ maClickHdl.Call( this );
+ return true;
+ }
+
+ // -----------------------------------------------------------------------
+ OMySQLIntroPageSetup::~OMySQLIntroPageSetup()
+ {
+
+ DBG_DTOR(OMySQLIntroPageSetup,NULL);
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OMySQLIntroPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
+ {
+ // show the "Connect directly" option only if the driver is installed
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rSet.GetItem(DSID_TYPECOLLECTION));
+ bool bHasMySQLNative = ( pCollectionItem != NULL ) && pCollectionItem->getCollection()->hasDriver( "sdbc:mysqlc:" );
+ if ( bHasMySQLNative )
+ m_aRB_NATIVEDatabase.Show();
+
+ // if any of the options is checked, then there's nothing to do
+ if ( m_aRB_ODBCDatabase.IsChecked() || m_aRB_JDBCDatabase.IsChecked() || m_aRB_NATIVEDatabase.IsChecked() )
+ return;
+
+ // prefer "native" or "JDBC"
+ if ( bHasMySQLNative )
+ m_aRB_NATIVEDatabase.Check();
+ else
+ m_aRB_JDBCDatabase.Check();
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OMySQLIntroPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+ {
+ }
+
+ // -----------------------------------------------------------------------
+ void OMySQLIntroPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+ {
+ }
+
+
+ // -----------------------------------------------------------------------
+ sal_Bool OMySQLIntroPageSetup::FillItemSet(SfxItemSet& /*_rSet*/)
+ {
+ OSL_FAIL("Who called me?! Please ask oj for more information.");
+ return sal_True;
+ }
+
+
+ OMySQLIntroPageSetup::ConnectionType OMySQLIntroPageSetup::getMySQLMode()
+ {
+ if (m_aRB_JDBCDatabase.IsChecked())
+ return VIA_JDBC;
+ else if (m_aRB_NATIVEDatabase.IsChecked())
+ return VIA_NATIVE;
+ else
+ return VIA_ODBC;
+ }
+
+ // =======================================================================
+ // = MySQLNativeSetupPage
+ // =======================================================================
+ // -----------------------------------------------------------------------
+ MySQLNativeSetupPage::MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage( _pParent, ModuleRes( PAGE_DBWIZARD_MYSQL_NATIVE ), _rCoreAttrs )
+ ,m_aHeader ( this, ModuleRes( FT_SETUP_WIZARD_HEADER ) )
+ ,m_aHelpText ( this, ModuleRes( FT_SETUP_WIZARD_HELP ) )
+ ,m_aMySQLSettings ( *this, getControlModifiedLink() )
+ {
+ SetControlFontWeight( &m_aHeader );
+
+ LayoutHelper::positionBelow( m_aHelpText, m_aMySQLSettings, UnrelatedControls, 0 );
+ m_aMySQLSettings.Show();
+
+ SetRoadmapStateValue(sal_False);
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ OGenericAdministrationPage* MySQLNativeSetupPage::Create( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return new MySQLNativeSetupPage( pParent, _rAttrSet );
+ }
+
+ // -----------------------------------------------------------------------
+ void MySQLNativeSetupPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ m_aMySQLSettings.fillControls( _rControlList );
+ }
+
+ // -----------------------------------------------------------------------
+ void MySQLNativeSetupPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHelpText ) );
+ m_aMySQLSettings.fillWindows( _rControlList );
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool MySQLNativeSetupPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ return m_aMySQLSettings.FillItemSet( _rSet );
+ }
+
+ // -----------------------------------------------------------------------
+ void MySQLNativeSetupPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
+ {
+ m_aMySQLSettings.implInitControls( _rSet );
+
+ OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
+
+ OnModified( NULL );
+ }
+
+ // -----------------------------------------------------------------------
+ Link MySQLNativeSetupPage::getControlModifiedLink()
+ {
+ return LINK( this, MySQLNativeSetupPage, OnModified );
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK( MySQLNativeSetupPage, OnModified, Edit*, _pEdit )
+ {
+ SetRoadmapStateValue( m_aMySQLSettings.canAdvance() );
+
+ return OGenericAdministrationPage::getControlModifiedLink().Call( _pEdit );
+ }
+
+ //========================================================================
+ //= OMySQLJDBCConnectionPageSetup
+ //========================================================================
+ OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( Window* pParent,sal_uInt16 _nResId, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, sal_uInt16 _nDefaultPortResId, sal_uInt16 _nHelpTextResId, sal_uInt16 _nHeaderTextResId, sal_uInt16 _nDriverClassId)
+ :OGenericAdministrationPage(pParent, ModuleRes(_nResId), _rCoreAttrs)
+ ,m_aFTHelpText (this, ModuleRes(FT_AUTOWIZARDHELPTEXT))
+ ,m_aFTDatabasename (this, ModuleRes(FT_AUTODATABASENAME))
+ ,m_aETDatabasename (this, ModuleRes(ET_AUTODATABASENAME))
+ ,m_aFTHostname (this, ModuleRes(FT_AUTOHOSTNAME))
+ ,m_aETHostname (this, ModuleRes(ET_AUTOHOSTNAME))
+ ,m_aFTPortNumber (this, ModuleRes(FT_AUTOPORTNUMBER))
+ ,m_aFTDefaultPortNumber (this, ModuleRes(FT_AUTOPORTNUMBERDEFAULT))
+ ,m_aNFPortNumber (this, ModuleRes(NF_AUTOPORTNUMBER))
+ ,m_aFTDriverClass (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
+ ,m_aETDriverClass (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
+ ,m_aPBTestJavaDriver (this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
+ ,m_nPortId(_nPortId)
+ {
+ m_aFTDriverClass.SetText(String(ModuleRes(_nDriverClassId)));
+
+ m_aFTDefaultPortNumber.SetText(String(ModuleRes(_nDefaultPortResId)));
+ String sHelpText = String(ModuleRes(_nHelpTextResId));
+ m_aFTHelpText.SetText(sHelpText);
+ //TODO this code snippet is redundant
+ SetHeaderText(FT_AUTOWIZARDHEADER, _nHeaderTextResId);
+
+ m_aETDatabasename.SetModifyHdl(getControlModifiedLink());
+ m_aETHostname.SetModifyHdl(getControlModifiedLink());
+ m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
+
+ m_aETDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified));
+ m_aPBTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCConnectionPageSetup,OnTestJavaClickHdl));
+
+ SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+ ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
+ if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() )
+ {
+ m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
+ }
+
+ SetRoadmapStateValue(sal_False);
+ FreeResource();
+ }
+
+
+ // -----------------------------------------------------------------------
+ OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
+ PAGE_DBWIZARD_MYSQL_JDBC,
+ _rAttrSet,
+ DSID_MYSQL_PORTNUMBER ,
+ STR_MYSQL_DEFAULT,
+ STR_MYSQLJDBC_HELPTEXT,
+ STR_MYSQLJDBC_HEADERTEXT,
+ STR_MYSQL_DRIVERCLASSTEXT) );
+ }
+
+ // -----------------------------------------------------------------------
+ OGenericAdministrationPage* OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OGeneralSpecialJDBCConnectionPageSetup( pParent,
+ PAGE_DBWIZARD_ORACLE,
+ _rAttrSet,
+ DSID_ORACLE_PORTNUMBER,
+ STR_ORACLE_DEFAULT,
+ STR_ORACLE_HELPTEXT,
+ STR_ORACLE_HEADERTEXT,
+ STR_ORACLE_DRIVERCLASSTEXT) );
+ }
+
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDatabasename));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETHostname));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
+ }
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDatabasename));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTPortNumber));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDefaultPortNumber));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OGeneralSpecialJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = sal_False;
+ fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
+ fillString(_rSet,&m_aETHostname,DSID_CONN_HOSTNAME,bChangedSomething);
+ fillString(_rSet,&m_aETDatabasename,DSID_DATABASENAME,bChangedSomething);
+ fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething );
+ return bChangedSomething;
+ }
+
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
+ SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True);
+
+ if ( bValid )
+ {
+ m_aETDatabasename.SetText(pDatabaseName->GetValue());
+ m_aETDatabasename.ClearModifyFlag();
+
+ m_aETDriverClass.SetText(pDrvItem->GetValue());
+ m_aETDriverClass.ClearModifyFlag();
+
+ m_aETHostname.SetText(pHostName->GetValue());
+ m_aETHostname.ClearModifyFlag();
+
+ m_aNFPortNumber.SetValue(pPortNumber->GetValue());
+ m_aNFPortNumber.ClearModifyFlag();
+ }
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+
+ // to get the correct value when saveValue was called by base class
+ if ( !m_aETDriverClass.GetText().Len() )
+ {
+ m_aETDriverClass.SetText(m_sDefaultJdbcDriverName);
+ m_aETDriverClass.SetModifyFlag();
+ }
+ callModifiedHdl();
+
+ sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
+ SetRoadmapStateValue(bRoadmapState);
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if ( m_aETDriverClass.GetText().Len() )
+ {
+// TODO chage jvmaccess
+ ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
+ bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
+ }
+ }
+ catch(::com::sun::star::uno::Exception&)
+ {
+ }
+
+ sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
+ OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+ aMsg.Execute();
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGeneralSpecialJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
+ {
+ if ( _pEdit == &m_aETDriverClass )
+ m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
+ sal_Bool bRoadmapState = ((m_aETDatabasename.GetText().Len() != 0 ) && ( m_aETHostname.GetText().Len() != 0 ) && (m_aNFPortNumber.GetText().Len() != 0 ) && ( m_aETDriverClass.GetText().Len() != 0 ));
+ SetRoadmapStateValue(bRoadmapState);
+ callModifiedHdl();
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------
+ OGenericAdministrationPage* OJDBCConnectionPageSetup::CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OJDBCConnectionPageSetup( pParent, _rAttrSet));
+ }
+
+
+ //========================================================================
+ //= OMySQLJDBCConnectionPageSetup
+ //========================================================================
+ OJDBCConnectionPageSetup::OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs)
+ :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_JDBC, _rCoreAttrs, STR_JDBC_HELPTEXT, STR_JDBC_HEADERTEXT, STR_COMMONURL)
+ ,m_aFTDriverClass (this, ModuleRes(FT_AUTOJDBCDRIVERCLASS))
+ ,m_aETDriverClass (this, ModuleRes(ET_AUTOJDBCDRIVERCLASS))
+ ,m_aPBTestJavaDriver (this, ModuleRes(PB_AUTOTESTDRIVERCLASS))
+ {
+ m_aETDriverClass.SetModifyHdl(LINK(this, OJDBCConnectionPageSetup, OnEditModified));
+ m_aPBTestJavaDriver.SetClickHdl(LINK(this,OJDBCConnectionPageSetup,OnTestJavaClickHdl));
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ void OJDBCConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETDriverClass));
+ }
+
+ // -----------------------------------------------------------------------
+ void OJDBCConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OJDBCConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
+ fillString(_rSet,&m_aETDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
+ return bChangedSomething;
+ }
+
+ // -----------------------------------------------------------------------
+ void OJDBCConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
+
+ if ( bValid )
+ {
+ if ( !pDrvItem->GetValue().Len() )
+ {
+ String sDefaultJdbcDriverName = m_pCollection->getJavaDriverClass(m_eType);
+ if ( sDefaultJdbcDriverName.Len() )
+ {
+ m_aETDriverClass.SetText(sDefaultJdbcDriverName);
+ m_aETDriverClass.SetModifyFlag();
+ }
+ }
+ else
+ {
+ m_aETDriverClass.SetText(pDrvItem->GetValue());
+ m_aETDriverClass.ClearModifyFlag();
+ }
+ }
+ sal_Bool bEnable = pDrvItem->GetValue().Len() != 0;
+ m_aPBTestJavaDriver.Enable(bEnable);
+ OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
+
+ SetRoadmapStateValue(checkTestConnection());
+ }
+
+
+ bool OJDBCConnectionPageSetup::checkTestConnection()
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ sal_Bool bEnableTestConnection = !m_aConnectionURL.IsVisible() || (m_aConnectionURL.GetTextNoPrefix().Len() != 0);
+ bEnableTestConnection = bEnableTestConnection && (m_aETDriverClass.GetText().Len() != 0);
+ return bEnableTestConnection;
+ }
+
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OJDBCConnectionPageSetup, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if ( m_aETDriverClass.GetText().Len() )
+ {
+// TODO chage jvmaccess
+ ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
+ bSuccess = xJVM.is() && ::connectivity::existsJavaClassByName(xJVM,m_aETDriverClass.GetText());
+ }
+ }
+ catch(::com::sun::star::uno::Exception&)
+ {
+ }
+
+ sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
+ OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+ aMsg.Execute();
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OJDBCConnectionPageSetup, OnEditModified, Edit*, _pEdit)
+ {
+ if ( _pEdit == &m_aETDriverClass )
+ m_aPBTestJavaDriver.Enable( m_aETDriverClass.GetText().Len() != 0 );
+ SetRoadmapStateValue(checkTestConnection());
+ // tell the listener we were modified
+ callModifiedHdl();
+ return 0L;
+ }
+
+
+ OGenericAdministrationPage* OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OSpreadSheetConnectionPageSetup( pParent, _rAttrSet ) );
+ }
+
+DBG_NAME(OSpreadSheetConnectionPageSetup)
+
+ OSpreadSheetConnectionPageSetup::OSpreadSheetConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OConnectionTabPageSetup(pParent, PAGE_DBWIZARD_SPREADSHEET, _rCoreAttrs, STR_SPREADSHEET_HELPTEXT, STR_SPREADSHEET_HEADERTEXT, STR_SPREADSHEETPATH)
+ , m_aCBPasswordrequired(this, ModuleRes(CB_SPREADSHEETPASSWORDREQUIRED))
+ {
+ DBG_CTOR(OSpreadSheetConnectionPageSetup,NULL);
+
+ m_aCBPasswordrequired.SetToggleHdl(getControlModifiedLink());
+ FreeResource();
+ }
+
+
+ // -----------------------------------------------------------------------
+ OSpreadSheetConnectionPageSetup::~OSpreadSheetConnectionPageSetup()
+ {
+
+ DBG_DTOR(OSpreadSheetConnectionPageSetup,NULL);
+ }
+
+
+ void OSpreadSheetConnectionPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+ {
+ }
+
+ // -----------------------------------------------------------------------
+ void OSpreadSheetConnectionPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OConnectionTabPageSetup::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordrequired));
+
+ }
+
+ // -----------------------------------------------------------------------
+ void OSpreadSheetConnectionPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ OConnectionTabPageSetup::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OSpreadSheetConnectionPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OConnectionTabPageSetup::FillItemSet(_rSet);
+ fillBool(_rSet,&m_aCBPasswordrequired,DSID_PASSWORDREQUIRED,bChangedSomething);
+ return bChangedSomething;
+ }
+
+ OGenericAdministrationPage* OAuthentificationPageSetup::CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OAuthentificationPageSetup( pParent, _rAttrSet) );
+ }
+
+DBG_NAME(OAuthentificationPageSetup)
+
+ OAuthentificationPageSetup::OAuthentificationPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_AUTHENTIFICATION), _rCoreAttrs )
+ , m_aFTHelpText (this, ModuleRes(FT_AUTHENTIFICATIONHELPTEXT))
+ , m_aFTHeaderText (this, ModuleRes(FT_AUTHENTIFICATIONHEADERTEXT))
+ , m_aFTUserName (this, ModuleRes(FT_GENERALUSERNAME))
+ , m_aETUserName (this, ModuleRes(ET_GENERALUSERNAME))
+ , m_aCBPasswordRequired (this, ModuleRes(CB_GENERALPASSWORDREQUIRED))
+ , m_aPBTestConnection (this, ModuleRes(PB_TESTCONNECTION))
+ {
+ DBG_CTOR(OAuthentificationPageSetup,NULL);
+
+ SetControlFontWeight(&m_aFTHeaderText);
+ m_aETUserName.SetModifyHdl(getControlModifiedLink());
+ m_aCBPasswordRequired.SetClickHdl(getControlModifiedLink());
+ m_aPBTestConnection.SetClickHdl(LINK(this,OGenericAdministrationPage,OnTestConnectionClickHdl));
+ FreeResource();
+
+ LayoutHelper::fitSizeRightAligned( m_aPBTestConnection );
+ }
+
+
+ // -----------------------------------------------------------------------
+ OAuthentificationPageSetup::~OAuthentificationPageSetup()
+ {
+
+ DBG_DTOR(OAuthentificationPageSetup,NULL);
+ }
+
+
+ void OAuthentificationPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHelpText));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTUserName));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aPBTestConnection));
+ }
+
+ // -----------------------------------------------------------------------
+ void OAuthentificationPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETUserName));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBPasswordRequired));
+ }
+
+ // -----------------------------------------------------------------------
+ void OAuthentificationPageSetup::implInitControls(const SfxItemSet& _rSet, sal_Bool /*_bSaveValue*/)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+ SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
+ SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
+
+ m_aETUserName.SetText(pUidItem->GetValue());
+ m_aCBPasswordRequired.Check(pAllowEmptyPwd->GetValue());
+
+ m_aETUserName.ClearModifyFlag();
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OAuthentificationPageSetup::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ if (m_aETUserName.GetText() != m_aETUserName.GetSavedValue())
+ {
+ _rSet.Put(SfxStringItem(DSID_USER, m_aETUserName.GetText()));
+ _rSet.Put(SfxStringItem(DSID_PASSWORD, String()));
+ bChangedSomething = sal_True;
+ }
+ fillBool(_rSet,&m_aCBPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
+ return bChangedSomething;
+ }
+
+
+ OGenericAdministrationPage* OFinalDBPageSetup::CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet)
+ {
+ return ( new OFinalDBPageSetup( pParent, _rAttrSet) );
+ }
+
+DBG_NAME(OFinalDBPageSetup)
+
+ OFinalDBPageSetup::OFinalDBPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage(pParent, ModuleRes(PAGE_DBWIZARD_FINAL), _rCoreAttrs )
+ , m_aFTFinalHeader (this, ModuleRes(FT_FINALHEADER))
+ , m_aFTFinalHelpText (this, ModuleRes(FT_FINALHELPTEXT))
+ , m_aRBRegisterDataSource (this, ModuleRes(RB_REGISTERDATASOURCE))
+ , m_aRBDontregisterDataSource (this, ModuleRes(RB_DONTREGISTERDATASOURCE))
+ , m_aFTAdditionalSettings (this, ModuleRes(FT_ADDITIONALSETTINGS))
+ , m_aCBOpenAfterwards (this, ModuleRes(CB_OPENAFTERWARDS))
+ , m_aCBStartTableWizard (this, ModuleRes(CB_STARTTABLEWIZARD))
+ , m_aFTFinalText (this, ModuleRes(FT_FINALTEXT))
+ {
+ DBG_CTOR(OFinalDBPageSetup,NULL);
+
+ String stext = m_aFTFinalHeader.GetText();
+ SetControlFontWeight(&m_aFTFinalHeader);
+ m_aCBOpenAfterwards.SetClickHdl(LINK(this, OFinalDBPageSetup, OnOpenSelected));
+ m_aCBStartTableWizard.SetClickHdl(getControlModifiedLink());
+ m_aRBRegisterDataSource.SetState(sal_True);
+ FreeResource();
+
+ sal_Int32 nUnrelatedHeight = LogicToPixel( Size( 0, UNRELATED_CONTROLS ), MAP_APPFONT ).Height();
+ sal_Int32 nRelatedHeight = LogicToPixel( Size( 0, RELATED_CONTROLS ), MAP_APPFONT ).Height();
+
+ ::std::pair<Window*,sal_Int32> pWindows[] = {
+ ::std::pair<Window*,sal_Int32>(&m_aFTFinalHelpText,nRelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aRBRegisterDataSource,nRelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aRBDontregisterDataSource,nUnrelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aFTAdditionalSettings,nRelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aCBOpenAfterwards,nRelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aCBStartTableWizard,nUnrelatedHeight)
+ ,::std::pair<Window*,sal_Int32>(&m_aFTFinalText,nUnrelatedHeight)
+ };
+
+ Point aPos(m_aFTFinalHeader.GetPosPixel());
+ Size aStart(m_aFTFinalHeader.GetSizePixel());
+ aPos.Y() += aStart.Height() + nUnrelatedHeight;
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ aPos.X() = pWindows[i].first->GetPosPixel().X();
+ Size aSize = pWindows[i].first->GetSizePixel();
+ FixedText* pText = dynamic_cast<FixedText*>(pWindows[i].first);
+ if ( pText )
+ aSize = pText->CalcMinimumSize(aSize.Width());
+ pWindows[i].first->SetPosSizePixel(aPos,aSize);
+ aPos.Y() += aSize.Height() + pWindows[i].second;
+ }
+ }
+
+
+ // -----------------------------------------------------------------------
+ OFinalDBPageSetup::~OFinalDBPageSetup()
+ {
+
+ DBG_DTOR(OFinalDBPageSetup,NULL);
+ }
+
+ sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeRegistered()
+ {
+ return m_aRBRegisterDataSource.IsChecked() && m_aRBRegisterDataSource.IsEnabled();
+ }
+
+ sal_Bool OFinalDBPageSetup::IsDatabaseDocumentToBeOpened()
+ {
+ return m_aCBOpenAfterwards.IsChecked() && m_aCBOpenAfterwards.IsEnabled();
+ }
+
+ sal_Bool OFinalDBPageSetup::IsTableWizardToBeStarted()
+ {
+ return m_aCBStartTableWizard.IsChecked() && m_aCBStartTableWizard.IsEnabled();
+ }
+
+
+ void OFinalDBPageSetup::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHeader));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalHelpText));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTAdditionalSettings));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTFinalText));
+ }
+
+ // -----------------------------------------------------------------------
+ void OFinalDBPageSetup::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBOpenAfterwards));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBStartTableWizard));
+ _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBRegisterDataSource));
+ _rControlList.push_back(new OSaveValueWrapper<RadioButton>(&m_aRBDontregisterDataSource));
+ }
+
+ // -----------------------------------------------------------------------
+ void OFinalDBPageSetup::implInitControls(const SfxItemSet& /*_rSet*/, sal_Bool /*_bSaveValue*/)
+ {
+ m_aCBOpenAfterwards.Check();
+ }
+
+ void OFinalDBPageSetup::enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation)
+ {
+ m_aCBStartTableWizard.Enable(_bSupportsTableCreation);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OFinalDBPageSetup::FillItemSet( SfxItemSet& /*_rSet*/ )
+ {
+ return sal_True;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OFinalDBPageSetup, OnOpenSelected, CheckBox*, _pBox)
+ {
+ m_aCBStartTableWizard.Enable( _pBox->IsEnabled() && _pBox->IsChecked() );
+ callModifiedHdl();
+ // outta here
+ return 0L;
+ }
+//.........................................................................
+}
+// namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
new file mode 100644
index 000000000000..00fe40ffbce1
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.hxx
@@ -0,0 +1,344 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBSETUPCONNECTIONPAGES_HXX
+#define DBAUI_DBSETUPCONNECTIONPAGES_HXX
+
+#include "ConnectionPageSetup.hxx"
+
+#include "adminpages.hxx"
+#include "admincontrols.hxx"
+#include "curledit.hxx"
+#include "TextConnectionHelper.hxx"
+
+#include <svtools/roadmapwizard.hxx>
+#include <ucbhelper/content.hxx>
+#include <vcl/field.hxx>
+
+
+//.........................................................................
+namespace dbaui
+
+{
+//.........................................................................
+
+ class IDatabaseSettingsDialog;
+
+
+ //========================================================================
+ //= OSpreadSheetConnectionPageSetup
+ //========================================================================
+ class OSpreadSheetConnectionPageSetup : public OConnectionTabPageSetup
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateSpreadSheetTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ OSpreadSheetConnectionPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs);
+
+ protected:
+ CheckBox m_aCBPasswordrequired;
+ virtual ~OSpreadSheetConnectionPageSetup();
+
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ };
+
+ //========================================================================
+ //= OTextConnectionPage
+ //========================================================================
+ class OTextConnectionPageSetup : public OConnectionTabPageSetup
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateTextTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ OTextConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ OTextConnectionHelper* m_pTextConnectionHelper;
+ private:
+
+ protected:
+ virtual ~OTextConnectionPageSetup();
+ virtual sal_Bool prepareLeave();
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ bool checkTestConnection();
+
+ private:
+ DECL_LINK(ImplGetExtensionHdl, OTextConnectionHelper*);
+ };
+
+ //========================================================================
+ //= OLDAPConnectionPageSetup
+ //========================================================================
+ class OLDAPConnectionPageSetup : public OGenericAdministrationPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateLDAPTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ OLDAPConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ virtual Link getControlModifiedLink() { return LINK(this, OLDAPConnectionPageSetup, OnEditModified); }
+
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ DECL_LINK(OnEditModified,Edit*);
+
+ private:
+ FixedText m_aFTHeaderText;
+ FixedText m_aFTHelpText;
+ FixedText m_aFTHostServer;
+ Edit m_aETHostServer;
+ FixedText m_aFTBaseDN;
+ Edit m_aETBaseDN;
+ FixedText m_aFTPortNumber;
+ NumericField m_aNFPortNumber;
+ FixedText m_aFTDefaultPortNumber;
+ CheckBox m_aCBUseSSL;
+ };
+
+ //========================================================================
+ //= MySQLNativeSetupPage
+ //========================================================================
+ class MySQLNativeSetupPage : public OGenericAdministrationPage
+ {
+ private:
+ FixedText m_aHeader;
+ FixedText m_aHelpText;
+ MySQLNativeSettings m_aMySQLSettings;
+
+ public:
+ MySQLNativeSetupPage( Window* _pParent, const SfxItemSet& _rCoreAttrs );
+
+ static OGenericAdministrationPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ protected:
+ virtual void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList );
+ virtual void fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList );
+
+ virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ virtual Link getControlModifiedLink();
+
+ private:
+ DECL_LINK( OnModified, Edit* );
+ };
+
+ //========================================================================
+ //= OGeneralSpecialJDBCConnectionPageSetup
+ //========================================================================
+ class OGeneralSpecialJDBCConnectionPageSetup : public OGenericAdministrationPage
+ {
+ public:
+ OGeneralSpecialJDBCConnectionPageSetup( Window* pParent
+ , sal_uInt16 _nResId
+ , const SfxItemSet& _rCoreAttrs
+ , sal_uInt16 _nPortId
+ , sal_uInt16 _nDefaultPortResId
+ , sal_uInt16 _nHelpTextResId
+ , sal_uInt16 _nHeaderTextResId
+ , sal_uInt16 _nDriverClassId );
+ static OGenericAdministrationPage* CreateMySQLJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ static OGenericAdministrationPage* CreateOracleJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ protected:
+ virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual Link getControlModifiedLink() { return LINK(this, OGeneralSpecialJDBCConnectionPageSetup, OnEditModified); }
+
+ DECL_LINK(OnTestJavaClickHdl,PushButton*);
+ DECL_LINK(OnEditModified,Edit*);
+ FixedText m_aFTHelpText;
+ FixedText m_aFTDatabasename;
+ Edit m_aETDatabasename;
+ FixedText m_aFTHostname;
+ Edit m_aETHostname;
+ FixedText m_aFTPortNumber;
+ FixedText m_aFTDefaultPortNumber;
+ NumericField m_aNFPortNumber;
+
+
+ FixedText m_aFTDriverClass;
+ Edit m_aETDriverClass;
+ PushButton m_aPBTestJavaDriver;
+
+ String m_sDefaultJdbcDriverName;
+ sal_uInt16 m_nPortId;
+ };
+
+
+ //========================================================================
+ //= OJDBCConnectionPageSetup
+ //========================================================================
+ class OJDBCConnectionPageSetup : public OConnectionTabPageSetup
+ {
+ public:
+ OJDBCConnectionPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateJDBCTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ protected:
+ virtual bool checkTestConnection();
+
+ virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ DECL_LINK(OnTestJavaClickHdl,PushButton*);
+ DECL_LINK(OnEditModified,Edit*);
+ FixedText m_aFTDriverClass;
+ Edit m_aETDriverClass;
+ PushButton m_aPBTestJavaDriver;
+ };
+
+
+
+ //========================================================================
+ //= OJDBCConnectionPageSetup
+ //========================================================================
+ class OMySQLIntroPageSetup : public OGenericAdministrationPage
+ {
+ public:
+ enum ConnectionType
+ {
+ VIA_ODBC,
+ VIA_JDBC,
+ VIA_NATIVE
+ };
+
+ OMySQLIntroPageSetup( Window* pParent, const SfxItemSet& _rCoreAttrs);
+
+ static OMySQLIntroPageSetup* CreateMySQLIntroTabPage( Window* _pParent, const SfxItemSet& _rAttrSet );
+ ConnectionType getMySQLMode();
+ Link maClickHdl;
+ void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
+ const Link& GetClickHdl() const { return maClickHdl; }
+ DECL_LINK(ImplClickHdl, OMySQLIntroPageSetup*);
+
+
+
+
+ protected:
+ virtual sal_Bool FillItemSet(SfxItemSet& _rSet);
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual ~OMySQLIntroPageSetup();
+
+ private:
+ RadioButton m_aRB_ODBCDatabase;
+ RadioButton m_aRB_JDBCDatabase;
+ RadioButton m_aRB_NATIVEDatabase;
+ FixedText m_aFT_ConnectionMode;
+ FixedText m_aFT_Helptext;
+ FixedText m_aFT_Headertext;
+
+ DECL_LINK(OnSetupModeSelected, RadioButton*);
+
+ };
+
+
+
+
+ //========================================================================
+ //= OAuthentificationPageSetup
+ //========================================================================
+ class OAuthentificationPageSetup : public OGenericAdministrationPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateAuthentificationTabPage( Window* pParent, const SfxItemSet& _rAttrSet );
+ OAuthentificationPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs);
+
+ protected:
+ FixedText m_aFTHelpText;
+ FixedText m_aFTHeaderText;
+ FixedText m_aFTUserName;
+ Edit m_aETUserName;
+ CheckBox m_aCBPasswordRequired;
+ PushButton m_aPBTestConnection;
+ virtual ~OAuthentificationPageSetup();
+
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ };
+
+
+
+ //========================================================================
+ //= OFinalDBPageSetup
+ //========================================================================
+ class OFinalDBPageSetup : public OGenericAdministrationPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+ static OGenericAdministrationPage* CreateFinalDBTabPageSetup( Window* pParent, const SfxItemSet& _rAttrSet);
+
+ FixedText m_aFTFinalHeader;
+ FixedText m_aFTFinalHelpText;
+ RadioButton m_aRBRegisterDataSource;
+ RadioButton m_aRBDontregisterDataSource;
+ FixedText m_aFTAdditionalSettings;
+ CheckBox m_aCBOpenAfterwards;
+ CheckBox m_aCBStartTableWizard;
+ FixedText m_aFTFinalText;
+
+ OFinalDBPageSetup(Window* pParent, const SfxItemSet& _rCoreAttrs);
+ sal_Bool IsDatabaseDocumentToBeRegistered();
+ sal_Bool IsDatabaseDocumentToBeOpened();
+ sal_Bool IsTableWizardToBeStarted();
+ void enableTableWizardCheckBox( sal_Bool _bSupportsTableCreation);
+
+ /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
+ Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
+
+ DECL_LINK(OnOpenSelected, CheckBox*);
+ protected:
+ virtual ~OFinalDBPageSetup();
+
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
new file mode 100644
index 000000000000..968fc0127157
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx
@@ -0,0 +1,1222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "DbAdminImpl.hxx"
+#include "dsmeta.hxx"
+
+#include <svl/poolitem.hxx>
+#include <svl/itempool.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include "DriverSettings.hxx"
+#include "IItemSetHelper.hxx"
+#include "UITools.hxx"
+#include "dbu_dlg.hrc"
+#include "dbustrings.hrc"
+#include "dsitems.hxx"
+#include "dsnItem.hxx"
+#include "moduledbu.hxx"
+#include "optionalboolitem.hxx"
+#include "propertysetitem.hxx"
+#include "stringlistitem.hxx"
+#include "OAuthenticationContinuation.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp>
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/interaction.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/guarding.hxx>
+#include <connectivity/DriversConfig.hxx>
+#include <connectivity/dbexception.hxx>
+#include <osl/file.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/itempool.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <typelib/typedescription.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/waitobj.hxx>
+#include <osl/mutex.hxx>
+
+#include <algorithm>
+#include <functional>
+#include <o3tl/compat_functional.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::dbtools;
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::task;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::util;
+using namespace com::sun::star::container;
+using namespace com::sun::star::frame;
+
+//-------------------------------------------------------------------------
+namespace
+{
+ sal_Bool implCheckItemType( SfxItemSet& _rSet, const sal_uInt16 _nId, const TypeId _nExpectedItemType )
+ {
+ sal_Bool bCorrectType = sal_False;
+
+ SfxItemPool* pPool = _rSet.GetPool();
+ OSL_ENSURE( pPool, "implCheckItemType: invalid item pool!" );
+ if ( pPool )
+ {
+ const SfxPoolItem& rDefItem = pPool->GetDefaultItem( _nId );
+ bCorrectType = rDefItem.IsA( _nExpectedItemType );
+ }
+ return bCorrectType;
+ }
+
+ void lcl_putProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const Any& _rValue)
+ {
+ try
+ {
+ if ( _rxSet.is() )
+ _rxSet->setPropertyValue(_rName, _rValue);
+ }
+ catch(Exception&)
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage("ODbAdminDialog::implTranslateProperty: could not set the property ");
+ sMessage += ::rtl::OString(_rName.getStr(), _rName.getLength(), RTL_TEXTENCODING_ASCII_US);
+ sMessage += ::rtl::OString("!");
+ OSL_FAIL(sMessage.getStr());
+ #endif
+ }
+
+ }
+
+ String lcl_createHostWithPort(const SfxStringItem* _pHostName,const SfxInt32Item* _pPortNumber)
+ {
+ String sNewUrl;
+
+ if ( _pHostName && _pHostName->GetValue().Len() )
+ sNewUrl = _pHostName->GetValue();
+
+ if ( _pPortNumber )
+ {
+ sNewUrl += String::CreateFromAscii(":");
+ sNewUrl += String::CreateFromInt32(_pPortNumber->GetValue());
+ }
+
+ return sNewUrl;
+ }
+}
+
+ //========================================================================
+ //= ODbDataSourceAdministrationHelper
+ //========================================================================
+ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper(const Reference< XMultiServiceFactory >& _xORB,Window* _pParent,IItemSetHelper* _pItemSetHelper)
+ : m_xORB(_xORB)
+ , m_pParent(_pParent)
+ , m_pItemSetHelper(_pItemSetHelper)
+{
+ /// initialize the property translation map
+ // direct properties of a data source
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_CONNECTURL, PROPERTY_URL));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_NAME, PROPERTY_NAME));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_USER, PROPERTY_USER));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORD, PROPERTY_PASSWORD));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_PASSWORDREQUIRED, PROPERTY_ISPASSWORDREQUIRED));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_TABLEFILTER, PROPERTY_TABLEFILTER));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_READONLY, PROPERTY_ISREADONLY));
+ m_aDirectPropTranslator.insert(MapInt2String::value_type(DSID_SUPPRESSVERSIONCL, PROPERTY_SUPPRESSVERSIONCL));
+
+ // implicit properties, to be found in the direct property "Info"
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_JDBCDRIVERCLASS, INFO_JDBCDRIVERCLASS));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEEXTENSION, INFO_TEXTFILEEXTENSION));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHARSET, INFO_CHARSET));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTFILEHEADER, INFO_TEXTFILEHEADER));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_FIELDDELIMITER, INFO_FIELDDELIMITER));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_TEXTDELIMITER, INFO_TEXTDELIMITER));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DECIMALDELIMITER, INFO_DECIMALDELIMITER));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_THOUSANDSDELIMITER, INFO_THOUSANDSDELIMITER));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SHOWDELETEDROWS, INFO_SHOWDELETEDROWS));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ALLOWLONGTABLENAMES, INFO_ALLOWLONGTABLENAMES));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ADDITIONALOPTIONS, INFO_ADDITIONALOPTIONS));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SQL92CHECK, PROPERTY_ENABLESQL92CHECK));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTOINCREMENTVALUE, PROPERTY_AUTOINCREMENTCREATION));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEVALUE, INFO_AUTORETRIEVEVALUE));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AUTORETRIEVEENABLED, INFO_AUTORETRIEVEENABLED));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_APPEND_TABLE_ALIAS, INFO_APPEND_TABLE_ALIAS));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_AS_BEFORE_CORRNAME, INFO_AS_BEFORE_CORRELATION_NAME ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CHECK_REQUIRED_FIELDS, INFO_FORMS_CHECK_REQUIRED_FIELDS ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ESCAPE_DATETIME, INFO_ESCAPE_DATETIME ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PRIMARY_KEY_SUPPORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrimaryKeySupport" ) ) ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_PARAMETERNAMESUBST, INFO_PARAMETERNAMESUBST));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_IGNOREDRIVER_PRIV, INFO_IGNOREDRIVER_PRIV));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_BOOLEANCOMPARISON, PROPERTY_BOOLEANCOMPARISONMODE));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_ENABLEOUTERJOIN, PROPERTY_ENABLEOUTERJOIN));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CATALOG, PROPERTY_USECATALOGINSELECT));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_SCHEMA, PROPERTY_USESCHEMAINSELECT));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_INDEXAPPENDIX, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AddIndexAppendix"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DOSLINEENDS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreferDosLikeLineEnds" ) ) ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_SOCKET, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalSocket" ) ) ) );
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_NAMED_PIPE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NamedPipe" ) ) ) );
+
+ // special settings for adabas
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_SHUTSERVICE, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_DATAINC, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CACHESIZE, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLUSER, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_CTRLPWD, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))));
+
+ // extra settings for odbc
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_USECATALOG, INFO_USECATALOG));
+ // extra settings for a ldap address book
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_BASEDN, INFO_CONN_LDAP_BASEDN));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_ROWCOUNT, INFO_CONN_LDAP_ROWCOUNT));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_CONN_LDAP_USESSL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL"))));
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_DOCUMENT_URL, PROPERTY_URL));
+
+ // oracle
+ m_aIndirectPropTranslator.insert(MapInt2String::value_type(DSID_IGNORECURRENCY, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency"))));
+
+ try
+ {
+ m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ m_xDynamicContext.set(m_xDatabaseContext,UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ }
+
+ if ( !m_xDatabaseContext.is() )
+ {
+ ShowServiceNotAvailableError(_pParent->GetParent(), String(SERVICE_SDB_DATABASECONTEXT), sal_True);
+ }
+
+ OSL_ENSURE(m_xDynamicContext.is(), "ODbAdminDialog::ODbAdminDialog : no XNamingService interface !");
+}
+ //-------------------------------------------------------------------------
+sal_Bool ODbDataSourceAdministrationHelper::getCurrentSettings(Sequence< PropertyValue >& _rDriverParam)
+{
+ OSL_ENSURE(m_pItemSetHelper->getOutputSet(), "ODbDataSourceAdministrationHelper::getCurrentSettings : not to be called without an example set!");
+ if (!m_pItemSetHelper->getOutputSet())
+ return sal_False;
+
+ ::std::vector< PropertyValue > aReturn;
+ // collecting this in a vector because it has a push_back, in opposite to sequences
+
+ // user: DSID_USER -> "user"
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pUser, SfxStringItem, DSID_USER, sal_True);
+ if (pUser && pUser->GetValue().Len())
+ aReturn.push_back(
+ PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), 0,
+ makeAny(::rtl::OUString(pUser->GetValue())), PropertyState_DIRECT_VALUE));
+
+ // check if the connection type requires a password
+ if (hasAuthentication(*m_pItemSetHelper->getOutputSet()))
+ {
+ // password: DSID_PASSWORD -> "password"
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True);
+ String sPassword = pPassword ? pPassword->GetValue() : String();
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPasswordRequired, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
+ // if the set does not contain a password, but the item set says it requires one, ask the user
+ if ((!pPassword || !pPassword->GetValue().Len()) && (pPasswordRequired && pPasswordRequired->GetValue()))
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pName, SfxStringItem, DSID_NAME, sal_True);
+
+ Reference< XModel > xModel( getDataSourceOrModel( m_xDatasource ), UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+
+ if ( !xHandler.is() )
+ {
+ // instantiate the default SDB interaction handler
+ xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( !xHandler.is() )
+ ShowServiceNotAvailableError(m_pParent->GetParent(), String(SERVICE_TASK_INTERACTION_HANDLER), sal_True);
+ }
+
+ String sName = pName ? pName->GetValue() : String();
+ String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD));
+ ::rtl::OUString sTemp = sName;
+ sName = ::dbaui::getStrippedDatabaseName(NULL,sTemp);
+ if ( sName.Len() )
+ sLoginRequest.SearchAndReplaceAscii("$name$", sName);
+ else
+ {
+ sLoginRequest.SearchAndReplaceAscii("\"$name$\"", String());
+ sLoginRequest.SearchAndReplaceAscii("$name$", String()); // just to be sure that in other languages the string will be deleted
+ }
+
+ // the request
+ AuthenticationRequest aRequest;
+ aRequest.ServerName = sName;
+ aRequest.Diagnostic = sLoginRequest;
+ aRequest.HasRealm = aRequest.HasAccount = sal_False;
+ // aRequest.Realm
+ aRequest.HasUserName = pUser != 0;
+ aRequest.UserName = pUser ? rtl::OUString(pUser->GetValue()) : ::rtl::OUString();
+ aRequest.HasPassword = sal_True;
+ //aRequest.Password
+ aRequest.HasAccount = sal_False;
+ // aRequest.Account
+
+ comphelper::OInteractionRequest* pRequest = new comphelper::OInteractionRequest(makeAny(aRequest));
+ uno::Reference< XInteractionRequest > xRequest(pRequest);
+
+ // build an interaction request
+ // two continuations (Ok and Cancel)
+ ::rtl::Reference< comphelper::OInteractionAbort > pAbort = new comphelper::OInteractionAbort;
+ ::rtl::Reference< dbaccess::OAuthenticationContinuation > pAuthenticate = new dbaccess::OAuthenticationContinuation;
+ pAuthenticate->setCanChangeUserName( sal_False );
+ pAuthenticate->setRememberPassword( RememberAuthentication_SESSION );
+
+ // some knittings
+ pRequest->addContinuation(pAbort.get());
+ pRequest->addContinuation(pAuthenticate.get());
+
+ // handle the request
+ try
+ {
+ SolarMutexGuard aSolarGuard;
+ // release the mutex when calling the handler, it may need to lock the SolarMutex
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ if (!pAuthenticate->wasSelected())
+ return sal_False;
+
+ sPassword = pAuthenticate->getPassword();
+ if (pAuthenticate->getRememberPassword())
+ m_pItemSetHelper->getWriteOutputSet()->Put(SfxStringItem(DSID_PASSWORD, sPassword));
+ }
+
+ if (sPassword.Len())
+ aReturn.push_back(
+ PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("password")), 0,
+ makeAny(::rtl::OUString(sPassword)), PropertyState_DIRECT_VALUE));
+ }
+
+ if ( !aReturn.empty() )
+ _rDriverParam = Sequence< PropertyValue >(&(*aReturn.begin()), aReturn.size());
+
+ // append all the other stuff (charset etc.)
+ fillDatasourceInfo(*m_pItemSetHelper->getOutputSet(), _rDriverParam);
+
+ return sal_True;
+}
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::successfullyConnected()
+{
+ OSL_ENSURE(m_pItemSetHelper->getOutputSet(), "ODbDataSourceAdministrationHelper::successfullyConnected: not to be called without an example set!");
+ if (!m_pItemSetHelper->getOutputSet())
+ return;
+
+ if (hasAuthentication(*m_pItemSetHelper->getOutputSet()))
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPassword, SfxStringItem, DSID_PASSWORD, sal_True);
+ if (pPassword && (0 != pPassword->GetValue().Len()))
+ {
+ ::rtl::OUString sPassword = pPassword->GetValue();
+
+ Reference< XPropertySet > xCurrentDatasource = getCurrentDataSource();
+ lcl_putProperty(xCurrentDatasource,m_aDirectPropTranslator[DSID_PASSWORD], makeAny(sPassword));
+ }
+ }
+}
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::clearPassword()
+{
+ if (m_pItemSetHelper->getWriteOutputSet())
+ m_pItemSetHelper->getWriteOutputSet()->ClearItem(DSID_PASSWORD);
+}
+// -----------------------------------------------------------------------------
+::std::pair< Reference<XConnection>,sal_Bool> ODbDataSourceAdministrationHelper::createConnection()
+{
+ ::std::pair< Reference<XConnection>,sal_Bool> aRet;
+ aRet.second = sal_False;
+ Sequence< PropertyValue > aConnectionParams;
+ if ( getCurrentSettings(aConnectionParams) )
+ {
+ // the current DSN
+ // fill the table list with this connection information
+ SQLExceptionInfo aErrorInfo;
+ try
+ {
+ WaitObject aWaitCursor(m_pParent);
+ aRet.first = getDriver()->connect(getConnectionURL(), aConnectionParams);
+ aRet.second = sal_True;
+ }
+ catch (SQLContext& e) { aErrorInfo = SQLExceptionInfo(e); }
+ catch (SQLWarning& e) { aErrorInfo = SQLExceptionInfo(e); }
+ catch (SQLException& e) { aErrorInfo = SQLExceptionInfo(e); }
+
+ showError(aErrorInfo,m_pParent,getORB());
+ }
+ if ( aRet.first.is() )
+ successfullyConnected();// notify the admindlg to save the password
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver()
+{
+ return getDriver(getConnectionURL());
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > ODbDataSourceAdministrationHelper::getDriver(const ::rtl::OUString& _sURL)
+{
+ // get the global DriverManager
+ Reference< XDriverAccess > xDriverManager;
+ String sCurrentActionError = String(ModuleRes(STR_COULDNOTCREATE_DRIVERMANAGER));
+ // in case an error occures
+ sCurrentActionError.SearchAndReplaceAscii("#servicename#", (::rtl::OUString)SERVICE_SDBC_CONNECTIONPOOL);
+ try
+ {
+ xDriverManager = Reference< XDriverAccess >(getORB()->createInstance(SERVICE_SDBC_CONNECTIONPOOL), UNO_QUERY);
+ OSL_ENSURE(xDriverManager.is(), "ODbDataSourceAdministrationHelper::getDriver: could not instantiate the driver manager, or it does not provide the necessary interface!");
+ }
+ catch (Exception& e)
+ {
+ // wrap the exception into an SQLException
+ SQLException aSQLWrapper(e.Message, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
+ throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, makeAny(aSQLWrapper));
+ }
+ if (!xDriverManager.is())
+ throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
+
+
+ Reference< XDriver > xDriver = xDriverManager->getDriverByURL(_sURL);
+ if (!xDriver.is())
+ {
+ sCurrentActionError = String(ModuleRes(STR_NOREGISTEREDDRIVER));
+ sCurrentActionError.SearchAndReplaceAscii("#connurl#", _sURL);
+ // will be caught and translated into an SQLContext exception
+ throw SQLException(sCurrentActionError, getORB(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")), 0, Any());
+ }
+ return xDriver;
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > ODbDataSourceAdministrationHelper::getCurrentDataSource()
+{
+ if ( !m_xDatasource.is() )
+ {
+ Reference<XInterface> xIn(m_aDataSourceOrName,UNO_QUERY);
+ if ( !xIn.is() )
+ {
+ ::rtl::OUString sCurrentDatasource;
+ m_aDataSourceOrName >>= sCurrentDatasource;
+ OSL_ENSURE(sCurrentDatasource.getLength(),"No datasource name given!");
+ try
+ {
+ if ( m_xDatabaseContext.is() )
+ m_xDatasource.set(m_xDatabaseContext->getByName(sCurrentDatasource),UNO_QUERY);
+ xIn = m_xDatasource;
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ m_xModel.set(getDataSourceOrModel(xIn),UNO_QUERY);
+ if ( m_xModel.is() )
+ m_xDatasource.set(xIn,UNO_QUERY);
+ else
+ {
+ m_xDatasource.set(getDataSourceOrModel(xIn),UNO_QUERY);
+ m_xModel.set(xIn,UNO_QUERY);
+ }
+ }
+
+
+ OSL_ENSURE(m_xDatasource.is(), "ODbDataSourceAdministrationHelper::getCurrentDataSource: no data source!");
+ return m_xDatasource;
+}
+//-------------------------------------------------------------------------
+::rtl::OUString ODbDataSourceAdministrationHelper::getDatasourceType( const SfxItemSet& _rSet )
+{
+ SFX_ITEMSET_GET( _rSet, pConnectURL, SfxStringItem, DSID_CONNECTURL, sal_True );
+ OSL_ENSURE( pConnectURL , "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!" );
+ SFX_ITEMSET_GET(_rSet, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+ OSL_ENSURE(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!");
+ ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
+ return pCollection->getType(pConnectURL->GetValue());
+}
+
+//-------------------------------------------------------------------------
+sal_Bool ODbDataSourceAdministrationHelper::hasAuthentication(const SfxItemSet& _rSet) const
+{
+ return DataSourceMetaData::getAuthentication( getDatasourceType( _rSet ) ) != AuthNone;
+}
+// -----------------------------------------------------------------------------
+String ODbDataSourceAdministrationHelper::getConnectionURL() const
+{
+ String sNewUrl;
+
+ ::rtl::OUString eType = getDatasourceType(*m_pItemSetHelper->getOutputSet());
+
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+
+ OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!");
+ OSL_ENSURE(pTypeCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid items in the source set!");
+ ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
+ OSL_ENSURE(pCollection, "ODbDataSourceAdministrationHelper::getDatasourceType: invalid type collection!");
+
+ switch( pCollection->determineType(eType) )
+ {
+ case ::dbaccess::DST_DBASE:
+ case ::dbaccess::DST_FLAT:
+ case ::dbaccess::DST_CALC:
+ break;
+ case ::dbaccess::DST_ADABAS:
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ sNewUrl = lcl_createHostWithPort(pHostName,NULL);
+ String sUrl = pCollection->cutPrefix(pUrlItem->GetValue());
+ if ( sUrl.GetTokenCount(':') == 1 )
+ sNewUrl += String::CreateFromAscii(":");
+
+ sNewUrl += sUrl;
+ }
+ break;
+ case ::dbaccess::DST_MSACCESS:
+ case ::dbaccess::DST_MSACCESS_2007:
+ {
+ ::rtl::OUString sFileName = pCollection->cutPrefix(pUrlItem->GetValue());
+ ::rtl::OUString sNewFileName;
+ if ( ::osl::FileBase::getSystemPathFromFileURL( sFileName, sNewFileName ) == ::osl::FileBase::E_None )
+ {
+ sNewUrl += String(sNewFileName);
+ }
+ }
+ break;
+ case ::dbaccess::DST_MYSQL_NATIVE:
+ case ::dbaccess::DST_MYSQL_JDBC:
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_MYSQL_PORTNUMBER, sal_True);
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True);
+ sNewUrl = lcl_createHostWithPort(pHostName,pPortNumber);
+ String sDatabaseName = pDatabaseName ? pDatabaseName->GetValue() : String();
+ if ( !sDatabaseName.Len() && pUrlItem )
+ sDatabaseName = pCollection->cutPrefix( pUrlItem->GetValue() );
+ // TODO: what's that? Why is the database name transported via the URL Item?
+ // Huh? Anybody there?
+ // OJ: It is needed when the connection properties are changed. There the URL is used for every type.
+
+ if ( sDatabaseName.Len() )
+ {
+ sNewUrl += String::CreateFromAscii("/");
+ sNewUrl += sDatabaseName;
+ }
+ }
+ break;
+ case ::dbaccess::DST_ORACLE_JDBC:
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_ORACLE_PORTNUMBER, sal_True);
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True);
+ if ( pHostName && pHostName->GetValue().Len() )
+ {
+ sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("@"));
+ sNewUrl += lcl_createHostWithPort(pHostName,pPortNumber);
+ String sDatabaseName = pDatabaseName ? pDatabaseName->GetValue() : String();
+ if ( !sDatabaseName.Len() && pUrlItem )
+ sDatabaseName = pCollection->cutPrefix( pUrlItem->GetValue() );
+ if ( sDatabaseName.Len() )
+ {
+ sNewUrl += String::CreateFromAscii(":");
+ sNewUrl += sDatabaseName;
+ }
+ }
+ else
+ { // here someone entered a JDBC url which looks like oracle, so we have to use the url property
+
+ }
+ }
+ break;
+ case ::dbaccess::DST_LDAP:
+ {
+ SFX_ITEMSET_GET(*m_pItemSetHelper->getOutputSet(), pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
+ sNewUrl = pCollection->cutPrefix(pUrlItem->GetValue());
+ sNewUrl += lcl_createHostWithPort(NULL,pPortNumber);
+ }
+ break;
+ case ::dbaccess::DST_JDBC:
+ // run through
+ default:
+ break;
+ }
+ if ( sNewUrl.Len() )
+ {
+ String sUrl = pCollection->getPrefix(eType);
+ sUrl += sNewUrl;
+ sNewUrl = sUrl;
+ }
+ else
+ sNewUrl = pUrlItem->GetValue();
+
+ return sNewUrl;
+}
+//-------------------------------------------------------------------------
+struct PropertyValueLess
+{
+ bool operator() (const PropertyValue& x, const PropertyValue& y) const
+ { return x.Name < y.Name ? true : false; } // construct prevents a MSVC6 warning
+};
+DECLARE_STL_SET( PropertyValue, PropertyValueLess, PropertyValueSet);
+
+//........................................................................
+void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPropertySet >& _rxSource, SfxItemSet& _rDest)
+{
+ ::rtl::OUString sNewConnectURL, sName, sUid, sPwd;
+ Sequence< ::rtl::OUString > aTableFitler;
+
+ if (_rxSource.is())
+ {
+ for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
+ aDirect != m_aDirectPropTranslator.end();
+ ++aDirect
+ )
+ {
+ // get the property value
+ Any aValue;
+ try
+ {
+ aValue = _rxSource->getPropertyValue(aDirect->second);
+ }
+ catch(Exception&)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString aMessage("ODbDataSourceAdministrationHelper::translateProperties: could not extract the property ");
+ aMessage += ::rtl::OString(aDirect->second.getStr(), aDirect->second.getLength(), RTL_TEXTENCODING_ASCII_US);
+ aMessage += ::rtl::OString("!");
+ OSL_FAIL(aMessage.getStr());
+#endif
+ }
+ // transfer it into an item
+ implTranslateProperty(_rDest, aDirect->first, aValue);
+ }
+
+ // get the additional informations
+ Sequence< PropertyValue > aAdditionalInfo;
+ try
+ {
+ _rxSource->getPropertyValue(PROPERTY_INFO) >>= aAdditionalInfo;
+ }
+ catch(Exception&) { }
+
+ // collect the names of the additional settings
+ const PropertyValue* pAdditionalInfo = aAdditionalInfo.getConstArray();
+ PropertyValueSet aInfos;
+ for (sal_Int32 i=0; i<aAdditionalInfo.getLength(); ++i, ++pAdditionalInfo)
+ {
+ if (0 == pAdditionalInfo->Name.compareToAscii("JDBCDRV"))
+ { // compatibility
+ PropertyValue aCompatibility(*pAdditionalInfo);
+ aCompatibility.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"));
+ aInfos.insert(aCompatibility);
+ }
+ else
+ aInfos.insert(*pAdditionalInfo);
+ }
+
+ // go through all known translations and check if we have such a setting
+ if ( !aInfos.empty() )
+ {
+ PropertyValue aSearchFor;
+ ConstMapInt2StringIterator aEnd = m_aIndirectPropTranslator.end();
+ for ( ConstMapInt2StringIterator aIndirect = m_aIndirectPropTranslator.begin();
+ aIndirect != aEnd;
+ ++aIndirect)
+ {
+ aSearchFor.Name = aIndirect->second;
+ ConstPropertyValueSetIterator aInfoPos = aInfos.find(aSearchFor);
+ if (aInfos.end() != aInfoPos)
+ // the property is contained in the info sequence
+ // -> transfer it into an item
+ implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value);
+ }
+ }
+
+ convertUrl(_rDest);
+ }
+
+ try
+ {
+ _rDest.Put(OPropertySetItem(DSID_DATASOURCE_UNO, _rxSource));
+ Reference<XStorable> xStore(getDataSourceOrModel(_rxSource),UNO_QUERY);
+ _rDest.Put(SfxBoolItem(DSID_READONLY, !xStore.is() || xStore->isReadonly() ));
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("IsReadOnly throws an exception!");
+ }
+}
+
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::translateProperties(const SfxItemSet& _rSource, const Reference< XPropertySet >& _rxDest)
+{
+ OSL_ENSURE(_rxDest.is(), "ODbDataSourceAdministrationHelper::translateProperties: invalid property set!");
+ if (!_rxDest.is())
+ return;
+
+ // the property set info
+ Reference< XPropertySetInfo > xInfo;
+ try { xInfo = _rxDest->getPropertySetInfo(); }
+ catch(Exception&) { }
+
+ const ::rtl::OUString sUrlProp(RTL_CONSTASCII_USTRINGPARAM("URL"));
+ // -----------------------------
+ // transfer the direct properties
+ for ( ConstMapInt2StringIterator aDirect = m_aDirectPropTranslator.begin();
+ aDirect != m_aDirectPropTranslator.end();
+ ++aDirect
+ )
+ {
+ const SfxPoolItem* pCurrentItem = _rSource.GetItem((sal_uInt16)aDirect->first);
+ if (pCurrentItem)
+ {
+ sal_Int16 nAttributes = PropertyAttribute::READONLY;
+ if (xInfo.is())
+ {
+ try { nAttributes = xInfo->getPropertyByName(aDirect->second).Attributes; }
+ catch(Exception&) { }
+ }
+ if ((nAttributes & PropertyAttribute::READONLY) == 0)
+ {
+ if ( sUrlProp == aDirect->second )
+ {
+ Any aValue(makeAny(::rtl::OUString(getConnectionURL())));
+ // aValue <<= ::rtl::OUString();
+ lcl_putProperty(_rxDest, aDirect->second,aValue);
+ }
+ else
+ implTranslateProperty(_rxDest, aDirect->second, pCurrentItem);
+ }
+ }
+ }
+
+ // -------------------------------
+ // now for the indirect properties
+
+ Sequence< PropertyValue > aInfo;
+ // the original properties
+ try
+ {
+ _rxDest->getPropertyValue(PROPERTY_INFO) >>= aInfo;
+ }
+ catch(Exception&) { }
+
+ // overwrite and extend them
+ fillDatasourceInfo(_rSource, aInfo);
+ // and propagate the (newly composed) sequence to the set
+ lcl_putProperty(_rxDest,PROPERTY_INFO, makeAny(aInfo));
+}
+
+
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rSource, Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo)
+{
+ // within the current "Info" sequence, replace the ones we can examine from the item set
+ // (we don't just fill a completely new sequence with our own items, but we preserve any properties unknown to
+ // us)
+
+ // first determine which of all the items are relevant for the data source (depends on the connection url)
+ ::rtl::OUString eType = getDatasourceType(_rSource);
+ ::std::vector< sal_Int32> aDetailIds;
+ ODriversSettings::getSupportedIndirectSettings(eType,getORB(),aDetailIds);
+
+ // collect the translated property values for the relevant items
+ PropertyValueSet aRelevantSettings;
+ ConstMapInt2StringIterator aTranslation;
+ ::std::vector< sal_Int32>::iterator aDetailsEnd = aDetailIds.end();
+ for (::std::vector< sal_Int32>::iterator aIter = aDetailIds.begin();aIter != aDetailsEnd ; ++aIter)
+ {
+ const SfxPoolItem* pCurrent = _rSource.GetItem((sal_uInt16)*aIter);
+ aTranslation = m_aIndirectPropTranslator.find(*aIter);
+ if ( pCurrent && (m_aIndirectPropTranslator.end() != aTranslation) )
+ {
+ if ( aTranslation->second == INFO_CHARSET )
+ {
+ ::rtl::OUString sCharSet;
+ implTranslateProperty(pCurrent) >>= sCharSet;
+ if ( sCharSet.getLength() )
+ aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, makeAny(sCharSet), PropertyState_DIRECT_VALUE));
+ }
+ else
+ aRelevantSettings.insert(PropertyValue(aTranslation->second, 0, implTranslateProperty(pCurrent), PropertyState_DIRECT_VALUE));
+ }
+ }
+
+ // settings to preserve
+ MapInt2String aPreservedSettings;
+
+ // now aRelevantSettings contains all the property values relevant for the current data source type,
+ // check the original sequence if it already contains any of these values (which have to be overwritten, then)
+ PropertyValue* pInfo = _rInfo.getArray();
+ PropertyValue aSearchFor;
+ sal_Int32 nObsoleteSetting = -1;
+ sal_Int32 nCount = _rInfo.getLength();
+ for (sal_Int32 i = 0; i < nCount; ++i, ++pInfo)
+ {
+ aSearchFor.Name = pInfo->Name;
+ PropertyValueSetIterator aOverwrittenSetting = aRelevantSettings.find(aSearchFor);
+ if (aRelevantSettings.end() != aOverwrittenSetting)
+ { // the setting was present in the original sequence, and it is to be overwritten -> replace it
+ if ( !::comphelper::compare(pInfo->Value,aOverwrittenSetting->Value) )
+ *pInfo = *aOverwrittenSetting;
+ aRelevantSettings.erase(aOverwrittenSetting);
+ }
+ else if (0 == pInfo->Name.compareToAscii("JDBCDRV"))
+ { // this is a compatibility setting, remove it from the sequence (it's replaced by JavaDriverClass)
+ nObsoleteSetting = i;
+ }
+ else
+ aPreservedSettings[i] = pInfo->Name;
+ }
+ if (-1 != nObsoleteSetting)
+ ::comphelper::removeElementAt(_rInfo, nObsoleteSetting);
+
+ if ( !aPreservedSettings.empty() )
+ { // check if there are settings which
+ // * are known as indirect properties
+ // * but not relevant for the current data source type
+ // These settings have to be removed: If they're not relevant, we have no UI for changing them.
+
+ // for this, we need a string-controlled quick access to m_aIndirectPropTranslator
+ StringSet aIndirectProps;
+ ::std::transform(m_aIndirectPropTranslator.begin(),
+ m_aIndirectPropTranslator.end(),
+ ::std::insert_iterator<StringSet>(aIndirectProps,aIndirectProps.begin()),
+ ::o3tl::select2nd<MapInt2String::value_type>());
+
+ // now check the to-be-preserved props
+ ::std::vector< sal_Int32 > aRemoveIndexes;
+ sal_Int32 nPositionCorrector = 0;
+ ConstMapInt2StringIterator aPreservedEnd = aPreservedSettings.end();
+ for ( ConstMapInt2StringIterator aPreserved = aPreservedSettings.begin();
+ aPreserved != aPreservedEnd;
+ ++aPreserved
+ )
+ {
+ if (aIndirectProps.end() != aIndirectProps.find(aPreserved->second))
+ {
+#if OSL_DEBUG_LEVEL > 0
+ const ::rtl::OUString sName = aPreserved->second;
+#endif
+ aRemoveIndexes.push_back(aPreserved->first - nPositionCorrector);
+ ++nPositionCorrector;
+ }
+ }
+ // now finally remove all such props
+ ::std::vector< sal_Int32 >::const_iterator aRemoveEnd = aRemoveIndexes.end();
+ for ( ::std::vector< sal_Int32 >::const_iterator aRemoveIndex = aRemoveIndexes.begin();
+ aRemoveIndex != aRemoveEnd;
+ ++aRemoveIndex
+ )
+ ::comphelper::removeElementAt(_rInfo, *aRemoveIndex);
+#if OSL_DEBUG_LEVEL > 0
+ const PropertyValue* pWhatsLeft = _rInfo.getConstArray();
+ const PropertyValue* pWhatsLeftEnd = pWhatsLeft + _rInfo.getLength();
+ for (; pWhatsLeft != pWhatsLeftEnd; ++pWhatsLeft)
+ {
+ ::rtl::OUString sLookAtIt = pWhatsLeft->Name;
+ }
+#endif
+ }
+
+ ::connectivity::DriversConfig aDriverConfig(getORB());
+ const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(eType);
+ Sequence< Any> aTypeSettings;
+ aTypeSettings = aProperties.getOrDefault("TypeInfoSettings",aTypeSettings);
+ // here we have a special entry for types from oracle
+ if ( aTypeSettings.getLength() )
+ {
+ aRelevantSettings.insert(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")), 0, makeAny(aTypeSettings), PropertyState_DIRECT_VALUE));
+ }
+
+ // check which values are still left ('cause they were not present in the original sequence, but are to be set)
+ if ( !aRelevantSettings.empty() )
+ {
+ sal_Int32 nOldLength = _rInfo.getLength();
+ _rInfo.realloc(nOldLength + aRelevantSettings.size());
+ PropertyValue* pAppendValues = _rInfo.getArray() + nOldLength;
+ ConstPropertyValueSetIterator aRelevantEnd = aRelevantSettings.end();
+ for ( ConstPropertyValueSetIterator aLoop = aRelevantSettings.begin();
+ aLoop != aRelevantEnd;
+ ++aLoop, ++pAppendValues
+ )
+ {
+ if ( aLoop->Name == INFO_CHARSET )
+ {
+ ::rtl::OUString sCharSet;
+ aLoop->Value >>= sCharSet;
+ if ( sCharSet.getLength() )
+ *pAppendValues = *aLoop;
+ }
+ else
+ *pAppendValues = *aLoop;
+ }
+ }
+}
+//-------------------------------------------------------------------------
+Any ODbDataSourceAdministrationHelper::implTranslateProperty(const SfxPoolItem* _pItem)
+{
+ // translate the SfxPoolItem
+ Any aValue;
+
+ const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, _pItem );
+ const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, _pItem );
+ const OptionalBoolItem* pOptBoolItem = PTR_CAST( OptionalBoolItem, _pItem );
+ const SfxInt32Item* pInt32Item = PTR_CAST( SfxInt32Item, _pItem );
+ const OStringListItem* pStringListItem = PTR_CAST( OStringListItem, _pItem );
+
+ if ( pStringItem )
+ {
+ aValue <<= ::rtl::OUString( pStringItem->GetValue().GetBuffer() );
+ }
+ else if ( pBoolItem )
+ {
+ aValue <<= pBoolItem->GetValue();
+ }
+ else if ( pOptBoolItem )
+ {
+ if ( !pOptBoolItem->HasValue() )
+ aValue.clear();
+ else
+ aValue <<= (sal_Bool)pOptBoolItem->GetValue();
+ }
+ else if ( pInt32Item )
+ {
+ aValue <<= pInt32Item->GetValue();
+ }
+ else if ( pStringListItem )
+ {
+ aValue <<= pStringListItem->getList();
+ }
+ else
+ {
+ OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported item type!");
+ return aValue;
+ }
+
+ return aValue;
+}
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::implTranslateProperty(const Reference< XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem)
+{
+ Any aValue = implTranslateProperty(_pItem);
+ lcl_putProperty(_rxSet, _rName,aValue);
+}
+
+#if OSL_DEBUG_LEVEL > 0
+//-------------------------------------------------------------------------
+::rtl::OString ODbDataSourceAdministrationHelper::translatePropertyId( sal_Int32 _nId )
+{
+ ::rtl::OUString aString;
+
+ MapInt2String::const_iterator aPos = m_aDirectPropTranslator.find( _nId );
+ if ( m_aDirectPropTranslator.end() != aPos )
+ {
+ aString = aPos->second;
+ }
+ else
+ {
+ MapInt2String::const_iterator indirectPos = m_aIndirectPropTranslator.find( _nId );
+ if ( m_aIndirectPropTranslator.end() != indirectPos )
+ aString = indirectPos->second;
+ }
+
+ ::rtl::OString aReturn( aString.getStr(), aString.getLength(), RTL_TEXTENCODING_ASCII_US );
+ return aReturn;
+}
+#endif
+
+//-------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::implTranslateProperty( SfxItemSet& _rSet, sal_Int32 _nId, const Any& _rValue )
+{
+ switch ( _rValue.getValueType().getTypeClass() )
+ {
+ case TypeClass_STRING:
+ if ( implCheckItemType( _rSet, _nId, SfxStringItem::StaticType() ) )
+ {
+ ::rtl::OUString sValue;
+ _rValue >>= sValue;
+ _rSet.Put(SfxStringItem(_nId, sValue.getStr()));
+ }
+ else {
+ OSL_FAIL(
+ ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
+ += ::rtl::OString( translatePropertyId( _nId ) )
+ += ::rtl::OString( " should be no string)!" )
+ ).getStr()
+ );
+ }
+ break;
+
+ case TypeClass_BOOLEAN:
+ if ( implCheckItemType( _rSet, _nId, SfxBoolItem::StaticType() ) )
+ {
+ sal_Bool bVal = sal_False;
+ _rValue >>= bVal;
+ _rSet.Put(SfxBoolItem(_nId, bVal));
+ }
+ else if ( implCheckItemType( _rSet, _nId, OptionalBoolItem::StaticType() ) )
+ {
+ OptionalBoolItem aItem( _nId );
+ if ( _rValue.hasValue() )
+ {
+ sal_Bool bValue = sal_False;
+ _rValue >>= bValue;
+ aItem.SetValue( bValue );
+ }
+ else
+ aItem.ClearValue();
+ _rSet.Put( aItem );
+ }
+ else {
+ OSL_FAIL(
+ ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
+ += ::rtl::OString( translatePropertyId( _nId ) )
+ += ::rtl::OString( " should be no boolean)!" )
+ ).getStr()
+ );
+ }
+ break;
+
+ case TypeClass_LONG:
+ if ( implCheckItemType( _rSet, _nId, SfxInt32Item::StaticType() ) )
+ {
+ sal_Int32 nValue = 0;
+ _rValue >>= nValue;
+ _rSet.Put( SfxInt32Item( _nId, nValue ) );
+ }
+ else {
+ OSL_FAIL(
+ ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
+ += ::rtl::OString( translatePropertyId( _nId ) )
+ += ::rtl::OString( " should be no int)!" )
+ ).getStr()
+ );
+ }
+ break;
+
+ case TypeClass_SEQUENCE:
+ if ( implCheckItemType( _rSet, _nId, OStringListItem::StaticType() ) )
+ {
+ // determine the element type
+ TypeDescription aTD(_rValue.getValueType());
+ typelib_IndirectTypeDescription* pSequenceTD =
+ reinterpret_cast< typelib_IndirectTypeDescription* >(aTD.get());
+ OSL_ENSURE(pSequenceTD && pSequenceTD->pType, "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid sequence type!");
+
+ Type aElementType(pSequenceTD->pType);
+ switch (aElementType.getTypeClass())
+ {
+ case TypeClass_STRING:
+ {
+ Sequence< ::rtl::OUString > aStringList;
+ _rValue >>= aStringList;
+ _rSet.Put(OStringListItem(_nId, aStringList));
+ }
+ break;
+ default:
+ OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!");
+ }
+ }
+ else {
+ OSL_FAIL(
+ ( ::rtl::OString( "ODbDataSourceAdministrationHelper::implTranslateProperty: invalid property value (" )
+ += ::rtl::OString( translatePropertyId( _nId ) )
+ += ::rtl::OString( " should be no string sequence)!" )
+ ).getStr()
+ );
+ }
+ break;
+
+ case TypeClass_VOID:
+ _rSet.ClearItem(_nId);
+ break;
+
+ default:
+ OSL_FAIL("ODbDataSourceAdministrationHelper::implTranslateProperty: unsupported property value type!");
+ }
+}
+
+
+String ODbDataSourceAdministrationHelper::getDocumentUrl(SfxItemSet& _rDest)
+{
+ SFX_ITEMSET_GET(_rDest, pUrlItem, SfxStringItem, DSID_DOCUMENT_URL, sal_True);
+ OSL_ENSURE(pUrlItem,"Document URL is NULL. -> GPF!");
+ return pUrlItem->GetValue();
+}
+
+
+// -----------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::convertUrl(SfxItemSet& _rDest)
+{
+ ::rtl::OUString eType = getDatasourceType(_rDest);
+
+ SFX_ITEMSET_GET(_rDest, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(_rDest, pTypeCollection, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+
+ OSL_ENSURE(pUrlItem,"Connection URL is NULL. -> GPF!");
+ OSL_ENSURE(pTypeCollection, "ODbAdminDialog::getDatasourceType: invalid items in the source set!");
+ ::dbaccess::ODsnTypeCollection* pCollection = pTypeCollection->getCollection();
+ OSL_ENSURE(pCollection, "ODbAdminDialog::getDatasourceType: invalid type collection!");
+
+ sal_uInt16 nPortNumberId = 0;
+ sal_Int32 nPortNumber = -1;
+ String sNewHostName;
+ String sUrlPart;
+
+ pCollection->extractHostNamePort(pUrlItem->GetValue(),sUrlPart,sNewHostName,nPortNumber);
+ const ::dbaccess::DATASOURCE_TYPE eTy = pCollection->determineType(eType);
+
+ switch( eTy )
+ {
+ case ::dbaccess::DST_MYSQL_NATIVE:
+ case ::dbaccess::DST_MYSQL_JDBC:
+ nPortNumberId = DSID_MYSQL_PORTNUMBER;
+ break;
+ case ::dbaccess::DST_ORACLE_JDBC:
+ nPortNumberId = DSID_ORACLE_PORTNUMBER;
+ break;
+ case ::dbaccess::DST_LDAP:
+ nPortNumberId = DSID_CONN_LDAP_PORTNUMBER;
+ break;
+ default:
+ break;
+ }
+
+ if ( sUrlPart.Len() )
+ {
+ if ( eTy == ::dbaccess::DST_MYSQL_NATIVE )
+ {
+ _rDest.Put( SfxStringItem( DSID_DATABASENAME, sUrlPart ) );
+ }
+ else
+ {
+ String sNewUrl = pCollection->getPrefix(eType);
+ sNewUrl += sUrlPart;
+ _rDest.Put( SfxStringItem( DSID_CONNECTURL, sNewUrl ) );
+ }
+ }
+
+ if ( sNewHostName.Len() )
+ _rDest.Put(SfxStringItem(DSID_CONN_HOSTNAME, sNewHostName));
+
+ if ( nPortNumber != -1 && nPortNumberId != 0 )
+ _rDest.Put(SfxInt32Item(nPortNumberId, nPortNumber));
+
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODbDataSourceAdministrationHelper::saveChanges(const SfxItemSet& _rSource)
+{
+ // put the remembered settings into the property set
+ Reference<XPropertySet> xDatasource = getCurrentDataSource();
+ if ( !xDatasource.is() )
+ return sal_False;
+
+ translateProperties(_rSource,xDatasource );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODbDataSourceAdministrationHelper::setDataSourceOrName( const Any& _rDataSourceOrName )
+{
+ OSL_ENSURE( !m_aDataSourceOrName.hasValue(), "ODbDataSourceAdministrationHelper::setDataSourceOrName: already have one!" );
+ // hmm. We could reset m_xDatasource/m_xModel, probably, and continue working
+ m_aDataSourceOrName = _rDataSourceOrName;
+}
+//=========================================================================
+//= DbuTypeCollectionItem
+//=========================================================================
+TYPEINIT1(DbuTypeCollectionItem, SfxPoolItem);
+//-------------------------------------------------------------------------
+DbuTypeCollectionItem::DbuTypeCollectionItem(sal_Int16 _nWhich, ::dbaccess::ODsnTypeCollection* _pCollection)
+ :SfxPoolItem(_nWhich)
+ ,m_pCollection(_pCollection)
+{
+}
+
+//-------------------------------------------------------------------------
+DbuTypeCollectionItem::DbuTypeCollectionItem(const DbuTypeCollectionItem& _rSource)
+ :SfxPoolItem(_rSource)
+ ,m_pCollection(_rSource.getCollection())
+{
+}
+
+//-------------------------------------------------------------------------
+int DbuTypeCollectionItem::operator==(const SfxPoolItem& _rItem) const
+{
+ DbuTypeCollectionItem* pCompare = PTR_CAST(DbuTypeCollectionItem, &_rItem);
+ return pCompare && (pCompare->getCollection() == getCollection());
+}
+
+//-------------------------------------------------------------------------
+SfxPoolItem* DbuTypeCollectionItem::Clone(SfxItemPool* /*_pPool*/) const
+{
+ return new DbuTypeCollectionItem(*this);
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
new file mode 100644
index 000000000000..2e4c2b251a53
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBADMINIMPL_HXX_
+#define _DBAUI_DBADMINIMPL_HXX_
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <comphelper/stl_types.hxx>
+#include "dsntypes.hxx"
+#include <svl/itemset.hxx>
+#include <com/sun/star/frame/XModel.hpp>
+#include <svl/poolitem.hxx>
+
+class Window;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ class DataSourceInfoConverter
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ public:
+ DataSourceInfoConverter(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory)
+ :m_xFactory(_xFactory)
+ {
+ }
+ void convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource);
+ };
+ class IItemSetHelper;
+ //========================================================================
+ //= ODbDataSourceAdministrationHelper
+ //========================================================================
+ class ODbDataSourceAdministrationHelper
+ {
+ public:
+ DECLARE_STL_MAP(sal_Int32, ::rtl::OUString, ::std::less< sal_Int32 >, MapInt2String);
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB; /// service factory
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xDatabaseContext; /// database context we're working in
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService >
+ m_xDynamicContext; /// just another interface of the context ...
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDatasource;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel;
+
+ ::com::sun::star::uno::Any m_aDataSourceOrName;
+ typedef ::std::set< ::rtl::OUString > StringSet;
+ typedef StringSet::const_iterator ConstStringSetIterator;
+
+
+ MapInt2String m_aDirectPropTranslator; /// translating property id's into names (direct properties of a data source)
+ MapInt2String m_aIndirectPropTranslator; /// translating property id's into names (indirect properties of a data source)
+ Window* m_pParent;
+ IItemSetHelper* m_pItemSetHelper;
+ public:
+
+ ODbDataSourceAdministrationHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB
+ ,Window* _pParent
+ ,IItemSetHelper* _pItemSetHelper);
+
+ /** translate the current dialog SfxItems into driver relevant PropertyValues
+ @see successfullyConnected
+ */
+ sal_Bool getCurrentSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverParams);
+
+ /** to be called if the settings got from getCurrentSettings have been used for successfully connecting
+ @see getCurrentSettings
+ */
+ void successfullyConnected();
+
+ /// clear the password in the current data source's item set
+ void clearPassword();
+
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getDatabaseContext() const { return m_xDatabaseContext; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XNamingService > getDynamicContext() const { return m_xDynamicContext; }
+
+ /** creates a new connection. The caller is responsible to dispose it !!!!
+ */
+ ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+
+ /** return the corresponding driver for the selected URL
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver(const ::rtl::OUString& _sURL);
+
+ /** returns the data source the dialog is currently working with
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getCurrentDataSource();
+ // returns the Url of a database document
+ String getDocumentUrl(SfxItemSet& _rDest);
+
+ void setDataSourceOrName( const ::com::sun::star::uno::Any& _rDataSourceOrName );
+
+ /** extracts the connection type from the given set<p/>
+ The connection type is determined by the value of the DSN item, analyzed by the TypeCollection item.
+ */
+ static ::rtl::OUString getDatasourceType( const SfxItemSet& _rSet );
+
+ /** returns the connection URL
+ @return
+ The connection URL
+ */
+ String getConnectionURL() const;
+
+ /// fill the nescessary information from the url line
+ void convertUrl(SfxItemSet& _rDest);
+
+ const MapInt2String& getIndirectProperties() const { return m_aIndirectPropTranslator; }
+
+ /** translates properties of an UNO data source into SfxItems
+ @param _rxSource
+ The data source
+ @param _rDest
+ The item set to fill.
+ */
+ void translateProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSource,
+ SfxItemSet& _rDest);
+
+ /** translate SfxItems into properties of an UNO data source
+ @param _rSource
+ The item set to read from.
+ @param _rxDest
+ The data source to fill.
+ */
+ void translateProperties(
+ const SfxItemSet& _rSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDest);
+
+ sal_Bool saveChanges(const SfxItemSet& _rSource);
+ protected:
+ /** fill a data source info array with the settings from a given item set
+ */
+ void fillDatasourceInfo(const SfxItemSet& _rSource, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo);
+
+ /// translate the given value into an SfxPoolItem, put this into the given set under the given id
+ void implTranslateProperty(SfxItemSet& _rSet, sal_Int32 _nId, const ::com::sun::star::uno::Any& _rValue);
+
+ /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>
+ ::com::sun::star::uno::Any implTranslateProperty(const SfxPoolItem* _pItem);
+
+ /// translate the given SfxPoolItem into an <type scope="com.sun.star.Any">uno</type>, set it (under the given name) on the given property set
+ void implTranslateProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSet, const ::rtl::OUString& _rName, const SfxPoolItem* _pItem);
+
+ /** check if the data source described by the given set needs authentication<p/>
+ The return value depends on the data source type only.
+ */
+ sal_Bool hasAuthentication(const SfxItemSet& _rSet) const;
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString translatePropertyId( sal_Int32 _nId );
+#endif
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DBADMINIMPL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx
new file mode 100644
index 000000000000..2408297e20cf
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DriverSettings.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "DriverSettings.hxx"
+#include "dsmeta.hxx"
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+#include <connectivity/DriversConfig.hxx>
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::NamedValue;
+
+using namespace dbaui;
+void ODriversSettings::getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory, ::std::vector< sal_Int32>& _out_rDetailsIds )
+{
+ // for a number of settings, we do not need to use hard-coded here, but can ask a
+ // central DataSourceUI instance.
+ DataSourceMetaData aMeta( _sURLPrefix );
+ const FeatureSet& rFeatures( aMeta.getFeatureSet() );
+ for ( FeatureSet::const_iterator feature = rFeatures.begin();
+ feature != rFeatures.end();
+ ++feature
+ )
+ {
+ _out_rDetailsIds.push_back( *feature );
+ }
+
+ // the rest is configuration-based
+ // TODO: that's not really true: *everything* is configuration-based nowadays, even the FeatureSet obtained
+ // from the DataSourceMetaData has been initialized from the configuration. So in fact, we could consolidate
+ // the two blocks.
+ // The best approach would be to extend the FeatureSet to contain *all* known data source features, not only
+ // the ones from the "Advanced settings" UI.
+
+ ::connectivity::DriversConfig aDriverConfig(_xFactory);
+ const ::comphelper::NamedValueCollection& aProperties = aDriverConfig.getProperties(_sURLPrefix);
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Sequence< NamedValue > aNamedValues;
+ aProperties >>= aNamedValues;
+ for ( const NamedValue* loop = aNamedValues.getConstArray();
+ loop != aNamedValues.getConstArray() + aNamedValues.getLength();
+ ++loop
+ )
+ {
+ int dummy = 0;
+ (void)dummy;
+ }
+ }
+#endif
+ typedef ::std::pair<sal_uInt16, ::rtl::OUString> TProperties;
+ TProperties aProps[] = { TProperties(DSID_SHOWDELETEDROWS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted")))
+ ,TProperties(DSID_CHARSET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet")))
+ ,TProperties(DSID_FIELDDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter")))
+ ,TProperties(DSID_TEXTDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter")))
+ ,TProperties(DSID_DECIMALDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter")))
+ ,TProperties(DSID_THOUSANDSDELIMITER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter")))
+ ,TProperties(DSID_TEXTFILEEXTENSION,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension")))
+ ,TProperties(DSID_TEXTFILEHEADER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine")))
+ ,TProperties(DSID_ADDITIONALOPTIONS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings")))
+ ,TProperties(DSID_CONN_SHUTSERVICE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase")))
+ ,TProperties(DSID_CONN_DATAINC,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement")))
+ ,TProperties(DSID_CONN_CACHESIZE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSize")))
+ ,TProperties(DSID_CONN_CTRLUSER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser")))
+ ,TProperties(DSID_CONN_CTRLPWD,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword")))
+ ,TProperties(DSID_USECATALOG,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog")))
+ ,TProperties(DSID_CONN_SOCKET,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LocalSocket")))
+ ,TProperties(DSID_NAMED_PIPE,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedPipe")))
+ ,TProperties(DSID_JDBCDRIVERCLASS,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")))
+ ,TProperties(DSID_CONN_LDAP_BASEDN,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN")))
+ ,TProperties(DSID_CONN_LDAP_ROWCOUNT,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount")))
+ ,TProperties(DSID_CONN_LDAP_USESSL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSSL")))
+ ,TProperties(DSID_IGNORECURRENCY,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency")))
+ ,TProperties(0,::rtl::OUString())
+ };
+ // TODO: This mapping between IDs and property names already exists - in ODbDataSourceAdministrationHelper::ODbDataSourceAdministrationHelper.
+ // Another mapping (which is also duplicated in ODbDataSourceAdministrationHelper) exists in dsmeta.cxx. We should
+ // consolidate those three places into one.
+ // However, care has to be taken: We need to distinguish between "features" and "properties" of a data source (resp. driver).
+ // That is, a driver can support a certain property, but not allow to change it in the UI, which means it would
+ // not have the respective "feature".
+ for ( TProperties* pProps = aProps; pProps->first; ++pProps )
+ {
+ if ( aProperties.has(pProps->second) )
+ _out_rDetailsIds.push_back(pProps->first);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/DriverSettings.hxx b/dbaccess/source/ui/dlg/DriverSettings.hxx
new file mode 100644
index 000000000000..13b4b50e5943
--- /dev/null
+++ b/dbaccess/source/ui/dlg/DriverSettings.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_DRIVERSETTINGS_HXX
+#define DBAUI_DRIVERSETTINGS_HXX
+
+#include "dsntypes.hxx"
+#include <svl/poolitem.hxx>
+#include <vector>
+
+class SfxTabPage;
+class Window;
+namespace dbaui
+{
+ /// a collection class for all details a driver needs
+ class ODriversSettings
+ {
+ public:
+
+ /** filles the IDs of the settings which are reflected in indirect data source properties
+ (aka properties in the css.sdb.DataSource.Info sequence)
+
+ @param _eType
+ The Type of the data source.
+ @param _out_rDetailsIds
+ Will be filled.
+ */
+ static void getSupportedIndirectSettings( const ::rtl::OUString& _sURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory,::std::vector< sal_Int32>& _out_rDetailsIds );
+
+ /** Creates the detail page for Dbase
+ */
+ static SfxTabPage* CreateDbase2( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for ado
+ */
+ static SfxTabPage* CreateDbase( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for ado
+ */
+ static SfxTabPage* CreateAdo( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for ODBC
+ */
+ static SfxTabPage* CreateODBC( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for user
+ */
+ static SfxTabPage* CreateUser( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for MySQLODBC
+ */
+ static SfxTabPage* CreateMySQLODBC( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for MySQLJDBC
+ */
+ static SfxTabPage* CreateMySQLJDBC( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for MySQLNATIVE
+ */
+ static SfxTabPage* CreateMySQLNATIVE( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for Oracle JDBC
+ */
+ static SfxTabPage* CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for Adabas
+ */
+ static SfxTabPage* CreateAdabas( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /** Creates the detail page for LDAP
+ */
+ static SfxTabPage* CreateLDAP( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /// Creates the detail page for Text
+ static SfxTabPage* CreateText( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+
+ /// creates the GeneratedValues page
+ static SfxTabPage* CreateGeneratedValuesPage( Window* _pParent, const SfxItemSet& _rAttrSet );
+
+ /// creates the "Special Settings" page of the "Advanced Settings" dialog
+ static SfxTabPage* CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet );
+ };
+}
+
+#endif // DBAUI_DRIVERSETTINGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/RelationDlg.cxx b/dbaccess/source/ui/dlg/RelationDlg.cxx
new file mode 100644
index 000000000000..7618e732fd1a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/RelationDlg.cxx
@@ -0,0 +1,270 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RelationDlg.hrc"
+#include "RelationDlg.hxx"
+
+#include <vcl/wrkwin.hxx>
+
+#include <vcl/svapp.hxx>
+#include "dbu_dlg.hrc"
+#include "dbaccess_helpid.hrc"
+#include <com/sun/star/sdbc/KeyRule.hpp>
+
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "UITools.hxx"
+#include "JoinDesignView.hxx"
+#include "JoinController.hxx"
+#include <connectivity/dbexception.hxx>
+#include "RTableConnectionData.hxx"
+#include "RelationControl.hxx"
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::dbaui;
+using namespace ::dbtools;
+
+//========================================================================
+// class ORelationDialog
+DBG_NAME(ORelationDialog)
+//========================================================================
+ORelationDialog::ORelationDialog( OJoinTableView* pParent,
+ const TTableConnectionData::value_type& pConnectionData,
+ sal_Bool bAllowTableSelect )
+ :ModalDialog( pParent, ModuleRes(DLG_REL_PROPERTIES) )
+ ,m_pTableMap(pParent->GetTabWinMap())
+
+ ,aFL_CascUpd( this, ModuleRes(FL_CASC_UPD) )
+ ,aRB_NoCascUpd( this, ModuleRes(RB_NO_CASC_UPD) )
+ ,aRB_CascUpd( this, ModuleRes(RB_CASC_UPD) )
+ ,aRB_CascUpdNull( this, ModuleRes(RB_CASC_UPD_NULL) )
+ ,aRB_CascUpdDefault( this, ModuleRes(RB_CASC_UPD_DEFAULT) )
+ ,aFL_CascDel( this, ModuleRes(FL_CASC_DEL) )
+ ,aRB_NoCascDel( this, ModuleRes(RB_NO_CASC_DEL) )
+ ,aRB_CascDel( this, ModuleRes(RB_CASC_DEL) )
+ ,aRB_CascDelNull( this, ModuleRes(RB_CASC_DEL_NULL) )
+ ,aRB_CascDelDefault( this, ModuleRes(RB_CASC_DEL_DEFAULT) )
+
+ ,aPB_OK( this, ModuleRes( PB_OK ) )
+ ,aPB_CANCEL( this, ModuleRes( PB_CANCEL ) )
+ ,aPB_HELP( this, ModuleRes( PB_HELP ) )
+
+ ,m_pOrigConnData( pConnectionData )
+ ,m_bTriedOneUpdate(sal_False)
+{
+ DBG_CTOR(ORelationDialog,NULL);
+
+ m_xConnection = pParent->getDesignView()->getController().getConnection();
+
+ //////////////////////////////////////////////////////////////////////
+ // Connection kopieren
+ m_pConnData.reset( static_cast<ORelationTableConnectionData*>(pConnectionData->NewInstance()) );
+ m_pConnData->CopyFrom( *pConnectionData );
+
+ Init(m_pConnData);
+ m_pTableControl.reset( new OTableListBoxControl(this,ModuleRes(WND_CONTROL),m_pTableMap,this) );
+
+ aPB_OK.SetClickHdl( LINK(this, ORelationDialog, OKClickHdl) );
+
+ m_pTableControl->Init( m_pConnData );
+ if ( bAllowTableSelect )
+ m_pTableControl->fillListBoxes();
+ else
+ m_pTableControl->fillAndDisable(pConnectionData);
+
+ m_pTableControl->lateInit();
+
+ m_pTableControl->NotifyCellChange();
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionData)
+{
+ ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(_pConnectionData.get());
+ // Update Rules
+ switch (pConnData->GetUpdateRules())
+ {
+ case KeyRule::NO_ACTION:
+ case KeyRule::RESTRICT:
+ aRB_NoCascUpd.Check( sal_True );
+ break;
+
+ case KeyRule::CASCADE:
+ aRB_CascUpd.Check( sal_True );
+ break;
+
+ case KeyRule::SET_NULL:
+ aRB_CascUpdNull.Check( sal_True );
+ break;
+ case KeyRule::SET_DEFAULT:
+ aRB_CascUpdDefault.Check( sal_True );
+ break;
+ }
+
+ // Delete Rules
+ switch (pConnData->GetDeleteRules())
+ {
+ case KeyRule::NO_ACTION:
+ case KeyRule::RESTRICT:
+ aRB_NoCascDel.Check( sal_True );
+ break;
+
+ case KeyRule::CASCADE:
+ aRB_CascDel.Check( sal_True );
+ break;
+
+ case KeyRule::SET_NULL:
+ aRB_CascDelNull.Check( sal_True );
+ break;
+ case KeyRule::SET_DEFAULT:
+ aRB_CascDelDefault.Check( sal_True );
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+ORelationDialog::~ORelationDialog()
+{
+ DBG_DTOR(ORelationDialog,NULL);
+}
+
+//------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------
+IMPL_LINK( ORelationDialog, OKClickHdl, Button*, /*pButton*/ )
+{
+ //////////////////////////////////////////////////////////////////////
+ // RadioButtons auslesen
+ sal_uInt16 nAttrib = 0;
+
+ // Delete Rules
+ if( aRB_NoCascDel.IsChecked() )
+ nAttrib |= KeyRule::NO_ACTION;
+ if( aRB_CascDel.IsChecked() )
+ nAttrib |= KeyRule::CASCADE;
+ if( aRB_CascDelNull.IsChecked() )
+ nAttrib |= KeyRule::SET_NULL;
+ if( aRB_CascDelDefault.IsChecked() )
+ nAttrib |= KeyRule::SET_DEFAULT;
+
+ ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(m_pConnData.get());
+ pConnData->SetDeleteRules( nAttrib );
+
+ // Update Rules
+ nAttrib = 0;
+ if( aRB_NoCascUpd.IsChecked() )
+ nAttrib |= KeyRule::NO_ACTION;
+ if( aRB_CascUpd.IsChecked() )
+ nAttrib |= KeyRule::CASCADE;
+ if( aRB_CascUpdNull.IsChecked() )
+ nAttrib |= KeyRule::SET_NULL;
+ if( aRB_CascUpdDefault.IsChecked() )
+ nAttrib |= KeyRule::SET_DEFAULT;
+ pConnData->SetUpdateRules( nAttrib );
+
+ m_pTableControl->SaveModified();
+
+ //// wenn die ComboBoxen fuer die Tabellenauswahl enabled sind (Constructor mit bAllowTableSelect==sal_True), dann muss ich in die
+ //// Connection auch die Tabellennamen stecken
+ //m_pConnData->SetSourceWinName(m_pTableControl->getSourceWinName());
+ //m_pConnData->SetDestWinName(m_pTableControl->getDestWinName());
+
+ // try to create the relation
+ try
+ {
+ ORelationTableConnectionData* pOrigConnData = static_cast<ORelationTableConnectionData*>(m_pOrigConnData.get());
+ if ( *pConnData == *pOrigConnData || pConnData->Update())
+ {
+ m_pOrigConnData->CopyFrom( *m_pConnData );
+ EndDialog( RET_OK );
+ return 0L;
+ }
+ }
+ catch( const SQLException& )
+ {
+ ::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ),
+ this,
+ static_cast<OJoinTableView*>(GetParent())->getDesignView()->getController().getORB());
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_bTriedOneUpdate = sal_True;
+ // this means that the original connection may be lost (if m_pConnData was not a newly created but an
+ // existent conn to be modified), which we reflect by returning RET_NO (see ::Execute)
+
+ // try again
+ Init(m_pConnData);
+ m_pTableControl->Init( m_pConnData );
+ m_pTableControl->lateInit();
+
+ return 0;
+}
+
+
+//------------------------------------------------------------------------
+short ORelationDialog::Execute()
+{
+ short nResult = ModalDialog::Execute();
+ if ((nResult != RET_OK) && m_bTriedOneUpdate)
+ return RET_NO;
+
+ return nResult;
+}
+// -----------------------------------------------------------------------------
+TTableConnectionData::value_type ORelationDialog::getConnectionData() const
+{
+ return m_pConnData;
+}
+// -----------------------------------------------------------------------------
+void ORelationDialog::setValid(sal_Bool _bValid)
+{
+ aPB_OK.Enable(_bValid);
+}
+// -----------------------------------------------------------------------------
+void ORelationDialog::notifyConnectionChange()
+{
+ Init(m_pConnData);
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/RelationDlg.hrc b/dbaccess/source/ui/dlg/RelationDlg.hrc
new file mode 100644
index 000000000000..b0d14aa6d93a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/RelationDlg.hrc
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELATIONDIALOG_HRC
+#define DBAUI_RELATIONDIALOG_HRC
+
+#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+#include "RelationControl.hrc"
+#endif
+
+#define FL_CASC_DEL 3
+#define FL_CASC_UPD 4
+
+#define RB_NO_CASC_DEL 1
+#define RB_NO_CASC_UPD 2
+#define RB_CASC_DEL 3
+#define RB_CASC_UPD 4
+#define RB_CASC_DEL_NULL 5
+#define RB_CASC_DEL_DEFAULT 6
+#define RB_CASC_UPD_NULL 7
+#define RB_CASC_UPD_DEFAULT 8
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+
+#define WND_CONTROL 1
+
+#endif // DBAUI_RELATIONDIALOG_HRC
+
+
diff --git a/dbaccess/source/ui/dlg/RelationDlg.src b/dbaccess/source/ui/dlg/RelationDlg.src
new file mode 100644
index 000000000000..90602e37c4a9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/RelationDlg.src
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_RELATIONDIALOG_HRC
+#include "RelationDlg.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+
+ModalDialog DLG_REL_PROPERTIES
+{
+ HelpID = "dbaccess:ModalDialog:DLG_REL_PROPERTIES";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 186 , 205 ) ;
+ Text [ en-US ] = "Relations" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ Window WND_CONTROL
+ {
+ Pos = MAP_APPFONT( 0, 0 );
+ Size = MAP_APPFONT( 186, 113 );
+ DialogControl = TRUE;
+ HelpId = HID_DLG_QRY_WINDOW_CONTROL ;
+
+ FixedLine FL_INVOLVED_TABLES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 174 , 8 ) ;
+ Text [ en-US ] = "Tables involved";
+ };
+
+ ListBox LB_LEFT_TABLE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 12, 14 );
+ Size = MAP_APPFONT( 78, 60 );
+ HelpId = HID_DLG_QRY_LEFT_TABLE ;
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+
+ ListBox LB_RIGHT_TABLE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 96, 14 );
+ Size = MAP_APPFONT( 78, 60 );
+ HelpId = HID_DLG_QRY_RIGHT_TABLE ;
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+
+ FixedLine FL_INVOLVED_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 29 ) ;
+ Size = MAP_APPFONT ( 174 , 8 ) ;
+ Text [ en-US ] = "Fields involved";
+ };
+ };
+
+ FixedLine FL_CASC_UPD
+ {
+ Pos = MAP_APPFONT ( 6 , 114 ) ;
+ Size = MAP_APPFONT ( 84 , 8 ) ;
+ Text [ en-US ] = "Update options" ;
+ };
+ RadioButton RB_NO_CASC_UPD
+ {
+ Pos = MAP_APPFONT ( 12 , 125 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DLG_REL_NO_CASC_UPD;
+ Text [ en-US ] = "~No action" ;
+ };
+ RadioButton RB_CASC_UPD
+ {
+ Pos = MAP_APPFONT ( 12 , 139 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_UPD ;
+ Text [ en-US ] = "~Update cascade" ;
+ };
+ RadioButton RB_CASC_UPD_NULL
+ {
+ Pos = MAP_APPFONT ( 12 , 153 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_UPD_NULL ;
+ Text [ en-US ] = "~Set null" ;
+ };
+ RadioButton RB_CASC_UPD_DEFAULT
+ {
+ Pos = MAP_APPFONT ( 12 , 167 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_UPD_DEFAULT ;
+ Text [ en-US ] = "Set ~default" ;
+ };
+ FixedLine FL_CASC_DEL
+ {
+ Pos = MAP_APPFONT ( 96 , 114 ) ;
+ Size = MAP_APPFONT ( 84 , 8 ) ;
+ Text [ en-US ] = "Delete options" ;
+ };
+ RadioButton RB_NO_CASC_DEL
+ {
+ Pos = MAP_APPFONT ( 102 , 125 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DLG_REL_NO_CASC_DEL ;
+ Text [ en-US ] = "~No action" ;
+ };
+ RadioButton RB_CASC_DEL
+ {
+ Pos = MAP_APPFONT ( 102 , 139 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_DEL ;
+ Text [ en-US ] = "Delete ~cascade" ;
+ };
+ RadioButton RB_CASC_DEL_NULL
+ {
+ Pos = MAP_APPFONT ( 102 , 153 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_DEL_NULL ;
+ Text [ en-US ] = "~Set null" ;
+ };
+ RadioButton RB_CASC_DEL_DEFAULT
+ {
+ Pos = MAP_APPFONT ( 102 , 167 ) ;
+ Size = MAP_APPFONT ( 72 , 10 ) ;
+ HelpId = HID_DLG_REL_CASC_DEL_DEFAULT ;
+ Text [ en-US ] = "Set ~default" ;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 184 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 59 , 184 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 115 , 184 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+};
diff --git a/dbaccess/source/ui/dlg/TablesSingleDlg.cxx b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx
new file mode 100644
index 000000000000..17fcf7861e51
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TablesSingleDlg.cxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TablesSingleDlg.hxx"
+#include "DbAdminImpl.hxx"
+#include "tablespage.hxx"
+#include <vcl/msgbox.hxx>
+#include "dsitems.hxx"
+
+#include "propertysetitem.hxx"
+
+#include "dbu_dlg.hrc"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+
+DBG_NAME(OTableSubscriptionDialog)
+ //========================================================================
+ //= OTableSubscriptionDialog
+ //========================================================================
+OTableSubscriptionDialog::OTableSubscriptionDialog(Window* pParent
+ ,SfxItemSet* _pItems
+ ,const Reference< XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName)
+ :SfxSingleTabDialog(pParent,DLG_TABLE_FILTER,_pItems)
+ ,m_pImpl( new ODbDataSourceAdministrationHelper( _rxORB, pParent, this ) )
+ ,m_bStopExecution(sal_False)
+ ,m_pOutSet(_pItems)
+{
+ DBG_CTOR(OTableSubscriptionDialog,NULL);
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ m_pOutSet = new SfxItemSet( *_pItems );
+
+ m_pImpl->translateProperties(xDatasource, *m_pOutSet);
+ SetInputSet(m_pOutSet);
+
+ OTableSubscriptionPage* pTabPage = new OTableSubscriptionPage(this,*m_pOutSet,this);
+ pTabPage->SetServiceFactory(_rxORB);
+ SetTabPage(pTabPage);
+}
+// -----------------------------------------------------------------------------
+OTableSubscriptionDialog::~OTableSubscriptionDialog()
+{
+ DBG_DTOR(OTableSubscriptionDialog,NULL);
+ delete m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+short OTableSubscriptionDialog::Execute()
+{
+ short nRet = RET_CANCEL;
+ if ( !m_bStopExecution )
+ {
+ nRet = SfxSingleTabDialog::Execute();
+ if ( nRet == RET_OK )
+ {
+ m_pOutSet->Put(*GetOutputItemSet());
+ m_pImpl->saveChanges(*m_pOutSet);
+ }
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableSubscriptionDialog::getCurrentSettings(Sequence< PropertyValue >& _rDriverParams)
+{
+ return m_pImpl->getCurrentSettings(_rDriverParams);
+}
+// -----------------------------------------------------------------------------
+void OTableSubscriptionDialog::successfullyConnected()
+{
+ m_pImpl->successfullyConnected();
+}
+// -----------------------------------------------------------------------------
+void OTableSubscriptionDialog::clearPassword()
+{
+ m_pImpl->clearPassword();
+}
+// -----------------------------------------------------------------------------
+String OTableSubscriptionDialog::getConnectionURL() const
+{
+ return m_pImpl->getConnectionURL();
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OTableSubscriptionDialog::getCurrentDataSource()
+{
+ return m_pImpl->getCurrentDataSource();
+}
+// -----------------------------------------------------------------------------
+const SfxItemSet* OTableSubscriptionDialog::getOutputSet() const
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+SfxItemSet* OTableSubscriptionDialog::getWriteOutputSet()
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
new file mode 100644
index 000000000000..2903742efa70
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -0,0 +1,549 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "moduledbu.hxx"
+
+#include "TextConnectionHelper.hxx"
+
+#include "sqlmessage.hxx"
+#include "dbu_dlg.hrc"
+#include "dbu_resource.hrc"
+#include "AutoControls.hrc"
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dsitems.hxx"
+#include "dbfindex.hxx"
+#include "dbaccess_helpid.hrc"
+#include "localresaccess.hxx"
+#include <vcl/msgbox.hxx>
+#include <vcl/mnemonic.hxx>
+#include <svl/cjkoptions.hxx>
+#include <jvmaccess/virtualmachine.hxx>
+#include "AdabasStat.hxx"
+#include <connectivity/CommonTools.hxx>
+#include "DriverSettings.hxx"
+#include "dbadmin.hxx"
+#include <comphelper/types.hxx>
+
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+
+#include <svl/filenotation.hxx>
+
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include "finteraction.hxx"
+#include <connectivity/CommonTools.hxx>
+
+#include "DBSetupConnectionPages.hxx"
+
+#include "dbu_dlg.hrc"
+
+#include "dbaccess_helpid.hrc"
+
+#include <unotools/pathoptions.hxx>
+
+#include <svtools/roadmapwizard.hxx>
+
+
+namespace dbaui
+{
+
+ //========================================================================
+ //= OTextConnectionPageSetup
+ //========================================================================
+DBG_NAME(OTextConnectionHelper)
+//------------------------------------------------------------------------
+ OTextConnectionHelper::OTextConnectionHelper( Window* pParent, const short _nAvailableSections )
+ :Control( pParent, WB_DIALOGCONTROL )
+ ,m_aFTExtensionHeader (this, ModuleRes(FT_AUTOEXTENSIONHEADER))
+ ,m_aRBAccessTextFiles (this, ModuleRes(RB_AUTOACCESSCTEXTFILES))
+ ,m_aRBAccessCSVFiles (this, ModuleRes(RB_AUTOACCESSCCSVFILES))
+ ,m_aRBAccessOtherFiles (this, ModuleRes(RB_AUTOACCESSOTHERS))
+ ,m_aETOwnExtension (this, ModuleRes(ET_AUTOOWNEXTENSION))
+ ,m_aFTExtensionExample (this, ModuleRes(FT_AUTOOWNEXTENSIONAPPENDIX))
+ ,m_aLineFormat (this, ModuleRes(FL_AUTOSEPARATOR2))
+ ,m_aFieldSeparatorLabel (this, ModuleRes(FT_AUTOFIELDSEPARATOR))
+ ,m_aFieldSeparator (this, ModuleRes(CM_AUTOFIELDSEPARATOR))
+ ,m_aTextSeparatorLabel (this, ModuleRes(FT_AUTOTEXTSEPARATOR))
+ ,m_aTextSeparator (this, ModuleRes(CM_AUTOTEXTSEPARATOR))
+ ,m_aDecimalSeparatorLabel (this, ModuleRes(FT_AUTODECIMALSEPARATOR))
+ ,m_aDecimalSeparator (this, ModuleRes(CM_AUTODECIMALSEPARATOR))
+ ,m_aThousandsSeparatorLabel (this, ModuleRes(FT_AUTOTHOUSANDSSEPARATOR))
+ ,m_aThousandsSeparator (this, ModuleRes(CM_AUTOTHOUSANDSSEPARATOR))
+ ,m_aRowHeader (this, ModuleRes(CB_AUTOHEADER))
+ ,m_aCharSetHeader (this, ModuleRes(FL_DATACONVERT))
+ ,m_aCharSetLabel (this, ModuleRes(FT_CHARSET))
+ ,m_aCharSet (this, ModuleRes(LB_CHARSET))
+ ,m_aFieldSeparatorList (ModuleRes(STR_AUTOFIELDSEPARATORLIST))
+ ,m_aTextSeparatorList (ModuleRes(STR_AUTOTEXTSEPARATORLIST))
+ ,m_aTextNone (ModuleRes(STR_AUTOTEXT_FIELD_SEP_NONE))
+ ,m_nAvailableSections( _nAvailableSections )
+ {
+ DBG_CTOR(OTextConnectionHelper,NULL);
+
+ xub_StrLen nCnt = m_aFieldSeparatorList.GetTokenCount( '\t' );
+ xub_StrLen i;
+
+ for( i = 0 ; i < nCnt ; i += 2 )
+ m_aFieldSeparator.InsertEntry( m_aFieldSeparatorList.GetToken( i, '\t' ) );
+
+ nCnt = m_aTextSeparatorList.GetTokenCount( '\t' );
+ for( i=0 ; i<nCnt ; i+=2 )
+ m_aTextSeparator.InsertEntry( m_aTextSeparatorList.GetToken( i, '\t' ) );
+ m_aTextSeparator.InsertEntry(m_aTextNone);
+
+ // set the modify handlers
+ m_aFieldSeparator.SetUpdateDataHdl(getControlModifiedLink());
+ m_aFieldSeparator.SetSelectHdl(getControlModifiedLink());
+ m_aTextSeparator.SetUpdateDataHdl(getControlModifiedLink());
+ m_aTextSeparator.SetSelectHdl(getControlModifiedLink());
+ m_aCharSet.SetSelectHdl(getControlModifiedLink());
+
+ m_aFieldSeparator.SetModifyHdl(getControlModifiedLink());
+ m_aTextSeparator.SetModifyHdl(getControlModifiedLink());
+ m_aDecimalSeparator.SetModifyHdl(getControlModifiedLink());
+ m_aThousandsSeparator.SetModifyHdl(getControlModifiedLink());
+ m_aETOwnExtension.SetModifyHdl(LINK(this, OTextConnectionHelper, OnEditModified));
+ m_aRBAccessTextFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
+ m_aRBAccessCSVFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
+ m_aRBAccessOtherFiles.SetToggleHdl(LINK(this, OTextConnectionHelper, OnSetExtensionHdl));
+ m_aRBAccessCSVFiles.Check(sal_True);
+
+ struct SectionDescriptor
+ {
+ short nFlag;
+ Window* pFirstControl;
+ } aSections[] = {
+ { TC_EXTENSION, &m_aFTExtensionHeader },
+ { TC_SEPARATORS, &m_aLineFormat },
+ { TC_HEADER, &m_aRowHeader },
+ { TC_CHARSET, &m_aCharSetHeader },
+ { 0, NULL }
+ };
+
+ for ( size_t section=0; section < SAL_N_ELEMENTS( aSections ) - 1; ++section )
+ {
+ if ( ( m_nAvailableSections & aSections[section].nFlag ) != 0 )
+ {
+ // the section is visible, no need to do anything here
+ continue;
+ }
+
+ Window* pThisSection = aSections[section].pFirstControl;
+ Window* pNextSection = aSections[section+1].pFirstControl;
+
+ // hide all elements from this section
+ Window* pControl = pThisSection;
+ while ( ( pControl != pNextSection ) && pControl )
+ {
+ Window* pRealWindow = pControl->GetWindow( WINDOW_CLIENT );
+ #if OSL_DEBUG_LEVEL > 0
+ String sWindowText( pRealWindow->GetText() );
+ (void)sWindowText;
+ #endif
+ pRealWindow->Hide();
+ pControl = pControl->GetWindow( WINDOW_NEXT );
+ }
+
+ // move all controls in following sections up
+ if ( !pNextSection )
+ continue;
+ const long nThisSectionStart = pThisSection->GetPosPixel().Y();
+ const long nNextSectionStart = pNextSection->GetPosPixel().Y();
+ const long nMoveOffset( nThisSectionStart - nNextSectionStart );
+ while ( pControl )
+ {
+ Point aPos = pControl->GetPosPixel();
+ aPos.Move( 0, nMoveOffset );
+ pControl->SetPosPixel( aPos );
+ pControl = pControl->GetWindow( WINDOW_NEXT );
+ }
+ }
+
+ Rectangle aControlRectUnion;
+ for ( Window* pControl = aSections[0].pFirstControl;
+ pControl != NULL;
+ pControl = pControl->GetWindow( WINDOW_NEXT )
+ )
+ {
+ aControlRectUnion = aControlRectUnion.Union( Rectangle( pControl->GetPosPixel(), pControl->GetSizePixel() ) );
+ }
+
+ // need some adjustments to the positions, since the resource-specified
+ // positions for the control were relative to *our* parent, while by now
+ // the controls have |this| as parent.
+
+ // first, move ourself to the upper left of the area occupied by all controls
+ SetPosPixel( aControlRectUnion.TopLeft() );
+
+ // then, compensate in the control positions, by moving them the up/left
+ for ( Window* pControl = aSections[0].pFirstControl;
+ pControl != NULL;
+ pControl = pControl->GetWindow( WINDOW_NEXT )
+ )
+ {
+ Point aPos( pControl->GetPosPixel() );
+ aPos.Move( -aControlRectUnion.Left(), -aControlRectUnion.Top() );
+ pControl->SetPosPixel( aPos );
+
+ // while we are here ... the controls should not have an own background
+ // (this would not be needed when our outer dialog were also the parent
+ // of the controls)
+ pControl->SetBackground();
+ }
+
+ // now, change our own size so all controls fit
+ SetSizePixel( aControlRectUnion.GetSize() );
+
+ SetBackground();
+ Show();
+ }
+
+ // -----------------------------------------------------------------------
+ OTextConnectionHelper::~OTextConnectionHelper()
+ {
+
+ DBG_DTOR(OTextConnectionHelper,NULL);
+ }
+
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OTextConnectionHelper, OnControlModified, Control*, /*EMPTYARG*/)
+ {
+ callModifiedHdl();
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OTextConnectionHelper, OnEditModified, Edit*, /*_pEdit*/)
+ {
+ m_aGetExtensionHandler.Call(this);
+ return 0L;
+ }
+
+
+ IMPL_LINK(OTextConnectionHelper, OnSetExtensionHdl, RadioButton*, /*_pRadioButton*/)
+ {
+ sal_Bool bDoEnable = m_aRBAccessOtherFiles.IsChecked();
+ m_aETOwnExtension.Enable(bDoEnable);
+ m_aFTExtensionExample.Enable(bDoEnable);
+ m_aGetExtensionHandler.Call(this);
+ return 0L;
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OTextConnectionHelper::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aFieldSeparator));
+ _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aTextSeparator));
+ _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aDecimalSeparator));
+ _rControlList.push_back(new OSaveValueWrapper<ComboBox>(&m_aThousandsSeparator));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aRowHeader));
+ _rControlList.push_back(new OSaveValueWrapper<ListBox>(&m_aCharSet));
+ }
+ // -----------------------------------------------------------------------
+ void OTextConnectionHelper::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFieldSeparatorLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTextSeparatorLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDecimalSeparatorLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aThousandsSeparatorLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aCharSetHeader));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aCharSetLabel));
+ _rControlList.push_back(new ODisableWrapper<ListBox>(&m_aCharSet));
+ }
+
+ // -----------------------------------------------------------------------
+ void OTextConnectionHelper::implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid)
+ {
+ if ( !_bValid )
+ return;
+
+ SFX_ITEMSET_GET( _rSet, pDelItem, SfxStringItem, DSID_FIELDDELIMITER, sal_True );
+ SFX_ITEMSET_GET( _rSet, pStrItem, SfxStringItem, DSID_TEXTDELIMITER, sal_True );
+ SFX_ITEMSET_GET( _rSet, pDecdelItem, SfxStringItem, DSID_DECIMALDELIMITER, sal_True );
+ SFX_ITEMSET_GET( _rSet, pThodelItem, SfxStringItem, DSID_THOUSANDSDELIMITER, sal_True );
+ SFX_ITEMSET_GET( _rSet, pExtensionItem, SfxStringItem, DSID_TEXTFILEEXTENSION, sal_True );
+ SFX_ITEMSET_GET( _rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True );
+
+ if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
+ {
+ m_aOldExtension = pExtensionItem->GetValue();
+ SetExtension( m_aOldExtension );
+ }
+
+ if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
+ {
+ SFX_ITEMSET_GET( _rSet, pHdrItem, SfxBoolItem, DSID_TEXTFILEHEADER, sal_True );
+ m_aRowHeader.Check( pHdrItem->GetValue() );
+ }
+
+ if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
+ {
+ SetSeparator( m_aFieldSeparator, m_aFieldSeparatorList, pDelItem->GetValue() );
+ SetSeparator( m_aTextSeparator, m_aTextSeparatorList, pStrItem->GetValue() );
+ m_aDecimalSeparator.SetText( pDecdelItem->GetValue() );
+ m_aThousandsSeparator.SetText( pThodelItem->GetValue() );
+ }
+
+ if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
+ {
+ m_aCharSet.SelectEntryByIanaName( pCharsetItem->GetValue() );
+ }
+ }
+
+
+
+ // -----------------------------------------------------------------------
+ sal_Bool OTextConnectionHelper::prepareLeave()
+ {
+ LocalResourceAccess aStringResAccess(PAGE_TEXT, RSC_TABPAGE);
+ // for accessing the strings which are local to our own resource block
+ String sExtension = GetExtension();
+ String aErrorText;
+ Control* pErrorWin = NULL;
+ // if (!m_aFieldSeparator.GetText().Len())
+ // if this line is compiled under OS2 (in a product environent)
+ // -> use a temporary variable
+ String aDelText(m_aFieldSeparator.GetText());
+ if(!aDelText.Len())
+ { // Kein FeldTrenner
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
+ aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
+ pErrorWin = &m_aFieldSeparator;
+ }
+ else if (!m_aDecimalSeparator.GetText().Len())
+ { // kein Decimaltrenner
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MISSING));
+ aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
+ pErrorWin = &m_aDecimalSeparator;
+ }
+ else if (m_aTextSeparator.GetText() == m_aFieldSeparator.GetText())
+ { // Feld und TextTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aFieldSeparatorLabel.GetText());
+ pErrorWin = &m_aTextSeparator;
+ }
+ else if (m_aDecimalSeparator.GetText() == m_aThousandsSeparator.GetText())
+ { // Tausender und DecimalTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aDecimalSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
+ pErrorWin = &m_aDecimalSeparator;
+ }
+ else if (m_aFieldSeparator.GetText() == m_aThousandsSeparator.GetText())
+ { // Tausender und FeldTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
+ pErrorWin = &m_aFieldSeparator;
+ }
+ else if (m_aFieldSeparator.GetText() == m_aDecimalSeparator.GetText())
+ { // Zehner und FeldTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aFieldSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
+ pErrorWin = &m_aFieldSeparator;
+ }
+ else if (m_aTextSeparator.GetText() == m_aThousandsSeparator.GetText())
+ { // Tausender und TextTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aThousandsSeparatorLabel.GetText());
+ pErrorWin = &m_aTextSeparator;
+ }
+ else if (m_aTextSeparator.GetText() == m_aDecimalSeparator.GetText())
+ { // Zehner und TextTrenner duerfen nicht gleich sein
+ aErrorText = String(ModuleRes(STR_AUTODELIMITER_MUST_DIFFER));
+ aErrorText.SearchAndReplaceAscii("#1",m_aTextSeparatorLabel.GetText());
+ aErrorText.SearchAndReplaceAscii("#2",m_aDecimalSeparatorLabel.GetText());
+ pErrorWin = &m_aTextSeparator;
+ }
+ else if ((sExtension.Search('*') != STRING_NOTFOUND) || (sExtension.Search('?') != STRING_NOTFOUND))
+ {
+ aErrorText = String(ModuleRes(STR_AUTONO_WILDCARDS));
+ aErrorText.SearchAndReplaceAscii("#1",sExtension);
+ pErrorWin = &m_aETOwnExtension;
+ }
+ else
+ return sal_True;
+ ErrorBox(NULL, WB_OK, MnemonicGenerator::EraseAllMnemonicChars( aErrorText)).Execute();
+ pErrorWin->GrabFocus();
+ return 0;
+ }
+
+
+ // -----------------------------------------------------------------------
+ sal_Bool OTextConnectionHelper::FillItemSet( SfxItemSet& rSet, const sal_Bool _bChangedSomething )
+ {
+ sal_Bool bChangedSomething = _bChangedSomething;
+
+ if ( ( m_nAvailableSections & TC_EXTENSION ) != 0 )
+ {
+ String sExtension = GetExtension();
+ if( !m_aOldExtension.Equals( sExtension ) )
+ {
+ rSet.Put( SfxStringItem( DSID_TEXTFILEEXTENSION, sExtension ) );
+ bChangedSomething = sal_True;
+ }
+ }
+
+ if ( ( m_nAvailableSections & TC_HEADER ) != 0 )
+ {
+ if( (m_aRowHeader.GetState() != m_aRowHeader.GetSavedValue()) )
+ {
+ rSet.Put(SfxBoolItem(DSID_TEXTFILEHEADER, m_aRowHeader.IsChecked()));
+ bChangedSomething = sal_True;
+ }
+ }
+
+ if ( ( m_nAvailableSections & TC_SEPARATORS ) != 0 )
+ {
+ if( m_aFieldSeparator.GetText() != m_aFieldSeparator.GetSavedValue() )
+ {
+ rSet.Put( SfxStringItem(DSID_FIELDDELIMITER, GetSeparator( m_aFieldSeparator, m_aFieldSeparatorList) ) );
+ bChangedSomething = sal_True;
+ }
+ if( m_aTextSeparator.GetText() != m_aTextSeparator.GetSavedValue() )
+ {
+ rSet.Put( SfxStringItem(DSID_TEXTDELIMITER, GetSeparator( m_aTextSeparator, m_aTextSeparatorList) ) );
+ bChangedSomething = sal_True;
+ }
+
+ if( m_aDecimalSeparator.GetText() != m_aDecimalSeparator.GetSavedValue() )
+ {
+ rSet.Put( SfxStringItem(DSID_DECIMALDELIMITER, m_aDecimalSeparator.GetText().Copy(0, 1) ) );
+ bChangedSomething = sal_True;
+ }
+ if( m_aThousandsSeparator.GetText() != m_aThousandsSeparator.GetSavedValue() )
+ {
+ rSet.Put( SfxStringItem(DSID_THOUSANDSDELIMITER, m_aThousandsSeparator.GetText().Copy(0,1) ) );
+ bChangedSomething = sal_True;
+ }
+ }
+
+ if ( ( m_nAvailableSections & TC_CHARSET ) != 0 )
+ {
+ if ( m_aCharSet.StoreSelectedCharSet( rSet, DSID_CHARSET ) )
+ bChangedSomething = sal_True;
+ }
+
+ return bChangedSomething;
+ }
+
+
+ void OTextConnectionHelper::SetExtension(const String& _rVal)
+ {
+ if (_rVal.EqualsAscii("txt"))
+ m_aRBAccessTextFiles.Check(sal_True);
+ else if (_rVal.EqualsAscii( "csv" ))
+ m_aRBAccessCSVFiles.Check(sal_True);
+ else
+ {
+ m_aRBAccessOtherFiles.Check(sal_True);
+ m_aFTExtensionExample.SetText(_rVal);
+ }
+ }
+
+
+ String OTextConnectionHelper::GetExtension()
+ {
+ String sExtension;
+ if (m_aRBAccessTextFiles.IsChecked())
+ sExtension = String::CreateFromAscii("txt");
+ else if (m_aRBAccessCSVFiles.IsChecked())
+ sExtension = String::CreateFromAscii("csv");
+ else
+ {
+ sExtension = m_aETOwnExtension.GetText();
+ if ( sExtension.GetToken(0,'.').Equals('*') )
+ sExtension.Erase(0,2);
+ }
+ return sExtension;
+ }
+
+
+ //------------------------------------------------------------------------
+ String OTextConnectionHelper::GetSeparator( const ComboBox& rBox, const String& rList )
+ {
+ sal_Unicode nTok = '\t';
+ xub_StrLen nPos(rBox.GetEntryPos( rBox.GetText() ));
+
+ if( nPos == COMBOBOX_ENTRY_NOTFOUND )
+ return rBox.GetText().Copy(0);
+
+ if ( !( &m_aTextSeparator == &rBox && nPos == (rBox.GetEntryCount()-1) ) )
+ return String(
+ static_cast< sal_Unicode >(
+ rList.GetToken(((nPos*2)+1), nTok ).ToInt32()));
+ // somewhat strange ... translates for instance an "32" into " "
+ return String();
+ }
+
+ //------------------------------------------------------------------------
+ void OTextConnectionHelper::SetSeparator( ComboBox& rBox, const String& rList, const String& rVal )
+ {
+ char nTok = '\t';
+ xub_StrLen nCnt(rList.GetTokenCount( nTok ));
+ xub_StrLen i;
+
+ for( i=0 ; i<nCnt ; i+=2 )
+ {
+ String sTVal(
+ static_cast< sal_Unicode >(
+ rList.GetToken( (i+1), nTok ).ToInt32()));
+
+ if( sTVal == rVal )
+ {
+ rBox.SetText( rList.GetToken( i, nTok ) );
+ break;
+ }
+ }
+
+ if ( i >= nCnt )
+ {
+ if ( &m_aTextSeparator == &rBox && !rVal.Len() )
+ rBox.SetText(m_aTextNone);
+ else
+ rBox.SetText( rVal.Copy(0, 1) );
+ }
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.hxx b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx
new file mode 100644
index 000000000000..8c1d0aa0c0fd
--- /dev/null
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_TEXTCONNECTIONHELPER_HXX
+#define DBAUI_TEXTCONNECTIONHELPER_HXX
+
+#include "ConnectionPageSetup.hxx"
+#include "adminpages.hxx"
+#include "charsetlistbox.hxx"
+#include <ucbhelper/content.hxx>
+#include "curledit.hxx"
+#include <svtools/roadmapwizard.hxx>
+#include <vcl/field.hxx>
+#include <rtl/ustring.hxx>
+#include <vcl/lstbox.hxx>
+
+
+//.........................................................................
+namespace dbaui
+
+{
+//.........................................................................
+
+ #define TC_EXTENSION ((short)0x01) // a section specifying the extension of the files to connect to
+ #define TC_SEPARATORS ((short)0x02) // a section specifying the various separators
+ #define TC_HEADER ((short)0x04) // a section containing the "Text contains header" check box only
+ #define TC_CHARSET ((short)0x08) // not yet implemented
+
+ //========================================================================
+ //= OTextConnectionPage
+ //========================================================================
+ class OTextConnectionHelper : public Control
+ {
+ OTextConnectionHelper();
+
+ Link m_aModifiedHandler; /// to be called if something on the page has been modified
+
+ public:
+ OTextConnectionHelper( Window* pParent, const short _nAvailableSections );
+ virtual ~OTextConnectionHelper();
+
+ private:
+ FixedText m_aFTExtensionHeader;
+ RadioButton m_aRBAccessTextFiles;
+ RadioButton m_aRBAccessCSVFiles;
+ RadioButton m_aRBAccessOtherFiles;
+ Edit m_aETOwnExtension;
+ FixedText m_aFTExtensionExample;
+ FixedLine m_aLineFormat;
+ FixedText m_aFieldSeparatorLabel;
+ ComboBox m_aFieldSeparator;
+ FixedText m_aTextSeparatorLabel;
+ ComboBox m_aTextSeparator;
+ FixedText m_aDecimalSeparatorLabel;
+ ComboBox m_aDecimalSeparator;
+ FixedText m_aThousandsSeparatorLabel;
+ ComboBox m_aThousandsSeparator;
+ CheckBox m_aRowHeader;
+ FixedLine m_aCharSetHeader;
+ FixedText m_aCharSetLabel;
+ CharSetListBox m_aCharSet;
+ String m_aFieldSeparatorList;
+ String m_aTextSeparatorList;
+ String m_aTextNone;
+ String m_aOldExtension;
+ Link m_aGetExtensionHandler; /// to be called if a new type is selected
+
+ short m_nAvailableSections;
+
+ protected:
+ void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }
+ Link getControlModifiedLink() { return LINK(this, OTextConnectionHelper, OnControlModified); }
+ DECL_LINK(OnSetExtensionHdl,RadioButton*);
+ DECL_LINK(OnControlModified,Control*);
+ DECL_LINK(OnEditModified,Edit*);
+
+ private:
+ String GetSeparator( const ComboBox& rBox, const String& rList );
+ void SetSeparator( ComboBox& rBox, const String& rList, const String& rVal );
+ void SetExtension(const String& _rVal);
+
+
+ public:
+ void implInitControls(const SfxItemSet& _rSet, sal_Bool _bValid);
+ void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ void SetClickHandler(const Link& _rHandler) { m_aGetExtensionHandler = _rHandler; }
+ String GetExtension();
+ sal_Bool FillItemSet( SfxItemSet& rSet, const sal_Bool bChangedSomething );
+ sal_Bool prepareLeave();
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBWIZ2_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx
new file mode 100644
index 000000000000..d22e8c4839a7
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.cxx
@@ -0,0 +1,354 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "UserAdmin.hxx"
+#include "UserAdmin.hrc"
+#include "UITools.hxx"
+#include "dbu_dlg.hrc"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <ucbhelper/interactionrequest.hxx>
+#include <ucbhelper/simpleauthenticationrequest.hxx>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbcx/XUser.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include "dbustrings.hrc"
+#include <tools/debug.hxx>
+#include "dbadmin.hxx"
+#include "moduledbu.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/passwd.hxx>
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace dbaui;
+using namespace ucbhelper;
+using namespace comphelper;
+
+
+class OPasswordDialog : public ModalDialog
+{
+ FixedLine aFLUser;
+ FixedText aFTOldPassword;
+ Edit aEDOldPassword;
+ FixedText aFTPassword;
+ Edit aEDPassword;
+ FixedText aFTPasswordRepeat;
+ Edit aEDPasswordRepeat;
+ OKButton aOKBtn;
+ CancelButton aCancelBtn;
+ HelpButton aHelpBtn;
+
+
+ DECL_LINK( OKHdl_Impl, OKButton * );
+ DECL_LINK( ModifiedHdl, Edit * );
+
+public:
+ OPasswordDialog( Window* pParent,const String& _sUserName);
+
+ String GetOldPassword() const { return aEDOldPassword.GetText(); }
+ String GetNewPassword() const { return aEDPassword.GetText(); }
+};
+
+OPasswordDialog::OPasswordDialog(Window* _pParent,const String& _sUserName) :
+
+ ModalDialog( _pParent, ModuleRes( DLG_PASSWORD) ),
+
+ aFLUser ( this, ModuleRes( FL_USER ) ),
+ aFTOldPassword ( this, ModuleRes( FT_OLDPASSWORD ) ),
+ aEDOldPassword ( this, ModuleRes( ED_OLDPASSWORD ) ),
+ aFTPassword ( this, ModuleRes( FT_PASSWORD ) ),
+ aEDPassword ( this, ModuleRes( ED_PASSWORD ) ),
+ aFTPasswordRepeat ( this, ModuleRes( FT_PASSWORD_REPEAT ) ),
+ aEDPasswordRepeat ( this, ModuleRes( ED_PASSWORD_REPEAT ) ),
+ aOKBtn ( this, ModuleRes( BTN_PASSWORD_OK ) ),
+ aCancelBtn ( this, ModuleRes( BTN_PASSWORD_CANCEL ) ),
+ aHelpBtn ( this, ModuleRes( BTN_PASSWORD_HELP ) )
+{
+ // hide until a help is avalable
+ aHelpBtn.Hide();
+
+ FreeResource();
+ String sUser = aFLUser.GetText();
+ sUser.SearchAndReplaceAscii("$name$: $",_sUserName);
+ aFLUser.SetText(sUser);
+ aOKBtn.Disable();
+
+ aOKBtn.SetClickHdl( LINK( this, OPasswordDialog, OKHdl_Impl ) );
+ aEDOldPassword.SetModifyHdl( LINK( this, OPasswordDialog, ModifiedHdl ) );
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OPasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG )
+{
+ if( aEDPassword.GetText() == aEDPasswordRepeat.GetText() )
+ EndDialog( RET_OK );
+ else
+ {
+ String aErrorMsg( ModuleRes( STR_ERROR_PASSWORDS_NOT_IDENTICAL));
+ ErrorBox aErrorBox( this, WB_OK, aErrorMsg );
+ aErrorBox.Execute();
+ aEDPassword.SetText( String() );
+ aEDPasswordRepeat.SetText( String() );
+ aEDPassword.GrabFocus();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( OPasswordDialog, ModifiedHdl, Edit *, pEdit )
+{
+ aOKBtn.Enable(pEdit->GetText().Len() != 0);
+ return 0;
+}
+
+DBG_NAME(OUserAdmin);
+//================================================================================
+// OUserAdmin
+//================================================================================
+OUserAdmin::OUserAdmin(Window* pParent,const SfxItemSet& _rAttrSet)
+ : OGenericAdministrationPage( pParent, ModuleRes(TAB_PAGE_USERADMIN), _rAttrSet)
+ ,m_FL_USER( this , ModuleRes(FL_USER))
+ ,m_FT_USER( this , ModuleRes(FT_USER))
+ ,m_LB_USER( this , ModuleRes(LB_USER))
+ ,m_PB_NEWUSER( this , ModuleRes(PB_NEWUSER))
+ ,m_PB_CHANGEPWD( this , ModuleRes(PB_CHANGEPWD))
+ ,m_PB_DELETEUSER( this , ModuleRes(PB_DELETEUSER))
+ ,m_FL_TABLE_GRANTS( this , ModuleRes(FL_TABLE_GRANTS))
+ ,m_TableCtrl( this , ModuleRes(CTRL_TABLE_GRANTS))
+{
+ DBG_CTOR(OUserAdmin,NULL);
+ m_LB_USER.SetSelectHdl(LINK(this, OUserAdmin, ListDblClickHdl));
+
+ m_PB_NEWUSER.SetClickHdl(LINK(this, OUserAdmin, UserHdl));
+ m_PB_CHANGEPWD.SetClickHdl(LINK(this, OUserAdmin, UserHdl));
+ m_PB_DELETEUSER.SetClickHdl(LINK(this, OUserAdmin, UserHdl));
+
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OUserAdmin::~OUserAdmin()
+{
+ DBG_DTOR(OUserAdmin,NULL);
+ m_xConnection = NULL;
+}
+// -----------------------------------------------------------------------
+void OUserAdmin::FillUserNames()
+{
+ if(m_xConnection.is())
+ {
+ m_LB_USER.Clear();
+
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+
+ if ( xMetaData.is() )
+ {
+ m_UserName = xMetaData->getUserName();
+
+ // first we need the users
+ if ( m_xUsers.is() )
+ {
+ m_LB_USER.Clear();
+
+ m_aUserNames = m_xUsers->getElementNames();
+ const ::rtl::OUString* pBegin = m_aUserNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + m_aUserNames.getLength();
+ ::rtl::OUString sUserName = m_UserName;
+ for(;pBegin != pEnd;++pBegin)
+ m_LB_USER.InsertEntry(*pBegin);
+
+ m_LB_USER.SelectEntryPos(0);
+ if(m_xUsers->hasByName(m_UserName))
+ {
+ Reference<XAuthorizable> xAuth;
+ m_xUsers->getByName(m_UserName) >>= xAuth;
+ m_TableCtrl.setGrantUser(xAuth);
+ }
+
+ m_TableCtrl.setUserName(GetUser());
+ m_TableCtrl.Init();
+ }
+ }
+ }
+
+ Reference<XAppend> xAppend(m_xUsers,UNO_QUERY);
+ m_PB_NEWUSER.Enable(xAppend.is());
+ Reference<XDrop> xDrop(m_xUsers,UNO_QUERY);
+ m_PB_DELETEUSER.Enable(xDrop.is());
+
+ m_PB_CHANGEPWD.Enable(m_xUsers.is());
+ m_TableCtrl.Enable(m_xUsers.is());
+
+}
+// -----------------------------------------------------------------------
+SfxTabPage* OUserAdmin::Create( Window* pParent, const SfxItemSet& _rAttrSet )
+{
+ return ( new OUserAdmin( pParent, _rAttrSet ) );
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OUserAdmin, UserHdl, PushButton *, pButton )
+{
+ try
+ {
+ if(pButton == &m_PB_NEWUSER)
+ {
+ SfxPasswordDialog aPwdDlg(this);
+ aPwdDlg.ShowExtras(SHOWEXTRAS_ALL);
+ if(aPwdDlg.Execute())
+ {
+ Reference<XDataDescriptorFactory> xUserFactory(m_xUsers,UNO_QUERY);
+ Reference<XPropertySet> xNewUser = xUserFactory->createDataDescriptor();
+ if(xNewUser.is())
+ {
+ xNewUser->setPropertyValue(PROPERTY_NAME,makeAny(rtl::OUString(aPwdDlg.GetUser())));
+ xNewUser->setPropertyValue(PROPERTY_PASSWORD,makeAny(rtl::OUString(aPwdDlg.GetPassword())));
+ Reference<XAppend> xAppend(m_xUsers,UNO_QUERY);
+ if(xAppend.is())
+ xAppend->appendByDescriptor(xNewUser);
+ }
+ }
+ }
+ else if(pButton == &m_PB_CHANGEPWD)
+ {
+ String sName = GetUser();
+
+ if(m_xUsers->hasByName(sName))
+ {
+ Reference<XUser> xUser;
+ m_xUsers->getByName(sName) >>= xUser;
+ if(xUser.is())
+ {
+ ::rtl::OUString sNewPassword,sOldPassword;
+ OPasswordDialog aDlg(this,sName);
+ if(aDlg.Execute() == RET_OK)
+ {
+ sNewPassword = aDlg.GetNewPassword();
+ sOldPassword = aDlg.GetOldPassword();
+
+ if(sNewPassword.getLength())
+ xUser->changePassword(sOldPassword,sNewPassword);
+ }
+ }
+ }
+ }
+ else
+ {// delete user
+ if(m_xUsers.is() && m_xUsers->hasByName(GetUser()))
+ {
+ Reference<XDrop> xDrop(m_xUsers,UNO_QUERY);
+ if(xDrop.is())
+ {
+ QueryBox aQry(this, ModuleRes(QUERY_USERADMIN_DELETE_USER));
+ if(aQry.Execute() == RET_YES)
+ xDrop->dropByName(GetUser());
+ }
+ }
+ }
+ FillUserNames();
+ }
+ catch(SQLException& e)
+ {
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,m_xORB);
+ return 0;
+ }
+ catch(Exception& )
+ {
+ return 0;
+ }
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OUserAdmin, ListDblClickHdl, ListBox *, /*pListBox*/ )
+{
+ m_TableCtrl.setUserName(GetUser());
+ m_TableCtrl.UpdateTables();
+ m_TableCtrl.DeactivateCell();
+ m_TableCtrl.ActivateCell(m_TableCtrl.GetCurRow(),m_TableCtrl.GetCurColumnId());
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+String OUserAdmin::GetUser()
+{
+ return m_LB_USER.GetSelectEntry();
+}
+// -----------------------------------------------------------------------------
+void OUserAdmin::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+{
+}
+// -----------------------------------------------------------------------
+void OUserAdmin::fillWindows(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+{
+}
+// -----------------------------------------------------------------------------
+void OUserAdmin::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+{
+ m_TableCtrl.setORB(m_xORB);
+ try
+ {
+ if ( !m_xConnection.is() && m_pAdminDialog )
+ {
+ m_xConnection = m_pAdminDialog->createConnection().first;
+ Reference< XTablesSupplier > xTablesSup(m_xConnection,UNO_QUERY);
+ Reference<XUsersSupplier> xUsersSup(xTablesSup,UNO_QUERY);
+ if ( !xUsersSup.is() )
+ {
+ Reference< XDataDefinitionSupplier > xDriver(m_pAdminDialog->getDriver(),UNO_QUERY);
+ if ( xDriver.is() )
+ {
+ xUsersSup.set(xDriver->getDataDefinitionByConnection(m_xConnection),UNO_QUERY);
+ xTablesSup.set(xUsersSup,UNO_QUERY);
+ }
+ }
+ if ( xUsersSup.is() )
+ {
+ m_TableCtrl.setTablesSupplier(xTablesSup);
+ m_xUsers = xUsersSup->getUsers();
+ }
+ }
+ FillUserNames();
+ }
+ catch(SQLException& e)
+ {
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),this,m_xORB);
+ }
+
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/UserAdmin.hrc b/dbaccess/source/ui/dlg/UserAdmin.hrc
new file mode 100644
index 000000000000..6a012724f49a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.hrc
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_USERADMIN_HRC
+#define DBAUI_USERADMIN_HRC
+
+#define FT_USER 1
+
+#define LB_USER 1
+
+#define NF_TIMEOUT 1
+
+#define FL_TABLE_GRANTS 1
+#define FL_USER 2
+
+#define CTRL_TABLE_GRANTS 1
+
+#define PB_NEWUSER 2
+#define PB_CHANGEPWD 3
+#define PB_DELETEUSER 4
+
+
+
+#define FT_OLDPASSWORD 19
+#define ED_OLDPASSWORD 19
+#define FT_PASSWORD 20
+#define ED_PASSWORD 21
+#define FT_PASSWORD_REPEAT 22
+#define ED_PASSWORD_REPEAT 23
+
+#define BTN_PASSWORD_OK 50
+#define BTN_PASSWORD_CANCEL 51
+#define BTN_PASSWORD_HELP 52
+
+
+#endif // DBAUI_USERADMIN_HRC
diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx
new file mode 100644
index 000000000000..73458126dbb1
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_USERADMIN_HXX
+#define DBAUI_USERADMIN_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/group.hxx>
+#include "TableGrantCtrl.hxx"
+#include "adminpages.hxx"
+#include <comphelper/uno3.hxx>
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+namespace dbaui
+{
+
+class OUserAdmin : public OGenericAdministrationPage
+{
+protected:
+ FixedLine m_FL_USER;
+ FixedText m_FT_USER;
+ ListBox m_LB_USER;
+ PushButton m_PB_NEWUSER;
+ PushButton m_PB_CHANGEPWD;
+ PushButton m_PB_DELETEUSER;
+ FixedLine m_FL_TABLE_GRANTS;
+ OTableGrantControl m_TableCtrl; // show the grant rights of one user
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aUserNames;
+
+ String m_UserName;
+
+ // methods
+ DECL_LINK( ListDblClickHdl, ListBox * );
+ DECL_LINK( CloseHdl, PushButton * );
+ DECL_LINK( UserHdl, PushButton * );
+
+ void FillUserNames();
+
+ OUserAdmin( Window* pParent, const SfxItemSet& _rCoreAttrs);
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet );
+
+ ~OUserAdmin();
+ String GetUser();
+
+ // must be overloaded by subclasses, but it isn't pure virtual
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+};
+}
+#endif // DBAUI_USERADMIN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/UserAdmin.src b/dbaccess/source/ui/dlg/UserAdmin.src
new file mode 100644
index 000000000000..74c8c1ed8098
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdmin.src
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_USERADMIN_HRC
+#include "UserAdmin.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#define WINDOW_SIZE_X 260
+#define WINDOW_SIZE_Y 185
+
+TabPage TAB_PAGE_USERADMIN
+{
+ SVLook = TRUE ;
+ HelpId = HID_TAB_PAGE_USERADMIN ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Hide = TRUE;
+
+ FixedLine FL_USER
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8, 8) ;
+ Text [ en-US ] = "User selection";
+ };
+
+ FixedText FT_USER
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "Us~er:";
+ };
+
+ ListBox LB_USER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 108 , 13) ;
+ Size = MAP_APPFONT ( 105 , 97 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE ;
+ Sort = TRUE ;
+ DropDown = TRUE ;
+ HelpId = HID_TAB_PAGE_LBUSER ;
+ };
+
+ PushButton PB_NEWUSER
+ {
+ Pos = MAP_APPFONT ( 12 , 29 ) ;
+ Size = MAP_APPFONT ( 70 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ HelpId = HID_TAB_PAGE_PBUSER ;
+ Text [ en-US ] = "~Add User...";
+ };
+
+ PushButton PB_CHANGEPWD
+ {
+ Pos = MAP_APPFONT ( 95 , 29 ) ;
+ Size = MAP_APPFONT ( 70 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ HelpId = HID_TAB_PAGE_PBCHGPWD ;
+ Text [ en-US ] = "Change ~Password...";
+ };
+
+ PushButton PB_DELETEUSER
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 82 , 29 ) ;
+ Size = MAP_APPFONT ( 70 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ HelpId = HID_TAB_PAGE_PBUSERDELETE ;
+ Text [ en-US ] = "~Delete User...";
+ };
+
+ FixedLine FL_TABLE_GRANTS
+ {
+ Pos = MAP_APPFONT ( 6 , 52 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8, 8) ;
+ Text [ en-US ] = "Access rights for selected user";
+ };
+
+ Control CTRL_TABLE_GRANTS
+ {
+ Pos = MAP_APPFONT ( 12 , 63 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 22, WINDOW_SIZE_Y - 75 );
+ Border = TRUE ;
+ TabStop = TRUE ;
+ HelpId = HID_TAB_PAGE_TBLGRANTS ;
+ };
+};
+
+QueryBox QUERY_USERADMIN_DELETE_USER
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "Do you really want to delete the user?";
+};
+
+String STR_USERADMIN_NOT_AVAILABLE
+{
+ Text [ en-US ] = "The database does not support user administration." ;
+};
+
+#define EDIT_SIZE_X 50
+#define FT_SIZE_X 90
+#define WIN_X 220
+#define WIN_Y 72
+
+ModalDialog DLG_PASSWORD
+{
+ HelpId = HID_DLG_PASSWORD ;
+ Border = TRUE ;
+ Moveable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIN_X , WIN_Y ) ;
+
+ FixedLine FL_USER
+ {
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( WIN_X - 3 - 6 - 6 - 50 , 8 ) ;
+ Text [ en-US ] = "User \"$name$: $\"";
+ };
+ FixedText FT_OLDPASSWORD
+ {
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ;
+ Text [ en-US ] = "Old p~assword";
+ };
+ Edit ED_OLDPASSWORD
+ {
+ HelpID = "dbaccess:Edit:DLG_PASSWORD:ED_OLDPASSWORD";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 16 ) ;
+ Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ;
+ PassWord = TRUE ;
+ };
+
+ FixedText FT_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ;
+ Text [ en-US ] = "~Password";
+ };
+ Edit ED_PASSWORD
+ {
+ HelpID = "dbaccess:Edit:DLG_PASSWORD:ED_PASSWORD";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 34 ) ;
+ Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ;
+ PassWord = TRUE ;
+ };
+ FixedText FT_PASSWORD_REPEAT
+ {
+ Pos = MAP_APPFONT ( 6 , 52 ) ;
+ Size = MAP_APPFONT ( FT_SIZE_X , 10 ) ;
+ Text [ en-US ] = "~Confirm password";
+ };
+ Edit ED_PASSWORD_REPEAT
+ {
+ HelpID = "dbaccess:Edit:DLG_PASSWORD:ED_PASSWORD_REPEAT";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 51 ) ;
+ Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ;
+ PassWord = TRUE ;
+ };
+
+ OKButton BTN_PASSWORD_OK
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_PASSWORD_CANCEL
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_PASSWORD_HELP
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ Text [ en-US ] = "Change Password";
+};
+
+String STR_ERROR_PASSWORDS_NOT_IDENTICAL
+{
+ Text [ en-US ] = "The passwords do not match. Please enter the password again.";
+};
diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.cxx b/dbaccess/source/ui/dlg/UserAdminDlg.cxx
new file mode 100644
index 000000000000..553f5446ca86
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdminDlg.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "adminpages.hxx"
+#include "DbAdminImpl.hxx"
+#include "dbu_dlg.hrc"
+#include "DriverSettings.hxx"
+#include "dsitems.hxx"
+#include "propertysetitem.hxx"
+#include "UITools.hxx"
+#include "UserAdmin.hxx"
+#include "UserAdminDlg.hrc"
+#include "UserAdminDlg.hxx"
+
+#include <comphelper/componentcontext.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+
+ //========================================================================
+ //= OUserAdminDlg
+DBG_NAME(OUserAdminDlg)
+//========================================================================
+ OUserAdminDlg::OUserAdminDlg(Window* _pParent
+ , SfxItemSet* _pItems
+ ,const Reference< XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ ,const Reference< XConnection >& _xConnection)
+ :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_USERADMIN), _pItems)
+ ,m_pItemSet(_pItems)
+ ,m_xConnection(_xConnection)
+ ,m_bOwnConnection(!_xConnection.is())
+ {
+ DBG_CTOR(OUserAdminDlg,NULL);
+
+ m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this));
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ m_pImpl->translateProperties(xDatasource, *_pItems);
+ SetInputSet(_pItems);
+ // propagate this set as our new input set and reset the example set
+ delete pExampleSet;
+ pExampleSet = new SfxItemSet(*GetInputSetImpl());
+
+ AddTabPage(TAB_PAGE_USERADMIN, String(ModuleRes(STR_PAGETITLE_USERADMIN)), OUserAdmin::Create,0, sal_False, 1);
+
+ // remove the reset button - it's meaning is much too ambiguous in this dialog
+ RemoveResetButton();
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ OUserAdminDlg::~OUserAdminDlg()
+ {
+ if ( m_bOwnConnection )
+ {
+ try
+ {
+ ::comphelper::disposeComponent(m_xConnection);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ SetInputSet(NULL);
+ DELETEZ(pExampleSet);
+
+ DBG_DTOR(OUserAdminDlg,NULL);
+ }
+ // -----------------------------------------------------------------------
+ short OUserAdminDlg::Execute()
+ {
+ try
+ {
+ ::dbtools::DatabaseMetaData aMetaData( createConnection().first );
+ if ( !aMetaData.supportsUserAdministration( ::comphelper::ComponentContext( getORB() ) ) )
+ {
+ String sError(ModuleRes(STR_USERADMIN_NOT_AVAILABLE));
+ throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+ }
+ }
+ catch(const SQLException&)
+ {
+ ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), GetParent(), getORB() );
+ return RET_CANCEL;
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ short nRet = SfxTabDialog::Execute();
+ if ( nRet == RET_OK )
+ m_pImpl->saveChanges(*GetOutputItemSet());
+ return nRet;
+ }
+ //-------------------------------------------------------------------------
+ void OUserAdminDlg::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
+ {
+ // register ourself as modified listener
+ static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
+ static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
+
+ AdjustLayout();
+ Window *pWin = GetViewWindow();
+ if(pWin)
+ pWin->Invalidate();
+
+ SfxTabDialog::PageCreated(_nId, _rPage);
+ }
+ // -----------------------------------------------------------------------------
+ const SfxItemSet* OUserAdminDlg::getOutputSet() const
+ {
+ return m_pItemSet;
+ }
+ // -----------------------------------------------------------------------------
+ SfxItemSet* OUserAdminDlg::getWriteOutputSet()
+ {
+ return m_pItemSet;
+ }
+ // -----------------------------------------------------------------------------
+ ::std::pair< Reference<XConnection>,sal_Bool> OUserAdminDlg::createConnection()
+ {
+ if ( !m_xConnection.is() )
+ {
+ m_xConnection = m_pImpl->createConnection().first;
+ m_bOwnConnection = m_xConnection.is();
+ }
+ return ::std::pair< Reference<XConnection>,sal_Bool> (m_xConnection,sal_False);
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XMultiServiceFactory > OUserAdminDlg::getORB() const
+ {
+ return m_pImpl->getORB();
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XDriver > OUserAdminDlg::getDriver()
+ {
+ return m_pImpl->getDriver();
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OUserAdminDlg::getDatasourceType(const SfxItemSet& _rSet) const
+ {
+ return m_pImpl->getDatasourceType(_rSet);
+ }
+ // -----------------------------------------------------------------------------
+ void OUserAdminDlg::clearPassword()
+ {
+ m_pImpl->clearPassword();
+ }
+ // -----------------------------------------------------------------------------
+ void OUserAdminDlg::setTitle(const ::rtl::OUString& _sTitle)
+ {
+ SetText(_sTitle);
+ }
+ //-------------------------------------------------------------------------
+ void OUserAdminDlg::enableConfirmSettings( bool _bEnable )
+ {
+ (void)_bEnable;
+ }
+ //-------------------------------------------------------------------------
+ sal_Bool OUserAdminDlg::saveDatasource()
+ {
+ return PrepareLeaveCurrentPage();
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.hrc b/dbaccess/source/ui/dlg/UserAdminDlg.hrc
new file mode 100644
index 000000000000..c1e023cfc9b7
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdminDlg.hrc
@@ -0,0 +1,33 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_USERADMINDLG_HRC
+#define DBAUI_USERADMINDLG_HRC
+
+#define STR_PAGETITLE_USERADMIN 1
+
+
+#endif // DBAUI_USERADMINDLG_HRC
diff --git a/dbaccess/source/ui/dlg/UserAdminDlg.src b/dbaccess/source/ui/dlg/UserAdminDlg.src
new file mode 100644
index 000000000000..5b07b43093b5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/UserAdminDlg.src
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_USERADMINDLG_HRC
+#include "UserAdminDlg.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+TabDialog DLG_DATABASE_USERADMIN
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_USERADMIN;
+
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ HelpId = HID_DSADMIN_TABCONTROL;
+ };
+ String STR_PAGETITLE_USERADMIN
+ {
+ Text[ en-US ] = "User Settings";
+ };
+
+ Text [ en-US ] = "User administration" ;
+};
diff --git a/dbaccess/source/ui/dlg/admincontrols.cxx b/dbaccess/source/ui/dlg/admincontrols.cxx
new file mode 100644
index 000000000000..a8b11805dcb3
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.cxx
@@ -0,0 +1,314 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "admincontrols.hxx"
+#include "admincontrols.hrc"
+#include "dbu_dlg.hrc"
+#include "dsitems.hxx"
+#include "moduledbu.hxx"
+
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= TextResetOperatorEventFilter
+ //====================================================================
+ class TextResetOperatorEventFilter : public ::svt::IWindowEventFilter
+ {
+ public:
+ TextResetOperatorEventFilter()
+ {
+ }
+
+ // IWindowEventFilter
+ virtual bool payAttentionTo( const VclWindowEvent& _rEvent ) const
+ {
+ return ( _rEvent.GetId() == VCLEVENT_WINDOW_ENABLED )
+ || ( _rEvent.GetId() == VCLEVENT_WINDOW_DISABLED )
+ || ( _rEvent.GetId() == VCLEVENT_EDIT_MODIFY );
+ }
+ };
+
+ //====================================================================
+ //= TextResetOperator
+ //====================================================================
+ class TextResetOperator :public ::svt::IWindowOperator
+ {
+ public:
+ TextResetOperator( const String& _rDisabledText )
+ :m_sDisabledText( _rDisabledText )
+ {
+ }
+
+ // IWindowOperator
+ virtual void operateOn( const VclWindowEvent& _rTrigger, Window& _rOperateOn ) const;
+
+ private:
+ const String m_sDisabledText;
+ String m_sUserText;
+ sal_Bool m_bLastKnownEnabledState;
+ };
+
+ //--------------------------------------------------------------------
+ void TextResetOperator::operateOn( const VclWindowEvent& _rTrigger, Window& _rOperateOn ) const
+ {
+ OSL_ENSURE( _rTrigger.GetWindow() == &_rOperateOn, "TextResetOperator::operateOn: you're misusing this implementation!" );
+
+ switch ( _rTrigger.GetId() )
+ {
+ case 0:
+ // initial call
+ const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText();
+ break;
+
+ case VCLEVENT_EDIT_MODIFY:
+ if ( _rTrigger.GetWindow()->IsEnabled() )
+ const_cast< TextResetOperator* >( this )->m_sUserText = _rTrigger.GetWindow()->GetText();
+ break;
+
+ case VCLEVENT_WINDOW_ENABLED:
+ _rOperateOn.SetText( m_sUserText );
+ break;
+
+ case VCLEVENT_WINDOW_DISABLED:
+ _rOperateOn.SetText( m_sDisabledText );
+ break;
+
+ default:
+ OSL_FAIL( "TextResetOperator::operateOn: unexpected event ID!" );
+ // all those IDs should have been filtered out by payAttentionTo
+ break;
+ }
+ }
+
+ //====================================================================
+ //= TextResetOperatorController
+ //====================================================================
+ class TextResetOperatorController_Base
+ {
+ protected:
+ TextResetOperatorController_Base( const String& _rDisabledText )
+ :m_pEventFilter( new TextResetOperatorEventFilter )
+ ,m_pOperator( new TextResetOperator( _rDisabledText ) )
+ {
+ }
+
+ inline ::svt::PWindowEventFilter getEventFilter() const { return m_pEventFilter; }
+ inline ::svt::PWindowOperator getOperator() const { return m_pOperator; }
+
+ private:
+ ::svt::PWindowEventFilter m_pEventFilter;
+ ::svt::PWindowOperator m_pOperator;
+ };
+
+ class TextResetOperatorController :public TextResetOperatorController_Base
+ ,public ::svt::DialogController
+ {
+ public:
+ TextResetOperatorController( Window& _rObservee, const String& _rDisabledText )
+ :TextResetOperatorController_Base( _rDisabledText )
+ ,::svt::DialogController( _rObservee, getEventFilter(), getOperator() )
+ {
+ addDependentWindow( _rObservee );
+ }
+ };
+
+ //====================================================================
+ //= MySQLNativeSettings
+ //====================================================================
+ //--------------------------------------------------------------------
+ MySQLNativeSettings::MySQLNativeSettings( Window& _rParent, const Link& _rControlModificationLink )
+ :Control( &_rParent, ModuleRes( RID_MYSQL_NATIVE_SETTINGS ).SetAutoRelease( sal_False ) )
+ ,m_aDatabaseNameLabel ( this, ModuleRes( FT_MYSQL_DATABASE_NAME ) )
+ ,m_aDatabaseName ( this, ModuleRes( ED_MYSQL_DATABASE_NAME ) )
+ ,m_aHostPortRadio ( this, ModuleRes( RB_MYSQL_HOST_PORT ) )
+ ,m_aSocketRadio ( this, ModuleRes( RB_MYSQL_SOCKET ) )
+ ,m_aNamedPipeRadio ( this, ModuleRes( RB_MYSQL_NAMED_PIPE ) )
+ ,m_aHostNameLabel ( this, ModuleRes( FT_COMMON_HOST_NAME ) )
+ ,m_aHostName ( this, ModuleRes( ED_COMMON_HOST_NAME ) )
+ ,m_aPortLabel ( this, ModuleRes( FT_COMMON_PORT ) )
+ ,m_aPort ( this, ModuleRes( NF_COMMON_PORT ) )
+ ,m_aDefaultPort ( this, ModuleRes( FT_COMMON_PORT_DEFAULT ) )
+ ,m_aSocket ( this, ModuleRes( ED_MYSQL_SOCKET ) )
+ ,m_aNamedPipe ( this, ModuleRes( ED_MYSQL_NAMED_PIPE ) )
+ {
+ FreeResource();
+
+ m_aDatabaseName.SetModifyHdl( _rControlModificationLink );
+ m_aHostName.SetModifyHdl( _rControlModificationLink );
+ m_aPort.SetModifyHdl( _rControlModificationLink );
+ m_aNamedPipe.SetModifyHdl( _rControlModificationLink );
+ m_aSocketRadio.SetToggleHdl( _rControlModificationLink );
+ m_aNamedPipeRadio.SetToggleHdl( _rControlModificationLink );
+
+ m_aControlDependencies.enableOnRadioCheck( m_aHostPortRadio, m_aHostNameLabel, m_aHostName, m_aPortLabel, m_aPort, m_aDefaultPort );
+ m_aControlDependencies.enableOnRadioCheck( m_aSocketRadio, m_aSocket );
+ m_aControlDependencies.enableOnRadioCheck( m_aNamedPipeRadio, m_aNamedPipe );
+
+ m_aControlDependencies.addController( ::svt::PDialogController(
+ new TextResetOperatorController( m_aHostName, String::CreateFromAscii( "localhost" ) )
+ ) );
+
+ // sockets are available on Unix systems only, named pipes only on Windows
+#ifdef UNX
+ m_aNamedPipeRadio.Hide();
+ m_aNamedPipe.Hide();
+#else
+ m_aSocketRadio.Hide();
+ m_aSocket.Hide();
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ MySQLNativeSettings::~MySQLNativeSettings()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void MySQLNativeSettings::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aDatabaseName ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aHostName ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aPort ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aSocket ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aNamedPipe ) );
+ }
+
+ //--------------------------------------------------------------------
+ void MySQLNativeSettings::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aDatabaseNameLabel ) );
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aHostNameLabel ) );
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aPortLabel ) );
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aDefaultPort ) );
+ _rControlList.push_back( new ODisableWrapper< RadioButton >( &m_aSocketRadio ) );
+ _rControlList.push_back( new ODisableWrapper< RadioButton >( &m_aNamedPipeRadio ) );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool MySQLNativeSettings::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ OGenericAdministrationPage::fillString( _rSet, &m_aHostName, DSID_CONN_HOSTNAME, bChangedSomething );
+ OGenericAdministrationPage::fillString( _rSet, &m_aDatabaseName, DSID_DATABASENAME, bChangedSomething );
+ OGenericAdministrationPage::fillInt32 ( _rSet, &m_aPort, DSID_MYSQL_PORTNUMBER, bChangedSomething );
+#ifdef UNX
+ OGenericAdministrationPage::fillString( _rSet, &m_aSocket, DSID_CONN_SOCKET, bChangedSomething );
+#else
+ OGenericAdministrationPage::fillString( _rSet, &m_aNamedPipe, DSID_NAMED_PIPE, bChangedSomething );
+#endif
+
+ return bChangedSomething;
+ }
+
+ //--------------------------------------------------------------------
+ void MySQLNativeSettings::implInitControls(const SfxItemSet& _rSet )
+ {
+ SFX_ITEMSET_GET( _rSet, pInvalid, SfxBoolItem, DSID_INVALID_SELECTION, sal_True );
+ bool bValid = !pInvalid || !pInvalid->GetValue();
+ if ( !bValid )
+ return;
+
+ SFX_ITEMSET_GET( _rSet, pDatabaseName, SfxStringItem, DSID_DATABASENAME, sal_True );
+ SFX_ITEMSET_GET( _rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True );
+ SFX_ITEMSET_GET( _rSet, pPortNumber, SfxInt32Item, DSID_MYSQL_PORTNUMBER, sal_True );
+ SFX_ITEMSET_GET( _rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, sal_True );
+ SFX_ITEMSET_GET( _rSet, pNamedPipe, SfxStringItem, DSID_NAMED_PIPE, sal_True );
+
+ m_aDatabaseName.SetText( pDatabaseName->GetValue() );
+ m_aDatabaseName.ClearModifyFlag();
+
+ m_aHostName.SetText( pHostName->GetValue() );
+ m_aHostName.ClearModifyFlag();
+
+ m_aPort.SetValue( pPortNumber->GetValue() );
+ m_aPort.ClearModifyFlag();
+
+ m_aSocket.SetText( pSocket->GetValue() );
+ m_aSocket.ClearModifyFlag();
+
+ m_aNamedPipe.SetText( pNamedPipe->GetValue() );
+ m_aNamedPipe.ClearModifyFlag();
+
+ // if a socket (on Unix) or a pipe name (on Windows) is given, this is preferred over
+ // the port
+#ifdef UNX
+ RadioButton& rSocketPipeRadio = m_aSocketRadio;
+ const SfxStringItem* pSocketPipeItem = pSocket;
+#else
+ RadioButton& rSocketPipeRadio = m_aNamedPipeRadio;
+ const SfxStringItem* pSocketPipeItem = pNamedPipe;
+#endif
+ String sSocketPipe( pSocketPipeItem->GetValue() );
+ if ( sSocketPipe.Len() > 0 )
+ rSocketPipeRadio.Check();
+ else
+ m_aHostPortRadio.Check();
+ }
+
+ //--------------------------------------------------------------------
+ bool MySQLNativeSettings::canAdvance() const
+ {
+ if ( m_aDatabaseName.GetText().Len() == 0 )
+ return false;
+
+ if ( m_aHostPortRadio.IsChecked()
+ && ( ( m_aHostName.GetText().Len() == 0 )
+ || ( m_aPort.GetText().Len() == 0 )
+ )
+ )
+ return false;
+
+#ifdef UNX
+ if ( ( m_aSocketRadio.IsChecked() )
+ && ( m_aSocket.GetText().Len() == 0 )
+ )
+#else
+ if ( ( m_aNamedPipeRadio.IsChecked() )
+ && ( m_aNamedPipe.GetText().Len() == 0 )
+ )
+#endif
+ return false;
+
+ return true;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/admincontrols.hrc b/dbaccess/source/ui/dlg/admincontrols.hrc
new file mode 100755
index 000000000000..8286bc7f8b25
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.hrc
@@ -0,0 +1,49 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef ADMINCONTROLS_HRC
+#define ADMINCONTROLS_HRC
+
+#define FT_MYSQL_DATABASE_NAME 1
+#define FT_COMMON_HOST_NAME 2
+#define FT_COMMON_PORT_DEFAULT 3
+#define FT_COMMON_PORT 4
+
+
+#define RB_MYSQL_HOST_PORT 1
+#define RB_MYSQL_SOCKET 2
+#define RB_MYSQL_NAMED_PIPE 3
+
+
+#define ED_MYSQL_DATABASE_NAME 1
+#define ED_MYSQL_SOCKET 2
+#define ED_COMMON_HOST_NAME 3
+#define ED_MYSQL_NAMED_PIPE 4
+
+
+#define NF_COMMON_PORT 1
+
+#endif // ADMINCONTROLS_HRC
diff --git a/dbaccess/source/ui/dlg/admincontrols.hxx b/dbaccess/source/ui/dlg/admincontrols.hxx
new file mode 100644
index 000000000000..83353be4b8d0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef DBACCESS_ADMINCONTROLS_HXX
+#define DBACCESS_ADMINCONTROLS_HXX
+
+#include "adminpages.hxx"
+
+#include <vcl/edit.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+
+#include <svtools/dialogcontrolling.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= MySQLNativeSettings
+ //====================================================================
+ class MySQLNativeSettings : public Control
+ {
+ private:
+ FixedText m_aDatabaseNameLabel;
+ Edit m_aDatabaseName;
+ RadioButton m_aHostPortRadio;
+ RadioButton m_aSocketRadio;
+ RadioButton m_aNamedPipeRadio;
+ FixedText m_aHostNameLabel;
+ Edit m_aHostName;
+ FixedText m_aPortLabel;
+ NumericField m_aPort;
+ FixedText m_aDefaultPort;
+ Edit m_aSocket;
+ Edit m_aNamedPipe;
+
+ ::svt::ControlDependencyManager
+ m_aControlDependencies;
+
+ public:
+ MySQLNativeSettings( Window& _rParent, const Link& _rControlModificationLink );
+ ~MySQLNativeSettings();
+
+ void fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList );
+ void fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList );
+
+ sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ void implInitControls( const SfxItemSet& _rSet );
+
+ bool canAdvance() const;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_ADMINCONTROLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/admincontrols.src b/dbaccess/source/ui/dlg/admincontrols.src
new file mode 100644
index 000000000000..8ce3bb4030dc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/admincontrols.src
@@ -0,0 +1,131 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#include "AutoControls.hrc"
+#include "dbu_dlg.hrc"
+#include "admincontrols.hrc"
+
+#define LINE_HEIGHT ( EDIT_HEIGHT + RELATED_CONTROLS )
+#define SETTINGS_CONTROL_WIDTH ( WIZARD_PAGE_X - 2 * START_X )
+#define COLUMN_WIDTH_1 80
+#define COLUMN_WIDTH_2 ( SETTINGS_CONTROL_WIDTH - COLUMN_WIDTH_1 )
+
+Control RID_MYSQL_NATIVE_SETTINGS
+{
+ DialogControl = TRUE;
+ Size = MAP_APPFONT( SETTINGS_CONTROL_WIDTH, 5 * LINE_HEIGHT );
+ Hide = FALSE;
+
+ FixedText FT_MYSQL_DATABASE_NAME
+ {
+ Pos = MAP_APPFONT ( 0, 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1 - UNRELATED_CONTROLS, FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "~Database name";
+ };
+
+ Edit ED_MYSQL_DATABASE_NAME
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1, 0 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT );
+ Border = TRUE;
+ };
+
+ RadioButton RB_MYSQL_HOST_PORT
+ {
+ Pos = MAP_APPFONT ( 0, LINE_HEIGHT );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1, FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Se~rver / Port" ;
+ Group = TRUE;
+ };
+
+#define OPTION_GROUP_START ( LINE_HEIGHT + FIXEDTEXT_HEIGHT + RELATED_CONTROLS )
+
+ FixedText FT_COMMON_HOST_NAME
+ {
+ Pos = MAP_APPFONT ( INDENT_BELOW_RADIO, OPTION_GROUP_START + 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS - INDENT_BELOW_RADIO, FIXEDTEXT_HEIGHT );
+ Text [ en-US ] = "~Server" ;
+ };
+
+ Edit ED_COMMON_HOST_NAME
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT );
+ Border = TRUE;
+ };
+
+ FixedText FT_COMMON_PORT
+ {
+ Pos = MAP_APPFONT ( INDENT_BELOW_RADIO, OPTION_GROUP_START + LINE_HEIGHT + 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS - INDENT_BELOW_RADIO, FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~Port" ;
+ Group = TRUE;
+ };
+
+ NumericField NF_COMMON_PORT
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + LINE_HEIGHT );
+ Size = MAP_APPFONT ( 25, EDIT_HEIGHT );
+ Border = TRUE;
+ NoThousandSep = TRUE;
+ Value = 3306;
+ };
+
+ FixedText FT_COMMON_PORT_DEFAULT
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1 + 25 + RELATED_CONTROLS, OPTION_GROUP_START + LINE_HEIGHT + 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_2 - 25 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Default: 3306";
+ };
+
+ RadioButton RB_MYSQL_SOCKET
+ {
+ Pos = MAP_APPFONT ( 0, OPTION_GROUP_START + 2 * LINE_HEIGHT + 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT );
+ Text [ en-US ] = "So~cket";
+ };
+
+ Edit ED_MYSQL_SOCKET
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + 2 * LINE_HEIGHT );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT );
+ Border = TRUE ;
+ };
+
+ RadioButton RB_MYSQL_NAMED_PIPE
+ {
+ Pos = MAP_APPFONT ( 0, OPTION_GROUP_START + 2 * LINE_HEIGHT + 2 );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_1 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT );
+ Text [ en-US ] = "Named p~ipe";
+ };
+
+ Edit ED_MYSQL_NAMED_PIPE
+ {
+ Pos = MAP_APPFONT ( COLUMN_WIDTH_1, OPTION_GROUP_START + 2 * LINE_HEIGHT );
+ Size = MAP_APPFONT ( COLUMN_WIDTH_2, EDIT_HEIGHT );
+ Border = TRUE ;
+ };
+};
diff --git a/dbaccess/source/ui/dlg/adminpages.cxx b/dbaccess/source/ui/dlg/adminpages.cxx
new file mode 100644
index 000000000000..2bf12cf82740
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adminpages.cxx
@@ -0,0 +1,356 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "adminpages.hxx"
+#include "dbadmin.hrc"
+#include "dbadmin.hxx"
+#include "dbu_dlg.hrc"
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dbustrings.hrc"
+#include "dsitems.hxx"
+#include "dsselect.hxx"
+#include "localresaccess.hxx"
+#include "odbcconfig.hxx"
+#include "optionalboolitem.hxx"
+#include "sqlmessage.hxx"
+
+#include <osl/file.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/accel.hxx>
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <algorithm>
+#include <stdlib.h>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::dbtools;
+ using namespace ::svt;
+
+
+ //=========================================================================
+ //= OGenericAdministrationPage
+ //=========================================================================
+ DBG_NAME(OGenericAdministrationPage)
+ //-------------------------------------------------------------------------
+ OGenericAdministrationPage::OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet)
+ :SfxTabPage(_pParent, _rId, _rAttrSet)
+ ,m_abEnableRoadmap(sal_False)
+ ,m_pAdminDialog(NULL)
+ ,m_pItemSetHelper(NULL)
+ ,m_pFT_HeaderText(NULL)
+ {
+ DBG_CTOR(OGenericAdministrationPage,NULL);
+
+ SetExchangeSupport(sal_True);
+ }
+
+ //-------------------------------------------------------------------------
+ OGenericAdministrationPage::~OGenericAdministrationPage()
+ {
+ DELETEZ(m_pFT_HeaderText);
+
+ DBG_DTOR(OGenericAdministrationPage,NULL);
+ }
+
+ //-------------------------------------------------------------------------
+ int OGenericAdministrationPage::DeactivatePage(SfxItemSet* _pSet)
+ {
+ if (_pSet)
+ {
+ if (!prepareLeave())
+ return KEEP_PAGE;
+ FillItemSet(*_pSet);
+ }
+
+ return LEAVE_PAGE;
+ }
+
+ //-------------------------------------------------------------------------
+ void OGenericAdministrationPage::Reset(const SfxItemSet& _rCoreAttrs)
+ {
+ implInitControls(_rCoreAttrs, sal_False);
+ }
+ //-------------------------------------------------------------------------
+ void OGenericAdministrationPage::ActivatePage()
+ {
+ TabPage::ActivatePage();
+ OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!");
+ if ( m_pItemSetHelper )
+ ActivatePage(*m_pItemSetHelper->getOutputSet());
+ }
+ //-------------------------------------------------------------------------
+ void OGenericAdministrationPage::ActivatePage(const SfxItemSet& _rSet)
+ {
+ implInitControls(_rSet, sal_True);
+ }
+
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly)
+ {
+ SFX_ITEMSET_GET(_rSet, pInvalid, SfxBoolItem, DSID_INVALID_SELECTION, sal_True);
+ _rValid = !pInvalid || !pInvalid->GetValue();
+ SFX_ITEMSET_GET(_rSet, pReadonly, SfxBoolItem, DSID_READONLY, sal_True);
+ _rReadonly = !_rValid || (pReadonly && pReadonly->GetValue());
+ }
+
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGenericAdministrationPage, OnControlModified, Control*, EMPTYARG)
+ {
+ callModifiedHdl();
+ return 0L;
+ }
+ // -----------------------------------------------------------------------
+ sal_Bool OGenericAdministrationPage::getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr)
+ {
+ // collect all ODBC data source names
+ StringBag aOdbcDatasources;
+ OOdbcEnumeration aEnumeration;
+ if (!aEnumeration.isLoaded())
+ {
+ // show an error message
+ LocalResourceAccess aLocRes( PAGE_GENERAL, RSC_TABPAGE );
+ String sError(ModuleRes(STR_COULDNOTLOAD_ODBCLIB));
+ sError.SearchAndReplaceAscii("#lib#", aEnumeration.getLibraryName());
+ ErrorBox aDialog(this, WB_OK, sError);
+ aDialog.Execute();
+ return sal_False;
+ }
+ else
+ {
+ aEnumeration.getDatasourceNames(aOdbcDatasources);
+ // execute the select dialog
+ ODatasourceSelectDialog aSelector(GetParent(), aOdbcDatasources, false);
+ if (_sCurr.getLength())
+ aSelector.Select(_sCurr);
+ if ( RET_OK == aSelector.Execute() )
+ _sReturn = aSelector.GetSelected();
+ }
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ ::std::vector< ISaveValueWrapper* > aControlList;
+ if ( _bSaveValue )
+ {
+ fillControls(aControlList);
+ ::std::for_each(aControlList.begin(),aControlList.end(),TSaveValueWrapperFunctor());
+ }
+
+ if ( bReadonly )
+ {
+ fillWindows(aControlList);
+ ::std::for_each(aControlList.begin(),aControlList.end(),TDisableWrapperFunctor());
+ }
+
+ ::std::for_each(aControlList.begin(),aControlList.end(),TDeleteWrapperFunctor());
+ aControlList.clear();
+ }
+
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::initializePage()
+ {
+ OSL_ENSURE(m_pItemSetHelper,"NO ItemSetHelper set!");
+ if ( m_pItemSetHelper )
+ Reset(*m_pItemSetHelper->getOutputSet());
+ }
+ // -----------------------------------------------------------------------
+ sal_Bool OGenericAdministrationPage::commitPage( ::svt::WizardTypes::CommitPageReason )
+ {
+ return sal_True;
+ }
+ // -----------------------------------------------------------------------
+ bool OGenericAdministrationPage::canAdvance() const
+ {
+ return true;
+ }
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, sal_Bool& _bChangedSomething, bool _bRevertValue )
+ {
+ if ( (_pCheckBox != NULL ) && ( _pCheckBox->GetState() != _pCheckBox->GetSavedValue() ) )
+ {
+ sal_Bool bValue = _pCheckBox->IsChecked();
+ if ( _bRevertValue )
+ bValue = !bValue;
+
+ if ( _pCheckBox->IsTriStateEnabled() )
+ {
+ OptionalBoolItem aValue( _nID );
+ if ( _pCheckBox->GetState() != STATE_DONTKNOW )
+ aValue.SetValue( bValue );
+ _rSet.Put( aValue );
+ }
+ else
+ _rSet.Put( SfxBoolItem( _nID, bValue ) );
+
+ _bChangedSomething = sal_True;
+ }
+ }
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething)
+ {
+ if( (_pEdit != NULL) && (_pEdit->GetValue() != _pEdit->GetSavedValue().ToInt32()) )
+ {
+ _rSet.Put(SfxInt32Item(_nID, static_cast<sal_Int32>(_pEdit->GetValue())));
+ _bChangedSomething = sal_True;
+ }
+ }
+ // -----------------------------------------------------------------------
+ void OGenericAdministrationPage::fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething)
+ {
+ if( (_pEdit != NULL) && (_pEdit->GetText() != _pEdit->GetSavedValue()) )
+ {
+ _rSet.Put(SfxStringItem(_nID, _pEdit->GetText()));
+ _bChangedSomething = sal_True;
+ }
+ }
+
+ void OGenericAdministrationPage::SetControlFontWeight(Window* _pWindow, FontWeight _eWeight)
+ {
+ Font aFont = _pWindow->GetControlFont();
+ aFont.SetWeight( _eWeight );
+ _pWindow->SetControlFont( aFont );
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGenericAdministrationPage, OnTestConnectionClickHdl, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ sal_Bool bSuccess = sal_False;
+ if ( m_pAdminDialog )
+ {
+ m_pAdminDialog->saveDatasource();
+ OGenericAdministrationPage::implInitControls(*m_pItemSetHelper->getOutputSet(), sal_True);
+ sal_Bool bShowMessage = sal_True;
+ try
+ {
+ ::std::pair< Reference<XConnection>,sal_Bool> xConnection = m_pAdminDialog->createConnection();
+ bShowMessage = xConnection.second;
+ bSuccess = xConnection.first.is();
+ ::comphelper::disposeComponent(xConnection.first);
+ }
+ catch(Exception&)
+ {
+ }
+ if ( bShowMessage )
+ {
+ OSQLMessageBox::MessageType eImage = OSQLMessageBox::Info;
+ String aMessage,sTitle;
+ sTitle = String (ModuleRes(STR_CONNECTION_TEST));
+ if ( bSuccess )
+ {
+ aMessage = String(ModuleRes(STR_CONNECTION_SUCCESS));
+ }
+ else
+ {
+ eImage = OSQLMessageBox::Error;
+ aMessage = String(ModuleRes(STR_CONNECTION_NO_SUCCESS));
+ }
+ OSQLMessageBox aMsg( this, sTitle, aMessage, WB_OK, eImage );
+ aMsg.Execute();
+ }
+ if ( !bSuccess )
+ m_pAdminDialog->clearPassword();
+ }
+ return 0L;
+ }
+
+ void OGenericAdministrationPage::SetHeaderText( sal_uInt16 _nFTResId, sal_uInt16 _StringResId)
+ {
+ delete(m_pFT_HeaderText);
+ m_pFT_HeaderText = new FixedText(this, ModuleRes(_nFTResId));
+ String sHeaderText = String(ModuleRes(_StringResId));
+ m_pFT_HeaderText->SetText(sHeaderText);
+ SetControlFontWeight(m_pFT_HeaderText);
+ }
+
+ //=========================================================================
+ //= LayoutHelper
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ void LayoutHelper::positionBelow( const Control& _rReference, Control& _rControl, const ControlRelation _eRelation,
+ const long _nIndentAppFont )
+ {
+ Point aReference = _rReference.GetPosPixel();
+ aReference.Y() += _rReference.GetSizePixel().Height();
+
+ const Window* pConverter = _rControl.GetParent();
+ Size aOffset = pConverter->LogicToPixel( Size( _nIndentAppFont, ( _eRelation == RelatedControls ? 3 : 6 ) ), MAP_APPFONT );
+
+ Point aControlPos( aReference.X() + aOffset.Width(), aReference.Y() + aOffset.Height() );
+ _rControl.SetPosPixel( aControlPos );
+ }
+
+ //-------------------------------------------------------------------------
+ void LayoutHelper::fitSizeRightAligned( PushButton& io_button )
+ {
+ const Point aOldPos = io_button.GetPosPixel();
+ const Size aOldSize = io_button.GetSizePixel();
+ const Size aMinSize( io_button.CalcMinimumSize() );
+ if ( aMinSize.Width() > aOldSize.Width() )
+ {
+ io_button.SetPosSizePixel(
+ aOldPos.X() + aOldSize.Width() - aMinSize.Width(),
+ 0,
+ aMinSize.Width(),
+ 0,
+ WINDOW_POSSIZE_X | WINDOW_POSSIZE_WIDTH
+ );
+ }
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adminpages.hxx b/dbaccess/source/ui/dlg/adminpages.hxx
new file mode 100644
index 000000000000..51fd7f025965
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adminpages.hxx
@@ -0,0 +1,293 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_ADMINPAGES_HXX_
+#define _DBAUI_ADMINPAGES_HXX_
+
+#include <sfx2/tabdlg.hxx>
+#include "dsntypes.hxx"
+#include "commontypes.hxx"
+#include <svtools/wizardmachine.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+
+
+class NumericField;
+class Edit;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ /// helper class to wrap the savevalue and disable call
+ class SAL_NO_VTABLE ISaveValueWrapper
+ {
+ public:
+ virtual bool SaveValue() = 0;
+ virtual bool Disable() = 0;
+ };
+
+ template < class T > class OSaveValueWrapper : public ISaveValueWrapper
+ {
+ T* m_pSaveValue;
+ public:
+ OSaveValueWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
+ { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
+
+ virtual bool SaveValue() { m_pSaveValue->SaveValue(); return true;} // bool return value only for stl
+ virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
+ };
+
+ template < class T > class ODisableWrapper : public ISaveValueWrapper
+ {
+ T* m_pSaveValue;
+ public:
+ ODisableWrapper(T* _pSaveValue) : m_pSaveValue(_pSaveValue)
+ { OSL_ENSURE(m_pSaveValue,"Illegal argument!"); }
+
+ virtual bool SaveValue() { return true;} // bool return value only for stl
+ virtual bool Disable() { m_pSaveValue->Disable(); return true;} // bool return value only for stl
+ };
+
+ struct TSaveValueWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
+ {
+ bool operator() (ISaveValueWrapper* lhs)
+ {
+ return lhs->SaveValue();
+ }
+ };
+ struct TDisableWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
+ {
+ bool operator() (ISaveValueWrapper* lhs)
+ {
+ return lhs->Disable();
+ }
+ };
+
+ struct TDeleteWrapperFunctor : public ::std::unary_function< ISaveValueWrapper, bool>
+ {
+ bool operator() (ISaveValueWrapper* lhs)
+ {
+ delete lhs;
+ return true;
+ }
+ };
+
+ //=========================================================================
+ //= OGenericAdministrationPage
+ //=========================================================================
+ class IDatabaseSettingsDialog;
+ class IItemSetHelper;
+ class OGenericAdministrationPage :public SfxTabPage
+ ,public ::svt::IWizardPageController
+ {
+ private:
+ Link m_aModifiedHandler; /// to be called if something on the page has been modified
+ sal_Bool m_abEnableRoadmap;
+ protected:
+ IDatabaseSettingsDialog* m_pAdminDialog;
+ IItemSetHelper* m_pItemSetHelper;
+ FixedText* m_pFT_HeaderText;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ public:
+ OGenericAdministrationPage(Window* _pParent, const ResId& _rId, const SfxItemSet& _rAttrSet);
+ ~OGenericAdministrationPage();
+
+ /// set a handler which gets called every time something on the page has been modified
+ void SetModifiedHandler(const Link& _rHandler) { m_aModifiedHandler = _rHandler; }
+
+ /** Sets the ParentDialog
+ @param _pAdminDialog
+ the ParentDialog
+ @param _pItemSetHelper
+ the itemset helper
+ */
+ inline void SetAdminDialog(IDatabaseSettingsDialog* _pDialog,IItemSetHelper* _pItemSetHelper)
+ {
+ OSL_ENSURE(_pDialog && _pItemSetHelper,"Values are NULL!");
+ m_pAdminDialog = _pDialog;
+ m_pItemSetHelper = _pItemSetHelper;
+ }
+
+ /** Sets the ServiceFactory
+ @param _rxORB
+ The service factory.
+ */
+ virtual void SetServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB)
+ {
+ m_xORB = _rxORB;
+ }
+
+ /** opens a dialog filled with all data sources available for this type and
+ returns the selected on.
+ @param _eType
+ The type for which the data source dialog should be opened.
+ @param _sReturn
+ <OUT/> contains the selected name.
+ @return
+ <FALSE/> if an error occurred, otherwise <TRUE/>
+ */
+ sal_Bool getSelectedDataSource(::rtl::OUString& _sReturn,::rtl::OUString& _sCurr);
+
+ // svt::IWizardPageController
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ void SetRoadmapStateValue( sal_Bool _bDoEnable ) { m_abEnableRoadmap = _bDoEnable; }
+ bool GetRoadmapStateValue() const { return m_abEnableRoadmap; }
+
+ protected:
+ /// default implementation: call FillItemSet, call prepareLeave,
+ virtual int DeactivatePage(SfxItemSet* pSet);
+ using SfxTabPage::DeactivatePage;
+ /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_False
+ virtual void Reset(const SfxItemSet& _rCoreAttrs);
+ /// default implementation: call implInitControls with the given item set and _bSaveValue = sal_True
+ virtual void ActivatePage(const SfxItemSet& _rSet);
+
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ protected:
+ void callModifiedHdl() const { if (m_aModifiedHandler.IsSet()) m_aModifiedHandler.Call((void*)this); }
+
+ /// called from within DeactivatePage. The page is allowed to be deactivated if this method returns sal_True
+ virtual sal_Bool prepareLeave() { return sal_True; }
+
+ /** called from within Reset and ActivatePage, use to initialize the controls with the items from the given set
+ @param _bSaveValue if set to sal_True, the implementation should call SaveValue on all relevant controls
+ */
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ /// analyze the invalid and the readonly flag which may be present in the set
+ void getFlags(const SfxItemSet& _rSet, sal_Bool& _rValid, sal_Bool& _rReadonly);
+
+ /** will be called inside <method>implInitControls</method> to save the value if necessary
+ @param _rControlList
+ The list must be filled with the controls.
+ It is not allowed to clear the list before pusching data into it.
+ */
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
+
+ /** will be called inside <method>implInitControls</method> to disable if necessary
+ @param _rControlList
+ The list must be filled with the controls.
+ It is not allowed to clear the list before pusching data into it.
+ */
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList) = 0;
+
+ public:
+ /** fills the Boolean value into the item set when the value changed.
+ @param _rSet
+ The item set where to put the new value into.
+ @param _pCheckBox
+ The check box which is checked.
+ @param _nID
+ The id in the itemset to set whith the new value.
+ @param _bChangedSomething
+ <TRUE/> if something changed otherwise <FALSE/>
+ @param _bRevertValue
+ set to <TRUE/> if the display value should be reverted before putting it into the set
+ */
+ static void fillBool( SfxItemSet& _rSet, CheckBox* _pCheckBox, sal_uInt16 _nID, sal_Bool& _bChangedSomething, bool _bRevertValue = false);
+
+ /** fills the int value into the item set when the value changed.
+ @param _rSet
+ The item set where to put the new value into.
+ @param _pEdit
+ The check box which is checked.
+ @param _nID
+ The id in the itemset to set whith the new value.
+ @param _bChangedSomething
+ <TRUE/> if something changed otherwise <FALSE/>
+ */
+ static void fillInt32(SfxItemSet& _rSet,NumericField* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
+
+ /** fills the String value into the item set when the value changed.
+ @param _rSet
+ The item set where to put the new value into.
+ @param _pEdit
+ The check box which is checked.
+ @param _nID
+ The id in the itemset to set whith the new value.
+ @param _bChangedSomething
+ <TRUE/> if something changed otherwise <FALSE/>
+ */
+ static void fillString(SfxItemSet& _rSet,Edit* _pEdit,sal_uInt16 _nID,sal_Bool& _bChangedSomething);
+
+ protected:
+ // used to set the right Pane header of a wizard to bold
+ void SetControlFontWeight(Window* _pWindow, FontWeight _eWeight = WEIGHT_BOLD);
+ void SetHeaderText( sal_uInt16 _nFTResId, sal_uInt16 _StringResId);
+
+ /** This link be used for controls where the tabpage does not need to take any special action when the control
+ is modified. The implementation just calls callModifiedHdl.
+ */
+ DECL_LINK(OnControlModified, Control*);
+ DECL_LINK(OnTestConnectionClickHdl,PushButton*);
+
+ /// may be used in SetXXXHdl calls to controls, is a link to <method>OnControlModified</method>
+ virtual Link getControlModifiedLink() { return LINK(this, OGenericAdministrationPage, OnControlModified); }
+ };
+
+ //=========================================================================
+ //= ControlRelation
+ //=========================================================================
+ enum ControlRelation
+ {
+ RelatedControls, UnrelatedControls
+ };
+
+ //=========================================================================
+ //= LayoutHelper
+ //=========================================================================
+ class LayoutHelper
+ {
+ public:
+ static void positionBelow(
+ const Control& _rReference,
+ Control& _rControl,
+ const ControlRelation _eRelation,
+ const long _nIndentAppFont
+ );
+ /** fits the button size to be large enough to contain the buttons text
+ */
+ static void fitSizeRightAligned( PushButton& io_button );
+ // why is CalcMinimumSize not a virtual method of ::Window?
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_ADMINPAGES_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adodatalinks.cxx b/dbaccess/source/ui/dlg/adodatalinks.cxx
new file mode 100644
index 000000000000..9af7714a1cdc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adodatalinks.cxx
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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"
+
+
+#if defined(WNT)
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#pragma warning(disable: 4917)
+#endif
+#include "msdasc.h" // OLE DB Service Component header
+#if defined _MSC_VER
+#pragma warning(push, 1)
+#endif
+#include "stdio.h"
+
+#include <initguid.h> // Include only once in your application
+#include <adoid.h> // needed for CLSID_CADOConnection
+#include <adoint.h> // needed for ADOConnection
+
+#include "adodatalinks.hxx"
+
+BSTR PromptEdit(long hWnd,BSTR connstr);
+BSTR PromptNew(long hWnd);
+
+::rtl::OUString getAdoDatalink(long hWnd,::rtl::OUString& oldLink)
+{
+ ::rtl::OUString dataLink;
+ if (oldLink.getLength())
+ {
+ dataLink=reinterpret_cast<sal_Unicode *>(PromptEdit(hWnd,(BSTR)oldLink.getStr()));
+ }
+ else
+ dataLink=reinterpret_cast<sal_Unicode *>(PromptNew(hWnd));
+ return dataLink;
+}
+BSTR PromptNew(long hWnd)
+{
+ BSTR connstr=NULL;
+ HRESULT hr;
+ IDataSourceLocator* dlPrompt = NULL;
+ ADOConnection* piTmpConnection = NULL;
+ BSTR _result=NULL;
+
+ // Initialize COM
+ ::CoInitialize( NULL );
+
+ // Instantiate DataLinks object.
+ hr = CoCreateInstance(
+ CLSID_DataLinks, //clsid -- Data Links UI
+ NULL, //pUnkOuter
+ CLSCTX_INPROC_SERVER, //dwClsContext
+ IID_IDataSourceLocator, //riid
+ (void**)&dlPrompt //ppvObj
+ );
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ dlPrompt->put_hWnd(hWnd);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ // Prompt for connection information.
+ hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection);
+
+ if( FAILED( hr ) || !piTmpConnection )
+ {
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ hr = piTmpConnection->get_ConnectionString(&_result);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ CoUninitialize();
+ return _result;
+}
+
+BSTR PromptEdit(long hWnd,BSTR connstr)
+{
+ HRESULT hr;
+ IDataSourceLocator* dlPrompt = NULL;
+ ADOConnection* piTmpConnection = NULL;
+ BSTR _result=NULL;
+
+ // Initialize COM
+ ::CoInitialize( NULL );
+
+ hr = CoCreateInstance(CLSID_CADOConnection,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IADOConnection,
+ (LPVOID *)&piTmpConnection);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ return connstr;
+ }
+
+
+ hr = piTmpConnection->put_ConnectionString(connstr);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ return connstr;
+ }
+
+ // Instantiate DataLinks object.
+ hr = CoCreateInstance(
+ CLSID_DataLinks, //clsid -- Data Links UI
+ NULL, //pUnkOuter
+ CLSCTX_INPROC_SERVER, //dwClsContext
+ IID_IDataSourceLocator, //riid
+ (void**)&dlPrompt //ppvObj
+ );
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ dlPrompt->put_hWnd(hWnd);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ VARIANT_BOOL pbSuccess;
+
+ // Prompt for connection information.
+ hr = dlPrompt->PromptEdit((IDispatch **)&piTmpConnection,&pbSuccess);
+ if( SUCCEEDED( hr ) && sal_False == pbSuccess ) //if user press cancel then sal_False == pbSuccess
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ if( FAILED( hr ) )
+ {
+ // Prompt for new connection information.
+ piTmpConnection->Release( );
+ piTmpConnection = NULL;
+ hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection);
+ if( FAILED( hr ) || !piTmpConnection )
+ {
+ dlPrompt->Release( );
+ return connstr;
+ }
+ }
+
+ hr = piTmpConnection->get_ConnectionString(&_result);
+ if( FAILED( hr ) )
+ {
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ return connstr;
+ }
+
+ piTmpConnection->Release( );
+ dlPrompt->Release( );
+ CoUninitialize();
+ return _result;
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adodatalinks.hxx b/dbaccess/source/ui/dlg/adodatalinks.hxx
new file mode 100644
index 000000000000..e5f299e7a7be
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adodatalinks.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_ADO_DATALINK_HXX_
+#define _DBAUI_ADO_DATALINK_HXX_
+
+#include <osl/module.h>
+#include "commontypes.hxx"
+
+::rtl::OUString getAdoDatalink(long hWnd,::rtl::OUString& oldLink);
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx
new file mode 100644
index 000000000000..540e26982039
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adtabdlg.cxx
@@ -0,0 +1,532 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "adtabdlg.hxx"
+#include "adtabdlg.hrc"
+#include "sqlmessage.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <svtools/localresaccess.hxx>
+#include "dbaccess_helpid.hrc"
+#include "dbu_resource.hrc"
+#include "dbu_dlg.hrc"
+#include <sfx2/sfxsids.hrc>
+#include "QueryTableView.hxx"
+#include "QueryDesignView.hxx"
+#include "querycontroller.hxx"
+#include <connectivity/dbtools.hxx>
+#include "browserids.hxx"
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "UITools.hxx"
+#include "imageprovider.hxx"
+
+#include <comphelper/containermultiplexer.hxx>
+#include "cppuhelper/basemutex.hxx"
+#include <algorithm>
+
+// slot ids
+using namespace dbaui;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace dbtools;
+
+//==============================================================================
+//= TableObjectListFacade
+//==============================================================================
+TableObjectListFacade::~TableObjectListFacade()
+{
+}
+
+//==============================================================================
+//= TableListFacade
+//==============================================================================
+class TableListFacade : public ::cppu::BaseMutex
+ , public TableObjectListFacade
+ , public ::comphelper::OContainerListener
+{
+ OTableTreeListBox& m_rTableList;
+ Reference< XConnection > m_xConnection;
+ ::rtl::Reference< comphelper::OContainerListenerAdapter>
+ m_pContainerListener;
+ bool m_bAllowViews;
+
+public:
+ TableListFacade( OTableTreeListBox& _rTableList, const Reference< XConnection >& _rxConnection )
+ : ::comphelper::OContainerListener(m_aMutex)
+ ,m_rTableList( _rTableList )
+ ,m_xConnection( _rxConnection )
+ ,m_bAllowViews(true)
+ {
+ }
+ virtual ~TableListFacade();
+
+
+private:
+ virtual void updateTableObjectList( bool _bAllowViews );
+ virtual String getSelectedName( String& _out_rAliasName ) const;
+ virtual bool isLeafSelected() const;
+ // OContainerListener
+ virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+TableListFacade::~TableListFacade()
+{
+ if ( m_pContainerListener.is() )
+ m_pContainerListener->dispose();
+}
+//------------------------------------------------------------------------------
+String TableListFacade::getSelectedName( String& _out_rAliasName ) const
+{
+ SvLBoxEntry* pEntry = m_rTableList.FirstSelected();
+ if ( !pEntry )
+ return String();
+
+ ::rtl::OUString aCatalog, aSchema, aTableName;
+ SvLBoxEntry* pSchema = m_rTableList.GetParent(pEntry);
+ if(pSchema && pSchema != m_rTableList.getAllObjectsEntry())
+ {
+ SvLBoxEntry* pCatalog = m_rTableList.GetParent(pSchema);
+ if(pCatalog && pCatalog != m_rTableList.getAllObjectsEntry())
+ aCatalog = m_rTableList.GetEntryText(pCatalog);
+ aSchema = m_rTableList.GetEntryText(pSchema);
+ }
+ aTableName = m_rTableList.GetEntryText(pEntry);
+
+ ::rtl::OUString aComposedName;
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta( m_xConnection->getMetaData(), UNO_QUERY_THROW );
+ if ( !aCatalog.getLength()
+ && aSchema.getLength()
+ && xMeta->supportsCatalogsInDataManipulation()
+ && !xMeta->supportsSchemasInDataManipulation() )
+ {
+ aCatalog = aSchema;
+ aSchema = ::rtl::OUString();
+ }
+
+ aComposedName = ::dbtools::composeTableName(
+ xMeta, aCatalog, aSchema, aTableName, sal_False, ::dbtools::eInDataManipulation );
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ _out_rAliasName = aTableName;
+ return aComposedName;
+}
+// -----------------------------------------------------------------------------
+void TableListFacade::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ updateTableObjectList(m_bAllowViews);
+}
+// -----------------------------------------------------------------------------
+void TableListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ updateTableObjectList(m_bAllowViews);
+}
+// -----------------------------------------------------------------------------
+void TableListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+//------------------------------------------------------------------------------
+void TableListFacade::updateTableObjectList( bool _bAllowViews )
+{
+ m_bAllowViews = _bAllowViews;
+ m_rTableList.Clear();
+ try
+ {
+ Reference< XTablesSupplier > xTableSupp( m_xConnection, UNO_QUERY_THROW );
+
+ Reference< XViewsSupplier > xViewSupp;
+ Reference< XNameAccess > xTables, xViews;
+ Sequence< ::rtl::OUString > sTables, sViews;
+
+ xTables = xTableSupp->getTables();
+ if ( xTables.is() )
+ {
+ if ( !m_pContainerListener.is() )
+ {
+ Reference< XContainer> xContainer(xTables,uno::UNO_QUERY);
+ if ( xContainer.is() )
+ m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
+ }
+ sTables = xTables->getElementNames();
+ }
+
+ xViewSupp.set( xTableSupp, UNO_QUERY );
+ if ( xViewSupp.is() )
+ {
+ xViews = xViewSupp->getViews();
+ if ( xViews.is() )
+ sViews = xViews->getElementNames();
+ }
+
+ // if no views are allowed remove the views also out the table name filter
+ if ( !_bAllowViews )
+ {
+ const ::rtl::OUString* pTableBegin = sTables.getConstArray();
+ const ::rtl::OUString* pTableEnd = pTableBegin + sTables.getLength();
+ ::std::vector< ::rtl::OUString > aTables(pTableBegin,pTableEnd);
+
+ const ::rtl::OUString* pViewBegin = sViews.getConstArray();
+ const ::rtl::OUString* pViewEnd = pViewBegin + sViews.getLength();
+ ::comphelper::TStringMixEqualFunctor aEqualFunctor;
+ for(;pViewBegin != pViewEnd;++pViewBegin)
+ aTables.erase(::std::remove_if(aTables.begin(),aTables.end(),::std::bind2nd(aEqualFunctor,*pViewBegin)),aTables.end());
+ ::rtl::OUString* pTables = aTables.empty() ? 0 : &aTables[0];
+ sTables = Sequence< ::rtl::OUString>(pTables, aTables.size());
+ sViews = Sequence< ::rtl::OUString>();
+ }
+
+ m_rTableList.UpdateTableList( m_xConnection, sTables, sViews );
+ SvLBoxEntry* pEntry = m_rTableList.First();
+ while( pEntry && m_rTableList.GetModel()->HasChilds( pEntry ) )
+ {
+ m_rTableList.Expand( pEntry );
+ pEntry = m_rTableList.Next( pEntry );
+ }
+ if ( pEntry )
+ m_rTableList.Select(pEntry);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+bool TableListFacade::isLeafSelected() const
+{
+ SvLBoxEntry* pEntry = m_rTableList.FirstSelected();
+ return pEntry && !m_rTableList.GetModel()->HasChilds( pEntry );
+}
+
+//==============================================================================
+//= QueryListFacade
+//==============================================================================
+class QueryListFacade : public ::cppu::BaseMutex
+ , public TableObjectListFacade
+ , public ::comphelper::OContainerListener
+{
+ SvTreeListBox& m_rQueryList;
+ Reference< XConnection > m_xConnection;
+ ::rtl::Reference< comphelper::OContainerListenerAdapter>
+ m_pContainerListener;
+
+public:
+ QueryListFacade( SvTreeListBox& _rQueryList, const Reference< XConnection >& _rxConnection )
+ : ::comphelper::OContainerListener(m_aMutex)
+ ,m_rQueryList( _rQueryList )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+ virtual ~QueryListFacade();
+private:
+ virtual void updateTableObjectList( bool _bAllowViews );
+ virtual String getSelectedName( String& _out_rAliasName ) const;
+ virtual bool isLeafSelected() const;
+ // OContainerListener
+ virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+};
+QueryListFacade::~QueryListFacade()
+{
+ if ( m_pContainerListener.is() )
+ m_pContainerListener->dispose();
+}
+// -----------------------------------------------------------------------------
+void QueryListFacade::_elementInserted( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sName;
+ if ( _rEvent.Accessor >>= sName )
+ m_rQueryList.InsertEntry( sName );
+}
+// -----------------------------------------------------------------------------
+void QueryListFacade::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ updateTableObjectList(true);
+}
+// -----------------------------------------------------------------------------
+void QueryListFacade::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------------
+void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ )
+{
+ m_rQueryList.Clear();
+ try
+ {
+ ImageProvider aImageProvider( m_xConnection );
+ Image aQueryImage( aImageProvider.getDefaultImage( DatabaseObject::QUERY ) );
+
+ m_rQueryList.SetDefaultExpandedEntryBmp( aQueryImage );
+ m_rQueryList.SetDefaultCollapsedEntryBmp( aQueryImage );
+
+ Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY_THROW );
+ if ( !m_pContainerListener.is() )
+ {
+ Reference< XContainer> xContainer(xQueries,UNO_QUERY_THROW);
+ m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
+ }
+ Sequence< ::rtl::OUString > aQueryNames = xQueries->getElementNames();
+
+ const ::rtl::OUString* pQuery = aQueryNames.getConstArray();
+ const ::rtl::OUString* pQueryEnd = aQueryNames.getConstArray() + aQueryNames.getLength();
+ while ( pQuery != pQueryEnd )
+ m_rQueryList.InsertEntry( *pQuery++ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+String QueryListFacade::getSelectedName( String& _out_rAliasName ) const
+{
+ String sSelected;
+ SvLBoxEntry* pEntry = m_rQueryList.FirstSelected();
+ if ( pEntry )
+ sSelected = _out_rAliasName = m_rQueryList.GetEntryText( pEntry );
+ return sSelected;
+}
+
+//------------------------------------------------------------------------------
+bool QueryListFacade::isLeafSelected() const
+{
+ SvLBoxEntry* pEntry = m_rQueryList.FirstSelected();
+ return pEntry && !m_rQueryList.GetModel()->HasChilds( pEntry );
+}
+
+//==============================================================================
+//= OAddTableDlg
+//==============================================================================
+//------------------------------------------------------------------------------
+OAddTableDlg::OAddTableDlg( Window* pParent, IAddTableDialogContext& _rContext )
+ :ModelessDialog( pParent, ModuleRes(DLG_JOIN_TABADD) )
+ ,m_aCaseTables( this, ModuleRes( RB_CASE_TABLES ) )
+ ,m_aCaseQueries( this, ModuleRes( RB_CASE_QUERIES ) )
+ ,m_aTableList( this, NULL, ModuleRes( LB_TABLE_OR_QUERY ), sal_False )
+ ,m_aQueryList( this, ModuleRes( LB_TABLE_OR_QUERY ) )
+ ,aAddButton( this, ModuleRes( PB_ADDTABLE ) )
+ ,aCloseButton( this, ModuleRes( PB_CLOSE ) )
+ ,aHelpButton( this, ModuleRes( PB_HELP ) )
+ ,m_rContext( _rContext )
+{
+ // der Close-Button hat schon einen Standard-Help-Text, den ich aber hier nicht haben moechte, also den Text ruecksetzen
+ // und eine neue ID verteilen
+ aCloseButton.SetHelpText(String());
+ aCloseButton.SetHelpId(HID_JOINSH_ADDTAB_CLOSE);
+
+ m_aTableList.SetHelpId( HID_JOINSH_ADDTAB_TABLELIST );
+ m_aQueryList.SetHelpId( HID_JOINSH_ADDTAB_QUERYLIST );
+
+ //////////////////////////////////////////////////////////////////////
+ m_aCaseTables.SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) );
+ m_aCaseQueries.SetClickHdl( LINK( this, OAddTableDlg, OnTypeSelected ) );
+ aAddButton.SetClickHdl( LINK( this, OAddTableDlg, AddClickHdl ) );
+ aCloseButton.SetClickHdl( LINK( this, OAddTableDlg, CloseClickHdl ) );
+ m_aTableList.SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) );
+ m_aTableList.SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) );
+ m_aQueryList.SetDoubleClickHdl( LINK( this, OAddTableDlg, TableListDoubleClickHdl ) );
+ m_aQueryList.SetSelectHdl( LINK( this, OAddTableDlg, TableListSelectHdl ) );
+
+ //////////////////////////////////////////////////////////////////////
+ m_aTableList.EnableInplaceEditing( sal_False );
+ m_aTableList.SetStyle(m_aTableList.GetStyle() | WB_BORDER | WB_HASLINES |WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_SORT | WB_HSCROLL );
+ m_aTableList.EnableCheckButton( NULL ); // do not show any buttons
+ m_aTableList.SetSelectionMode( SINGLE_SELECTION );
+ m_aTableList.notifyHiContrastChanged();
+ m_aTableList.suppressEmptyFolders();
+
+ //////////////////////////////////////////////////////////////////////
+ m_aQueryList.EnableInplaceEditing( sal_False );
+ m_aQueryList.SetSelectionMode( SINGLE_SELECTION );
+
+ //////////////////////////////////////////////////////////////////////
+ if ( !m_rContext.allowQueries() )
+ {
+ m_aCaseTables.Hide();
+ m_aCaseQueries.Hide();
+
+ long nPixelDiff = m_aTableList.GetPosPixel().Y() - m_aCaseTables.GetPosPixel().Y();
+
+ Point aListPos( m_aTableList.GetPosPixel() );
+ aListPos.Y() -= nPixelDiff;
+
+ Size aListSize( m_aTableList.GetSizePixel() );
+ aListSize.Height() += nPixelDiff;
+
+ m_aTableList.SetPosSizePixel( aListPos, aListSize );
+ }
+
+ FreeResource();
+
+ SetText( getDialogTitleForContext( m_rContext ) );
+}
+
+//------------------------------------------------------------------------------
+OAddTableDlg::~OAddTableDlg()
+{
+ m_rContext.onWindowClosing( this );
+}
+
+//------------------------------------------------------------------------------
+void OAddTableDlg::impl_switchTo( ObjectList _eList )
+{
+ switch ( _eList )
+ {
+ case Tables:
+ m_aTableList.Show( sal_True ); m_aCaseTables.Check( sal_True );
+ m_aQueryList.Show( sal_False ); m_aCaseQueries.Check( sal_False );
+ m_pCurrentList.reset( new TableListFacade( m_aTableList, m_rContext.getConnection() ) );
+ m_aTableList.GrabFocus();
+ break;
+
+ case Queries:
+ m_aTableList.Show( sal_False ); m_aCaseTables.Check( sal_False );
+ m_aQueryList.Show( sal_True ); m_aCaseQueries.Check( sal_True );
+ m_pCurrentList.reset( new QueryListFacade( m_aQueryList, m_rContext.getConnection() ) );
+ m_aQueryList.GrabFocus();
+ break;
+ }
+ m_pCurrentList->updateTableObjectList( m_rContext.allowViews() );
+}
+
+//------------------------------------------------------------------------------
+void OAddTableDlg::Update()
+{
+ if ( !m_pCurrentList.get() )
+ impl_switchTo( Tables );
+ else
+ m_pCurrentList->updateTableObjectList( m_rContext.allowViews() );
+}
+
+//------------------------------------------------------------------------------
+void OAddTableDlg::impl_addTable()
+{
+ if ( m_pCurrentList->isLeafSelected() )
+ {
+ String sSelectedName, sAliasName;
+ sSelectedName = m_pCurrentList->getSelectedName( sAliasName );
+
+ m_rContext.addTableWindow( sSelectedName, sAliasName );
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OAddTableDlg, AddClickHdl, Button*, /*pButton*/ )
+{
+ TableListDoubleClickHdl(NULL);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OAddTableDlg, TableListDoubleClickHdl, void*, /*EMPTY_ARG*/ )
+{
+ if ( impl_isAddAllowed() )
+ {
+ impl_addTable();
+ if ( !impl_isAddAllowed() )
+ Close();
+ return 1L; // handled
+ }
+
+ return 0L; // not handled
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OAddTableDlg, TableListSelectHdl, void*, /*EMPTY_ARG*/ )
+{
+ aAddButton.Enable( m_pCurrentList->isLeafSelected() );
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OAddTableDlg, CloseClickHdl, Button*, /*pButton*/ )
+{
+ return Close();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OAddTableDlg, OnTypeSelected, void*, /*EMPTY_ARG*/ )
+{
+ if ( m_aCaseTables.IsChecked() )
+ impl_switchTo( Tables );
+ else
+ impl_switchTo( Queries );
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OAddTableDlg::Close()
+{
+ m_rContext.onWindowClosing( this );
+ return ModelessDialog::Close();
+}
+
+//------------------------------------------------------------------------------
+bool OAddTableDlg::impl_isAddAllowed()
+{
+ return m_rContext.allowAddition();
+}
+
+//------------------------------------------------------------------------------
+String OAddTableDlg::getDialogTitleForContext( IAddTableDialogContext& _rContext )
+{
+ String sTitle;
+
+ ::svt::OLocalResourceAccess aLocalRes( ModuleRes( DLG_JOIN_TABADD ), RSC_MODELESSDIALOG );
+ if ( _rContext.allowQueries() )
+ sTitle = String( ModuleRes( STR_ADD_TABLE_OR_QUERY ) );
+ else
+ sTitle = String( ModuleRes( STR_ADD_TABLES ) );
+
+ return sTitle;
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/adtabdlg.hrc b/dbaccess/source/ui/dlg/adtabdlg.hrc
new file mode 100644
index 000000000000..3c0e348abfaa
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adtabdlg.hrc
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_ADTABDLG_HRC
+#define DBAUI_ADTABDLG_HRC
+
+#define LB_TABLE_OR_QUERY 1
+#define LB_DATABASE 2
+
+#define FT_DATABASE 1
+
+#define PB_ADDTABLE 1
+#define PB_CLOSE 2
+#define PB_HELP 3
+
+#define RB_CASE_TABLES 1
+#define RB_CASE_QUERIES 2
+
+#define STR_ADD_TABLES 1
+#define STR_ADD_TABLE_OR_QUERY 2
+
+#endif // DBAUI_ADTABDLG_HRC
+
+
diff --git a/dbaccess/source/ui/dlg/adtabdlg.src b/dbaccess/source/ui/dlg/adtabdlg.src
new file mode 100644
index 000000000000..deb914dd831d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/adtabdlg.src
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+
+#ifndef DBAUI_ADTABDLG_HRC
+#include "adtabdlg.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+ModelessDialog DLG_JOIN_TABADD
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_DLG_JOIN_TABADD ;
+ Size = MAP_APPFONT ( 178 , 147 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+
+ RadioButton RB_CASE_TABLES
+ {
+ HelpID = "dbaccess:RadioButton:DLG_JOIN_TABADD:RB_CASE_TABLES";
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 50, 8 );
+ Text [ en-US ] = "Tables";
+ };
+
+ RadioButton RB_CASE_QUERIES
+ {
+ HelpID = "dbaccess:RadioButton:DLG_JOIN_TABADD:RB_CASE_QUERIES";
+ Pos = MAP_APPFONT( 62, 6 );
+ Size = MAP_APPFONT( 50, 8 );
+ Text [ en-US ] = "Queries";
+ };
+
+ Control LB_TABLE_OR_QUERY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 106 , 122 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE;
+ Group = TRUE;
+ };
+
+ PushButton PB_ADDTABLE
+ {
+ HelpID = "dbaccess:PushButton:DLG_JOIN_TABADD:PB_ADDTABLE";
+ Pos = MAP_APPFONT ( 123 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( 123 , 22 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ HelpId = HID_JOINSH_ADDTAB_CLOSE;
+ Text [ en-US ] = "~Close" ;
+ TabStop = TRUE ;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 123 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ String STR_ADD_TABLES
+ {
+ Text [ en-US ] = "Add Tables";
+ };
+
+ String STR_ADD_TABLE_OR_QUERY
+ {
+ Text [ en-US ] = "Add Table or Query" ;
+ };
+};
diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx
new file mode 100644
index 000000000000..d7dec225f1a8
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.cxx
@@ -0,0 +1,604 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "advancedsettings.hxx"
+#include "advancedsettingsdlg.hxx"
+#include "moduledbu.hxx"
+#include "dsitems.hxx"
+#include "DbAdminImpl.hxx"
+#include "DriverSettings.hxx"
+#include "optionalboolitem.hxx"
+#include "dbu_resource.hrc"
+#include "dbu_dlg.hrc"
+#include "dbadmin.hrc"
+#include "advancedsettings.hrc"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XDriver;
+ /** === end UNO using === **/
+
+ //========================================================================
+ //= SpecialSettingsPage
+ //========================================================================
+ struct BooleanSettingDesc
+ {
+ CheckBox** ppControl; // the dialog's control which displays this setting
+ sal_uInt16 nControlResId; // the resource ID to load the control from
+ sal_uInt16 nItemId; // the ID of the item (in an SfxItemSet) which corresponds to this setting
+ bool bInvertedDisplay; // true if and only if the checkbox is checked when the item is sal_False, and vice versa
+ };
+
+ //========================================================================
+ //= SpecialSettingsPage
+ //========================================================================
+ SpecialSettingsPage::SpecialSettingsPage( Window* pParent, const SfxItemSet& _rCoreAttrs, const DataSourceMetaData& _rDSMeta )
+ :OGenericAdministrationPage( pParent, ModuleRes( PAGE_ADVANCED_SETTINGS_SPECIAL ), _rCoreAttrs )
+ ,m_aTopLine( this, ModuleRes( FL_DATAHANDLING ) )
+ ,m_pIsSQL92Check( NULL )
+ ,m_pAppendTableAlias( NULL )
+ ,m_pAsBeforeCorrelationName( NULL )
+ ,m_pEnableOuterJoin( NULL )
+ ,m_pIgnoreDriverPrivileges( NULL )
+ ,m_pParameterSubstitution( NULL )
+ ,m_pSuppressVersionColumn( NULL )
+ ,m_pCatalog( NULL )
+ ,m_pSchema( NULL )
+ ,m_pIndexAppendix( NULL )
+ ,m_pDosLineEnds( NULL )
+ ,m_pCheckRequiredFields( NULL )
+ ,m_pIgnoreCurrency(NULL)
+ ,m_pEscapeDateTime(NULL)
+ ,m_pPrimaryKeySupport(NULL)
+ ,m_pBooleanComparisonModeLabel( NULL )
+ ,m_pBooleanComparisonMode( NULL )
+ ,m_pMaxRowScanLabel( NULL )
+ ,m_pMaxRowScan( NULL )
+ ,m_aControlDependencies()
+ ,m_aBooleanSettings()
+ ,m_bHasBooleanComparisonMode( _rDSMeta.getFeatureSet().has( DSID_BOOLEANCOMPARISON ) )
+ ,m_bHasMaxRowScan( _rDSMeta.getFeatureSet().has( DSID_MAX_ROW_SCAN ) )
+ {
+ impl_initBooleanSettings();
+
+ const FeatureSet& rFeatures( _rDSMeta.getFeatureSet() );
+ // create all the check boxes for the boolean settings
+ for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
+ setting != m_aBooleanSettings.end();
+ ++setting
+ )
+ {
+ sal_uInt16 nItemId = setting->nItemId;
+ if ( rFeatures.has( nItemId ) )
+ {
+ sal_uInt16 nResourceId = setting->nControlResId;
+ (*setting->ppControl) = new CheckBox( this, ModuleRes( nResourceId ) );
+ (*setting->ppControl)->SetClickHdl( getControlModifiedLink() );
+
+ // check whether this must be a tristate check box
+ const SfxPoolItem& rItem = _rCoreAttrs.Get( nItemId );
+ if ( rItem.ISA( OptionalBoolItem ) )
+ (*setting->ppControl)->EnableTriState( sal_True );
+ }
+ }
+
+ if ( m_pAsBeforeCorrelationName && m_pAppendTableAlias )
+ // make m_pAsBeforeCorrelationName depend on m_pAppendTableAlias
+ m_aControlDependencies.enableOnCheckMark( *m_pAppendTableAlias, *m_pAsBeforeCorrelationName );
+
+ // move the controls to the appropriate positions
+ Point aPos( m_aTopLine.GetPosPixel() );
+ aPos.Move( 0, m_aTopLine.GetSizePixel().Height() );
+ Size aFirstDistance( LogicToPixel( Size( INDENTED_X, RELATED_CONTROLS ), MAP_APPFONT ) );
+ aPos.Move( aFirstDistance.Width(), aFirstDistance.Height() );
+
+ Size aUnrelatedControls( LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ) );
+
+ for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
+ setting != m_aBooleanSettings.end();
+ ++setting
+ )
+ {
+ if ( !*setting->ppControl )
+ continue;
+
+ (*setting->ppControl)->SetPosPixel( aPos );
+ aPos.Move( 0, (*setting->ppControl)->GetSizePixel().Height() );
+ aPos.Move( 0, aUnrelatedControls.Height() );
+ }
+
+ // create the controls for the boolean comparison mode
+ if ( m_bHasBooleanComparisonMode )
+ {
+ m_pBooleanComparisonModeLabel = new FixedText( this, ModuleRes( FT_BOOLEANCOMPARISON ) );
+ m_pBooleanComparisonMode = new ListBox( this, ModuleRes( LB_BOOLEANCOMPARISON ) );
+ m_pBooleanComparisonMode->SetDropDownLineCount( 4 );
+ m_pBooleanComparisonMode->SetSelectHdl( getControlModifiedLink() );
+
+ Point aLabelPos( m_pBooleanComparisonModeLabel->GetPosPixel() );
+ Point aControlPos( m_pBooleanComparisonMode->GetPosPixel() );
+ long nMoveUp = aControlPos.Y() - aPos.Y();
+
+ m_pBooleanComparisonModeLabel->SetPosPixel( Point( aLabelPos.X(), aLabelPos.Y() - nMoveUp ) );
+ m_pBooleanComparisonMode->SetPosPixel( Point( aControlPos.X(), aControlPos.Y() - nMoveUp ) );
+ }
+ // create the controls for the max row scan
+ if ( m_bHasMaxRowScan )
+ {
+ m_pMaxRowScanLabel = new FixedText( this, ModuleRes( FT_MAXROWSCAN ) );
+ m_pMaxRowScan = new NumericField( this, ModuleRes( NF_MAXROWSCAN ) );
+ m_pMaxRowScan->SetModifyHdl(getControlModifiedLink());
+ m_pMaxRowScan->SetUseThousandSep(sal_False);
+
+ Point aLabelPos( m_pMaxRowScanLabel->GetPosPixel() );
+ Point aControlPos( m_pMaxRowScan->GetPosPixel() );
+ long nMoveUp = aControlPos.Y() - aPos.Y();
+
+ m_pMaxRowScanLabel->SetPosPixel( Point( aLabelPos.X(), aLabelPos.Y() - nMoveUp ) );
+ m_pMaxRowScan->SetPosPixel( Point( aControlPos.X(), aControlPos.Y() - nMoveUp ) );
+ }
+
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ SpecialSettingsPage::~SpecialSettingsPage()
+ {
+ m_aControlDependencies.clear();
+
+ DELETEZ( m_pIsSQL92Check );
+ DELETEZ( m_pAppendTableAlias );
+ DELETEZ( m_pAsBeforeCorrelationName );
+ DELETEZ( m_pParameterSubstitution );
+ DELETEZ( m_pIgnoreDriverPrivileges );
+ DELETEZ( m_pSuppressVersionColumn );
+ DELETEZ( m_pEnableOuterJoin );
+ DELETEZ( m_pCatalog );
+ DELETEZ( m_pSchema );
+ DELETEZ( m_pIndexAppendix );
+ DELETEZ( m_pDosLineEnds );
+ DELETEZ( m_pCheckRequiredFields );
+ DELETEZ( m_pIgnoreCurrency );
+ DELETEZ( m_pEscapeDateTime );
+ DELETEZ( m_pPrimaryKeySupport );
+ DELETEZ( m_pBooleanComparisonModeLabel );
+ DELETEZ( m_pBooleanComparisonMode );
+ DELETEZ( m_pMaxRowScanLabel );
+ DELETEZ( m_pMaxRowScan );
+ }
+
+ // -----------------------------------------------------------------------
+ void SpecialSettingsPage::impl_initBooleanSettings()
+ {
+ OSL_PRECOND( m_aBooleanSettings.empty(), "SpecialSettingsPage::impl_initBooleanSettings: called twice!" );
+
+ // for easier maintainance, write the table in this form, then copy it to m_aBooleanSettings
+ BooleanSettingDesc aSettings[] = {
+ { &m_pIsSQL92Check, CB_SQL92CHECK, DSID_SQL92CHECK, false },
+ { &m_pAppendTableAlias, CB_APPENDTABLEALIAS, DSID_APPEND_TABLE_ALIAS, false },
+ { &m_pAsBeforeCorrelationName, CB_AS_BEFORE_CORR_NAME, DSID_AS_BEFORE_CORRNAME, false },
+ { &m_pEnableOuterJoin, CB_ENABLEOUTERJOIN, DSID_ENABLEOUTERJOIN, false },
+ { &m_pIgnoreDriverPrivileges, CB_IGNOREDRIVER_PRIV, DSID_IGNOREDRIVER_PRIV, false },
+ { &m_pParameterSubstitution, CB_PARAMETERNAMESUBST, DSID_PARAMETERNAMESUBST, false },
+ { &m_pSuppressVersionColumn, CB_SUPPRESVERSIONCL, DSID_SUPPRESSVERSIONCL, true },
+ { &m_pCatalog, CB_CATALOG, DSID_CATALOG, false },
+ { &m_pSchema, CB_SCHEMA, DSID_SCHEMA, false },
+ { &m_pIndexAppendix, CB_IGNOREINDEXAPPENDIX, DSID_INDEXAPPENDIX, false },
+ { &m_pDosLineEnds, CB_DOSLINEENDS, DSID_DOSLINEENDS, false },
+ { &m_pCheckRequiredFields, CB_CHECK_REQUIRED, DSID_CHECK_REQUIRED_FIELDS, false },
+ { &m_pIgnoreCurrency, CB_IGNORECURRENCY, DSID_IGNORECURRENCY, false },
+ { &m_pEscapeDateTime, CB_ESCAPE_DATETIME, DSID_ESCAPE_DATETIME, false },
+ { &m_pPrimaryKeySupport, CB_PRIMARY_KEY_SUPPORT, DSID_PRIMARY_KEY_SUPPORT, false },
+ { NULL, 0, 0, false }
+ };
+
+ for ( const BooleanSettingDesc* pCopy = aSettings; pCopy->nItemId != 0; ++pCopy )
+ {
+ m_aBooleanSettings.push_back( *pCopy );
+ }
+ }
+
+ // -----------------------------------------------------------------------
+ void SpecialSettingsPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ if ( m_bHasBooleanComparisonMode )
+ {
+ _rControlList.push_back( new ODisableWrapper< FixedText >( m_pBooleanComparisonModeLabel ) );
+ }
+ if ( m_bHasMaxRowScan )
+ {
+ _rControlList.push_back( new ODisableWrapper< FixedText >( m_pMaxRowScanLabel ) );
+ }
+ }
+
+ // -----------------------------------------------------------------------
+ void SpecialSettingsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
+ setting != m_aBooleanSettings.end();
+ ++setting
+ )
+ {
+ if ( *setting->ppControl )
+ {
+ _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *setting->ppControl ) );
+ }
+ }
+
+ if ( m_bHasBooleanComparisonMode )
+ _rControlList.push_back( new OSaveValueWrapper< ListBox >( m_pBooleanComparisonMode ) );
+ if ( m_bHasMaxRowScan )
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(m_pMaxRowScan));
+ }
+
+ // -----------------------------------------------------------------------
+ void SpecialSettingsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags( _rSet, bValid, bReadonly );
+
+ if ( !bValid )
+ {
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ return;
+ }
+
+ // the boolean items
+ for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
+ setting != m_aBooleanSettings.end();
+ ++setting
+ )
+ {
+ if ( !*setting->ppControl )
+ continue;
+
+ ::boost::optional< bool > aValue;
+
+ SFX_ITEMSET_GET( _rSet, pItem, SfxPoolItem, setting->nItemId, sal_True );
+ if ( pItem->ISA( SfxBoolItem ) )
+ {
+ aValue.reset( PTR_CAST( SfxBoolItem, pItem )->GetValue() );
+ }
+ else if ( pItem->ISA( OptionalBoolItem ) )
+ {
+ aValue = PTR_CAST( OptionalBoolItem, pItem )->GetFullValue();
+ }
+ else
+ OSL_FAIL( "SpecialSettingsPage::implInitControls: unknown boolean item type!" );
+
+ if ( !aValue )
+ {
+ (*setting->ppControl)->SetState( STATE_DONTKNOW );
+ }
+ else
+ {
+ sal_Bool bValue = *aValue;
+ if ( setting->bInvertedDisplay )
+ bValue = !bValue;
+ (*setting->ppControl)->Check( bValue );
+ }
+ }
+
+ // the non-boolean items
+ if ( m_bHasBooleanComparisonMode )
+ {
+ SFX_ITEMSET_GET( _rSet, pBooleanComparison, SfxInt32Item, DSID_BOOLEANCOMPARISON, sal_True );
+ m_pBooleanComparisonMode->SelectEntryPos( static_cast< sal_uInt16 >( pBooleanComparison->GetValue() ) );
+ }
+
+ if ( m_bHasMaxRowScan )
+ {
+ SFX_ITEMSET_GET(_rSet, pMaxRowScan, SfxInt32Item, DSID_MAX_ROW_SCAN, sal_True);
+ m_pMaxRowScan->SetValue(pMaxRowScan->GetValue());
+ }
+
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool SpecialSettingsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ // the boolean items
+ for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin();
+ setting != m_aBooleanSettings.end();
+ ++setting
+ )
+ {
+ if ( !*setting->ppControl )
+ continue;
+ fillBool( _rSet, *setting->ppControl, setting->nItemId, bChangedSomething, setting->bInvertedDisplay );
+ }
+
+ // the non-boolean items
+ if ( m_bHasBooleanComparisonMode )
+ {
+ if ( m_pBooleanComparisonMode->GetSelectEntryPos() != m_pBooleanComparisonMode->GetSavedValue() )
+ {
+ _rSet.Put( SfxInt32Item( DSID_BOOLEANCOMPARISON, m_pBooleanComparisonMode->GetSelectEntryPos() ) );
+ bChangedSomething = sal_True;
+ }
+ }
+ if ( m_bHasMaxRowScan )
+ {
+ fillInt32(_rSet,m_pMaxRowScan,DSID_MAX_ROW_SCAN,bChangedSomething);
+ }
+ return bChangedSomething;
+ }
+
+ //========================================================================
+ //= GeneratedValuesPage
+ //========================================================================
+ //------------------------------------------------------------------------
+ GeneratedValuesPage::GeneratedValuesPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OGenericAdministrationPage(pParent, ModuleRes( PAGE_GENERATED_VALUES ), _rCoreAttrs)
+ ,m_aAutoFixedLine ( this, ModuleRes( FL_SEPARATORAUTO ) )
+ ,m_aAutoRetrievingEnabled( this, ModuleRes( CB_RETRIEVE_AUTO ) )
+ ,m_aAutoIncrementLabel ( this, ModuleRes( FT_AUTOINCREMENTVALUE ) )
+ ,m_aAutoIncrement ( this, ModuleRes( ET_AUTOINCREMENTVALUE ) )
+ ,m_aAutoRetrievingLabel ( this, ModuleRes( FT_RETRIEVE_AUTO ) )
+ ,m_aAutoRetrieving ( this, ModuleRes( ET_RETRIEVE_AUTO ) )
+ {
+ m_aAutoRetrievingEnabled.SetClickHdl( getControlModifiedLink() );
+ m_aAutoIncrement.SetModifyHdl( getControlModifiedLink() );
+ m_aAutoRetrieving.SetModifyHdl( getControlModifiedLink() );
+
+ m_aControlDependencies.enableOnCheckMark( m_aAutoRetrievingEnabled,
+ m_aAutoIncrementLabel, m_aAutoIncrement, m_aAutoRetrievingLabel, m_aAutoRetrieving );
+
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ GeneratedValuesPage::~GeneratedValuesPage()
+ {
+ m_aControlDependencies.clear();
+ }
+
+ // -----------------------------------------------------------------------
+ void GeneratedValuesPage::fillWindows( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ _rControlList.push_back( new ODisableWrapper< FixedLine >( &m_aAutoFixedLine ) );
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoIncrementLabel ) );
+ _rControlList.push_back( new ODisableWrapper< FixedText >( &m_aAutoRetrievingLabel ) );
+ }
+
+ // -----------------------------------------------------------------------
+ void GeneratedValuesPage::fillControls( ::std::vector< ISaveValueWrapper* >& _rControlList )
+ {
+ _rControlList.push_back( new OSaveValueWrapper< CheckBox >( &m_aAutoRetrievingEnabled ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoIncrement ) );
+ _rControlList.push_back( new OSaveValueWrapper< Edit >( &m_aAutoRetrieving ) );
+ }
+
+ // -----------------------------------------------------------------------
+ void GeneratedValuesPage::implInitControls( const SfxItemSet& _rSet, sal_Bool _bSaveValue )
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ // collect the items
+ SFX_ITEMSET_GET(_rSet, pAutoIncrementItem, SfxStringItem, DSID_AUTOINCREMENTVALUE, sal_True);
+ SFX_ITEMSET_GET(_rSet, pAutoRetrieveValueItem, SfxStringItem, DSID_AUTORETRIEVEVALUE, sal_True);
+ SFX_ITEMSET_GET(_rSet, pAutoRetrieveEnabledItem, SfxBoolItem, DSID_AUTORETRIEVEENABLED, sal_True);
+
+ // forward the values to the controls
+ if (bValid)
+ {
+ sal_Bool bEnabled = pAutoRetrieveEnabledItem->GetValue();
+ m_aAutoRetrievingEnabled.Check( bEnabled );
+
+ m_aAutoIncrement.SetText( pAutoIncrementItem->GetValue() );
+ m_aAutoIncrement.ClearModifyFlag();
+ m_aAutoRetrieving.SetText( pAutoRetrieveValueItem->GetValue() );
+ m_aAutoRetrieving.ClearModifyFlag();
+ }
+ OGenericAdministrationPage::implInitControls( _rSet, _bSaveValue );
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool GeneratedValuesPage::FillItemSet(SfxItemSet& _rSet)
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ fillString( _rSet, &m_aAutoIncrement, DSID_AUTOINCREMENTVALUE, bChangedSomething );
+ fillBool( _rSet, &m_aAutoRetrievingEnabled, DSID_AUTORETRIEVEENABLED, bChangedSomething );
+ fillString( _rSet, &m_aAutoRetrieving, DSID_AUTORETRIEVEVALUE, bChangedSomething );
+
+ return bChangedSomething;
+ }
+
+ //========================================================================
+ //= AdvancedSettingsDialog
+ //========================================================================
+ //------------------------------------------------------------------------
+ AdvancedSettingsDialog::AdvancedSettingsDialog( Window* _pParent, SfxItemSet* _pItems,
+ const Reference< XMultiServiceFactory >& _rxORB, const Any& _aDataSourceName )
+ :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADVANCED), _pItems)
+ ,m_pItemSet(_pItems)
+ {
+ m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,_pParent,this));
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ m_pImpl->translateProperties(xDatasource, *_pItems);
+ SetInputSet(_pItems);
+ // propagate this set as our new input set and reset the example set
+ delete pExampleSet;
+ pExampleSet = new SfxItemSet(*GetInputSetImpl());
+
+ const ::rtl::OUString eType = m_pImpl->getDatasourceType(*_pItems);
+
+ DataSourceMetaData aMeta( eType );
+ const FeatureSet& rFeatures( aMeta.getFeatureSet() );
+
+ // auto-generated values?
+ if ( rFeatures.supportsGeneratedValues() )
+ AddTabPage( PAGE_GENERATED_VALUES, String( ModuleRes( STR_GENERATED_VALUE ) ), ODriversSettings::CreateGeneratedValuesPage, NULL );
+
+ // any "special settings"?
+ if ( rFeatures.supportsAnySpecialSetting() )
+ AddTabPage( PAGE_ADVANCED_SETTINGS_SPECIAL, String( ModuleRes( STR_DS_BEHAVIOUR ) ), ODriversSettings::CreateSpecialSettingsPage, NULL );
+
+ // remove the reset button - it's meaning is much too ambiguous in this dialog
+ RemoveResetButton();
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ AdvancedSettingsDialog::~AdvancedSettingsDialog()
+ {
+ SetInputSet(NULL);
+ DELETEZ(pExampleSet);
+ }
+
+ // -----------------------------------------------------------------------
+ bool AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL )
+ {
+ DataSourceMetaData aMeta( _sURL );
+ const FeatureSet& rFeatures( aMeta.getFeatureSet() );
+ if ( rFeatures.supportsGeneratedValues() || rFeatures.supportsAnySpecialSetting() )
+ return true;
+ return false;
+ }
+
+ // -----------------------------------------------------------------------
+ short AdvancedSettingsDialog::Execute()
+ {
+ short nRet = SfxTabDialog::Execute();
+ if ( nRet == RET_OK )
+ {
+ pExampleSet->Put(*GetOutputItemSet());
+ m_pImpl->saveChanges(*pExampleSet);
+ }
+ return nRet;
+ }
+
+ //-------------------------------------------------------------------------
+ void AdvancedSettingsDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
+ {
+ // register ourself as modified listener
+ static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
+ static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
+
+ AdjustLayout();
+ Window *pWin = GetViewWindow();
+ if(pWin)
+ pWin->Invalidate();
+
+ SfxTabDialog::PageCreated(_nId, _rPage);
+ }
+
+ // -----------------------------------------------------------------------------
+ const SfxItemSet* AdvancedSettingsDialog::getOutputSet() const
+ {
+ return pExampleSet;
+ }
+
+ // -----------------------------------------------------------------------------
+ SfxItemSet* AdvancedSettingsDialog::getWriteOutputSet()
+ {
+ return pExampleSet;
+ }
+
+ // -----------------------------------------------------------------------------
+ ::std::pair< Reference< XConnection >, sal_Bool > AdvancedSettingsDialog::createConnection()
+ {
+ return m_pImpl->createConnection();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XMultiServiceFactory > AdvancedSettingsDialog::getORB() const
+ {
+ return m_pImpl->getORB();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XDriver > AdvancedSettingsDialog::getDriver()
+ {
+ return m_pImpl->getDriver();
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString AdvancedSettingsDialog::getDatasourceType(const SfxItemSet& _rSet) const
+ {
+ return m_pImpl->getDatasourceType(_rSet);
+ }
+
+ // -----------------------------------------------------------------------------
+ void AdvancedSettingsDialog::clearPassword()
+ {
+ m_pImpl->clearPassword();
+ }
+
+ // -----------------------------------------------------------------------------
+ void AdvancedSettingsDialog::setTitle(const ::rtl::OUString& _sTitle)
+ {
+ SetText(_sTitle);
+ }
+
+ //-------------------------------------------------------------------------
+ void AdvancedSettingsDialog::enableConfirmSettings( bool _bEnable )
+ {
+ (void)_bEnable;
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool AdvancedSettingsDialog::saveDatasource()
+ {
+ return PrepareLeaveCurrentPage();
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/advancedsettings.hrc b/dbaccess/source/ui/dlg/advancedsettings.hrc
new file mode 100644
index 000000000000..193fdf5f3853
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.hrc
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_ADVANCEDSETTINGS_HRC
+#define DBAUI_ADVANCEDSETTINGS_HRC
+
+#define ADVANCED_CHECKBOX_OPTIONS 15
+#define ADVANCED_LISTBOX_OPTIONS 1
+
+#define ADVANCED_PAGE_X 200
+#define ADVANCED_PAGE_Y \
+ /* top space */ START_Y + \
+ /* label */ FIXEDTEXT_HEIGHT + RELATED_CONTROLS + \
+ /* check boxes */ ( ADVANCED_CHECKBOX_OPTIONS * ( CHECKBOX_HEIGHT + RELATED_CONTROLS ) ) + \
+ /* list boxes */ ( ADVANCED_LISTBOX_OPTIONS * ( LISTBOX_HEIGHT + RELATED_CONTROLS ) ) + \
+ /* bottom space */ START_Y
+
+
+#define STR_GENERATED_VALUE 1
+#define STR_DS_BEHAVIOUR 2
+
+#define FL_SEPARATORAUTO 1
+#define FL_DATAHANDLING 2
+
+#define CB_SUPPRESVERSIONCL 1
+#define CB_SQL92CHECK 2
+#define CB_RETRIEVE_AUTO 3
+#define CB_APPENDTABLEALIAS 4
+#define CB_IGNOREDRIVER_PRIV 5
+#define CB_PARAMETERNAMESUBST 6
+#define CB_ENABLEOUTERJOIN 7
+#define CB_SCHEMA 8
+#define CB_CATALOG 9
+#define CB_IGNOREINDEXAPPENDIX 10
+#define CB_DOSLINEENDS 11
+#define CB_AS_BEFORE_CORR_NAME 12
+#define CB_CHECK_REQUIRED 13
+#define CB_IGNORECURRENCY 14
+#define CB_ESCAPE_DATETIME 15
+#define CB_PRIMARY_KEY_SUPPORT 16
+
+#define ET_AUTOINCREMENTVALUE 1
+#define ET_RETRIEVE_AUTO 2
+
+#define FT_AUTOINCREMENTVALUE 1
+#define FT_RETRIEVE_AUTO 2
+#define FT_BOOLEANCOMPARISON 3
+#define FT_MAXROWSCAN 4
+
+#define LB_BOOLEANCOMPARISON 1
+#define NF_MAXROWSCAN 1
+
+#endif // DBAUI_ADVANCEDSETTINGS_HRC
diff --git a/dbaccess/source/ui/dlg/advancedsettings.hxx b/dbaccess/source/ui/dlg/advancedsettings.hxx
new file mode 100644
index 000000000000..6a6ae93f9f8e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_ADVANCEDSETTINGS_HXX
+#define DBACCESS_ADVANCEDSETTINGS_HXX
+
+#include "adminpages.hxx"
+#include "dsmeta.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svtools/dialogcontrolling.hxx>
+
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+
+#include <vector>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ struct BooleanSettingDesc;
+ typedef ::std::vector< BooleanSettingDesc > BooleanSettingDescs;
+
+ //====================================================================
+ //= SpecialSettingsPage
+ //====================================================================
+ /** implements the "Special Settings" page of the advanced database settings
+ */
+ class SpecialSettingsPage : public OGenericAdministrationPage
+ {
+ protected:
+ FixedLine m_aTopLine;
+ CheckBox* m_pIsSQL92Check;
+ CheckBox* m_pAppendTableAlias;
+ CheckBox* m_pAsBeforeCorrelationName;
+ CheckBox* m_pEnableOuterJoin;
+ CheckBox* m_pIgnoreDriverPrivileges;
+ CheckBox* m_pParameterSubstitution;
+ CheckBox* m_pSuppressVersionColumn;
+ CheckBox* m_pCatalog;
+ CheckBox* m_pSchema;
+ CheckBox* m_pIndexAppendix;
+ CheckBox* m_pDosLineEnds;
+ CheckBox* m_pCheckRequiredFields;
+ CheckBox* m_pIgnoreCurrency;
+ CheckBox* m_pEscapeDateTime;
+ CheckBox* m_pPrimaryKeySupport;
+
+ FixedText* m_pBooleanComparisonModeLabel;
+ ListBox* m_pBooleanComparisonMode;
+
+ FixedText* m_pMaxRowScanLabel;
+ NumericField* m_pMaxRowScan;
+
+ ::svt::ControlDependencyManager
+ m_aControlDependencies;
+
+ BooleanSettingDescs m_aBooleanSettings;
+
+ bool m_bHasBooleanComparisonMode;
+ bool m_bHasMaxRowScan;
+
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ SpecialSettingsPage(Window* pParent, const SfxItemSet& _rCoreAttrs, const DataSourceMetaData& _rDSMeta );
+
+ protected:
+ virtual ~SpecialSettingsPage();
+
+ // OGenericAdministrationPage overridables
+ virtual void implInitControls (const SfxItemSet& _rSet, sal_Bool _bSaveValue );
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ void impl_initBooleanSettings();
+ };
+
+ //====================================================================
+ //= GeneratedValuesPage
+ //====================================================================
+ class GeneratedValuesPage : public OGenericAdministrationPage
+ {
+ protected:
+
+ FixedLine m_aAutoFixedLine;
+ CheckBox m_aAutoRetrievingEnabled;
+ FixedText m_aAutoIncrementLabel;
+ Edit m_aAutoIncrement;
+ FixedText m_aAutoRetrievingLabel;
+ Edit m_aAutoRetrieving;
+
+ ::svt::ControlDependencyManager
+ m_aControlDependencies;
+
+ public:
+ virtual sal_Bool FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ GeneratedValuesPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ protected:
+
+ // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
+ virtual ~GeneratedValuesPage();
+
+ // must be overloaded by subclasses, but it isn't pure virtual
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ DECL_LINK( OnCheckBoxClick, CheckBox * );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_ADVANCEDSETTINGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/advancedsettings.src b/dbaccess/source/ui/dlg/advancedsettings.src
new file mode 100644
index 000000000000..9a2dc467d586
--- /dev/null
+++ b/dbaccess/source/ui/dlg/advancedsettings.src
@@ -0,0 +1,386 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dbaccess_helpid.hrc"
+#include "dbu_dlg.hrc"
+#include "advancedsettings.hrc"
+
+//-------------------------------------------------------------------------
+
+#define AUTO_DATAHANDLING(AUTO_Y) \
+ FixedLine FL_DATAHANDLING \
+ { \
+ Pos = MAP_APPFONT ( RELATED_CONTROLS , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ; \
+ Text [ en-US ] = "Options"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_SQL92CHECK(AUTO_Y) \
+ CheckBox CB_SQL92CHECK \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_SQL92CHECK; \
+ Text[ en-US ] = "Use SQL92 naming constraints"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_APPENDTABLEALIAS(AUTO_Y) \
+ CheckBox CB_APPENDTABLEALIAS \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_APPENDTABLEALIAS; \
+ Text[ en-US ] = "Append the table alias name on SELECT statements"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_AS_BEFORE_CORR_NAME(AUTO_Y) \
+ CheckBox CB_AS_BEFORE_CORR_NAME \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_AS_BEFORE_CORRELATION_NAME; \
+ Text[ en-US ] = "Use keyword AS before table alias names"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_ENABLEOUTERJOIN(AUTO_Y) \
+ CheckBox CB_ENABLEOUTERJOIN \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_ENABLEOUTERJOIN; \
+ Text [ en-US ] = "Use Outer Join syntax '{OJ }'"; \
+ };
+
+
+//-------------------------------------------------------------------------
+
+#define AUTO_IGNOREDRIVER_PRIV(AUTO_Y) \
+ CheckBox CB_IGNOREDRIVER_PRIV \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_IGNOREDRIVER_PRIV; \
+ Text[ en-US ] = "Ignore the privileges from the database driver"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_PARAMETERNAMESUBST(AUTO_Y) \
+ CheckBox CB_PARAMETERNAMESUBST \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_PARAMETERNAMESUBST; \
+ Text[ en-US ] = "Replace named parameters with '?'"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_SUPPRESVERSIONCOLUMN(AUTO_Y) \
+ CheckBox CB_SUPPRESVERSIONCL \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_SUPPRESS_VERSIONCL; \
+ Text [ en-US ] = "Display version columns (when available)"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_CATALOG(AUTO_Y) \
+ CheckBox CB_CATALOG \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_CATALOG; \
+ Text [ en-US ] = "Use catalog name in SELECT statements"; \
+ };
+
+
+//-------------------------------------------------------------------------
+
+#define AUTO_SCHEMA(AUTO_Y) \
+ CheckBox CB_SCHEMA \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_SCHEMA; \
+ Text [ en-US ] = "Use schema name in SELECT statements"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_IGNOREINDEXAPPENDIX(AUTO_Y) \
+ CheckBox CB_IGNOREINDEXAPPENDIX \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_IGNOREINDEXAPPENDIX; \
+ Text[ en-US ] = "Create index with ASC or DESC statement"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_DOSLINEENDS(AUTO_Y) \
+ CheckBox CB_DOSLINEENDS \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_DOSLINEENDS; \
+ Text [ en-US ] = "End text lines with CR+LF"; \
+ };
+
+//-------------------------------------------------------------------------
+#define AUTO_IGNORECURRENCY(AUTO_Y) \
+ CheckBox CB_IGNORECURRENCY \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_IGNORECURRENCY; \
+ Text [ en-US ] = "Ignore currency field information"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_CHECKREQUIRED(AUTO_Y) \
+ CheckBox CB_CHECK_REQUIRED \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_CHECK_REQUIRED_FIELDS; \
+ Text [ en-US ] = "Form data input checks for required fields"; \
+ };
+
+#define AUTO_ESCAPE_DATETIME(AUTO_Y) \
+ CheckBox CB_ESCAPE_DATETIME \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_ESCAPE_DATETIME; \
+ Text [ en-US ] = "Use ODBC conformant date/time literals"; \
+ };
+
+
+#define AUTO_PRIMARY_KEY_SUPPORT(AUTO_Y) \
+ CheckBox CB_PRIMARY_KEY_SUPPORT \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_PRIMARY_KEY_SUPPORT; \
+ Text [ en-US ] = "Supports primary keys"; \
+ };
+
+
+//-------------------------------------------------------------------------
+
+#define WORKAROUND \
+ StringList [ en-US ] = \
+ { \
+ < "Default" ; Default ; > ; \
+ < "SQL" ; Default ; > ; \
+ < "Mixed" ; Default ; > ; \
+ < "MS Access" ; Default ; > ; \
+ };
+
+
+#define AUTO_BOOLEANCOMPARISON(AUTO_Y) \
+ FixedText FT_BOOLEANCOMPARISON \
+ { \
+ Pos = MAP_APPFONT ( START_X , AUTO_Y + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) ; \
+ Size = MAP_APPFONT ( 100 , CHECKBOX_HEIGHT ); \
+ Text [ en-US ] = "Comparison of Boolean values"; \
+ }; \
+ ListBox LB_BOOLEANCOMPARISON \
+ { \
+ Pos = MAP_APPFONT ( START_X + 100, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 60 , LISTBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ SvLook = TRUE; \
+ DropDown = TRUE; \
+ Border = TRUE; \
+ HelpId = HID_DSADMIN_BOOLEANCOMPARISON; \
+ WORKAROUND \
+ }; \
+
+#define AUTO_MAXROWSCAN(AUTO_Y) \
+ FixedText FT_MAXROWSCAN \
+ { \
+ Pos = MAP_APPFONT ( START_X , AUTO_Y + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 ) ; \
+ Size = MAP_APPFONT ( 100 , CHECKBOX_HEIGHT ); \
+ Text [ en-US ] = "Rows to scan column types"; \
+ }; \
+ NumericField NF_MAXROWSCAN \
+ { \
+ Pos = MAP_APPFONT ( START_X + 100, AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 60 , EDIT_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ NoThousandSep = TRUE; \
+ Border = TRUE; \
+ HelpId = HID_DSADMIN_MAXROWSCAN; \
+ }; \
+
+
+//-------------------------------------------------------------------------
+
+TabPage PAGE_GENERATED_VALUES
+{
+ HelpID = "dbaccess:TabPage:PAGE_GENERATED_VALUES";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X , ADVANCED_PAGE_Y ) ;
+ Hide = TRUE;
+
+ FixedLine FL_SEPARATORAUTO
+ {
+ Pos = MAP_APPFONT ( 4, UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*RELATED_CONTROLS , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Settings";
+ };
+
+ CheckBox CB_RETRIEVE_AUTO
+ {
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 2*UNRELATED_CONTROLS , CHECKBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_AUTORETRIEVEENABLED;
+ Text [ en-US ] = "Re~trieve generated values";
+ };
+
+ FixedText FT_AUTOINCREMENTVALUE
+ {
+ Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS + CHECKBOX_HEIGHT ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 6 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Auto-increment statement";
+ };
+
+ Edit ET_AUTOINCREMENTVALUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 3*RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 2*UNRELATED_CONTROLS , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_AUTOINCREMENTVALUE;
+ };
+
+ FixedText FT_RETRIEVE_AUTO
+ {
+ Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 4*RELATED_CONTROLS + EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 6 , 10 ) ;
+ Text [ en-US ] = "~Query of generated values";
+ };
+
+ Edit ET_RETRIEVE_AUTO
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT + 5*RELATED_CONTROLS + EDIT_HEIGHT ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X - 15 - 2*UNRELATED_CONTROLS, EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_RETRIEVE_AUTO;
+ };
+};
+
+//-------------------------------------------------------------------------
+
+TabPage PAGE_ADVANCED_SETTINGS_SPECIAL
+{
+ HelpID = "dbaccess:TabPage:PAGE_ADVANCED_SETTINGS_SPECIAL";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( ADVANCED_PAGE_X , ADVANCED_PAGE_Y ) ;
+ Hide = TRUE;
+ AUTO_DATAHANDLING( RELATED_CONTROLS )
+ AUTO_SQL92CHECK( 1*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS )
+ AUTO_APPENDTABLEALIAS( 2*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 1*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_AS_BEFORE_CORR_NAME( 3*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_ENABLEOUTERJOIN( 4*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 3*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_IGNOREDRIVER_PRIV( 5*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 4*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_PARAMETERNAMESUBST( 6*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 5*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_SUPPRESVERSIONCOLUMN( 7*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 6*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_CATALOG( 8*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 7*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_SCHEMA( 9*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 8*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_IGNOREINDEXAPPENDIX( 10*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 9*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_DOSLINEENDS( 11*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 10*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_CHECKREQUIRED( 12*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 11*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_IGNORECURRENCY( 13*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 12*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_ESCAPE_DATETIME( 14*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_PRIMARY_KEY_SUPPORT( 15*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 15*CHECKBOX_HEIGHT + RELATED_CONTROLS )
+ AUTO_BOOLEANCOMPARISON( 16*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 )
+ AUTO_MAXROWSCAN( 17*RELATED_CONTROLS + FIXEDTEXT_HEIGHT + 14*CHECKBOX_HEIGHT + RELATED_CONTROLS + ( LISTBOX_HEIGHT - CHECKBOX_HEIGHT ) / 2 )
+};
+
+//-------------------------------------------------------------------------
+
+TabDialog DLG_DATABASE_ADVANCED
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_ADVANCED;
+
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ HelpId = HID_DSADMIN_TABCONTROL;
+ };
+
+ String STR_GENERATED_VALUE
+ {
+ Text [ en-US ] = "Generated Values";
+ };
+
+ String STR_DS_BEHAVIOUR
+ {
+ Text [ en-US ] = "Special Settings";
+ };
+
+ Text [ en-US ] = "Advanced Properties" ;
+};
diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx
new file mode 100644
index 000000000000..510b1864eb0b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin.cxx
@@ -0,0 +1,517 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionPage.hxx"
+#include "DbAdminImpl.hxx"
+#include "DriverSettings.hxx"
+#include "adminpages.hxx"
+#include "dbadmin.hrc"
+#include "dbadmin.hxx"
+#include "dbu_dlg.hrc"
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include "dbustrings.hrc"
+#include "dsitems.hxx"
+#include "dsnItem.hxx"
+#include "localresaccess.hxx"
+#include "optionalboolitem.hxx"
+#include "propertysetitem.hxx"
+#include "stringlistitem.hxx"
+
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/confignode.hxx>
+#include <vcl/msgbox.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::util;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+
+//=========================================================================
+//= ODbAdminDialog
+//=========================================================================
+DBG_NAME(ODbAdminDialog)
+//-------------------------------------------------------------------------
+ODbAdminDialog::ODbAdminDialog(Window* _pParent
+ , SfxItemSet* _pItems
+ , const Reference< XMultiServiceFactory >& _rxORB
+ )
+ :SfxTabDialog(_pParent, ModuleRes(DLG_DATABASE_ADMINISTRATION), _pItems)
+ ,m_bApplied(sal_False)
+ ,m_bUIEnabled( sal_True )
+ ,m_nMainPageID( PAGE_CONNECTION )
+{
+ DBG_CTOR(ODbAdminDialog,NULL);
+
+ m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
+
+ // add the initial tab page
+ AddTabPage( m_nMainPageID, String( ModuleRes( STR_PAGETITLE_GENERAL ) ), OConnectionTabPage::Create, NULL );
+
+ // remove the reset button - it's meaning is much too ambiguous in this dialog
+ RemoveResetButton();
+ // no local resources needed anymore
+ FreeResource();
+}
+
+//-------------------------------------------------------------------------
+ODbAdminDialog::~ODbAdminDialog()
+{
+ SetInputSet(NULL);
+ DELETEZ(pExampleSet);
+
+ DBG_DTOR(ODbAdminDialog,NULL);
+}
+//-------------------------------------------------------------------------
+short ODbAdminDialog::Ok()
+{
+ SfxTabDialog::Ok();
+ disabledUI();
+ return ( AR_LEAVE_MODIFIED == implApplyChanges() ) ? RET_OK : RET_CANCEL;
+ // TODO : AR_ERROR is not handled correctly, we always close the dialog here
+}
+
+//-------------------------------------------------------------------------
+void ODbAdminDialog::PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage)
+{
+ // register ourself as modified listener
+ static_cast<OGenericAdministrationPage&>(_rPage).SetServiceFactory(m_pImpl->getORB());
+ static_cast<OGenericAdministrationPage&>(_rPage).SetAdminDialog(this,this);
+
+ AdjustLayout();
+ Window *pWin = GetViewWindow();
+ if(pWin)
+ pWin->Invalidate();
+
+ SfxTabDialog::PageCreated(_nId, _rPage);
+}
+
+// -----------------------------------------------------------------------------
+void ODbAdminDialog::addDetailPage(sal_uInt16 _nPageId, sal_uInt16 _nTextId, CreateTabPage _pCreateFunc)
+{
+ // open our own resource block, as the page titles are strings local to this block
+ LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
+
+ AddTabPage(_nPageId, String(ModuleRes(_nTextId)), _pCreateFunc, NULL);
+ m_aCurrentDetailPages.push(_nPageId);
+}
+
+//-------------------------------------------------------------------------
+void ODbAdminDialog::impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName)
+{
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ impl_resetPages( xDatasource );
+
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION));
+ ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
+ ::dbaccess::DATASOURCE_TYPE eType = pCollection->determineType(getDatasourceType(*getOutputSet()));
+
+ // and insert the new ones
+ switch ( eType )
+ {
+ case ::dbaccess::DST_DBASE:
+ addDetailPage(PAGE_DBASE, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateDbase);
+ break;
+
+ case ::dbaccess::DST_ADO:
+ addDetailPage(PAGE_ADO, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdo);
+ break;
+
+ case ::dbaccess::DST_FLAT:
+ addDetailPage(PAGE_TEXT, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateText);
+ break;
+
+ case ::dbaccess::DST_ODBC:
+ addDetailPage(PAGE_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateODBC);
+ break;
+
+ case ::dbaccess::DST_MYSQL_ODBC:
+ addDetailPage(PAGE_MYSQL_ODBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLODBC);
+ break;
+
+ case ::dbaccess::DST_MYSQL_JDBC:
+ addDetailPage(PAGE_MYSQL_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateMySQLJDBC);
+ break;
+
+ case ::dbaccess::DST_ORACLE_JDBC:
+ addDetailPage(PAGE_ORACLE_JDBC, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateOracleJDBC);
+ break;
+
+ case ::dbaccess::DST_ADABAS:
+ // for adabas we have more than one page
+ // CAUTION: the order of inserting pages matters.
+ // the major detail page should be inserted last always (thus, it becomes the first page after
+ // the general page)
+ addDetailPage(PAGE_ADABAS, STR_PAGETITLE_ADVANCED, ODriversSettings::CreateAdabas);
+ break;
+
+ case ::dbaccess::DST_LDAP:
+ addDetailPage(PAGE_LDAP,STR_PAGETITLE_ADVANCED,ODriversSettings::CreateLDAP);
+ break;
+ case ::dbaccess::DST_USERDEFINE1: /// first user defined driver
+ case ::dbaccess::DST_USERDEFINE2:
+ case ::dbaccess::DST_USERDEFINE3:
+ case ::dbaccess::DST_USERDEFINE4:
+ case ::dbaccess::DST_USERDEFINE5:
+ case ::dbaccess::DST_USERDEFINE6:
+ case ::dbaccess::DST_USERDEFINE7:
+ case ::dbaccess::DST_USERDEFINE8:
+ case ::dbaccess::DST_USERDEFINE9:
+ case ::dbaccess::DST_USERDEFINE10:
+ {
+ LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
+ String aTitle(ModuleRes(STR_PAGETITLE_ADVANCED));
+ AddTabPage(PAGE_USERDRIVER, aTitle, ODriversSettings::CreateUser, 0, sal_False, 1);
+ m_aCurrentDetailPages.push(PAGE_USERDRIVER);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+//-------------------------------------------------------------------------
+void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasource)
+{
+ // the selection is valid if and only if we have a datasource now
+ GetInputSetImpl()->Put(SfxBoolItem(DSID_INVALID_SELECTION, !_rxDatasource.is()));
+ // (sal_False tells the tab pages to disable and reset all their controls, which is different
+ // from "just set them to readonly")
+
+ // reset the pages
+
+ // prevent flicker
+ SetUpdateMode(sal_False);
+
+ // remove all items which relate to indirect properties from the input set
+ // (without this, the following may happen: select an arbitrary data source where some indirect properties
+ // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
+ // the indirect property values of the first ds are shown in the second ds ...)
+ const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties();
+ for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin();
+ aIndirect != rMap.end();
+ ++aIndirect
+ )
+ GetInputSetImpl()->ClearItem( (sal_uInt16)aIndirect->first );
+
+ // extract all relevant data from the property set of the data source
+ m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl());
+
+ // propagate this set as our new input set and reset the example set
+ SetInputSet(GetInputSetImpl());
+ delete pExampleSet;
+ pExampleSet = new SfxItemSet(*GetInputSetImpl());
+
+ // special case: MySQL Native does not have the generic PAGE_CONNECTION page
+
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, getOutputSet()->GetItem(DSID_TYPECOLLECTION));
+ ::dbaccess::ODsnTypeCollection* pCollection = pCollectionItem->getCollection();
+ if ( pCollection->determineType(getDatasourceType( *pExampleSet )) == ::dbaccess::DST_MYSQL_NATIVE )
+ {
+ LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
+ AddTabPage( PAGE_MYSQL_NATIVE, String( ModuleRes( STR_PAGETITLE_CONNECTION ) ), ODriversSettings::CreateMySQLNATIVE, NULL );
+ RemoveTabPage( PAGE_CONNECTION );
+ m_nMainPageID = PAGE_MYSQL_NATIVE;
+ }
+
+ ShowPage( m_nMainPageID );
+ SfxTabPage* pConnectionPage = GetTabPage( m_nMainPageID );
+ if ( pConnectionPage )
+ pConnectionPage->Reset(*GetInputSetImpl());
+ // if this is NULL, the page has not been created yet, which means we're called before the
+ // dialog was displayed (probably from inside the ctor)
+
+ SetUpdateMode(sal_True);
+}
+// -----------------------------------------------------------------------------
+void ODbAdminDialog::setTitle(const ::rtl::OUString& _sTitle)
+{
+ SetText(_sTitle);
+}
+//-------------------------------------------------------------------------
+void ODbAdminDialog::enableConfirmSettings( bool _bEnable )
+{
+ (void)_bEnable;
+}
+//-------------------------------------------------------------------------
+sal_Bool ODbAdminDialog::saveDatasource()
+{
+ return PrepareLeaveCurrentPage();
+}
+//-------------------------------------------------------------------------
+ODbAdminDialog::ApplyResult ODbAdminDialog::implApplyChanges()
+{
+ if (!PrepareLeaveCurrentPage())
+ { // the page did not allow us to leave
+ return AR_KEEP;
+ }
+
+ if ( !m_pImpl->saveChanges(*pExampleSet) )
+ return AR_KEEP;
+
+ if ( isUIEnabled() )
+ ShowPage(GetCurPageId());
+ // This does the usual ActivatePage, so the pages can save their current status.
+ // This way, next time they're asked what has changed since now and here, they really
+ // can compare with the status they have _now_ (not the one they had before this apply call).
+
+ m_bApplied = sal_True;
+
+ return AR_LEAVE_MODIFIED;
+}
+//-------------------------------------------------------------------------
+void ODbAdminDialog::selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName)
+{
+ impl_selectDataSource(_aDataSourceName);
+}
+
+// -----------------------------------------------------------------------------
+const SfxItemSet* ODbAdminDialog::getOutputSet() const
+{
+ return GetExampleSet();
+}
+// -----------------------------------------------------------------------------
+SfxItemSet* ODbAdminDialog::getWriteOutputSet()
+{
+ return pExampleSet;
+}
+// -----------------------------------------------------------------------------
+::std::pair< Reference<XConnection>,sal_Bool> ODbAdminDialog::createConnection()
+{
+ return m_pImpl->createConnection();
+}
+// -----------------------------------------------------------------------------
+Reference< XMultiServiceFactory > ODbAdminDialog::getORB() const
+{
+ return m_pImpl->getORB();
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > ODbAdminDialog::getDriver()
+{
+ return m_pImpl->getDriver();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODbAdminDialog::getDatasourceType(const SfxItemSet& _rSet) const
+{
+ return m_pImpl->getDatasourceType(_rSet);
+}
+// -----------------------------------------------------------------------------
+void ODbAdminDialog::clearPassword()
+{
+ m_pImpl->clearPassword();
+}
+//-------------------------------------------------------------------------
+SfxItemSet* ODbAdminDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection)
+{
+ // just to be sure ....
+ _rpSet = NULL;
+ _rpPool = NULL;
+ _rppDefaults = NULL;
+
+ const ::rtl::OUString sFilterAll( "%", 1, RTL_TEXTENCODING_ASCII_US );
+ // create and initialize the defaults
+ _rppDefaults = new SfxPoolItem*[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1];
+ SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults
+ *pCounter++ = new SfxStringItem(DSID_NAME, String());
+ *pCounter++ = new SfxStringItem(DSID_ORIGINALNAME, String());
+ *pCounter++ = new SfxStringItem(DSID_CONNECTURL, String());
+ *pCounter++ = new OStringListItem(DSID_TABLEFILTER, Sequence< ::rtl::OUString >(&sFilterAll, 1));
+ *pCounter++ = new DbuTypeCollectionItem(DSID_TYPECOLLECTION, _pTypeCollection);
+ *pCounter++ = new SfxBoolItem(DSID_INVALID_SELECTION, sal_False);
+ *pCounter++ = new SfxBoolItem(DSID_READONLY, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_USER, String());
+ *pCounter++ = new SfxStringItem(DSID_PASSWORD, String());
+ *pCounter++ = new SfxStringItem(DSID_ADDITIONALOPTIONS, String());
+ *pCounter++ = new SfxStringItem(DSID_CHARSET, String());
+ *pCounter++ = new SfxBoolItem(DSID_PASSWORDREQUIRED, sal_False);
+ *pCounter++ = new SfxBoolItem(DSID_SHOWDELETEDROWS, sal_False);
+ *pCounter++ = new SfxBoolItem(DSID_ALLOWLONGTABLENAMES, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_JDBCDRIVERCLASS, String());
+ *pCounter++ = new SfxStringItem(DSID_FIELDDELIMITER, ',');
+ *pCounter++ = new SfxStringItem(DSID_TEXTDELIMITER, '"');
+ *pCounter++ = new SfxStringItem(DSID_DECIMALDELIMITER, '.');
+ *pCounter++ = new SfxStringItem(DSID_THOUSANDSDELIMITER, String());
+ *pCounter++ = new SfxStringItem(DSID_TEXTFILEEXTENSION, String::CreateFromAscii("txt"));
+ *pCounter++ = new SfxBoolItem(DSID_TEXTFILEHEADER, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_PARAMETERNAMESUBST, sal_False);
+ *pCounter++ = new SfxInt32Item(DSID_CONN_PORTNUMBER, 8100);
+ *pCounter++ = new SfxBoolItem(DSID_SUPPRESSVERSIONCL, sal_False);
+ *pCounter++ = new OPropertySetItem(DSID_DATASOURCE_UNO);
+ *pCounter++ = new SfxBoolItem(DSID_CONN_SHUTSERVICE, sal_False);
+ *pCounter++ = new SfxInt32Item(DSID_CONN_DATAINC, 20);
+ *pCounter++ = new SfxInt32Item(DSID_CONN_CACHESIZE, 20);
+ *pCounter++ = new SfxStringItem(DSID_CONN_CTRLUSER, String());
+ *pCounter++ = new SfxStringItem(DSID_CONN_CTRLPWD, String());
+ *pCounter++ = new SfxBoolItem(DSID_USECATALOG, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_CONN_HOSTNAME, String());
+ *pCounter++ = new SfxStringItem(DSID_CONN_LDAP_BASEDN, String());
+ *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_PORTNUMBER, 389);
+ *pCounter++ = new SfxInt32Item(DSID_CONN_LDAP_ROWCOUNT, 100);
+ *pCounter++ = new SfxBoolItem(DSID_SQL92CHECK, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_AUTOINCREMENTVALUE, String());
+ *pCounter++ = new SfxStringItem(DSID_AUTORETRIEVEVALUE, String());
+ *pCounter++ = new SfxBoolItem(DSID_AUTORETRIEVEENABLED, sal_False);
+ *pCounter++ = new SfxBoolItem(DSID_APPEND_TABLE_ALIAS, sal_False);
+ *pCounter++ = new SfxInt32Item(DSID_MYSQL_PORTNUMBER, 3306);
+ *pCounter++ = new SfxBoolItem(DSID_IGNOREDRIVER_PRIV, sal_True);
+ *pCounter++ = new SfxInt32Item(DSID_BOOLEANCOMPARISON, 0);
+ *pCounter++ = new SfxInt32Item(DSID_ORACLE_PORTNUMBER, 1521);
+ *pCounter++ = new SfxBoolItem(DSID_ENABLEOUTERJOIN, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_CATALOG, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_SCHEMA, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_INDEXAPPENDIX, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_CONN_LDAP_USESSL, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_DOCUMENT_URL, String());
+ *pCounter++ = new SfxBoolItem(DSID_DOSLINEENDS, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_DATABASENAME, String());
+ *pCounter++ = new SfxBoolItem(DSID_AS_BEFORE_CORRNAME, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_CHECK_REQUIRED_FIELDS, sal_True);
+ *pCounter++ = new SfxBoolItem(DSID_IGNORECURRENCY, sal_False);
+ *pCounter++ = new SfxStringItem(DSID_CONN_SOCKET, String());
+ *pCounter++ = new SfxBoolItem(DSID_ESCAPE_DATETIME, sal_True);
+ *pCounter++ = new SfxStringItem(DSID_NAMED_PIPE, String());
+ *pCounter++ = new OptionalBoolItem( DSID_PRIMARY_KEY_SUPPORT );
+ *pCounter++ = new SfxInt32Item(DSID_MAX_ROW_SCAN, 100);
+
+ // create the pool
+ static SfxItemInfo const aItemInfos[DSID_LAST_ITEM_ID - DSID_FIRST_ITEM_ID + 1] =
+ {
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0},
+ {0,0}
+ };
+
+ OSL_ENSURE(SAL_N_ELEMENTS(aItemInfos) == DSID_LAST_ITEM_ID,"Invalid Ids!");
+ _rpPool = new SfxItemPool(String::CreateFromAscii("DSAItemPool"), DSID_FIRST_ITEM_ID, DSID_LAST_ITEM_ID,
+ aItemInfos, _rppDefaults);
+ _rpPool->FreezeIdRanges();
+
+ // and, finally, the set
+ _rpSet = new SfxItemSet(*_rpPool, sal_True);
+
+ return _rpSet;
+}
+//-------------------------------------------------------------------------
+void ODbAdminDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
+{
+ // _first_ delete the set (refering the pool)
+ if (_rpSet)
+ {
+ delete _rpSet;
+ _rpSet = NULL;
+ }
+
+ // delete the pool
+ if (_rpPool)
+ {
+ _rpPool->ReleaseDefaults(sal_True);
+ // the "true" means delete the items, too
+ SfxItemPool::Free(_rpPool);
+ _rpPool = NULL;
+ }
+
+ // reset the defaults ptr
+ _rppDefaults = NULL;
+ // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dbadmin.hrc b/dbaccess/source/ui/dlg/dbadmin.hrc
new file mode 100644
index 000000000000..88ed5aea8d47
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin.hrc
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBADMIN_HRC_
+#define _DBAUI_DBADMIN_HRC_
+
+//========================================================================
+// control ids
+
+#define FT_DATATYPE 1
+#define FT_DATASOURCETYPE_PRE 2
+#define FT_USERNAME 3
+#define FT_PASSWORD 4
+#define FT_OPTIONS 5
+ // FREE
+#define FT_JDBCDRIVERCLASS 7
+#define FT_SPECIAL_MESSAGE 8
+#define FT_FILTER_EXPLANATION 9
+#define FT_HOSTNAME 10
+#define FT_BASEDN 11
+#define FT_PORTNUMBER 12
+#define FT_LDAPROWCOUNT 13
+#define FT_DATASOURCETYPE_POST 14
+#define FT_GENERALHEADERTEXT 15
+#define FT_GENERALHELPTEXT 16
+#define FT_DATATYPEAPPENDIX 17
+#define FT_DATASOURCEHEADER 18
+#define FT_DOCLISTLABEL 19
+
+#define LB_DATATYPE 1
+ // FREE
+#define LB_DOCUMENTLIST 3
+
+#define ET_USERNAME 1
+#define ET_PASSWORD 2
+#define ET_OPTIONS 3
+#define ET_JDBCDRIVERCLASS 4
+#define ET_HOSTNAME 5
+#define ET_BASEDN 6
+
+#define PB_INDICIES 1
+#define BTN_PASSWORD_OK 2
+#define BTN_PASSWORD_CANCEL 3
+#define BTN_PASSWORD_HELP 4
+#define PB_TESTDRIVERCLASS 5
+#define PB_OPENDOCUMENT 6
+
+#define CB_PASSWORD_REQUIRED 1
+#define CB_SHOWDELETEDROWS 2
+#define CB_USESSL 3
+#define CB_USECATALOG 4
+
+#define FL_SEPARATOR2 1
+
+#define CTL_TABLESUBSCRIPTION 1
+
+#define TLB_ACTIONS 1
+
+#define NF_PORTNUMBER 1
+#define NF_LDAPROWCOUNT 2
+
+#define RB_CREATEDBDATABASE 1
+#define RB_GETEXISTINGDATABASE 2
+#define RB_OPENEXISTINGDOC 3
+
+//========================================================================
+// string ids (usually relative to other resources, that's why not necessarily unique)
+
+#define STR_PAGETITLE_GENERAL 1
+#define STR_PAGETITLE_CONNECTION 2
+#define STR_PAGETITLE_ADVANCED 3
+#define STR_NO_WILDCARDS 4
+#define STR_MYSQLENTRY 5
+#define STR_PARENTTITLE 6
+#define STR_COULDNOTLOAD_ODBCLIB 7
+#define STR_UNSUPPORTED_DATASOURCE_TYPE 8
+#define STR_MYSQL_CONFIG_NEXT_PAGE 9
+#define STR_JDBC_DEFAULT_URL 10
+
+//========================================================================
+// menu item ids
+#define MID_NEW_DATASOURCE 1
+#define MID_DELETE_DATASOURCE 2
+#define MID_RESTORE_DATASOURCE 3
+
+#endif // _DBAUI_DBADMIN_HRC_
+
diff --git a/dbaccess/source/ui/dlg/dbadmin.src b/dbaccess/source/ui/dlg/dbadmin.src
new file mode 100644
index 000000000000..e5eae80b5406
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin.src
@@ -0,0 +1,807 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_ADABASPAGE_HRC
+#include "AdabasPage.hrc"
+#endif
+#include "admincontrols.hrc"
+
+//-------------------------------------------------------------------------
+
+#define AUTO_USECATALOG(AUTO_Y) \
+ CheckBox CB_USECATALOG \
+ { \
+ Pos = MAP_APPFONT ( 6 ,AUTO_Y) ; \
+ Size = MAP_APPFONT ( PAGE_X -12 , CHECKBOX_HEIGHT ) ; \
+ TabStop = TRUE ; \
+ HelpId = HID_DSADMIN_USECATALOG; \
+ Text[ en-US ] = "Use catalog for file-based databases"; \
+ };
+
+//-------------------------------------------------------------------------
+
+#define AUTO_FIXEDLINE_CONNSETTINGS(AUTO_Y) \
+ FixedLine FL_SEPARATOR1 \
+ { \
+ Pos = MAP_APPFONT ( 4 , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "Connection Settings"; \
+ }; \
+
+#define AUTO_HOST_AND_PORT(AUTO_Y) \
+ FixedText FT_HOSTNAME \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y + 2 ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "~Host name"; \
+ }; \
+ Edit ET_HOSTNAME \
+ { \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ HelpId = HID_DSADMIN_HOSTNAME; \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y ) ; \
+ Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; \
+ }; \
+ FixedText FT_PORTNUMBER \
+ { \
+ Pos = MAP_APPFONT ( 6 , AUTO_Y + UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + 2 ) ; \
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ; \
+ Text[ en-US ] = "~Port number"; \
+ }; \
+ NumericField NF_PORTNUMBER \
+ { \
+ TabStop = TRUE ; \
+ Border = TRUE ; \
+ HelpId = HID_DSADMIN_PORTNUMBER; \
+ NoThousandSep = TRUE; \
+ Pos = MAP_APPFONT ( EDIT_X , AUTO_Y +UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT ) ; \
+ Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ; \
+ };
+//-------------------------------------------------------------------------
+
+TabDialog DLG_DATABASE_ADMINISTRATION
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_DIALOG;
+
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ HelpId = HID_DSADMIN_TABCONTROL;
+ };
+
+ //.........................................................................
+ String STR_PAGETITLE_GENERAL
+ {
+ Text [ en-US ] = "Advanced Properties" ;
+ };
+ String STR_PAGETITLE_ADVANCED
+ {
+ Text [ en-US ] = "Additional Settings" ;
+ };
+ String STR_PAGETITLE_CONNECTION
+ {
+ Text [ en-US ] = "Connection settings" ;
+ };
+
+ Text [ en-US ] = "Database properties" ;
+};
+
+// -----------------------------------------------------------------------------
+
+ModalDialog DLG_DATABASE_TYPE_CHANGE
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE;
+ Closeable = TRUE ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_TYPE_DIALOG;
+
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ HelpId = HID_DSADMIN_TABCONTROL;
+ };
+ Text [ en-US ] = "Database properties" ;
+};
+
+//-------------------------------------------------------------------------
+
+TabPage PAGE_GENERAL
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_GENERAL;
+
+
+ FixedText FT_GENERALHEADERTEXT
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Welcome to the %PRODUCTNAME Database Wizard";
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_GENERALHELPTEXT
+ {
+ Pos = MAP_APPFONT (START_X , 27 );
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 5* FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Use the Database Wizard to create a new database, open an existing database file, or connect to a database stored on a server." ;
+ WordBreak = TRUE ;
+ };
+
+ FixedText FT_DATASOURCEHEADER
+ {
+ Pos = MAP_APPFONT ( START_X , 73 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "What do you want to do?";
+ };
+
+ RadioButton RB_CREATEDBDATABASE
+ {
+ HelpId = HID_PAGE_DBWIZARD_GENERAL_RB_CREATEDBDATABASE ;
+ Pos = MAP_APPFONT (START_X + 6 , 85 ) ;
+ Size = MAP_APPFONT ( 205 , 10 ) ;
+ Group = TRUE;
+ Text [ en-US ] = "Create a n~ew database" ;
+ };
+
+ RadioButton RB_OPENEXISTINGDOC
+ {
+ HelpID = "dbaccess:RadioButton:PAGE_GENERAL:RB_OPENEXISTINGDOC";
+ Pos = MAP_APPFONT (START_X + 6 , 97 );
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Open an existing database ~file" ;
+ };
+
+ FixedText FT_DOCLISTLABEL
+ {
+ Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 110 );
+ Size = MAP_APPFONT( 120, 8 );
+ Text [ en-US ] = "Recently used";
+ };
+
+ ListBox LB_DOCUMENTLIST
+ {
+ HelpID = "dbaccess:ListBox:PAGE_GENERAL:LB_DOCUMENTLIST";
+ Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 121 );
+ Size = MAP_APPFONT( 120, 14 );
+ DropDown = TRUE;
+ Border = TRUE;
+ };
+
+ PushButton PB_OPENDOCUMENT
+ {
+ HelpID = "dbaccess:PushButton:PAGE_GENERAL:PB_OPENDOCUMENT";
+ Pos = MAP_APPFONT( START_X + INDENTED_X + INDENT_BELOW_RADIO, 139 );
+ Size = MAP_APPFONT( 50, 16 );
+ OutputSize = TRUE;
+ TabStop = TRUE;
+ };
+
+ RadioButton RB_GETEXISTINGDATABASE
+ {
+ HelpId = HID_PAGE_DBWIZARD_GENERAL_RB_GETEXISTINGDATABASE;
+ Pos = MAP_APPFONT (START_X + 6 , 159 ) ;
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Connect to an e~xisting database" ;
+ };
+
+ FixedText FT_DATASOURCETYPE_PRE
+ {
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , 3*FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "Select the type of database to which you want to establish a connection.";
+ };
+
+ FixedText FT_DATATYPE
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( 80 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Database ~type ";
+ };
+
+ ListBox LB_DATATYPE
+ {
+ HelpId = HID_DSADMIN_DSTYPE;
+ Pos = MAP_APPFONT ( 90, 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS -2 ) ;
+ Size = MAP_APPFONT ( 120, 120 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = FALSE;
+ };
+
+ FixedText FT_DATATYPEAPPENDIX
+ {
+ Pos = MAP_APPFONT ( 90, 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS -2 + 72) ;
+ Size = MAP_APPFONT ( 60, 8 );
+ Text [ en-US ] = "Database";
+ };
+
+ FixedText FT_DATASOURCETYPE_POST
+ {
+ Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - 12 , 5*FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "On the following pages, you can make detailed settings for the connection.\n\nThe new settings you make will overwrite your existing settings.";
+ };
+
+ FixedText FT_SPECIAL_MESSAGE
+ {
+ Pos = MAP_APPFONT ( 6, 4*UNRELATED_CONTROLS + 9*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS );
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - 12, 3*FIXEDTEXT_HEIGHT );
+ WordBreak = TRUE;
+ HelpId = HID_DSADMIN_SPECIAL_MESSAGE;
+ };
+
+ String STR_MYSQLENTRY
+ {
+ Text [ en-US ] = "MySQL" ;
+ };
+
+ String STR_PARENTTITLE
+ {
+ Text [ en-US ] = "Data Source Properties: #" ;
+ };
+ String STR_COULDNOTLOAD_ODBCLIB
+ {
+ Text [ en-US ] = "Could not load the program library #lib# or it is corrupted. The ODBC data source selection is not available.";
+ };
+ String STR_UNSUPPORTED_DATASOURCE_TYPE
+ {
+ Text [ en-US ] = "This kind of data source is not supported on this platform.\nYou are allowed to change the settings, but you probably will not be able to connect to the database.";
+ };
+ Text [ en-US ] = "General" ;
+};
+
+//.........................................................................
+
+TabPage PAGE_DBASE
+{
+ SVLook = TRUE ;
+ Hide = TRUE;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ HelpId = HID_DSADMIN_PAGE_DBASE;
+
+ AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X)
+
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 4 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Optional settings";
+ };
+
+ CheckBox CB_SHOWDELETEDROWS
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( 200 , CHECKBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_SHOWDELETED;
+ Text [ en-US ] = "Display deleted records as well" ;
+ };
+
+ FixedText FT_SPECIAL_MESSAGE
+ {
+ Hide = TRUE;
+ WordBreak = TRUE;
+ Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT) ;
+ Size = MAP_APPFONT ( PAGE_X - 12 , 2*FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Note: When deleted, and thus inactive, records are displayed, you will not be able to delete records from the data source." ;
+ };
+
+ PushButton PB_INDICIES
+ {
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_DBASE_INDICIES;
+ Text [ en-US ] = "Indexes...";
+ };
+};
+
+//.........................................................................
+
+TabPage PAGE_ADO
+{
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_ADO;
+ AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X)
+};
+
+//.........................................................................
+
+TabPage PAGE_ODBC
+{
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_ODBC;
+
+ AUTO_CHARSET(UNRELATED_CONTROLS,PAGE_X)
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 4 , 2*UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Optional Settings";
+ };
+
+ FixedText FT_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "ODBC ~options" ;
+ };
+ Edit ET_OPTIONS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS -1 ) ;
+ Size = MAP_APPFONT ( 130 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_ODBC_OPTIONS;
+ };
+
+ AUTO_USECATALOG( 3*UNRELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 2*RELATED_CONTROLS )
+};
+
+TabPage PAGE_ADABAS
+{
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_ADABAS;
+
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Connection Settings";
+ };
+
+ FixedText FT_HOSTNAME
+ {
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Host name";
+ };
+ Edit ET_HOSTNAME
+ {
+ HelpID = "dbaccess:Edit:PAGE_ADABAS:ET_HOSTNAME";
+ TabStop = TRUE ;
+ Border = TRUE ;
+
+ Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT-1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+
+ FixedText FT_CACHE_SIZE
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Data ~buffer size (MB)";
+ };
+ NumericField NF_CACHE_SIZE
+ {
+ HelpID = "dbaccess:NumericField:PAGE_ADABAS:NF_CACHE_SIZE";
+ Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT -1 ) ;
+ Size = MAP_APPFONT ( 40 , EDIT_HEIGHT ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1;
+ StrictFormat = TRUE;
+ };
+
+ FixedText FT_DATA_INCREMENT
+ {
+ Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Data increment (MB)";
+ };
+ NumericField NF_DATA_INCREMENT
+ {
+ HelpID = "dbaccess:NumericField:PAGE_ADABAS:NF_DATA_INCREMENT";
+ Pos = MAP_APPFONT ( EDIT_X , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 ) ;
+ Size = MAP_APPFONT ( 40 , EDIT_HEIGHT ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1;
+ StrictFormat = TRUE;
+ };
+ FixedLine FL_SEPARATOR2
+ {
+ Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( 248 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Administration" ;
+ };
+ FixedText FT_CTRLUSERNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Control ~user name" ;
+ };
+ Edit ET_CTRLUSERNAME
+ {
+ HelpID = "dbaccess:Edit:PAGE_ADABAS:ET_CTRLUSERNAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT-1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_CTRLPASSWORD
+ {
+ Pos = MAP_APPFONT ( 6 , 5*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Control ~password" ;
+ };
+ Edit ET_CTRLPASSWORD
+ {
+ HelpID = "dbaccess:Edit:PAGE_ADABAS:ET_CTRLPASSWORD";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( EDIT_X , 5*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 6*FIXEDTEXT_HEIGHT-1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT) ;
+ TabStop = TRUE ;
+ PassWord = TRUE ;
+ };
+
+ CheckBox CB_SHUTDB
+ {
+ HelpID = "dbaccess:CheckBox:PAGE_ADABAS:CB_SHUTDB";
+ Pos = MAP_APPFONT ( 6 , 6*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 7*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( 248 , CHECKBOX_HEIGHT ) ;
+ Text[ en-US ] = "~Shut down service when closing %PRODUCTNAME";
+ };
+
+ PushButton PB_STAT
+ {
+ HelpID = "dbaccess:PushButton:PAGE_ADABAS:PB_STAT";
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS, PAGE_Y - BUTTON_HEIGHT - UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ Text[ en-US ] = "E~xtended...";
+ };
+
+ AUTO_CHARSET( 7*UNRELATED_CONTROLS + 2*RELATED_CONTROLS + 7*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT, PAGE_X )
+};
+
+//.........................................................................
+#define MYSQL_YDIST 53
+#define MYSQL_FL_Y 8
+#define MYSQL_DRIVERCLASS_Y 8
+
+TabPage PAGE_MYSQL_ODBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_MYSQL_ODBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+
+ AUTO_CHARSET( UNRELATED_CONTROLS, PAGE_X )
+};
+
+TabPage PAGE_MYSQL_JDBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_MYSQL_JDBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+
+ AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS )
+ AUTO_HOST_AND_PORT( UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT )
+ AUTO_SOCKETCONTROLGROUP(3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT)
+
+ FixedText FT_JDBCDRIVERCLASS
+ {
+ Pos = MAP_APPFONT ( 6,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "MySQL JDBC d~river class";
+ };
+ Edit ET_JDBCDRIVERCLASS
+ {
+ HelpID = "dbaccess:Edit:PAGE_MYSQL_JDBC:ET_JDBCDRIVERCLASS";
+ Pos = MAP_APPFONT ( EDIT_X,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton PB_TESTDRIVERCLASS
+ {
+ HelpID = "dbaccess:PushButton:PAGE_MYSQL_JDBC:PB_TESTDRIVERCLASS";
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -2 + EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ Text [ en-US ] = "Test class" ;
+ };
+
+ AUTO_CHARSET( 5*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT+ EDIT_HEIGHT, PAGE_X )
+};
+
+TabPage PAGE_MYSQL_NATIVE
+{
+ HelpID = "dbaccess:TabPage:PAGE_MYSQL_NATIVE";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+
+ AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS )
+
+ FixedLine FL_SEPARATOR2
+ {
+ Pos = MAP_APPFONT ( 3 , 4*UNRELATED_CONTROLS + 3*RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT ) ;
+ Size = MAP_APPFONT ( PAGE_X - 6, FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "User authentication";
+ };
+ FixedText FT_USERNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + 4*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 6 - RELATED_CONTROLS, FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~User name" ;
+ };
+ Edit ET_USERNAME
+ {
+ HelpID = "dbaccess:Edit:PAGE_MYSQL_NATIVE:ET_USERNAME";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( EDIT_X, 4*UNRELATED_CONTROLS + 4*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 3*EDIT_HEIGHT - 1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox CB_PASSWORD_REQUIRED
+ {
+ HelpID = "dbaccess:CheckBox:PAGE_MYSQL_NATIVE:CB_PASSWORD_REQUIRED";
+ Pos = MAP_APPFONT ( EDIT_X, 4*UNRELATED_CONTROLS + 5*RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT + 4*EDIT_HEIGHT ) ;
+ Size = MAP_APPFONT ( 105, CHECKBOX_HEIGHT ) ;
+ Text [ en-US ] = "Password required";
+ };
+
+ AUTO_CHARSET( 5*UNRELATED_CONTROLS + 5*RELATED_CONTROLS + 5*FIXEDTEXT_HEIGHT + 4*EDIT_HEIGHT, PAGE_X )
+};
+
+TabPage PAGE_ORACLE_JDBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_ORACLE_JDBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+
+ AUTO_FIXEDLINE_CONNSETTINGS( UNRELATED_CONTROLS )
+ AUTO_HOST_AND_PORT( UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT )
+
+ AUTO_SOCKETCONTROLGROUP(3*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT)
+
+ FixedText FT_JDBCDRIVERCLASS
+ {
+ Pos = MAP_APPFONT ( 6,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Oracle JDBC d~river class";
+ };
+ Edit ET_JDBCDRIVERCLASS
+ {
+ HelpID = "dbaccess:Edit:PAGE_ORACLE_JDBC:ET_JDBCDRIVERCLASS";
+ Pos = MAP_APPFONT ( EDIT_X,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - EDIT_HEIGHT ) / 2 ) ;
+ Size = MAP_APPFONT ( 97 , EDIT_HEIGHT ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton PB_TESTDRIVERCLASS
+ {
+ HelpID = "dbaccess:PushButton:PAGE_ORACLE_JDBC:PB_TESTDRIVERCLASS";
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS,
+ 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + EDIT_HEIGHT + ( FIXEDTEXT_HEIGHT - BUTTON_HEIGHT ) / 2 ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ Text [ en-US ] = "Test class" ;
+ };
+
+ AUTO_CHARSET( 5*UNRELATED_CONTROLS + RELATED_CONTROLS + 4*FIXEDTEXT_HEIGHT+ EDIT_HEIGHT, PAGE_X )
+};
+
+//.........................................................................
+
+TabPage PAGE_LDAP
+{
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_LDAP;
+
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 4 , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X - 8 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Connection Settings";
+ };
+
+ FixedText FT_BASEDN
+ {
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Base DN";
+ };
+ Edit ET_BASEDN
+ {
+ TabStop = TRUE ;
+ Border = TRUE ;
+ HelpId = HID_DSADMIN_LDAP_BASEDN;
+
+ Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS + RELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+ CheckBox CB_USESSL
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( PAGE_X - 12 , CHECKBOX_HEIGHT ) ;
+ Text [ en-US ] = "Use secure connection(SSL)";
+ HelpId = HID_DSADMIN_USESSL_LDAP;
+ };
+
+ FixedText FT_PORTNUMBER
+ {
+ Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Port number";
+ };
+ NumericField NF_PORTNUMBER
+ {
+ TabStop = TRUE ;
+ Border = TRUE ;
+ HelpId = HID_DSADMIN_LDAP_PORTNUMBER;
+ NoThousandSep = TRUE;
+
+ Pos = MAP_APPFONT ( EDIT_X , 3*UNRELATED_CONTROLS + RELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT-1 + CHECKBOX_HEIGHT) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+ FixedText FT_LDAPROWCOUNT
+ {
+ Pos = MAP_APPFONT ( 6 , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT + CHECKBOX_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Maximum number of ~records";
+ };
+ NumericField NF_LDAPROWCOUNT
+ {
+ TabStop = TRUE ;
+ Border = TRUE ;
+ HelpId = HID_DSADMIN_LDAP_ROWCOUNT;
+ NoThousandSep = TRUE;
+
+ Pos = MAP_APPFONT ( EDIT_X , 4*UNRELATED_CONTROLS + RELATED_CONTROLS + 3*FIXEDTEXT_HEIGHT -1 + CHECKBOX_HEIGHT) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+};
+
+
+//.........................................................................
+
+TabPage PAGE_TEXT
+{
+ SVLook = TRUE ;
+ Hide = TRUE;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ HelpId = HID_DSADMIN_PAGE_TEXT;
+
+ AUTO_SEPARATORCONTROLGROUP(UNRELATED_CONTROLS, PAGE_X)
+};
+
+//.........................................................................
+TabPage PAGE_USERDRIVER
+{
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X , PAGE_Y ) ;
+ Hide = TRUE;
+ HelpId = HID_DSADMIN_PAGE_USERDRIVER;
+
+ FixedText FT_HOSTNAME
+ {
+ Pos = MAP_APPFONT ( 6 , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Hostname";
+ };
+ Edit ET_HOSTNAME
+ {
+ HelpID = "dbaccess:Edit:PAGE_USERDRIVER:ET_HOSTNAME";
+ TabStop = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( EDIT_X , UNRELATED_CONTROLS -1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+
+ FixedText FT_PORTNUMBER
+ {
+ Pos = MAP_APPFONT ( 6 , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~Port number";
+ };
+
+ NumericField NF_PORTNUMBER
+ {
+ HelpID = "dbaccess:NumericField:PAGE_USERDRIVER:NF_PORTNUMBER";
+ TabStop = TRUE ;
+ Border = TRUE ;
+ NoThousandSep = TRUE;
+
+ Pos = MAP_APPFONT ( EDIT_X , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT -1 ) ;
+ Size = MAP_APPFONT ( 105 , EDIT_HEIGHT ) ;
+ };
+
+ FixedText FT_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 3*UNRELATED_CONTROLS + 2*FIXEDTEXT_HEIGHT ) ;
+ Size = MAP_APPFONT ( EDIT_X - 7 , FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "~Driver settings" ;
+ };
+ Edit ET_OPTIONS
+ {
+ HelpID = "dbaccess:Edit:PAGE_USERDRIVER:ET_OPTIONS";
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ AUTO_CHARSET( 4*UNRELATED_CONTROLS+ 3*FIXEDTEXT_HEIGHT + RELATED_CONTROLS, PAGE_X)
+};
+
+String STR_ERR_USE_CONNECT_TO
+{
+ Text [ en-US ] = "Please choose 'Connect to an existing database' to connect to an existing database instead.";
+};
diff --git a/dbaccess/source/ui/dlg/dbadmin2.src b/dbaccess/source/ui/dlg/dbadmin2.src
new file mode 100644
index 000000000000..44ef3f024e3a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadmin2.src
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_DBADMIN_HRC_
+#include "dbadmin.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+//.........................................................................
+
+String STR_ENTER_CONNECTION_PASSWORD
+{
+ Text [ en-US ] = "A password is needed to connect to the data source \"$name$\".";
+};
+
+String STR_ASK_FOR_DIRECTORY_CREATION
+{
+ Text [ en-US ] = "The directory\n\n$path$\n\ndoes not exist. Should it be created?";
+};
+
+String STR_COULD_NOT_CREATE_DIRECTORY
+{
+ Text [ en-US ] = "The directory $name$ could not be created.";
+};
+
+
+
+
+
+
+#define EDIT_SIZE_X 50
+#define FT_SIZE_X 90
+#define WIN_X 220
+#define WIN_Y 72
+
+ModalDialog DLG_DOMAINPASSWORD
+{
+ HelpID = "dbaccess:ModalDialog:DLG_DOMAINPASSWORD";
+ Border = TRUE ;
+ Moveable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIN_X , WIN_Y ) ;
+ Text[ en-US ] = "Convert Database";
+
+ FixedLine FT_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( WIN_X - 3 - 6 - 6 - 50 , 8 ) ;
+ Text[ en-US ] = "Please enter the ~password for the user 'DOMAIN'.";
+ };
+
+ Edit ET_PASSWORD
+ {
+ HelpID = "dbaccess:Edit:DLG_DOMAINPASSWORD:ET_PASSWORD";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 + FT_SIZE_X , 16 ) ;
+ Size = MAP_APPFONT ( EDIT_SIZE_X , 12 ) ;
+ PassWord = TRUE ;
+ };
+ OKButton BTN_PASSWORD_OK
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_PASSWORD_CANCEL
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_PASSWORD_HELP
+ {
+ Pos = MAP_APPFONT ( WIN_X - 56 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+#define PAGE_X_T (PAGE_X -80)
+#define PAGE_Y_T (PAGE_Y -50)
+
+TabPage PAGE_TABLESUBSCRIPTION
+{
+ SVLook = TRUE ;
+ Hide = TRUE;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( PAGE_X_T, PAGE_Y_T) ;
+ HelpId = HID_DSADMIN_TABLE_SUBSCRIPTION;
+
+ Text [ en-US ] = "Tables Filter" ;
+
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( RELATED_CONTROLS , UNRELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( PAGE_X_T - 2* RELATED_CONTROLS, FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Tables and table filter";
+ };
+ Control CTL_TABLESUBSCRIPTION
+ {
+ Pos = MAP_APPFONT ( UNRELATED_CONTROLS , UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS) ;
+ Size = MAP_APPFONT ( PAGE_X_T - 2*UNRELATED_CONTROLS , 81 ) ;
+ Group = TRUE;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ HelpId = HID_DSADMIN_TABLE_SELECTOR;
+ };
+ FixedText FT_FILTER_EXPLANATION
+ {
+ Pos = MAP_APPFONT ( UNRELATED_CONTROLS , 2*UNRELATED_CONTROLS + FIXEDTEXT_HEIGHT + RELATED_CONTROLS + 81 ) ;
+ Size = MAP_APPFONT ( PAGE_X_T - 2*UNRELATED_CONTROLS , 16 ) ;
+ HelpId = HID_DSADMIN_FILTER_EXPLANATION;
+ WordBreak = TRUE;
+ Text [ en-US ] = "Mark the tables that should be visible for the applications.";
+ };
+};
diff --git a/dbaccess/source/ui/dlg/dbadminsetup.hrc b/dbaccess/source/ui/dlg/dbadminsetup.hrc
new file mode 100644
index 000000000000..7d6757951089
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadminsetup.hrc
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBADMINSETUP_HRC_
+#define _DBAUI_DBADMINSETUP_HRC_
+
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+
+
+#define STR_DBASE_HELPTEXT 28
+#define STR_MSACCESS_HELPTEXT 29
+#define STR_TEXT_HELPTEXT 30
+ // FREE
+#define STR_ADO_HELPTEXT 32
+#define STR_JDBC_HELPTEXT 33
+#define STR_ODBC_HELPTEXT 34
+#define STR_MYSQLJDBC_HELPTEXT 35
+#define STR_SPREADSHEET_HELPTEXT 36
+ // FREE
+#define STR_FINAL_HELPTEXT 38
+#define STR_ADABAS_HELPTEXT 39
+#define STR_ORACLE_HELPTEXT 40
+#define STR_DBASE_HEADERTEXT 41
+#define STR_MSACCESS_HEADERTEXT 42
+#define STR_TEXT_HEADERTEXT 43
+ // FREE
+#define STR_ADO_HEADERTEXT 45
+#define STR_JDBC_HEADERTEXT 46
+#define STR_ODBC_HEADERTEXT 47
+#define STR_MYSQLJDBC_HEADERTEXT 48
+ // FREE
+#define STR_SPREADSHEET_HEADERTEXT 50
+#define STR_FINAL_HEADERTEXT 52
+#define STR_ADABAS_HEADERTEXT 53
+#define STR_ORACLE_HEADERTEXT 54
+#define STR_GENERAL_HEADERTEXT 55
+#define STR_DBWIZARDTITLE 56
+
+#define STR_DEFAULTLDAPPORTNUMBER 60
+
+#define STR_ADABASNAME 61
+#define STR_ODBCDATASOURCENAME 63
+#define STR_SPREADSHEETPATH 64
+#define STR_DBLOCATIONLABEL 65
+#define STR_ADMIN_HELPTEXT 66
+
+#define STR_ORACLE_DEFAULT 67
+#define STR_PAGETITLE_INTROPAGE 69
+#define STR_PAGETITLE_DBASE 70
+#define STR_PAGETITLE_TEXT 71
+#define STR_PAGETITLE_MSACCESS 72
+#define STR_PAGETITLE_LDAP 73
+#define STR_PAGETITLE_ADABAS 74
+#define STR_PAGETITLE_ADO 75
+#define STR_PAGETITLE_JDBC 76
+#define STR_PAGETITLE_ORACLE 77
+#define STR_PAGETITLE_MYSQL 78
+#define STR_PAGETITLE_ODBC 79
+#define STR_PAGETITLE_SPREADSHEET 80
+#define STR_PAGETITLE_AUTHENTIFICATION 81
+#define STR_PAGETITLE_FINAL 82
+#define STR_MYSQL_DEFAULT 83
+#define STR_ORACLE_DRIVERCLASSTEXT 84
+#define STR_MYSQL_DRIVERCLASSTEXT 85
+#define STR_LDAP_DEFAULT 86
+#define STR_PAGETITLE_MYSQL_NATIVE 87
+
+
+#define FT_PORTNUMBERDEFAULT 1
+#define FT_LDAP_HELPTEXT 2
+#define FT_MYSQL_HELPTEXT 3
+#define FT_MYSQL_HEADERTEXT 4
+#define FT_MYSQLCONNECTIONMODE 5
+#define FT_BROWSEURL 6
+#define FT_AUTHENTIFICATIONHELPTEXT 7
+#define FT_AUTHENTIFICATIONHEADERTEXT 8
+#define FT_LDAP_HEADERTEXT 9
+#define FT_GENERALUSERNAME 10
+#define FT_FINALHEADER 11
+#define FT_FINALTEXT 12
+#define FT_FINALHELPTEXT 13
+#define FT_ADDITIONALSETTINGS 14
+#define FT_SETUP_WIZARD_HEADER 15
+#define FT_SETUP_WIZARD_HELP 16
+
+#define ET_GENERALUSERNAME 1
+
+#define PB_TESTCONNECTION 1
+
+#define RB_CONNECTVIAODBC 1
+#define RB_CONNECTVIAJDBC 2
+#define RB_REGISTERDATASOURCE 3
+#define RB_DONTREGISTERDATASOURCE 4
+#define RB_CONNECTVIANATIVE 5
+
+#define CB_WIZ_USESSL 1
+#define CB_STARTTABLEWIZARD 2
+#define CB_OPENAFTERWARDS 3
+#define CB_SPREADSHEETPASSWORDREQUIRED 4
+#define CB_GENERALPASSWORDREQUIRED 5
+
+#endif
diff --git a/dbaccess/source/ui/dlg/dbadminsetup.src b/dbaccess/source/ui/dlg/dbadminsetup.src
new file mode 100644
index 000000000000..ea4341914e82
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbadminsetup.src
@@ -0,0 +1,656 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBADMINSETUP_HRC_
+#include "dbadminsetup.hrc"
+#endif
+
+#ifndef _DBAUI_AUTOCONTROLS_HRC_
+#include "AutoControls.hrc"
+#endif
+
+
+#define CHECKBOX_HEIGHT 8
+#define FIXEDTEXT_HEIGHT 8
+#define RELATED_CONTROLS 4
+#define UNRELATED_CONTROLS 7
+#define EDIT_HEIGHT 12
+#define EDIT_X 101
+
+
+// -----------------------------------------------------------------------------
+ModalDialog DLG_DATABASE_WIZARD
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE;
+ Closeable = TRUE ;
+ HelpId = HID_DLG_DATABASE_WIZARD;
+ Hide = TRUE;
+ Text[ en-US ] = "Database Wizard" ;
+
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ HelpId = HID_DSADMIN_TABCONTROL;
+ };
+
+ String STR_DBWIZARDTITLE
+ {
+ Text[ en-US ] = "Database Wizard" ;
+ };
+
+ String STR_PAGETITLE_INTROPAGE
+ {
+ Text[ en-US ] = "Select database" ;
+ };
+
+ String STR_PAGETITLE_DBASE
+ {
+ Text[ en-US ] = "Set up dBASE connection" ;
+
+ };
+
+ String STR_PAGETITLE_TEXT
+ {
+ Text[ en-US ] = "Set up a connection to text files" ;
+ };
+
+
+ String STR_PAGETITLE_MSACCESS
+ {
+ Text[ en-US ] = "Set up Microsoft Access connection" ;
+ };
+
+ String STR_PAGETITLE_LDAP
+ {
+ Text[ en-US ] = "Set up LDAP connection" ;
+ };
+
+ String STR_PAGETITLE_ADABAS
+ {
+ Text[ en-US ] = "Set up Adabas D connection" ;
+ };
+
+ String STR_PAGETITLE_ADO
+ {
+ Text[ en-US ] = "Set up ADO connection" ;
+ };
+
+ String STR_PAGETITLE_JDBC
+ {
+ Text[ en-US ] = "Set up JDBC connection" ;
+ };
+
+ String STR_PAGETITLE_ORACLE
+ {
+ Text[ en-US ] = "Set up Oracle database connection" ;
+ };
+
+ String STR_PAGETITLE_MYSQL
+ {
+ Text[ en-US ] = "Set up MySQL connection" ;
+ };
+
+ String STR_PAGETITLE_ODBC
+ {
+ Text[ en-US ] = "Set up ODBC connection" ;
+ };
+
+ String STR_PAGETITLE_SPREADSHEET
+ {
+ Text[ en-US ] = "Set up Spreadsheet connection" ;
+ };
+
+ String STR_PAGETITLE_AUTHENTIFICATION
+ {
+ Text[ en-US ] = "Set up user authentication" ;
+ };
+
+ String STR_PAGETITLE_MYSQL_NATIVE
+ {
+ Text [ en-US ] = "Set up MySQL server data";
+ };
+
+ String STR_PAGETITLE_FINAL
+ {
+ Text[ en-US ] = "Save and proceed" ;
+ };
+};
+
+String STR_DATABASEDEFAULTNAME
+{
+ Text[ en-US ] = "New Database" ;
+};
+
+
+TabPage PAGE_DBWIZARD_MYSQL_INTRO
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_MYSQL_INTRO";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ FixedText FT_MYSQL_HEADERTEXT
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Set up a connection to a MySQL database";
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_MYSQL_HELPTEXT
+ {
+ Pos = MAP_APPFONT (START_X , 27 ) ;
+ Size = MAP_APPFONT ( 213 , 48 ) ;
+ Text[ en-US ] = "You can connect to a MySQL database using either ODBC or JDBC.\nPlease contact your system administrator if you are unsure about the following settings.";
+ WordBreak = TRUE ;
+ };
+
+ FixedText FT_MYSQLCONNECTIONMODE
+ {
+ Pos = MAP_APPFONT (START_X , 79 ) ;
+ Size = MAP_APPFONT ( 209 , 8 ) ;
+ Text[ en-US ] = "How do you want to connect to your MySQL database?" ;
+ };
+
+ RadioButton RB_CONNECTVIAODBC
+ {
+ HelpId = HID_PAGE_DBWIZARD_MYSQL_RB_CONNECTVIAODBC ;
+ Pos = MAP_APPFONT (START_X + 6 , 91 ) ;
+ Size = MAP_APPFONT ( 205 , 9 ) ;
+ Text[ en-US ] = "Connect using ODBC (Open Database Connectivity)" ;
+ };
+
+ RadioButton RB_CONNECTVIAJDBC
+ {
+ HelpId = HID_PAGE_DBWIZARD_MYSQL_RB_CONNECTVIAJDBC ;
+ Pos = MAP_APPFONT (START_X + 6, 103 ) ;
+ Size = MAP_APPFONT ( 208 , 8 ) ;
+ Text[ en-US ] = "Connect using JDBC (Java Database Connectivity)" ;
+ };
+ RadioButton RB_CONNECTVIANATIVE
+ {
+ HelpID = "dbaccess:RadioButton:PAGE_DBWIZARD_MYSQL_INTRO:RB_CONNECTVIANATIVE";
+ Pos = MAP_APPFONT (START_X + 6 , 115 ) ;
+ Size = MAP_APPFONT ( 205 , 9 ) ;
+ Text[ en-US ] = "Connect directly" ;
+ Hide = TRUE ;
+ };
+};
+
+#define AUTHENTEDIT_X (EDIT_X - 10)
+
+TabPage PAGE_DBWIZARD_AUTHENTIFICATION
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_AUTHENTIFICATION";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ FixedText FT_AUTHENTIFICATIONHEADERTEXT
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Set up the user authentication";
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_AUTHENTIFICATIONHELPTEXT\
+ {
+ Pos = MAP_APPFONT (START_X , 27 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 3*FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Some databases require you to enter a user name." ;\
+ WordBreak = TRUE ;
+ };
+
+ FixedText FT_GENERALUSERNAME
+ {
+ Pos = MAP_APPFONT (START_X , 62 ) ;
+ Size = MAP_APPFONT ( AUTHENTEDIT_X - START_X , FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "~User name" ;
+ };
+
+ Edit ET_GENERALUSERNAME
+ {
+ Border = TRUE ;
+ HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_ET_GENERALUSERNAME ;
+ Pos = MAP_APPFONT (AUTHENTEDIT_X , 60 ) ;
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - AUTHENTEDIT_X - 6), EDIT_HEIGHT ) ;
+ };
+
+ CheckBox CB_GENERALPASSWORDREQUIRED
+ {
+ HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_CB_GENERALPASSWORDREQUIRED ;
+ Pos = MAP_APPFONT (AUTHENTEDIT_X , 76 );
+ Size = MAP_APPFONT ( 93 , CHECKBOX_HEIGHT );
+ Text[ en-US ] = "Password re~quired" ;
+ };
+
+ PushButton PB_TESTCONNECTION
+ {
+ HelpId = HID_PAGE_DBWIZARD_AUTHENTIFICATION_PB_TESTCONNECTION ;
+ Pos = MAP_APPFONT (WIZARD_PAGE_X - BUTTON_WIDTH - UNRELATED_CONTROLS , WIZARD_PAGE_Y - 18 ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ Text[ en-US ] = "~Test Connection" ;
+ };
+};
+
+
+TabPage PAGE_DBWIZARD_FINAL
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_FINAL";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ FixedText FT_FINALHEADER
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 2* FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Decide how to proceed after saving the database";
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_FINALHELPTEXT
+ {
+ Pos = MAP_APPFONT (START_X , 27 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6, 2*FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Do you want the wizard to register the database in %PRODUCTNAME?" ;
+ WordBreak = TRUE ;
+ };
+
+ RadioButton RB_REGISTERDATASOURCE
+ {
+ HelpId = HID_PAGE_DBWIZARD_FINAL_RB_REGISTERDATASOURCE;
+ Pos = MAP_APPFONT (START_X + 6 , 45 ) ;
+ Size = MAP_APPFONT ( 205 , 9 ) ;
+ Group = TRUE;
+ Text[ en-US ] = "~Yes, register the database for me" ;
+ };
+
+ RadioButton RB_DONTREGISTERDATASOURCE
+ {
+ HelpId = HID_PAGE_DBWIZARD_FINAL_RB_DONTREGISTERDATASOURCE ;
+ Pos = MAP_APPFONT (START_X + 6, 57 ) ;
+ Size = MAP_APPFONT ( 208 , 8 ) ;
+ Text[ en-US ] = "N~o, do not register the database" ;
+ };
+
+ FixedText FT_ADDITIONALSETTINGS
+ {
+ Pos = MAP_APPFONT (START_X , 100 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 8 ) ;
+ Text[ en-US ] = "After the database file has been saved, what do you want to do?" ;
+ };
+
+ CheckBox CB_OPENAFTERWARDS
+ {
+ HelpId = HID_PAGE_DBWIZARD_FINAL_CB_OPENAFTERWARDS ;
+ Pos = MAP_APPFONT (START_X + 6, 118 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X , 8 ) ;
+ Text[ en-US ] = "Open the database for editing" ;
+ };
+
+ CheckBox CB_STARTTABLEWIZARD
+ {
+ HelpId = HID_PAGE_DBWIZARD_FINAL_CB_STARTTABLEWIZARD ;
+ Pos = MAP_APPFONT (START_X + 6, 130 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 8 ) ;
+ Text[ en-US ] = "Create tables using the table wizard" ;
+ };
+
+
+ FixedText FT_FINALTEXT
+ {
+ Pos = MAP_APPFONT ( START_X , 173 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 6 , 2* FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Click 'Finish' to save the database.";
+ WordBreak = TRUE;
+ };
+};
+
+TabPage PAGE_DBWIZARD_MYSQL_JDBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_MYSQL_JDBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_MYSQLJDBC_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up connection to a MySQL database using JDBC" ;
+ };
+
+ String STR_MYSQLJDBC_HELPTEXT
+ {
+ Text[ en-US ] = "Please enter the required information to connect to a MySQL database using JDBC. Note that a JDBC driver class must be installed on your system and registered with %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings.";
+ };
+
+ String STR_MYSQL_DRIVERCLASSTEXT
+ {
+ Text [ en-US ] = "MySQL JDBC d~river class:";
+ };
+
+
+ String STR_MYSQL_DEFAULT
+ {
+ Text[ en-US ] = "Default: 3306";
+ };
+
+ AUTOHELP_JDBCCONTROLGROUP(HID_PAGE_DBWIZARD_JDBC_ET_MYSQLDBNAME,HID_PAGE_DBWIZARD_JDBC_ET_MYSQLHOSTSERVER,HID_PAGE_DBWIZARD_JDBC_ET_MYSQLPORT,HID_PAGE_DBWIZARD_JDBC_ET_MYSQLCLASS,HID_PAGE_DBWIZARD_JDBC_PB_TESTMYSQLCLASS)
+};
+
+TabPage PAGE_DBWIZARD_MYSQL_NATIVE
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_MYSQL_NATIVE";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0, 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ FixedText FT_SETUP_WIZARD_HEADER
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 2 * FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Set up connection to a MySQL database" ;
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_SETUP_WIZARD_HELP
+ {
+ Pos = MAP_APPFONT ( START_X , INIT_Y ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X - START_X - 12 , 3 * FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Please enter the required information to connect to a MySQL database.";
+ WordBreak = TRUE;
+ };
+};
+
+
+TabPage PAGE_DBWIZARD_DBASE
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_DBASE";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_DBASE_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to dBASE files" ;
+ };
+
+ String STR_DBASE_HELPTEXT
+ {
+ Text[ en-US ] = "Select the folder where the dBASE files are stored." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP( 3, HID_PAGE_DBWIZARD_DBASE_ET_DBASELOCATION,HID_PAGE_DBWIZARD_DBASE_PB_DBASELOCATION)
+};
+
+TabPage PAGE_DBWIZARD_TEXT
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_TEXT";
+ String STR_TEXT_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to text files" ;
+ };
+
+ String STR_TEXT_HELPTEXT
+ {
+ Text[ en-US ] = "Select the folder where the CSV (Comma Separated Values) text files are stored. %PRODUCTNAME Base will open these files in read-only mode." ;
+ };
+
+ String STR_TEXT_PATH_OR_FILE{
+ Text[ en-US ] = "Path to text files";
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_TEXT_ET_LOCATIONTEXTFILE,HID_PAGE_DBWIZARD_TEXT_PB_LOCATIONTEXTFILE)
+ AUTO_SEPARATORCONTROLGROUP(82, WIZARD_PAGE_X)
+ };
+
+TabPage PAGE_DBWIZARD_MSACCESS
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_MSACCESS";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_MSACCESS_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to a Microsoft Access database" ;
+ };
+
+ String STR_MSACCESS_HELPTEXT
+ {
+ Text[ en-US ] = "Please select the Microsoft Access file you want to access.";
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_MSACCESS_ET_MSACCESSLOCATION, HID_PAGE_DBWIZARD_MSACCESS_PB_MSACCESSLOCATION)
+};
+
+TabPage PAGE_DBWIZARD_LDAP
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_LDAP";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ FixedText FT_LDAP_HEADERTEXT
+ {
+ Pos = MAP_APPFONT ( START_X , 8 ) ;
+ Size = MAP_APPFONT ( (WIZARD_PAGE_X - START_X) - 12 , 2 * FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Set up a connection to an LDAP directory";
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_LDAP_HELPTEXT
+ {
+ Pos = MAP_APPFONT (START_X , 27 ) ;
+ Size = MAP_APPFONT (WIZARD_PAGE_X - START_X - 6, 5 * FIXEDTEXT_HEIGHT ) ;
+ Text[ en-US ] = "Please enter the required information to connect to an LDAP directory.\nPlease contact your system administrator if you are unsure about the following settings." ;
+ WordBreak = TRUE ;
+ };
+ AUTO_HOSTCONTROLGROUP( INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_HOSTSERVER)
+ AUTO_BASEDNCONTROLGROUP(INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + EDIT_HEIGHT + RELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_BASEDN)
+ AUTO_PORTCONTROLGROUP( INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + 2 * EDIT_HEIGHT + 2 * RELATED_CONTROLS, HID_PAGE_DBWIZARD_LDAP_ET_PORTNUMBER)
+
+ String STR_LDAP_DEFAULT{
+ Text[ en-US ] = "Default: 389" ;
+ };
+
+ CheckBox CB_WIZ_USESSL
+ {
+ HelpId = HID_PAGE_DBWIZARD_LDAP_CB_USESSL ;
+ Pos = MAP_APPFONT (START_X , INIT_Y + 7 * FIXEDTEXT_HEIGHT + UNRELATED_CONTROLS + 3 * EDIT_HEIGHT + 4 * RELATED_CONTROLS ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text[ en-US ] = "Use ~secure connection (SSL)" ;
+ };
+};
+
+TabPage PAGE_DBWIZARD_ADABAS
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_ADABAS";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_ADABAS_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to an Adabas D database" ;
+ };
+
+ String STR_ADABAS_HELPTEXT{
+ Text[ en-US ] = "Enter the name of the Adabas D database you want to connect to.\nClick 'Browse...' to select an Adabas D database that is already registered in %PRODUCTNAME." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(4, HID_PAGE_DBWIZARD_ADABAS_ET_ADABASNAME, HID_PAGE_DBWIZARD_ADABAS_PB_ADABASNAME)
+};
+
+TabPage PAGE_DBWIZARD_ADO
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_ADO";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_ADO_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to an ADO database" ;
+ };
+
+ String STR_ADO_HELPTEXT{
+ Text[ en-US ] = "Please enter the URL of the ADO data source you want to connect to.\nClick 'Browse' to configure provider-specific settings.\nPlease contact your system administrator if you are unsure about the following settings." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(5, HID_PAGE_DBWIZARD_ADO_ET_ADOURL, HID_PAGE_DBWIZARD_ADO_PB_ADOURL)
+};
+
+
+TabPage PAGE_DBWIZARD_ODBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_ODBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_ODBC_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to an ODBC database" ;
+ };
+
+ String STR_ODBC_HELPTEXT{
+ Text[ en-US ] = "Enter the name of the ODBC database you want to connect to.\nClick 'Browse...' to select an ODBC database that is already registered in %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(6, HID_PAGE_DBWIZARD_ODBC_ET_NAMEOFODBCDATASOURCE, HID_PAGE_DBWIZARD_ODBC_PB_NAMEOFODBCDATASOURCE)
+};
+
+TabPage PAGE_DBWIZARD_USERDEFINED
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_USERDEFINED";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ AUTO_HELP_BROWSECONTROLGROUP(6, HID_PAGE_DBWIZARD_USERDEFINED_ET_BROWSE, HID_PAGE_DBWIZARD_USERDEFINED_BROWSE)
+};
+
+TabPage PAGE_DBWIZARD_JDBC
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_JDBC";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_JDBC_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to a JDBC database" ;
+ };
+
+ String STR_JDBC_HELPTEXT{
+ Text[ en-US ] = "Please enter the required information to connect to a JDBC database.\nPlease contact your system administrator if you are unsure about the following settings." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(4, HID_PAGE_DBWIZARD_JDBC_ET_JDBCURL, HID_PAGE_DBWIZARD_JDBC_PB_JDBCURL)
+ AUTO_JDBCDRIVERCLASSGROUP(119, HID_PAGE_DBWIZARD_JDBC_ET_JDBCCLASS, HID_PAGE_DBWIZARD_JDBC_PB_TESTJDBCCLASS)
+};
+
+
+
+TabPage PAGE_DBWIZARD_ORACLE
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_ORACLE";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_ORACLE_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to an Oracle database";
+ };
+
+ String STR_ORACLE_DEFAULT
+ {
+ Text[ en-US ] = "Default: 1521" ;
+ };
+
+ String STR_ORACLE_DRIVERCLASSTEXT{
+ Text [ en-US ] = "Oracle JDBC ~driver class";
+ };
+
+ String STR_ORACLE_HELPTEXT{
+ Text[ en-US ] = "Please enter the required information to connect to an Oracle database.Note that a JDBC Driver Class must be installed on your system and registered with %PRODUCTNAME.\nPlease contact your system administrator if you are unsure about the following settings." ;
+ };
+
+ AUTOHELP_JDBCCONTROLGROUP(HID_PAGE_DBWIZARD_ORACLE_ET_ORACLEDBNAME,HID_PAGE_DBWIZARD_ORACLE_ET_ORACLEHOSTSERVER,HID_PAGE_DBWIZARD_ORACLE_ET_ORACLEPORT,HID_PAGE_DBWIZARD_ORACLE_ET_ORACLECLASS,HID_PAGE_DBWIZARD_ORACLE_PB_TESTORACLECLASS)
+};
+
+
+TabPage PAGE_DBWIZARD_SPREADSHEET
+{
+ HelpID = "dbaccess:TabPage:PAGE_DBWIZARD_SPREADSHEET";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( WIZARD_PAGE_X , WIZARD_PAGE_Y ) ;
+ Hide = TRUE ;
+
+ String STR_SPREADSHEET_HEADERTEXT
+ {
+ Text[ en-US ] = "Set up a connection to spreadsheets";
+ };
+
+ String STR_SPREADSHEET_HELPTEXT{
+ Text[ en-US ] = "Click 'Browse...' to select a %PRODUCTNAME spreadsheet or Microsoft Excel workbook.\n%PRODUCTNAME will open this file in read-only mode." ;
+ };
+
+ AUTO_HELP_BROWSECONTROLGROUP(3, HID_PAGE_DBWIZARD_SPREADSHEET_ET_SPREADSHEETPATH,HID_PAGE_DBWIZARD_SPREADSHEET_PB_SPREADSHEETPATH )
+
+ String STR_SPREADSHEETPATH{
+ Text[ en-US ] = "~Location and file name" ;
+ };
+
+
+ CheckBox CB_SPREADSHEETPASSWORDREQUIRED
+ {
+ HelpId = HID_PAGE_DBWIZARD_SPREADSHEET_CB_SPREADSHEETPASSWORDREQUIRED ;
+ Pos = MAP_APPFONT (START_X + UNRELATED_CONTROLS , 83 ) ;
+ Size = MAP_APPFONT ( 93 , 11 ) ;
+ Text[ en-US ] = "~Password required" ;
+ };
+};
diff --git a/dbaccess/source/ui/dlg/dbfindex.cxx b/dbaccess/source/ui/dlg/dbfindex.cxx
new file mode 100644
index 000000000000..c1e77135987b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.cxx
@@ -0,0 +1,554 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbfindex.hxx"
+
+#include <tools/config.hxx>
+#include <sfx2/app.hxx>
+#include "moduledbu.hxx"
+#include "dbu_dlg.hrc"
+#include "dbfindex.hrc"
+#include <osl/diagnose.h>
+#include <unotools/localfilehelper.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/pathoptions.hxx>
+#include <ucbhelper/content.hxx>
+#include <svl/filenotation.hxx>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::svt;
+
+const ByteString aGroupIdent("dBase III");
+
+//////////////////////////////////////////////////////////////////////////
+// Klasse ODbaseIndexDialog
+DBG_NAME(ODbaseIndexDialog)
+//-------------------------------------------------------------------------
+ODbaseIndexDialog::ODbaseIndexDialog( Window * pParent, String aDataSrcName )
+ : ModalDialog( pParent, ModuleRes(DLG_DBASE_INDEXES) ),
+ aPB_OK( this, ModuleRes( PB_OK ) ),
+ aPB_CANCEL( this, ModuleRes( PB_CANCEL ) ),
+ aPB_HELP( this, ModuleRes( PB_HELP ) ),
+ m_FT_Tables( this, ModuleRes( FT_TABLES ) ),
+ aCB_Tables( this, ModuleRes( CB_TABLES ) ),
+ m_FL_Indexes( this, ModuleRes( FL_INDEXES ) ),
+ m_FT_TableIndexes( this, ModuleRes( FT_TABLEINDEXES ) ),
+ aLB_TableIndexes( this, ModuleRes( LB_TABLEINDEXES ) ),
+ m_FT_AllIndexes( this, ModuleRes( FT_ALLINDEXES ) ),
+ aLB_FreeIndexes( this, ModuleRes( LB_FREEINDEXES ) ),
+ aIB_Add( this, ModuleRes( IB_ADD ) ),
+ aIB_Remove( this, ModuleRes( IB_REMOVE ) ),
+ aIB_AddAll( this, ModuleRes( IB_ADDALL ) ),
+ aIB_RemoveAll( this, ModuleRes( IB_REMOVEALL ) ),
+ m_aDSN(aDataSrcName),
+ m_bCaseSensitiv(sal_True)
+{
+ DBG_CTOR(ODbaseIndexDialog,NULL);
+
+ aCB_Tables.SetSelectHdl( LINK(this, ODbaseIndexDialog, TableSelectHdl) );
+ aIB_Add.SetClickHdl( LINK(this, ODbaseIndexDialog, AddClickHdl) );
+ aIB_Remove.SetClickHdl( LINK(this, ODbaseIndexDialog, RemoveClickHdl) );
+ aIB_AddAll.SetClickHdl( LINK(this, ODbaseIndexDialog, AddAllClickHdl) );
+ aIB_RemoveAll.SetClickHdl( LINK(this, ODbaseIndexDialog, RemoveAllClickHdl) );
+ aPB_OK.SetClickHdl( LINK(this, ODbaseIndexDialog, OKClickHdl) );
+
+ aLB_FreeIndexes.SetSelectHdl( LINK(this, ODbaseIndexDialog, OnListEntrySelected) );
+ aLB_TableIndexes.SetSelectHdl( LINK(this, ODbaseIndexDialog, OnListEntrySelected) );
+
+ aCB_Tables.SetDropDownLineCount(8);
+ Init();
+ SetCtrls();
+ FreeResource();
+}
+
+//-------------------------------------------------------------------------
+ODbaseIndexDialog::~ODbaseIndexDialog()
+{
+
+ DBG_DTOR(ODbaseIndexDialog,NULL);
+}
+
+//-------------------------------------------------------------------------
+sal_Bool ODbaseIndexDialog::GetTable(const String& _rName, TableInfoListIterator& _rPosition)
+{
+ for ( _rPosition = m_aTableInfoList.begin();
+ _rPosition != m_aTableInfoList.end();
+ ++_rPosition
+ )
+ {
+ if (m_bCaseSensitiv)
+ {
+ if (_rPosition->aTableName.Equals(_rName))
+ return sal_True;
+ }
+ else
+ {
+ if (_rPosition->aTableName.EqualsIgnoreCaseAscii(_rName))
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//-------------------------------------------------------------------------
+void ODbaseIndexDialog::checkButtons()
+{
+ aIB_Add.Enable(0 != aLB_FreeIndexes.GetSelectEntryCount());
+ aIB_AddAll.Enable(0 != aLB_FreeIndexes.GetEntryCount());
+
+ aIB_Remove.Enable(0 != aLB_TableIndexes.GetSelectEntryCount());
+ aIB_RemoveAll.Enable(0 != aLB_TableIndexes.GetEntryCount());
+}
+
+//-------------------------------------------------------------------------
+OTableIndex ODbaseIndexDialog::implRemoveIndex(const String& _rName, TableIndexList& _rList, ListBox& _rDisplay, sal_Bool _bMustExist)
+{
+ OTableIndex aReturn;
+
+ sal_Int32 nPos = 0;
+
+ TableIndexListIterator aSearch;
+ for ( aSearch = _rList.begin();
+ aSearch != _rList.end();
+ ++aSearch, ++nPos
+ )
+ {
+ if ( m_bCaseSensitiv ? aSearch->GetIndexFileName().Equals(_rName) : aSearch->GetIndexFileName().EqualsIgnoreCaseAscii(_rName) )
+ {
+ aReturn = *aSearch;
+
+ _rList.erase(aSearch);
+ _rDisplay.RemoveEntry( _rName );
+
+ // adjust selection if necessary
+ if ((sal_uInt32)nPos == _rList.size())
+ _rDisplay.SelectEntryPos((sal_uInt16)nPos-1);
+ else
+ _rDisplay.SelectEntryPos((sal_uInt16)nPos);
+
+ break;
+ }
+ }
+
+ (void)_bMustExist;
+ OSL_ENSURE(!_bMustExist || (aSearch != _rList.end()), "ODbaseIndexDialog::implRemoveIndex : did not find the index!");
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+void ODbaseIndexDialog::implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay)
+{
+ _rList.push_front( _rIndex );
+ _rDisplay.InsertEntry( _rIndex.GetIndexFileName() );
+ _rDisplay.SelectEntryPos(0);
+}
+
+//-------------------------------------------------------------------------
+OTableIndex ODbaseIndexDialog::RemoveTableIndex( const String& _rTableName, const String& _rIndexName, sal_Bool _bMustExist )
+{
+ OTableIndex aReturn;
+
+ // does the table exist ?
+ TableInfoListIterator aTablePos;
+ if (!GetTable(_rTableName, aTablePos))
+ return aReturn;
+
+ return implRemoveIndex(_rIndexName, aTablePos->aIndexList, aLB_TableIndexes, _bMustExist);
+}
+
+//-------------------------------------------------------------------------
+void ODbaseIndexDialog::InsertTableIndex( const String& _rTableName, const OTableIndex& _rIndex)
+{
+ TableInfoListIterator aTablePos;
+ if (!GetTable(_rTableName, aTablePos))
+ return;
+
+ implInsertIndex(_rIndex, aTablePos->aIndexList, aLB_TableIndexes);
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, OKClickHdl, PushButton*, /*pButton*/ )
+{
+ // let all tables write their INF file
+
+ for ( ConstTableInfoListIterator aLoop = m_aTableInfoList.begin();
+ aLoop != m_aTableInfoList.end();
+ ++aLoop
+ )
+ aLoop->WriteInfFile(m_aDSN);
+
+ EndDialog();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, AddClickHdl, PushButton*, /*pButton*/ )
+{
+ String aSelection = aLB_FreeIndexes.GetSelectEntry();
+ String aTableName = aCB_Tables.GetText();
+ OTableIndex aIndex = RemoveFreeIndex( aSelection, sal_True );
+ InsertTableIndex( aTableName, aIndex );
+
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, RemoveClickHdl, PushButton*, /*pButton*/ )
+{
+ String aSelection = aLB_TableIndexes.GetSelectEntry();
+ String aTableName = aCB_Tables.GetText();
+ OTableIndex aIndex = RemoveTableIndex( aTableName, aSelection, sal_True );
+ InsertFreeIndex( aIndex );
+
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, AddAllClickHdl, PushButton*, /*pButton*/ )
+{
+ sal_uInt16 nCnt = aLB_FreeIndexes.GetEntryCount();
+ String aTableName = aCB_Tables.GetText();
+ String aEntry;
+
+ for( sal_uInt16 nPos = 0; nPos < nCnt; ++nPos )
+ InsertTableIndex( aTableName, RemoveFreeIndex( aLB_FreeIndexes.GetEntry(0), sal_True ) );
+
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, RemoveAllClickHdl, PushButton*, /*pButton*/ )
+{
+ sal_uInt16 nCnt = aLB_TableIndexes.GetEntryCount();
+ String aTableName = aCB_Tables.GetText();
+ String aEntry;
+
+ for( sal_uInt16 nPos = 0; nPos < nCnt; ++nPos )
+ InsertFreeIndex( RemoveTableIndex( aTableName, aLB_TableIndexes.GetEntry(0), sal_True ) );
+
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, OnListEntrySelected, ListBox*, /*NOTINTERESTEDIN*/ )
+{
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK( ODbaseIndexDialog, TableSelectHdl, ComboBox*, pComboBox )
+{
+ // search the table
+ TableInfoListIterator aTablePos;
+ if (!GetTable(pComboBox->GetText(), aTablePos))
+ return 0L;
+
+ // fill the listbox for the indexes
+ aLB_TableIndexes.Clear();
+ for ( ConstTableIndexListIterator aLoop = aTablePos->aIndexList.begin();
+ aLoop != aTablePos->aIndexList.end();
+ ++aLoop
+ )
+ aLB_TableIndexes.InsertEntry( aLoop->GetIndexFileName() );
+
+ if ( aTablePos->aIndexList.size() )
+ aLB_TableIndexes.SelectEntryPos(0);
+
+ checkButtons();
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+void ODbaseIndexDialog::Init()
+{
+ aPB_OK.Disable();
+ m_FL_Indexes.Disable();
+ m_FT_TableIndexes.Disable();
+ aLB_TableIndexes.Disable();
+ m_FT_AllIndexes.Disable();
+ aLB_FreeIndexes.Disable();
+ aIB_Add.Disable();
+ aIB_Remove.Disable();
+ aIB_AddAll.Disable();
+ aIB_RemoveAll.Disable();
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Alle Indizes werden erst einmal zur Liste der freien Indizes hinzugefuegt.
+ // Dann wird fuer jede Tabelle in der Inf-Datei nachgeschaut, welche Indizes sie besitzt.
+ // Diese Indizes werden aus der Liste der freien Indizes entfernt
+ // und in die Indexliste der Tabelle eingetragen
+
+ ///////////////////////////////////////////////////////////////////////////
+ // if the string does not contain a path, cut the string
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ {
+ SvtPathOptions aPathOptions;
+ m_aDSN = aPathOptions.SubstituteVariable(m_aDSN);
+ }
+ aURL.SetSmartURL(m_aDSN);
+
+
+ // String aFileName = aURL.PathToFileName();
+ m_aDSN = aURL.GetMainURL(INetURLObject::NO_DECODE);
+ ::ucbhelper::Content aFile;
+ sal_Bool bFolder=sal_True;
+ try
+ {
+ aFile = ::ucbhelper::Content(m_aDSN,Reference< ::com::sun::star::ucb::XCommandEnvironment >());
+ bFolder = aFile.isFolder();
+ }
+ catch(Exception&)
+ {
+ return;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // first assume for all indexes they're free
+
+ Sequence< ::rtl::OUString> aFolderContent( ::utl::LocalFileHelper::GetFolderContents(m_aDSN,bFolder));
+
+ ::rtl::OUString aIndexExt(RTL_CONSTASCII_USTRINGPARAM("ndx"));
+ ::rtl::OUString aTableExt(RTL_CONSTASCII_USTRINGPARAM("dbf"));
+
+ ::std::vector< String > aUsedIndexes;
+
+ String aExt;
+ const ::rtl::OUString *pBegin = aFolderContent.getConstArray();
+ const ::rtl::OUString *pEnd = pBegin + aFolderContent.getLength();
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ for(;pBegin != pEnd;++pBegin)
+ {
+ String aName;
+ ::utl::LocalFileHelper::ConvertURLToPhysicalName(pBegin->getStr(),aName);
+ aURL.SetSmartURL(aName);
+ aExt = aURL.getExtension();
+ if(aExt == aIndexExt.getStr())
+ {
+ m_aFreeIndexList.push_back( OTableIndex(aURL.getName()) );
+ }
+ else if(aExt == aTableExt.getStr())
+ {
+ m_aTableInfoList.push_back( OTableInfo(aURL.getName()) );
+ OTableInfo& rTabInfo = m_aTableInfoList.back();
+
+ // open the INF file
+ aURL.setExtension(String::CreateFromAscii("inf"));
+ OFileNotation aTransformer(aURL.GetURLNoPass(), OFileNotation::N_URL);
+ Config aInfFile( aTransformer.get(OFileNotation::N_SYSTEM) );
+ aInfFile.SetGroup( aGroupIdent );
+
+ ///////////////////////////////////////////////////////////////////////////
+ // fill the indexes list
+ ByteString aNDX;
+ sal_uInt16 nKeyCnt = aInfFile.GetKeyCount();
+ ByteString aKeyName;
+ String aEntry;
+
+ for( sal_uInt16 nKey = 0; nKey < nKeyCnt; nKey++ )
+ {
+ // does the key point to an index file ?
+ aKeyName = aInfFile.GetKeyName( nKey );
+ aNDX = aKeyName.Copy(0,3);
+
+ // yes -> add to the tables index list
+ if (aNDX == "NDX" )
+ {
+ aEntry = String(aInfFile.ReadKey(aKeyName), gsl_getSystemTextEncoding());
+ rTabInfo.aIndexList.push_back( OTableIndex( aEntry ) );
+
+ // and remove it from the free index list
+ aUsedIndexes.push_back(aEntry);
+ // do this later below. We may not have encountered the index file, yet, thus we may not
+ // know the index as beeing free, yet
+ }
+
+ }
+ }
+ }
+
+ for ( ::std::vector< String >::const_iterator aUsedIndex = aUsedIndexes.begin();
+ aUsedIndex != aUsedIndexes.end();
+ ++aUsedIndex
+ )
+ RemoveFreeIndex( *aUsedIndex, sal_False );
+
+ if (m_aTableInfoList.size())
+ {
+ aPB_OK.Enable();
+ m_FL_Indexes.Enable();
+ m_FT_TableIndexes.Enable();
+ aLB_TableIndexes.Enable();
+ m_FT_AllIndexes.Enable();
+ aLB_FreeIndexes.Enable();
+ }
+
+ checkButtons();
+}
+
+//-------------------------------------------------------------------------
+void ODbaseIndexDialog::SetCtrls()
+{
+ // ComboBox Tabellen
+ for ( ConstTableInfoListIterator aLoop = m_aTableInfoList.begin();
+ aLoop != m_aTableInfoList.end();
+ ++aLoop
+ )
+ aCB_Tables.InsertEntry( aLoop->aTableName );
+
+ // Den ersten Datensatz ins Edit stellen
+ if( m_aTableInfoList.size() )
+ {
+ const OTableInfo& rTabInfo = m_aTableInfoList.front();
+ aCB_Tables.SetText( rTabInfo.aTableName );
+
+ // ListBox der Tabellenindizes aufbauen
+ for ( ConstTableIndexListIterator aIndex = rTabInfo.aIndexList.begin();
+ aIndex != rTabInfo.aIndexList.end();
+ ++aIndex
+ )
+ aLB_TableIndexes.InsertEntry( aIndex->GetIndexFileName() );
+
+ if( rTabInfo.aIndexList.size() )
+ aLB_TableIndexes.SelectEntryPos( 0 );
+
+ }
+
+ // ListBox freie Indizes
+ for ( ConstTableIndexListIterator aFree = m_aFreeIndexList.begin();
+ aFree != m_aFreeIndexList.end();
+ ++aFree
+ )
+ aLB_FreeIndexes.InsertEntry( aFree->GetIndexFileName() );
+
+ if( m_aFreeIndexList.size() )
+ aLB_FreeIndexes.SelectEntryPos( 0 );
+
+
+ TableSelectHdl(&aCB_Tables);
+ checkButtons();
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Klasse OTableInfo
+//-------------------------------------------------------------------------
+void OTableInfo::WriteInfFile( const String& rDSN ) const
+{
+ // INF-Datei oeffnen
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String aDsn = rDSN;
+ {
+ SvtPathOptions aPathOptions;
+ aDsn = aPathOptions.SubstituteVariable(aDsn);
+ }
+ aURL.SetSmartURL(aDsn);
+ aURL.Append(aTableName);
+ aURL.setExtension(String::CreateFromAscii("inf"));
+
+ OFileNotation aTransformer(aURL.GetURLNoPass(), OFileNotation::N_URL);
+ Config aInfFile( aTransformer.get(OFileNotation::N_SYSTEM) );
+ aInfFile.SetGroup( aGroupIdent );
+
+ // Erst einmal alle Tabellenindizes loeschen
+ ByteString aNDX;
+ sal_uInt16 nKeyCnt = aInfFile.GetKeyCount();
+ ByteString aKeyName;
+ ByteString aEntry;
+ sal_uInt16 nKey = 0;
+
+ while( nKey < nKeyCnt )
+ {
+ // Verweist der Key auf ein Indexfile?...
+ aKeyName = aInfFile.GetKeyName( nKey );
+ aNDX = aKeyName.Copy(0,3);
+
+ //...wenn ja, Indexfile loeschen, nKey steht dann auf nachfolgendem Key
+ if( aNDX == "NDX" )
+ {
+ aInfFile.DeleteKey(aKeyName);
+ nKeyCnt--;
+ }
+ else
+ nKey++;
+
+ }
+
+ // Jetzt alle gespeicherten Indizes hinzufuegen
+ sal_uInt16 nPos = 0;
+ for ( ConstTableIndexListIterator aIndex = aIndexList.begin();
+ aIndex != aIndexList.end();
+ ++aIndex, ++nPos
+ )
+ {
+ aKeyName = "NDX";
+ if( nPos > 0 ) // Erster Index erhaelt keine Ziffer
+ aKeyName += ByteString::CreateFromInt32( nPos );
+ aInfFile.WriteKey( aKeyName, ByteString(aIndex->GetIndexFileName(), gsl_getSystemTextEncoding()) );
+ }
+
+ aInfFile.Flush();
+
+ // Falls nur noch [dbase] in INF-File steht, Datei loeschen
+ if(!nPos)
+ {
+ try
+ {
+ ::ucbhelper::Content aContent(aURL.GetURLNoPass(),Reference<XCommandEnvironment>());
+ aContent.executeCommand( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")),makeAny( sal_Bool( sal_True ) ) );
+ }
+ catch (const Exception& e )
+ {
+ (void)e; // make compiler happy
+ // simply silent this. The strange algorithm here does a lot of things even if no files at all were
+ // created or accessed, so it's possible that the file we're trying to delete does not even exist,
+ // and this is a valid condition.
+ }
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dbfindex.hrc b/dbaccess/source/ui/dlg/dbfindex.hrc
new file mode 100644
index 000000000000..0d67da065568
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.hrc
@@ -0,0 +1,26 @@
+#ifndef _DBAUI_DBF_INDEXES_HRC_
+#define _DBAUI_DBF_INDEXES_HRC_
+
+#define CB_TABLES 1
+
+#define FT_TABLES 1
+#define FT_TABLEINDEXES 2
+#define FT_ALLINDEXES 3
+
+#define FL_INDEXES 1
+
+#define LB_TABLEINDEXES 1
+#define LB_FREEINDEXES 2
+
+#define PB_OK 1
+#define PB_CANCEL 1
+#define PB_HELP 1
+
+#define IB_ADD 1
+#define IB_REMOVE 2
+#define IB_ADDALL 3
+#define IB_REMOVEALL 4
+
+
+#endif //_DBAUI_DBF_INDEXES_HRC_
+
diff --git a/dbaccess/source/ui/dlg/dbfindex.hxx b/dbaccess/source/ui/dlg/dbfindex.hxx
new file mode 100644
index 000000000000..c10b2362027b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBFINDEX_HXX_
+#define _DBAUI_DBFINDEX_HXX_
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#include <comphelper/stl_types.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OTableIndex
+//=========================================================================
+/// represents a single dbf index
+class OTableIndex
+{
+private:
+ String aIndexFileName;
+
+public:
+ OTableIndex() { }
+ OTableIndex( const OTableIndex& _rSource) : aIndexFileName(_rSource.aIndexFileName) { }
+ OTableIndex( const String& rFileName ) : aIndexFileName( rFileName ) { }
+
+ void SetIndexFileName( const String& rFileName ) { aIndexFileName = rFileName; }
+ String GetIndexFileName() const { return aIndexFileName; }
+};
+
+//-------------------------------------------------------------------------
+typedef ::std::list< OTableIndex > TableIndexList;
+DECLARE_STL_ITERATORS(TableIndexList);
+
+//=========================================================================
+//= OTableInfo
+//=========================================================================
+class ODbaseIndexDialog;
+/** holds the INF file of a table
+*/
+class OTableInfo
+{
+ friend class ODbaseIndexDialog;
+private:
+ String aTableName;
+ TableIndexList aIndexList;
+
+public:
+ OTableInfo() { }
+ OTableInfo( const String& rName ) : aTableName(rName) { }
+
+ void WriteInfFile( const String& rDSN ) const;
+};
+
+//-------------------------------------------------------------------------
+typedef ::std::list< OTableInfo > TableInfoList;
+DECLARE_STL_ITERATORS(TableInfoList);
+
+//////////////////////////////////////////////////////////////////////////
+// IndexDialog
+class ODbaseIndexDialog : public ModalDialog
+{
+protected:
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+ FixedText m_FT_Tables;
+ ComboBox aCB_Tables;
+
+ FixedLine m_FL_Indexes;
+
+ FixedText m_FT_TableIndexes;
+ ListBox aLB_TableIndexes;
+
+ FixedText m_FT_AllIndexes;
+ ListBox aLB_FreeIndexes;
+
+ ImageButton aIB_Add;
+ ImageButton aIB_Remove;
+ ImageButton aIB_AddAll;
+ ImageButton aIB_RemoveAll;
+
+ DECL_LINK( TableSelectHdl, ComboBox* );
+ DECL_LINK( AddClickHdl, PushButton* );
+ DECL_LINK( RemoveClickHdl, PushButton* );
+ DECL_LINK( AddAllClickHdl, PushButton* );
+ DECL_LINK( RemoveAllClickHdl, PushButton* );
+ DECL_LINK( OKClickHdl, PushButton* );
+ DECL_LINK( OnListEntrySelected, ListBox* );
+
+ String m_aDSN;
+ TableInfoList m_aTableInfoList;
+ TableIndexList m_aFreeIndexList;
+ sal_Bool m_bCaseSensitiv;
+
+ void Init();
+ void SetCtrls();
+ sal_Bool GetTable(const String& rName, TableInfoListIterator& _rPosition);
+
+ OTableIndex implRemoveIndex(const String& _rName, TableIndexList& _rList, ListBox& _rDisplay, sal_Bool _bMustExist);
+ void implInsertIndex(const OTableIndex& _rIndex, TableIndexList& _rList, ListBox& _rDisplay);
+
+ OTableIndex RemoveFreeIndex( const String& _rName, sal_Bool _bMustExist ) { return implRemoveIndex(_rName, m_aFreeIndexList, aLB_FreeIndexes, _bMustExist); }
+ void InsertFreeIndex( const OTableIndex& _rIndex ) { implInsertIndex(_rIndex, m_aFreeIndexList, aLB_FreeIndexes); }
+ OTableIndex RemoveTableIndex( const String& _rTableName, const String& _rIndexName, sal_Bool _bMustExist );
+ void InsertTableIndex( const String& _rTableName, const OTableIndex& _rIndex );
+
+ void checkButtons();
+
+public:
+ ODbaseIndexDialog( Window * pParent, String aDataSrcName );
+ virtual ~ODbaseIndexDialog();
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DBFINDEX_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dbfindex.src b/dbaccess/source/ui/dlg/dbfindex.src
new file mode 100644
index 000000000000..ca8b6e4a3622
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbfindex.src
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBF_INDEXES_HRC_
+#include "dbfindex.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#define WIN_X 264
+#define WIN_Y 149
+
+ModalDialog DLG_DBASE_INDEXES
+{
+ HelpID = "dbaccess:ModalDialog:DLG_DBASE_INDEXES";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIN_X , WIN_Y ) ;
+ Text [ en-US ] = "Indexes" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 208 , 5 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 208 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 208 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_TABLES
+ {
+ Pos = MAP_APPFONT ( 8 , 7 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "~Table";
+ };
+ ComboBox CB_TABLES
+ {
+ HelpID = "dbaccess:ComboBox:DLG_DBASE_INDEXES:CB_TABLES";
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 62 , 5 ) ;
+ Size = MAP_APPFONT ( 134 , 12 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedLine FL_INDEXES
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 196 , 8 ) ;
+ Text [ en-US ] = "Assignment" ;
+ };
+ FixedText FT_TABLEINDEXES
+ {
+ Pos = MAP_APPFONT ( 12 , 33 ) ;
+ Size = MAP_APPFONT ( 83 , 8 ) ;
+ Text [ en-US ] = "T~able indexes";
+ };
+ ListBox LB_TABLEINDEXES
+ {
+ HelpID = "dbaccess:ListBox:DLG_DBASE_INDEXES:LB_TABLEINDEXES";
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 44 ) ;
+ Size = MAP_APPFONT ( 76 , 98 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_ALLINDEXES
+ {
+ Pos = MAP_APPFONT ( 120 , 33 ) ;
+ Size = MAP_APPFONT ( 73 , 8 ) ;
+ Text [ en-US ] = "~Free indexes";
+ };
+ ListBox LB_FREEINDEXES
+ {
+ HelpID = "dbaccess:ListBox:DLG_DBASE_INDEXES:LB_FREEINDEXES";
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 120 , 44 ) ;
+ Size = MAP_APPFONT ( 76 , 98 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_ADD
+ {
+ HelpID = "dbaccess:ImageButton:DLG_DBASE_INDEXES:IB_ADD";
+ Pos = MAP_APPFONT ( 94 , 60 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_left.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_ADDALL
+ {
+ HelpID = "dbaccess:ImageButton:DLG_DBASE_INDEXES:IB_ADDALL";
+ Pos = MAP_APPFONT ( 94 , 77 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_left.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_REMOVE
+ {
+ HelpID = "dbaccess:ImageButton:DLG_DBASE_INDEXES:IB_REMOVE";
+ Pos = MAP_APPFONT ( 94 , 98 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_REMOVEALL
+ {
+ HelpID = "dbaccess:ImageButton:DLG_DBASE_INDEXES:IB_REMOVEALL";
+ Pos = MAP_APPFONT ( 94, 114 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_right.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+};
diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx
new file mode 100644
index 000000000000..f23f340b5e78
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbwiz.cxx
@@ -0,0 +1,386 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbwiz.hxx"
+#include "dbadmin.hrc"
+#include "dbu_dlg.hrc"
+#include "dsitems.hxx"
+#include "dsnItem.hxx"
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <vcl/msgbox.hxx>
+#include "dbustrings.hrc"
+#include "adminpages.hxx"
+#include "generalpage.hxx"
+#include "localresaccess.hxx"
+#include "stringlistitem.hxx"
+#include "propertysetitem.hxx"
+#include <unotools/confignode.hxx>
+#include "ConnectionPage.hxx"
+#include "DriverSettings.hxx"
+#include "DbAdminImpl.hxx"
+#include "dbaccess_helpid.hrc"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace svt;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::util;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+
+#define START_PAGE 0
+#define CONNECTION_PAGE 1
+#define ADDITIONAL_PAGE_DBASE 2
+#define ADDITIONAL_PAGE_FLAT 3
+#define ADDITIONAL_PAGE_LDAP 4
+#define ADDITIONAL_PAGE_ADABAS 5
+#define ADDITIONAL_PAGE_MYSQL_JDBC 6
+#define ADDITIONAL_PAGE_MYSQL_ODBC 7
+#define ADDITIONAL_PAGE_ORACLE_JDBC 8
+#define ADDITIONAL_PAGE_ADO 9
+#define ADDITIONAL_PAGE_ODBC 10
+#define ADDITIONAL_USERDEFINED 11
+#define ADDITIONAL_PAGE_MYSQL_NATIVE 12
+
+
+DBG_NAME(ODbTypeWizDialog)
+//=========================================================================
+//= ODbTypeWizDialog
+//=========================================================================
+//-------------------------------------------------------------------------
+ODbTypeWizDialog::ODbTypeWizDialog(Window* _pParent
+ ,SfxItemSet* _pItems
+ ,const Reference< XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ )
+ :OWizardMachine(_pParent, ModuleRes(DLG_DATABASE_TYPE_CHANGE), WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP )
+ ,m_pOutSet(NULL)
+ ,m_bResetting(sal_False)
+ ,m_bApplied(sal_False)
+ ,m_bUIEnabled( sal_True )
+{
+ DBG_CTOR(ODbTypeWizDialog,NULL);
+ m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() );
+
+ m_pImpl->translateProperties(xDatasource, *m_pOutSet);
+ m_eType = m_pImpl->getDatasourceType(*m_pOutSet);
+
+ SetPageSizePixel(LogicToPixel(::Size(PAGE_X, PAGE_Y), MAP_APPFONT));
+ ShowButtonFixedLine(sal_True);
+ defaultButton(WZB_NEXT);
+ enableButtons(WZB_FINISH, sal_False);
+ enableAutomaticNextButtonState( true );
+
+ m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_DBWIZ_NEXT);
+ m_pCancel->SetHelpId(HID_DBWIZ_CANCEL);
+ m_pFinish->SetHelpId(HID_DBWIZ_FINISH);
+ m_pHelp->SetUniqueId(UID_DBWIZ_HELP);
+ // no local resources needed anymore
+
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION));
+ m_pCollection = pCollectionItem->getCollection();
+
+ FreeResource();
+ ActivatePage();
+}
+
+//-------------------------------------------------------------------------
+ODbTypeWizDialog::~ODbTypeWizDialog()
+{
+ DBG_DTOR(ODbTypeWizDialog,NULL);
+ delete m_pOutSet;
+}
+//-------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialog, OnTypeSelected, OGeneralPage*, _pTabPage)
+{
+ m_eType = _pTabPage->GetSelectedType();
+ const bool bURLRequired = m_pCollection->isConnectionUrlRequired(m_eType);
+ enableButtons(WZB_NEXT,bURLRequired);
+ enableButtons(WZB_FINISH,!bURLRequired);
+ return 1L;
+}
+//-------------------------------------------------------------------------
+WizardTypes::WizardState ODbTypeWizDialog::determineNextState( WizardState _nCurrentState ) const
+{
+ WizardTypes::WizardState nNextState = WZS_INVALID_STATE;
+ switch(_nCurrentState)
+ {
+ case START_PAGE:
+ switch(m_pCollection->determineType(m_eType))
+ {
+ case ::dbaccess::DST_MOZILLA:
+ case ::dbaccess::DST_OUTLOOK:
+ case ::dbaccess::DST_OUTLOOKEXP:
+ case ::dbaccess::DST_EVOLUTION:
+ case ::dbaccess::DST_EVOLUTION_GROUPWISE:
+ case ::dbaccess::DST_EVOLUTION_LDAP:
+ case ::dbaccess::DST_KAB:
+ case ::dbaccess::DST_MACAB:
+ nNextState = WZS_INVALID_STATE;
+ break;
+ case ::dbaccess::DST_MYSQL_NATIVE:
+ nNextState = ADDITIONAL_PAGE_MYSQL_NATIVE;
+ break;
+ default:
+ nNextState = CONNECTION_PAGE;
+ break;
+ }
+ break;
+ case CONNECTION_PAGE:
+ switch(m_pCollection->determineType(m_eType))
+ {
+ case ::dbaccess::DST_MOZILLA:
+ case ::dbaccess::DST_THUNDERBIRD:
+ case ::dbaccess::DST_OUTLOOK:
+ case ::dbaccess::DST_OUTLOOKEXP:
+ case ::dbaccess::DST_EVOLUTION:
+ case ::dbaccess::DST_EVOLUTION_GROUPWISE:
+ case ::dbaccess::DST_EVOLUTION_LDAP:
+ case ::dbaccess::DST_KAB:
+ case ::dbaccess::DST_MACAB:
+ case ::dbaccess::DST_MSACCESS:
+ case ::dbaccess::DST_MSACCESS_2007:
+ case ::dbaccess::DST_JDBC:
+ case ::dbaccess::DST_CALC:
+ nNextState = WZS_INVALID_STATE;
+ break;
+ case ::dbaccess::DST_DBASE:
+ nNextState = ADDITIONAL_PAGE_DBASE;
+ break;
+ case ::dbaccess::DST_FLAT:
+ nNextState = ADDITIONAL_PAGE_FLAT;
+ break;
+ case ::dbaccess::DST_LDAP:
+ nNextState = ADDITIONAL_PAGE_LDAP;
+ break;
+ case ::dbaccess::DST_ADABAS:
+ nNextState = ADDITIONAL_PAGE_ADABAS;
+ break;
+ case ::dbaccess::DST_MYSQL_JDBC:
+ nNextState = ADDITIONAL_PAGE_MYSQL_JDBC;
+ break;
+ case ::dbaccess::DST_MYSQL_ODBC:
+ nNextState = ADDITIONAL_PAGE_MYSQL_ODBC;
+ break;
+ case ::dbaccess::DST_ORACLE_JDBC:
+ nNextState = ADDITIONAL_PAGE_ORACLE_JDBC;
+ break;
+ case ::dbaccess::DST_ADO:
+ nNextState = ADDITIONAL_PAGE_ADO;
+ break;
+ case ::dbaccess::DST_ODBC:
+ nNextState = ADDITIONAL_PAGE_ODBC;
+ break;
+ default:
+ nNextState = WZS_INVALID_STATE;
+ break;
+ }
+ break;
+ }
+
+ return nNextState;
+}
+
+// -----------------------------------------------------------------------------
+const SfxItemSet* ODbTypeWizDialog::getOutputSet() const
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+SfxItemSet* ODbTypeWizDialog::getWriteOutputSet()
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialog::createConnection()
+{
+ return m_pImpl->createConnection();
+}
+// -----------------------------------------------------------------------------
+Reference< XMultiServiceFactory > ODbTypeWizDialog::getORB() const
+{
+ return m_pImpl->getORB();
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > ODbTypeWizDialog::getDriver()
+{
+ return m_pImpl->getDriver();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODbTypeWizDialog::getDatasourceType(const SfxItemSet& _rSet) const
+{
+ return m_pImpl->getDatasourceType(_rSet);
+}
+// -----------------------------------------------------------------------------
+void ODbTypeWizDialog::clearPassword()
+{
+ m_pImpl->clearPassword();
+}
+
+// -----------------------------------------------------------------------------
+TabPage* ODbTypeWizDialog::createPage(WizardState _nState)
+{
+ sal_uInt16 nStringId = STR_PAGETITLE_ADVANCED;
+ TabPage* pPage = NULL;
+ switch(_nState)
+ {
+ case START_PAGE: // start state
+ {
+ pPage = OGeneralPage::Create(this,*m_pOutSet);
+ OGeneralPage* pGeneralPage = static_cast< OGeneralPage* >( pPage );
+ pGeneralPage->SetTypeSelectHandler( LINK( this, ODbTypeWizDialog, OnTypeSelected));
+// pGeneralPage->SetCreationModeHandler( LINK( this, ODbTypeWizDialog, TODO ) );
+ nStringId = STR_PAGETITLE_GENERAL;
+ }
+ break;
+ case CONNECTION_PAGE:
+ pPage = OConnectionTabPage::Create(this,*m_pOutSet);
+ nStringId = STR_PAGETITLE_CONNECTION;
+ break;
+
+ case ADDITIONAL_PAGE_DBASE:
+ pPage = ODriversSettings::CreateDbase(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_FLAT:
+ pPage = ODriversSettings::CreateText(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_LDAP:
+ pPage = ODriversSettings::CreateLDAP(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_ADABAS:
+ pPage = ODriversSettings::CreateAdabas(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_MYSQL_JDBC:
+ pPage = ODriversSettings::CreateMySQLJDBC(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_MYSQL_NATIVE:
+ pPage = ODriversSettings::CreateMySQLNATIVE(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_MYSQL_ODBC:
+ pPage = ODriversSettings::CreateMySQLODBC(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_ORACLE_JDBC:
+ pPage = ODriversSettings::CreateOracleJDBC(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_ADO:
+ pPage = ODriversSettings::CreateAdo(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_PAGE_ODBC:
+ pPage = ODriversSettings::CreateODBC(this,*m_pOutSet);
+ break;
+ case ADDITIONAL_USERDEFINED:
+ pPage = ODriversSettings::CreateUser(this,*m_pOutSet);
+ break;
+ default:
+ OSL_FAIL("Wrong state!");
+ break;
+ }
+
+ // register ourself as modified listener
+ if ( pPage )
+ {
+ static_cast<OGenericAdministrationPage*>(pPage)->SetServiceFactory(m_pImpl->getORB());
+ static_cast<OGenericAdministrationPage*>(pPage)->SetAdminDialog(this,this);
+ // open our own resource block, as the page titles are strings local to this block
+ LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
+
+ pPage->SetText(String(ModuleRes(nStringId)));
+ defaultButton( _nState == START_PAGE ? WZB_NEXT : WZB_FINISH );
+ enableButtons( WZB_FINISH, _nState == START_PAGE ? sal_False : sal_True);
+ pPage->Show();
+ }
+ return pPage;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialog::leaveState(WizardState _nState)
+{
+ SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState));
+ if ( pPage )
+ pPage->FillItemSet(*m_pOutSet);
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODbTypeWizDialog::setTitle(const ::rtl::OUString& _sTitle)
+{
+ SetText(_sTitle);
+}
+//-------------------------------------------------------------------------
+void ODbTypeWizDialog::enableConfirmSettings( bool _bEnable )
+{
+ enableButtons( WZB_FINISH, _bEnable );
+ // TODO:
+ // this is hacky. At the moment, this method is used in only one case.
+ // As soon as it is to be used more wide-spread, we should find a proper concept
+ // for enabling both the Next and Finish buttons, depending on the current page state.
+ // Plus, the concept must also care for the case where those pages are embedded into
+ // anormal tab dialog.
+}
+//-------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialog::saveDatasource()
+{
+ SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState()));
+ if ( pPage )
+ pPage->FillItemSet(*m_pOutSet);
+
+ DataSourceInfoConverter aConverter(getORB());
+ ::rtl::OUString sOldURL;
+ if ( m_pImpl->getCurrentDataSource().is() )
+ m_pImpl->getCurrentDataSource()->getPropertyValue(PROPERTY_URL) >>= sOldURL;
+ aConverter.convert(m_pCollection,sOldURL,m_eType,m_pImpl->getCurrentDataSource());
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+IWizardPageController* ODbTypeWizDialog::getPageController( TabPage* _pCurrentPage ) const
+{
+ OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage);
+ return pPage;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialog::onFinish()
+{
+ saveDatasource();
+ return m_pImpl->saveChanges(*m_pOutSet) ? OWizardMachine::onFinish() : sal_False;
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
new file mode 100644
index 000000000000..17843bd898a4
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -0,0 +1,1139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbwizsetup.hxx"
+#include "dsmeta.hxx"
+#include "DBSetupConnectionPages.hxx"
+#include "dbadminsetup.hrc"
+#include "dbu_dlg.hrc"
+#include "dsitems.hxx"
+#include "dsnItem.hxx"
+
+#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <vcl/msgbox.hxx>
+#include "dbustrings.hrc"
+#include "adminpages.hxx"
+#include <sfx2/docfilt.hxx>
+#include <unotools/ucbhelper.hxx>
+#include "generalpage.hxx"
+#include "localresaccess.hxx"
+#include "stringlistitem.hxx"
+#include "propertysetitem.hxx"
+#include <unotools/confignode.hxx>
+#include "DbAdminImpl.hxx"
+#include "dbaccess_helpid.hrc"
+#include "ConnectionPageSetup.hxx"
+#include "UITools.hxx"
+#include "dbadmin.hrc"
+#include "AsyncronousLink.hxx"
+#include <sfx2/filedlghelper.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#include <com/sun/star/io/IOException.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/document/MacroExecMode.hpp>
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/task/XInteractionHandler2.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+
+
+/** === end UNO includes === **/
+
+#include <svl/filenotation.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <connectivity/DriversConfig.hxx>
+
+#include <memory>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace dbtools;
+using namespace svt;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::task;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::ucb;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::document;
+using namespace ::comphelper;
+using namespace ::cppu;
+
+#define START_PAGE 0
+#define CONNECTION_PAGE 1
+
+OFinalDBPageSetup* pFinalPage;
+
+DBG_NAME(ODbTypeWizDialogSetup)
+//=========================================================================
+//= ODbTypeWizDialogSetup
+//=========================================================================
+//-------------------------------------------------------------------------
+ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent
+ ,SfxItemSet* _pItems
+ ,const Reference< XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ )
+ :svt::RoadmapWizard( _pParent, ModuleRes(DLG_DATABASE_WIZARD),
+ WZB_NEXT | WZB_PREVIOUS | WZB_FINISH | WZB_CANCEL | WZB_HELP )
+
+ , m_pOutSet(NULL)
+ , m_bResetting(sal_False)
+ , m_bApplied(sal_False)
+ , m_bUIEnabled( sal_True )
+ , m_bIsConnectable( sal_False)
+ , m_sRM_IntroText(ModuleRes(STR_PAGETITLE_INTROPAGE))
+ , m_sRM_dBaseText(ModuleRes(STR_PAGETITLE_DBASE))
+ , m_sRM_TextText(ModuleRes(STR_PAGETITLE_TEXT))
+ , m_sRM_MSAccessText(ModuleRes(STR_PAGETITLE_MSACCESS))
+ , m_sRM_LDAPText(ModuleRes(STR_PAGETITLE_LDAP))
+ , m_sRM_ADABASText(ModuleRes(STR_PAGETITLE_ADABAS))
+ , m_sRM_ADOText(ModuleRes(STR_PAGETITLE_ADO))
+ , m_sRM_JDBCText(ModuleRes(STR_PAGETITLE_JDBC))
+ , m_sRM_MySQLNativePageTitle(ModuleRes(STR_PAGETITLE_MYSQL_NATIVE))
+ , m_pGeneralPage( NULL )
+ , m_pMySQLIntroPage(NULL)
+ , m_pCollection( NULL )
+{
+ DBG_CTOR(ODbTypeWizDialogSetup,NULL);
+ // no local resources needed anymore
+ m_sRM_MySQLText = String(ModuleRes(STR_PAGETITLE_MYSQL));
+ m_sRM_OracleText = String(ModuleRes(STR_PAGETITLE_ORACLE));
+ m_sRM_ODBCText = String(ModuleRes(STR_PAGETITLE_ODBC));
+ m_sRM_SpreadSheetText = String(ModuleRes(STR_PAGETITLE_SPREADSHEET));
+ m_sRM_AuthentificationText = String(ModuleRes(STR_PAGETITLE_AUTHENTIFICATION));
+ m_sRM_FinalText = String(ModuleRes(STR_PAGETITLE_FINAL));
+ m_sWorkPath = SvtPathOptions().GetWorkPath();
+ pFinalPage = NULL;
+ // extract the datasource type collection from the item set
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _pItems->GetItem(DSID_TYPECOLLECTION));
+ if (pCollectionItem)
+ m_pCollection = pCollectionItem->getCollection();
+
+ OSL_ENSURE(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !");
+
+ FreeResource();
+
+ m_pImpl = ::std::auto_ptr<ODbDataSourceAdministrationHelper>(new ODbDataSourceAdministrationHelper(_rxORB,this,this));
+ m_pImpl->setDataSourceOrName(_aDataSourceName);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ m_pOutSet = new SfxItemSet( *_pItems->GetPool(), _pItems->GetRanges() );
+
+ m_pImpl->translateProperties(xDatasource, *m_pOutSet);
+
+ SetPageSizePixel(LogicToPixel(::Size(WIZARD_PAGE_X, WIZARD_PAGE_Y), MAP_APPFONT));
+ ShowButtonFixedLine(sal_True);
+ defaultButton(WZB_NEXT);
+ enableButtons(WZB_FINISH, sal_True);
+ enableAutomaticNextButtonState();
+
+ ::dbaccess::ODsnTypeCollection::TypeIterator aIter = m_pCollection->begin();
+ ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
+ for(PathId i = 1;aIter != aEnd;++aIter,++i)
+ {
+ const ::rtl::OUString sURLPrefix = aIter.getURLPrefix();
+ svt::RoadmapWizardTypes::WizardPath aPath;
+ aPath.push_back(PAGE_DBSETUPWIZARD_INTRO);
+ m_pCollection->fillPageIds(sURLPrefix,aPath);
+ aPath.push_back(PAGE_DBSETUPWIZARD_AUTHENTIFICATION);
+ aPath.push_back(PAGE_DBSETUPWIZARD_FINAL);
+
+ declareAuthDepPath(sURLPrefix,i,aPath);
+ }
+
+ svt::RoadmapWizardTypes::WizardPath aPath;
+ aPath.push_back(PAGE_DBSETUPWIZARD_INTRO);
+ declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath);
+
+ m_pPrevPage->SetHelpId(HID_DBWIZ_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_DBWIZ_NEXT);
+ m_pCancel->SetHelpId(HID_DBWIZ_CANCEL);
+ m_pFinish->SetHelpId(HID_DBWIZ_FINISH);
+ m_pHelp->SetUniqueId(UID_DBWIZ_HELP);
+ SetRoadmapInteractive( sal_True );
+ ActivatePage();
+}
+
+void ODbTypeWizDialogSetup::declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths)
+{
+ bool bHasAuthentication = DataSourceMetaData::getAuthentication( _sURL ) != AuthNone;
+
+ // collect the elements of the path
+ WizardPath aPath;
+
+ svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin();
+ svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) )
+ aPath.push_back( *aIter );
+ }
+
+ // call base method
+ ::svt::RoadmapWizard::declarePath( _nPathId, aPath );
+}
+
+String ODbTypeWizDialogSetup::getStateDisplayName( WizardState _nState ) const
+{
+ String sRoadmapItem;
+ switch( _nState )
+ {
+ case PAGE_DBSETUPWIZARD_INTRO:
+ sRoadmapItem = m_sRM_IntroText;
+ break;
+
+ case PAGE_DBSETUPWIZARD_DBASE:
+ sRoadmapItem = m_sRM_dBaseText;
+ break;
+ case PAGE_DBSETUPWIZARD_ADO:
+ sRoadmapItem = m_sRM_ADOText;
+ break;
+ case PAGE_DBSETUPWIZARD_TEXT:
+ sRoadmapItem = m_sRM_TextText;
+ break;
+ case PAGE_DBSETUPWIZARD_MSACCESS:
+ sRoadmapItem = m_sRM_MSAccessText;
+ break;
+ case PAGE_DBSETUPWIZARD_LDAP:
+ sRoadmapItem = m_sRM_LDAPText;
+ break;
+ case PAGE_DBSETUPWIZARD_ADABAS:
+ sRoadmapItem = m_sRM_ADABASText;
+ break;
+ case PAGE_DBSETUPWIZARD_JDBC:
+ sRoadmapItem = m_sRM_JDBCText;
+ break;
+ case PAGE_DBSETUPWIZARD_ORACLE:
+ sRoadmapItem = m_sRM_OracleText;
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_INTRO:
+ sRoadmapItem = m_sRM_MySQLText;
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_JDBC:
+ sRoadmapItem = m_sRM_JDBCText;
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_NATIVE:
+ sRoadmapItem = m_sRM_MySQLNativePageTitle;
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_ODBC:
+ sRoadmapItem = m_sRM_ODBCText;
+ break;
+ case PAGE_DBSETUPWIZARD_ODBC:
+ sRoadmapItem = m_sRM_ODBCText;
+ break;
+ case PAGE_DBSETUPWIZARD_SPREADSHEET:
+ sRoadmapItem = m_sRM_SpreadSheetText;
+ break;
+ case PAGE_DBSETUPWIZARD_AUTHENTIFICATION:
+ sRoadmapItem = m_sRM_AuthentificationText;
+ break;
+ case PAGE_DBSETUPWIZARD_USERDEFINED:
+ {
+ LocalResourceAccess aDummy(DLG_DATABASE_ADMINISTRATION, RSC_TABDIALOG);
+ sRoadmapItem = String(ModuleRes(STR_PAGETITLE_CONNECTION));
+ }
+ break;
+ case PAGE_DBSETUPWIZARD_FINAL:
+ sRoadmapItem = m_sRM_FinalText;
+ break;
+ default:
+ break;
+ }
+ return sRoadmapItem;
+}
+
+//-------------------------------------------------------------------------
+ODbTypeWizDialogSetup::~ODbTypeWizDialogSetup()
+{
+ delete m_pOutSet;
+ DBG_DTOR(ODbTypeWizDialogSetup,NULL);
+}
+
+//-------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage*, /*_pTabPage*/)
+{
+ activateDatabasePath();
+ return 1L;
+}
+
+void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo)
+{
+ _rDSInfo.merge(_aNew,true);
+ uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues();
+ const beans::NamedValue* pIter = aOldValues.getConstArray();
+ const beans::NamedValue* pEnd = pIter + aOldValues.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( !_aNew.has(pIter->Name) )
+ {
+ _rDSInfo.remove(pIter->Name);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void DataSourceInfoConverter::convert(const ::dbaccess::ODsnTypeCollection* _pCollection,const ::rtl::OUString& _sOldURLPrefix,const ::rtl::OUString& _sNewURLPrefix,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDatasource)
+{
+ if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) )
+ return ;
+ uno::Sequence< beans::PropertyValue> aInfo;
+ _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
+ ::comphelper::NamedValueCollection aDS(aInfo);
+
+ ::connectivity::DriversConfig aDriverConfig(m_xFactory);
+
+ const ::comphelper::NamedValueCollection& aOldProperties = aDriverConfig.getProperties(_sOldURLPrefix);
+ const ::comphelper::NamedValueCollection& aNewProperties = aDriverConfig.getProperties(_sNewURLPrefix);
+ lcl_removeUnused(aOldProperties,aNewProperties,aDS);
+
+ aDS >>= aInfo;
+ _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo));
+}
+//-------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::activateDatabasePath()
+{
+ switch ( m_pGeneralPage->GetDatabaseCreationMode() )
+ {
+ case OGeneralPage::eCreateNew:
+ {
+ sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
+ if ( nCreateNewDBIndex == -1 )
+ nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) );
+ OSL_ENSURE( nCreateNewDBIndex != -1, "ODbTypeWizDialogSetup::activateDatabasePath: the GeneralPage should have prevented this!" );
+ activatePath( static_cast< PathId >( nCreateNewDBIndex + 1 ), sal_True );
+
+ enableState(PAGE_DBSETUPWIZARD_FINAL, sal_True );
+ enableButtons( WZB_FINISH, sal_True);
+ }
+ break;
+ case OGeneralPage::eConnectExternal:
+ {
+ ::rtl::OUString sOld = m_sURL;
+ DataSourceInfoConverter aConverter(getORB());
+ m_sURL = m_pGeneralPage->GetSelectedType();
+ aConverter.convert(m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource());
+ ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL));
+ if (eType == ::dbaccess::DST_UNKNOWN)
+ eType = m_pCollection->determineType(m_sOldURL);
+
+ activatePath( static_cast<PathId>(m_pCollection->getIndexOf(m_sURL) + 1), sal_True);
+ updateTypeDependentStates();
+ }
+ break;
+ case OGeneralPage::eOpenExisting:
+ {
+ activatePath( static_cast<PathId>(m_pCollection->size() + 1), sal_True );
+ enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 );
+ }
+ break;
+ default:
+ OSL_FAIL( "ODbTypeWizDialogSetup::activateDatabasePath: unknown creation mode!" );
+ }
+
+ enableButtons( WZB_NEXT, m_pGeneralPage->GetDatabaseCreationMode() != OGeneralPage::eOpenExisting );
+ // TODO: this should go into the base class. Point is, we activate a path whose *last*
+ // step is also the current one. The base class should automatically disable
+ // the Next button in such a case. However, not for this patch ...
+}
+
+//-------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::updateTypeDependentStates()
+{
+ sal_Bool bDoEnable = sal_False;
+ sal_Bool bIsConnectionRequired = IsConnectionUrlRequired();
+ if (!bIsConnectionRequired)
+ {
+ bDoEnable = sal_True;
+ }
+ else if ( m_sURL == m_sOldURL )
+ {
+ bDoEnable = m_bIsConnectable;
+ }
+ enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, bDoEnable);
+ enableState(PAGE_DBSETUPWIZARD_FINAL, bDoEnable );
+ enableButtons( WZB_FINISH, bDoEnable);
+}
+
+
+//-------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialogSetup::IsConnectionUrlRequired()
+{
+ return m_pCollection->isConnectionUrlRequired(m_sURL);
+}
+
+//-------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::resetPages(const Reference< XPropertySet >& _rxDatasource)
+{
+ // remove all items which relate to indirect properties from the input set
+ // (without this, the following may happen: select an arbitrary data source where some indirect properties
+ // are set. Select another data source of the same type, where the indirect props are not set (yet). Then,
+ // the indirect property values of the first ds are shown in the second ds ...)
+ const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties();
+ for ( ODbDataSourceAdministrationHelper::ConstMapInt2StringIterator aIndirect = rMap.begin();
+ aIndirect != rMap.end();
+ ++aIndirect
+ )
+ getWriteOutputSet()->ClearItem( (sal_uInt16)aIndirect->first );
+
+ // extract all relevant data from the property set of the data source
+ m_pImpl->translateProperties(_rxDatasource, *getWriteOutputSet());
+}
+// -----------------------------------------------------------------------------
+const SfxItemSet* ODbTypeWizDialogSetup::getOutputSet() const
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+SfxItemSet* ODbTypeWizDialogSetup::getWriteOutputSet()
+{
+ return m_pOutSet;
+}
+// -----------------------------------------------------------------------------
+::std::pair< Reference<XConnection>,sal_Bool> ODbTypeWizDialogSetup::createConnection()
+{
+ return m_pImpl->createConnection();
+}
+// -----------------------------------------------------------------------------
+Reference< XMultiServiceFactory > ODbTypeWizDialogSetup::getORB() const
+{
+ return m_pImpl->getORB();
+}
+// -----------------------------------------------------------------------------
+Reference< XDriver > ODbTypeWizDialogSetup::getDriver()
+{
+ return m_pImpl->getDriver();
+}
+
+
+::dbaccess::DATASOURCE_TYPE ODbTypeWizDialogSetup::VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const
+{
+ ::dbaccess::DATASOURCE_TYPE LocDatabaseType = _DatabaseType;
+ if ((LocDatabaseType == ::dbaccess::DST_MYSQL_JDBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_ODBC) || (LocDatabaseType == ::dbaccess::DST_MYSQL_NATIVE))
+ {
+ if (m_pMySQLIntroPage != NULL)
+ {
+ switch( m_pMySQLIntroPage->getMySQLMode() )
+ {
+ case OMySQLIntroPageSetup::VIA_JDBC:
+ return ::dbaccess::DST_MYSQL_JDBC;
+ case OMySQLIntroPageSetup::VIA_NATIVE:
+ return ::dbaccess::DST_MYSQL_NATIVE;
+ case OMySQLIntroPageSetup::VIA_ODBC:
+ return ::dbaccess::DST_MYSQL_ODBC;
+ }
+ }
+ }
+ return LocDatabaseType;
+}
+
+
+
+// -----------------------------------------------------------------------------
+::rtl::OUString ODbTypeWizDialogSetup::getDatasourceType(const SfxItemSet& _rSet) const
+{
+ ::rtl::OUString sRet = m_pImpl->getDatasourceType(_rSet);
+ if (m_pMySQLIntroPage != NULL && m_pMySQLIntroPage->IsVisible() )
+ {
+ switch( m_pMySQLIntroPage->getMySQLMode() )
+ {
+ case OMySQLIntroPageSetup::VIA_JDBC:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"));
+ break;
+ case OMySQLIntroPageSetup::VIA_NATIVE:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"));
+ break;
+ case OMySQLIntroPageSetup::VIA_ODBC:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"));
+ break;
+ }
+ }
+ return sRet;
+}
+
+// -----------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::clearPassword()
+{
+ m_pImpl->clearPassword();
+}
+
+// -----------------------------------------------------------------------------
+TabPage* ODbTypeWizDialogSetup::createPage(WizardState _nState)
+{
+ SfxTabPage* pFirstPage;
+ OGenericAdministrationPage* pPage = NULL;
+ switch(_nState)
+ {
+ case PAGE_DBSETUPWIZARD_INTRO:
+ pFirstPage = OGeneralPage::Create(this,*m_pOutSet, sal_True);
+ pPage = static_cast<OGenericAdministrationPage*> (pFirstPage);
+ m_pGeneralPage = static_cast<OGeneralPage*>(pFirstPage);
+ m_pGeneralPage->SetTypeSelectHandler(LINK(this, ODbTypeWizDialogSetup, OnTypeSelected));
+ m_pGeneralPage->SetCreationModeHandler(LINK( this, ODbTypeWizDialogSetup, OnChangeCreationMode ) );
+ m_pGeneralPage->SetDocumentSelectionHandler(LINK( this, ODbTypeWizDialogSetup, OnRecentDocumentSelected ) );
+ m_pGeneralPage->SetChooseDocumentHandler(LINK( this, ODbTypeWizDialogSetup, OnSingleDocumentChosen ) );
+ break;
+
+ case PAGE_DBSETUPWIZARD_DBASE:
+ pPage = OConnectionTabPageSetup::CreateDbaseTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_ADO:
+ pPage = OConnectionTabPageSetup::CreateADOTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_TEXT:
+ pPage = OTextConnectionPageSetup::CreateTextTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_ODBC:
+ pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_JDBC:
+ pPage = OJDBCConnectionPageSetup::CreateJDBCTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_MYSQL_ODBC:
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:")))));
+ pPage = OConnectionTabPageSetup::CreateODBCTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_MYSQL_JDBC:
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:")))));
+ pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage( this, *m_pOutSet);
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_NATIVE:
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")))));
+ pPage = MySQLNativeSetupPage::Create( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_ORACLE:
+ pPage = OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_ADABAS:
+ pPage = OConnectionTabPageSetup::CreateAdabasTabPage( this, *m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_LDAP :
+ pPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_SPREADSHEET: /// first user defined driver
+ pPage = OSpreadSheetConnectionPageSetup::CreateSpreadSheetTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_MSACCESS:
+ pPage = OConnectionTabPageSetup::CreateMSAccessTabPage(this,*m_pOutSet);
+ break;
+ case PAGE_DBSETUPWIZARD_MYSQL_INTRO:
+ m_pMySQLIntroPage = OMySQLIntroPageSetup::CreateMySQLIntroTabPage(this,*m_pOutSet);
+ m_pMySQLIntroPage->SetClickHdl(LINK( this, ODbTypeWizDialogSetup, ImplClickHdl ) );
+ pPage = m_pMySQLIntroPage;
+ break;
+
+ case PAGE_DBSETUPWIZARD_AUTHENTIFICATION:
+ pPage = OAuthentificationPageSetup::CreateAuthentificationTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_USERDEFINED:
+ pPage = OConnectionTabPageSetup::CreateUserDefinedTabPage(this,*m_pOutSet);
+ break;
+
+ case PAGE_DBSETUPWIZARD_FINAL:
+ pPage = OFinalDBPageSetup::CreateFinalDBTabPageSetup(this,*m_pOutSet);
+ pFinalPage = static_cast<OFinalDBPageSetup*> (pPage);
+ break;
+ }
+
+ if ((_nState != PAGE_DBSETUPWIZARD_INTRO) && (_nState != PAGE_DBSETUPWIZARD_AUTHENTIFICATION))
+ {
+ pPage->SetModifiedHandler(LINK( this, ODbTypeWizDialogSetup, ImplModifiedHdl ) );
+ }
+
+ if ( pPage )
+ {
+ pPage->SetServiceFactory(m_pImpl->getORB());
+ pPage->SetAdminDialog(this, this);
+
+ defaultButton( _nState == PAGE_DBSETUPWIZARD_FINAL ? WZB_FINISH : WZB_NEXT );
+ enableButtons( WZB_FINISH, _nState == PAGE_DBSETUPWIZARD_FINAL );
+ enableButtons( WZB_NEXT, _nState == PAGE_DBSETUPWIZARD_FINAL ? sal_False : sal_True);
+ pPage->Show();
+ }
+ return pPage;
+}
+
+
+IMPL_LINK(ODbTypeWizDialogSetup, ImplModifiedHdl, OGenericAdministrationPage*, _pConnectionPageSetup)
+{
+ m_bIsConnectable = _pConnectionPageSetup->GetRoadmapStateValue( );
+ enableState(PAGE_DBSETUPWIZARD_FINAL, m_bIsConnectable);
+ enableState(PAGE_DBSETUPWIZARD_AUTHENTIFICATION, m_bIsConnectable);
+ if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL)
+ enableButtons( WZB_FINISH, sal_True);
+ else
+ enableButtons( WZB_FINISH, m_bIsConnectable);
+ enableButtons( WZB_NEXT, m_bIsConnectable && (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL));
+ return sal_True;
+}
+
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialogSetup, ImplClickHdl, OMySQLIntroPageSetup*, _pMySQLIntroPageSetup)
+{
+ ::rtl::OUString sURLPrefix;
+ switch( _pMySQLIntroPageSetup->getMySQLMode() )
+ {
+ case OMySQLIntroPageSetup::VIA_ODBC:
+ sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:odbc:"));
+ break;
+ case OMySQLIntroPageSetup::VIA_JDBC:
+ sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:jdbc:"));
+ break;
+ case OMySQLIntroPageSetup::VIA_NATIVE:
+ sURLPrefix = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:"));
+ break;
+ }
+ activatePath( static_cast<PathId>(m_pCollection->getIndexOf(sURLPrefix) + 1), sal_True);
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialogSetup, OnChangeCreationMode, OGeneralPage*, /*_pGeneralPage*/)
+{
+ activateDatabasePath();
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialogSetup, OnRecentDocumentSelected, OGeneralPage*, /*_pGeneralPage*/)
+{
+ enableButtons( WZB_FINISH, m_pGeneralPage->GetSelectedDocument().sURL.Len() != 0 );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(ODbTypeWizDialogSetup, OnSingleDocumentChosen, OGeneralPage*, /*_pGeneralPage*/)
+{
+ if ( prepareLeaveCurrentState( eFinish ) )
+ onFinish();
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::enterState(WizardState _nState)
+{
+ m_sURL = m_pImpl->getDatasourceType(*m_pOutSet);
+ RoadmapWizard::enterState(_nState);
+ switch(_nState)
+ {
+ case PAGE_DBSETUPWIZARD_INTRO:
+ m_sOldURL = m_sURL;
+ break;
+ case PAGE_DBSETUPWIZARD_FINAL:
+ enableButtons( WZB_FINISH, sal_True);
+ if ( pFinalPage )
+ pFinalPage->enableTableWizardCheckBox(m_pCollection->supportsTableCreation(m_sURL));
+ break;
+ }
+}
+
+//-------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialogSetup::saveDatasource()
+{
+ SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(getCurrentState()));
+ if ( pPage )
+ pPage->FillItemSet(*m_pOutSet);
+ return sal_True;
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialogSetup::leaveState(WizardState _nState)
+{
+ if (_nState == PAGE_DBSETUPWIZARD_MYSQL_INTRO)
+ return sal_True;
+ if ( _nState == PAGE_DBSETUPWIZARD_INTRO && m_sURL != m_sOldURL )
+ {
+ resetPages(m_pImpl->getCurrentDataSource());
+ }
+ SfxTabPage* pPage = static_cast<SfxTabPage*>(WizardDialog::GetPage(_nState));
+ return pPage && pPage->DeactivatePage(m_pOutSet) != 0;
+}
+
+// -----------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::setTitle(const ::rtl::OUString& /*_sTitle*/)
+{
+ OSL_FAIL( "ODbTypeWizDialogSetup::setTitle: not implemented!" );
+ // why?
+}
+
+//-------------------------------------------------------------------------
+void ODbTypeWizDialogSetup::enableConfirmSettings( bool _bEnable )
+{
+ (void)_bEnable;
+}
+
+//-------------------------------------------------------------------------
+namespace
+{
+ bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, const Any& _rRequest )
+ {
+ OInteractionRequest* pRequest = new OInteractionRequest( _rRequest );
+ Reference < XInteractionRequest > xRequest( pRequest );
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ pRequest->addContinuation( pAbort );
+
+ return _rxHandler->handleInteractionRequest( xRequest );
+ }
+}
+
+//-------------------------------------------------------------------------
+sal_Bool ODbTypeWizDialogSetup::SaveDatabaseDocument()
+{
+ Reference< XInteractionHandler2 > xHandler( getORB()->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ try
+ {
+ if (callSaveAsDialog() == sal_True)
+ {
+ m_pImpl->saveChanges(*m_pOutSet);
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ Reference< XModel > xModel( getDataSourceOrModel( xDatasource ), UNO_QUERY_THROW );
+ Reference< XStorable > xStore( xModel, UNO_QUERY_THROW );
+
+ if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eCreateNew )
+ CreateDatabase();
+
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ aArgs.put( "Overwrite", sal_Bool( sal_True ) );
+ aArgs.put( "InteractionHandler", xHandler );
+ aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
+
+ ::rtl::OUString sPath = m_pImpl->getDocumentUrl( *m_pOutSet );
+ xStore->storeAsURL( sPath, aArgs.getPropertyValues() );
+
+ if ( !pFinalPage || pFinalPage->IsDatabaseDocumentToBeRegistered() )
+ RegisterDataSourceByLocation( sPath );
+
+ return sal_True;
+ }
+ }
+ catch ( const Exception& e )
+ {
+ Any aError = ::cppu::getCaughtException();
+ if ( xHandler.is() )
+ {
+ if ( !lcl_handle( xHandler, aError ) )
+ {
+ InteractiveIOException aRequest;
+ aRequest.Classification = InteractionClassification_ERROR;
+ if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) )
+ // assume savint the document faile
+ aRequest.Code = IOErrorCode_CANT_WRITE;
+ else
+ aRequest.Code = IOErrorCode_GENERAL;
+ aRequest.Message = e.Message;
+ aRequest.Context = e.Context;
+ lcl_handle( xHandler, makeAny( aRequest ) );
+ }
+ }
+ }
+ return sal_False;
+}
+ // ------------------------------------------------------------------------
+ sal_Bool ODbTypeWizDialogSetup::IsDatabaseDocumentToBeOpened() const
+ {
+ if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
+ return sal_True;
+
+ if ( pFinalPage != NULL )
+ return pFinalPage->IsDatabaseDocumentToBeOpened();
+
+ return sal_True;
+ }
+
+ // ------------------------------------------------------------------------
+ sal_Bool ODbTypeWizDialogSetup::IsTableWizardToBeStarted() const
+ {
+ if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
+ return sal_False;
+
+ if ( pFinalPage != NULL )
+ return pFinalPage->IsTableWizardToBeStarted();
+
+ return sal_False;
+ }
+
+ //-------------------------------------------------------------------------
+ ::rtl::OUString ODbTypeWizDialogSetup::getDefaultDatabaseType() const
+ {
+ ::rtl::OUString sEmbeddedURL = m_pCollection->getEmbeddedDatabase();
+ ::connectivity::DriversConfig aDriverConfig(getORB());
+ try
+ {
+ if ( !aDriverConfig.getDriverFactoryName(sEmbeddedURL).getLength() || !m_pImpl->getDriver(sEmbeddedURL).is() )
+ sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"));
+ }
+ catch(const Exception&)
+ {
+ sEmbeddedURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"));
+ }
+
+ return sEmbeddedURL;
+ }
+
+ //-------------------------------------------------------------------------
+ void ODbTypeWizDialogSetup::CreateDatabase()
+ {
+ ::rtl::OUString sUrl;
+ ::rtl::OUString eType = getDefaultDatabaseType();
+ if ( m_pCollection->isEmbeddedDatabase(eType) )
+ {
+ sUrl = eType;
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ OSL_ENSURE(xDatasource.is(),"DataSource is null!");
+ if ( xDatasource.is() )
+ xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) );
+ m_pImpl->translateProperties(xDatasource,*m_pOutSet);
+ }
+ else if ( m_pCollection->isFileSystemBased(eType) )
+ {
+ Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
+ INetURLObject aDBPathURL(m_sWorkPath);
+ aDBPathURL.Append(m_aDocURL.getBase());
+ createUniqueFolderName(&aDBPathURL);
+ ::rtl::OUString sPrefix = eType;
+ sUrl = aDBPathURL.GetMainURL( INetURLObject::NO_DECODE);
+ xSimpleFileAccess->createFolder(sUrl);
+ sUrl = sPrefix.concat(sUrl);
+ }
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl));
+ m_pImpl->saveChanges(*m_pOutSet);
+ }
+
+ //-------------------------------------------------------------------------
+ void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const ::rtl::OUString& _sPath)
+ {
+ Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource();
+ Reference< XNamingService > xDatabaseContext(getORB()->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ Reference< XNameAccess > xNameAccessDatabaseContext(xDatabaseContext, UNO_QUERY);
+ INetURLObject aURL( _sPath );
+ ::rtl::OUString sFilename = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ ::rtl::OUString sDatabaseName = ::dbtools::createUniqueName(xNameAccessDatabaseContext, sFilename,sal_False);
+ xDatabaseContext->registerObject(sDatabaseName, xDatasource);
+ }
+
+
+ //-------------------------------------------------------------------------
+ sal_Bool ODbTypeWizDialogSetup::callSaveAsDialog()
+ {
+ sal_Bool bRet = sal_False;
+ WinBits nBits(WB_STDMODAL|WB_SAVEAS);
+ ::sfx2::FileDialogHelper aFileDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, static_cast<sal_uInt32>(nBits), this);
+ const SfxFilter* pFilter = getStandardDatabaseFilter();
+ if ( pFilter )
+ {
+ INetURLObject aWorkURL( m_sWorkPath );
+ aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( INetURLObject::NO_DECODE ));
+
+ ::rtl::OUString sDefaultName = String( ModuleRes( STR_DATABASEDEFAULTNAME ) );
+ ::rtl::OUString sExtension = pFilter->GetDefaultExtension();
+ sDefaultName += sExtension.replaceAt( 0, 1, ::rtl::OUString() );
+ aWorkURL.Append( sDefaultName );
+ sDefaultName = createUniqueFileName( aWorkURL );
+ aFileDlg.SetFileName( sDefaultName );
+
+ aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
+ aFileDlg.SetCurrentFilter(pFilter->GetUIName());
+ }
+ if ( aFileDlg.Execute() == ERRCODE_NONE )
+ {
+ m_aDocURL = INetURLObject(aFileDlg.GetPath());
+
+ if( m_aDocURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ ::rtl::OUString sFileName = m_aDocURL.GetMainURL( INetURLObject::NO_DECODE );
+ if ( ::utl::UCBContentHelper::IsDocument(sFileName) )
+ ::utl::UCBContentHelper::Kill(sFileName);
+ m_pOutSet->Put(SfxStringItem(DSID_DOCUMENT_URL, sFileName));
+ bRet = sal_True;
+ }
+ }
+ return bRet;
+ }
+
+ //-------------------------------------------------------------------------
+ void ODbTypeWizDialogSetup::createUniqueFolderName(INetURLObject* pURL)
+ {
+ Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
+ :: rtl::OUString sLastSegmentName = pURL->getName();
+ sal_Bool bFolderExists = sal_True;
+ sal_Int32 i = 1;
+ while (bFolderExists == sal_True)
+ {
+ bFolderExists = xSimpleFileAccess->isFolder(pURL->GetMainURL( INetURLObject::NO_DECODE ));
+ if (bFolderExists == sal_True)
+ {
+ i++;
+ pURL->setName(sLastSegmentName.concat(::rtl::OUString::valueOf(i)));
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ String ODbTypeWizDialogSetup::createUniqueFileName(const INetURLObject& _rURL)
+ {
+ Reference< XSimpleFileAccess > xSimpleFileAccess(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess"))), UNO_QUERY);
+ :: rtl::OUString sFilename = _rURL.getName();
+ ::rtl::OUString BaseName = _rURL.getBase();
+ ::rtl::OUString sExtension = _rURL.getExtension();
+
+ sal_Bool bElementExists = sal_True;
+
+ INetURLObject aExistenceCheck( _rURL );
+ for ( sal_Int32 i = 1; bElementExists; )
+ {
+ bElementExists = xSimpleFileAccess->exists( aExistenceCheck.GetMainURL( INetURLObject::NO_DECODE ) );
+ if ( bElementExists )
+ {
+ aExistenceCheck.setBase( BaseName.concat( ::rtl::OUString::valueOf( i ) ) );
+ ++i;
+ }
+ }
+ return aExistenceCheck.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ }
+ // -----------------------------------------------------------------------------
+ IWizardPageController* ODbTypeWizDialogSetup::getPageController( TabPage* _pCurrentPage ) const
+ {
+ OGenericAdministrationPage* pPage = static_cast<OGenericAdministrationPage*>(_pCurrentPage);
+ return pPage;
+ }
+
+ // -----------------------------------------------------------------------------
+ namespace
+ {
+ // .............................................................................
+ typedef ::cppu::WeakImplHelper1 < XTerminateListener
+ > AsyncLoader_Base;
+ class AsyncLoader : public AsyncLoader_Base
+ {
+ private:
+ Reference< XComponentLoader > m_xFrameLoader;
+ Reference< XDesktop > m_xDesktop;
+ Reference< XInteractionHandler > m_xInteractionHandler;
+ ::rtl::OUString m_sURL;
+ OAsyncronousLink m_aAsyncCaller;
+
+ public:
+ AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL );
+
+ void doLoadAsync();
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const EventObject& Event ) throw (TerminationVetoException, RuntimeException);
+ virtual void SAL_CALL notifyTermination( const EventObject& Event ) throw (RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ DECL_LINK( OnOpenDocument, void* );
+ };
+
+ // .............................................................................
+ AsyncLoader::AsyncLoader( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rURL )
+ :m_sURL( _rURL )
+ ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) )
+ {
+ try
+ {
+ m_xDesktop.set( _rxORB->createInstance( SERVICE_FRAME_DESKTOP ), UNO_QUERY_THROW );
+ m_xFrameLoader.set( m_xDesktop, UNO_QUERY_THROW );
+ m_xInteractionHandler.set(
+ _rxORB->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) )
+ ),
+ UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // .............................................................................
+ void AsyncLoader::doLoadAsync()
+ {
+ OSL_ENSURE( !m_aAsyncCaller.IsRunning(), "AsyncLoader:doLoadAsync: already running!" );
+
+ acquire();
+ try
+ {
+ if ( m_xDesktop.is() )
+ m_xDesktop->addTerminateListener( this );
+ }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ m_aAsyncCaller.Call( NULL );
+ }
+
+ // .............................................................................
+ IMPL_LINK( AsyncLoader, OnOpenDocument, void*, /*_pEmptyArg*/ )
+ {
+ try
+ {
+ if ( m_xFrameLoader.is() )
+ {
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "InteractionHandler", m_xInteractionHandler );
+ aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG );
+
+ Sequence< PropertyValue > aLoadArgPV;
+ aLoadArgs >>= aLoadArgPV;
+
+ m_xFrameLoader->loadComponentFromURL( m_sURL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ),
+ FrameSearchFlag::ALL,
+ aLoadArgPV
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ // do not assert.
+ // Such an exception happens for instance of the to-be-loaded document does not exist anymore.
+ }
+
+ try
+ {
+ if ( m_xDesktop.is() )
+ m_xDesktop->removeTerminateListener( this );
+ }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ release();
+ return 0L;
+ }
+
+ // .............................................................................
+ void SAL_CALL AsyncLoader::queryTermination( const EventObject& /*Event*/ ) throw (TerminationVetoException, RuntimeException)
+ {
+ throw TerminationVetoException();
+ }
+
+ // .............................................................................
+ void SAL_CALL AsyncLoader::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException)
+ {
+ }
+ // .............................................................................
+ void SAL_CALL AsyncLoader::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODbTypeWizDialogSetup::onFinish()
+ {
+ if ( m_pGeneralPage->GetDatabaseCreationMode() == OGeneralPage::eOpenExisting )
+ {
+ // we're not going to re-use the XModel we have - since the document the user
+ // wants us to load could be a non-database document. Instead, we asynchronously
+ // open the selected document. Thus, the wizard's return value is RET_CANCEL,
+ // which means to not continue loading the database document
+ if ( !OWizardMachine::Finnish( RET_CANCEL ) )
+ return sal_False;
+
+ Reference< XComponentLoader > xFrameLoader;
+ try
+ {
+ AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocument().sURL );
+ ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader );
+ pAsyncLoader->doLoadAsync();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_True;
+ }
+
+ if (getCurrentState() != PAGE_DBSETUPWIZARD_FINAL)
+ {
+ skipUntil(PAGE_DBSETUPWIZARD_FINAL);
+ }
+ if (getCurrentState() == PAGE_DBSETUPWIZARD_FINAL)
+ return SaveDatabaseDocument() ? OWizardMachine::onFinish() : sal_False;
+ else
+ {
+ enableButtons( WZB_FINISH, sal_False );
+ return sal_False;
+ }
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/detailpages.cxx b/dbaccess/source/ui/dlg/detailpages.cxx
new file mode 100644
index 000000000000..c02f603c99eb
--- /dev/null
+++ b/dbaccess/source/ui/dlg/detailpages.cxx
@@ -0,0 +1,1128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "detailpages.hxx"
+#include "sqlmessage.hxx"
+#include "dsmeta.hxx"
+#include "advancedsettings.hxx"
+#include "DbAdminImpl.hxx"
+#include "dsitems.hxx"
+#include "dbfindex.hxx"
+#include "localresaccess.hxx"
+#include "dsnItem.hxx"
+
+#include "dbaccess_helpid.hrc"
+#include "dbu_dlg.hrc"
+#include "dbadmin.hrc"
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/mnemonic.hxx>
+#include <svl/cjkoptions.hxx>
+#include <jvmaccess/virtualmachine.hxx>
+#include "AdabasPage.hrc"
+#include "AdabasStat.hxx"
+#include <connectivity/CommonTools.hxx>
+#include "DriverSettings.hxx"
+#include "dbadmin.hxx"
+#include <comphelper/types.hxx>
+#include "AutoControls.hrc"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::dbtools;
+
+ //========================================================================
+ //= OCommonBehaviourTabPage
+ //========================================================================
+ DBG_NAME(OCommonBehaviourTabPage)
+ //------------------------------------------------------------------------
+ OCommonBehaviourTabPage::OCommonBehaviourTabPage(Window* pParent, sal_uInt16 nResId, const SfxItemSet& _rCoreAttrs,
+ sal_uInt32 nControlFlags,bool _bFreeResource)
+
+ :OGenericAdministrationPage(pParent, ModuleRes(nResId), _rCoreAttrs)
+ ,m_pOptionsLabel(NULL)
+ ,m_pOptions(NULL)
+ ,m_pDataConvertFixedLine(NULL)
+ ,m_pCharsetLabel(NULL)
+ ,m_pCharset(NULL)
+ ,m_pAutoFixedLine(NULL)
+ ,m_pAutoRetrievingEnabled(NULL)
+ ,m_pAutoIncrementLabel(NULL)
+ ,m_pAutoIncrement(NULL)
+ ,m_pAutoRetrievingLabel(NULL)
+ ,m_pAutoRetrieving(NULL)
+ ,m_nControlFlags(nControlFlags)
+ {
+ DBG_CTOR(OCommonBehaviourTabPage,NULL);
+
+ if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
+ {
+ m_pOptionsLabel = new FixedText(this, ModuleRes(FT_OPTIONS));
+ m_pOptions = new Edit(this, ModuleRes(ET_OPTIONS));
+ m_pOptions->SetModifyHdl(getControlModifiedLink());
+ }
+
+ if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
+ {
+ m_pDataConvertFixedLine = new FixedLine(this, ModuleRes(FL_DATACONVERT));
+ m_pCharsetLabel = new FixedText(this, ModuleRes(FT_CHARSET));
+ m_pCharset = new CharSetListBox(this, ModuleRes(LB_CHARSET));
+ m_pCharset->SetSelectHdl(getControlModifiedLink());
+ }
+
+ Window* pWindows[] = { m_pAutoRetrievingEnabled, m_pAutoFixedLine,
+ m_pAutoIncrementLabel, m_pAutoIncrement,
+ m_pAutoRetrievingLabel, m_pAutoRetrieving };
+
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=1; i < nCount; ++i)
+ {
+ if ( pWindows[i] )
+ {
+ Window* pPrev = pWindows[i-1];
+ for (sal_Int32 j = i-1; pPrev == NULL && j >= 0 ; --j)
+ {
+ pPrev = pWindows[j];
+ }
+ if ( pPrev )
+ pWindows[i]->SetZOrder(pPrev, WINDOW_ZORDER_BEHIND);
+ }
+ }
+
+ if ( _bFreeResource )
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ OCommonBehaviourTabPage::~OCommonBehaviourTabPage()
+ {
+ DELETEZ(m_pOptionsLabel);
+ DELETEZ(m_pOptions);
+
+ DELETEZ(m_pDataConvertFixedLine);
+ DELETEZ(m_pCharsetLabel);
+ DELETEZ(m_pCharset);
+
+ DELETEZ(m_pAutoFixedLine);
+ DELETEZ(m_pAutoIncrementLabel);
+ DELETEZ(m_pAutoIncrement);
+
+ DELETEZ(m_pAutoRetrievingEnabled);
+ DELETEZ(m_pAutoRetrievingLabel);
+ DELETEZ(m_pAutoRetrieving);
+
+ DBG_DTOR(OCommonBehaviourTabPage,NULL);
+ }
+
+ // -----------------------------------------------------------------------
+ void OCommonBehaviourTabPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(m_pOptionsLabel));
+ }
+
+ if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(m_pDataConvertFixedLine));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(m_pCharsetLabel));
+ }
+ }
+ // -----------------------------------------------------------------------
+ void OCommonBehaviourTabPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(m_pOptions));
+
+ if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
+ _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pCharset));
+ }
+
+ // -----------------------------------------------------------------------
+ void OCommonBehaviourTabPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ // collect the items
+ SFX_ITEMSET_GET(_rSet, pOptionsItem, SfxStringItem, DSID_ADDITIONALOPTIONS, sal_True);
+ SFX_ITEMSET_GET(_rSet, pCharsetItem, SfxStringItem, DSID_CHARSET, sal_True);
+
+ // forward the values to the controls
+ if (bValid)
+ {
+ if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
+ {
+ m_pOptions->SetText(pOptionsItem->GetValue());
+ m_pOptions->ClearModifyFlag();
+ }
+
+ if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
+ {
+ m_pCharset->SelectEntryByIanaName( pCharsetItem->GetValue() );
+ }
+ }
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ }
+ // -----------------------------------------------------------------------
+ sal_Bool OCommonBehaviourTabPage::FillItemSet(SfxItemSet& _rSet)
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ if ((m_nControlFlags & CBTP_USE_OPTIONS) == CBTP_USE_OPTIONS)
+ {
+ fillString(_rSet,m_pOptions,DSID_ADDITIONALOPTIONS,bChangedSomething);
+ }
+
+ if ((m_nControlFlags & CBTP_USE_CHARSET) == CBTP_USE_CHARSET)
+ {
+ if ( m_pCharset->StoreSelectedCharSet( _rSet, DSID_CHARSET ) )
+ bChangedSomething = sal_True;
+ }
+
+ return bChangedSomething;
+ }
+
+ //========================================================================
+ //= ODbaseDetailsPage
+ //========================================================================
+ DBG_NAME(ODbaseDetailsPage)
+ //------------------------------------------------------------------------
+ ODbaseDetailsPage::ODbaseDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_DBASE, _rCoreAttrs, CBTP_USE_CHARSET ,false)
+ ,m_aShowDeleted (this, ModuleRes(CB_SHOWDELETEDROWS))
+ ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) )
+ ,m_aFT_Message (this, ModuleRes( FT_SPECIAL_MESSAGE) )
+ ,m_aIndexes (this, ModuleRes(PB_INDICIES))
+ {
+ DBG_CTOR(ODbaseDetailsPage,NULL);
+
+ m_aIndexes.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
+ m_aShowDeleted.SetClickHdl(LINK(this, ODbaseDetailsPage, OnButtonClicked));
+
+ // correct the z-order which is mixed-up because the base class constructed some controls before we did
+ m_pCharset->SetZOrder(&m_aShowDeleted, WINDOW_ZORDER_BEFOR);
+
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ ODbaseDetailsPage::~ODbaseDetailsPage()
+ {
+
+ DBG_DTOR(ODbaseDetailsPage,NULL);
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateDbase( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new ODbaseDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ void ODbaseDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aShowDeleted));
+ }
+ // -----------------------------------------------------------------------
+ void ODbaseDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFT_Message));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_aIndexes));
+ }
+ // -----------------------------------------------------------------------
+ void ODbaseDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ // get the DSN string (needed for the index dialog)
+ SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(_rSet, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+ ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
+ if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len())
+ m_sDsn = pTypeCollection->cutPrefix(pUrlItem->GetValue());
+
+ // get the other relevant items
+ SFX_ITEMSET_GET(_rSet, pDeletedItem, SfxBoolItem, DSID_SHOWDELETEDROWS, sal_True);
+
+ if ( bValid )
+ {
+ m_aShowDeleted.Check( pDeletedItem->GetValue() );
+ m_aFT_Message.Show(m_aShowDeleted.IsChecked());
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool ODbaseDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+
+ fillBool(_rSet,&m_aShowDeleted,DSID_SHOWDELETEDROWS,bChangedSomething);
+ return bChangedSomething;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( ODbaseDetailsPage, OnButtonClicked, Button*, pButton )
+ {
+ if (&m_aIndexes == pButton)
+ {
+ ODbaseIndexDialog aIndexDialog(this, m_sDsn);
+ aIndexDialog.Execute();
+ }
+ else
+ {
+ m_aFT_Message.Show(m_aShowDeleted.IsChecked());
+ // it was one of the checkboxes -> we count as modified from now on
+ callModifiedHdl();
+ }
+
+ return 0;
+ }
+
+ //========================================================================
+ //= OAdoDetailsPage
+ //========================================================================
+ DBG_NAME(OAdoDetailsPage)
+ // -----------------------------------------------------------------------
+ OAdoDetailsPage::OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_ADO, _rCoreAttrs, CBTP_USE_CHARSET )
+ {
+ DBG_CTOR(OAdoDetailsPage,NULL);
+
+ }
+
+ // -----------------------------------------------------------------------
+ OAdoDetailsPage::~OAdoDetailsPage()
+ {
+
+ DBG_DTOR(OAdoDetailsPage,NULL);
+ }
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateAdo( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OAdoDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ //========================================================================
+ //= OOdbcDetailsPage
+ //========================================================================
+ OOdbcDetailsPage::OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_ODBC, _rCoreAttrs, CBTP_USE_CHARSET | CBTP_USE_OPTIONS,false)
+ ,m_aFL_1 (this, ModuleRes(FL_SEPARATOR1))
+ ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG))
+ {
+ m_aUseCatalog.SetToggleHdl(getControlModifiedLink());
+ FreeResource();
+
+ Window* pWindows[] = { m_pCharsetLabel, m_pCharset
+ ,m_pOptionsLabel,m_pOptions,&m_aUseCatalog
+ };
+
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=1; i < nCount; ++i)
+ pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateODBC( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OOdbcDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OOdbcDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+ fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething);
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ void OOdbcDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog));
+ }
+ // -----------------------------------------------------------------------
+ void OOdbcDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
+ }
+ // -----------------------------------------------------------------------
+ void OOdbcDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True);
+
+ if ( bValid )
+ m_aUseCatalog.Check(pUseCatalogItem->GetValue());
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+ //========================================================================
+ //= OOdbcDetailsPage
+ //========================================================================
+ OUserDriverDetailsPage::OUserDriverDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_USERDRIVER, _rCoreAttrs,
+ CBTP_USE_CHARSET | CBTP_USE_OPTIONS ,false)
+ ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME))
+ ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME))
+ ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER))
+ ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER))
+ ,m_aUseCatalog (this, ModuleRes(CB_USECATALOG))
+ {
+ m_aUseCatalog.SetToggleHdl(getControlModifiedLink());
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateUser( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OUserDriverDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OUserDriverDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+
+ fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_PORTNUMBER,bChangedSomething);
+ fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
+ fillBool(_rSet,&m_aUseCatalog,DSID_USECATALOG,bChangedSomething);
+
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ void OUserDriverDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aUseCatalog));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
+ }
+ // -----------------------------------------------------------------------
+ void OUserDriverDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
+ }
+ // -----------------------------------------------------------------------
+ void OUserDriverDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pUseCatalogItem, SfxBoolItem, DSID_USECATALOG, sal_True);
+ SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_PORTNUMBER, sal_True);
+
+ if ( bValid )
+ {
+ m_aEDHostname.SetText(pHostName->GetValue());
+ m_aEDHostname.ClearModifyFlag();
+
+ m_aNFPortNumber.SetValue(pPortNumber->GetValue());
+ m_aNFPortNumber.ClearModifyFlag();
+
+ m_aUseCatalog.Check(pUseCatalogItem->GetValue());
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+ //========================================================================
+ //= OMySQLODBCDetailsPage
+ //========================================================================
+ OMySQLODBCDetailsPage::OMySQLODBCDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_MYSQL_ODBC, _rCoreAttrs, CBTP_USE_CHARSET )
+ {
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateMySQLODBC( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OMySQLODBCDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ //========================================================================
+ //= OMySQLJDBCDetailsPage
+ //========================================================================
+ OGeneralSpecialJDBCDetailsPage::OGeneralSpecialJDBCDetailsPage( Window* pParent,sal_uInt16 _nResId, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId)
+ :OCommonBehaviourTabPage(pParent, _nResId, _rCoreAttrs, CBTP_USE_CHARSET ,false)
+ ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) )
+ ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME))
+ ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME))
+ ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER))
+ ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER))
+ ,m_aFTSocket (this, ModuleRes(FT_SOCKET))
+ ,m_aEDSocket (this, ModuleRes(ET_SOCKET))
+ ,m_aFTDriverClass (this, ModuleRes(FT_JDBCDRIVERCLASS))
+ ,m_aEDDriverClass (this, ModuleRes(ET_JDBCDRIVERCLASS))
+ ,m_aTestJavaDriver (this, ModuleRes(PB_TESTDRIVERCLASS))
+ ,m_nPortId(_nPortId)
+ ,m_bUseClass(true)
+ {
+ SFX_ITEMSET_GET(_rCoreAttrs, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ SFX_ITEMSET_GET(_rCoreAttrs, pTypesItem, DbuTypeCollectionItem, DSID_TYPECOLLECTION, sal_True);
+ ::dbaccess::ODsnTypeCollection* pTypeCollection = pTypesItem ? pTypesItem->getCollection() : NULL;
+ if (pTypeCollection && pUrlItem && pUrlItem->GetValue().Len() )
+ {
+ m_sDefaultJdbcDriverName = pTypeCollection->getJavaDriverClass(pUrlItem->GetValue());
+ }
+ if ( m_sDefaultJdbcDriverName.Len() )
+ {
+ m_aEDDriverClass.SetModifyHdl(getControlModifiedLink());
+ m_aEDDriverClass.SetModifyHdl(LINK(this, OGeneralSpecialJDBCDetailsPage, OnEditModified));
+ m_aTestJavaDriver.SetClickHdl(LINK(this,OGeneralSpecialJDBCDetailsPage,OnTestJavaClickHdl));
+ }
+ else
+ {
+ m_bUseClass = false;
+ m_aFTDriverClass.Show(sal_False);
+ m_aEDDriverClass.Show(sal_False);
+ m_aTestJavaDriver.Show(sal_False);
+ }
+
+ m_aFTSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass);
+ m_aEDSocket.Show(PAGE_MYSQL_JDBC == _nResId && !m_bUseClass);
+
+ m_aEDHostname.SetModifyHdl(getControlModifiedLink());
+ m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
+ m_aEDSocket.SetModifyHdl(getControlModifiedLink());
+
+ Window* pWindows[] = { &m_aFTHostname,&m_aEDHostname,
+ &m_aPortNumber,&m_aNFPortNumber,&m_aFTSocket,&m_aEDSocket,
+ &m_aFTDriverClass, &m_aEDDriverClass,&m_aTestJavaDriver,
+ m_pCharsetLabel, m_pCharset};
+
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=1; i < nCount; ++i)
+ pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
+
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ if ( m_bUseClass )
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDDriverClass));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDSocket));
+ }
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTSocket));
+ if ( m_bUseClass )
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDriverClass));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OGeneralSpecialJDBCDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+ if ( m_bUseClass )
+ fillString(_rSet,&m_aEDDriverClass,DSID_JDBCDRIVERCLASS,bChangedSomething);
+ fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
+ fillString(_rSet,&m_aEDSocket,DSID_CONN_SOCKET,bChangedSomething);
+ fillInt32(_rSet,&m_aNFPortNumber,m_nPortId,bChangedSomething );
+
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ void OGeneralSpecialJDBCDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pDrvItem, SfxStringItem, DSID_JDBCDRIVERCLASS, sal_True);
+ SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, m_nPortId, sal_True);
+ SFX_ITEMSET_GET(_rSet, pSocket, SfxStringItem, DSID_CONN_SOCKET, sal_True);
+
+ if ( bValid )
+ {
+ if ( m_bUseClass )
+ {
+ m_aEDDriverClass.SetText(pDrvItem->GetValue());
+ m_aEDDriverClass.ClearModifyFlag();
+ }
+
+ m_aEDHostname.SetText(pHostName->GetValue());
+ m_aEDHostname.ClearModifyFlag();
+
+ m_aNFPortNumber.SetValue(pPortNumber->GetValue());
+ m_aNFPortNumber.ClearModifyFlag();
+
+ m_aEDSocket.SetText(pSocket->GetValue());
+ m_aEDSocket.ClearModifyFlag();
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+
+ // to get the correcxt value when saveValue was called by base class
+ if ( m_bUseClass && !m_aEDDriverClass.GetText().Len() )
+ {
+ m_aEDDriverClass.SetText(m_sDefaultJdbcDriverName);
+ m_aEDDriverClass.SetModifyFlag();
+ }
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnTestJavaClickHdl, PushButton*, /*_pButton*/)
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ OSL_ENSURE(m_bUseClass,"Who called me?");
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if ( m_aEDDriverClass.GetText().Len() )
+ {
+// TODO chage jvmaccess
+ ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_pAdminDialog->getORB());
+ bSuccess = ::connectivity::existsJavaClassByName(xJVM,m_aEDDriverClass.GetText());
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+ sal_uInt16 nMessage = bSuccess ? STR_JDBCDRIVER_SUCCESS : STR_JDBCDRIVER_NO_SUCCESS;
+ OSQLMessageBox aMsg( this, String( ModuleRes( nMessage ) ), String() );
+ aMsg.Execute();
+ return 0L;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK(OGeneralSpecialJDBCDetailsPage, OnEditModified, Edit*, _pEdit)
+ {
+ if ( m_bUseClass && _pEdit == &m_aEDDriverClass )
+ m_aTestJavaDriver.Enable( m_aEDDriverClass.GetText().Len() != 0 );
+
+ // tell the listener we were modified
+ callModifiedHdl();
+ return 0L;
+ }
+
+ //========================================================================
+ //= MySQLNativePage
+ //========================================================================
+ MySQLNativePage::MySQLNativePage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_MYSQL_NATIVE, _rCoreAttrs, CBTP_USE_CHARSET, false )
+ ,m_aSeparator1 ( this, ModuleRes( FL_SEPARATOR1) )
+ ,m_aMySQLSettings ( *this, getControlModifiedLink() )
+ ,m_aSeparator2 ( this, ModuleRes(FL_SEPARATOR2))
+ ,m_aUserNameLabel ( this, ModuleRes(FT_USERNAME))
+ ,m_aUserName ( this, ModuleRes(ET_USERNAME))
+ ,m_aPasswordRequired ( this, ModuleRes(CB_PASSWORD_REQUIRED))
+ {
+ m_aUserName.SetModifyHdl(getControlModifiedLink());
+
+ Window* pWindows[] = { &m_aMySQLSettings, &m_aSeparator2, &m_aUserNameLabel, &m_aUserName,
+ &m_aPasswordRequired, m_pCharsetLabel, m_pCharset};
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=1; i < nCount; ++i)
+ pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
+
+ LayoutHelper::positionBelow( m_aSeparator1, m_aMySQLSettings, RelatedControls, 3 );
+ m_aMySQLSettings.Show();
+
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ void MySQLNativePage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls( _rControlList );
+ m_aMySQLSettings.fillControls( _rControlList );
+
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aUserName));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aPasswordRequired));
+ }
+ // -----------------------------------------------------------------------
+ void MySQLNativePage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows( _rControlList );
+ m_aMySQLSettings.fillWindows( _rControlList);
+
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator1));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aSeparator2));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aUserNameLabel));
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool MySQLNativePage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet( _rSet );
+
+ bChangedSomething |= m_aMySQLSettings.FillItemSet( _rSet );
+
+ if ( m_aUserName.GetText() != m_aUserName.GetSavedValue() )
+ {
+ _rSet.Put( SfxStringItem( DSID_USER, m_aUserName.GetText() ) );
+ _rSet.Put( SfxStringItem( DSID_PASSWORD, String()));
+ bChangedSomething = sal_True;
+ }
+ fillBool(_rSet,&m_aPasswordRequired,DSID_PASSWORDREQUIRED,bChangedSomething);
+
+ return bChangedSomething;
+ }
+ // -----------------------------------------------------------------------
+ void MySQLNativePage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ m_aMySQLSettings.implInitControls( _rSet );
+
+ SFX_ITEMSET_GET(_rSet, pUidItem, SfxStringItem, DSID_USER, sal_True);
+ SFX_ITEMSET_GET(_rSet, pAllowEmptyPwd, SfxBoolItem, DSID_PASSWORDREQUIRED, sal_True);
+
+ if ( bValid )
+ {
+ m_aUserName.SetText(pUidItem->GetValue());
+ m_aUserName.ClearModifyFlag();
+ m_aPasswordRequired.Check(pAllowEmptyPwd->GetValue());
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateMySQLJDBC( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_MYSQL_JDBC, _rAttrSet,DSID_MYSQL_PORTNUMBER ) );
+ }
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateMySQLNATIVE( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new MySQLNativePage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateOracleJDBC( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OGeneralSpecialJDBCDetailsPage( pParent,PAGE_ORACLE_JDBC, _rAttrSet,DSID_ORACLE_PORTNUMBER) );
+ }
+
+
+ //========================================================================
+ //= OAdabasDetailsPage
+ //========================================================================
+ OAdabasDetailsPage::OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_ADABAS, _rCoreAttrs, CBTP_USE_CHARSET ,false)
+ ,m_aFTHostname (this, ModuleRes(FT_HOSTNAME))
+ ,m_aEDHostname (this, ModuleRes(ET_HOSTNAME))
+ ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) )
+ ,m_FT_CACHE_SIZE( this, ModuleRes( FT_CACHE_SIZE ) )
+ ,m_NF_CACHE_SIZE( this, ModuleRes( NF_CACHE_SIZE ) )
+ ,m_FT_DATA_INCREMENT( this, ModuleRes( FT_DATA_INCREMENT ) )
+ ,m_NF_DATA_INCREMENT( this, ModuleRes( NF_DATA_INCREMENT ) )
+ ,m_aFL_2( this, ModuleRes( FL_SEPARATOR2 ) )
+ ,m_FT_CTRLUSERNAME( this, ModuleRes( FT_CTRLUSERNAME ) )
+ ,m_ET_CTRLUSERNAME( this, ModuleRes( ET_CTRLUSERNAME ) )
+ ,m_FT_CTRLPASSWORD( this, ModuleRes( FT_CTRLPASSWORD ) )
+ ,m_ET_CTRLPASSWORD( this, ModuleRes( ET_CTRLPASSWORD ) )
+ ,m_CB_SHUTDB( this, ModuleRes( CB_SHUTDB ) )
+ ,m_PB_STAT( this, ModuleRes( PB_STAT ) )
+ {
+ m_aEDHostname.SetModifyHdl(getControlModifiedLink());
+
+ FreeResource();
+
+ m_PB_STAT.SetClickHdl( LINK(this,OAdabasDetailsPage,PBClickHdl));
+
+ m_CB_SHUTDB.SetClickHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
+ m_NF_CACHE_SIZE.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
+ m_NF_DATA_INCREMENT.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
+ m_ET_CTRLUSERNAME.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
+ m_ET_CTRLPASSWORD.SetModifyHdl( LINK(this,OAdabasDetailsPage,AttributesChangedHdl));
+
+ m_ET_CTRLUSERNAME.SetLoseFocusHdl( LINK(this,OAdabasDetailsPage,LoseFocusHdl));
+ m_ET_CTRLPASSWORD.SetLoseFocusHdl( LINK(this,OAdabasDetailsPage,LoseFocusHdl));
+
+ m_NF_DATA_INCREMENT.SetMin(20);
+ m_NF_DATA_INCREMENT.SetMax(LONG_MAX);
+ m_NF_DATA_INCREMENT.SetValue(20);
+ m_NF_DATA_INCREMENT.SetDecimalDigits(0);
+
+ m_NF_CACHE_SIZE.SetMin(4);
+ m_NF_CACHE_SIZE.SetMax(LONG_MAX);
+ m_NF_CACHE_SIZE.SetValue(4);
+ m_NF_CACHE_SIZE.SetDecimalDigits(0);
+
+ Window* pWindows[] = { &m_aFTHostname,&m_aEDHostname
+ ,&m_FT_CACHE_SIZE,&m_NF_CACHE_SIZE
+ ,&m_FT_DATA_INCREMENT,&m_NF_DATA_INCREMENT
+ ,&m_FT_CTRLUSERNAME,&m_ET_CTRLUSERNAME
+ ,&m_FT_CTRLPASSWORD,&m_ET_CTRLPASSWORD
+ ,&m_CB_SHUTDB
+ ,m_pCharsetLabel, m_pCharset,&m_PB_STAT};
+
+ sal_Int32 nCount = SAL_N_ELEMENTS(pWindows);
+ for (sal_Int32 i=1; i < nCount; ++i)
+ pWindows[i]->SetZOrder(pWindows[i-1], WINDOW_ZORDER_BEHIND);
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateAdabas( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OAdabasDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ void OAdabasDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aEDHostname));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_CACHE_SIZE));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_NF_DATA_INCREMENT));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLUSERNAME));
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_ET_CTRLPASSWORD));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_CB_SHUTDB));
+ }
+ // -----------------------------------------------------------------------
+ void OAdabasDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTHostname));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CACHE_SIZE));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_DATA_INCREMENT));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_2));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLUSERNAME));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_FT_CTRLPASSWORD));
+ _rControlList.push_back(new ODisableWrapper<PushButton>(&m_PB_STAT));
+ }
+ // -----------------------------------------------------------------------
+ void OAdabasDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ SFX_ITEMSET_GET(_rSet, pHostName, SfxStringItem, DSID_CONN_HOSTNAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pCtrlUserItem, SfxStringItem, DSID_CONN_CTRLUSER, sal_True);
+ SFX_ITEMSET_GET(_rSet, pCtrlPwdItem, SfxStringItem, DSID_CONN_CTRLPWD, sal_True);
+ SFX_ITEMSET_GET(_rSet, pShutItem, SfxBoolItem, DSID_CONN_SHUTSERVICE, sal_True);
+ SFX_ITEMSET_GET(_rSet, pIncItem, SfxInt32Item, DSID_CONN_DATAINC, sal_True);
+ SFX_ITEMSET_GET(_rSet, pCacheItem, SfxInt32Item, DSID_CONN_CACHESIZE, sal_True);
+ if ( bValid )
+ {
+ m_aEDHostname.SetText(pHostName->GetValue());
+ m_aEDHostname.ClearModifyFlag();
+ m_CB_SHUTDB.Check( pShutItem->GetValue() );
+ m_NF_DATA_INCREMENT.SetValue( pIncItem->GetValue() );
+ m_NF_CACHE_SIZE.SetValue( pCacheItem->GetValue() );
+ m_ET_CTRLUSERNAME.SetText(pCtrlUserItem->GetValue());
+ m_ET_CTRLPASSWORD.SetText(pCtrlPwdItem->GetValue());
+ m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+ // -----------------------------------------------------------------------
+ sal_Bool OAdabasDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+
+ fillString(_rSet,&m_aEDHostname,DSID_CONN_HOSTNAME,bChangedSomething);
+ fillBool(_rSet,&m_CB_SHUTDB,DSID_CONN_SHUTSERVICE,bChangedSomething);
+ fillInt32(_rSet,&m_NF_DATA_INCREMENT,DSID_CONN_DATAINC,bChangedSomething );
+ fillInt32(_rSet,&m_NF_CACHE_SIZE,DSID_CONN_CACHESIZE,bChangedSomething );
+ fillString(_rSet,&m_ET_CTRLUSERNAME,DSID_CONN_CTRLUSER,bChangedSomething );
+ fillString(_rSet,&m_ET_CTRLPASSWORD,DSID_CONN_CTRLPWD,bChangedSomething );
+
+ return bChangedSomething;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OAdabasDetailsPage, AttributesChangedHdl, void *, EMPTYARG )
+ {
+ m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
+ bAttrsChanged = sal_True;
+ callModifiedHdl();
+ return 0;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OAdabasDetailsPage, LoseFocusHdl, Edit *, /*pEdit*/ )
+ {
+ m_CB_SHUTDB.Enable(m_ET_CTRLUSERNAME.GetText().Len() && m_ET_CTRLPASSWORD.GetText().Len());
+ return 0;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OAdabasDetailsPage, PBClickHdl, Button *, /*pButton*/ )
+ {
+ OSL_ENSURE(m_pAdminDialog,"No Admin dialog set! ->GPF");
+ if ( m_pAdminDialog )
+ {
+ m_pAdminDialog->saveDatasource();
+ try
+ {
+ Reference< XConnection > xConnection = m_pAdminDialog->createConnection().first;
+ if ( xConnection.is() )
+ {
+ OAdabasStatistics aDlg(this,m_sUser,xConnection,m_pAdminDialog->getORB());
+ aDlg.Execute();
+ ::comphelper::disposeComponent(xConnection);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+
+ return 0;
+ }
+
+
+ //========================================================================
+ //= OLDAPDetailsPage
+ //========================================================================
+ OLDAPDetailsPage::OLDAPDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_LDAP, _rCoreAttrs,0,false)
+ ,m_aFL_1 (this, ModuleRes( FL_SEPARATOR1) )
+ ,m_aBaseDN (this, ModuleRes(FT_BASEDN))
+ ,m_aETBaseDN (this, ModuleRes(ET_BASEDN))
+ ,m_aCBUseSSL (this, ModuleRes(CB_USESSL))
+ ,m_aPortNumber (this, ModuleRes(FT_PORTNUMBER))
+ ,m_aNFPortNumber (this, ModuleRes(NF_PORTNUMBER))
+ ,m_aFTRowCount (this, ModuleRes(FT_LDAPROWCOUNT))
+ ,m_aNFRowCount (this, ModuleRes(NF_LDAPROWCOUNT))
+ {
+ m_aETBaseDN.SetModifyHdl(getControlModifiedLink());
+ m_aCBUseSSL.SetToggleHdl(getControlModifiedLink());
+ m_aNFPortNumber.SetModifyHdl(getControlModifiedLink());
+ m_aNFRowCount.SetModifyHdl(getControlModifiedLink());
+
+ m_aNFRowCount.SetUseThousandSep(sal_False);
+ m_iNormalPort = 389;
+ m_iSSLPort = 636;
+ m_aCBUseSSL.SetClickHdl(LINK(this, OLDAPDetailsPage,OnCheckBoxClick));
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateLDAP( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OLDAPDetailsPage( pParent, _rAttrSet ) );
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OLDAPDetailsPage::FillItemSet( SfxItemSet& _rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(_rSet);
+
+ fillString(_rSet,&m_aETBaseDN,DSID_CONN_LDAP_BASEDN,bChangedSomething);
+ fillInt32(_rSet,&m_aNFPortNumber,DSID_CONN_LDAP_PORTNUMBER,bChangedSomething);
+ fillInt32(_rSet,&m_aNFRowCount,DSID_CONN_LDAP_ROWCOUNT,bChangedSomething);
+ fillBool(_rSet,&m_aCBUseSSL,DSID_CONN_LDAP_USESSL,bChangedSomething);
+ return bChangedSomething;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OLDAPDetailsPage, OnCheckBoxClick, CheckBox*, pCheckBox )
+ {
+ callModifiedHdl();
+ if ( pCheckBox == &m_aCBUseSSL)
+ {
+ if ( m_aCBUseSSL.IsChecked() )
+ {
+ m_iNormalPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue());
+ m_aNFPortNumber.SetValue(m_iSSLPort);
+ }
+ else
+ {
+ m_iSSLPort = static_cast<sal_Int32>(m_aNFPortNumber.GetValue());
+ m_aNFPortNumber.SetValue(m_iNormalPort);
+ }
+ }
+ return 0;
+ }
+
+ // -----------------------------------------------------------------------
+ void OLDAPDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ _rControlList.push_back(new OSaveValueWrapper<Edit>(&m_aETBaseDN));
+ _rControlList.push_back(new OSaveValueWrapper<CheckBox>(&m_aCBUseSSL));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFPortNumber));
+ _rControlList.push_back(new OSaveValueWrapper<NumericField>(&m_aNFRowCount));
+ }
+ // -----------------------------------------------------------------------
+ void OLDAPDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aBaseDN));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aPortNumber));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTRowCount));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aFL_1));
+ }
+ // -----------------------------------------------------------------------
+ void OLDAPDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+
+ SFX_ITEMSET_GET(_rSet, pBaseDN, SfxStringItem, DSID_CONN_LDAP_BASEDN, sal_True);
+ SFX_ITEMSET_GET(_rSet, pUseSSL, SfxBoolItem, DSID_CONN_LDAP_USESSL, sal_True);
+ SFX_ITEMSET_GET(_rSet, pPortNumber, SfxInt32Item, DSID_CONN_LDAP_PORTNUMBER, sal_True);
+ SFX_ITEMSET_GET(_rSet, pRowCount, SfxInt32Item, DSID_CONN_LDAP_ROWCOUNT, sal_True);
+
+ if ( bValid )
+ {
+ m_aETBaseDN.SetText(pBaseDN->GetValue());
+ m_aNFPortNumber.SetValue(pPortNumber->GetValue());
+ m_aNFRowCount.SetValue(pRowCount->GetValue());
+ m_aCBUseSSL.Check(pUseSSL->GetValue());
+ }
+
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+
+ //========================================================================
+ //= OTextDetailsPage
+ //========================================================================
+ DBG_NAME(OTextDetailsPage)
+ //------------------------------------------------------------------------
+ OTextDetailsPage::OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs )
+ :OCommonBehaviourTabPage(pParent, PAGE_TEXT, _rCoreAttrs, 0, false )
+ {
+ DBG_CTOR(OTextDetailsPage,NULL);
+
+ m_pTextConnectionHelper = new OTextConnectionHelper( this, TC_EXTENSION | TC_HEADER | TC_SEPARATORS | TC_CHARSET );
+ FreeResource();
+ }
+
+ // -----------------------------------------------------------------------
+ OTextDetailsPage::~OTextDetailsPage()
+ {
+ DELETEZ(m_pTextConnectionHelper);
+
+ DBG_DTOR(OTextDetailsPage,NULL);
+ }
+
+ // -----------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateText( Window* pParent, const SfxItemSet& _rAttrSet )
+ {
+ return ( new OTextDetailsPage( pParent, _rAttrSet ) );
+ }
+ // -----------------------------------------------------------------------
+ void OTextDetailsPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillControls(_rControlList);
+ m_pTextConnectionHelper->fillControls(_rControlList);
+
+ }
+ // -----------------------------------------------------------------------
+ void OTextDetailsPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ OCommonBehaviourTabPage::fillWindows(_rControlList);
+ m_pTextConnectionHelper->fillWindows(_rControlList);
+
+ }
+ // -----------------------------------------------------------------------
+ void OTextDetailsPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ m_pTextConnectionHelper->implInitControls(_rSet, bValid);
+ OCommonBehaviourTabPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OTextDetailsPage::FillItemSet( SfxItemSet& rSet )
+ {
+ sal_Bool bChangedSomething = OCommonBehaviourTabPage::FillItemSet(rSet);
+ bChangedSomething = m_pTextConnectionHelper->FillItemSet(rSet, bChangedSomething);
+ return bChangedSomething;
+ }
+
+ // -----------------------------------------------------------------------
+ sal_Bool OTextDetailsPage::prepareLeave()
+ {
+ return m_pTextConnectionHelper->prepareLeave();
+ }
+
+ //------------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateGeneratedValuesPage( Window* _pParent, const SfxItemSet& _rAttrSet )
+ {
+ return new GeneratedValuesPage( _pParent, _rAttrSet );
+ }
+
+ //------------------------------------------------------------------------
+ SfxTabPage* ODriversSettings::CreateSpecialSettingsPage( Window* _pParent, const SfxItemSet& _rAttrSet )
+ {
+ ::rtl::OUString eType = ODbDataSourceAdministrationHelper::getDatasourceType( _rAttrSet );
+ DataSourceMetaData aMetaData( eType );
+ return new SpecialSettingsPage( _pParent, _rAttrSet, aMetaData );
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/detailpages.hxx b/dbaccess/source/ui/dlg/detailpages.hxx
new file mode 100644
index 000000000000..6d48d2fd2711
--- /dev/null
+++ b/dbaccess/source/ui/dlg/detailpages.hxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DETAILPAGES_HXX_
+#define _DBAUI_DETAILPAGES_HXX_
+
+#include "adminpages.hxx"
+#include "charsets.hxx"
+#include "charsetlistbox.hxx"
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+#include "TextConnectionHelper.hxx"
+#include "admincontrols.hxx"
+
+#include <svtools/dialogcontrolling.hxx>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ //=========================================================================
+ //= OCommonBehaviourTabPage
+ //=========================================================================
+ #define CBTP_NONE 0x00000000
+ #define CBTP_USE_CHARSET 0x00000002
+ #define CBTP_USE_OPTIONS 0x00000004
+
+ /** eases the implementation of tab pages handling user/password and/or character
+ set and/or generic options input
+ <BR>
+ The controls to be used habe to be defined within the resource, as usual, but
+ this class does all the handling necessary.
+ */
+ class OCommonBehaviourTabPage : public OGenericAdministrationPage
+ {
+ protected:
+
+ FixedText* m_pOptionsLabel;
+ Edit* m_pOptions;
+
+ FixedLine* m_pDataConvertFixedLine;
+ FixedText* m_pCharsetLabel;
+ CharSetListBox* m_pCharset;
+
+ FixedLine* m_pAutoFixedLine;
+ CheckBox* m_pAutoRetrievingEnabled;
+ FixedText* m_pAutoIncrementLabel;
+ Edit* m_pAutoIncrement;
+ FixedText* m_pAutoRetrievingLabel;
+ Edit* m_pAutoRetrieving;
+
+ sal_uInt32 m_nControlFlags;
+
+ public:
+ virtual sal_Bool FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ OCommonBehaviourTabPage(Window* pParent, sal_uInt16 nResId, const SfxItemSet& _rCoreAttrs, sal_uInt32 nControlFlags,bool _bFreeResource = true);
+ protected:
+
+ // nControlFlags ist eine Kombination der CBTP_xxx-Konstanten
+ virtual ~OCommonBehaviourTabPage();
+
+ // must be overloaded by subclasses, but it isn't pure virtual
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ };
+
+ //========================================================================
+ //= ODbaseDetailsPage
+ //========================================================================
+ class ODbaseDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ ODbaseDetailsPage(Window* pParent, const SfxItemSet& _rCoreAttrs);
+ private:
+ // please add new controls also to <method>fillControls</method> or <method>fillWindows</method>
+ CheckBox m_aShowDeleted;
+ FixedLine m_aFL_1;
+ FixedText m_aFT_Message;
+ PushButton m_aIndexes;
+
+ String m_sDsn;
+
+ protected:
+
+ virtual ~ODbaseDetailsPage();
+
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ DECL_LINK( OnButtonClicked, Button * );
+ };
+
+ //========================================================================
+ //= OAdoDetailsPage
+ //========================================================================
+ class OAdoDetailsPage : public OCommonBehaviourTabPage
+ {
+ protected:
+ virtual ~OAdoDetailsPage();
+ public:
+
+ OAdoDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ };
+
+ //========================================================================
+ //= OOdbcDetailsPage
+ //========================================================================
+ class OOdbcDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ OOdbcDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ private:
+ FixedLine m_aFL_1;
+ CheckBox m_aUseCatalog;
+ };
+
+
+ //========================================================================
+ //= OUserDriverDetailsPage
+ //========================================================================
+ class OUserDriverDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ OUserDriverDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ private:
+ FixedText m_aFTHostname;
+ Edit m_aEDHostname;
+ FixedText m_aPortNumber;
+ NumericField m_aNFPortNumber;
+ CheckBox m_aUseCatalog;
+ };
+
+ //========================================================================
+ //= OMySQLODBCDetailsPage
+ //========================================================================
+ class OMySQLODBCDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ OMySQLODBCDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ };
+
+ //========================================================================
+ //= OGeneralSpecialJDBCDetailsPage
+ //========================================================================
+ class OGeneralSpecialJDBCDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ OGeneralSpecialJDBCDetailsPage( Window* pParent
+ , sal_uInt16 _nResId
+ , const SfxItemSet& _rCoreAttrs
+ , sal_uInt16 _nPortId
+ );
+
+ protected:
+
+
+ virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ DECL_LINK(OnTestJavaClickHdl,PushButton*);
+ DECL_LINK(OnEditModified,Edit*);
+
+ FixedLine m_aFL_1;
+ FixedText m_aFTHostname;
+ Edit m_aEDHostname;
+ FixedText m_aPortNumber;
+ NumericField m_aNFPortNumber;
+ FixedText m_aFTSocket;
+ Edit m_aEDSocket;
+
+ FixedText m_aFTDriverClass;
+ Edit m_aEDDriverClass;
+ PushButton m_aTestJavaDriver;
+
+ String m_sDefaultJdbcDriverName;
+ sal_uInt16 m_nPortId;
+ bool m_bUseClass;
+ };
+
+ //========================================================================
+ //= MySQLNativePage
+ //========================================================================
+ class MySQLNativePage : public OCommonBehaviourTabPage
+ {
+ public:
+ MySQLNativePage( Window* pParent,
+ const SfxItemSet& _rCoreAttrs );
+
+ private:
+ FixedLine m_aSeparator1;
+ MySQLNativeSettings m_aMySQLSettings;
+
+ FixedLine m_aSeparator2;
+ FixedText m_aUserNameLabel;
+ Edit m_aUserName;
+ CheckBox m_aPasswordRequired;
+
+ protected:
+ virtual sal_Bool FillItemSet( SfxItemSet& _rCoreAttrs );
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ };
+
+ //========================================================================
+ //= OAdabasDetailsPage
+ //========================================================================
+ class OAdabasDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet (SfxItemSet& _rCoreAttrs);
+
+ OAdabasDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ FixedText m_aFTHostname;
+ Edit m_aEDHostname;
+ FixedLine m_aFL_1;
+ FixedText m_FT_CACHE_SIZE;
+ NumericField m_NF_CACHE_SIZE;
+
+ FixedText m_FT_DATA_INCREMENT;
+ NumericField m_NF_DATA_INCREMENT;
+
+ FixedLine m_aFL_2;
+ FixedText m_FT_CTRLUSERNAME;
+ Edit m_ET_CTRLUSERNAME;
+ FixedText m_FT_CTRLPASSWORD;
+ Edit m_ET_CTRLPASSWORD;
+
+ CheckBox m_CB_SHUTDB;
+ PushButton m_PB_STAT;
+ String m_sUser;
+ sal_Bool bAttrsChanged;
+
+ DECL_LINK( AttributesChangedHdl, void * );
+ DECL_LINK( UserSettingsHdl, void * );
+ DECL_LINK( LoseFocusHdl, Edit * );
+ DECL_LINK( PBClickHdl, Button *);
+ };
+
+ //========================================================================
+ //= OOdbcDetailsPage
+ //========================================================================
+ class OLDAPDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ OLDAPDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ protected:
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+ private:
+ FixedLine m_aFL_1;
+ FixedText m_aBaseDN;
+ Edit m_aETBaseDN;
+ CheckBox m_aCBUseSSL;
+ FixedText m_aPortNumber;
+ NumericField m_aNFPortNumber;
+ FixedText m_aFTRowCount;
+ NumericField m_aNFRowCount;
+
+ sal_Int32 m_iSSLPort;
+ sal_Int32 m_iNormalPort;
+ DECL_LINK( OnCheckBoxClick, CheckBox * );
+ };
+
+ //========================================================================
+ //= OMozillaDetailsPage Detail page for Mozilla and Thunderbird addressbook
+ //========================================================================
+ class OMozillaDetailsPage : public OCommonBehaviourTabPage
+ {
+ protected:
+ virtual ~OMozillaDetailsPage();
+ public:
+
+ OMozillaDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ };
+
+ //========================================================================
+ //= OTextDetailsPage
+ //========================================================================
+ class OTextDetailsPage : public OCommonBehaviourTabPage
+ {
+ public:
+ virtual sal_Bool FillItemSet ( SfxItemSet& _rCoreAttrs );
+
+ OTextDetailsPage( Window* pParent, const SfxItemSet& _rCoreAttrs );
+ OTextConnectionHelper* m_pTextConnectionHelper;
+
+ private:
+
+ String m_aFieldSeparatorList;
+ String m_aTextSeparatorList;
+ String m_aTextNone;
+ protected:
+ virtual ~OTextDetailsPage();
+ virtual sal_Bool prepareLeave();
+
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ private:
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DETAILPAGES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
new file mode 100644
index 000000000000..0e4a61414de8
--- /dev/null
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -0,0 +1,351 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "directsql.hxx"
+#include "directsql.hrc"
+#include "dbu_dlg.hrc"
+#include <vcl/msgbox.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+
+ //====================================================================
+ //= LargeEntryListBox
+ //====================================================================
+ class LargeEntryListBox : public ListBox
+ {
+ public:
+ LargeEntryListBox( Window* _pParent, const ResId& _rId );
+
+ protected:
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+ };
+
+ //--------------------------------------------------------------------
+ LargeEntryListBox::LargeEntryListBox( Window* _pParent, const ResId& _rId )
+ :ListBox(_pParent, _rId )
+ {
+ EnableUserDraw(sal_True);
+ }
+
+ //--------------------------------------------------------------------
+ void LargeEntryListBox::UserDraw( const UserDrawEvent& _rUDEvt )
+ {
+ if (LISTBOX_ENTRY_NOTFOUND == _rUDEvt.GetItemId())
+ ListBox::UserDraw( _rUDEvt );
+ else
+ _rUDEvt.GetDevice()->DrawText( _rUDEvt.GetRect(), GetEntry( _rUDEvt.GetItemId() ), TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS);
+ }
+
+ //====================================================================
+ //= DirectSQLDialog
+ //====================================================================
+DBG_NAME(DirectSQLDialog)
+//--------------------------------------------------------------------
+ DirectSQLDialog::DirectSQLDialog( Window* _pParent, const Reference< XConnection >& _rxConn )
+ :ModalDialog(_pParent, ModuleRes(DLG_DIRECTSQL))
+ ,m_aFrame (this, ModuleRes(FL_SQL))
+ ,m_aSQLLabel (this, ModuleRes(FT_SQL))
+ ,m_aSQL (this, ModuleRes(ME_SQL))
+ ,m_aExecute (this, ModuleRes(PB_EXECUTE))
+ ,m_aHistoryLabel (this, ModuleRes(FT_HISTORY))
+ ,m_pSQLHistory(new LargeEntryListBox(this, ModuleRes(LB_HISTORY)))
+ ,m_aStatusFrame (this, ModuleRes(FL_STATUS))
+ ,m_aStatus (this, ModuleRes(ME_STATUS))
+ ,m_aButtonSeparator (this, ModuleRes(FL_BUTTONS))
+ ,m_aHelp (this, ModuleRes(PB_HELP))
+ ,m_aClose (this, ModuleRes(PB_CLOSE))
+ ,m_nHistoryLimit(20)
+ ,m_nStatusCount(1)
+ ,m_xConnection(_rxConn)
+ {
+ DBG_CTOR(DirectSQLDialog,NULL);
+
+ FreeResource();
+
+ m_aSQL.GrabFocus();
+
+ m_aExecute.SetClickHdl(LINK(this, DirectSQLDialog, OnExecute));
+ m_aClose.SetClickHdl(LINK(this, DirectSQLDialog, OnClose));
+ m_pSQLHistory->SetSelectHdl(LINK(this, DirectSQLDialog, OnListEntrySelected));
+ m_pSQLHistory->SetDropDownLineCount(10);
+
+ // add a dispose listener to the connection
+ Reference< XComponent > xConnComp(m_xConnection, UNO_QUERY);
+ OSL_ENSURE(xConnComp.is(), "DirectSQLDialog::DirectSQLDialog: invalid connection!");
+ if (xConnComp.is())
+ startComponentListening(xConnComp);
+
+ m_aSQL.SetModifyHdl(LINK(this, DirectSQLDialog, OnStatementModified));
+ OnStatementModified(&m_aSQL);
+ }
+
+ //--------------------------------------------------------------------
+ DirectSQLDialog::~DirectSQLDialog()
+ {
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ stopAllComponentListening();
+ }
+ delete m_pSQLHistory;
+
+ DBG_DTOR(DirectSQLDialog,NULL);
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::_disposing( const EventObject& _rSource )
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OSL_ENSURE(Reference< XConnection >(_rSource.Source, UNO_QUERY).get() == m_xConnection.get(),
+ "DirectSQLDialog::_disposing: where does this come from?");
+ (void)_rSource;
+
+ {
+ String sMessage(ModuleRes(STR_DIRECTSQL_CONNECTIONLOST));
+ ErrorBox aError(this, WB_OK, sMessage);
+ aError.Execute();
+ }
+
+ PostUserEvent(LINK(this, DirectSQLDialog, OnClose));
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 DirectSQLDialog::getHistorySize() const
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::getHistorySize");
+ return m_aStatementHistory.size();
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::implEnsureHistoryLimit()
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::implEnsureHistoryLimit");
+
+ if (getHistorySize() <= m_nHistoryLimit)
+ // nothing to do
+ return;
+
+ sal_Int32 nRemoveEntries = getHistorySize() - m_nHistoryLimit;
+ while (nRemoveEntries--)
+ {
+ m_aStatementHistory.pop_front();
+ m_aNormalizedHistory.pop_front();
+ m_pSQLHistory->RemoveEntry((sal_uInt16)0);
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::implAddToStatementHistory(const String& _rStatement)
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::implAddToStatementHistory");
+
+ // add the statement to the history
+ m_aStatementHistory.push_back(_rStatement);
+
+ // normalize the statement, and remember the normalized form, too
+ String sNormalized(_rStatement);
+ sNormalized.SearchAndReplaceAll((sal_Unicode)'\n', ' ');
+ m_aNormalizedHistory.push_back(sNormalized);
+
+ // add the normalized version to the list box
+ m_pSQLHistory->InsertEntry(sNormalized);
+
+ // ensure that we don't exceed the history limit
+ implEnsureHistoryLimit();
+ }
+
+#ifdef DBG_UTIL
+ //--------------------------------------------------------------------
+ const sal_Char* DirectSQLDialog::impl_CheckInvariants() const
+ {
+ if (m_aStatementHistory.size() != m_aNormalizedHistory.size())
+ return "statement history is inconsistent!";
+
+ if (!m_pSQLHistory)
+ return "invalid listbox!";
+
+ if (m_aStatementHistory.size() != m_pSQLHistory->GetEntryCount())
+ return "invalid listbox entry count!";
+
+ if (!m_xConnection.is())
+ return "have no connection!";
+
+ return NULL;
+ }
+#endif
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::implExecuteStatement(const String& _rStatement)
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::implExecuteStatement");
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ String sStatus;
+ try
+ {
+ // create a statement
+ Reference< XStatement > xStatement = m_xConnection->createStatement();
+ OSL_ENSURE(xStatement.is(), "DirectSQLDialog::implExecuteStatement: no statement returned by the connection!");
+
+ // execute it
+ if (xStatement.is())
+ xStatement->execute(_rStatement);
+
+ // successfull
+ sStatus = String(ModuleRes(STR_COMMAND_EXECUTED_SUCCESSFULLY));
+
+ // dispose the statement
+ ::comphelper::disposeComponent(xStatement);
+ }
+ catch(const SQLException& e)
+ {
+ sStatus = e.Message;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // add the status text
+ addStatusText(sStatus);
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::addStatusText(const String& _rMessage)
+ {
+ String sAppendMessage = String::CreateFromInt32(m_nStatusCount++);
+ sAppendMessage += String::CreateFromAscii(": ");
+ sAppendMessage += _rMessage;
+ sAppendMessage += String::CreateFromAscii("\n\n");
+
+ String sCompleteMessage = m_aStatus.GetText();
+ sCompleteMessage += sAppendMessage;
+ m_aStatus.SetText(sCompleteMessage);
+
+ m_aStatus.SetSelection(Selection(sCompleteMessage.Len(), sCompleteMessage.Len()));
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::executeCurrent()
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::executeCurrent");
+
+ String sStatement = m_aSQL.GetText();
+
+ // execute
+ implExecuteStatement(sStatement);
+
+ // add the statement to the history
+ implAddToStatementHistory(sStatement);
+
+ m_aSQL.SetSelection(Selection());
+ m_aSQL.GrabFocus();
+ }
+
+ //--------------------------------------------------------------------
+ void DirectSQLDialog::switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox)
+ {
+ CHECK_INVARIANTS("DirectSQLDialog::switchToHistory");
+
+ if ((_nHistoryPos >= 0) && (_nHistoryPos < getHistorySize()))
+ {
+ // set the text in the statement editor
+ String sStatement = m_aStatementHistory[_nHistoryPos];
+ m_aSQL.SetText(sStatement);
+ OnStatementModified(&m_aSQL);
+
+ if (_bUpdateListBox)
+ {
+ // selecte the normalized statement in the list box
+ m_pSQLHistory->SelectEntryPos((sal_uInt16)_nHistoryPos);
+ OSL_ENSURE(m_pSQLHistory->GetSelectEntry() == m_aNormalizedHistory[_nHistoryPos],
+ "DirectSQLDialog::switchToHistory: inconsistent listbox entries!");
+ }
+
+ m_aSQL.GrabFocus();
+ m_aSQL.SetSelection(Selection(sStatement.Len(), sStatement.Len()));
+ }
+ else
+ OSL_FAIL("DirectSQLDialog::switchToHistory: invalid position!");
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DirectSQLDialog, OnStatementModified, void*, /*NOTINTERESTEDIN*/ )
+ {
+ m_aExecute.Enable(0 != m_aSQL.GetText().Len());
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DirectSQLDialog, OnClose, void*, /*NOTINTERESTEDIN*/ )
+ {
+ EndDialog( RET_OK );
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DirectSQLDialog, OnExecute, void*, /*NOTINTERESTEDIN*/ )
+ {
+ executeCurrent();
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DirectSQLDialog, OnListEntrySelected, void*, /*NOTINTERESTEDIN*/ )
+ {
+ if (!m_pSQLHistory->IsTravelSelect())
+ {
+ const sal_uInt16 nSelected = m_pSQLHistory->GetSelectEntryPos();
+ if (LISTBOX_ENTRY_NOTFOUND != nSelected)
+ switchToHistory(nSelected, sal_False);
+ }
+ return 0L;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/directsql.hrc b/dbaccess/source/ui/dlg/directsql.hrc
new file mode 100644
index 000000000000..23f19a350ab4
--- /dev/null
+++ b/dbaccess/source/ui/dlg/directsql.hrc
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBACCESS_UI_DIRECTSQL_HRC_
+#define _DBACCESS_UI_DIRECTSQL_HRC_
+
+#define FL_SQL 1
+#define FT_SQL 2
+#define ME_SQL 3
+#define PB_EXECUTE 4
+#define FT_HISTORY 5
+#define LB_HISTORY 6
+#define FL_STATUS 7
+#define ME_STATUS 8
+#define FL_BUTTONS 9
+#define PB_HELP 10
+#define PB_CLOSE 11
+
+#endif // _DBACCESS_UI_DIRECTSQL_HRC_
diff --git a/dbaccess/source/ui/dlg/directsql.src b/dbaccess/source/ui/dlg/directsql.src
new file mode 100644
index 000000000000..5428535c365a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/directsql.src
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBACCESS_UI_DIRECTSQL_HRC_
+#include "directsql.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+#define WINDOW_SIZE_X 200
+#define WINDOW_SIZE_Y 210 + BUTTON_SIZE_Y + BUTTON_SIZE_Y
+
+ModalDialog DLG_DIRECTSQL
+{
+ HelpID = "dbaccess:ModalDialog:DLG_DIRECTSQL";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedLine FL_SQL
+ {
+ Pos = MAP_APPFONT( 4, 3 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
+ Text [ en-US ] = "SQL command";
+ };
+ FixedText FT_SQL
+ {
+ Pos = MAP_APPFONT( 7, 15 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 8 );
+ Text [ en-US ] = "Command to execute";
+ };
+ MultiLineEdit ME_SQL
+ {
+ HelpID = "dbaccess:MultiLineEdit:DLG_DIRECTSQL:ME_SQL";
+ Pos = MAP_APPFONT( 7, 26 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 80 );
+ SVLook = TRUE;
+ Border = TRUE;
+ TabStop = TRUE;
+ IgnoreTab = TRUE;
+ };
+ PushButton PB_EXECUTE
+ {
+ HelpID = "dbaccess:PushButton:DLG_DIRECTSQL:PB_EXECUTE";
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - BUTTON_SIZE_X - 7, 109 );
+ Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ Text [ en-US ] = "Execute";
+ DefButton = TRUE;
+ };
+ FixedText FT_HISTORY
+ {
+ Pos = MAP_APPFONT( 7, 110 + BUTTON_SIZE_Y + 3 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 8 );
+ Text [ en-US ] = "Previous commands";
+ };
+ ListBox LB_HISTORY
+ {
+ HelpID = "dbaccess:ListBox:DLG_DIRECTSQL:LB_HISTORY";
+ Pos = MAP_APPFONT( 7, 121 + BUTTON_SIZE_Y + 3 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 14 );
+ SvLook = TRUE;
+ DropDown = TRUE;
+ Border = TRUE;
+ };
+ FixedLine FL_STATUS
+ {
+ Pos = MAP_APPFONT( 4, 138 + BUTTON_SIZE_Y + 4 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
+ Text [ en-US ] = "Status";
+ };
+ MultiLineEdit ME_STATUS
+ {
+ HelpID = "dbaccess:MultiLineEdit:DLG_DIRECTSQL:ME_STATUS";
+ Pos = MAP_APPFONT( 7, 153 + BUTTON_SIZE_Y );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 14, 41 );
+ Border = TRUE;
+ ReadOnly = TRUE;
+ VScroll = TRUE;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT( 4, 193 + BUTTON_SIZE_Y + 4 );
+ Size = MAP_APPFONT( WINDOW_SIZE_X - 8, 8 );
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X - 3 - BUTTON_SIZE_X, 207 + BUTTON_SIZE_Y );
+ Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ };
+ PushButton PB_CLOSE
+ {
+ HelpID = "dbaccess:PushButton:DLG_DIRECTSQL:PB_CLOSE";
+ Pos = MAP_APPFONT( WINDOW_SIZE_X - 7 - BUTTON_SIZE_X, 207 + BUTTON_SIZE_Y );
+ Size = MAP_APPFONT( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ Text [ en-US ] = "Close";
+ };
+
+ Text [ en-US ] = "Execute SQL Statement" ;
+};
+
+String STR_COMMAND_EXECUTED_SUCCESSFULLY
+{
+ Text [ en-US ] = "Command successfully executed." ;
+};
+
+String STR_DIRECTSQL_CONNECTIONLOST
+{
+ Text [ en-US ] = "The connection to the database has been lost. This dialog will be closed.";
+};
diff --git a/dbaccess/source/ui/dlg/dlgattr.cxx b/dbaccess/source/ui/dlg/dlgattr.cxx
new file mode 100644
index 000000000000..e77c20704d26
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgattr.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dlgattr.hxx"
+
+#include <sfx2/tabdlg.hxx>
+
+#include <svx/numinf.hxx>
+
+#include <svx/numinf.hxx>
+
+#include <svx/dialogs.hrc>
+#include "dbu_dlg.hrc"
+#include <svl/itemset.hxx>
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/zforlist.hxx>
+#include <svx/svxids.hrc>
+#include <svx/flagsdef.hxx>
+#include <svl/intitem.hxx>
+#include "moduledbu.hxx"
+using namespace dbaui;
+
+DBG_NAME(SbaSbAttrDlg)
+//==================================================================
+SbaSbAttrDlg::SbaSbAttrDlg(Window* pParent, const SfxItemSet* pCellAttrs, SvNumberFormatter* pFormatter, sal_uInt16 nFlags, sal_Bool bRow)
+ : SfxTabDialog(pParent, ModuleRes( DLG_ATTR ), pCellAttrs )
+ ,aTitle(ModuleRes(ST_ROW))
+{
+ DBG_CTOR(SbaSbAttrDlg,NULL);
+
+ pNumberInfoItem = new SvxNumberInfoItem( pFormatter, 0 );
+
+ if (bRow)
+ SetText(aTitle);
+ if( nFlags & TP_ATTR_CHAR )
+ {
+ OSL_FAIL( "found flag TP_ATTR_CHAR" );
+ }
+ if( nFlags & TP_ATTR_NUMBER )
+ AddTabPage( RID_SVXPAGE_NUMBERFORMAT,String(ModuleRes(TP_ATTR_NUMBER)) );
+ if( nFlags & TP_ATTR_ALIGN )
+ AddTabPage( RID_SVXPAGE_ALIGNMENT,String(ModuleRes(TP_ATTR_ALIGN)) );
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+SbaSbAttrDlg::~SbaSbAttrDlg()
+{
+ delete pNumberInfoItem;
+
+ DBG_DTOR(SbaSbAttrDlg,NULL);
+}
+
+// -----------------------------------------------------------------------
+void SbaSbAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
+{
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch ( nPageId )
+ {
+ case RID_SVXPAGE_NUMBERFORMAT:
+ {
+ aSet.Put (SvxNumberInfoItem( pNumberInfoItem->GetNumberFormatter(), (const sal_uInt16)SID_ATTR_NUMBERFORMAT_INFO));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ case RID_SVXPAGE_CHAR_STD:
+ {
+ }
+ break;
+
+ case RID_SVXPAGE_ALIGNMENT:
+ {
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dlgattr.src b/dbaccess/source/ui/dlg/dlgattr.src
new file mode 100644
index 000000000000..4ed8c1c5644a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgattr.src
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBAUI_SBATTRDLG_HRC
+#include "dlgattr.hrc"
+#endif
+
+ //================================================
+ // Der Attributdialog:
+TabDialog DLG_ATTR
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Field Format" ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ };
+ OKButton 1
+ {
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE;
+ };
+ CancelButton 1
+ {
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton 1
+ {
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton 1
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Text [ en-US ] = "Bac~k" ;
+ };
+ String TP_ATTR_CHAR
+ {
+ Text [ en-US ] = "Font" ;
+ };
+ String TP_ATTR_NUMBER
+ {
+ Text [ en-US ] = "Format" ;
+ };
+ String TP_ATTR_ALIGN
+ {
+ Text [ en-US ] = "Alignment" ;
+ };
+ String ST_ROW
+ {
+ Text [ en-US ] = "Table Format" ;
+ };
+};
diff --git a/dbaccess/source/ui/dlg/dlgsave.cxx b/dbaccess/source/ui/dlg/dlgsave.cxx
new file mode 100644
index 000000000000..7d5738d1e7ff
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsave.cxx
@@ -0,0 +1,448 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dlgsave.hxx"
+#include "dlgsave.hrc"
+#include <vcl/msgbox.hxx>
+#include "dbu_dlg.hrc"
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include "sqlmessage.hxx"
+#include <connectivity/dbtools.hxx>
+#include "UITools.hxx"
+#include "dbaccess_helpid.hrc"
+#include "SqlNameEdit.hxx"
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "moduledbu.hxx"
+#include "objectnamecheck.hxx"
+#include <tools/diagnose_ex.h>
+
+
+using namespace dbaui;
+using namespace dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+namespace dbaui
+{
+class OSaveAsDlgImpl
+{
+public:
+ FixedText m_aDescription;
+ FixedText m_aCatalogLbl;
+ OSQLNameComboBox m_aCatalog;
+ FixedText m_aSchemaLbl;
+ OSQLNameComboBox m_aSchema;
+ FixedText m_aLabel;
+ OSQLNameEdit m_aTitle;
+ OKButton m_aPB_OK;
+ CancelButton m_aPB_CANCEL;
+ HelpButton m_aPB_HELP;
+ String m_aQryLabel;
+ String m_sTblLabel;
+ rtl::OUString m_sCatalog;
+ rtl::OUString m_sSchema;
+ String m_aName;
+ const IObjectNameCheck&
+ m_rObjectNameCheck;
+ String m_sParentURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData;
+ sal_Int32 m_nType;
+ sal_Int32 m_nFlags;
+
+ OSaveAsDlgImpl( Window * pParent,const sal_Int32& _rType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags);
+ OSaveAsDlgImpl( Window * pParent,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags);
+};
+// -----------------------------------------------------------------------------
+} // dbaui
+// -----------------------------------------------------------------------------
+OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent,
+ const sal_Int32& _rType,
+ const Reference< XConnection>& _xConnection,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags)
+ :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION))
+ ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG))
+ ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG), ::rtl::OUString())
+ ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA))
+ ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA), ::rtl::OUString())
+ ,m_aLabel(_pParent, ModuleRes (FT_TITLE))
+ ,m_aTitle(_pParent, ModuleRes (ET_TITLE), ::rtl::OUString())
+ ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) )
+ ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL ))
+ ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP))
+ ,m_aQryLabel(ModuleRes(STR_QRY_LABEL))
+ ,m_sTblLabel(ModuleRes(STR_TBL_LABEL))
+ ,m_aName(rDefault)
+ ,m_rObjectNameCheck( _rObjectNameCheck )
+ ,m_nType(_rType)
+ ,m_nFlags(_nFlags)
+{
+ if ( _xConnection.is() )
+ m_xMetaData = _xConnection->getMetaData();
+
+ if ( m_xMetaData.is() )
+ {
+ ::rtl::OUString sExtraNameChars( m_xMetaData->getExtraNameCharacters() );
+ m_aCatalog.setAllowedChars( sExtraNameChars );
+ m_aSchema.setAllowedChars( sExtraNameChars );
+ m_aTitle.setAllowedChars( sExtraNameChars );
+ }
+
+ m_aCatalog.SetDropDownLineCount( 10 );
+ m_aSchema.SetDropDownLineCount( 10 );
+}
+// -----------------------------------------------------------------------------
+OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags)
+ :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION))
+ ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG))
+ ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG))
+ ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA))
+ ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA))
+ ,m_aLabel(_pParent, ModuleRes (FT_TITLE))
+ ,m_aTitle(_pParent, ModuleRes (ET_TITLE))
+ ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) )
+ ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL ))
+ ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP))
+ ,m_aQryLabel(ModuleRes(STR_QRY_LABEL))
+ ,m_sTblLabel(ModuleRes(STR_TBL_LABEL))
+ ,m_aName(rDefault)
+ ,m_rObjectNameCheck( _rObjectNameCheck )
+ ,m_nType(CommandType::COMMAND)
+ ,m_nFlags(_nFlags)
+{
+ m_aCatalog.SetDropDownLineCount( 10 );
+ m_aSchema.SetDropDownLineCount( 10 );
+}
+
+// -----------------------------------------------------------------------------
+using namespace ::com::sun::star::lang;
+
+//==================================================================
+namespace
+{
+ typedef Reference< XResultSet > (SAL_CALL XDatabaseMetaData::*FGetMetaStrings)();
+
+ void lcl_fillComboList( ComboBox& _rList, const Reference< XConnection >& _rxConnection,
+ FGetMetaStrings _GetAll, const ::rtl::OUString& _rCurrent )
+ {
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+
+ Reference< XResultSet > xRes = (xMetaData.get()->*_GetAll)();
+ Reference< XRow > xRow( xRes, UNO_QUERY_THROW );
+ ::rtl::OUString sValue;
+ while ( xRes->next() )
+ {
+ sValue = xRow->getString( 1 );
+ if ( !xRow->wasNull() )
+ _rList.InsertEntry( sValue );
+ }
+
+ sal_uInt16 nPos = _rList.GetEntryPos( String( _rCurrent ) );
+ if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
+ _rList.SelectEntryPos( nPos );
+ else
+ _rList.SelectEntryPos( 0 );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+//==================================================================
+OSaveAsDlg::OSaveAsDlg( Window * pParent,
+ const sal_Int32& _rType,
+ const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XConnection>& _xConnection,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags)
+ :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS))
+ ,m_xORB( _rxORB )
+{
+ m_pImpl = new OSaveAsDlgImpl(this,_rType,_xConnection,rDefault,_rObjectNameCheck,_nFlags);
+
+ switch (_rType)
+ {
+ case CommandType::QUERY:
+ implInitOnlyTitle(m_pImpl->m_aQryLabel);
+ break;
+
+ case CommandType::TABLE:
+ OSL_ENSURE( m_pImpl->m_xMetaData.is(), "OSaveAsDlg::OSaveAsDlg: no meta data for entering table names: this will crash!" );
+ {
+ m_pImpl->m_aLabel.SetText(m_pImpl->m_sTblLabel);
+ Point aPos(m_pImpl->m_aPB_OK.GetPosPixel());
+ if(m_pImpl->m_xMetaData.is() && !m_pImpl->m_xMetaData->supportsCatalogsInTableDefinitions())
+ {
+ m_pImpl->m_aCatalogLbl.Hide();
+ m_pImpl->m_aCatalog.Hide();
+
+ aPos = m_pImpl->m_aLabel.GetPosPixel();
+
+ m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel());
+ m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel());
+
+ m_pImpl->m_aSchemaLbl.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel());
+ m_pImpl->m_aSchema.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel());
+ }
+ else
+ {
+ // now fill the catalogs
+ lcl_fillComboList( m_pImpl->m_aCatalog, _xConnection,
+ &XDatabaseMetaData::getCatalogs, _xConnection->getCatalog() );
+ }
+
+ if ( !m_pImpl->m_xMetaData->supportsSchemasInTableDefinitions())
+ {
+ m_pImpl->m_aSchemaLbl.Hide();
+ m_pImpl->m_aSchema.Hide();
+
+ aPos = m_pImpl->m_aLabel.GetPosPixel();
+
+ m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel());
+ m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel());
+ }
+ else
+ {
+ lcl_fillComboList( m_pImpl->m_aSchema, _xConnection,
+ &XDatabaseMetaData::getSchemas, m_pImpl->m_xMetaData->getUserName() );
+ }
+
+ OSL_ENSURE(m_pImpl->m_xMetaData.is(),"The metadata can not be null!");
+ if(m_pImpl->m_aName.Search('.') != STRING_NOTFOUND)
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_pImpl->m_xMetaData,
+ m_pImpl->m_aName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ sal_uInt16 nPos = m_pImpl->m_aCatalog.GetEntryPos(String(sCatalog));
+ if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
+ m_pImpl->m_aCatalog.SelectEntryPos(nPos);
+
+ if ( sSchema.getLength() )
+ {
+ nPos = m_pImpl->m_aSchema.GetEntryPos(String(sSchema));
+ if ( nPos != COMBOBOX_ENTRY_NOTFOUND )
+ m_pImpl->m_aSchema.SelectEntryPos(nPos);
+ }
+ m_pImpl->m_aTitle.SetText(sTable);
+ }
+ else
+ m_pImpl->m_aTitle.SetText(m_pImpl->m_aName);
+ m_pImpl->m_aTitle.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
+
+ m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y()));
+ m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y()));
+ m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y()));
+
+ sal_uInt16 nLength = m_pImpl->m_xMetaData.is() ? static_cast<sal_uInt16>(m_pImpl->m_xMetaData->getMaxTableNameLength()) : 0;
+ nLength = nLength ? nLength : EDIT_NOLIMIT;
+
+ m_pImpl->m_aTitle.SetMaxTextLen(nLength);
+ m_pImpl->m_aSchema.SetMaxTextLen(nLength);
+ m_pImpl->m_aCatalog.SetMaxTextLen(nLength);
+
+ sal_Bool bCheck = _xConnection.is() && isSQL92CheckEnabled(_xConnection);
+ m_pImpl->m_aTitle.setCheck(bCheck); // enable non valid sql chars as well
+ m_pImpl->m_aSchema.setCheck(bCheck); // enable non valid sql chars as well
+ m_pImpl->m_aCatalog.setCheck(bCheck); // enable non valid sql chars as well
+
+ Size aSize = GetSizePixel();
+ aSize.Height() =
+ aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2;
+ SetSizePixel(aSize);
+ }
+ break;
+
+ default:
+ OSL_FAIL( "OSaveAsDlg::OSaveAsDlg: Type not supported yet!" );
+ }
+
+ implInit();
+}
+// -----------------------------------------------------------------------------
+OSaveAsDlg::OSaveAsDlg( Window * pParent,
+ const Reference< XMultiServiceFactory >& _rxORB,
+ const String& rDefault,
+ const String& _sLabel,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags)
+ :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS))
+ ,m_xORB( _rxORB )
+{
+ m_pImpl = new OSaveAsDlgImpl(this,rDefault,_rObjectNameCheck,_nFlags);
+ implInitOnlyTitle(_sLabel);
+ implInit();
+}
+// -----------------------------------------------------------------------------
+OSaveAsDlg::~OSaveAsDlg()
+{
+ DELETEZ(m_pImpl);
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton)
+{
+ if (pButton == &m_pImpl->m_aPB_OK)
+ {
+ m_pImpl->m_aName = m_pImpl->m_aTitle.GetText();
+
+ ::rtl::OUString sNameToCheck( m_pImpl->m_aName );
+
+ if ( m_pImpl->m_nType == CommandType::TABLE )
+ {
+ sNameToCheck = ::dbtools::composeTableName(
+ m_pImpl->m_xMetaData,
+ getCatalog(),
+ getSchema(),
+ sNameToCheck,
+ sal_False, // no quoting
+ ::dbtools::eInDataManipulation
+ );
+ }
+
+ SQLExceptionInfo aNameError;
+ if ( m_pImpl->m_rObjectNameCheck.isNameValid( sNameToCheck, aNameError ) )
+ EndDialog( RET_OK );
+
+ showError( aNameError, this, m_xORB );
+ m_pImpl->m_aTitle.GrabFocus();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+
+IMPL_LINK(OSaveAsDlg, EditModifyHdl, Edit *, pEdit )
+{
+ if (pEdit == &m_pImpl->m_aTitle)
+ m_pImpl->m_aPB_OK.Enable(0 != m_pImpl->m_aTitle.GetText().Len());
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OSaveAsDlg::implInitOnlyTitle(const String& _rLabel)
+{
+ m_pImpl->m_aLabel.SetText(_rLabel);
+ m_pImpl->m_aCatalogLbl.Hide();
+ m_pImpl->m_aCatalog.Hide();
+ m_pImpl->m_aSchemaLbl.Hide();
+ m_pImpl->m_aSchema.Hide();
+
+ Point aPos(m_pImpl->m_aSchemaLbl.GetPosPixel());
+ m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel());
+ m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel());
+
+ m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y()));
+ m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y()));
+ m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y()));
+
+ sal_Int32 nNewHeight =
+ aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2;
+
+ SetSizePixel(Size(GetSizePixel().Width(), nNewHeight));
+
+ m_pImpl->m_aTitle.SetText(m_pImpl->m_aName);
+ m_pImpl->m_aTitle.setCheck(sal_False); // enable non valid sql chars as well
+}
+// -----------------------------------------------------------------------------
+void OSaveAsDlg::implInit()
+{
+ if ( 0 == ( m_pImpl->m_nFlags & SAD_ADDITIONAL_DESCRIPTION ) )
+ {
+ // hide the description window
+ m_pImpl->m_aDescription.Hide();
+
+ // the number of pixels we have to move the other controls
+ sal_Int32 nMoveUp = m_pImpl->m_aCatalog.GetPosPixel().Y() - m_pImpl->m_aDescription.GetPosPixel().Y();
+
+ // loop to all controls and move them ...
+ for ( Window* pChildControl = GetWindow( WINDOW_FIRSTCHILD );
+ pChildControl;
+ pChildControl= pChildControl->GetWindow( WINDOW_NEXT )
+ )
+ {
+ if ( &m_pImpl->m_aDescription != pChildControl )
+ {
+ Point aPos = pChildControl->GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ pChildControl->SetPosPixel(aPos);
+ }
+ }
+
+ // change our own size accordingly
+ Size aSize = GetSizePixel();
+ aSize.Height() -= nMoveUp;
+ SetSizePixel(aSize);
+ }
+
+ if ( SAD_TITLE_PASTE_AS == ( m_pImpl->m_nFlags & SAD_TITLE_PASTE_AS ) )
+ SetText( String( ModuleRes( STR_TITLE_PASTE_AS ) ) );
+ else if ( SAD_TITLE_RENAME == ( m_pImpl->m_nFlags & SAD_TITLE_RENAME ) )
+ {
+ SetText( String( ModuleRes( STR_TITLE_RENAME ) ) );
+ m_pImpl->m_aTitle.SetHelpId(HID_DLG_RENAME);
+ }
+
+ m_pImpl->m_aPB_OK.SetClickHdl(LINK(this,OSaveAsDlg,ButtonClickHdl));
+ m_pImpl->m_aTitle.SetModifyHdl(LINK(this,OSaveAsDlg,EditModifyHdl));
+ m_pImpl->m_aTitle.GrabFocus();
+ FreeResource();
+}
+// -----------------------------------------------------------------------------
+String OSaveAsDlg::getName() const { return m_pImpl->m_aName; }
+String OSaveAsDlg::getCatalog() const { return m_pImpl->m_aCatalog.IsVisible() ? m_pImpl->m_aCatalog.GetText() : String(); }
+String OSaveAsDlg::getSchema() const { return m_pImpl->m_aSchema.IsVisible() ? m_pImpl->m_aSchema.GetText() : String(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dlgsave.hrc b/dbaccess/source/ui/dlg/dlgsave.hrc
new file mode 100644
index 000000000000..7a36319ef4de
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsave.hrc
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DLGSAVE_HRC
+#define DBAUI_DLGSAVE_HRC
+
+// defines ------------------------------------------------------------------
+
+#define PB_OK 1
+#define PB_CANCEL 1
+#define PB_HELP 1
+
+#define ET_CATALOG 1
+#define ET_SCHEMA 2
+#define ET_TITLE 3
+
+#define FT_DESCRIPTION 1
+#define FT_CATALOG 2
+#define FT_SCHEMA 3
+#define FT_TITLE 4
+
+#define STR_TBL_LABEL 1
+#define STR_VW_LABEL 2
+#define STR_QRY_LABEL 3
+#define STR_TITLE_RENAME 4
+#define STR_TITLE_PASTE_AS 6
+
+#endif // DBAUI_DLGSAVE_HRC
+
diff --git a/dbaccess/source/ui/dlg/dlgsave.src b/dbaccess/source/ui/dlg/dlgsave.src
new file mode 100644
index 000000000000..bc94b77eee37
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsave.src
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DLGSAVE_HRC
+#include "dlgsave.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+ModalDialog DLG_SAVE_AS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_DLG_SAVE_AS ;
+ Size = MAP_APPFONT ( 174 , 75 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Save As" ;
+
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 174 - 12 , 16 ) ;
+ WordBreak=TRUE;
+ Text [ en-US ] = "Please enter a name for the object to be created:";
+ };
+
+ FixedText FT_CATALOG
+ {
+ Pos = MAP_APPFONT ( 6 , 26 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Catalog";
+ };
+ ComboBox ET_CATALOG
+ {
+ HelpID = "dbaccess:ComboBox:DLG_SAVE_AS:ET_CATALOG";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 , 25 ) ;
+ Size = MAP_APPFONT ( 89 , 12 ) ;
+ SVLook = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ FixedText FT_SCHEMA
+ {
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Schema";
+ };
+ ComboBox ET_SCHEMA
+ {
+ HelpID = "dbaccess:ComboBox:DLG_SAVE_AS:ET_SCHEMA";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 , 42 ) ;
+ Size = MAP_APPFONT ( 89 , 12 ) ;
+ SVLook = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 6 , 60 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ };
+ Edit ET_TITLE
+ {
+ HelpID = "dbaccess:Edit:DLG_SAVE_AS:ET_TITLE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 77 , 59 ) ;
+ Size = MAP_APPFONT ( 89 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 77 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 62 , 77 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 118 , 77 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ // String Resourcen ------------------------------------------------------------------
+ String STR_TBL_LABEL
+ {
+ Text [ en-US ] = "~Table Name" ;
+ };
+ String STR_VW_LABEL
+ {
+ Text [ en-US ] = "~Name of table view" ;
+ };
+ String STR_QRY_LABEL
+ {
+ Text [ en-US ] = "~Query name" ;
+ };
+ String STR_TITLE_RENAME
+ {
+ Text [ en-US ] = "Rename to";
+ };
+ String STR_TITLE_PASTE_AS
+ {
+ Text [ en-US ] = "Insert as";
+ };
+};
diff --git a/dbaccess/source/ui/dlg/dlgsize.cxx b/dbaccess/source/ui/dlg/dlgsize.cxx
new file mode 100644
index 000000000000..a42122657c23
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsize.cxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dlgsize.hrc"
+#include "dlgsize.hxx"
+#include "dbu_dlg.hrc"
+#include "moduledbu.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+
+#define DEF_ROW_HEIGHT 45
+#define DEF_COL_WIDTH 227
+
+DBG_NAME(DlgSize)
+//==================================================================
+DlgSize::DlgSize( Window* pParent, sal_Int32 nVal, sal_Bool bRow, sal_Int32 _nAlternativeStandard )
+ :ModalDialog( pParent, ModuleRes(bRow ? DLG_ROWHEIGHT : DLG_COLWIDTH))
+ ,m_nPrevValue(nVal)
+ ,m_nStandard(bRow ? DEF_ROW_HEIGHT : DEF_COL_WIDTH)
+ ,aFT_VALUE(this, ModuleRes( FT_VALUE))
+ ,aMF_VALUE(this, ModuleRes( MF_VALUE))
+ ,aCB_STANDARD(this, ModuleRes(CB_STANDARD))
+ ,aPB_OK(this, ModuleRes(PB_OK))
+ ,aPB_CANCEL(this, ModuleRes(PB_CANCEL))
+ ,aPB_HELP(this, ModuleRes(PB_HELP))
+{
+ DBG_CTOR(DlgSize,NULL);
+
+ if ( _nAlternativeStandard > 0 )
+ m_nStandard = _nAlternativeStandard;
+ aCB_STANDARD.SetClickHdl(LINK(this,DlgSize,CbClickHdl));
+
+ aMF_VALUE.EnableEmptyFieldValue(sal_True);
+ sal_Bool bDefault = -1 == nVal;
+ aCB_STANDARD.Check(bDefault);
+ if (bDefault)
+ {
+ SetValue(m_nStandard);
+ m_nPrevValue = m_nStandard;
+ }
+ LINK(this,DlgSize,CbClickHdl).Call(&aCB_STANDARD);
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------------
+DlgSize::~DlgSize()
+{
+
+ DBG_DTOR(DlgSize,NULL);
+}
+
+//------------------------------------------------------------------------------
+void DlgSize::SetValue( sal_Int32 nVal )
+{
+ aMF_VALUE.SetValue(nVal, FUNIT_CM );
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 DlgSize::GetValue()
+{
+ if (aCB_STANDARD.IsChecked())
+ return -1;
+ return (sal_Int32)aMF_VALUE.GetValue( FUNIT_CM );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DlgSize, CbClickHdl, Button *, pButton )
+{
+
+ if( pButton == &aCB_STANDARD )
+ {
+ aMF_VALUE.Enable(!aCB_STANDARD.IsChecked());
+ if (aCB_STANDARD.IsChecked())
+ {
+ m_nPrevValue = static_cast<sal_Int32>(aMF_VALUE.GetValue(FUNIT_CM));
+ // don't use getValue as this will use aCB_STANDARD.to determine if we're standard
+ aMF_VALUE.SetEmptyFieldValue();
+ }
+ else
+ {
+ SetValue( m_nPrevValue );
+ }
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dlgsize.hrc b/dbaccess/source/ui/dlg/dlgsize.hrc
new file mode 100644
index 000000000000..3eef0951a0dd
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsize.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DLGSIZE_HRC
+#define DBAUI_DLGSIZE_HRC
+
+#define FT_VALUE 1
+#define MF_VALUE 1
+#define CB_STANDARD 2
+#define PB_OK 1
+#define PB_CANCEL 1
+#define PB_HELP 1
+
+#endif //DBAUI_DLGSIZE_HRC
+
diff --git a/dbaccess/source/ui/dlg/dlgsize.src b/dbaccess/source/ui/dlg/dlgsize.src
new file mode 100644
index 000000000000..556c53974c9a
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dlgsize.src
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DLGSIZE_HRC
+#include "dlgsize.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+ModalDialog DLG_ROWHEIGHT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_DLG_ROWHEIGHT ;
+ Size = MAP_APPFONT ( 159 , 59 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 23 , 10 ) ;
+ Text [ en-US ] = "~Height" ;
+ };
+ MetricField MF_VALUE
+ {
+ HelpID = "dbaccess:MetricField:DLG_ROWHEIGHT:MF_VALUE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 36 , 6 ) ;
+ Size = MAP_APPFONT ( 63 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ Maximum = 1600 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Repeat = TRUE ;
+ };
+ CheckBox CB_STANDARD
+ {
+ HelpID = "dbaccess:CheckBox:DLG_ROWHEIGHT:CB_STANDARD";
+ Pos = MAP_APPFONT ( 36 , 25 ) ;
+ Size = MAP_APPFONT ( 62 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatic";
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 105 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 105 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 105 , 42 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Row Height" ;
+};
+ModalDialog DLG_COLWIDTH
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_DLG_COLWIDTH ;
+ Size = MAP_APPFONT ( 159 , 59 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 23 , 10 ) ;
+ Text [ en-US ] = "~Width" ;
+ };
+ MetricField MF_VALUE
+ {
+ HelpID = "dbaccess:MetricField:DLG_COLWIDTH:MF_VALUE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 36 , 6 ) ;
+ Size = MAP_APPFONT ( 63 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ Maximum = 20000 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Repeat = TRUE ;
+ };
+ CheckBox CB_STANDARD
+ {
+ HelpID = "dbaccess:CheckBox:DLG_COLWIDTH:CB_STANDARD";
+ Pos = MAP_APPFONT ( 36 , 25 ) ;
+ Size = MAP_APPFONT ( 62 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatic";
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 105 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 105 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 105 , 42 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Column Width" ;
+};
diff --git a/dbaccess/source/ui/dlg/dsnItem.hxx b/dbaccess/source/ui/dlg/dsnItem.hxx
new file mode 100644
index 000000000000..a3b542a1d4f6
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsnItem.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DSNITEM_HXX_
+#define _DBAUI_DSNITEM_HXX_
+
+#include <svl/poolitem.hxx>
+
+//.........................................................................
+namespace dbaccess
+{
+//.........................................................................
+ class ODsnTypeCollection;
+//.........................................................................
+}
+//.........................................................................
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ //=========================================================================
+ //= DbuTypeCollectionItem
+ //=========================================================================
+ /** allows an ODsnTypeCollection to be transported in an SfxItemSet
+ */
+ class DbuTypeCollectionItem : public SfxPoolItem
+ {
+ ::dbaccess::ODsnTypeCollection* m_pCollection;
+
+ public:
+ TYPEINFO();
+ DbuTypeCollectionItem(sal_Int16 nWhich = 0, ::dbaccess::ODsnTypeCollection* _pCollection = NULL);
+ DbuTypeCollectionItem(const DbuTypeCollectionItem& _rSource);
+
+ virtual int operator==(const SfxPoolItem& _rItem) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* _pPool = NULL) const;
+
+ ::dbaccess::ODsnTypeCollection* getCollection() const { return m_pCollection; }
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DSNITEM_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx
new file mode 100644
index 000000000000..e6bbb8494e16
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dsselect.hxx"
+#include "dsselect.hrc"
+#include "dbu_dlg.hrc"
+#include <vcl/msgbox.hxx>
+#include "localresaccess.hxx"
+#include <tools/rcid.h>
+#include <sal/macros.h>
+
+#include <com/sun/star/sdbcx/XCreateCatalog.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include "dbustrings.hrc"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/processfactory.hxx>
+#include "dsitems.hxx"
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::comphelper;
+//==================================================================
+ODatasourceSelectDialog::ODatasourceSelectDialog(Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet)
+ :ModalDialog(_pParent, ModuleRes(DLG_DATASOURCE_SELECTION))
+ ,m_aDescription (this, ModuleRes(FT_DESCRIPTION))
+ ,m_aDatasource (this, ModuleRes(LB_DATASOURCE))
+ ,m_aOk (this, ModuleRes(PB_OK))
+ ,m_aCancel (this, ModuleRes(PB_CANCEL))
+ ,m_aHelp (this, ModuleRes(PB_HELP))
+#ifdef HAVE_ODBC_ADMINISTRATION
+ ,m_aManageDatasources (this, ModuleRes(PB_MANAGE))
+#endif
+ ,m_aCreateAdabasDB (this, ModuleRes(PB_CREATE))
+ ,m_pOutputSet(_pOutputSet)
+{
+ if ( _bAdabas )
+ { // set a new title (indicating that we're browsing local data sources only)
+ SetText(ModuleRes(STR_LOCAL_DATASOURCES));
+ m_aDescription.SetText(ModuleRes(STR_DESCRIPTION2));
+
+ m_aCreateAdabasDB.Show();
+ m_aCreateAdabasDB.SetClickHdl(LINK(this,ODatasourceSelectDialog,CreateDBClickHdl));
+
+ // resize the dialog a little bit, 'cause Adabas data source names are usually somewhat shorter
+ // than ODBC ones are
+
+ // shrink the listbox
+ Size aOldSize = m_aDatasource.GetSizePixel();
+ Size aNewSize(3 * aOldSize.Width() / 4, aOldSize.Height());
+ m_aDatasource.SetSizePixel(aNewSize);
+
+ sal_Int32 nLostPixels = aOldSize.Width() - aNewSize.Width();
+
+ // shrink the fixed text
+ aOldSize = m_aDescription.GetSizePixel();
+ m_aDescription.SetSizePixel(Size(aOldSize.Width() - nLostPixels, aOldSize.Height()));
+
+ // move the buttons
+ PushButton* pButtons[] = { &m_aOk, &m_aCancel, &m_aHelp ,&m_aCreateAdabasDB};
+ for (size_t i=0; i < SAL_N_ELEMENTS(pButtons); ++i)
+ {
+ Point aOldPos = pButtons[i]->GetPosPixel();
+ pButtons[i]->SetPosPixel(Point(aOldPos.X() - nLostPixels, aOldPos.Y()));
+ }
+
+ // resize the dialog itself
+ aOldSize = GetSizePixel();
+ SetSizePixel(Size(aOldSize.Width() - nLostPixels, aOldSize.Height()));
+ }
+
+ fillListBox(_rDatasources);
+#ifdef HAVE_ODBC_ADMINISTRATION
+ // allow ODBC datasource managenment
+ if ( !_bAdabas )
+ {
+ m_aManageDatasources.Show();
+ m_aManageDatasources.Enable();
+ m_aManageDatasources.SetClickHdl(LINK(this,ODatasourceSelectDialog,ManageClickHdl));
+ }
+#endif
+ m_aDatasource.SetDoubleClickHdl(LINK(this,ODatasourceSelectDialog,ListDblClickHdl));
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+ODatasourceSelectDialog::~ODatasourceSelectDialog()
+{
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( ODatasourceSelectDialog, ListDblClickHdl, ListBox *, pListBox )
+{
+ if (pListBox->GetSelectEntryCount())
+ EndDialog(RET_OK);
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( ODatasourceSelectDialog, CreateDBClickHdl, PushButton*, /*pButton*/ )
+{
+ try
+ {
+ OSL_ENSURE(m_pOutputSet,"No itemset given!");
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
+ Reference<XCreateCatalog> xCatalog(xORB->createInstance(SERVICE_EXTENDED_ADABAS_DRIVER),UNO_QUERY);
+ if ( xCatalog.is() && m_pOutputSet )
+ {
+ Sequence< Any > aArgs(2);
+ aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateCatalog")), 0, makeAny(xCatalog), PropertyState_DIRECT_VALUE);
+ aArgs[1] <<= PropertyValue(PROPERTY_PARENTWINDOW, 0, makeAny(VCLUnoHelper::GetInterface(this)), PropertyState_DIRECT_VALUE);
+
+ Reference< XExecutableDialog > xDialog(
+ xORB->createInstanceWithArguments(SERVICE_SDB_ADABASCREATIONDIALOG, aArgs), UNO_QUERY);
+ if (!xDialog.is())
+ {
+ // ShowServiceNotAvailableError(this, String(SERVICE_SDB_ADABASCREATIONDIALOG), sal_True);
+ return 0L;
+ }
+
+ if ( xDialog->execute() == RET_OK )
+ {
+ Reference<XPropertySet> xProp(xDialog,UNO_QUERY);
+ if(xProp.is())
+ {
+ Reference<XPropertySetInfo> xPropInfo(xProp->getPropertySetInfo());
+ if(xPropInfo->hasPropertyByName(PROPERTY_DATABASENAME))
+ {
+ String sDatabaseName;
+ sDatabaseName = String(::comphelper::getString(xProp->getPropertyValue(PROPERTY_DATABASENAME)));
+ m_aDatasource.SelectEntryPos(m_aDatasource.InsertEntry( sDatabaseName ));
+
+ }
+ if ( xPropInfo->hasPropertyByName(PROPERTY_CONTROLUSER) )
+ m_pOutputSet->Put(SfxStringItem(DSID_CONN_CTRLUSER, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_CONTROLUSER))));
+ if ( xPropInfo->hasPropertyByName(PROPERTY_CONTROLPASSWORD) )
+ m_pOutputSet->Put(SfxStringItem(DSID_CONN_CTRLPWD, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_CONTROLPASSWORD))));
+ if ( xPropInfo->hasPropertyByName(PROPERTY_USER) )
+ m_pOutputSet->Put(SfxStringItem(DSID_USER, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_USER))));
+ if ( xPropInfo->hasPropertyByName(PROPERTY_PASSWORD) )
+ {
+ m_pOutputSet->Put(SfxStringItem(DSID_PASSWORD, ::comphelper::getString(xProp->getPropertyValue(PROPERTY_PASSWORD))));
+ m_pOutputSet->Put(SfxBoolItem(DSID_PASSWORDREQUIRED, sal_True));
+ }
+ if ( xPropInfo->hasPropertyByName(PROPERTY_CACHESIZE) )
+ m_pOutputSet->Put(SfxInt32Item(DSID_CONN_CACHESIZE, ::comphelper::getINT32(xProp->getPropertyValue(PROPERTY_CACHESIZE))));
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return 0L;
+}
+
+// -----------------------------------------------------------------------
+sal_Bool ODatasourceSelectDialog::Close()
+{
+#ifdef HAVE_ODBC_ADMINISTRATION
+ if ( m_pODBCManagement.get() && m_pODBCManagement->isRunning() )
+ return sal_False;
+#endif
+
+ return ModalDialog::Close();
+}
+
+// -----------------------------------------------------------------------
+#ifdef HAVE_ODBC_ADMINISTRATION
+IMPL_LINK( ODatasourceSelectDialog, ManageClickHdl, PushButton*, EMPTYARG )
+{
+ if ( !m_pODBCManagement.get() )
+ m_pODBCManagement.reset( new OOdbcManagement( LINK( this, ODatasourceSelectDialog, ManageProcessFinished ) ) );
+
+ if ( !m_pODBCManagement->manageDataSources_async() )
+ {
+ // TODO: error message
+ m_aDatasource.GrabFocus();
+ m_aManageDatasources.Disable();
+ return 1L;
+ }
+
+ m_aDatasource.Disable();
+ m_aOk.Disable();
+ m_aCancel.Disable();
+ m_aManageDatasources.Disable();
+
+ OSL_POSTCOND( m_pODBCManagement->isRunning(), "ODatasourceSelectDialog::ManageClickHdl: success, but not running - you were *fast*!" );
+ return 0L;
+}
+
+IMPL_LINK( ODatasourceSelectDialog, ManageProcessFinished, void*, /**/ )
+{
+ StringBag aOdbcDatasources;
+ OOdbcEnumeration aEnumeration;
+ aEnumeration.getDatasourceNames( aOdbcDatasources );
+ fillListBox( aOdbcDatasources );
+
+ m_aDatasource.Enable();
+ m_aOk.Enable();
+ m_aCancel.Enable();
+ m_aManageDatasources.Enable();
+
+ return 0L;
+}
+
+#endif
+// -----------------------------------------------------------------------------
+void ODatasourceSelectDialog::fillListBox(const StringBag& _rDatasources)
+{
+ ::rtl::OUString sSelected;
+ if (m_aDatasource.GetEntryCount())
+ sSelected = m_aDatasource.GetSelectEntry();
+ m_aDatasource.Clear();
+ // fill the list
+ for ( ConstStringBagIterator aDS = _rDatasources.begin();
+ aDS != _rDatasources.end();
+ ++aDS
+ )
+ {
+ m_aDatasource.InsertEntry( *aDS );
+ }
+
+ if (m_aDatasource.GetEntryCount())
+ {
+ if (sSelected.getLength())
+ m_aDatasource.SelectEntry(sSelected);
+ else // select the first entry
+ m_aDatasource.SelectEntryPos(0);
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dsselect.hrc b/dbaccess/source/ui/dlg/dsselect.hrc
new file mode 100644
index 000000000000..5deffeeef102
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.hrc
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DSSELECT_HRC_
+#define _DBAUI_DSSELECT_HRC_
+
+#define LB_DATASOURCE 1
+#define PB_OK 2
+#define PB_CANCEL 3
+#define PB_HELP 4
+#define PB_MANAGE 5
+#define FT_DESCRIPTION 6
+#define STR_LOCAL_DATASOURCES 7
+#define PB_CREATE 9
+#define STR_DESCRIPTION2 10
+
+#endif // _DBAUI_DSSELECT_HRC_
diff --git a/dbaccess/source/ui/dlg/dsselect.hxx b/dbaccess/source/ui/dlg/dsselect.hxx
new file mode 100644
index 000000000000..34050aff9cb9
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DSSELECT_HXX_
+#define _DBAUI_DSSELECT_HXX_
+
+#include "dsntypes.hxx"
+#include "odbcconfig.hxx"
+#include "commontypes.hxx"
+
+#include <vcl/dialog.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <rtl/ustring.hxx>
+
+#include <memory>
+
+class SfxItemSet;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= ODatasourceSelector
+//=========================================================================
+class ODatasourceSelectDialog : public ModalDialog
+{
+protected:
+ FixedText m_aDescription;
+ ListBox m_aDatasource;
+ OKButton m_aOk;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+#ifdef HAVE_ODBC_ADMINISTRATION
+ PushButton m_aManageDatasources;
+#endif
+ PushButton m_aCreateAdabasDB;
+ SfxItemSet* m_pOutputSet;
+#ifdef HAVE_ODBC_ADMINISTRATION
+ ::std::auto_ptr< OOdbcManagement >
+ m_pODBCManagement;
+#endif
+
+public:
+ ODatasourceSelectDialog( Window* _pParent, const StringBag& _rDatasources, bool _bAdabas,SfxItemSet* _pOutputSet = NULL );
+ ~ODatasourceSelectDialog();
+
+ inline String GetSelected() const { return m_aDatasource.GetSelectEntry();}
+ void Select( const String& _rEntry ) { m_aDatasource.SelectEntry(_rEntry); }
+
+ virtual sal_Bool Close();
+
+protected:
+ DECL_LINK( ListDblClickHdl, ListBox * );
+#ifdef HAVE_ODBC_ADMINISTRATION
+ DECL_LINK( ManageClickHdl, PushButton * );
+ DECL_LINK( ManageProcessFinished, void* );
+#endif
+ DECL_LINK( CreateDBClickHdl, PushButton * );
+ void fillListBox(const StringBag& _rDatasources);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DSSELECT_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/dsselect.src b/dbaccess/source/ui/dlg/dsselect.src
new file mode 100644
index 000000000000..d6a8855559a2
--- /dev/null
+++ b/dbaccess/source/ui/dlg/dsselect.src
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DSSELECT_HRC_
+#include "dsselect.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+
+ModalDialog DLG_DATASOURCE_SELECTION
+{
+ HelpID = "dbaccess:ModalDialog:DLG_DATASOURCE_SELECTION";
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 218 , 118 ) ;
+ Text [ en-US ] = "Data Source" ;
+
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 154 , 10 ) ;
+ Text [ en-US ] = "Choose a data source:";
+ };
+ ListBox LB_DATASOURCE
+ {
+ HelpID = "dbaccess:ListBox:DLG_DATASOURCE_SELECTION:LB_DATASOURCE";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 154 , 94 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE ;
+ Sort = TRUE ;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 166 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 166 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 166 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_MANAGE
+ {
+ HelpID = "dbaccess:PushButton:DLG_DATASOURCE_SELECTION:PB_MANAGE";
+ Pos = MAP_APPFONT ( 166 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Disable = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Organize..." ;
+ };
+ PushButton PB_CREATE
+ {
+ HelpID = "dbaccess:PushButton:DLG_DATASOURCE_SELECTION:PB_CREATE";
+ Pos = MAP_APPFONT ( 166 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Create..." ;
+ };
+ String STR_LOCAL_DATASOURCES
+ {
+ Text [ en-US ] = "Local Databases" ;
+ };
+ String STR_DESCRIPTION2
+ {
+ Text [ en-US ] = "Choose a database";
+ };
+};
diff --git a/dbaccess/source/ui/dlg/finteraction.cxx b/dbaccess/source/ui/dlg/finteraction.cxx
new file mode 100644
index 000000000000..562ebf435223
--- /dev/null
+++ b/dbaccess/source/ui/dlg/finteraction.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "finteraction.hxx"
+#include <tools/debug.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::ucb;
+
+ //====================================================================
+ //= OFilePickerInteractionHandler
+ //====================================================================
+ DBG_NAME( OFilePickerInteractionHandler )
+ //--------------------------------------------------------------------
+ OFilePickerInteractionHandler::OFilePickerInteractionHandler( const Reference< XInteractionHandler >& _rxMaster )
+ :m_xMaster( _rxMaster )
+ ,m_bDoesNotExist(sal_False)
+ {
+ DBG_CTOR( OFilePickerInteractionHandler, NULL );
+ OSL_ENSURE( m_xMaster.is(), "OFilePickerInteractionHandler::OFilePickerInteractionHandler: invalid master handler!" );
+ }
+
+ //--------------------------------------------------------------------
+ OFilePickerInteractionHandler::~OFilePickerInteractionHandler( )
+ {
+ DBG_DTOR( OFilePickerInteractionHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OFilePickerInteractionHandler::handle( const Reference< XInteractionRequest >& _rxRequest ) throw (RuntimeException)
+ {
+ InteractiveIOException aIoException;
+ if ( _rxRequest->getRequest() >>= aIoException )
+ {
+ if ( IOErrorCode_NOT_EXISTING == aIoException.Code )
+ {
+ m_bDoesNotExist = sal_True;
+ return;
+ }
+ }
+
+ if ( m_xMaster.is() )
+ m_xMaster->handle( _rxRequest );
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/finteraction.hxx b/dbaccess/source/ui/dlg/finteraction.hxx
new file mode 100644
index 000000000000..bbc837e0b074
--- /dev/null
+++ b/dbaccess/source/ui/dlg/finteraction.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_FILEPICKER_INTERACTION_HXX
+#define DBAUI_FILEPICKER_INTERACTION_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= OFilePickerInteractionHandler
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::task::XInteractionHandler
+ > OFilePickerInteractionHandler_Base;
+
+ /** a InteractionHandler implementation which extends another handler with some customizability
+ */
+ class OFilePickerInteractionHandler : public OFilePickerInteractionHandler_Base
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >
+ m_xMaster; // our master handler
+ sal_Bool m_bDoesNotExist;
+
+ public:
+ OFilePickerInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxMaster );
+
+ inline sal_Bool isDoesNotExist( ) const { return m_bDoesNotExist; }
+
+ protected:
+ // XInteractionHandler
+ virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& _rxRequest ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ~OFilePickerInteractionHandler();
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBAUI_FILEPICKER_INTERACTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
new file mode 100644
index 000000000000..060f83d43853
--- /dev/null
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -0,0 +1,638 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dsnItem.hxx"
+#include "generalpage.hxx"
+#include <connectivity/dbexception.hxx>
+#include "dbu_dlg.hrc"
+#include "dbadmin.hrc"
+#include "dsitems.hxx"
+#include "dbustrings.hrc"
+#include "dbadmin.hxx"
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docfilt.hxx>
+#include <vcl/stdtext.hxx>
+#include "localresaccess.hxx"
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/waitobj.hxx>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "DriverSettings.hxx"
+#include "UITools.hxx"
+#include <comphelper/processfactory.hxx>
+#include <unotools/confignode.hxx>
+#include <osl/diagnose.h>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+ //=========================================================================
+ //= OGeneralPage
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OGeneralPage::OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode)
+ :OGenericAdministrationPage(pParent, ModuleRes(PAGE_GENERAL), _rItems)
+ ,m_aFTHeaderText (this, ModuleRes(FT_GENERALHEADERTEXT))
+ ,m_aFTHelpText (this, ModuleRes(FT_GENERALHELPTEXT))
+ ,m_aFT_DatasourceTypeHeader (this, ModuleRes(FT_DATASOURCEHEADER))
+ ,m_aRB_CreateDatabase (this, ModuleRes(RB_CREATEDBDATABASE))
+ ,m_aRB_OpenDocument (this, ModuleRes(RB_OPENEXISTINGDOC))
+ ,m_aRB_GetExistingDatabase (this, ModuleRes(RB_GETEXISTINGDATABASE))
+ ,m_aFT_DocListLabel (this, ModuleRes(FT_DOCLISTLABEL))
+ ,m_pLB_DocumentList ( new OpenDocumentListBox( this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes( LB_DOCUMENTLIST ) ) )
+ ,m_aPB_OpenDocument (this, "com.sun.star.sdb.OfficeDatabaseDocument", ModuleRes(PB_OPENDOCUMENT))
+ ,m_aTypePreLabel (this, ModuleRes(FT_DATASOURCETYPE_PRE))
+ ,m_aDatasourceTypeLabel (this, ModuleRes(FT_DATATYPE))
+ ,m_pDatasourceType ( new ListBox(this, ModuleRes(LB_DATATYPE)))
+ ,m_aFTDataSourceAppendix (this, ModuleRes(FT_DATATYPEAPPENDIX))
+ ,m_aTypePostLabel (this, ModuleRes(FT_DATASOURCETYPE_POST))
+ ,m_aSpecialMessage (this, ModuleRes(FT_SPECIAL_MESSAGE))
+ ,m_DBWizardMode (_bDBWizardMode)
+ ,m_sMySQLEntry (ModuleRes(STR_MYSQLENTRY))
+ ,m_eOriginalCreationMode (eCreateNew)
+ ,m_pCollection (NULL)
+ ,m_eNotSupportedKnownType ( ::dbaccess::DST_UNKNOWN)
+ ,m_eLastMessage (smNone)
+ ,m_bDisplayingInvalid (sal_False)
+ ,m_bUserGrabFocus (sal_True)
+ ,m_bInitTypeList (true)
+ {
+ // fill the listbox with the UI descriptions for the possible types
+ // and remember the respective DSN prefixes
+ FreeResource();
+ // extract the datasource type collection from the item set
+ DbuTypeCollectionItem* pCollectionItem = PTR_CAST(DbuTypeCollectionItem, _rItems.GetItem(DSID_TYPECOLLECTION));
+ if (pCollectionItem)
+ m_pCollection = pCollectionItem->getCollection();
+ OSL_ENSURE(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !");
+
+ // If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
+ sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pCollection->getEmbeddedDatabase() );
+ if ( nCreateNewDBIndex == -1 )
+ nCreateNewDBIndex = m_pCollection->getIndexOf( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) );
+ bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
+
+ // also, if our application policies tell us to hide the option, do it
+ ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ ::comphelper::getProcessServiceFactory(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/Policies/Features/Base" ) )
+ ) );
+ sal_Bool bAllowCreateLocalDatabase( sal_True );
+ OSL_VERIFY( aConfig.getNodeValue( "CreateLocalDatabase" ) >>= bAllowCreateLocalDatabase );
+ if ( !bAllowCreateLocalDatabase )
+ bHideCreateNew = true;
+
+ if ( bHideCreateNew )
+ {
+ m_aRB_CreateDatabase.Hide();
+ Window* pWindowsToMove[] = {
+ &m_aRB_OpenDocument, &m_aRB_GetExistingDatabase, &m_aFT_DocListLabel, m_pLB_DocumentList.get(),
+ &m_aPB_OpenDocument, &m_aDatasourceTypeLabel, m_pDatasourceType.get(), &m_aFTDataSourceAppendix,
+ &m_aTypePostLabel
+ };
+ const long nOffset = m_aRB_OpenDocument.GetPosPixel().Y() - m_aRB_CreateDatabase.GetPosPixel().Y();
+ for ( size_t i=0; i < SAL_N_ELEMENTS( pWindowsToMove ); ++i )
+ {
+ Point aPos( pWindowsToMove[i]->GetPosPixel() );
+ aPos.Y() -= nOffset;
+ pWindowsToMove[i]->SetPosPixel( aPos );
+ }
+ }
+
+ if ( bHideCreateNew )
+ m_aRB_GetExistingDatabase.Check();
+ else
+ m_aRB_CreateDatabase.Check();
+
+ // do some knittings
+ m_pDatasourceType->SetSelectHdl(LINK(this, OGeneralPage, OnDatasourceTypeSelected));
+ m_aRB_CreateDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
+ m_aRB_GetExistingDatabase.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
+ m_aRB_OpenDocument.SetClickHdl(LINK(this, OGeneralPage, OnSetupModeSelected));
+ m_pLB_DocumentList->SetSelectHdl( LINK( this, OGeneralPage, OnDocumentSelected ) );
+ m_aPB_OpenDocument.SetClickHdl( LINK( this, OGeneralPage, OnOpenDocument ) );
+ }
+
+ //-------------------------------------------------------------------------
+ OGeneralPage::~OGeneralPage()
+ {
+ m_pDatasourceType.reset( NULL );
+ m_pLB_DocumentList.reset( NULL );
+ }
+
+ //-------------------------------------------------------------------------
+ namespace
+ {
+ struct DisplayedType
+ {
+ ::rtl::OUString eType;
+ String sDisplayName;
+
+ DisplayedType( const ::rtl::OUString& _eType, const String& _rDisplayName ) : eType( _eType ), sDisplayName( _rDisplayName ) { }
+ };
+ typedef ::std::vector< DisplayedType > DisplayedTypes;
+
+ struct DisplayedTypeLess : ::std::binary_function< DisplayedType, DisplayedType, bool >
+ {
+ bool operator() ( const DisplayedType& _rLHS, const DisplayedType& _rRHS )
+ {
+ return _rLHS.eType < _rRHS.eType;
+ }
+ };
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::initializeTypeList()
+ {
+ if ( m_bInitTypeList )
+ {
+ m_bInitTypeList = false;
+ m_pDatasourceType->Clear();
+
+ if ( m_pCollection )
+ {
+ DisplayedTypes aDisplayedTypes;
+
+ ::dbaccess::ODsnTypeCollection::TypeIterator aEnd = m_pCollection->end();
+ for ( ::dbaccess::ODsnTypeCollection::TypeIterator aTypeLoop = m_pCollection->begin();
+ aTypeLoop != aEnd;
+ ++aTypeLoop
+ )
+ {
+ const ::rtl::OUString sURLPrefix = aTypeLoop.getURLPrefix();
+ if ( sURLPrefix.getLength() )
+ {
+ String sDisplayName = aTypeLoop.getDisplayName();
+ if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
+ && approveDataSourceType( sURLPrefix, sDisplayName ) )
+ {
+ aDisplayedTypes.push_back( DisplayedTypes::value_type( sURLPrefix, sDisplayName ) );
+ }
+ }
+ }
+ ::std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() );
+ DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end();
+ for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin();
+ loop != aDisplayEnd;
+ ++loop
+ )
+ insertDatasourceTypeEntryData( loop->eType, loop->sDisplayName );
+ }
+ }
+ }
+
+
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::setParentTitle(const ::rtl::OUString& _sURLPrefix)
+ {
+ if (!m_DBWizardMode)
+ {
+ const String sName = m_pCollection->getTypeDisplayName(_sURLPrefix);
+ if ( m_pAdminDialog )
+ {
+ LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
+ String sMessage = String(ModuleRes(STR_PARENTTITLE));
+ sMessage.SearchAndReplaceAscii("#",sName);
+ m_pAdminDialog->setTitle(sMessage);
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ OGeneralPage::CreationMode OGeneralPage::GetDatabaseCreationMode() const
+ {
+ if ( m_aRB_CreateDatabase.IsChecked() )
+ return eCreateNew;
+ if ( m_aRB_GetExistingDatabase.IsChecked() )
+ return eConnectExternal;
+ return eOpenExisting;
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::GetFocus()
+ {
+ OGenericAdministrationPage::GetFocus();
+ if ( m_pLB_DocumentList.get() && m_pLB_DocumentList->IsEnabled() )
+ m_pLB_DocumentList->GrabFocus();
+ else if (m_pDatasourceType.get() && m_pDatasourceType->IsEnabled())
+ m_pDatasourceType->GrabFocus();
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::switchMessage(const ::rtl::OUString& _sURLPrefix)
+ {
+ SPECIAL_MESSAGE eMessage = smNone;
+ if ( !_sURLPrefix.getLength()/*_eType == m_eNotSupportedKnownType*/ )
+ {
+ eMessage = smUnsupportedType;
+ }
+
+
+ if ( eMessage != m_eLastMessage )
+ {
+ sal_uInt16 nResId = 0;
+ if ( smUnsupportedType == eMessage )
+ nResId = STR_UNSUPPORTED_DATASOURCE_TYPE;
+ String sMessage;
+ if ( nResId )
+ {
+ LocalResourceAccess aStringResAccess( PAGE_GENERAL, RSC_TABPAGE );
+ sMessage = String(ModuleRes(nResId));
+ }
+ m_aSpecialMessage.SetText(sMessage);
+
+ m_eLastMessage = eMessage;
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::onTypeSelected(const ::rtl::OUString& _sURLPrefix)
+ {
+ // the the new URL text as indicated by the selection history
+ implSetCurrentType( _sURLPrefix );
+
+ switchMessage(_sURLPrefix);
+
+ if ( m_aTypeSelectHandler.IsSet() )
+ m_aTypeSelectHandler.Call(this);
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ initializeTypeList();
+
+ // first check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+ if (m_DBWizardMode)
+ {
+ m_aTypePreLabel.Hide();
+ m_aTypePostLabel.Hide();
+ m_aSpecialMessage.Hide();
+ SetControlFontWeight(&m_aFTHeaderText);
+ SetText(String());
+
+ LayoutHelper::positionBelow( m_aRB_GetExistingDatabase, *m_pDatasourceType, RelatedControls, INDENT_BELOW_RADIO );
+
+ if ( !bValid || bReadonly )
+ {
+ m_aDatasourceTypeLabel.Enable( false );
+ m_pDatasourceType->Enable( false );
+ m_aFTDataSourceAppendix.Enable( false );
+ m_aPB_OpenDocument.Enable( false );
+ m_aFT_DocListLabel.Enable( false );
+ m_pLB_DocumentList->Enable( false );
+ }
+ else
+ {
+ m_aControlDependencies.enableOnRadioCheck( m_aRB_GetExistingDatabase, m_aDatasourceTypeLabel, *m_pDatasourceType, m_aFTDataSourceAppendix );
+ m_aControlDependencies.enableOnRadioCheck( m_aRB_OpenDocument, m_aPB_OpenDocument, m_aFT_DocListLabel, *m_pLB_DocumentList );
+ }
+
+ m_pLB_DocumentList->SetDropDownLineCount( 20 );
+ if ( m_pLB_DocumentList->GetEntryCount() )
+ m_pLB_DocumentList->SelectEntryPos( 0 );
+
+ m_aDatasourceTypeLabel.Hide();
+ m_aFTDataSourceAppendix.Hide();
+
+ m_eOriginalCreationMode = GetDatabaseCreationMode();
+ }
+ else
+ {
+ m_aFT_DatasourceTypeHeader.Hide();
+ m_aRB_CreateDatabase.Hide();
+ m_aRB_GetExistingDatabase.Hide();
+ m_aRB_OpenDocument.Hide();
+ m_aPB_OpenDocument.Hide();
+ m_aFT_DocListLabel.Hide();
+ m_pLB_DocumentList->Hide();
+ m_aFTHeaderText.Hide();
+ m_aFTHelpText.Hide();
+ m_aTypePreLabel.Enable(bValid);
+ m_aTypePostLabel.Enable(bValid);
+ m_aDatasourceTypeLabel.Enable(bValid);
+ m_pDatasourceType->Enable(bValid);
+ }
+ // if the selection is invalid, disable evrything
+ String sName,sConnectURL;
+ m_bDisplayingInvalid = !bValid;
+ if ( bValid )
+ {
+ // collect some items and some values
+ SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
+ SFX_ITEMSET_GET(_rSet, pUrlItem, SfxStringItem, DSID_CONNECTURL, sal_True);
+ OSL_ENSURE(pUrlItem, "OGeneralPage::implInitControls : missing the type attribute !");
+ OSL_ENSURE(pNameItem, "OGeneralPage::implInitControls : missing the type attribute !");
+ sName = pNameItem->GetValue();
+ sConnectURL = pUrlItem->GetValue();
+ }
+
+ ::rtl::OUString eOldSelection = m_eCurrentSelection;
+ m_eNotSupportedKnownType = ::dbaccess::DST_UNKNOWN;
+ implSetCurrentType( ::rtl::OUString() );
+
+ // compare the DSN prefix with the registered ones
+ String sDisplayName;
+
+ if (m_pCollection && bValid)
+ {
+ implSetCurrentType( m_pCollection->getPrefix(sConnectURL) );
+ sDisplayName = m_pCollection->getTypeDisplayName(m_eCurrentSelection);
+ }
+
+ // select the correct datasource type
+ if ( approveDataSourceType( m_eCurrentSelection, sDisplayName )
+ && ( LISTBOX_ENTRY_NOTFOUND == m_pDatasourceType->GetEntryPos( sDisplayName ) )
+ )
+ { // this indicates it's really a type which is known in general, but not supported on the current platform
+ // show a message saying so
+ // eSpecialMessage = smUnsupportedType;
+ insertDatasourceTypeEntryData(m_eCurrentSelection, sDisplayName);
+ // remember this type so we can show the special message again if the user selects this
+ // type again (without changing the data source)
+ m_eNotSupportedKnownType = m_pCollection->determineType(m_eCurrentSelection);
+ }
+
+ if (m_aRB_CreateDatabase.IsChecked() && m_DBWizardMode)
+ sDisplayName = m_pCollection->getTypeDisplayName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:")));
+ m_pDatasourceType->SelectEntry(sDisplayName);
+
+ // notify our listener that our type selection has changed (if so)
+ if ( eOldSelection != m_eCurrentSelection )
+ {
+ setParentTitle(m_eCurrentSelection);
+ onTypeSelected(m_eCurrentSelection);
+ }
+
+ // a special message for the current page state
+ switchMessage(m_eCurrentSelection);
+
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+
+ // For the databaseWizard we only have one entry for the MySQL Database,
+ // because we have a seperate tabpage to retrieve the respective datasource type
+ // ( ::dbaccess::DST_MYSQL_ODBC || ::dbaccess::DST_MYSQL_JDBC). Therefore we use ::dbaccess::DST_MYSQL_JDBC as a temporary
+ // representative for all MySQl databases)
+ // Also, embedded databases (embedded HSQL, at the moment), are not to appear in the list of
+ // databases to connect to.
+ bool OGeneralPage::approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName )
+ {
+ const ::dbaccess::DATASOURCE_TYPE eType = m_pCollection->determineType(_sURLPrefix);
+
+ if ( m_DBWizardMode )
+ {
+ switch ( eType )
+ {
+ case ::dbaccess::DST_MYSQL_JDBC:
+ _inout_rDisplayName = m_sMySQLEntry;
+ break;
+ case ::dbaccess::DST_MYSQL_ODBC:
+ case ::dbaccess::DST_MYSQL_NATIVE:
+ // don't display those, the decision whether the user connects via JDBC/ODBC/C-OOo is made on another
+ // page
+ _inout_rDisplayName = String();
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ( eType == ::dbaccess::DST_MYSQL_NATIVE_DIRECT )
+ {
+ // do not display the Connector/OOo driver itself, it is always wrapped via the MySQL-Driver, if
+ // this driver is installed
+ if ( m_pCollection->hasDriver( "sdbc:mysql:mysqlc:" ) )
+ _inout_rDisplayName = String();
+ }
+
+ if ( eType == ::dbaccess::DST_EMBEDDED_HSQLDB )
+ _inout_rDisplayName = String();
+
+ return _inout_rDisplayName.Len() > 0;
+ }
+
+
+ // -----------------------------------------------------------------------
+ void OGeneralPage::insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName)
+ {
+ // insert a (temporary) entry
+ sal_uInt16 nPos = m_pDatasourceType->InsertEntry(sDisplayName);
+ if ( nPos >= m_aURLPrefixes.size() )
+ m_aURLPrefixes.resize(nPos+1);
+ m_aURLPrefixes[nPos] = _sType;
+ }
+
+ // -----------------------------------------------------------------------
+ void OGeneralPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePreLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aDatasourceTypeLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aTypePostLabel));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aSpecialMessage));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aFTDataSourceAppendix));
+ }
+ // -----------------------------------------------------------------------
+ void OGeneralPage::fillControls(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new OSaveValueWrapper<ListBox>(m_pDatasourceType.get()));
+ }
+
+ //-------------------------------------------------------------------------
+ SfxTabPage* OGeneralPage::Create(Window* _pParent, const SfxItemSet& _rAttrSet, sal_Bool _bWizardMode)
+ {
+ return ( new OGeneralPage( _pParent, _rAttrSet, _bWizardMode ) );
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::implSetCurrentType( const ::rtl::OUString& _eType )
+ {
+ if ( _eType == m_eCurrentSelection )
+ return;
+
+ m_eCurrentSelection = _eType;
+ }
+
+ //-------------------------------------------------------------------------
+ void OGeneralPage::Reset(const SfxItemSet& _rCoreAttrs)
+ {
+ // reset all locale data
+ implSetCurrentType( ::rtl::OUString() );
+ // this ensures that our type selection link will be called, even if the new is is the same as the
+ // current one
+ OGenericAdministrationPage::Reset(_rCoreAttrs);
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool OGeneralPage::FillItemSet(SfxItemSet& _rCoreAttrs)
+ {
+ sal_Bool bChangedSomething = sal_False;
+
+ bool bCommitTypeSelection = true;
+ if ( m_DBWizardMode )
+ {
+ if ( m_aRB_CreateDatabase.IsChecked() )
+ {
+ _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:"))));
+ bChangedSomething = sal_True;
+ bCommitTypeSelection = false;
+ }
+ else if ( m_aRB_OpenDocument.IsChecked() )
+ {
+ if ( m_aRB_OpenDocument.GetSavedValue() != m_aRB_OpenDocument.IsChecked() )
+ bChangedSomething = sal_True;
+
+ // TODO
+ bCommitTypeSelection = false;
+ }
+ }
+
+ if ( bCommitTypeSelection )
+ {
+ sal_uInt16 nEntry = m_pDatasourceType->GetSelectEntryPos();
+ ::rtl::OUString sURLPrefix = m_aURLPrefixes[nEntry];
+ if (m_DBWizardMode)
+ {
+ if ( ( m_pDatasourceType->GetSavedValue() != nEntry )
+ || ( GetDatabaseCreationMode() != m_eOriginalCreationMode )
+ )
+ {
+ _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL,sURLPrefix ));
+ bChangedSomething = sal_True;
+ }
+ else
+ implSetCurrentType(sURLPrefix);
+ }
+ else
+ {
+ if ( m_pDatasourceType->GetSavedValue() != nEntry)
+ {
+ _rCoreAttrs.Put(SfxStringItem(DSID_CONNECTURL, sURLPrefix));
+ bChangedSomething = sal_True;
+ }
+ }
+ }
+ return bChangedSomething;
+ }
+
+ //-------------------------------------------------------------------------
+ IMPL_LINK(OGeneralPage, OnDatasourceTypeSelected, ListBox*, _pBox)
+ {
+ // get the type from the entry data
+ sal_Int16 nSelected = _pBox->GetSelectEntryPos();
+ const ::rtl::OUString sURLPrefix = m_aURLPrefixes[nSelected];
+
+ setParentTitle(sURLPrefix);
+ // let the impl method do all the stuff
+ onTypeSelected(sURLPrefix);
+ // tell the listener we were modified
+ callModifiedHdl();
+ // outta here
+ return 0L;
+ }
+
+ //-------------------------------------------------------------------------
+ OGeneralPage::DocumentDescriptor OGeneralPage::GetSelectedDocument() const
+ {
+ DocumentDescriptor aDocument;
+ if ( m_aBrowsedDocument.sURL.Len() )
+ aDocument = m_aBrowsedDocument;
+ else
+ {
+ aDocument.sURL = m_pLB_DocumentList->GetSelectedDocumentURL();
+ aDocument.sFilter = m_pLB_DocumentList->GetSelectedDocumentFilter();
+ }
+ return aDocument;
+ }
+
+ //-------------------------------------------------------------------------
+ IMPL_LINK(OGeneralPage, OnSetupModeSelected, RadioButton*, /*_pBox*/)
+ {
+ if ( m_aCreationModeHandler.IsSet() )
+ m_aCreationModeHandler.Call(this);
+ return 1L;
+ }
+
+ //-------------------------------------------------------------------------
+ IMPL_LINK(OGeneralPage, OnDocumentSelected, ListBox*, /*_pBox*/)
+ {
+ m_aDocumentSelectionHandler.Call( this );
+ return 0L;
+ }
+
+ //-------------------------------------------------------------------------
+ IMPL_LINK(OGeneralPage, OnOpenDocument, PushButton*, /*_pBox*/)
+ {
+ ::sfx2::FileDialogHelper aFileDlg( WB_OPEN, ::String::CreateFromAscii("sdatabase") );
+ const SfxFilter* pFilter = getStandardDatabaseFilter();
+ if ( pFilter )
+ {
+ aFileDlg.SetCurrentFilter(pFilter->GetUIName());
+ }
+ if ( aFileDlg.Execute() == ERRCODE_NONE )
+ {
+ String sPath = aFileDlg.GetPath();
+ if ( aFileDlg.GetCurrentFilter() != pFilter->GetUIName() || !pFilter->GetWildcard().Matches(sPath) )
+ {
+ String sMessage(ModuleRes(STR_ERR_USE_CONNECT_TO));
+ InfoBox aError(this, sMessage);
+ aError.Execute();
+ m_aRB_GetExistingDatabase.Check();
+ OnSetupModeSelected(&m_aRB_GetExistingDatabase);
+ return 0L;
+ }
+ m_aBrowsedDocument.sURL = sPath;
+ m_aBrowsedDocument.sFilter = String();
+ m_aChooseDocumentHandler.Call( this );
+ return 1L;
+ }
+
+ return 0L;
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx
new file mode 100644
index 000000000000..5bd2dbe189fa
--- /dev/null
+++ b/dbaccess/source/ui/dlg/generalpage.hxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_GENERALPAGE_HXX_
+#define _DBAUI_GENERALPAGE_HXX_
+
+#include "adminpages.hxx"
+#include "opendoccontrols.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <svtools/dialogcontrolling.hxx>
+#include <memory>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ class IDatabaseSettingsDialog;
+ //=========================================================================
+ //= OGeneralPage
+ //=========================================================================
+ class OGeneralPage : public OGenericAdministrationPage
+ {
+ OGeneralPage(Window* pParent, const SfxItemSet& _rItems, sal_Bool _bDBWizardMode = sal_False);
+ ~OGeneralPage();
+
+ public:
+ enum CreationMode
+ {
+ eCreateNew,
+ eConnectExternal,
+ eOpenExisting
+ };
+
+ struct DocumentDescriptor
+ {
+ String sURL;
+ String sFilter;
+ };
+
+ private:
+ // dialog controls
+ FixedText m_aFTHeaderText;
+ FixedText m_aFTHelpText;
+ FixedText m_aFT_DatasourceTypeHeader;
+ RadioButton m_aRB_CreateDatabase;
+ RadioButton m_aRB_OpenDocument;
+ RadioButton m_aRB_GetExistingDatabase;
+ FixedText m_aFT_DocListLabel;
+ ::std::auto_ptr< OpenDocumentListBox >
+ m_pLB_DocumentList;
+ OpenDocumentButton m_aPB_OpenDocument;
+ FixedText m_aTypePreLabel;
+ FixedText m_aDatasourceTypeLabel;
+ ::std::auto_ptr< ListBox >
+ m_pDatasourceType;
+ FixedText m_aFTDataSourceAppendix;
+ FixedText m_aTypePostLabel;
+ FixedText m_aSpecialMessage;
+ sal_Bool m_DBWizardMode;
+ String m_sMySQLEntry;
+ CreationMode m_eOriginalCreationMode;
+ DocumentDescriptor m_aBrowsedDocument;
+
+ ::svt::ControlDependencyManager
+ m_aControlDependencies;
+ ::std::vector< ::rtl::OUString> m_aURLPrefixes;
+
+
+ ::dbaccess::ODsnTypeCollection*
+ m_pCollection; /// the DSN type collection instance
+ ::rtl::OUString m_eCurrentSelection; /// currently selected type
+ ::dbaccess::DATASOURCE_TYPE m_eNotSupportedKnownType; /// if a data source of an unsupported, but known type is encountered ....
+
+ enum SPECIAL_MESSAGE
+ {
+ smNone,
+ smUnsupportedType
+ };
+ SPECIAL_MESSAGE m_eLastMessage;
+
+ Link m_aTypeSelectHandler; /// to be called if a new type is selected
+ Link m_aCreationModeHandler; /// to be called if a new type is selected
+ Link m_aDocumentSelectionHandler; /// to be called when a document in the RecentDoc list is selected
+ Link m_aChooseDocumentHandler; /// to be called when a recent document has been definately chosen
+ sal_Bool m_bDisplayingInvalid : 1; // the currently displayed data source is deleted
+ sal_Bool m_bUserGrabFocus : 1;
+ bool m_bInitTypeList : 1;
+ bool approveDataSourceType( const ::rtl::OUString& _sURLPrefix, String& _inout_rDisplayName );
+ void insertDatasourceTypeEntryData(const ::rtl::OUString& _sType, String sDisplayName);
+
+ public:
+ static SfxTabPage* Create(Window* pParent, const SfxItemSet& _rAttrSet, sal_Bool _bDBWizardMode = sal_False);
+
+ /// set a handler which gets called every time the user selects a new type
+ void SetTypeSelectHandler(const Link& _rHandler) { m_aTypeSelectHandler = _rHandler; }
+ void SetCreationModeHandler(const Link& _rHandler) { m_aCreationModeHandler = _rHandler; }
+ void SetDocumentSelectionHandler( const Link& _rHandler) { m_aDocumentSelectionHandler = _rHandler; }
+ void SetChooseDocumentHandler( const Link& _rHandler) { m_aChooseDocumentHandler = _rHandler; }
+ CreationMode GetDatabaseCreationMode() const;
+
+ DocumentDescriptor GetSelectedDocument() const;
+
+ /// get the currently selected datasource type
+ ::rtl::OUString GetSelectedType() const { return m_eCurrentSelection; }
+
+ protected:
+ // SfxTabPage overridables
+ virtual sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
+ virtual void Reset(const SfxItemSet& _rCoreAttrs);
+
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ virtual void GetFocus();
+
+ // <method>OGenericAdministrationPage::fillControls</method>
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ // <method>OGenericAdministrationPage::fillWindows</method>
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ protected:
+
+ void onTypeSelected(const ::rtl::OUString& _sURLPrefix);
+ void initializeTypeList();
+
+ void implSetCurrentType( const ::rtl::OUString& _eType );
+
+ void switchMessage(const ::rtl::OUString& _sURLPrefix);
+
+ /// sets the the title of the parent dialog
+ void setParentTitle(const ::rtl::OUString& _sURLPrefix);
+
+ DECL_LINK(OnDatasourceTypeSelected, ListBox*);
+ DECL_LINK(OnSetupModeSelected, RadioButton*);
+ DECL_LINK(OnDocumentSelected, ListBox*);
+ DECL_LINK(OnOpenDocument, PushButton*);
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+#endif // _DBAUI_GENERALPAGE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx
new file mode 100644
index 000000000000..d4480c464d59
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.cxx
@@ -0,0 +1,925 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "indexdialog.hxx"
+#include "dbu_dlg.hrc"
+#include "dbaccess_helpid.hrc"
+#include "indexdialog.hrc"
+#include "indexfieldscontrol.hxx"
+#include "indexcollection.hxx"
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include "UITools.hxx"
+#include <svtools/imgdef.hxx>
+#include "browserids.hxx"
+#include <connectivity/dbtools.hxx>
+#include <osl/diagnose.h>
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::lang;
+ using namespace ::dbtools;
+
+ //==================================================================
+ //= helper
+ //==================================================================
+ //------------------------------------------------------------------
+ sal_Bool operator ==(const OIndexField& _rLHS, const OIndexField& _rRHS)
+ {
+ return (_rLHS.sFieldName == _rRHS.sFieldName)
+ && (_rLHS.bSortAscending == _rRHS.bSortAscending);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator !=(const OIndexField& _rLHS, const OIndexField& _rRHS)
+ {
+ return !(_rLHS == _rRHS);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator ==(const IndexFields& _rLHS, const IndexFields& _rRHS)
+ {
+ if (_rLHS.size() != _rRHS.size())
+ return sal_False;
+
+ ConstIndexFieldsIterator aLeft = _rLHS.begin();
+ ConstIndexFieldsIterator aLeftEnd = _rLHS.end();
+ ConstIndexFieldsIterator aRight = _rRHS.begin();
+ for (; aLeft != aLeftEnd; ++aLeft, ++aRight)
+ {
+ if (*aLeft != *aRight)
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool operator !=(const IndexFields& _rLHS, const IndexFields& _rRHS)
+ {
+ return !(_rLHS == _rRHS);
+ }
+
+ //==================================================================
+ //= DbaIndexList
+ //==================================================================
+ //------------------------------------------------------------------
+ DbaIndexList::DbaIndexList(Window* _pParent, const ResId& _rId)
+ :SvTreeListBox(_pParent, _rId)
+ ,m_bSuspendSelectHdl(sal_False)
+ {
+ }
+
+ extern sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const ::rtl::OUString& _sAllowedChars);
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexList::EditedEntry( SvLBoxEntry* _pEntry, const String& _rNewText )
+ {
+ // first check if this is valid SQL92 name
+ if ( isSQL92CheckEnabled(m_xConnection) )
+ {
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ if ( xMeta.is() )
+ {
+ ::rtl::OUString sNewName(_rNewText);
+ ::rtl::OUString sAlias = ::dbtools::convertName2SQLName(sNewName,xMeta->getExtraNameCharacters());
+ if ( ( xMeta->supportsMixedCaseQuotedIdentifiers() )
+ ?
+ sAlias != sNewName
+ :
+ !sNewName.equalsIgnoreAsciiCase(sAlias))
+ return sal_False;
+ }
+ }
+
+ if (!SvTreeListBox::EditedEntry(_pEntry, _rNewText))
+ return sal_False;
+
+ String sOldText = GetEntryText(_pEntry);
+ SvTreeListBox::SetEntryText(_pEntry, _rNewText);
+
+ sal_Bool bValid = sal_True;
+ if (m_aEndEditHdl.IsSet())
+ bValid = (0 != m_aEndEditHdl.Call(_pEntry));
+
+ if (bValid)
+ return sal_True;
+
+ SvTreeListBox::SetEntryText(_pEntry, sOldText);
+
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::enableSelectHandler()
+ {
+ OSL_ENSURE(m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!");
+ m_bSuspendSelectHdl = sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::disableSelectHandler()
+ {
+ OSL_ENSURE(!m_bSuspendSelectHdl, "DbaIndexList::enableSelectHandler: invalid call (this is not cumulative)!");
+ m_bSuspendSelectHdl = sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexList::SelectNoHandlerCall( SvLBoxEntry* _pEntry )
+ {
+ disableSelectHandler();
+ Select(_pEntry, sal_True);
+ enableSelectHandler();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexList::Select( SvLBoxEntry* pEntry, sal_Bool _bSelect )
+ {
+ sal_Bool bReturn = SvTreeListBox::Select(pEntry, _bSelect);
+
+ if (m_aSelectHdl.IsSet() && !m_bSuspendSelectHdl && _bSelect)
+ m_aSelectHdl.Call(this);
+
+ return bReturn;
+ }
+
+ //==================================================================
+ //= DbaIndexDialog
+ //==================================================================
+DBG_NAME(DbaIndexDialog)
+//------------------------------------------------------------------
+ DbaIndexDialog::DbaIndexDialog( Window* _pParent, const Sequence< ::rtl::OUString >& _rFieldNames,
+ const Reference< XNameAccess >& _rxIndexes,
+ const Reference< XConnection >& _rxConnection,
+ const Reference< XMultiServiceFactory >& _rxORB,sal_Int32 _nMaxColumnsInIndex)
+ :ModalDialog( _pParent, ModuleRes(DLG_INDEXDESIGN))
+ ,m_xConnection(_rxConnection)
+ ,m_aGeometrySettings(E_DIALOG, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("dbaccess.tabledesign.indexdialog")))
+ ,m_aActions (this, ModuleRes(TLB_ACTIONS))
+ ,m_aIndexes (this, ModuleRes(CTR_INDEXLIST))
+ ,m_aIndexDetails (this, ModuleRes(FL_INDEXDETAILS))
+ ,m_aDescriptionLabel (this, ModuleRes(FT_DESC_LABEL))
+ ,m_aDescription (this, ModuleRes(FT_DESCRIPTION))
+ ,m_aUnique (this, ModuleRes(CB_UNIQUE))
+ ,m_aFieldsLabel (this, ModuleRes(FT_FIELDS))
+ ,m_pFields(new IndexFieldsControl (this, ModuleRes(CTR_FIELDS),_nMaxColumnsInIndex,::dbtools::getBooleanDataSourceSetting( m_xConnection, "AddIndexAppendix" )))
+ ,m_aClose (this, ModuleRes(PB_CLOSE))
+ ,m_aHelp (this, ModuleRes(HB_HELP))
+ ,m_pIndexes(NULL)
+ ,m_pPreviousSelection(NULL)
+ ,m_bEditAgain(sal_False)
+ ,m_xORB(_rxORB)
+ {
+ DBG_CTOR(DbaIndexDialog,NULL);
+
+ FreeResource();
+
+ m_aActions.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexAction));
+
+ m_aIndexes.SetSelectHdl(LINK(this, DbaIndexDialog, OnIndexSelected));
+ m_aIndexes.SetEndEditHdl(LINK(this, DbaIndexDialog, OnEntryEdited));
+ m_aIndexes.SetSelectionMode(SINGLE_SELECTION);
+ m_aIndexes.SetHighlightRange();
+ m_aIndexes.setConnection(m_xConnection);
+
+ m_pFields->Init(_rFieldNames);
+
+ setToolBox(&m_aActions);
+
+ m_pIndexes = new OIndexCollection();
+ try
+ {
+ m_pIndexes->attach(_rxIndexes);
+ }
+ catch(SQLException& e)
+ {
+ ::dbaui::showError(SQLExceptionInfo(e),_pParent,_rxORB);
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("DbaIndexDialog::DbaIndexDialog: could not retrieve basic information from the UNO collection!");
+ }
+
+ fillIndexList();
+
+ m_aUnique.SetClickHdl(LINK(this, DbaIndexDialog, OnModified));
+ m_pFields->SetModifyHdl(LINK(this, DbaIndexDialog, OnModified));
+
+ m_aClose.SetClickHdl(LINK(this, DbaIndexDialog, OnCloseDialog));
+
+ // if all of the indexes have an empty description, we're not interested in displaying it
+ Indexes::const_iterator aCheck;
+
+ for ( aCheck = m_pIndexes->begin();
+ aCheck != m_pIndexes->end();
+ ++aCheck
+ )
+ {
+ if (aCheck->sDescription.getLength())
+ break;
+ }
+
+ if (aCheck == m_pIndexes->end())
+ {
+ sal_Int32 nMoveUp = m_aUnique.GetPosPixel().Y() - m_aDescriptionLabel.GetPosPixel().Y();
+
+ // hide the controls which are necessary for the description
+ m_aDescription.Hide();
+ m_aDescriptionLabel.Hide();
+
+ // move other controls up
+ Point aPos = m_aUnique.GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_aUnique.SetPosPixel(aPos);
+
+ aPos = m_aFieldsLabel.GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_aFieldsLabel.SetPosPixel(aPos);
+
+ aPos = m_pFields->GetPosPixel();
+ aPos.Y() -= nMoveUp;
+ m_pFields->SetPosPixel(aPos);
+
+ // and enlarge the fields list
+ Size aSize = m_pFields->GetSizePixel();
+ aSize.Height() += nMoveUp;
+ m_pFields->SetSizePixel(aSize);
+ }
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::updateToolbox()
+ {
+ m_aActions.EnableItem(ID_INDEX_NEW, !m_aIndexes.IsEditingActive());
+
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ sal_Bool bSelectedAnything = NULL != pSelected;
+
+
+ if (pSelected)
+ {
+ // is the current entry modified?
+ Indexes::const_iterator aSelectedPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData());
+ m_aActions.EnableItem(ID_INDEX_SAVE, aSelectedPos->isModified() || aSelectedPos->isNew());
+ m_aActions.EnableItem(ID_INDEX_RESET, aSelectedPos->isModified() || aSelectedPos->isNew());
+ bSelectedAnything = bSelectedAnything && !aSelectedPos->bPrimaryKey;
+ }
+ else
+ {
+ m_aActions.EnableItem(ID_INDEX_SAVE, sal_False);
+ m_aActions.EnableItem(ID_INDEX_RESET, sal_False);
+ }
+ m_aActions.EnableItem(ID_INDEX_DROP, bSelectedAnything);
+ m_aActions.EnableItem(ID_INDEX_RENAME, bSelectedAnything);
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::fillIndexList()
+ {
+ Image aPKeyIcon(ModuleRes( IMG_PKEYICON ));
+ // fill the list with the index names
+ m_aIndexes.Clear();
+ Indexes::iterator aIndexLoop = m_pIndexes->begin();
+ Indexes::iterator aEnd = m_pIndexes->end();
+ for (; aIndexLoop != aEnd; ++aIndexLoop)
+ {
+ SvLBoxEntry* pNewEntry = NULL;
+ if (aIndexLoop->bPrimaryKey)
+ pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName, aPKeyIcon, aPKeyIcon);
+ else
+ pNewEntry = m_aIndexes.InsertEntry(aIndexLoop->sName);
+
+ pNewEntry->SetUserData(reinterpret_cast< void* >(sal_Int32(aIndexLoop - m_pIndexes->begin())));
+ }
+
+ OnIndexSelected(&m_aIndexes);
+ }
+
+ //------------------------------------------------------------------
+ DbaIndexDialog::~DbaIndexDialog( )
+ {
+ setToolBox(NULL);
+ delete m_pIndexes;
+ delete m_pFields;
+
+ DBG_DTOR(DbaIndexDialog,NULL);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCommit(SvLBoxEntry* _pEntry)
+ {
+ OSL_ENSURE(_pEntry, "DbaIndexDialog::implCommit: invalid entry!");
+
+ Indexes::iterator aCommitPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData());
+
+ // if it's not a new index, remove it
+ // (we can't modify indexes, only drop'n'insert)
+ if (!aCommitPos->isNew())
+ if (!implDropIndex(_pEntry, sal_False))
+ return sal_False;
+
+ // create the new index
+ SQLExceptionInfo aExceptionInfo;
+ try
+ {
+ m_pIndexes->commitNewIndex(aCommitPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ // reflect the new selection in the toolbox
+ updateToolbox();
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+ else
+ {
+ m_aUnique.SaveValue();
+ m_pFields->SaveValue();
+ }
+
+ return !aExceptionInfo.isValid();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnNewIndex()
+ {
+ // commit the current entry, if necessary
+ if (!implCommitPreviouslySelected())
+ return;
+
+ // get a new unique name for the new index
+ String sNewIndexName;
+ const String sNewIndexNameBase(ModuleRes(STR_LOGICAL_INDEX_NAME));
+ sal_Int32 i;
+
+ for ( i = 1; i < 0x7FFFFFFF; ++i )
+ {
+ sNewIndexName = sNewIndexNameBase;
+ sNewIndexName += String::CreateFromInt32(i);
+ if (m_pIndexes->end() == m_pIndexes->find(sNewIndexName))
+ break;
+ }
+ if ((i>0x7FFFFFFF) || (i<0))
+ {
+ OSL_FAIL("DbaIndexDialog::OnNewIndex: no free index name found!");
+ // can't do anything ... of course we try another base, but this could end with the same result ...
+ return;
+ }
+
+ SvLBoxEntry* pNewEntry = m_aIndexes.InsertEntry(sNewIndexName);
+ m_pIndexes->insert(sNewIndexName);
+
+ // update the user data on the entries in the list box:
+ // they're iterators of the index collection, and thus they have changed when removing the index
+ for (SvLBoxEntry* pAdjust = m_aIndexes.First(); pAdjust; pAdjust = m_aIndexes.Next(pAdjust))
+ {
+ Indexes::iterator aAfterInsertPos = m_pIndexes->find(m_aIndexes.GetEntryText(pAdjust));
+ OSL_ENSURE(aAfterInsertPos != m_pIndexes->end(), "DbaIndexDialog::OnNewIndex: problems with on of the entries!");
+ pAdjust->SetUserData(reinterpret_cast< void* >(sal_Int32(aAfterInsertPos - m_pIndexes->begin())));
+ }
+
+ // select the entry and start in-place editing
+ m_aIndexes.SelectNoHandlerCall(pNewEntry);
+ OnIndexSelected(&m_aIndexes);
+ m_aIndexes.EditEntry(pNewEntry);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnDropIndex(sal_Bool _bConfirm)
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ OSL_ENSURE(pSelected, "DbaIndexDialog::OnDropIndex: invalid call!");
+ if (pSelected)
+ {
+ // let the user confirm the drop
+ if (_bConfirm)
+ {
+ String sConfirm(ModuleRes(STR_CONFIRM_DROP_INDEX));
+ sConfirm.SearchAndReplaceAscii("$name$", m_aIndexes.GetEntryText(pSelected));
+ QueryBox aConfirm(this, WB_YES_NO, sConfirm);
+ if (RET_YES != aConfirm.Execute())
+ return;
+ }
+
+ // do the drop
+ implDropIndex(pSelected, sal_True);
+
+ // reflect the new selection in the toolbox
+ updateToolbox();
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection)
+ {
+ // do the drop
+ Indexes::iterator aDropPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData());
+ OSL_ENSURE(aDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: did not find the index in my collection!");
+
+ SQLExceptionInfo aExceptionInfo;
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ if (_bRemoveFromCollection)
+ bSuccess = m_pIndexes->drop(aDropPos);
+ else
+ bSuccess = m_pIndexes->dropNoRemove(aDropPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+ else if (bSuccess && _bRemoveFromCollection)
+ {
+ SvLBoxTreeList* pModel = m_aIndexes.GetModel();
+
+ m_aIndexes.disableSelectHandler();
+ pModel->Remove(_pEntry);
+ m_aIndexes.enableSelectHandler();
+
+ // update the user data on the entries in the list box:
+ // they're iterators of the index collection, and thus they have changed when removing the index
+ for (SvLBoxEntry* pAdjust = m_aIndexes.First(); pAdjust; pAdjust = m_aIndexes.Next(pAdjust))
+ {
+ Indexes::iterator aAfterDropPos = m_pIndexes->find(m_aIndexes.GetEntryText(pAdjust));
+ OSL_ENSURE(aAfterDropPos != m_pIndexes->end(), "DbaIndexDialog::OnDropIndex: problems with on of the remaining entries!");
+ pAdjust->SetUserData(reinterpret_cast< void* >(sal_Int32(aAfterDropPos - m_pIndexes->begin())));
+ }
+
+ // if the remvoved entry was the selected on ...
+ if (m_pPreviousSelection == _pEntry)
+ m_pPreviousSelection = NULL;
+
+ // the Remove automatically selected another entry (if possible), but we disabled the calling of the handler
+ // to prevent that we missed something ... call the handler directly
+ OnIndexSelected(&m_aIndexes);
+ }
+
+ return !aExceptionInfo.isValid();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnRenameIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ OSL_ENSURE(pSelected, "DbaIndexDialog::OnRenameIndex: invalid call!");
+
+ // save the changes made 'til here
+ // Upon leaving the edit mode, the control will be re-initialized with the
+ // settings from the current entry
+ implSaveModified(sal_False);
+
+ m_aIndexes.EditEntry(pSelected);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnSaveIndex()
+ {
+ // the selected index
+#if OSL_DEBUG_LEVEL > 0
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ OSL_ENSURE( pSelected, "DbaIndexDialog::OnSaveIndex: invalid call!" );
+#endif
+
+ implCommitPreviouslySelected();
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::OnResetIndex()
+ {
+ // the selected index
+ SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ OSL_ENSURE(pSelected, "DbaIndexDialog::OnResetIndex: invalid call!");
+
+ Indexes::iterator aResetPos = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData());
+
+ if (aResetPos->isNew())
+ {
+ OnDropIndex(sal_False);
+ return;
+ }
+
+ SQLExceptionInfo aExceptionInfo;
+ try
+ {
+ m_pIndexes->resetIndex(aResetPos);
+ }
+ catch(SQLContext& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aExceptionInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aExceptionInfo = SQLExceptionInfo(e); }
+
+ if (aExceptionInfo.isValid())
+ showError(aExceptionInfo, this, m_xORB);
+ else
+ m_aIndexes.SetEntryText(pSelected, aResetPos->sName);
+
+ updateControls(pSelected);
+ updateToolbox();
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnIndexAction, ToolBox*, /*NOTINTERESTEDIN*/ )
+ {
+ sal_uInt16 nClicked = m_aActions.GetCurItemId();
+ switch (nClicked)
+ {
+ case ID_INDEX_NEW:
+ OnNewIndex();
+ break;
+ case ID_INDEX_DROP:
+ OnDropIndex();
+ break;
+ case ID_INDEX_RENAME:
+ OnRenameIndex();
+ break;
+ case ID_INDEX_SAVE:
+ OnSaveIndex();
+ break;
+ case ID_INDEX_RESET:
+ OnResetIndex();
+ break;
+ }
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnCloseDialog, void*, /*NOTINTERESTEDIN*/ )
+ {
+ if (m_aIndexes.IsEditingActive())
+ {
+ OSL_ENSURE(!m_bEditAgain, "DbaIndexDialog::OnCloseDialog: somebody was faster than hell!");
+ // this means somebody entered a new name, which was invalid, which cause us to posted us an event,
+ // and before the event arrived the user clicked onto "close". VERY fast, this user ....
+ m_aIndexes.EndEditing(sal_False);
+ if (m_bEditAgain)
+ // could not commit the new name (started a new - asynchronous - edit trial)
+ return 1L;
+ }
+
+ // the currently selected entry
+ const SvLBoxEntry* pSelected = m_aIndexes.FirstSelected();
+ OSL_ENSURE(pSelected == m_pPreviousSelection, "DbaIndexDialog::OnCloseDialog: inconsistence!");
+
+ sal_Int32 nResponse = RET_NO;
+ if (pSelected)
+ {
+ // the descriptor
+ Indexes::const_iterator aSelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(pSelected->GetUserData());
+
+ if (aSelected->isModified() || aSelected->isNew())
+ {
+ QueryBox aQuestion(this, ModuleRes(QUERY_SAVE_CURRENT_INDEX));
+ nResponse = aQuestion.Execute();
+ }
+ }
+
+ switch (nResponse)
+ {
+ case RET_YES:
+ if (!implCommitPreviouslySelected())
+ return 1L;
+ break;
+ case RET_NO:
+ break;
+ default:
+ return 1L;
+ }
+
+ EndDialog(RET_OK);
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnEditIndexAgain, SvLBoxEntry*, _pEntry )
+ {
+ m_bEditAgain = sal_False;
+ m_aIndexes.EditEntry(_pEntry);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnEntryEdited, SvLBoxEntry*, _pEntry )
+ {
+ Indexes::iterator aPosition = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData());
+
+ OSL_ENSURE(aPosition >= m_pIndexes->begin() && aPosition < m_pIndexes->end(),
+ "DbaIndexDialog::OnEntryEdited: invalid entry!");
+
+ String sNewName = m_aIndexes.GetEntryText(_pEntry);
+
+ Indexes::const_iterator aSameName = m_pIndexes->find(sNewName);
+ if ((aSameName != aPosition) && (m_pIndexes->end() != aSameName))
+ {
+ String sError(ModuleRes(STR_INDEX_NAME_ALREADY_USED));
+ sError.SearchAndReplaceAscii("$name$", sNewName);
+ ErrorBox aError(this, WB_OK, sError);
+ aError.Execute();
+
+ updateToolbox();
+ m_bEditAgain = sal_True;
+ PostUserEvent(LINK(this, DbaIndexDialog, OnEditIndexAgain), _pEntry);
+ return 0L;
+ }
+
+ aPosition->sName = sNewName;
+
+ // rename can be done by a drop/insert combination only
+ if (aPosition->isNew())
+ {
+ updateToolbox();
+ // no commitment needed here ....
+ return 1L;
+ }
+
+ if (aPosition->sName != aPosition->getOriginalName())
+ {
+ aPosition->setModified(sal_True);
+ updateToolbox();
+ }
+
+ return 1L;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implSaveModified(sal_Bool _bPlausibility)
+ {
+ if (m_pPreviousSelection)
+ {
+ // try to commit the previously selected index
+ if (m_pFields->IsModified() && !m_pFields->SaveModified())
+ return sal_False;
+
+ Indexes::iterator aPreviouslySelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData());
+
+ // the unique flag
+ aPreviouslySelected->bUnique = m_aUnique.IsChecked();
+ if (m_aUnique.GetSavedValue() != m_aUnique.GetState())
+ aPreviouslySelected->setModified(sal_True);
+
+ // the fields
+ m_pFields->commitTo(aPreviouslySelected->aFields);
+ if (m_pFields->GetSavedValue() != aPreviouslySelected->aFields)
+ aPreviouslySelected->setModified(sal_True);
+
+ // plausibility checks
+ if (_bPlausibility && !implCheckPlausibility(aPreviouslySelected))
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCheckPlausibility(const ConstIndexesIterator& _rPos)
+ {
+ // need at least one field
+ if (0 == _rPos->aFields.size())
+ {
+ ErrorBox aError(this, ModuleRes(ERR_NEED_INDEX_FIELDS));
+ aError.Execute();
+ m_pFields->GrabFocus();
+ return sal_False;
+ }
+
+ // no double fields
+ DECLARE_STL_STDKEY_SET( String, StringBag );
+ StringBag aExistentFields;
+ for ( ConstIndexFieldsIterator aFieldCheck = _rPos->aFields.begin();
+ aFieldCheck != _rPos->aFields.end();
+ ++aFieldCheck
+ )
+ {
+ if (aExistentFields.end() != aExistentFields.find(aFieldCheck->sFieldName))
+ {
+ // a column is specified twice ... won't work anyway, so prevent this here and now
+ String sMessage(ModuleRes(STR_INDEXDESIGN_DOUBLE_COLUMN_NAME));
+ sMessage.SearchAndReplaceAscii("$name$", aFieldCheck->sFieldName);
+ ErrorBox aError(this, WB_OK, sMessage);
+ aError.Execute();
+ m_pFields->GrabFocus();
+ return sal_False;
+ }
+ aExistentFields.insert(aFieldCheck->sFieldName);
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool DbaIndexDialog::implCommitPreviouslySelected()
+ {
+ if (m_pPreviousSelection)
+ {
+ Indexes::iterator aPreviouslySelected = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData());
+
+ if (!implSaveModified())
+ return sal_False;
+
+ // commit the index (if necessary)
+ if (aPreviouslySelected->isModified() && !implCommit(m_pPreviousSelection))
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnModified, void*, /*NOTINTERESTEDIN*/ )
+ {
+ OSL_ENSURE(m_pPreviousSelection, "DbaIndexDialog, OnModified: invalid call!");
+ Indexes::iterator aPosition = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(m_pPreviousSelection->GetUserData());
+
+ aPosition->setModified(sal_True);
+ updateToolbox();
+
+ return 1L;
+ }
+
+ //------------------------------------------------------------------
+ void DbaIndexDialog::updateControls(const SvLBoxEntry* _pEntry)
+ {
+ if (_pEntry)
+ {
+ // the descriptor of the selected index
+ Indexes::const_iterator aSelectedIndex = m_pIndexes->begin() + reinterpret_cast<sal_IntPtr>(_pEntry->GetUserData());
+
+ // fill the controls
+ m_aUnique.Check(aSelectedIndex->bUnique);
+ m_aUnique.Enable(!aSelectedIndex->bPrimaryKey);
+ m_aUnique.SaveValue();
+
+ m_pFields->initializeFrom(aSelectedIndex->aFields);
+ m_pFields->Enable(!aSelectedIndex->bPrimaryKey);
+ m_pFields->SaveValue();
+
+ m_aDescription.SetText(aSelectedIndex->sDescription);
+ m_aDescription.Enable(!aSelectedIndex->bPrimaryKey);
+
+ m_aDescriptionLabel.Enable(!aSelectedIndex->bPrimaryKey);
+ }
+ else
+ {
+ m_aUnique.Check(sal_False);
+ m_pFields->initializeFrom(IndexFields());
+ m_aDescription.SetText(String());
+ }
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaIndexDialog, OnIndexSelected, DbaIndexList*, /*NOTINTERESTEDIN*/ )
+ {
+ m_aIndexes.EndSelection();
+
+ if (m_aIndexes.IsEditingActive())
+ m_aIndexes.EndEditing(sal_False);
+
+ // commit the old data
+ if (m_aIndexes.FirstSelected() != m_pPreviousSelection)
+ { // (this call may happen in case somebody ended an in-place edit with 'return', so we need to check this before committing)
+ if (!implCommitPreviouslySelected())
+ {
+ m_aIndexes.SelectNoHandlerCall(m_pPreviousSelection);
+ return 1L;
+ }
+ }
+
+ sal_Bool bHaveSelection = (NULL != m_aIndexes.FirstSelected());
+
+ // disable/enable the detail controls
+ m_aIndexDetails.Enable(bHaveSelection);
+ m_aUnique.Enable(bHaveSelection);
+ m_aDescriptionLabel.Enable(bHaveSelection);
+ m_aFieldsLabel.Enable(bHaveSelection);
+ m_pFields->Enable(bHaveSelection);
+
+ SvLBoxEntry* pNewSelection = m_aIndexes.FirstSelected();
+ updateControls(pNewSelection);
+ if (bHaveSelection)
+ m_aIndexes.GrabFocus();
+
+ m_pPreviousSelection = pNewSelection;
+
+ updateToolbox();
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ void DbaIndexDialog::StateChanged( StateChangedType nType )
+ {
+ ModalDialog::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ checkImageList();
+ }
+ else if ( nType == STATE_CHANGE_TEXT )
+ {
+ // The physical toolbar changed its outlook and shows another logical toolbar!
+ // We have to set the correct high contrast mode on the new tbx manager.
+ // pMgr->SetHiContrast( IsHiContrastMode() );
+ checkImageList();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void DbaIndexDialog::DataChanged( const DataChangedEvent& rDCEvt )
+ {
+ ModalDialog::DataChanged( rDCEvt );
+
+ if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
+ ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) &&
+ ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ checkImageList();
+ }
+ }
+ //------------------------------------------------------------------
+ ImageList DbaIndexDialog::getImageList(sal_Int16 _eBitmapSet) const
+ {
+ sal_Int16 nN = IMG_INDEX_DLG_SC;
+ if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
+ {
+ nN = IMG_INDEX_DLG_LC;
+ }
+ return ImageList( nN );
+ }
+ //------------------------------------------------------------------
+ void DbaIndexDialog::resizeControls(const Size& _rDiff)
+ {
+ // we use large images so we must change them
+ if ( _rDiff.Width() || _rDiff.Height() )
+ {
+ Size aDlgSize = GetSizePixel();
+ // adjust size of dlg
+ SetSizePixel(Size(aDlgSize.Width() + _rDiff.Width(),
+ aDlgSize.Height() + _rDiff.Height())
+ );
+ Size aIndexSize = m_aIndexes.GetSizePixel();
+ m_aIndexes.SetPosSizePixel(m_aIndexes.GetPosPixel() + Point(0,_rDiff.Height()),
+ Size(aIndexSize.Width() + _rDiff.Width(),
+ aIndexSize.Height()));
+
+ //now move the rest to the left side
+ Point aMove(_rDiff.Width(),_rDiff.Height());
+ m_aIndexDetails.SetPosPixel(m_aIndexDetails.GetPosPixel() + aMove);
+ m_aDescriptionLabel.SetPosPixel(m_aDescriptionLabel.GetPosPixel() + aMove);
+ m_aDescription.SetPosPixel(m_aDescription.GetPosPixel() + aMove);
+ m_aUnique.SetPosPixel(m_aUnique.GetPosPixel() + aMove);
+ m_aFieldsLabel.SetPosPixel(m_aFieldsLabel.GetPosPixel() + aMove);
+ OSL_ENSURE(m_pFields,"NO valid fields!");
+ m_pFields->SetPosPixel(m_pFields->GetPosPixel() + aMove);
+ m_aClose.SetPosPixel(m_aClose.GetPosPixel() + aMove);
+ m_aHelp.SetPosPixel(m_aHelp.GetPosPixel() + aMove);
+
+ Invalidate();
+ }
+ }
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/indexdialog.hrc b/dbaccess/source/ui/dlg/indexdialog.hrc
new file mode 100644
index 000000000000..825e96de2edc
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.hrc
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INDEXDIALOG_HRC_
+#define _DBAUI_INDEXDIALOG_HRC_
+
+
+#define CTR_INDEXLIST 1
+#define CTR_FIELDS 2
+
+#define FL_INDEXDETAILS 1
+
+#define CB_UNIQUE 1
+
+#define FT_FIELDS 1
+#define FT_DESC_LABEL 2
+#define FT_DESCRIPTION 3
+
+#define TLB_ACTIONS 1
+
+#define PB_CLOSE 1
+
+#define HB_HELP 1
+
+#endif // _DBAUI_INDEXDIALOG_HRC_
diff --git a/dbaccess/source/ui/dlg/indexdialog.src b/dbaccess/source/ui/dlg/indexdialog.src
new file mode 100644
index 000000000000..2071684c37b6
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexdialog.src
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_INDEXDIALOG_HRC_
+#include "indexdialog.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#define DIALOG_SIZE_X 220
+#define DIALOG_SIZE_Y 140
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+#define LIST_WIDTH 70
+
+ModalDialog DLG_INDEXDESIGN
+{
+ HelpID = "dbaccess:ModalDialog:DLG_INDEXDESIGN";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X , DIALOG_SIZE_Y ) ;
+ Text [ en-US ] = "Indexes" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ ToolBox TLB_ACTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ ButtonType = BUTTON_SYMBOL;
+ Align = BOXALIGN_TOP;
+ HelpId = HID_INDEX_DIALOG_ACTION_TB;
+ Customize = FALSE;
+ ItemImageList = IMG_INDEX_DLG_SC ;
+
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_NEW;
+ HelpId = HID_DLGIDX_NEWINDEX;
+ Command = ".index:createNew";
+ Text [ en-US ] = "New Index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_DROP;
+ HelpId = HID_DLGIDX_DROPINDEX;
+ Command = ".index:dropCurrent";
+ Text [ en-US ] = "Delete Current Index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_RENAME;
+ HelpId = HID_DLGIDX_RENAMEINDEX;
+ Command = ".index:renameCurrent";
+ Text [ en-US ] = "Rename Current Index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_SAVE;
+ HelpId = HID_DLGIDX_SAVEINDEX;
+ Command = ".index:saveCurrent";
+ Text [ en-US ] = "Save Current Index" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = ID_INDEX_RESET;
+ HelpId = HID_DLGIDX_RESETINDEX;
+ Command = ".index:resetCurrent";
+ Text [ en-US ] = "Reset Current Index" ;
+ };
+ };
+ };
+ Control CTR_INDEXLIST
+ {
+ Pos = MAP_APPFONT ( 6 , 23 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 29 ) ;
+ SVLook = TRUE;
+ Border = TRUE;
+
+ HelpId = HID_DLGIDX_INDEXLIST;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_INDEXDETAILS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16 - 3, 9 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ Text [ en-US ] = "Index details";
+ };
+ FixedText FT_DESC_LABEL
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 23 ) ;
+ Size = MAP_APPFONT ( 50, 8 ) ;
+ Text [ en-US ] = "Index identifier:";
+ };
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 69, 23 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 75, 8 ) ;
+ };
+ CheckBox CB_UNIQUE
+ {
+ HelpID = "dbaccess:CheckBox:DLG_INDEXDESIGN:CB_UNIQUE";
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 34 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ SVLook = TRUE;
+ Text [ en-US ] = "~Unique";
+ };
+ FixedText FT_FIELDS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 48 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, 8 ) ;
+ SVLook = TRUE;
+ Text [ en-US ] = "Fields";
+ };
+ Control CTR_FIELDS
+ {
+ Pos = MAP_APPFONT ( LIST_WIDTH + 16, 59 ) ;
+ Size = MAP_APPFONT ( DIALOG_SIZE_X - LIST_WIDTH - 22, DIALOG_SIZE_Y - (BUTTON_SIZE_Y + 4) - 65 ) ;
+ SVLook = TRUE;
+ Border = TRUE;
+ TabStop = TRUE ;
+ };
+ PushButton PB_CLOSE
+ {
+ HelpID = "dbaccess:PushButton:DLG_INDEXDESIGN:PB_CLOSE";
+ Pos = MAP_APPFONT ( DIALOG_SIZE_X - BUTTON_SIZE_X - 6 - BUTTON_SIZE_X - 6, DIALOG_SIZE_Y - BUTTON_SIZE_Y - 6 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ SVLook = TRUE;
+ DefButton = TRUE;
+ Text [ en-US ] = "~Close";
+ };
+ HelpButton HB_HELP
+ {
+ Pos = MAP_APPFONT ( DIALOG_SIZE_X - BUTTON_SIZE_X - 6, DIALOG_SIZE_Y - BUTTON_SIZE_Y - 6 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y );
+ };
+};
+
+String STR_TAB_INDEX_SORTORDER
+{
+ Text [ en-US ] = "Sort order" ;
+};
+
+String STR_TAB_INDEX_FIELD
+{
+ Text [ en-US ] = "Index field" ;
+};
+
+String STR_ORDER_ASCENDING
+{
+ Text [ en-US ] = "Ascending" ;
+};
+
+String STR_ORDER_DESCENDING
+{
+ Text [ en-US ] = "Descending" ;
+};
+
+String STR_CONFIRM_DROP_INDEX
+{
+ Text [ en-US ] = "Do you really want to delete the index '$name$'?";
+};
+
+String STR_LOGICAL_INDEX_NAME
+{
+ Text [ en-US ] = "index";
+};
+
+Image IMG_PKEYICON
+{
+ ImageBitmap = Bitmap { File = "pkey.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+ErrorBox ERR_NEED_INDEX_FIELDS
+{
+ Title [ en-US ] = "Save Index";
+
+ Message [ en-US ] = "The index must contain at least one field.";
+
+ Buttons = WB_OK;
+};
+
+QueryBox QUERY_SAVE_CURRENT_INDEX
+{
+ Title [ en-US ] = "Exit Index Design";
+
+ Message [ en-US ] = "Do you want to save the changes made to the current index?";
+
+ Buttons = WB_YES_NO_CANCEL;
+ DefButton = WB_DEF_YES;
+};
+
+String STR_INDEX_NAME_ALREADY_USED
+{
+ Text [ en-US ] = "There is already another index named \"$name$\".";
+};
+
+String STR_INDEXDESIGN_DOUBLE_COLUMN_NAME
+{
+ Text [ en-US ] = "In an index definition, no table column may occur more than once. However, you have entered column \"$name$\" twice.";
+};
diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
new file mode 100644
index 000000000000..2a85b1a5d58b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx
@@ -0,0 +1,509 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "indexfieldscontrol.hxx"
+#include "dbu_dlg.hrc"
+#include <osl/diagnose.h>
+#include "dbaccess_helpid.hrc"
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+#define BROWSER_STANDARD_FLAGS BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL | \
+ BROWSER_HIDECURSOR | BROWSER_HIDESELECT | BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL
+
+#define COLUMN_ID_FIELDNAME 1
+#define COLUMN_ID_ORDER 2
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::svt;
+
+ //==================================================================
+ //= DbaMouseDownListBoxController
+ //==================================================================
+ class DbaMouseDownListBoxController : public ListBoxCellController
+ {
+ protected:
+ Link m_aOriginalModifyHdl;
+ Link m_aAdditionalModifyHdl;
+
+ public:
+ DbaMouseDownListBoxController(ListBoxControl* _pParent)
+ :ListBoxCellController(_pParent)
+ {
+ }
+
+ void SetAdditionalModifyHdl(const Link& _rHdl);
+
+ protected:
+ virtual sal_Bool WantMouseEvent() const { return sal_True; }
+ virtual void SetModifyHdl(const Link& _rHdl);
+
+ private:
+ void implCheckLinks();
+ DECL_LINK( OnMultiplexModify, void* );
+ };
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::SetAdditionalModifyHdl(const Link& _rHdl)
+ {
+ m_aAdditionalModifyHdl = _rHdl;
+ implCheckLinks();
+ }
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::SetModifyHdl(const Link& _rHdl)
+ {
+ m_aOriginalModifyHdl = _rHdl;
+ implCheckLinks();
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DbaMouseDownListBoxController, OnMultiplexModify, void*, _pArg )
+ {
+ if (m_aAdditionalModifyHdl.IsSet())
+ m_aAdditionalModifyHdl.Call(_pArg);
+ if (m_aOriginalModifyHdl.IsSet())
+ m_aOriginalModifyHdl.Call(_pArg);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ void DbaMouseDownListBoxController::implCheckLinks()
+ {
+ if (m_aAdditionalModifyHdl.IsSet() || m_aOriginalModifyHdl.IsSet())
+ ListBoxCellController::SetModifyHdl(LINK(this, DbaMouseDownListBoxController, OnMultiplexModify));
+ else
+ ListBoxCellController::SetModifyHdl(Link());
+ }
+
+ //==================================================================
+ //= IndexFieldsControl
+ //==================================================================
+DBG_NAME(IndexFieldsControl)
+//------------------------------------------------------------------
+ IndexFieldsControl::IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix)
+ :EditBrowseBox(_pParent, _rId, EBBF_SMART_TAB_TRAVEL | EBBF_ACTIVATE_ON_BUTTONDOWN, BROWSER_STANDARD_FLAGS)
+ ,m_aSeekRow(m_aFields.end())
+ ,m_pSortingCell(NULL)
+ ,m_pFieldNameCell(NULL)
+ ,m_nMaxColumnsInIndex(_nMaxColumnsInIndex)
+ ,m_bAddIndexAppendix(_bAddIndexAppendix)
+ {
+ DBG_CTOR(IndexFieldsControl,NULL);
+
+ SetUniqueId( UID_DLGINDEX_INDEXDETAILS_BACK );
+ GetDataWindow().SetUniqueId( UID_DLGINDEX_INDEXDETAILS_MAIN );
+ }
+
+ //------------------------------------------------------------------
+ IndexFieldsControl::~IndexFieldsControl()
+ {
+ delete m_pSortingCell;
+ delete m_pFieldNameCell;
+
+ DBG_DTOR(IndexFieldsControl,NULL);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::SeekRow(long nRow)
+ {
+ if (!EditBrowseBox::SeekRow(nRow))
+ return sal_False;
+
+ if (nRow < 0)
+ {
+ m_aSeekRow = m_aFields.end();
+ }
+ else
+ {
+ m_aSeekRow = m_aFields.begin() + nRow;
+ OSL_ENSURE(m_aSeekRow <= m_aFields.end(), "IndexFieldsControl::SeekRow: invalid row!");
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::PaintCell( OutputDevice& _rDev, const Rectangle& _rRect, sal_uInt16 _nColumnId ) const
+ {
+ Point aPos(_rRect.TopLeft());
+ aPos.X() += 1;
+
+ String aText = GetRowCellText(m_aSeekRow,_nColumnId);
+ Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight());
+
+ // clipping
+ if (aPos.X() < _rRect.Right() || aPos.X() + TxtSize.Width() > _rRect.Right() ||
+ aPos.Y() < _rRect.Top() || aPos.Y() + TxtSize.Height() > _rRect.Bottom())
+ _rDev.SetClipRegion( _rRect );
+
+ // allow for a disabled control ...
+ sal_Bool bEnabled = IsEnabled();
+ Color aOriginalColor = _rDev.GetTextColor();
+ if (!bEnabled)
+ _rDev.SetTextColor(GetSettings().GetStyleSettings().GetDisableColor());
+
+ // draw the text
+ _rDev.DrawText(aPos, aText);
+
+ // reset the color (if necessary)
+ if (!bEnabled)
+ _rDev.SetTextColor(aOriginalColor);
+
+ if (_rDev.IsClipRegion())
+ _rDev.SetClipRegion();
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::initializeFrom(const IndexFields& _rFields)
+ {
+ // copy the field descriptions
+ m_aFields = _rFields;
+ m_aSeekRow = m_aFields.end();
+
+ SetUpdateMode(sal_False);
+ // remove all rows
+ RowRemoved(1, GetRowCount());
+ // insert rows for the the fields
+ RowInserted(GetRowCount(), m_aFields.size(), sal_False);
+ // insert an additional row for a new field for that index
+ RowInserted(GetRowCount(), 1, sal_False);
+ SetUpdateMode(sal_True);
+
+ GoToRowColumnId(0, COLUMN_ID_FIELDNAME);
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::commitTo(IndexFields& _rFields)
+ {
+ // do not just copy the array, we may have empty field names (which should not be copied)
+ _rFields.resize(m_aFields.size());
+ ConstIndexFieldsIterator aSource = m_aFields.begin();
+ ConstIndexFieldsIterator aSourceEnd = m_aFields.end();
+ IndexFieldsIterator aDest = _rFields.begin();
+ for (; aSource < aSourceEnd; ++aSource)
+ if (0 != aSource->sFieldName.Len())
+ {
+ *aDest = *aSource;
+ ++aDest;
+ }
+
+ _rFields.resize(aDest - _rFields.begin());
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt32 IndexFieldsControl::GetTotalCellWidth(long _nRow, sal_uInt16 _nColId)
+ {
+ if (COLUMN_ID_ORDER == _nColId)
+ {
+ sal_Int32 nWidthAsc = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ sal_Int32 nWidthDesc = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ // maximum plus some additional space
+ return (nWidthAsc > nWidthDesc ? nWidthAsc : nWidthDesc) + GetTextWidth('0') * 2;
+ }
+ return EditBrowseBox::GetTotalCellWidth(_nRow, _nColId);
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::Init(const Sequence< ::rtl::OUString >& _rAvailableFields)
+ {
+ RemoveColumns();
+
+ // for the width: both columns together should be somewhat smaller than the whole window (without the scrollbar)
+ sal_Int32 nFieldNameWidth = GetSizePixel().Width();
+
+ if ( m_bAddIndexAppendix )
+ {
+ m_sAscendingText = String(ModuleRes(STR_ORDER_ASCENDING));
+ m_sDescendingText = String(ModuleRes(STR_ORDER_DESCENDING));
+
+ // the "sort order" column
+ String sColumnName = String(ModuleRes(STR_TAB_INDEX_SORTORDER));
+ // the width of the order column is the maximum widths of the texts used
+ // (the title of the column)
+ sal_Int32 nSortOrderColumnWidth = GetTextWidth(sColumnName);
+ // ("ascending" + scrollbar width)
+ sal_Int32 nOther = GetTextWidth(m_sAscendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
+ // ("descending" + scrollbar width)
+ nOther = GetTextWidth(m_sDescendingText) + GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSortOrderColumnWidth = nSortOrderColumnWidth > nOther ? nSortOrderColumnWidth : nOther;
+ // (plus some additional space)
+ nSortOrderColumnWidth += GetTextWidth('0') * 2;
+ InsertDataColumn(COLUMN_ID_ORDER, sColumnName, nSortOrderColumnWidth, HIB_STDSTYLE, 1);
+
+ m_pSortingCell = new ListBoxControl(&GetDataWindow());
+ m_pSortingCell->InsertEntry(m_sAscendingText);
+ m_pSortingCell->InsertEntry(m_sDescendingText);
+ m_pSortingCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_SORTORDER );
+
+ nFieldNameWidth -= nSortOrderColumnWidth;
+ }
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ nFieldNameWidth -= aSystemStyle.GetScrollBarSize();
+ nFieldNameWidth -= 8;
+ // the "field name" column
+ String sColumnName = String(ModuleRes(STR_TAB_INDEX_FIELD));
+ InsertDataColumn(COLUMN_ID_FIELDNAME, sColumnName, nFieldNameWidth, HIB_STDSTYLE, 0);
+
+ // create the cell controllers
+ // for the field name cell
+ m_pFieldNameCell = new ListBoxControl(&GetDataWindow());
+ m_pFieldNameCell->InsertEntry(String());
+ m_pFieldNameCell->SetHelpId( HID_DLGINDEX_INDEXDETAILS_FIELD );
+ const ::rtl::OUString* pFields = _rAvailableFields.getConstArray();
+ const ::rtl::OUString* pFieldsEnd = pFields + _rAvailableFields.getLength();
+ for (;pFields < pFieldsEnd; ++pFields)
+ m_pFieldNameCell->InsertEntry(*pFields);
+ }
+
+ //------------------------------------------------------------------
+ CellController* IndexFieldsControl::GetController(long _nRow, sal_uInt16 _nColumnId)
+ {
+ if (!IsEnabled())
+ return NULL;
+
+ ConstIndexFieldsIterator aRow;
+ sal_Bool bNewField = !implGetFieldDesc(_nRow, aRow);
+
+ DbaMouseDownListBoxController* pReturn = NULL;
+ switch (_nColumnId)
+ {
+ case COLUMN_ID_ORDER:
+ if (!bNewField && m_pSortingCell && 0 != aRow->sFieldName.Len())
+ pReturn = new DbaMouseDownListBoxController(m_pSortingCell);
+ break;
+
+ case COLUMN_ID_FIELDNAME:
+ pReturn = new DbaMouseDownListBoxController(m_pFieldNameCell);
+ break;
+
+ default:
+ OSL_FAIL("IndexFieldsControl::GetController: invalid column id!");
+ }
+
+ if (pReturn)
+ pReturn->SetAdditionalModifyHdl(LINK(this, IndexFieldsControl, OnListEntrySelected));
+
+ return pReturn;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::implGetFieldDesc(long _nRow, ConstIndexFieldsIterator& _rPos)
+ {
+ _rPos = m_aFields.end();
+ if ((_nRow < 0) || (_nRow >= (sal_Int32)m_aFields.size()))
+ return sal_False;
+ _rPos = m_aFields.begin() + _nRow;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::IsModified() const
+ {
+ return EditBrowseBox::IsModified();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::SaveModified()
+ {
+ if (!IsModified())
+ return sal_True;
+
+ switch (GetCurColumnId())
+ {
+ case COLUMN_ID_FIELDNAME:
+ {
+ String sFieldSelected = m_pFieldNameCell->GetSelectEntry();
+ sal_Bool bEmptySelected = 0 == sFieldSelected.Len();
+ if (isNewField())
+ {
+ if (!bEmptySelected)
+ {
+ // add a new field to the collection
+ OIndexField aNewField;
+ aNewField.sFieldName = sFieldSelected;
+ m_aFields.push_back(aNewField);
+ RowInserted(GetRowCount(), 1, sal_True);
+ }
+ }
+ else
+ {
+ sal_Int32 nRow = GetCurRow();
+ OSL_ENSURE(nRow < (sal_Int32)m_aFields.size(), "IndexFieldsControl::SaveModified: invalid current row!");
+ if (nRow >= 0) // may be -1 in case the control was empty
+ {
+ // remove the field from the selection
+ IndexFieldsIterator aPos = m_aFields.begin() + nRow;
+
+ if (bEmptySelected)
+ {
+ aPos->sFieldName = String();
+
+ // invalidate the row to force repaint
+ Invalidate(GetRowRectPixel(nRow));
+ return sal_True;
+ }
+
+ if (sFieldSelected == aPos->sFieldName)
+ // nothing changed
+ return sal_True;
+
+ aPos->sFieldName = sFieldSelected;
+ }
+ }
+
+ Invalidate(GetRowRectPixel(GetCurRow()));
+ }
+ break;
+ case COLUMN_ID_ORDER:
+ {
+ OSL_ENSURE(!isNewField(), "IndexFieldsControl::SaveModified: why the hell ...!!!");
+ // selected entry
+ sal_uInt16 nPos = m_pSortingCell->GetSelectEntryPos();
+ OSL_ENSURE(LISTBOX_ENTRY_NOTFOUND != nPos, "IndexFieldsControl::SaveModified: how did you get this selection??");
+ // adjust the sort flag in the index field description
+ OIndexField& rCurrentField = m_aFields[GetCurRow()];
+ rCurrentField.bSortAscending = (0 == nPos);
+
+ }
+ break;
+ default:
+ OSL_FAIL("IndexFieldsControl::SaveModified: invalid column id!");
+ }
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void IndexFieldsControl::InitController(CellControllerRef& /*_rController*/, long _nRow, sal_uInt16 _nColumnId)
+ {
+ ConstIndexFieldsIterator aFieldDescription;
+ sal_Bool bNewField = !implGetFieldDesc(_nRow, aFieldDescription);
+
+ switch (_nColumnId)
+ {
+ case COLUMN_ID_FIELDNAME:
+ m_pFieldNameCell->SelectEntry(bNewField ? String() : aFieldDescription->sFieldName);
+ m_pFieldNameCell->SaveValue();
+ break;
+
+ case COLUMN_ID_ORDER:
+ m_pSortingCell->SelectEntry(aFieldDescription->bSortAscending ? m_sAscendingText : m_sDescendingText);
+ m_pSortingCell->SaveValue();
+ break;
+
+ default:
+ OSL_FAIL("IndexFieldsControl::InitController: invalid column id!");
+ }
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( IndexFieldsControl, OnListEntrySelected, ListBox*, _pBox )
+ {
+ if (!_pBox->IsTravelSelect() && m_aModifyHdl.IsSet())
+ m_aModifyHdl.Call(this);
+
+ if (_pBox == m_pFieldNameCell)
+ { // a field has been selected
+ if (GetCurRow() >= GetRowCount() - 2)
+ { // and we're in one of the last two rows
+ String sSelectedEntry = m_pFieldNameCell->GetSelectEntry();
+ sal_Int32 nCurrentRow = GetCurRow();
+ sal_Int32 rowCount = GetRowCount();
+
+ OSL_ENSURE(((sal_Int32)(m_aFields.size() + 1)) == rowCount, "IndexFieldsControl::OnListEntrySelected: inconsistence!");
+
+ if (sSelectedEntry.Len() && (nCurrentRow == rowCount - 1) /*&& (!m_nMaxColumnsInIndex || rowCount < m_nMaxColumnsInIndex )*/ )
+ { // in the last row, an non-empty string has been selected
+ // -> insert a new row
+ m_aFields.push_back(OIndexField());
+ RowInserted(GetRowCount(), 1);
+ Invalidate(GetRowRectPixel(nCurrentRow));
+ }
+ else if (!sSelectedEntry.Len() && (nCurrentRow == rowCount - 2))
+ { // in the (last-1)th row, an empty entry has been selected
+ // -> remove the last row
+ m_aFields.erase(m_aFields.end() - 1);
+ RowRemoved(GetRowCount() - 1, 1);
+ Invalidate(GetRowRectPixel(nCurrentRow));
+ }
+ }
+
+ SaveModified();
+ }
+ return 0L;
+ }
+ //------------------------------------------------------------------
+ String IndexFieldsControl::GetCellText(long _nRow,sal_uInt16 nColId) const
+ {
+ ConstIndexFieldsIterator aRow = m_aFields.end();
+ if ( _nRow >= 0 )
+ {
+ aRow = m_aFields.begin() + _nRow;
+ OSL_ENSURE(aRow <= m_aFields.end(), "IndexFieldsControl::SeekRow: invalid row!");
+ }
+ return GetRowCellText(aRow,nColId);
+ }
+ //------------------------------------------------------------------
+ String IndexFieldsControl::GetRowCellText(const ConstIndexFieldsIterator& _rRow,sal_uInt16 nColId) const
+ {
+ if (_rRow < m_aFields.end())
+ {
+ switch (nColId)
+ {
+ case COLUMN_ID_FIELDNAME:
+ return _rRow->sFieldName;
+ case COLUMN_ID_ORDER:
+ if (0 == _rRow->sFieldName.Len())
+ return String();
+ else
+ return _rRow->bSortAscending ? m_sAscendingText : m_sDescendingText;
+ default:
+ OSL_FAIL("IndexFieldsControl::GetCurrentRowCellText: invalid column id!");
+ }
+ }
+ return String();
+ }
+ //------------------------------------------------------------------
+ sal_Bool IndexFieldsControl::IsTabAllowed(sal_Bool /*bForward*/) const
+ {
+ return sal_False;
+ }
+ //------------------------------------------------------------------
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/makefile.mk b/dbaccess/source/ui/dlg/makefile.mk
new file mode 100644
index 000000000000..8fa615d28a52
--- /dev/null
+++ b/dbaccess/source/ui/dlg/makefile.mk
@@ -0,0 +1,154 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=uidlg
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.IF "$(SYSTEM_ODBC_HEADERS)" == "YES"
+CFLAGS+=-DSYSTEM_ODBC_HEADERS
+.ENDIF
+
+.IF "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"==""
+CDEFS+=-DWINDOWS_VISTA_PSDK
+.ENDIF
+
+.IF "$(GUI)$(COM)"=="WNTGCC" # for adoint.h
+CFLAGS+=-fpermissive
+.ENDIF
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+
+LOCALIZE_ME=AutoControls_tmpl.hrc
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ AutoControls.src \
+ ConnectionPage.src \
+ UserAdmin.src \
+ admincontrols.src \
+ directsql.src \
+ AdabasStat.src \
+ indexdialog.src \
+ RelationDlg.src \
+ adtabdlg.src \
+ dlgsave.src \
+ queryorder.src \
+ queryfilter.src \
+ paramdialog.src \
+ dsselect.src \
+ dbadmin.src \
+ dbadmin2.src \
+ dbadminsetup.src \
+ dbfindex.src \
+ dlgsize.src \
+ CollectionView.src \
+ dlgattr.src \
+ advancedsettings.src\
+ UserAdminDlg.src \
+ sqlmessage.src \
+ textconnectionsettings.src
+
+
+# ... object files ............................
+EXCEPTIONSFILES= \
+ $(SLO)$/AdabasStat.obj \
+ $(SLO)$/CollectionView.obj \
+ $(SLO)$/ConnectionHelper.obj \
+ $(SLO)$/ConnectionPage.obj \
+ $(SLO)$/ConnectionPageSetup.obj \
+ $(SLO)$/DBSetupConnectionPages.obj \
+ $(SLO)$/DbAdminImpl.obj \
+ $(SLO)$/DriverSettings.obj \
+ $(SLO)$/RelationDlg.obj \
+ $(SLO)$/TablesSingleDlg.obj \
+ $(SLO)$/TextConnectionHelper.obj \
+ $(SLO)$/UserAdmin.obj \
+ $(SLO)$/UserAdminDlg.obj \
+ $(SLO)$/admincontrols.obj \
+ $(SLO)$/adminpages.obj \
+ $(SLO)$/adtabdlg.obj \
+ $(SLO)$/advancedsettings.obj \
+ $(SLO)$/dbadmin.obj \
+ $(SLO)$/dbfindex.obj \
+ $(SLO)$/dbwiz.obj \
+ $(SLO)$/dbwizsetup.obj \
+ $(SLO)$/detailpages.obj \
+ $(SLO)$/directsql.obj \
+ $(SLO)$/dlgattr.obj \
+ $(SLO)$/dlgsave.obj \
+ $(SLO)$/dlgsize.obj \
+ $(SLO)$/dsselect.obj \
+ $(SLO)$/finteraction.obj \
+ $(SLO)$/generalpage.obj \
+ $(SLO)$/indexdialog.obj \
+ $(SLO)$/indexfieldscontrol.obj \
+ $(SLO)$/odbcconfig.obj \
+ $(SLO)$/paramdialog.obj \
+ $(SLO)$/queryfilter.obj \
+ $(SLO)$/queryorder.obj \
+ $(SLO)$/sqlmessage.obj \
+ $(SLO)$/tablespage.obj \
+ $(SLO)$/textconnectionsettings.obj
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/optionalboolitem.obj
+
+.IF "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"==""
+DISABLE_ADO=TRUE
+.ENDIF # "$(WINDOWS_VISTA_PSDK)"!="" && "$(PROF_EDITION)"==""
+
+.IF "$(GUI)"=="WNT" && "$(DISABLE_ADO)"==""
+SLOFILES+= $(SLO)$/adodatalinks.obj
+.ENDIF
+
+# --- Targets ----------------------------------
+.INCLUDE : target.mk
+
+$(SLO)$/ConnectionHelper.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/ConnectionPageSetup.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/DBSetupConnectionPages.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/TextConnectionHelper.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/detailpages.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/tablespage.obj : $(LOCALIZE_ME_DEST)
+
+$(SLO)$/ConnectionPage.obj : $(LOCALIZE_ME_DEST)
diff --git a/dbaccess/source/ui/dlg/odbcconfig.cxx b/dbaccess/source/ui/dlg/odbcconfig.cxx
new file mode 100644
index 000000000000..3c04790c2f73
--- /dev/null
+++ b/dbaccess/source/ui/dlg/odbcconfig.cxx
@@ -0,0 +1,395 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "odbcconfig.hxx"
+
+#ifdef SYSTEM_ODBC_HEADERS
+#include <sqltypes.h>
+#else
+#include <odbc/sqltypes.h>
+#endif
+
+#include <rtl/bootstrap.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/diagnose.h>
+#include <osl/process.h>
+#include <osl/thread.hxx>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
+#ifdef HAVE_ODBC_SUPPORT
+
+#if defined(OS2)
+#define ODBC_LIBRARY "ODBC.DLL"
+#define ODBC_UI_LIBRARY "ODBCINST.DLL"
+#endif
+#if defined WNT
+#define ODBC_LIBRARY "ODBC32.DLL"
+#define ODBC_UI_LIBRARY "ODBCCP32.DLL"
+#endif
+#ifdef UNX
+#ifdef MACOSX
+#define ODBC_LIBRARY "libiodbc.dylib"
+#define ODBC_UI_LIBRARY "libiodbcinst.dylib"
+#else
+#define ODBC_LIBRARY_1 "libodbc.so.1"
+#define ODBC_UI_LIBRARY_1 "libodbcinst.so.1"
+#define ODBC_LIBRARY "libodbc.so"
+#define ODBC_UI_LIBRARY "libodbcinst.so"
+#endif
+#endif
+
+// just to go with calling convention of windows
+// so don't touch this
+#if defined(WNT)
+#define SQL_API __stdcall
+// At least under some circumstances, the below #include <odbc/sqlext.h> re-
+// defines SQL_API to an empty string, leading to a compiler warning on MSC; to
+// not break the current behavior, this is worked around by locally disabling
+// that warning:
+#if defined _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4005)
+#endif
+#endif // defined(WNT)
+
+#if defined(OS2)
+#define ALLREADY_HAVE_OS2_TYPES
+#define DONT_TD_VOID
+#endif
+
+#ifdef SYSTEM_ODBC_HEADERS
+#include <sqlext.h>
+#else
+#include <odbc/sqlext.h>
+#endif
+
+#if defined(WNT)
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#undef SQL_API
+#define SQL_API __stdcall
+#endif // defined(WNT)
+// from here on you can do what you want to
+
+#if defined(OS2)
+#define SQL_API _System
+#endif // defined(OS2)
+
+#else
+
+#define ODBC_LIBRARY ""
+#define ODBC_UI_LIBRARY ""
+
+#endif // HAVE_ODBC_SUPPORT
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+
+#ifdef HAVE_ODBC_SUPPORT
+typedef SQLRETURN (SQL_API* TSQLManageDataSource) (SQLHWND hwndParent);
+typedef SQLRETURN (SQL_API* TSQLAllocHandle) (SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE* OutputHandlePtr);
+typedef SQLRETURN (SQL_API* TSQLFreeHandle) (SQLSMALLINT HandleType, SQLHANDLE Handle);
+typedef SQLRETURN (SQL_API* TSQLSetEnvAttr) (SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength);
+typedef SQLRETURN (SQL_API* TSQLDataSources) (SQLHENV EnvironmentHandle, SQLUSMALLINT Direction, SQLCHAR* ServerName,
+ SQLSMALLINT BufferLength1, SQLSMALLINT* NameLength1Ptr, SQLCHAR* Description, SQLSMALLINT BufferLength2, SQLSMALLINT* NameLength2Ptr);
+
+#define NSQLManageDataSource(a) (*(TSQLManageDataSource)(m_pSQLManageDataSource))(a)
+#define NSQLAllocHandle(a,b,c) (*(TSQLAllocHandle)(m_pAllocHandle))(a,b,c)
+#define NSQLFreeHandle(a,b) (*(TSQLFreeHandle)(m_pFreeHandle))(a,b)
+#define NSQLSetEnvAttr(a,b,c,d) (*(TSQLSetEnvAttr)(m_pSetEnvAttr))(a,b,c,d)
+#define NSQLDataSources(a,b,c,d,e,f,g,h) (*(TSQLDataSources)(m_pDataSources))(a,b,c,d,e,f,g,h)
+#endif
+
+//=========================================================================
+//= OOdbcLibWrapper
+//=========================================================================
+DBG_NAME(OOdbcLibWrapper)
+//-------------------------------------------------------------------------
+#ifdef HAVE_ODBC_SUPPORT
+OOdbcLibWrapper::OOdbcLibWrapper()
+ :m_pOdbcLib(NULL)
+{
+ DBG_CTOR(OOdbcLibWrapper,NULL);
+
+}
+#endif
+
+//-------------------------------------------------------------------------
+sal_Bool OOdbcLibWrapper::load(const sal_Char* _pLibPath)
+{
+ m_sLibPath = ::rtl::OUString::createFromAscii(_pLibPath);
+#ifdef HAVE_ODBC_SUPPORT
+ // load the module
+ m_pOdbcLib = osl_loadModule(m_sLibPath.pData, SAL_LOADMODULE_NOW);
+ return (NULL != m_pOdbcLib);
+#endif
+}
+
+//-------------------------------------------------------------------------
+void OOdbcLibWrapper::unload()
+{
+#ifdef HAVE_ODBC_SUPPORT
+ if (isLoaded())
+ {
+ osl_unloadModule(m_pOdbcLib);
+ m_pOdbcLib = NULL;
+ }
+#endif
+}
+
+//-------------------------------------------------------------------------
+oslGenericFunction OOdbcLibWrapper::loadSymbol(const sal_Char* _pFunctionName)
+{
+ return osl_getFunctionSymbol(m_pOdbcLib, ::rtl::OUString::createFromAscii(_pFunctionName).pData);
+}
+
+//-------------------------------------------------------------------------
+OOdbcLibWrapper::~OOdbcLibWrapper()
+{
+ unload();
+
+ DBG_DTOR(OOdbcLibWrapper,NULL);
+}
+
+//=========================================================================
+//= OOdbcEnumeration
+//=========================================================================
+struct OdbcTypesImpl
+{
+#ifdef HAVE_ODBC_SUPPORT
+ SQLHANDLE hEnvironment;
+ OdbcTypesImpl() : hEnvironment(0) { }
+#else
+ void* pDummy;
+#endif
+};
+DBG_NAME(OOdbcEnumeration)
+//-------------------------------------------------------------------------
+OOdbcEnumeration::OOdbcEnumeration()
+#ifdef HAVE_ODBC_SUPPORT
+ :m_pAllocHandle(NULL)
+ ,m_pSetEnvAttr(NULL)
+ ,m_pDataSources(NULL)
+ ,m_pImpl(new OdbcTypesImpl)
+#endif
+{
+ DBG_CTOR(OOdbcEnumeration,NULL);
+
+ sal_Bool bLoaded = load(ODBC_LIBRARY);
+#ifdef ODBC_LIBRARY_1
+ if ( !bLoaded )
+ bLoaded = load(ODBC_LIBRARY_1);
+#endif
+
+ if ( bLoaded )
+ {
+#ifdef HAVE_ODBC_SUPPORT
+ // load the generic functions
+ m_pAllocHandle = loadSymbol("SQLAllocHandle");
+ m_pFreeHandle = loadSymbol("SQLFreeHandle");
+ m_pSetEnvAttr = loadSymbol("SQLSetEnvAttr");
+ m_pDataSources = loadSymbol("SQLDataSources");
+
+ // all or nothing
+ if (!m_pAllocHandle || !m_pSetEnvAttr || !m_pDataSources || !m_pFreeHandle)
+ {
+ unload();
+ m_pAllocHandle = m_pFreeHandle = m_pSetEnvAttr = m_pDataSources = NULL;
+ }
+#endif
+ }
+}
+
+//-------------------------------------------------------------------------
+OOdbcEnumeration::~OOdbcEnumeration()
+{
+ freeEnv();
+ delete m_pImpl;
+
+ DBG_DTOR(OOdbcEnumeration,NULL);
+}
+
+//-------------------------------------------------------------------------
+sal_Bool OOdbcEnumeration::allocEnv()
+{
+ OSL_ENSURE(isLoaded(), "OOdbcEnumeration::allocEnv: not loaded!");
+ if (!isLoaded())
+ return sal_False;
+
+#ifdef HAVE_ODBC_SUPPORT
+ if (m_pImpl->hEnvironment)
+ // nothing to do
+ return sal_True;
+ SQLRETURN nResult = NSQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_pImpl->hEnvironment);
+ if (SQL_SUCCESS != nResult)
+ // can't do anything without environment
+ return sal_False;
+
+ NSQLSetEnvAttr(m_pImpl->hEnvironment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
+ return sal_True;
+#else
+ return sal_False;
+#endif
+}
+
+//-------------------------------------------------------------------------
+void OOdbcEnumeration::freeEnv()
+{
+#ifdef HAVE_ODBC_SUPPORT
+ if (m_pImpl->hEnvironment)
+ NSQLFreeHandle(SQL_HANDLE_ENV, m_pImpl->hEnvironment);
+ m_pImpl->hEnvironment = 0;
+#endif
+}
+
+//-------------------------------------------------------------------------
+void OOdbcEnumeration::getDatasourceNames(StringBag& _rNames)
+{
+ OSL_ENSURE(isLoaded(), "OOdbcEnumeration::getDatasourceNames: not loaded!");
+ if (!isLoaded())
+ return;
+
+ if (!allocEnv())
+ {
+ OSL_FAIL("OOdbcEnumeration::getDatasourceNames: could not allocate an ODBC environment!");
+ return;
+ }
+
+#ifdef HAVE_ODBC_SUPPORT
+ // now that we have an environment collect the data source names
+ UCHAR szDSN[SQL_MAX_DSN_LENGTH+1];
+ SWORD pcbDSN;
+ UCHAR szDescription[1024+1];
+ SWORD pcbDescription;
+ SQLRETURN nResult = SQL_SUCCESS;
+ rtl_TextEncoding nTextEncoding = osl_getThreadTextEncoding();
+
+ for ( nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_FIRST, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription);
+ ;
+ nResult = NSQLDataSources(m_pImpl->hEnvironment, SQL_FETCH_NEXT, szDSN, sizeof(szDSN), &pcbDSN, szDescription, sizeof(szDescription)-1, &pcbDescription)
+ )
+ {
+ if (nResult != SQL_SUCCESS)
+ // no further error handling
+ break;
+ else
+ {
+ ::rtl::OUString aCurrentDsn(reinterpret_cast<const char*>(szDSN),pcbDSN, nTextEncoding);
+ _rNames.insert(aCurrentDsn);
+ }
+ }
+#endif
+}
+
+#ifdef HAVE_ODBC_ADMINISTRATION
+
+//=========================================================================
+//= ProcessTerminationWait
+//=========================================================================
+class ProcessTerminationWait : public ::osl::Thread
+{
+ oslProcess m_hProcessHandle;
+ Link m_aFinishHdl;
+
+public:
+ ProcessTerminationWait( oslProcess _hProcessHandle, const Link& _rFinishHdl )
+ :m_hProcessHandle( _hProcessHandle )
+ ,m_aFinishHdl( _rFinishHdl )
+ {
+ }
+
+protected:
+ virtual void SAL_CALL run()
+ {
+ osl_joinProcess( m_hProcessHandle );
+ osl_freeProcessHandle( m_hProcessHandle );
+ Application::PostUserEvent( m_aFinishHdl );
+ }
+};
+
+//=========================================================================
+//= OOdbcManagement
+//=========================================================================
+//-------------------------------------------------------------------------
+OOdbcManagement::OOdbcManagement( const Link& _rAsyncFinishCallback )
+ :m_pProcessWait( NULL )
+ ,m_aAsyncFinishCallback( _rAsyncFinishCallback )
+{
+}
+
+//-------------------------------------------------------------------------
+OOdbcManagement::~OOdbcManagement()
+{
+ // wait for our thread to be finished
+ if ( m_pProcessWait.get() )
+ m_pProcessWait->join();
+}
+
+//-------------------------------------------------------------------------
+bool OOdbcManagement::manageDataSources_async()
+{
+ OSL_PRECOND( !isRunning(), "OOdbcManagement::manageDataSources_async: still running from the previous call!" );
+ if ( isRunning() )
+ return false;
+
+ // this is done in an external process, due to #i78733#
+ // (and note this whole functionality is supported on Windows only, ATM)
+ ::rtl::OUString sExecutableName( RTL_CONSTASCII_USTRINGPARAM( "$OOO_BASE_DIR/program/odbcconfig.exe" ) );
+ ::rtl::Bootstrap::expandMacros( sExecutableName ); //TODO: detect failure
+ oslProcess hProcessHandle(0);
+ oslProcessError eError = osl_executeProcess( sExecutableName.pData, NULL, 0, 0, NULL, NULL, NULL, 0, &hProcessHandle );
+ if ( eError != osl_Process_E_None )
+ return false;
+
+ m_pProcessWait.reset( new ProcessTerminationWait( hProcessHandle, m_aAsyncFinishCallback ) );
+ m_pProcessWait->create();
+ return true;
+}
+
+//-------------------------------------------------------------------------
+bool OOdbcManagement::isRunning() const
+{
+ return ( m_pProcessWait.get() && m_pProcessWait->isRunning() );
+}
+
+#endif // HAVE_ODBC_ADMINISTRATION
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/odbcconfig.hxx b/dbaccess/source/ui/dlg/odbcconfig.hxx
new file mode 100644
index 000000000000..20b0adb0cb44
--- /dev/null
+++ b/dbaccess/source/ui/dlg/odbcconfig.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_ODBC_CONFIG_HXX_
+#define _DBAUI_ODBC_CONFIG_HXX_
+
+#include "commontypes.hxx"
+
+#if defined(WNT) || defined (UNX) || defined (OS2)
+#define HAVE_ODBC_SUPPORT
+#endif
+
+#if ( defined(WNT) || defined (OS2) ) && defined(HAVE_ODBC_SUPPORT)
+#define HAVE_ODBC_ADMINISTRATION
+#endif
+
+#include <tools/link.hxx>
+#include <osl/module.h>
+
+#include <memory>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OOdbcLibWrapper
+//=========================================================================
+/** base for helper classes wrapping functionality from an ODBC library
+*/
+class OOdbcLibWrapper
+{
+ oslModule m_pOdbcLib; // the library handle
+ ::rtl::OUString m_sLibPath; // the path to the library
+
+public:
+#ifdef HAVE_ODBC_SUPPORT
+ sal_Bool isLoaded() const { return NULL != m_pOdbcLib; }
+#else
+ sal_Bool isLoaded() const { return sal_False; }
+#endif
+ ::rtl::OUString getLibraryName() const { return m_sLibPath; }
+
+protected:
+#ifndef HAVE_ODBC_SUPPORT
+ OOdbcLibWrapper() : m_pOdbcLib(NULL) { }
+#else
+ OOdbcLibWrapper();
+#endif
+ ~OOdbcLibWrapper();
+
+ oslGenericFunction loadSymbol(const sal_Char* _pFunctionName);
+
+ /// load the lib
+ sal_Bool load(const sal_Char* _pLibPath);
+ /// unload the lib
+ void unload();
+};
+
+//=========================================================================
+//= OOdbcEnumeration
+//=========================================================================
+struct OdbcTypesImpl;
+class OOdbcEnumeration : public OOdbcLibWrapper
+{
+#ifdef HAVE_ODBC_SUPPORT
+ // entry points for ODBC administration
+ oslGenericFunction m_pAllocHandle;
+ oslGenericFunction m_pFreeHandle;
+ oslGenericFunction m_pSetEnvAttr;
+ oslGenericFunction m_pDataSources;
+
+#endif
+ OdbcTypesImpl* m_pImpl;
+ // needed because we can't have a member of type SQLHANDLE: this would require us to include the respective
+ // ODBC file, which would lead to a lot of conflicts with other includes
+
+public:
+ OOdbcEnumeration();
+ ~OOdbcEnumeration();
+
+ void getDatasourceNames(StringBag& _rNames);
+
+protected:
+ /// ensure that an ODBC environment is allocated
+ sal_Bool allocEnv();
+ /// free any allocated ODBC environment
+ void freeEnv();
+};
+
+//=========================================================================
+//= OOdbcManagement
+//=========================================================================
+#ifdef HAVE_ODBC_ADMINISTRATION
+class ProcessTerminationWait;
+class OOdbcManagement
+{
+ ::std::auto_ptr< ProcessTerminationWait > m_pProcessWait;
+ Link m_aAsyncFinishCallback;
+
+public:
+ OOdbcManagement( const Link& _rAsyncFinishCallback );
+ ~OOdbcManagement();
+
+ bool manageDataSources_async();
+ bool isRunning() const;
+};
+#endif
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_ODBC_CONFIG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/optionalboolitem.cxx b/dbaccess/source/ui/dlg/optionalboolitem.cxx
new file mode 100644
index 000000000000..5a271ab4be45
--- /dev/null
+++ b/dbaccess/source/ui/dlg/optionalboolitem.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "optionalboolitem.hxx"
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= OptionalBoolItem
+ //====================================================================
+ TYPEINIT1( OptionalBoolItem, SfxPoolItem );
+ //--------------------------------------------------------------------
+ OptionalBoolItem::OptionalBoolItem( sal_Int16 _nWhich )
+ :SfxPoolItem( _nWhich )
+ ,m_aValue()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OptionalBoolItem::OptionalBoolItem( const OptionalBoolItem& _rSource )
+ :SfxPoolItem( _rSource )
+ ,m_aValue( _rSource.m_aValue )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ int OptionalBoolItem::operator==( const SfxPoolItem& _rItem ) const
+ {
+ const OptionalBoolItem* pCompare = PTR_CAST( OptionalBoolItem, &_rItem );
+ if ( !pCompare )
+ return 0;
+
+ if ( m_aValue == pCompare->m_aValue )
+ return 1;
+
+ return 0;
+ }
+
+ //--------------------------------------------------------------------
+ SfxPoolItem* OptionalBoolItem::Clone( SfxItemPool* /*_pPool*/ ) const
+ {
+ return new OptionalBoolItem( *this );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx
new file mode 100644
index 000000000000..0fdb2dedf611
--- /dev/null
+++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef DBACCESS_OPTIONALBOOLITEM_HXX
+#define DBACCESS_OPTIONALBOOLITEM_HXX
+
+#include <svl/poolitem.hxx>
+
+#include <boost/optional.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= OptionalBoolItem
+ //====================================================================
+ class OptionalBoolItem : public SfxPoolItem
+ {
+ ::boost::optional< bool > m_aValue;
+
+ public:
+ TYPEINFO();
+ OptionalBoolItem( sal_Int16 nWhich );
+ OptionalBoolItem( const OptionalBoolItem& _rSource );
+
+ virtual int operator==( const SfxPoolItem& _rItem ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool* _pPool = NULL ) const;
+
+ bool HasValue() const { return !!m_aValue; }
+ void ClearValue() { m_aValue.reset(); }
+ bool GetValue() const { return *m_aValue; }
+ void SetValue( const bool _bValue ) { m_aValue.reset( _bValue ); }
+
+ const ::boost::optional< bool >&
+ GetFullValue() const { return m_aValue; }
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_OPTIONALBOOLITEM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx
new file mode 100644
index 000000000000..18eab7138f2e
--- /dev/null
+++ b/dbaccess/source/ui/dlg/paramdialog.cxx
@@ -0,0 +1,427 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "paramdialog.hxx"
+#include "paramdialog.hrc"
+#include "dbu_dlg.hrc"
+#include "commontypes.hxx"
+#include "moduledbu.hxx"
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <connectivity/dbtools.hxx>
+#include "dbustrings.hrc"
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+#include "localresaccess.hxx"
+#include <unotools/syslocale.hxx>
+
+#define EF_VISITED 0x0001
+#define EF_DIRTY 0x0002
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::util;
+ using namespace ::connectivity;
+
+ //==================================================================
+ //= OParameterDialog
+ //==================================================================
+
+ //------------------------------------------------------------------------------
+ #define INIT_MEMBERS() \
+ :ModalDialog( pParent, ModuleRes(DLG_PARAMETERS)) \
+ ,m_aNamesFrame (this, ModuleRes(FL_PARAMS)) \
+ ,m_aAllParams (this, ModuleRes(LB_ALLPARAMS)) \
+ ,m_aValueFrame (this, ModuleRes(FT_VALUE)) \
+ ,m_aParam (this, ModuleRes(ET_PARAM)) \
+ ,m_aTravelNext (this, ModuleRes(BT_TRAVELNEXT)) \
+ ,m_aOKBtn (this, ModuleRes(BT_OK)) \
+ ,m_aCancelBtn (this, ModuleRes(BT_CANCEL)) \
+ ,m_nCurrentlySelected(LISTBOX_ENTRY_NOTFOUND) \
+ ,m_xConnection(_rxConnection) \
+ ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() ) \
+ ,m_bNeedErrorOnCurrent(sal_True) \
+
+
+ //------------------------------------------------------------------------------
+DBG_NAME(OParameterDialog)
+
+ OParameterDialog::OParameterDialog(
+ Window* pParent, const Reference< XIndexAccess > & rParamContainer,
+ const Reference< XConnection > & _rxConnection, const Reference< XMultiServiceFactory >& _rxORB)
+ INIT_MEMBERS()
+ {
+ DBG_CTOR(OParameterDialog,NULL);
+
+ if (_rxORB.is())
+ m_xFormatter = Reference< XNumberFormatter>(_rxORB->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ else {
+ OSL_FAIL("OParameterDialog::OParameterDialog: need a service factory!");
+ }
+
+ Reference< XNumberFormatsSupplier > xNumberFormats = ::dbtools::getNumberFormats(m_xConnection, sal_True);
+ if (!xNumberFormats.is())
+ ::comphelper::disposeComponent(m_xFormatter);
+ else if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xNumberFormats);
+ try
+ {
+ OSL_ENSURE(rParamContainer->getCount(), "OParameterDialog::OParameterDialog : can't handle empty containers !");
+
+ m_aFinalValues.realloc(rParamContainer->getCount());
+ PropertyValue* pValues = m_aFinalValues.getArray();
+
+ for (sal_Int32 i = 0, nCount = rParamContainer->getCount(); i<nCount; ++i, ++pValues)
+ {
+ Reference< XPropertySet > xParamAsSet;
+ rParamContainer->getByIndex(i) >>= xParamAsSet;
+ OSL_ENSURE(xParamAsSet.is(),"Parameter is null!");
+ if(!xParamAsSet.is())
+ continue;
+ pValues->Name = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME));
+ m_aAllParams.InsertEntry(pValues->Name);
+
+ if (!pValues->Value.hasValue())
+ // it won't have a value, 'cause it's default constructed. But may be later we support
+ // initializing this dialog with values
+ pValues->Value = makeAny(::rtl::OUString());
+ // default the values to an empty string
+
+ m_aVisitedParams.push_back(0);
+ // not visited, not dirty
+ }
+
+ m_xParams = rParamContainer;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+
+ Construct();
+
+ m_aResetVisitFlag.SetTimeoutHdl(LINK(this, OParameterDialog, OnVisitedTimeout));
+
+ FreeResource();
+ }
+
+ //------------------------------------------------------------------------------
+ OParameterDialog::~OParameterDialog()
+ {
+ if (m_aResetVisitFlag.IsActive())
+ m_aResetVisitFlag.Stop();
+
+ DBG_DTOR(OParameterDialog,NULL);
+ }
+
+ //------------------------------------------------------------------------------
+ void OParameterDialog::Construct()
+ {
+ m_aAllParams.SetSelectHdl(LINK(this, OParameterDialog, OnEntrySelected));
+ m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus));
+ m_aParam.SetModifyHdl(LINK(this, OParameterDialog, OnValueModified));
+ m_aTravelNext.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked));
+ m_aOKBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked));
+ m_aCancelBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked));
+
+ if (m_aAllParams.GetEntryCount())
+ {
+ m_aAllParams.SelectEntryPos(0);
+ LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams);
+
+ if (m_aAllParams.GetEntryCount() == 1)
+ {
+ m_aTravelNext.Enable(sal_False);
+ }
+
+ if (m_aAllParams.GetEntryCount() > 1)
+ {
+ m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() & ~WB_DEFBUTTON);
+ m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() | WB_DEFBUTTON);
+ }
+ }
+
+ m_aParam.GrabFocus();
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(OParameterDialog, OnValueLoseFocus, Control*, /*pSource*/)
+ {
+ if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND)
+ {
+ if ( ( m_aVisitedParams[ m_nCurrentlySelected ] & EF_DIRTY ) == 0 )
+ // nothing to do, the value isn't dirty
+ return 0L;
+ }
+
+ // transform the current string according to the param field type
+ ::rtl::OUString sTransformedText(m_aParam.GetText());
+ Reference< XPropertySet > xParamAsSet;
+ m_xParams->getByIndex(m_nCurrentlySelected) >>= xParamAsSet;
+ if (xParamAsSet.is())
+ {
+ if (m_xConnection.is() && m_xFormatter.is())
+ {
+ ::rtl::OUString sParamValue( m_aParam.GetText() );
+ sal_Bool bValid = m_aPredicateInput.normalizePredicateString( sParamValue, xParamAsSet );
+ m_aParam.SetText( sParamValue );
+ if ( bValid )
+ {
+ // with this the value isn't dirty anymore
+ if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND)
+ m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY;
+ }
+ else
+ {
+ if (!m_bNeedErrorOnCurrent)
+ return 1L;
+
+ m_bNeedErrorOnCurrent = sal_False; // will be reset in OnValueModified
+
+ ::rtl::OUString sName;
+ try
+ {
+ sName = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME));
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ String sMessage;
+ {
+ LocalResourceAccess aDummy(DLG_PARAMETERS, RSC_MODALDIALOG);
+ sMessage = String(ModuleRes(STR_COULD_NOT_CONVERT_PARAM));
+ }
+ sMessage.SearchAndReplaceAll(String::CreateFromAscii("$name$"), sName.getStr());
+ ErrorBox(NULL, WB_OK, sMessage).Execute();
+ m_aParam.GrabFocus();
+ return 1L;
+ }
+ }
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(OParameterDialog, OnButtonClicked, PushButton*, pButton)
+ {
+ if (&m_aCancelBtn == pButton)
+ {
+ // no interpreting of the given values anymore ....
+ m_aParam.SetLoseFocusHdl(Link()); // no direct call from the control anymore ...
+ m_bNeedErrorOnCurrent = sal_False; // in case of any indirect calls -> no error message
+ m_aCancelBtn.SetClickHdl(Link());
+ m_aCancelBtn.Click();
+ }
+ else if (&m_aOKBtn == pButton)
+ {
+ // transfer the current values into the Any
+ if (LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams) != 0L)
+ { // there was an error interpreting the current text
+ m_bNeedErrorOnCurrent = sal_True;
+ // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now,
+ // so the next time it is called we need an error message, again ....
+ // (TODO : there surely are better solutions for this ...)
+ return 1L;
+ }
+
+ if (m_xParams.is())
+ {
+ // write the parameters
+ try
+ {
+ ::rtl::OUString sError;
+ PropertyValue* pValues = m_aFinalValues.getArray();
+ for (sal_Int32 i = 0, nCount = m_xParams->getCount(); i<nCount; ++i, ++pValues)
+ {
+ Reference< XPropertySet > xParamAsSet;
+ m_xParams->getByIndex(i) >>= xParamAsSet;
+
+ ::rtl::OUString sValue;
+ pValues->Value >>= sValue;
+ pValues->Value <<= ::rtl::OUString( m_aPredicateInput.getPredicateValue( sValue, xParamAsSet, sal_False ) );
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ }
+ // to close the dialog (which is more code than a simple EndDialog)
+ m_aOKBtn.SetClickHdl(Link());
+ m_aOKBtn.Click();
+ }
+ else if (&m_aTravelNext == pButton)
+ {
+ sal_uInt16 nCurrent = m_aAllParams.GetSelectEntryPos();
+ sal_uInt16 nCount = m_aAllParams.GetEntryCount();
+ OSL_ENSURE(nCount == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !");
+
+ // search the next entry in list we haven't visited yet
+ sal_uInt16 nNext = (nCurrent + 1) % nCount;
+ while ((nNext != nCurrent) && ( m_aVisitedParams[nNext] & EF_VISITED ))
+ nNext = (nNext + 1) % nCount;
+
+ if ( m_aVisitedParams[nNext] & EF_VISITED )
+ // there is no such "not visited yet" entry -> simpy take the next one
+ nNext = (nCurrent + 1) % nCount;
+
+ m_aAllParams.SelectEntryPos(nNext);
+ LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams);
+ m_bNeedErrorOnCurrent = sal_True;
+ // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now,
+ // so the next time it is called we need an error message, again ....
+ // (TODO : there surely are better solutions for this ...)
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(OParameterDialog, OnEntrySelected, ListBox*, /*pList*/)
+ {
+ if (m_aResetVisitFlag.IsActive())
+ {
+ LINK(this, OParameterDialog, OnVisitedTimeout).Call(&m_aResetVisitFlag);
+ m_aResetVisitFlag.Stop();
+ }
+ // save the old values
+ if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND)
+ {
+ // do the transformation of the current text
+ if (LINK(this, OParameterDialog, OnValueLoseFocus).Call(&m_aParam) != 0L)
+ { // there was an error interpreting the text
+ m_aAllParams.SelectEntryPos(m_nCurrentlySelected);
+ return 1L;
+ }
+
+ m_aFinalValues[m_nCurrentlySelected].Value <<= ::rtl::OUString(m_aParam.GetText());
+ }
+
+ // initialize the controls with the new values
+ sal_uInt16 nSelected = m_aAllParams.GetSelectEntryPos();
+ OSL_ENSURE(nSelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnEntrySelected : no current entry !");
+
+ m_aParam.SetText(::comphelper::getString(m_aFinalValues[nSelected].Value));
+ m_nCurrentlySelected = nSelected;
+
+ // with this the value isn't dirty
+ OSL_ENSURE(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnEntrySelected : invalid current entry !");
+ m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY;
+
+ m_aResetVisitFlag.SetTimeout(1000);
+ m_aResetVisitFlag.Start();
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(OParameterDialog, OnVisitedTimeout, Timer*, /*pTimer*/)
+ {
+ OSL_ENSURE(m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnVisitedTimeout : invalid call !");
+
+ // mark the currently selected entry as visited
+ OSL_ENSURE(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnVisitedTimeout : invalid entry !");
+ m_aVisitedParams[m_nCurrentlySelected] |= EF_VISITED;
+
+ // was it the last "not visited yet" entry ?
+ ConstByteVectorIterator aIter;
+ for ( aIter = m_aVisitedParams.begin();
+ aIter < m_aVisitedParams.end();
+ ++aIter
+ )
+ {
+ if (((*aIter) & EF_VISITED) == 0)
+ break;
+ }
+ if (aIter == m_aVisitedParams.end())
+ { // yes, there isn't another one -> change the "default button"
+ m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() & ~WB_DEFBUTTON);
+ m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() | WB_DEFBUTTON);
+
+ // set to focus to one of the buttons temporary (with this their "default"-state is really updated)
+ Window* pOldFocus = Application::GetFocusWindow();
+
+ // if the old focus window is the value edit do some preparations ...
+ Selection aSel;
+ if (pOldFocus == &m_aParam)
+ {
+ m_aParam.SetLoseFocusHdl(Link());
+ aSel = m_aParam.GetSelection();
+ }
+ m_aTravelNext.GrabFocus();
+ if (pOldFocus)
+ pOldFocus->GrabFocus();
+
+ // restore the settings for the value edit
+ if (pOldFocus == &m_aParam)
+ {
+ m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus));
+ m_aParam.SetSelection(aSel);
+ }
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(OParameterDialog, OnValueModified, Control*, /*pBox*/)
+ {
+ // mark the currently selected entry as dirty
+ OSL_ENSURE(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !");
+ m_aVisitedParams[m_nCurrentlySelected] |= EF_DIRTY;
+
+ m_bNeedErrorOnCurrent = sal_True;
+
+ return 0L;
+ }
+
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/paramdialog.hrc b/dbaccess/source/ui/dlg/paramdialog.hrc
new file mode 100644
index 000000000000..0b834dd3e7eb
--- /dev/null
+++ b/dbaccess/source/ui/dlg/paramdialog.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_PARAMDIALOG_HRC_
+#define _DBAUI_PARAMDIALOG_HRC_
+
+#define LB_ALLPARAMS 1
+#define FL_PARAMS 2
+#define FT_VALUE 3
+#define ET_PARAM 4
+#define CB_NULLVAL 5
+#define BT_TRAVELNEXT 6
+#define BT_OK 7
+#define BT_CANCEL 8
+#define AB_PREV 9
+#define AB_NEXT 10
+
+
+#define STR_COULD_NOT_CONVERT_PARAM 1
+
+#endif // _DBAUI_PARAMDIALOG_HRC_
+
diff --git a/dbaccess/source/ui/dlg/paramdialog.src b/dbaccess/source/ui/dlg/paramdialog.src
new file mode 100644
index 000000000000..1f78123c6096
--- /dev/null
+++ b/dbaccess/source/ui/dlg/paramdialog.src
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_PARAMDIALOG_HRC_
+#include "paramdialog.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#define LIST_WIDTH 100
+#define LIST_HEIGHT 50
+
+ModalDialog DLG_PARAMETERS
+{
+ HelpID = "dbaccess:ModalDialog:DLG_PARAMETERS";
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 6 + LIST_WIDTH + 3 + 6 + BUTTON_WIDTH + 6, 98 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ FixedLine FL_PARAMS
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( 3 + LIST_WIDTH + 3 , 8 ) ;
+ Text [ en-US ] = "~Parameters";
+ };
+ ListBox LB_ALLPARAMS
+ {
+ HelpID = "dbaccess:ListBox:DLG_PARAMETERS:LB_ALLPARAMS";
+ Pos = MAP_APPFONT ( 7 , 12 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , LIST_HEIGHT ) ;
+ Border = TRUE;
+ SVLook = TRUE;
+ };
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 7 , 12 + LIST_HEIGHT + 4 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , 8 ) ;
+ Text [ en-US ] = "~Value";
+ };
+ Edit ET_PARAM
+ {
+ HelpID = "dbaccess:Edit:DLG_PARAMETERS:ET_PARAM";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 7 , 12 + LIST_HEIGHT + 4 + 8 + 3 ) ;
+ Size = MAP_APPFONT ( LIST_WIDTH , 12 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BT_TRAVELNEXT
+ {
+ HelpID = "dbaccess:PushButton:DLG_PARAMETERS:BT_TRAVELNEXT";
+ Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 12 + LIST_HEIGHT + 4 + 8 + 3 + ( 12 - BUTTON_HEIGHT ) / 2) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Next";
+ };
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 3 ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 4 + 3 + LIST_WIDTH + 3 + 6 , 3 + BUTTON_HEIGHT + 3 ) ;
+ Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Parameter Input" ;
+
+ String STR_COULD_NOT_CONVERT_PARAM
+ {
+ Text [ en-US ] = "The entry could not be converted to a valid value for the \"$name$\"column";
+ };
+};
diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx
new file mode 100644
index 000000000000..75ed025ac6df
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryfilter.cxx
@@ -0,0 +1,873 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "queryfilter.hxx"
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "moduledbu.hxx"
+#include <connectivity/sqliterator.hxx>
+#include <connectivity/dbtools.hxx>
+#include "queryfilter.hrc"
+#include "dbustrings.hrc"
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+
+using namespace dbaui;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+
+//------------------------------------------------------------------------------
+void Replace_OS_PlaceHolder(String& aString)
+{
+ while (aString.SearchAndReplace( '*', '%' ) != STRING_NOTFOUND) ;
+ while (aString.SearchAndReplace( '?', '_' ) != STRING_NOTFOUND) ;
+}
+
+//------------------------------------------------------------------------------
+void Replace_SQL_PlaceHolder(String& aString)
+{
+ while (aString.SearchAndReplace( '%', '*' ) != STRING_NOTFOUND) ;
+ while (aString.SearchAndReplace( '_', '?' ) != STRING_NOTFOUND) ;
+}
+
+DBG_NAME(DlgFilterCrit);
+//------------------------------------------------------------------------------
+DlgFilterCrit::DlgFilterCrit(Window * pParent,
+ const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XConnection>& _rxConnection,
+ const Reference< XSingleSelectQueryComposer >& _rxComposer,
+ const Reference< XNameAccess>& _rxCols
+ )
+ :ModalDialog( pParent, ModuleRes( DLG_FILTERCRIT ) )
+ ,aLB_WHEREFIELD1 ( this, ModuleRes( LB_WHEREFIELD1 ) )
+ ,aLB_WHERECOMP1 ( this, ModuleRes( LB_WHERECOMP1 ) )
+ ,aET_WHEREVALUE1 ( this, ModuleRes( ET_WHEREVALUE1 ) )
+ ,aLB_WHERECOND2 ( this, ModuleRes( LB_WHERECOND2 ) )
+ ,aLB_WHEREFIELD2 ( this, ModuleRes( LB_WHEREFIELD2 ) )
+ ,aLB_WHERECOMP2 ( this, ModuleRes( LB_WHERECOMP2 ) )
+ ,aET_WHEREVALUE2 ( this, ModuleRes( ET_WHEREVALUE2 ) )
+ ,aLB_WHERECOND3 ( this, ModuleRes( LB_WHERECOND3 ) )
+ ,aLB_WHEREFIELD3 ( this, ModuleRes( LB_WHEREFIELD3 ) )
+ ,aLB_WHERECOMP3 ( this, ModuleRes( LB_WHERECOMP3 ) )
+ ,aET_WHEREVALUE3 ( this, ModuleRes( ET_WHEREVALUE3 ) )
+ ,aFT_WHEREFIELD ( this, ModuleRes( FT_WHEREFIELD ) )
+ ,aFT_WHERECOMP ( this, ModuleRes( FT_WHERECOMP ) )
+ ,aFT_WHEREVALUE ( this, ModuleRes( FT_WHEREVALUE ) )
+ ,aFT_WHEREOPER ( this, ModuleRes( FT_WHEREOPER ) )
+ ,aFL_FIELDS ( this, ModuleRes( FL_FIELDS ) )
+ ,aBT_OK ( this, ModuleRes( BT_OK ) )
+ ,aBT_CANCEL ( this, ModuleRes( BT_CANCEL ) )
+ ,aBT_HELP ( this, ModuleRes( BT_HELP ) )
+ ,aSTR_NOENTRY ( ModuleRes( STR_NOENTRY ) )
+ ,aSTR_COMPARE_OPERATORS( ModuleRes( STR_COMPARE_OPERATORS ) )
+ ,m_xQueryComposer(_rxComposer)
+ ,m_xColumns( _rxCols )
+ ,m_xConnection( _rxConnection )
+ ,m_xMetaData( _rxConnection->getMetaData() )
+ ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() )
+{
+ DBG_CTOR(DlgFilterCrit,NULL);
+ // Den String fuer noEntry in die ListBoxen der Feldnamen schreiben
+ aLB_WHEREFIELD1.InsertEntry( aSTR_NOENTRY );
+ aLB_WHEREFIELD2.InsertEntry( aSTR_NOENTRY );
+ aLB_WHEREFIELD3.InsertEntry( aSTR_NOENTRY );
+
+ try
+ {
+ // ... sowie auch die restlichen Felder
+ Sequence< ::rtl::OUString> aNames = m_xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ Reference<XPropertySet> xColumn;
+ for(;pIter != pEnd;++pIter)
+ {
+ try
+ {
+ xColumn.set( m_xColumns->getByName( *pIter ), UNO_QUERY_THROW );
+
+ sal_Int32 nDataType( 0 );
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_TYPE ) >>= nDataType );
+ sal_Int32 eColumnSearch = ::dbtools::getSearchColumnFlag( m_xConnection, nDataType );
+ if ( eColumnSearch == ColumnSearch::NONE )
+ continue;
+
+ sal_Bool bIsSearchable( sal_True );
+ OSL_VERIFY( xColumn->getPropertyValue( PROPERTY_ISSEARCHABLE ) >>= bIsSearchable );
+ if ( !bIsSearchable )
+ continue;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ aLB_WHEREFIELD1.InsertEntry( *pIter );
+ aLB_WHEREFIELD2.InsertEntry( *pIter );
+ aLB_WHEREFIELD3.InsertEntry( *pIter );
+ }
+
+ Reference<XNameAccess> xSelectColumns = Reference<XColumnsSupplier>(m_xQueryComposer,UNO_QUERY)->getColumns();
+ aNames = xSelectColumns->getElementNames();
+ pIter = aNames.getConstArray();
+ pEnd = pIter + aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ // don't insert a column name twice
+ if ( !m_xColumns->hasByName(*pIter) )
+ {
+ xColumn.set(xSelectColumns->getByName(*pIter),UNO_QUERY);
+ OSL_ENSURE(xColumn.is(),"DlgFilterCrit::DlgFilterCrit: Column is null!");
+ sal_Int32 nDataType(0);
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
+ sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
+ // TODO
+ // !pColumn->IsFunction()
+ if(eColumnSearch != ColumnSearch::NONE)
+ {
+ aLB_WHEREFIELD1.InsertEntry( *pIter );
+ aLB_WHEREFIELD2.InsertEntry( *pIter );
+ aLB_WHEREFIELD3.InsertEntry( *pIter );
+ }
+ }
+ }
+ // initialize the listboxes with noEntry
+ aLB_WHEREFIELD1.SelectEntryPos(0);
+ aLB_WHEREFIELD2.SelectEntryPos(0);
+ aLB_WHEREFIELD3.SelectEntryPos(0);
+
+ // insert the criteria into the dialog
+ Sequence<Sequence<PropertyValue > > aValues = m_xQueryComposer->getStructuredFilter();
+ fillLines(aValues);
+ aValues = m_xQueryComposer->getStructuredHavingClause();
+ fillLines(aValues);
+
+ }
+ catch(Exception&)
+ {
+ FreeResource();
+ throw;
+ }
+
+ EnableLines();
+
+ aLB_WHEREFIELD1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
+ aLB_WHEREFIELD2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
+ aLB_WHEREFIELD3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectHdl));
+
+ aLB_WHERECOMP1.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
+ aLB_WHERECOMP2.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
+ aLB_WHERECOMP3.SetSelectHdl(LINK(this,DlgFilterCrit,ListSelectCompHdl));
+
+ aET_WHEREVALUE1.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
+ aET_WHEREVALUE2.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
+ aET_WHEREVALUE3.SetLoseFocusHdl( LINK( this, DlgFilterCrit, PredicateLoseFocus ) );
+
+ if ( aET_WHEREVALUE1.IsEnabled() )
+ aET_WHEREVALUE1.GrabFocus();
+
+ FreeResource();
+}
+//------------------------------------------------------------------------------
+DlgFilterCrit::~DlgFilterCrit()
+{
+ DBG_DTOR(DlgFilterCrit,NULL);
+}
+
+#define LbText(x) ((x).GetSelectEntry())
+#define LbPos(x) ((x).GetSelectEntryPos())
+
+//------------------------------------------------------------------------------
+sal_Int32 DlgFilterCrit::GetOSQLPredicateType( const String& _rSelectedPredicate ) const
+{
+ sal_Int32 nPredicateIndex = -1;
+ for ( xub_StrLen i=0; i<aSTR_COMPARE_OPERATORS.GetTokenCount(); ++i)
+ if ( aSTR_COMPARE_OPERATORS.GetToken(i) == _rSelectedPredicate )
+ {
+ nPredicateIndex = i;
+ break;
+ }
+
+ sal_Int32 nPredicateType = SQLFilterOperator::NOT_SQLNULL;
+ switch ( nPredicateIndex )
+ {
+ case 0:
+ nPredicateType = SQLFilterOperator::EQUAL;
+ break;
+ case 1:
+ nPredicateType = SQLFilterOperator::NOT_EQUAL;
+ break;
+ case 2:
+ nPredicateType = SQLFilterOperator::LESS;
+ break;
+ case 3:
+ nPredicateType = SQLFilterOperator::LESS_EQUAL;
+ break;
+ case 4:
+ nPredicateType = SQLFilterOperator::GREATER;
+ break;
+ case 5:
+ nPredicateType = SQLFilterOperator::GREATER_EQUAL;
+ break;
+ case 6:
+ nPredicateType = SQLFilterOperator::LIKE;
+ break;
+ case 7:
+ nPredicateType = SQLFilterOperator::NOT_LIKE;
+ break;
+ case 8:
+ nPredicateType = SQLFilterOperator::SQLNULL;
+ break;
+ case 9:
+ nPredicateType = SQLFilterOperator::NOT_SQLNULL;
+ break;
+ default:
+ OSL_FAIL( "DlgFilterCrit::GetOSQLPredicateType: unknown predicate string!" );
+ break;
+ }
+
+ return nPredicateType;
+}
+//------------------------------------------------------------------------------
+sal_uInt16 DlgFilterCrit::GetSelectionPos(sal_Int32 eType,const ListBox& rListBox) const
+{
+ sal_uInt16 nPos;
+ switch(eType)
+ {
+ case SQLFilterOperator::EQUAL:
+ nPos = 0;
+ break;
+ case SQLFilterOperator::NOT_EQUAL:
+ nPos = 1;
+ break;
+ case SQLFilterOperator::LESS:
+ nPos = 2;
+ break;
+ case SQLFilterOperator::LESS_EQUAL:
+ nPos = 3;
+ break;
+ case SQLFilterOperator::GREATER:
+ nPos = 4;
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ nPos = 5;
+ break;
+ case SQLFilterOperator::NOT_LIKE:
+ nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-3 : 0;
+ break;
+ case SQLFilterOperator::LIKE:
+ nPos = rListBox.GetEntryCount() > 2 ? rListBox.GetEntryCount()-4 : 1;
+ break;
+ case SQLFilterOperator::SQLNULL:
+ nPos = rListBox.GetEntryCount()-2;
+ break;
+ case SQLFilterOperator::NOT_SQLNULL:
+ nPos = rListBox.GetEntryCount()-1;
+ break;
+ default:
+ // TODO What value should this be?
+ nPos = 0;
+ break;
+ }
+ return nPos;
+}
+// -----------------------------------------------------------------------------
+sal_Bool DlgFilterCrit::getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,PropertyValue& _rFilter) const
+{
+ sal_Bool bHaving = sal_False;
+ try
+ {
+ ::rtl::OUString sTableName;
+ sal_Bool bFunction = sal_False;
+ _rFilter.Name = _rField.GetSelectEntry();
+ Reference< XPropertySet > xColumn = getQueryColumn(_rFilter.Name);
+ if ( xColumn.is() )
+ {
+ Reference< XPropertySetInfo > xInfo = xColumn->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName(PROPERTY_REALNAME) )
+ {
+ if ( xInfo->hasPropertyByName(PROPERTY_TABLENAME) )
+ {
+ xColumn->getPropertyValue(PROPERTY_TABLENAME) >>= sTableName;
+ if ( sTableName.getLength() )
+ {
+ // properly quote all parts of the table name, so e.g. <schema>.<table> becomes "<schema>"."<table>"
+ ::rtl::OUString aCatlog,aSchema,aTable;
+ ::dbtools::qualifiedNameComponents( m_xMetaData, sTableName, aCatlog, aSchema, aTable, ::dbtools::eInDataManipulation );
+ sTableName = ::dbtools::composeTableName( m_xMetaData, aCatlog, aSchema, aTable, sal_True, ::dbtools::eInDataManipulation );
+ }
+ }
+ xColumn->getPropertyValue(PROPERTY_REALNAME) >>= _rFilter.Name;
+ static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
+ if ( xInfo->hasPropertyByName(sAgg) )
+ xColumn->getPropertyValue(sAgg) >>= bHaving;
+ static ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("Function"));
+ if ( xInfo->hasPropertyByName(sFunction) )
+ xColumn->getPropertyValue(sFunction) >>= bFunction;
+ }
+ if ( !bFunction )
+ {
+ const ::rtl::OUString aQuote = m_xMetaData.is() ? m_xMetaData->getIdentifierQuoteString() : ::rtl::OUString();
+ _rFilter.Name = ::dbtools::quoteName(aQuote,_rFilter.Name);
+ if ( sTableName.getLength() )
+ {
+ static ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM("."));
+ sTableName += sSep;
+ sTableName += _rFilter.Name;
+ _rFilter.Name = sTableName;
+ }
+ }
+ }
+ }
+ catch(Exception)
+ {
+ }
+
+ _rFilter.Handle = GetOSQLPredicateType( _rComp.GetSelectEntry() );
+ if ( SQLFilterOperator::SQLNULL != _rFilter.Handle && _rFilter.Handle != SQLFilterOperator::NOT_SQLNULL )
+ {
+ String sPredicateValue = m_aPredicateInput.getPredicateValue( _rValue.GetText(), getMatchingColumn( _rValue ), sal_True );
+ ::Replace_OS_PlaceHolder( sPredicateValue );
+ _rFilter.Value <<= ::rtl::OUString(sPredicateValue);
+ }
+ return bHaving;
+}
+
+//------------------------------------------------------------------------------
+Reference< XPropertySet > DlgFilterCrit::getColumn( const ::rtl::OUString& _rFieldName ) const
+{
+ Reference< XPropertySet > xColumn;
+ try
+ {
+ if ( m_xColumns.is() && m_xColumns->hasByName( _rFieldName ) )
+ m_xColumns->getByName( _rFieldName ) >>= xColumn;
+
+ Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+ if ( xColumns.is() && !xColumn.is() )
+ {
+ Sequence< ::rtl::OUString> aSeq = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ Reference<XPropertySet> xProp(xColumns->getByName(*pIter),UNO_QUERY);
+ if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) )
+ {
+ ::rtl::OUString sRealName;
+ xProp->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ if ( sRealName == _rFieldName )
+ {
+ if ( m_xColumns.is() && m_xColumns->hasByName( *pIter ) )
+ m_xColumns->getByName( *pIter ) >>= xColumn;
+ break;
+ }
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xColumn;
+}
+//------------------------------------------------------------------------------
+Reference< XPropertySet > DlgFilterCrit::getQueryColumn( const ::rtl::OUString& _rFieldName ) const
+{
+ Reference< XPropertySet > xColumn;
+ try
+ {
+ Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+ if ( xColumns.is() && xColumns->hasByName( _rFieldName ) )
+ xColumns->getByName( _rFieldName ) >>= xColumn;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xColumn;
+}
+
+//------------------------------------------------------------------------------
+Reference< XPropertySet > DlgFilterCrit::getMatchingColumn( const Edit& _rValueInput ) const
+{
+ // the name
+ ::rtl::OUString sField;
+ if ( &_rValueInput == &aET_WHEREVALUE1 )
+ {
+ sField = aLB_WHEREFIELD1.GetSelectEntry();
+ }
+ else if ( &_rValueInput == &aET_WHEREVALUE2 )
+ {
+ sField = aLB_WHEREFIELD2.GetSelectEntry();
+ }
+ else if ( &_rValueInput == &aET_WHEREVALUE3 )
+ {
+ sField = aLB_WHEREFIELD3.GetSelectEntry();
+ }
+ else {
+ OSL_FAIL( "DlgFilterCrit::getMatchingColumn: invalid event source!" );
+ }
+
+ // the field itself
+ return getColumn( sField );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Edit*, _pField )
+{
+ OSL_ENSURE( _pField, "DlgFilterCrit::PredicateLoseFocus: invalid event source!" );
+ if ( _pField )
+ {
+ // retrieve the field affected
+ Reference< XPropertySet> xColumn( getMatchingColumn( *_pField ) );
+ // and normalize it's content
+ if ( xColumn.is() )
+ {
+ ::rtl::OUString sText( _pField->GetText() );
+ m_aPredicateInput.normalizePredicateString( sText, xColumn );
+ _pField->SetText( sText );
+ }
+ }
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,sal_Bool _bOr )
+{
+ DBG_CHKTHIS(DlgFilterCrit,NULL);
+ ::rtl::OUString aCondition;
+ _rItem.Value >>= aCondition;
+ String aStr = aCondition.getStr();
+ ::Replace_SQL_PlaceHolder(aStr);
+ aStr.EraseTrailingChars();
+
+ Reference< XPropertySet > xColumn = getColumn( _rItem.Name );
+
+ // remove the predicate from the condition
+ switch(_rItem.Handle)
+ {
+ case SQLFilterOperator::EQUAL:
+ // aStr.Erase(0,1);
+ break;
+ case SQLFilterOperator::NOT_EQUAL:
+ aStr.Erase(0,2);
+ break;
+ case SQLFilterOperator::LESS:
+ aStr.Erase(0,1);
+ break;
+ case SQLFilterOperator::LESS_EQUAL:
+ aStr.Erase(0,2);
+ break;
+ case SQLFilterOperator::GREATER:
+ aStr.Erase(0,1);
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ aStr.Erase(0,2);
+ break;
+ case SQLFilterOperator::NOT_LIKE:
+ aStr.Erase(0,8);
+ break;
+ case SQLFilterOperator::LIKE:
+ aStr.Erase(0,4);
+ break;
+ case SQLFilterOperator::SQLNULL:
+ aStr.Erase(0,7);
+ break;
+ case SQLFilterOperator::NOT_SQLNULL:
+ aStr.Erase(0,11);
+ break;
+ }
+ aStr.EraseLeadingChars();
+
+ // to make sure that we only set first three
+ ListBox* pColumnListControl = NULL;
+ ListBox* pPredicateListControl = NULL;
+ Edit* pPredicateValueControl = NULL;
+ switch( nIdx )
+ {
+ case 0:
+ pColumnListControl = &aLB_WHEREFIELD1;
+ pPredicateListControl = &aLB_WHERECOMP1;
+ pPredicateValueControl = &aET_WHEREVALUE1;
+ break;
+
+ case 1:
+ aLB_WHERECOND2.SelectEntryPos( _bOr ? 1 : 0 );
+
+ pColumnListControl = &aLB_WHEREFIELD2;
+ pPredicateListControl = &aLB_WHERECOMP2;
+ pPredicateValueControl = &aET_WHEREVALUE2;
+ break;
+
+ case 2:
+ aLB_WHERECOND3.SelectEntryPos( _bOr ? 1 : 0 );
+
+ pColumnListControl = &aLB_WHEREFIELD3;
+ pPredicateListControl = &aLB_WHERECOMP3;
+ pPredicateValueControl = &aET_WHEREVALUE3;
+ break;
+ }
+
+ if ( pColumnListControl && pPredicateListControl && pPredicateValueControl )
+ {
+ ::rtl::OUString sName;
+ if ( xColumn.is() )
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ else
+ sName = _rItem.Name;
+ // select the appropriate field name
+ SelectField( *pColumnListControl, sName );
+ ListSelectHdl( pColumnListControl );
+
+ // select the appropriate condition
+ pPredicateListControl->SelectEntryPos( GetSelectionPos( (sal_Int32)_rItem.Handle, *pPredicateListControl ) );
+
+ // initially normalize this value
+ ::rtl::OUString aString( aStr );
+ m_aPredicateInput.normalizePredicateString( aString, xColumn );
+ pPredicateValueControl->SetText( aString );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DlgFilterCrit::SelectField( ListBox& rBox, const String& rField )
+{
+ DBG_CHKTHIS(DlgFilterCrit,NULL);
+ sal_uInt16 nCnt = rBox.GetEntryCount();
+
+ for( sal_uInt16 i=0 ; i<nCnt ; i++ )
+ {
+ if(rBox.GetEntry(i) == rField)
+ {
+ rBox.SelectEntryPos(i);
+ return;
+ }
+ }
+
+ rBox.SelectEntryPos(0);
+}
+
+//------------------------------------------------------------------------------
+void DlgFilterCrit::EnableLines()
+{
+ DBG_CHKTHIS(DlgFilterCrit,NULL);
+ // Enablen/Disablen ganzer Zeilen
+ if( LbPos(aLB_WHEREFIELD1) == 0 )
+ {
+ aLB_WHEREFIELD2.Disable();
+ aLB_WHERECOND2.Disable();
+ aLB_WHERECOMP2.Disable();
+ aET_WHEREVALUE2.Disable();
+
+ aLB_WHEREFIELD3.Disable();
+ aLB_WHERECOND3.Disable();
+ aLB_WHERECOMP3.Disable();
+ aET_WHEREVALUE3.Disable();
+ }
+ else
+ {
+ aLB_WHEREFIELD2.Enable();
+ aLB_WHERECOND2.Enable();
+ aLB_WHERECOMP2.Enable();
+ aET_WHEREVALUE2.Enable();
+
+ aLB_WHEREFIELD3.Enable();
+ aLB_WHERECOND3.Enable();
+ aLB_WHERECOMP3.Enable();
+ aET_WHEREVALUE3.Enable();
+ }
+
+ if( LbPos(aLB_WHEREFIELD2) == 0 )
+ {
+ aLB_WHEREFIELD3.Disable();
+ aLB_WHERECOND3.Disable();
+ aLB_WHERECOMP3.Disable();
+ aET_WHEREVALUE3.Disable();
+ }
+ else
+ {
+ aLB_WHEREFIELD3.Enable();
+ aLB_WHERECOND3.Enable();
+ aLB_WHERECOMP3.Enable();
+ aET_WHEREVALUE3.Enable();
+ }
+
+ // Vergleichsfeld gleich NOENTRY
+ if( LbPos(aLB_WHEREFIELD1) == 0 )
+ {
+ aLB_WHERECOMP1.Disable();
+ aET_WHEREVALUE1.Disable();
+ }
+ else
+ {
+ aLB_WHEREFIELD1.Enable();
+ aLB_WHERECOMP1.Enable();
+ aET_WHEREVALUE1.Enable();
+ }
+
+ if( LbPos(aLB_WHEREFIELD2) == 0 )
+ {
+ aLB_WHERECOND2.Disable();
+ aLB_WHERECOMP2.Disable();
+ aET_WHEREVALUE2.Disable();
+ }
+ else
+ {
+ aLB_WHERECOND2.Enable();
+ aLB_WHEREFIELD2.Enable();
+ aLB_WHERECOMP2.Enable();
+ aET_WHEREVALUE2.Enable();
+ }
+
+ if( LbPos(aLB_WHEREFIELD3) == 0 )
+ {
+ aLB_WHERECOND3.Disable();
+ aLB_WHERECOMP3.Disable();
+ aET_WHEREVALUE3.Disable();
+ }
+ else
+ {
+ aLB_WHERECOND3.Enable();
+ aLB_WHERECOND3.Enable();
+ aLB_WHEREFIELD3.Enable();
+ aLB_WHERECOMP3.Enable();
+ aET_WHEREVALUE3.Enable();
+ }
+
+ // Vergleichsoperator gleich ISNULL oder ISNOTNULL
+ if(aLB_WHERECOMP1.GetEntryCount() > 2 &&
+ ((LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-1) ||
+ (LbPos(aLB_WHERECOMP1) == aLB_WHERECOMP1.GetEntryCount()-2)) )
+ aET_WHEREVALUE1.Disable();
+
+ if(aLB_WHERECOMP2.GetEntryCount() > 2 &&
+ ((LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-1) ||
+ (LbPos(aLB_WHERECOMP2) == aLB_WHERECOMP2.GetEntryCount()-2)) )
+ aET_WHEREVALUE2.Disable();
+
+ if(aLB_WHERECOMP3.GetEntryCount() > 2 &&
+ ((LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-1) ||
+ (LbPos(aLB_WHERECOMP3) == aLB_WHERECOMP3.GetEntryCount()-2)) )
+ aET_WHEREVALUE3.Disable();
+
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DlgFilterCrit, ListSelectHdl, ListBox *, pListBox )
+{
+ String aName;
+ ListBox* pComp;
+ if(pListBox == &aLB_WHEREFIELD1)
+ {
+ aName = LbText(aLB_WHEREFIELD1);
+ pComp = &aLB_WHERECOMP1;
+ }
+ else if(pListBox == &aLB_WHEREFIELD2)
+ {
+ aName = LbText(aLB_WHEREFIELD2);
+ pComp = &aLB_WHERECOMP2;
+ }
+ else
+ {
+ aName = LbText(aLB_WHEREFIELD3);
+ pComp = &aLB_WHERECOMP3;
+ }
+
+ pComp->Clear();
+
+ Reference<XPropertySet> xColumn = getColumn(aName);
+ if ( xColumn.is() )
+ {
+ sal_Int32 nDataType = 0;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
+ sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
+
+ if(eColumnSearch == ColumnSearch::FULL)
+ {
+ for(xub_StrLen i=0;i<aSTR_COMPARE_OPERATORS.GetTokenCount();i++)
+ pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
+ }
+ else if(eColumnSearch == ColumnSearch::CHAR)
+ {
+ for(xub_StrLen i=6;i<10;i++)
+ pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
+ }
+ else if(eColumnSearch == ColumnSearch::BASIC)
+ {
+ xub_StrLen i;
+ for( i = 0; i < 6; i++ )
+ pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
+ for(i=8;i<aSTR_COMPARE_OPERATORS.GetTokenCount();i++)
+ pComp->InsertEntry(aSTR_COMPARE_OPERATORS.GetToken(i));
+ }
+ else
+ {
+ OSL_FAIL("DlgFilterCrit::ListSelectHdl: Diese Column d�rfte garnicht vorhanden sein!");
+ }
+ }
+ pComp->SelectEntryPos(0);
+
+ EnableLines();
+ return 0;
+}
+
+
+
+//------------------------------------------------------------------------------
+IMPL_LINK_INLINE_START( DlgFilterCrit, ListSelectCompHdl, ListBox *, /*pListBox*/ )
+{
+ EnableLines();
+ return 0;
+}
+IMPL_LINK_INLINE_END( DlgFilterCrit, ListSelectCompHdl, ListBox *, pListBox )
+//------------------------------------------------------------------------------
+void DlgFilterCrit::BuildWherePart()
+{
+ DBG_CHKTHIS(DlgFilterCrit,NULL);
+ Sequence<Sequence<PropertyValue> > aFilter,aHaving;
+ aFilter.realloc(1);
+ aHaving.realloc(1);
+
+ if( LbPos(aLB_WHEREFIELD1) != 0 )
+ {
+ PropertyValue aValue;
+ if ( getCondition(aLB_WHEREFIELD1,aLB_WHERECOMP1,aET_WHEREVALUE1,aValue) )
+ {
+ aHaving[0].realloc(1);
+ aHaving[0][0] = aValue;
+ }
+ else
+ {
+ aFilter[0].realloc(1);
+ aFilter[0][0] = aValue;
+ }
+ }
+
+ if( LbPos(aLB_WHEREFIELD2) != 0 )
+ {
+ PropertyValue aValue;
+ Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
+ if ( getCondition(aLB_WHEREFIELD2,aLB_WHERECOMP2,aET_WHEREVALUE2,aValue) )
+ _rValues = aHaving;
+ PropertyValue* pPos = NULL;
+ if ( aLB_WHERECOND2.GetSelectEntryPos() )
+ {
+ sal_Int32 nPos = _rValues.getLength();
+ _rValues.realloc( nPos + 1);
+ _rValues[nPos].realloc( 1);
+ pPos = &_rValues[nPos][0];
+ }
+ else
+ {
+ sal_Int32 nPos = _rValues.getLength() - 1;
+ sal_Int32 nAndPos = _rValues[nPos].getLength();
+ _rValues[nPos].realloc( _rValues[nPos].getLength() + 1);
+ pPos = &_rValues[nPos][nAndPos];
+ }
+ *pPos = aValue;
+ }
+
+ if( LbPos(aLB_WHEREFIELD3) != 0 )
+ {
+ PropertyValue aValue;
+ Sequence<Sequence<PropertyValue> >& _rValues = aFilter;
+ if ( getCondition(aLB_WHEREFIELD3,aLB_WHERECOMP3,aET_WHEREVALUE3,aValue) )
+ _rValues = aHaving;
+ PropertyValue* pPos = NULL;
+ if ( aLB_WHERECOND3.GetSelectEntryPos() )
+ {
+ sal_Int32 nPos = _rValues.getLength();
+ _rValues.realloc( nPos + 1);
+ _rValues[nPos].realloc( 1);
+ pPos = &_rValues[nPos][0];
+ }
+ else
+ {
+ sal_Int32 nPos = _rValues.getLength() - 1;
+ sal_Int32 nAndPos = _rValues[nPos].getLength();
+ _rValues[nPos].realloc( _rValues[nPos].getLength() + 1);
+ pPos = &_rValues[nPos][nAndPos];
+ }
+ *pPos = aValue;
+ }
+ try
+ {
+ m_xQueryComposer->setStructuredFilter(aFilter);
+ m_xQueryComposer->setStructuredHavingClause(aHaving);
+ }
+ catch(Exception)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void DlgFilterCrit::fillLines(const Sequence<Sequence<PropertyValue > >& _aValues)
+{
+ const Sequence<PropertyValue >* pOrIter = _aValues.getConstArray();
+ const Sequence<PropertyValue >* pOrEnd = pOrIter + _aValues.getLength();
+ sal_Bool bOr = sal_True;
+ for(sal_uInt16 i=0;pOrIter != pOrEnd; ++pOrIter)
+ {
+ bOr = sal_True;
+ const PropertyValue* pAndIter = pOrIter->getConstArray();
+ const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength();
+ for(;pAndIter != pAndEnd; ++pAndIter)
+ {
+ SetLine( i++,*pAndIter,bOr);
+ bOr = sal_False;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/queryfilter.hrc b/dbaccess/source/ui/dlg/queryfilter.hrc
new file mode 100644
index 000000000000..ff2aaaca30d0
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryfilter.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYFILTER_HRC
+#define DBAUI_QUERYFILTER_HRC
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+#define FT_WHEREFIELD 1
+#define FT_WHERECOMP 2
+#define FT_WHEREVALUE 3
+#define FT_WHEREOPER 4
+
+#define LB_WHEREFIELD1 1
+#define LB_WHERECOMP1 2
+#define LB_WHEREFIELD2 3
+#define LB_WHERECOMP2 4
+#define LB_WHEREFIELD3 5
+#define LB_WHERECOMP3 6
+#define LB_WHERECOND2 7
+#define LB_WHERECOND3 8
+
+#define FL_FIELDS 1
+
+#define ET_WHEREVALUE1 1
+#define ET_WHEREVALUE2 2
+#define ET_WHEREVALUE3 3
+
+#define STR_NOENTRY 1
+#define STR_NOENTRY2 2
+#define STR_DEFAULT 3
+#define STR_COMPARE_OPERATORS 4
+
+#define BT_OK 1
+#define BT_CANCEL 2
+#define BT_HELP 3
+
+#endif // DBAUI_QUERYFILTER_HRC
+
diff --git a/dbaccess/source/ui/dlg/queryfilter.src b/dbaccess/source/ui/dlg/queryfilter.src
new file mode 100644
index 000000000000..6d273b5c53aa
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryfilter.src
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYFILTER_HRC
+#include "queryfilter.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+
+ModalDialog DLG_FILTERCRIT
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 303 , 76 ) ;
+ /* These strings are equal to the toolbox bubble helptext from MID_SBA_QRY_FILTERCRIT in toolbox.hrc */
+ Text [ en-US ] ="Standard Filter";
+
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ HelpId = HID_DLG_FILTERCRIT ;
+ ListBox LB_WHEREFIELD1
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHEREFIELD1";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_WHERECOMP1
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHERECOMP1";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 25 ) ;
+ Size = MAP_APPFONT ( 49 , 72 ) ;
+ TabStop = TRUE ;
+ DDExtraWidth = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ };
+ Edit ET_WHEREVALUE1
+ {
+ HelpID = "dbaccess:Edit:DLG_FILTERCRIT:ET_WHEREVALUE1";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 177 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_WHERECOND2
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHERECOND2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , 41 ) ;
+ Size = MAP_APPFONT ( 41 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_WHEREFIELD2
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHEREFIELD2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_WHERECOMP2
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHERECOMP2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 41 ) ;
+ Size = MAP_APPFONT ( 49 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ CurPos = 0 ;
+ };
+ Edit ET_WHEREVALUE2
+ {
+ HelpID = "dbaccess:Edit:DLG_FILTERCRIT:ET_WHEREVALUE2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 177 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_WHERECOND3
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHERECOND3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 15 , 57 ) ;
+ Size = MAP_APPFONT ( 41 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_WHEREFIELD3
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHEREFIELD3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_WHERECOMP3
+ {
+ HelpID = "dbaccess:ListBox:DLG_FILTERCRIT:LB_WHERECOMP3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 57 ) ;
+ Size = MAP_APPFONT ( 49 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ CurPos = 0 ;
+ };
+ Edit ET_WHEREVALUE3
+ {
+ HelpID = "dbaccess:Edit:DLG_FILTERCRIT:ET_WHEREVALUE3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 177 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_WHEREFIELD
+ {
+ Pos = MAP_APPFONT ( 60 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "Field name" ;
+ };
+ FixedText FT_WHERECOMP
+ {
+ Pos = MAP_APPFONT ( 124 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ FixedText FT_WHEREVALUE
+ {
+ Pos = MAP_APPFONT ( 177 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "Value" ;
+ };
+ FixedText FT_WHEREOPER
+ {
+ Pos = MAP_APPFONT ( 15 , 14 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "Operator" ;
+ };
+ FixedLine FL_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 236 , 8 ) ;
+ Text [ en-US ] = "Criteria" ;
+ };
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 249 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 249 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 249 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_NOENTRY
+ {
+ Text [ en-US ] = "- none -" ;
+ };
+ String STR_COMPARE_OPERATORS
+ {
+ Text [ en-US ] = "=;<>;<;<=;>;>=;like;not like;null;not null";
+ };
+};
diff --git a/dbaccess/source/ui/dlg/queryorder.cxx b/dbaccess/source/ui/dlg/queryorder.cxx
new file mode 100644
index 000000000000..75f60ec28d81
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryorder.cxx
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "queryorder.hrc"
+#include "queryorder.hxx"
+
+#include "dbustrings.hrc"
+
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <tools/debug.hxx>
+#include "moduledbu.hxx"
+#include <connectivity/sqliterator.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+
+using namespace dbaui;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+
+DBG_NAME(DlgOrderCrit)
+//------------------------------------------------------------------------------
+DlgOrderCrit::DlgOrderCrit( Window * pParent,
+ const Reference< XConnection>& _rxConnection,
+ const Reference< XSingleSelectQueryComposer >& _rxComposer,
+ const Reference< XNameAccess>& _rxCols)
+ :ModalDialog( pParent, ModuleRes(DLG_ORDERCRIT) )
+ ,aLB_ORDERFIELD1( this, ModuleRes( LB_ORDERFIELD1 ) )
+ ,aLB_ORDERVALUE1( this, ModuleRes( LB_ORDERVALUE1 ) )
+ ,aLB_ORDERFIELD2( this, ModuleRes( LB_ORDERFIELD2 ) )
+ ,aLB_ORDERVALUE2( this, ModuleRes( LB_ORDERVALUE2 ) )
+ ,aLB_ORDERFIELD3( this, ModuleRes( LB_ORDERFIELD3 ) )
+ ,aLB_ORDERVALUE3( this, ModuleRes( LB_ORDERVALUE3 ) )
+ ,aFT_ORDERFIELD( this, ModuleRes( FT_ORDERFIELD ) )
+ ,aFT_ORDERAFTER1( this, ModuleRes( FT_ORDERAFTER1 ) )
+ ,aFT_ORDERAFTER2( this, ModuleRes( FT_ORDERAFTER2 ) )
+ ,aFT_ORDEROPER( this, ModuleRes( FT_ORDEROPER ) )
+ ,aFT_ORDERDIR( this, ModuleRes( FT_ORDERDIR ) )
+ ,aBT_OK( this, ModuleRes( BT_OK ) )
+ ,aBT_CANCEL( this, ModuleRes( BT_CANCEL ) )
+ ,aBT_HELP( this, ModuleRes( BT_HELP ) )
+ ,aFL_ORDER( this, ModuleRes( FL_ORDER ) )
+ ,aSTR_NOENTRY( ModuleRes( STR_NOENTRY ) )
+ ,m_xQueryComposer( _rxComposer )
+ ,m_xColumns(_rxCols)
+ ,m_xConnection(_rxConnection)
+{
+ DBG_CTOR(DlgOrderCrit,NULL);
+
+ AllSettings aSettings( GetSettings() );
+ StyleSettings aStyle( aSettings.GetStyleSettings() );
+ aStyle.SetAutoMnemonic( sal_False );
+ aSettings.SetStyleSettings( aStyle );
+ SetSettings( aSettings );
+
+ m_aColumnList[0] = &aLB_ORDERFIELD1;
+ m_aColumnList[1] = &aLB_ORDERFIELD2;
+ m_aColumnList[2] = &aLB_ORDERFIELD3;
+
+ m_aValueList[0] = &aLB_ORDERVALUE1;
+ m_aValueList[1] = &aLB_ORDERVALUE2;
+ m_aValueList[2] = &aLB_ORDERVALUE3;
+
+ xub_StrLen j;
+ for(j=0 ; j < DOG_ROWS ; j++ )
+ {
+ m_aColumnList[j]->InsertEntry( aSTR_NOENTRY );
+ }
+
+ for( j=0 ; j < DOG_ROWS ; j++ )
+ {
+ m_aColumnList[j]->SelectEntryPos(0);
+ m_aValueList[j]->SelectEntryPos(0);
+ }
+ try
+ {
+ // ... sowie auch die restlichen Felder
+ Sequence< ::rtl::OUString> aNames = m_xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ Reference<XPropertySet> xColumn;
+ for(;pIter != pEnd;++pIter)
+ {
+ xColumn.set(m_xColumns->getByName(*pIter),UNO_QUERY);
+ OSL_ENSURE(xColumn.is(),"Column is null!");
+ if ( xColumn.is() )
+ {
+ sal_Int32 nDataType = 0;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
+ sal_Int32 eColumnSearch = dbtools::getSearchColumnFlag(m_xConnection,nDataType);
+ if(eColumnSearch != ColumnSearch::NONE)
+ {
+ for( j=0 ; j < DOG_ROWS ; j++ )
+ {
+ m_aColumnList[j]->InsertEntry(*pIter);
+ }
+ }
+ }
+ }
+
+ m_sOrgOrder = m_xQueryComposer->getOrder();
+ impl_initializeOrderList_nothrow();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ EnableLines();
+
+ aLB_ORDERFIELD1.SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl));
+ aLB_ORDERFIELD2.SetSelectHdl(LINK(this,DlgOrderCrit,FieldListSelectHdl));
+
+ FreeResource();
+
+}
+
+//------------------------------------------------------------------------------
+
+#define LbText(x) ((x).GetSelectEntry())
+#define LbPos(x) ((x).GetSelectEntryPos())
+
+//------------------------------------------------------------------------------
+DlgOrderCrit::~DlgOrderCrit()
+{
+ DBG_DTOR(DlgOrderCrit,NULL);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK_INLINE_START( DlgOrderCrit, FieldListSelectHdl, ListBox *, /*pListBox*/ )
+{
+ DBG_CHKTHIS(DlgOrderCrit,NULL);
+ EnableLines();
+ return 0;
+}
+IMPL_LINK_INLINE_END( DlgOrderCrit, FieldListSelectHdl, ListBox *, pListBox )
+
+//------------------------------------------------------------------------------
+void DlgOrderCrit::impl_initializeOrderList_nothrow()
+{
+ try
+ {
+ const ::rtl::OUString sNameProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
+ const ::rtl::OUString sAscendingProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAscending" ) );
+
+ Reference< XIndexAccess > xOrderColumns( m_xQueryComposer->getOrderColumns(), UNO_QUERY_THROW );
+ sal_Int32 nColumns = xOrderColumns->getCount();
+ if ( nColumns > DOG_ROWS )
+ nColumns = DOG_ROWS;
+
+ for ( sal_Int32 i = 0; i < nColumns; ++i )
+ {
+ Reference< XPropertySet > xColumn( xOrderColumns->getByIndex( i ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sColumnName;
+ sal_Bool bIsAscending( sal_True );
+
+ xColumn->getPropertyValue( sNameProperty ) >>= sColumnName;
+ xColumn->getPropertyValue( sAscendingProperty ) >>= bIsAscending;
+
+ m_aColumnList[i]->SelectEntry( sColumnName );
+ m_aValueList[i]->SelectEntryPos( bIsAscending ? 0 : 1 );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DlgOrderCrit::EnableLines()
+{
+ DBG_CHKTHIS(DlgOrderCrit,NULL);
+
+ if ( aLB_ORDERFIELD1.GetSelectEntryPos() == 0 )
+ {
+ aLB_ORDERFIELD2.Disable();
+ aLB_ORDERVALUE2.Disable();
+
+ aLB_ORDERFIELD2.SelectEntryPos( 0 );
+ aLB_ORDERVALUE2.SelectEntryPos( 0 );
+ }
+ else
+ {
+ aLB_ORDERFIELD2.Enable();
+ aLB_ORDERVALUE2.Enable();
+ }
+
+ if ( aLB_ORDERFIELD2.GetSelectEntryPos() == 0 )
+ {
+ aLB_ORDERFIELD3.Disable();
+ aLB_ORDERVALUE3.Disable();
+
+ aLB_ORDERFIELD3.SelectEntryPos( 0 );
+ aLB_ORDERVALUE3.SelectEntryPos( 0 );
+ }
+ else
+ {
+ aLB_ORDERFIELD3.Enable();
+ aLB_ORDERVALUE3.Enable();
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString DlgOrderCrit::GetOrderList( ) const
+{
+ DBG_CHKTHIS(DlgOrderCrit,NULL);
+ Reference<XDatabaseMetaData> xMetaData = m_xConnection->getMetaData();
+ ::rtl::OUString sQuote = xMetaData.is() ? xMetaData->getIdentifierQuoteString() : ::rtl::OUString();
+ static const ::rtl::OUString sDESC(RTL_CONSTASCII_USTRINGPARAM(" DESC "));
+ static const ::rtl::OUString sASC(RTL_CONSTASCII_USTRINGPARAM(" ASC "));
+
+ Reference< XNameAccess> xColumns = Reference< XColumnsSupplier >(m_xQueryComposer,UNO_QUERY)->getColumns();
+
+ ::rtl::OUString sOrder;
+ for( sal_uInt16 i=0 ; i<DOG_ROWS; i++ )
+ {
+ if(m_aColumnList[i]->GetSelectEntryPos() != 0)
+ {
+ if(sOrder.getLength())
+ sOrder += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+
+ String sName = m_aColumnList[i]->GetSelectEntry();
+ try
+ {
+ sal_Bool bFunction = sal_False;
+ Reference< XPropertySet > xColumn;
+ if ( xColumns.is() && xColumns->hasByName( sName ) && (xColumns->getByName( sName ) >>= xColumn) && xColumn.is() )
+ {
+ if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_REALNAME) )
+ {
+ ::rtl::OUString sRealName;
+ xColumn->getPropertyValue(PROPERTY_REALNAME) >>= sRealName;
+ sName = sRealName;
+ static ::rtl::OUString sAgg(RTL_CONSTASCII_USTRINGPARAM("AggregateFunction"));
+ static ::rtl::OUString sFunction(RTL_CONSTASCII_USTRINGPARAM("Function"));
+ if ( xColumn->getPropertySetInfo()->hasPropertyByName(sFunction) )
+ xColumn->getPropertyValue(sFunction) >>= bFunction;
+ }
+ }
+ if ( bFunction )
+ sOrder += sName;
+ else
+ sOrder += ::dbtools::quoteName(sQuote,sName);
+ }
+ catch(Exception)
+ {
+ }
+ if(m_aValueList[i]->GetSelectEntryPos())
+ sOrder += sDESC;
+ else
+ sOrder += sASC;
+ }
+ }
+ return sOrder;
+}
+
+//------------------------------------------------------------------------------
+void DlgOrderCrit::BuildOrderPart()
+{
+ DBG_CHKTHIS(DlgOrderCrit,NULL);
+ m_xQueryComposer->setOrder(GetOrderList());
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/queryorder.hrc b/dbaccess/source/ui/dlg/queryorder.hrc
new file mode 100644
index 000000000000..059151ba9a8d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryorder.hrc
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYORDER_HRC
+#define DBAUI_QUERYORDER_HRC
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+
+
+#define FT_ORDERFIELD 1
+#define FT_ORDERDIR 3
+#define FT_ORDERAFTER1 4
+#define FT_ORDERAFTER2 5
+#define FT_ORDEROPER 6
+
+#define LB_ORDERFIELD1 1
+#define LB_ORDERFIELD2 2
+#define LB_ORDERFIELD3 3
+#define LB_ORDERVALUE1 4
+#define LB_ORDERVALUE2 5
+#define LB_ORDERVALUE3 6
+
+#define FL_ORDER 1
+
+#define BT_OK 1
+#define BT_CANCEL 2
+#define BT_HELP 3
+
+#define STR_NOENTRY 1
+
+#endif // DBAUI_QUERYORDER_HRC
+
diff --git a/dbaccess/source/ui/dlg/queryorder.src b/dbaccess/source/ui/dlg/queryorder.src
new file mode 100644
index 000000000000..7c349dda037b
--- /dev/null
+++ b/dbaccess/source/ui/dlg/queryorder.src
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYORDER_HRC
+#include "queryorder.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+
+ModalDialog DLG_ORDERCRIT
+{
+ OutputSize = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_DLG_ORDERCRIT ;
+ Size = MAP_APPFONT ( 252 , 76 ) ;
+ Text [ en-US ] = "Sort Order" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ ListBox LB_ORDERFIELD1
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERFIELD1";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox LB_ORDERVALUE1
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERVALUE1";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 123 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ StringList [ en-US ] =
+ {
+ < "ascending" ; Default ; > ;
+ < "descending" ; Default ; > ;
+ };
+ };
+ ListBox LB_ORDERFIELD2
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERFIELD2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox LB_ORDERVALUE2
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERVALUE2";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 123 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ StringList [ en-US ] =
+ {
+ < "ascending" ; Default ; > ;
+ < "descending" ; Default ; > ;
+ };
+ };
+ ListBox LB_ORDERFIELD3
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERFIELD3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 59 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 72 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ListBox LB_ORDERVALUE3
+ {
+ HelpID = "dbaccess:ListBox:DLG_ORDERCRIT:LB_ORDERVALUE3";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 123 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 36 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ CurPos = 0 ;
+ StringList [ en-US ] =
+ {
+ < "ascending" ; Default ; > ;
+ < "descending" ; Default ; > ;
+ };
+ };
+ FixedText FT_ORDERFIELD
+ {
+ Pos = MAP_APPFONT ( 58 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Field name" ;
+ Center = TRUE ;
+ };
+
+ FixedText FT_ORDERAFTER1
+ {
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "and then" ;
+ };
+ FixedText FT_ORDERAFTER2
+ {
+ Pos = MAP_APPFONT ( 12 , 59 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "and then" ;
+ };
+ FixedText FT_ORDEROPER
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 46 , 8 ) ;
+ Text [ en-US ] = "Operator" ;
+ };
+ FixedText FT_ORDERDIR
+ {
+ Pos = MAP_APPFONT ( 122 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Order" ;
+ Center = TRUE ;
+ };
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 196 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 196 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 196 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_ORDER
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 184 , 8 ) ;
+ Text [ en-US ] = "Sort order" ;
+ };
+ String STR_NOENTRY
+ {
+ Text [ en-US ] = "<none>" ;
+ };
+};
diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx
new file mode 100644
index 000000000000..80a1378d6a5d
--- /dev/null
+++ b/dbaccess/source/ui/dlg/sqlmessage.cxx
@@ -0,0 +1,779 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "sqlmessage.hxx"
+#include "dbu_dlg.hrc"
+#include "sqlmessage.hrc"
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <vcl/fixed.hxx>
+#include <osl/diagnose.h>
+#include <svtools/svtreebx.hxx>
+#include <svtools/svmedit.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/configmgr.hxx>
+#include <sfx2/sfxuno.hxx>
+#include "dbaccess_helpid.hrc"
+#include "UITools.hxx"
+#include "moduledbu.hxx"
+
+#include <tools/urlobj.hxx>
+
+#define BUTTONID_MORE BUTTONID_RETRY + 1
+
+#define DIALOG_WIDTH 220
+#define OUTER_MARGIN 6
+#define IMAGE_SIZE 20
+#define INNER_PADDING 3
+#define TEXT_POS_X ( OUTER_MARGIN + IMAGE_SIZE + INNER_PADDING )
+
+using namespace dbtools;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::sdbc;
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+namespace
+{
+ //------------------------------------------------------------------------------
+ class IImageProvider
+ {
+ public:
+ virtual Image getImage() const = 0;
+
+ virtual ~IImageProvider() { }
+ };
+
+ //------------------------------------------------------------------------------
+ class ILabelProvider
+ {
+ public:
+ virtual String getLabel() const = 0;
+
+ virtual ~ILabelProvider() { };
+ };
+
+ //------------------------------------------------------------------------------
+ class ImageProvider : public IImageProvider
+ {
+ private:
+ sal_uInt16 m_defaultImageID;
+
+ mutable Image m_defaultImage;
+
+ public:
+ ImageProvider( sal_uInt16 _defaultImageID )
+ :m_defaultImageID( _defaultImageID )
+ {
+ }
+
+ virtual Image getImage() const
+ {
+ if ( !m_defaultImage )
+ m_defaultImage = Image( ModuleRes( m_defaultImageID ) );
+ return m_defaultImage;
+ }
+ };
+
+ //------------------------------------------------------------------------------
+ class LabelProvider : public ILabelProvider
+ {
+ private:
+ String m_label;
+ public:
+ LabelProvider( sal_uInt16 _labelResourceID )
+ :m_label( ModuleRes( _labelResourceID ) )
+ {
+ }
+
+ virtual String getLabel() const
+ {
+ return m_label;
+ }
+ };
+
+ //------------------------------------------------------------------------------
+ class ProviderFactory
+ {
+ private:
+ mutable ::boost::shared_ptr< IImageProvider > m_pErrorImage;
+ mutable ::boost::shared_ptr< IImageProvider > m_pWarningsImage;
+ mutable ::boost::shared_ptr< IImageProvider > m_pInfoImage;
+ mutable ::boost::shared_ptr< ILabelProvider > m_pErrorLabel;
+ mutable ::boost::shared_ptr< ILabelProvider > m_pWarningsLabel;
+ mutable ::boost::shared_ptr< ILabelProvider > m_pInfoLabel;
+
+ public:
+ ProviderFactory()
+ {
+ }
+
+ ::boost::shared_ptr< IImageProvider > getImageProvider( SQLExceptionInfo::TYPE _eType ) const
+ {
+ ::boost::shared_ptr< IImageProvider >* ppProvider( &m_pErrorImage );
+ sal_uInt16 nNormalImageID( BMP_EXCEPTION_ERROR );
+
+ switch ( _eType )
+ {
+ case SQLExceptionInfo::SQL_WARNING:
+ ppProvider = &m_pWarningsImage;
+ nNormalImageID = BMP_EXCEPTION_WARNING;
+ break;
+
+ case SQLExceptionInfo::SQL_CONTEXT:
+ ppProvider = &m_pInfoImage;
+ nNormalImageID = BMP_EXCEPTION_INFO;
+ break;
+
+ default:
+ break;
+ }
+
+ if ( !ppProvider->get() )
+ ppProvider->reset( new ImageProvider( nNormalImageID ) );
+ return *ppProvider;
+ }
+
+ ::boost::shared_ptr< ILabelProvider > getLabelProvider( SQLExceptionInfo::TYPE _eType, bool _bSubLabel ) const
+ {
+ ::boost::shared_ptr< ILabelProvider >* ppProvider( &m_pErrorLabel );
+ sal_uInt16 nLabelID( STR_EXCEPTION_ERROR );
+
+ switch ( _eType )
+ {
+ case SQLExceptionInfo::SQL_WARNING:
+ ppProvider = &m_pWarningsLabel;
+ nLabelID = STR_EXCEPTION_WARNING;
+ break;
+
+ case SQLExceptionInfo::SQL_CONTEXT:
+ ppProvider = &m_pInfoLabel;
+ nLabelID = _bSubLabel ? STR_EXCEPTION_DETAILS : STR_EXCEPTION_INFO;
+ break;
+ default:
+ break;
+ }
+
+ if ( !ppProvider->get() )
+ ppProvider->reset( new LabelProvider( nLabelID ) );
+ return *ppProvider;
+ }
+
+ };
+
+ //------------------------------------------------------------------------------
+ /// a stripped version of the SQLException, packed for displaying
+ struct ExceptionDisplayInfo
+ {
+ SQLExceptionInfo::TYPE eType;
+
+ ::boost::shared_ptr< IImageProvider > pImageProvider;
+ ::boost::shared_ptr< ILabelProvider > pLabelProvider;
+
+ bool bSubEntry;
+
+ String sMessage;
+ String sSQLState;
+ String sErrorCode;
+
+ ExceptionDisplayInfo() : eType( SQLExceptionInfo::UNDEFINED ), bSubEntry( false ) { }
+ ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { }
+ };
+
+ static bool lcl_hasDetails( const ExceptionDisplayInfo& _displayInfo )
+ {
+ return ( _displayInfo.sErrorCode.Len() )
+ || ( _displayInfo.sSQLState.Len()
+ && !_displayInfo.sSQLState.EqualsAscii( "S1000" )
+ );
+ }
+
+ typedef ::std::vector< ExceptionDisplayInfo > ExceptionDisplayChain;
+
+ //------------------------------------------------------------------------------
+ /// strips the [OOoBase] vendor identifier from the given error message, if applicable
+ ::rtl::OUString lcl_stripOOoBaseVendor( const ::rtl::OUString& _rErrorMessage )
+ {
+ ::rtl::OUString sErrorMessage( _rErrorMessage );
+
+ const ::rtl::OUString sVendorIdentifier( ::connectivity::SQLError::getMessagePrefix() );
+ if ( sErrorMessage.indexOf( sVendorIdentifier ) == 0 )
+ {
+ // characters to strip
+ sal_Int32 nStripLen( sVendorIdentifier.getLength() );
+ // usually, there should be a whitespace between the vendor and the real message
+ while ( ( sErrorMessage.getLength() > nStripLen )
+ && ( sErrorMessage[nStripLen] == ' ' )
+ )
+ ++nStripLen;
+ sErrorMessage = sErrorMessage.copy( nStripLen );
+ }
+
+ return sErrorMessage;
+ }
+
+ //------------------------------------------------------------------------------
+ void lcl_buildExceptionChain( const SQLExceptionInfo& _rErrorInfo, const ProviderFactory& _rFactory, ExceptionDisplayChain& _out_rChain )
+ {
+ {
+ ExceptionDisplayChain empty;
+ _out_rChain.swap( empty );
+ }
+
+ SQLExceptionIteratorHelper iter( _rErrorInfo );
+ while ( iter.hasMoreElements() )
+ {
+ // current chain element
+ SQLExceptionInfo aCurrentElement;
+ iter.next( aCurrentElement );
+
+ const SQLException* pCurrentError = (const SQLException*)aCurrentElement;
+ OSL_ENSURE( pCurrentError, "lcl_buildExceptionChain: iterator failure!" );
+ // hasMoreElements should not have returned <TRUE/> in this case
+
+ ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() );
+
+ aDisplayInfo.sMessage = pCurrentError->Message.trim();
+ aDisplayInfo.sSQLState = pCurrentError->SQLState;
+ if ( pCurrentError->ErrorCode )
+ aDisplayInfo.sErrorCode = String::CreateFromInt32( pCurrentError->ErrorCode );
+
+ if ( !aDisplayInfo.sMessage.Len()
+ && !lcl_hasDetails( aDisplayInfo )
+ )
+ {
+ OSL_FAIL( "lcl_buildExceptionChain: useles exception: no state, no error code, no message!" );
+ continue;
+ }
+
+ aDisplayInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() );
+ aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), false );
+
+ _out_rChain.push_back( aDisplayInfo );
+
+ if ( aCurrentElement.getType() == SQLExceptionInfo::SQL_CONTEXT )
+ {
+ const SQLContext* pContext = (const SQLContext*)aCurrentElement;
+ if ( pContext->Details.getLength() )
+ {
+ ExceptionDisplayInfo aSubInfo( aCurrentElement.getType() );
+
+ aSubInfo.sMessage = pContext->Details;
+ aSubInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() );
+ aSubInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), true );
+ aSubInfo.bSubEntry = true;
+
+ _out_rChain.push_back( aSubInfo );
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void lcl_insertExceptionEntry( SvTreeListBox& _rList, size_t _nElementPos, const ExceptionDisplayInfo& _rEntry )
+ {
+ Image aEntryImage( _rEntry.pImageProvider->getImage() );
+ SvLBoxEntry* pListEntry =
+ _rList.InsertEntry( _rEntry.pLabelProvider->getLabel(), aEntryImage, aEntryImage );
+ pListEntry->SetUserData( reinterpret_cast< void* >( _nElementPos ) );
+ }
+}
+
+//==============================================================================
+class OExceptionChainDialog : public ModalDialog
+{
+ FixedLine m_aFrame;
+ FixedText m_aListLabel;
+ SvTreeListBox m_aExceptionList;
+ FixedText m_aDescLabel;
+ MultiLineEdit m_aExceptionText;
+ OKButton m_aOK;
+
+ String m_sStatusLabel;
+ String m_sErrorCodeLabel;
+
+ ExceptionDisplayChain m_aExceptions;
+
+public:
+ OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions );
+ ~OExceptionChainDialog();
+
+protected:
+ DECL_LINK(OnExceptionSelected, void*);
+};
+
+DBG_NAME(OExceptionChainDialog)
+//------------------------------------------------------------------------------
+OExceptionChainDialog::OExceptionChainDialog( Window* pParent, const ExceptionDisplayChain& _rExceptions )
+ :ModalDialog(pParent, ModuleRes(DLG_SQLEXCEPTIONCHAIN))
+ ,m_aFrame (this, ModuleRes(FL_DETAILS))
+ ,m_aListLabel (this, ModuleRes(FT_ERRORLIST))
+ ,m_aExceptionList (this, ModuleRes(CTL_ERRORLIST))
+ ,m_aDescLabel (this, ModuleRes(FT_DESCRIPTION))
+ ,m_aExceptionText (this, ModuleRes(ME_DESCRIPTION))
+ ,m_aOK (this, ModuleRes(PB_OK))
+ ,m_aExceptions( _rExceptions )
+{
+ DBG_CTOR(OExceptionChainDialog,NULL);
+
+ m_sStatusLabel = String( ModuleRes( STR_EXCEPTION_STATUS ) );
+ m_sErrorCodeLabel = String( ModuleRes( STR_EXCEPTION_ERRORCODE ) );
+
+ FreeResource();
+
+ m_aExceptionList.SetSelectionMode(SINGLE_SELECTION);
+ m_aExceptionList.SetDragDropMode(0);
+ m_aExceptionList.EnableInplaceEditing(sal_False);
+ m_aExceptionList.SetStyle(m_aExceptionList.GetStyle() | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
+
+ m_aExceptionList.SetSelectHdl(LINK(this, OExceptionChainDialog, OnExceptionSelected));
+ m_aExceptionList.SetNodeDefaultImages( );
+ m_aExceptionText.SetReadOnly(sal_True);
+
+ bool bHave22018 = false;
+ size_t elementPos = 0;
+
+ for ( ExceptionDisplayChain::const_iterator loop = m_aExceptions.begin();
+ loop != m_aExceptions.end();
+ ++loop, ++elementPos
+ )
+ {
+ lcl_insertExceptionEntry( m_aExceptionList, elementPos, *loop );
+ bHave22018 = loop->sSQLState.EqualsAscii( "22018" );
+ }
+
+ // if the error has the code 22018, then add an additional explanation
+ // #i24021#
+ if ( bHave22018 )
+ {
+ ProviderFactory aProviderFactory;
+
+ ExceptionDisplayInfo aInfo22018;
+ aInfo22018.sMessage = String( ModuleRes( STR_EXPLAN_STRINGCONVERSION_ERROR ) );
+ aInfo22018.pLabelProvider = aProviderFactory.getLabelProvider( SQLExceptionInfo::SQL_CONTEXT, false );
+ aInfo22018.pImageProvider = aProviderFactory.getImageProvider( SQLExceptionInfo::SQL_CONTEXT );
+ m_aExceptions.push_back( aInfo22018 );
+
+ lcl_insertExceptionEntry( m_aExceptionList, m_aExceptions.size() - 1, aInfo22018 );
+ }
+}
+
+//------------------------------------------------------------------------------
+OExceptionChainDialog::~OExceptionChainDialog()
+{
+ DBG_DTOR(OExceptionChainDialog,NULL);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OExceptionChainDialog, OnExceptionSelected, void*, EMPTYARG)
+{
+ SvLBoxEntry* pSelected = m_aExceptionList.FirstSelected();
+ OSL_ENSURE(!pSelected || !m_aExceptionList.NextSelected(pSelected), "OExceptionChainDialog::OnExceptionSelected : multi selection ?");
+
+ String sText;
+
+ if ( pSelected )
+ {
+ size_t pos = reinterpret_cast< size_t >( pSelected->GetUserData() );
+ const ExceptionDisplayInfo& aExceptionInfo( m_aExceptions[ pos ] );
+
+ if ( aExceptionInfo.sSQLState.Len() )
+ {
+ sText += m_sStatusLabel;
+ sText.AppendAscii(": ");
+ sText += aExceptionInfo.sSQLState;
+ sText.AppendAscii("\n");
+ }
+
+ if ( aExceptionInfo.sErrorCode.Len() )
+ {
+ sText += m_sErrorCodeLabel;
+ sText.AppendAscii(": ");
+ sText += aExceptionInfo.sErrorCode;
+ sText.AppendAscii("\n");
+ }
+
+ if ( sText.Len() )
+ sText.AppendAscii( "\n" );
+
+ sText += aExceptionInfo.sMessage;
+ }
+
+ m_aExceptionText.SetText(sText);
+
+ return 0L;
+}
+
+//==============================================================================
+//= SQLMessageBox_Impl
+//==============================================================================
+struct SQLMessageBox_Impl
+{
+ ExceptionDisplayChain aDisplayInfo;
+
+ SQLMessageBox_Impl( const SQLExceptionInfo& _rExceptionInfo )
+ {
+ // transform the exception chain to a form more suitable for displaying it here
+ ProviderFactory aProviderFactory;
+ lcl_buildExceptionChain( _rExceptionInfo, aProviderFactory, aDisplayInfo );
+ }
+};
+
+//------------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getProductName()
+ {
+ ::rtl::OUString sProductName;
+ OSL_VERIFY( ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME ) >>= sProductName );
+ return sProductName;
+ }
+
+ void lcl_positionInAppFont( const Window& _rParent, Window& _rChild, long _nX, long _nY, long _Width, long _Height )
+ {
+ Point aPos = _rParent.LogicToPixel( Point( _nX, _nY ), MAP_APPFONT );
+ Size aSize = _rParent.LogicToPixel( Size( _Width, _Height ), MAP_APPFONT );
+ _rChild.SetPosSizePixel( aPos, aSize );
+ }
+
+ void lcl_addButton( ButtonDialog& _rDialog, StandardButtonType _eType, bool _bDefault )
+ {
+ sal_uInt16 nButtonID = 0;
+ switch ( _eType )
+ {
+ case BUTTON_YES: nButtonID = BUTTONID_YES; break;
+ case BUTTON_NO: nButtonID = BUTTONID_NO; break;
+ case BUTTON_OK: nButtonID = BUTTONID_OK; break;
+ case BUTTON_CANCEL: nButtonID = BUTTONID_CANCEL; break;
+ case BUTTON_RETRY: nButtonID = BUTTONID_RETRY; break;
+ case BUTTON_HELP: nButtonID = BUTTONID_HELP; break;
+ default:
+ OSL_FAIL( "lcl_addButton: invalid button id!" );
+ break;
+ }
+ _rDialog.AddButton( _eType, nButtonID, _bDefault ? BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON : 0 );
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSQLMessageBox::impl_positionControls()
+{
+ OSL_PRECOND( !m_pImpl->aDisplayInfo.empty(), "OSQLMessageBox::impl_positionControls: nothing to display at all?" );
+
+
+ if ( m_pImpl->aDisplayInfo.empty() )
+ return;
+ const ExceptionDisplayInfo* pSecondInfo = NULL;
+
+ const ExceptionDisplayInfo& rFirstInfo = *m_pImpl->aDisplayInfo.begin();
+ if ( m_pImpl->aDisplayInfo.size() > 1 )
+ pSecondInfo = &m_pImpl->aDisplayInfo[1];
+ String sPrimary, sSecondary;
+ sPrimary = rFirstInfo.sMessage;
+ // one or two texts to display?
+ if ( pSecondInfo )
+ {
+ // we show two elements in the main dialog if and only if one of
+ // - the first element in the chain is an SQLContext, and the second
+ // element denotes its sub entry
+ // - the first and the second element are both independent (i.e. the second
+ // is no sub entry), and none of them is a context.
+ bool bFirstElementIsContext = ( rFirstInfo.eType == SQLExceptionInfo::SQL_CONTEXT );
+ bool bSecondElementIsContext = ( pSecondInfo->eType == SQLExceptionInfo::SQL_CONTEXT );
+
+ if ( bFirstElementIsContext && pSecondInfo->bSubEntry )
+ sSecondary = pSecondInfo->sMessage;
+ if ( !bFirstElementIsContext && !bSecondElementIsContext )
+ sSecondary = pSecondInfo->sMessage;
+ }
+
+ // image
+ lcl_positionInAppFont( *this, m_aInfoImage, OUTER_MARGIN, OUTER_MARGIN, IMAGE_SIZE, IMAGE_SIZE );
+ m_aInfoImage.Show();
+
+ // primary text
+ lcl_positionInAppFont( *this, m_aTitle, TEXT_POS_X, OUTER_MARGIN, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 16 );
+ sPrimary = lcl_stripOOoBaseVendor( sPrimary );
+ m_aTitle.SetText( sPrimary );
+ m_aTitle.Show();
+
+ Rectangle aPrimaryRect( m_aTitle.GetPosPixel(), m_aTitle.GetSizePixel() );
+
+ // secondary text (if applicable)
+ m_aMessage.SetStyle( m_aMessage.GetStyle() | WB_NOLABEL );
+ sSecondary = lcl_stripOOoBaseVendor( sSecondary );
+ m_aMessage.SetText( sSecondary );
+
+ lcl_positionInAppFont( *this, m_aMessage, TEXT_POS_X, OUTER_MARGIN + 16 + 3, DIALOG_WIDTH - TEXT_POS_X - 2 * OUTER_MARGIN, 8 );
+ Rectangle aSecondaryRect( m_aMessage.GetPosPixel(), m_aMessage.GetSizePixel() );
+
+ bool bHaveSecondaryText = sSecondary.Len() != 0;
+
+ // determine which space the secondary text would occupy
+ if ( bHaveSecondaryText )
+ aSecondaryRect = GetTextRect( aSecondaryRect, sSecondary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT );
+ else
+ aSecondaryRect.Bottom() = aSecondaryRect.Top() - 1;
+
+ // adjust secondary control height accordingly
+ m_aMessage.SetSizePixel( aSecondaryRect.GetSize() );
+ m_aMessage.Show( aSecondaryRect.GetHeight() > 0 );
+
+ // if there's no secondary text ...
+ if ( !bHaveSecondaryText )
+ { // then give the primary text as much horizontal space as it needs
+ Rectangle aSuggestedRect( GetTextRect( aPrimaryRect, sPrimary, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_CENTER ) );
+ aPrimaryRect.Right() = aPrimaryRect.Left() + aSuggestedRect.GetWidth();
+ aPrimaryRect.Bottom() = aPrimaryRect.Top() + aSuggestedRect.GetHeight();
+ // and center it horizontally
+ m_aTitle.SetStyle( ( m_aTitle.GetStyle() & ~WB_LEFT ) | WB_CENTER );
+
+ Rectangle aInfoRect( m_aInfoImage.GetPosPixel(), m_aInfoImage.GetSizePixel() );
+ // also, if it's not as high as the image ...
+ if ( aPrimaryRect.GetHeight() < m_aInfoImage.GetSizePixel().Height() )
+ { // ... make it fit the image height
+ aPrimaryRect.Bottom() += aInfoRect.GetHeight() - aPrimaryRect.GetHeight();
+ // and center it vertically
+ m_aTitle.SetStyle( m_aTitle.GetStyle() | WB_VCENTER );
+ }
+ else
+ { // ... otherwise, center the image vertically, relative to the primary text
+ aInfoRect.Move( 0, ( aPrimaryRect.GetHeight() - aInfoRect.GetHeight() ) / 2 );
+ m_aInfoImage.SetPosSizePixel( aInfoRect.TopLeft(), aInfoRect.GetSize() );
+ }
+
+ m_aTitle.SetPosSizePixel( aPrimaryRect.TopLeft(), aPrimaryRect.GetSize() );
+ }
+
+ // adjust dialog size accordingly
+ const Rectangle& rBottomTextRect( bHaveSecondaryText ? aSecondaryRect : aPrimaryRect );
+ Size aBorderSize = LogicToPixel( Size( OUTER_MARGIN, OUTER_MARGIN ), MAP_APPFONT );
+ Size aDialogSize( LogicToPixel( Size( DIALOG_WIDTH, 30 ), MAP_APPFONT ) );
+ aDialogSize.Height() = rBottomTextRect.Bottom() + aBorderSize.Height();
+ aDialogSize.Width() = aPrimaryRect.Right() + aBorderSize.Width();
+
+ SetSizePixel( aDialogSize );
+ SetPageSizePixel( aDialogSize );
+}
+
+//------------------------------------------------------------------------------
+void OSQLMessageBox::impl_initImage( MessageType _eImage )
+{
+ switch (_eImage)
+ {
+ default:
+ OSL_FAIL( "OSQLMessageBox::impl_initImage: unsupported image type!" );
+
+ case Info:
+ m_aInfoImage.SetImage(InfoBox::GetStandardImage());
+ break;
+ case Warning:
+ m_aInfoImage.SetImage(WarningBox::GetStandardImage());
+ break;
+ case Error:
+ m_aInfoImage.SetImage(ErrorBox::GetStandardImage());
+ break;
+ case Query:
+ m_aInfoImage.SetImage(QueryBox::GetStandardImage());
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle )
+{
+ if ( _nStyle & WB_YES_NO_CANCEL )
+ {
+ lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 );
+ lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 );
+ lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 );
+ }
+ else if ( _nStyle & WB_OK_CANCEL )
+ {
+ lcl_addButton( *this, BUTTON_OK, ( _nStyle & WB_DEF_OK ) != 0 );
+ lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 );
+ }
+ else if ( _nStyle & WB_YES_NO )
+ {
+ lcl_addButton( *this, BUTTON_YES, ( _nStyle & WB_DEF_YES ) != 0 );
+ lcl_addButton( *this, BUTTON_NO, ( _nStyle & WB_DEF_NO ) != 0 );
+ }
+ else if ( _nStyle & WB_RETRY_CANCEL )
+ {
+ lcl_addButton( *this, BUTTON_RETRY, ( _nStyle & WB_DEF_RETRY ) != 0 );
+ lcl_addButton( *this, BUTTON_CANCEL, ( _nStyle & WB_DEF_CANCEL ) != 0 );
+ }
+ else
+ {
+ OSL_ENSURE( WB_OK & _nStyle, "OSQLMessageBox::impl_createStandardButtons: unsupported dialog style requested!" );
+ AddButton( BUTTON_OK, BUTTONID_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON );
+ }
+
+ if ( m_sHelpURL.getLength() )
+ {
+ lcl_addButton( *this, BUTTON_HELP, false );
+
+ rtl::OUString aTmp;
+ INetURLObject aHID( m_sHelpURL );
+ if ( aHID.GetProtocol() == INET_PROT_HID )
+ aTmp = aHID.GetURLPath();
+ else
+ aTmp = m_sHelpURL;
+
+ SetHelpId( rtl::OUStringToOString( aTmp, RTL_TEXTENCODING_UTF8 ) );
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSQLMessageBox::impl_addDetailsButton()
+{
+ size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1;
+
+ bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible;
+ if ( !bMoreDetailsAvailable )
+ {
+ // even if the text fits into what we can display, we might need to details button
+ // if there is more non-trivial information in the errors than the mere messages
+ for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin();
+ error != m_pImpl->aDisplayInfo.end();
+ ++error
+ )
+ {
+ if ( lcl_hasDetails( *error ) )
+ {
+ bMoreDetailsAvailable = true;
+ break;
+ }
+ }
+ }
+
+ if ( bMoreDetailsAvailable )
+ {
+ AddButton( BUTTON_MORE, BUTTONID_MORE, 0 );
+ PushButton* pButton = GetPushButton( BUTTONID_MORE );
+ OSL_ENSURE( pButton, "OSQLMessageBox::impl_addDetailsButton: just added this button, why isn't it there?" );
+ pButton->SetClickHdl( LINK( this, OSQLMessageBox, ButtonClickHdl ) );
+ pButton->SetUniqueId( UID_SQLERROR_BUTTONMORE );
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSQLMessageBox::Construct( WinBits _nStyle, MessageType _eImage )
+{
+ // Changed as per BugID 79541 Branding/Configuration
+ String sDialogTitle( lcl_getProductName() );
+ SetText( sDialogTitle.AppendAscii( " Base" ) );
+
+ // position and size the controls and the dialog, depending on whether we have one or two texts to display
+ impl_positionControls();
+
+ // init the image
+ MessageType eType( _eImage );
+ if ( eType == AUTO )
+ {
+ switch ( m_pImpl->aDisplayInfo[0].eType )
+ {
+ case SQLExceptionInfo::SQL_EXCEPTION: eType = Error; break;
+ case SQLExceptionInfo::SQL_WARNING: eType = Warning; break;
+ case SQLExceptionInfo::SQL_CONTEXT: eType = Info; break;
+ default: OSL_FAIL( "OSQLMessageBox::Construct: invalid type!" );
+ }
+ }
+ impl_initImage( eType );
+
+ // create buttons
+ impl_createStandardButtons( _nStyle );
+ impl_addDetailsButton();
+}
+
+//------------------------------------------------------------------------------
+OSQLMessageBox::OSQLMessageBox(Window* _pParent, const SQLExceptionInfo& _rException, WinBits _nStyle, const ::rtl::OUString& _rHelpURL )
+ :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG )
+ ,m_aInfoImage( this )
+ ,m_aTitle( this, WB_WORDBREAK | WB_LEFT )
+ ,m_aMessage( this, WB_WORDBREAK | WB_LEFT )
+ ,m_sHelpURL( _rHelpURL )
+ ,m_pImpl( new SQLMessageBox_Impl( _rException ) )
+{
+ Construct( _nStyle, AUTO );
+}
+
+//------------------------------------------------------------------------------
+OSQLMessageBox::OSQLMessageBox( Window* _pParent, const UniString& _rTitle, const UniString& _rMessage, WinBits _nStyle, MessageType _eType, const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo )
+ :ButtonDialog( _pParent, WB_HORZ | WB_STDDIALOG )
+ ,m_aInfoImage( this )
+ ,m_aTitle( this, WB_WORDBREAK | WB_LEFT )
+ ,m_aMessage( this, WB_WORDBREAK | WB_LEFT )
+{
+ SQLContext aError;
+ aError.Message = _rTitle;
+ aError.Details = _rMessage;
+ if ( _pAdditionalErrorInfo )
+ aError.NextException = _pAdditionalErrorInfo->get();
+
+ m_pImpl.reset( new SQLMessageBox_Impl( SQLExceptionInfo( aError ) ) );
+
+ Construct( _nStyle, _eType );
+}
+
+//--------------------------------------------------------------------------
+OSQLMessageBox::~OSQLMessageBox()
+{
+}
+
+//--------------------------------------------------------------------------
+IMPL_LINK( OSQLMessageBox, ButtonClickHdl, Button *, /*pButton*/ )
+{
+ OExceptionChainDialog aDlg( this, m_pImpl->aDisplayInfo );
+ aDlg.Execute();
+ return 0;
+}
+
+//==================================================================
+// OSQLWarningBox
+//==================================================================
+OSQLWarningBox::OSQLWarningBox( Window* _pParent, const UniString& _rMessage, WinBits _nStyle,
+ const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo )
+ :OSQLMessageBox( _pParent, String( ModuleRes( STR_STAT_WARNING ) ), _rMessage, _nStyle, OSQLMessageBox::Warning, _pAdditionalErrorInfo )
+{
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/sqlmessage.hrc b/dbaccess/source/ui/dlg/sqlmessage.hrc
new file mode 100644
index 000000000000..76f722a1b08f
--- /dev/null
+++ b/dbaccess/source/ui/dlg/sqlmessage.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_SQLMESSAGE_HRC_
+#define _DBAUI_SQLMESSAGE_HRC_
+
+#define FT_ERRORLIST 1
+#define FT_DESCRIPTION 2
+
+#define ED_TEXT 1
+
+#define FL_DATA 1
+
+#define FL_DETAILS 1
+
+#define PB_OK 1
+#define PB_CANCEL 2
+
+#define CTL_ERRORLIST 1
+
+#define ME_DESCRIPTION 1
+
+#define STR_EXCEPTION_STATUS 1
+#define STR_EXCEPTION_ERRORCODE 2
+
+#endif // _DBAUI_SQLMESSAGE_HRC_
diff --git a/dbaccess/source/ui/dlg/sqlmessage.src b/dbaccess/source/ui/dlg/sqlmessage.src
new file mode 100644
index 000000000000..94b2e394d527
--- /dev/null
+++ b/dbaccess/source/ui/dlg/sqlmessage.src
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef _DBAUI_SQLMESSAGE_HRC_
+#include "sqlmessage.hrc"
+#endif
+
+//-------------------------------------------------------------------------
+Image BMP_EXCEPTION_ERROR
+{
+ ImageBitmap = Bitmap { File = "exerror.png"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_WARNING
+{
+ ImageBitmap = Bitmap { File = "exwarning.png"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+Image BMP_EXCEPTION_INFO
+{
+ ImageBitmap = Bitmap { File = "exinfo.png"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+ModalDialog DLG_SQLEXCEPTIONCHAIN
+{
+ HelpID = "dbaccess:ModalDialog:DLG_SQLEXCEPTIONCHAIN";
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 240 , 150 ) ;
+ Text [ en-US ] = "%PRODUCTNAME Base" ;
+
+ FixedLine FL_DETAILS
+ {
+ Pos = MAP_APPFONT ( 6, 3 ) ;
+ Size = MAP_APPFONT ( 228, 8 ) ;
+ Text [ en-US ] = "Details";
+ };
+ FixedText FT_ERRORLIST
+ {
+ Pos = MAP_APPFONT ( 12, 12 ) ;
+ Size = MAP_APPFONT ( 85, 10 ) ;
+ Text [ en-US ] = "Error ~list:";
+ Group = TRUE;
+ };
+ Control CTL_ERRORLIST
+ {
+ Pos = MAP_APPFONT ( 12, 25 ) ;
+ Size = MAP_APPFONT ( 85, 93 ) ;
+ Border = TRUE;
+ TabStop = TRUE;
+ HelpId = HID_SQLERROR_EXCHAIN_ERRORS;
+ };
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 103, 12 ) ;
+ Size = MAP_APPFONT ( 125, 10 ) ;
+ Text [ en-US ] = "~Description:";
+ Group = TRUE;
+ };
+ MultiLineEdit ME_DESCRIPTION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 103 , 25 ) ;
+ Size = MAP_APPFONT ( 125 , 93 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ HelpId = HID_SQLERROR_EXCHAIN_TEXT;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+
+ String STR_EXCEPTION_STATUS
+ {
+ Text [ en-US ] = "SQL Status";
+ };
+ String STR_EXCEPTION_ERRORCODE
+ {
+ Text [ en-US ] = "Error code";
+ };
+};
+
+String STR_EXPLAN_STRINGCONVERSION_ERROR
+{
+ Text [ en-US ] = "A frequent reason for this error is an inappropriate character set setting for the language of your database. Check the setting by choosing Edit - Database - Properties.";
+};
+
+String STR_EXCEPTION_ERROR
+{
+ Text [ en-US ] = "Error";
+};
+
+String STR_EXCEPTION_WARNING
+{
+ Text [ en-US ] = "Warning";
+};
+
+String STR_EXCEPTION_INFO
+{
+ Text [ en-US ] = "Information";
+};
+
+String STR_EXCEPTION_DETAILS
+{
+ Text [ en-US ] = "Details";
+};
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
new file mode 100644
index 000000000000..9b5e771b2173
--- /dev/null
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -0,0 +1,631 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "tablespage.hxx"
+#include "dbu_dlg.hrc"
+#include "dbadmin.hrc"
+#include "dsitems.hxx"
+#include "browserids.hxx"
+#include "datasourceconnector.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include "stringlistitem.hxx"
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include "dbustrings.hrc"
+#include <vcl/svapp.hxx>
+#include <vcl/waitobj.hxx>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include "sqlmessage.hxx"
+#include <vcl/msgbox.hxx>
+#include "dbaccess_helpid.hrc"
+#include "UITools.hxx"
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+#include <svtools/imgdef.hxx>
+#include "TablesSingleDlg.hxx"
+#include <tools/diagnose_ex.h>
+#include <cppuhelper/exc_hlp.hxx>
+#include "AutoControls.hrc"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::i18n;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::dbtools;
+ using namespace ::comphelper;
+
+ //========================================================================
+ //= OTableSubscriptionPage
+ //========================================================================
+DBG_NAME(OTableSubscriptionPage)
+//------------------------------------------------------------------------
+ OTableSubscriptionPage::OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs,OTableSubscriptionDialog* _pTablesDlg )
+ :OGenericAdministrationPage( pParent, ModuleRes(PAGE_TABLESUBSCRIPTION), _rCoreAttrs )
+ ,m_aTables (this, ModuleRes(FL_SEPARATOR1))
+ ,m_aTablesList (this, NULL,ModuleRes(CTL_TABLESUBSCRIPTION),sal_True)
+ ,m_aExplanation (this, ModuleRes(FT_FILTER_EXPLANATION))
+ ,m_bCheckedAll ( sal_False )
+ ,m_bCatalogAtStart ( sal_True )
+ ,m_pTablesDlg(_pTablesDlg)
+ {
+ DBG_CTOR(OTableSubscriptionPage,NULL);
+
+ m_aTablesList.SetCheckHandler(getControlModifiedLink());
+
+ // initialize the TabListBox
+ m_aTablesList.SetSelectionMode( MULTIPLE_SELECTION );
+ m_aTablesList.SetDragDropMode( 0 );
+ m_aTablesList.EnableInplaceEditing( sal_False );
+ m_aTablesList.SetStyle(m_aTablesList.GetStyle() | WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_SORT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
+
+ m_aTablesList.Clear();
+
+ FreeResource();
+
+ m_aTablesList.SetCheckButtonHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
+ m_aTablesList.SetCheckHandler(LINK(this, OTableSubscriptionPage, OnTreeEntryChecked));
+ }
+
+ //------------------------------------------------------------------------
+ OTableSubscriptionPage::~OTableSubscriptionPage()
+ {
+ // just to make sure that our connection will be removed
+ try
+ {
+ ::comphelper::disposeComponent(m_xCurrentConnection);
+ }
+ catch (RuntimeException&) { }
+
+ DBG_DTOR(OTableSubscriptionPage,NULL);
+ }
+
+ // -----------------------------------------------------------------------------
+ void OTableSubscriptionPage::StateChanged( StateChangedType nType )
+ {
+ OGenericAdministrationPage::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ m_aTablesList.notifyHiContrastChanged();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void OTableSubscriptionPage::DataChanged( const DataChangedEvent& rDCEvt )
+ {
+ OGenericAdministrationPage::DataChanged( rDCEvt );
+
+ if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) ||
+ ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) &&
+ ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
+ {
+ // Check if we need to get new images for normal/high contrast mode
+ m_aTablesList.notifyHiContrastChanged();
+ }
+ }
+ //------------------------------------------------------------------
+ void OTableSubscriptionPage::resizeControls(const Size& _rDiff)
+ {
+ if ( _rDiff.Height() )
+ {
+ Size aOldSize = m_aTablesList.GetSizePixel();
+ aOldSize.Height() -= _rDiff.Height();
+ m_aTablesList.SetPosSizePixel(
+ m_aTablesList.GetPosPixel()+Point(0,_rDiff.Height()),
+ aOldSize
+ );
+ }
+ }
+ //------------------------------------------------------------------------
+ void OTableSubscriptionPage::implCheckTables(const Sequence< ::rtl::OUString >& _rTables)
+ {
+ // the meta data for the current connection, used for splitting up table names
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ if (m_xCurrentConnection.is())
+ xMeta = m_xCurrentConnection->getMetaData();
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("OTableSubscriptionPage::implCheckTables : could not retrieve the current connection's meta data!");
+ }
+
+ // uncheck all
+ CheckAll(sal_False);
+
+ // check the ones which are in the list
+ String aListBoxTable;
+ ::rtl::OUString sCatalog, sSchema, sName;
+
+ SvLBoxEntry* pRootEntry = m_aTablesList.getAllObjectsEntry();
+ sal_Bool bAllTables = sal_False;
+ sal_Bool bAllSchemas = sal_False;
+
+ const ::rtl::OUString* pIncludeTable = _rTables.getConstArray();
+ for (sal_Int32 i=0; i<_rTables.getLength(); ++i, ++pIncludeTable)
+ {
+ if (xMeta.is())
+ qualifiedNameComponents(xMeta, pIncludeTable->getStr(), sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
+ else
+ sName = pIncludeTable->getStr();
+
+ bAllTables = (1 == sName.getLength()) && ('%' == sName[0]);
+ bAllSchemas = (1 == sSchema.getLength()) && ('%' == sSchema[0]);
+
+ // the catalog entry
+ SvLBoxEntry* pCatalog = m_aTablesList.GetEntryPosByName(sCatalog, pRootEntry);
+ if (!pCatalog && sCatalog.getLength())
+ // the table (resp. its catalog) refered in this filter entry does not exist anymore
+ continue;
+
+ if (bAllSchemas && pCatalog)
+ {
+ m_aTablesList.checkWildcard(pCatalog);
+ continue;
+ }
+
+ // the schema entry
+ SvLBoxEntry* pSchema = m_aTablesList.GetEntryPosByName(sSchema, (pCatalog ? pCatalog : pRootEntry));
+ if (!pSchema && sSchema.getLength())
+ // the table (resp. its schema) refered in this filter entry does not exist anymore
+ continue;
+
+ if (bAllTables && pSchema)
+ {
+ m_aTablesList.checkWildcard(pSchema);
+ continue;
+ }
+
+ SvLBoxEntry* pEntry = m_aTablesList.GetEntryPosByName(sName, pSchema ? pSchema : (pCatalog ? pCatalog : pRootEntry) );
+ if (pEntry)
+ m_aTablesList.SetCheckButtonState(pEntry, SV_BUTTON_CHECKED);
+ }
+ m_aTablesList.CheckButtons();
+ }
+
+ //------------------------------------------------------------------------
+ void OTableSubscriptionPage::implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter )
+ {
+ if (!_rTableFilter.getLength())
+ { // no tables visible
+ CheckAll(sal_False);
+ }
+ else
+ {
+ if ((1 == _rTableFilter.getLength()) && _rTableFilter[0].equalsAsciiL("%", 1))
+ { // all tables visible
+ CheckAll(sal_True);
+ }
+ else
+ implCheckTables( _rTableFilter );
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ void OTableSubscriptionPage::implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue)
+ {
+ // check whether or not the selection is invalid or readonly (invalid implies readonly, but not vice versa)
+ sal_Bool bValid, bReadonly;
+ getFlags(_rSet, bValid, bReadonly);
+
+ // get the name of the data source we're working for
+ SFX_ITEMSET_GET(_rSet, pNameItem, SfxStringItem, DSID_NAME, sal_True);
+ OSL_ENSURE(pNameItem, "OTableSubscriptionPage::implInitControls: missing the name attribute!");
+ String sDSName = pNameItem->GetValue();
+
+ if (bValid && sDSName.Len() && !m_xCurrentConnection.is() )
+ { // get the current table list from the connection for the current settings
+
+ // the PropertyValues for the current dialog settings
+ Sequence< PropertyValue > aConnectionParams;
+ OSL_ENSURE(m_pTablesDlg, "OTableSubscriptionPage::implInitControls: need a parent dialog doing the translation!");
+ if ( m_pTablesDlg )
+ {
+ if (!m_pTablesDlg->getCurrentSettings(aConnectionParams))
+ {
+ m_aTablesList.Clear();
+ m_pTablesDlg->endExecution();
+ return;
+ }
+ }
+
+ if (!m_xCollator.is())
+ {
+ // the collator for the string compares
+ try
+ {
+ m_xCollator = Reference< XCollator >(m_xORB->createInstance(SERVICE_I18N_COLLATOR), UNO_QUERY);
+ if (m_xCollator.is())
+ m_xCollator->loadDefaultCollator(Application::GetSettings().GetLocale(), 0);
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // fill the table list with this connection information
+ SQLExceptionInfo aErrorInfo;
+ // the current DSN
+ String sURL;
+ if ( m_pTablesDlg )
+ sURL = m_pTablesDlg->getConnectionURL();
+
+ try
+ {
+ WaitObject aWaitCursor(this);
+ m_aTablesList.GetModel()->SetSortMode(SortAscending);
+ m_aTablesList.GetModel()->SetCompareHdl(LINK(this, OTableSubscriptionPage, OnTreeEntryCompare));
+
+ Reference< XDriver > xDriver;
+ m_aTablesList.setORB(m_xORB);
+ Reference<XPropertySet> xProp = m_pTablesDlg->getCurrentDataSource();
+ OSL_ENSURE(xProp.is(),"No data source set!");
+ if ( xProp.is() )
+ {
+ Any aTableFilter = xProp->getPropertyValue(PROPERTY_TABLEFILTER);
+ Any aTableTypeFilter = xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER);
+
+ Reference<XModifiable> xModi(getDataSourceOrModel(xProp),UNO_QUERY);
+ sal_Bool bModified = ( xModi.is() && xModi->isModified() );
+
+ Sequence< ::rtl::OUString > aNewTableFilter(1);
+ aNewTableFilter[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
+ xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aNewTableFilter));
+
+ xProp->setPropertyValue( PROPERTY_TABLETYPEFILTER, makeAny( Sequence< ::rtl::OUString >() ) );
+ Reference< ::com::sun::star::lang::XEventListener> xEvt;
+ aErrorInfo = ::dbaui::createConnection(xProp,m_xORB,xEvt,m_xCurrentConnection);
+
+ xProp->setPropertyValue(PROPERTY_TABLEFILTER,aTableFilter);
+ xProp->setPropertyValue(PROPERTY_TABLETYPEFILTER,aTableTypeFilter);
+
+ if ( xModi.is() && !bModified )
+ xModi->setModified(sal_False);
+
+ }
+
+ if ( m_xCurrentConnection.is() )
+ {
+ m_aTablesList.UpdateTableList( m_xCurrentConnection );
+ if (m_pTablesDlg)
+ m_pTablesDlg->successfullyConnected();
+ }
+ }
+ catch (const SQLException&)
+ {
+ aErrorInfo = ::cppu::getCaughtException();
+ }
+
+ if (aErrorInfo.isValid())
+ {
+ // establishing the connection failed. Show an error window and exit.
+ OSQLMessageBox aMessageBox( GetParent()->GetParent(), aErrorInfo );
+ aMessageBox.Execute();
+ m_aTables.Enable(sal_False);
+ m_aTablesList.Enable(sal_False);
+ m_aExplanation.Enable(sal_False);
+ m_aTablesList.Clear();
+
+ if ( m_pTablesDlg )
+ {
+ m_pTablesDlg->clearPassword();
+ m_pTablesDlg->endExecution();
+ }
+ }
+ else
+ {
+ // in addition, we need some infos about the connection used
+ m_sCatalogSeparator = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); // (default)
+ m_bCatalogAtStart = sal_True; // (default)
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if (m_xCurrentConnection.is())
+ xMeta = m_xCurrentConnection->getMetaData();
+ if (xMeta.is() && xMeta->supportsCatalogsInDataManipulation())
+ {
+ m_sCatalogSeparator = xMeta->getCatalogSeparator();
+ m_bCatalogAtStart = xMeta->isCatalogAtStart();
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ bValid = bValid && m_xCurrentConnection.is();
+ bReadonly = bReadonly || !bValid;
+
+ // get the current table filter
+ SFX_ITEMSET_GET(_rSet, pTableFilter, OStringListItem, DSID_TABLEFILTER, sal_True);
+ Sequence< ::rtl::OUString > aTableFilter;
+ if (pTableFilter)
+ aTableFilter = pTableFilter->getList();
+
+ implCompleteTablesCheck( aTableFilter );
+
+ // expand the first entry by default
+ SvLBoxEntry* pExpand = m_aTablesList.getAllObjectsEntry();
+ while (pExpand)
+ {
+ m_aTablesList.Expand(pExpand);
+ pExpand = m_aTablesList.FirstChild(pExpand);
+ if (pExpand && m_aTablesList.NextSibling(pExpand))
+ pExpand = NULL;
+ }
+
+ // update the toolbox according the the current selection and check state
+ OGenericAdministrationPage::implInitControls(_rSet, _bSaveValue);
+ }
+
+ //------------------------------------------------------------------------
+ void OTableSubscriptionPage::CheckAll( sal_Bool _bCheck )
+ {
+ SvButtonState eState = _bCheck ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
+ SvLBoxEntry* pEntry = m_aTablesList.First();
+ while (pEntry)
+ {
+ m_aTablesList.SetCheckButtonState( pEntry, eState);
+ pEntry = m_aTablesList.Next(pEntry);
+ }
+
+ if (_bCheck && m_aTablesList.getAllObjectsEntry())
+ m_aTablesList.checkWildcard(m_aTablesList.getAllObjectsEntry());
+ }
+
+ //------------------------------------------------------------------------
+ int OTableSubscriptionPage::DeactivatePage(SfxItemSet* _pSet)
+ {
+ int nResult = OGenericAdministrationPage::DeactivatePage(_pSet);
+
+ // dispose the connection, we don't need it anymore, so we're not wasting resources
+ try
+ {
+ ::comphelper::disposeComponent(m_xCurrentConnection);
+ }
+ catch (RuntimeException&) { }
+
+ return nResult;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OTableSubscriptionPage, OnTreeEntryChecked, Control*, _pControl )
+ {
+ return OnControlModified(_pControl);
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( OTableSubscriptionPage, OnTreeEntryCompare, const SvSortData*, _pSortData )
+ {
+ SvLBoxEntry* pLHS = static_cast<SvLBoxEntry*>(_pSortData->pLeft);
+ SvLBoxEntry* pRHS = static_cast<SvLBoxEntry*>(_pSortData->pRight);
+ OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
+
+ SvLBoxString* pLeftTextItem = static_cast<SvLBoxString*>(pLHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ SvLBoxString* pRightTextItem = static_cast<SvLBoxString*>(pRHS->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
+
+ String sLeftText = pLeftTextItem->GetText();
+ String sRightText = pRightTextItem->GetText();
+
+ sal_Int32 nCompareResult = 0; // equal by default
+
+ if (m_xCollator.is())
+ {
+ try
+ {
+ nCompareResult = m_xCollator->compareString(sLeftText, sRightText);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ else
+ // default behaviour if we do not have a collator -> do the simple string compare
+ nCompareResult = sLeftText.CompareTo(sRightText);
+
+ return nCompareResult;
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OTableSubscriptionPage::collectDetailedSelection() const
+ {
+ Sequence< ::rtl::OUString > aTableFilter;
+ static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ static const ::rtl::OUString sWildcard(RTL_CONSTASCII_USTRINGPARAM("%"));
+
+ ::rtl::OUString sComposedName;
+ const SvLBoxEntry* pAllObjectsEntry = m_aTablesList.getAllObjectsEntry();
+ if (!pAllObjectsEntry)
+ return aTableFilter;
+ SvLBoxEntry* pEntry = m_aTablesList.GetModel()->Next(const_cast<SvLBoxEntry*>(pAllObjectsEntry));
+ while(pEntry)
+ {
+ sal_Bool bCatalogWildcard = sal_False;
+ sal_Bool bSchemaWildcard = sal_False;
+ SvLBoxEntry* pSchema = NULL;
+ SvLBoxEntry* pCatalog = NULL;
+
+ if (m_aTablesList.GetCheckButtonState(pEntry) == SV_BUTTON_CHECKED && !m_aTablesList.GetModel()->HasChilds(pEntry))
+ { // checked and a leaf, which means it's no catalog, no schema, but a real table
+ ::rtl::OUString sCatalog;
+ if(m_aTablesList.GetModel()->HasParent(pEntry))
+ {
+ pSchema = m_aTablesList.GetModel()->GetParent(pEntry);
+ if (pAllObjectsEntry == pSchema)
+ // do not want to have the root entry
+ pSchema = NULL;
+
+ if (pSchema)
+ { // it's a real schema entry, not the "all objects" root
+ if(m_aTablesList.GetModel()->HasParent(pSchema))
+ {
+ pCatalog = m_aTablesList.GetModel()->GetParent(pSchema);
+ if (pAllObjectsEntry == pCatalog)
+ // do not want to have the root entry
+ pCatalog = NULL;
+
+ if (pCatalog)
+ { // it's a real catalog entry, not the "all objects" root
+ bCatalogWildcard = m_aTablesList.isWildcardChecked(pCatalog);
+ if (m_bCatalogAtStart)
+ {
+ sComposedName += m_aTablesList.GetEntryText( pCatalog );
+ sComposedName += m_sCatalogSeparator;
+ if (bCatalogWildcard)
+ sComposedName += sWildcard;
+ }
+ else
+ {
+ if (bCatalogWildcard)
+ sCatalog = sWildcard;
+ else
+ sCatalog = ::rtl::OUString();
+ sCatalog += m_sCatalogSeparator;
+ sCatalog += m_aTablesList.GetEntryText( pCatalog );
+ }
+ }
+ }
+ bSchemaWildcard = m_aTablesList.isWildcardChecked(pSchema);
+ sComposedName += m_aTablesList.GetEntryText( pSchema );
+ sComposedName += sDot;
+ }
+
+ if (bSchemaWildcard)
+ sComposedName += sWildcard;
+ }
+ if (!bSchemaWildcard && !bCatalogWildcard)
+ sComposedName += m_aTablesList.GetEntryText( pEntry );
+
+ if (!m_bCatalogAtStart && !bCatalogWildcard)
+ sComposedName += sCatalog;
+
+ // need some space
+ sal_Int32 nOldLen = aTableFilter.getLength();
+ aTableFilter.realloc(nOldLen + 1);
+ // add the new name
+ aTableFilter[nOldLen] = sComposedName;
+
+ // reset the composed name
+ sComposedName = ::rtl::OUString();
+ }
+
+ if (bCatalogWildcard)
+ pEntry = implNextSibling(pCatalog);
+ else if (bSchemaWildcard)
+ pEntry = implNextSibling(pSchema);
+ else
+ pEntry = m_aTablesList.GetModel()->Next(pEntry);
+ }
+
+ return aTableFilter;
+ }
+
+ //------------------------------------------------------------------------
+ SvLBoxEntry* OTableSubscriptionPage::implNextSibling(SvLBoxEntry* _pEntry) const
+ {
+ SvLBoxEntry* pReturn = NULL;
+ if (_pEntry)
+ {
+ pReturn = m_aTablesList.NextSibling(_pEntry);
+ if (!pReturn)
+ pReturn = implNextSibling(m_aTablesList.GetParent(_pEntry));
+ }
+ return pReturn;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OTableSubscriptionPage::FillItemSet( SfxItemSet& _rCoreAttrs )
+ {
+ sal_Bool bValid, bReadonly;
+ getFlags(_rCoreAttrs, bValid, bReadonly);
+
+ if (!bValid || bReadonly)
+ // don't store anything if the data we're working with is invalid or readonly
+ return sal_True;
+
+ /////////////////////////////////////////////////////////////////////////
+ // create the output string which contains all the table names
+ if ( m_xCurrentConnection.is() )
+ { // collect the table filter data only if we have a connection - else no tables are displayed at all
+ Sequence< ::rtl::OUString > aTableFilter;
+ if (m_aTablesList.isWildcardChecked(m_aTablesList.getAllObjectsEntry()))
+ {
+ aTableFilter.realloc(1);
+ aTableFilter[0] = ::rtl::OUString("%", 1, RTL_TEXTENCODING_ASCII_US);
+ }
+ else
+ {
+ aTableFilter = collectDetailedSelection();
+ }
+ _rCoreAttrs.Put( OStringListItem(DSID_TABLEFILTER, aTableFilter) );
+ }
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------
+ void OTableSubscriptionPage::fillControls(::std::vector< ISaveValueWrapper* >& /*_rControlList*/)
+ {
+ }
+ // -----------------------------------------------------------------------
+ void OTableSubscriptionPage::fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList)
+ {
+ _rControlList.push_back(new ODisableWrapper<OTableTreeListBox>(&m_aTablesList));
+ _rControlList.push_back(new ODisableWrapper<FixedLine>(&m_aTables));
+ _rControlList.push_back(new ODisableWrapper<FixedText>(&m_aExplanation));
+ }
+ // -----------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/tablespage.hxx b/dbaccess/source/ui/dlg/tablespage.hxx
new file mode 100644
index 000000000000..81566ed7faf5
--- /dev/null
+++ b/dbaccess/source/ui/dlg/tablespage.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLESPAGE_HXX_
+#define _DBAUI_TABLESPAGE_HXX_
+
+#include "adminpages.hxx"
+#include <com/sun/star/i18n/XCollator.hpp>
+#include <osl/mutex.hxx>
+#include <comphelper/stl_types.hxx>
+#include <vcl/fixed.hxx>
+#include "tabletree.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //========================================================================
+ //= OTableSubscriptionPage
+ //========================================================================
+ class OTableSubscriptionDialog;
+ class OTableSubscriptionPage
+ :public OGenericAdministrationPage
+ {
+ private:
+ FixedLine m_aTables;
+ OTableTreeListBox m_aTablesList;
+ FixedText m_aExplanation;
+
+ ::rtl::OUString m_sCatalogSeparator;
+ sal_Bool m_bCheckedAll : 1;
+ sal_Bool m_bCatalogAtStart : 1;
+
+ ::osl::Mutex m_aNotifierMutex;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xCurrentConnection; /// valid as long as the page is active
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
+ m_xCollator;
+ OTableSubscriptionDialog* m_pTablesDlg;
+
+ public:
+ virtual sal_Bool FillItemSet(SfxItemSet& _rCoreAttrs);
+ virtual int DeactivatePage(SfxItemSet* _pSet);
+ using OGenericAdministrationPage::DeactivatePage;
+
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+
+ /** will be called when the controls need to be resized.
+ */
+ virtual void resizeControls(const Size& _rDiff);
+
+ OTableSubscriptionPage( Window* pParent, const SfxItemSet& _rCoreAttrs ,OTableSubscriptionDialog* _pTablesDlg);
+ virtual ~OTableSubscriptionPage();
+
+ protected:
+ virtual void fillControls(::std::vector< ISaveValueWrapper* >& _rControlList);
+ virtual void fillWindows(::std::vector< ISaveValueWrapper* >& _rControlList);
+
+ DECL_LINK( OnTreeEntryCompare, const SvSortData* );
+ DECL_LINK( OnTreeEntryChecked, Control* );
+
+ private:
+
+
+ /** check the tables in <member>m_aTablesList</member> according to <arg>_rTables</arg>
+ */
+ void implCheckTables(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTables);
+
+ /// returns the next sibling, if not available, the next sibling of the parent, a.s.o.
+ SvLBoxEntry* implNextSibling(SvLBoxEntry* _pEntry) const;
+
+ /** return the current selection in <member>m_aTablesList</member>
+ */
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > collectDetailedSelection() const;
+
+ /// (un)check all entries
+ void CheckAll( sal_Bool bCheck = sal_True );
+
+ virtual void implInitControls(const SfxItemSet& _rSet, sal_Bool _bSaveValue);
+
+ // checks the tables according to the filter given
+ // in oppsofite to implCheckTables, this method handles the case of an empty sequence, too ...
+ void implCompleteTablesCheck( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rTableFilter );
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_TABLESPAGE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.cxx b/dbaccess/source/ui/dlg/textconnectionsettings.cxx
new file mode 100644
index 000000000000..2ceefab64a35
--- /dev/null
+++ b/dbaccess/source/ui/dlg/textconnectionsettings.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "textconnectionsettings.hxx"
+#include "TextConnectionHelper.hxx"
+#include "dbu_resource.hrc"
+#include "moduledbu.hxx"
+#include "dsitems.hxx"
+#include "dbustrings.hrc"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= TextConnectionSettingsDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ TextConnectionSettingsDialog::TextConnectionSettingsDialog( Window* _pParent, SfxItemSet& _rItems )
+ :ModalDialog( _pParent, ModuleRes( DLG_TEXT_CONNECTION_SETTINGS ) )
+ ,m_aOK( this, ModuleRes( 1 ) )
+ ,m_aCancel( this, ModuleRes( 1 ) )
+ ,m_rItems( _rItems )
+ {
+ m_pTextConnectionHelper.reset( new OTextConnectionHelper( this, TC_HEADER | TC_SEPARATORS | TC_CHARSET ) );
+ FreeResource();
+
+ m_aOK.SetClickHdl( LINK( this, TextConnectionSettingsDialog, OnOK ) );
+ }
+
+ //--------------------------------------------------------------------
+ TextConnectionSettingsDialog::~TextConnectionSettingsDialog()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void TextConnectionSettingsDialog::bindItemStorages( SfxItemSet& _rSet, PropertyValues& _rValues )
+ {
+ _rValues[ PROPERTY_ID_HEADER_LINE ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTFILEHEADER ) );
+ _rValues[ PROPERTY_ID_FIELD_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_FIELDDELIMITER ) );
+ _rValues[ PROPERTY_ID_STRING_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_TEXTDELIMITER ) );
+ _rValues[ PROPERTY_ID_DECIMAL_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_DECIMALDELIMITER ) );
+ _rValues[ PROPERTY_ID_THOUSAND_DELIMITER ].reset( new SetItemPropertyStorage( _rSet, DSID_THOUSANDSDELIMITER ) );
+ _rValues[ PROPERTY_ID_ENCODING ].reset( new SetItemPropertyStorage( _rSet, DSID_CHARSET ) );
+ }
+
+ //--------------------------------------------------------------------
+ short TextConnectionSettingsDialog::Execute()
+ {
+ m_pTextConnectionHelper->implInitControls( m_rItems, sal_True );
+ return ModalDialog::Execute();
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( TextConnectionSettingsDialog, OnOK, PushButton*, /*_pButton*/ )
+ {
+ if ( m_pTextConnectionHelper->prepareLeave() )
+ {
+ sal_Bool bUnused = sal_False;
+ m_pTextConnectionHelper->FillItemSet( m_rItems, bUnused );
+ EndDialog( RET_OK );
+ return 1L;
+ }
+
+ return 0L;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/dlg/textconnectionsettings.src b/dbaccess/source/ui/dlg/textconnectionsettings.src
new file mode 100644
index 000000000000..b34a056076a8
--- /dev/null
+++ b/dbaccess/source/ui/dlg/textconnectionsettings.src
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dbu_dlg.hrc"
+#include "dbu_resource.hrc"
+#include "AutoControls.hrc"
+
+#define DIALOG_WIDTH 200
+#define DIALOG_HEIGHT 160
+
+ModalDialog DLG_TEXT_CONNECTION_SETTINGS
+{
+ HelpID = "dbaccess:ModalDialog:DLG_TEXT_CONNECTION_SETTINGS";
+ Size = MAP_APPFONT( DIALOG_WIDTH, DIALOG_HEIGHT );
+ OutputSize = TRUE ;
+
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ Text [ en-US ] = "Text Connection Settings";
+
+ AUTO_SEPARATORCONTROLGROUP( UNRELATED_CONTROLS, DIALOG_WIDTH )
+
+ OKButton 1
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH - RELATED_CONTROLS - BUTTON_WIDTH, DIALOG_HEIGHT - 6 - BUTTON_HEIGHT );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+
+ DefButton = TRUE;
+ };
+
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH, DIALOG_HEIGHT - 6 - BUTTON_HEIGHT );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+ };
+};
diff --git a/dbaccess/source/ui/imagelists/dbimagelists.src b/dbaccess/source/ui/imagelists/dbimagelists.src
new file mode 100644
index 000000000000..8f993554f7c7
--- /dev/null
+++ b/dbaccess/source/ui/imagelists/dbimagelists.src
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_DLG_HRC_
+#include "dbu_dlg.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; }
+
+//-------------------------------------------------------------------------
+#define IL_TOOL_2 \
+\
+ IdList = {\
+ ID_INDEX_NEW;\
+ ID_INDEX_DROP;\
+ ID_INDEX_RENAME;\
+ ID_INDEX_SAVE;\
+ ID_INDEX_RESET;\
+ };\
+ IdCount = {\
+ 5;\
+ }
+
+
+ImageList IMG_INDEX_DLG_SC
+{
+ MASKCOLOR;
+ prefix = "sc";
+ IL_TOOL_2 ;
+};
+
+ImageList IMG_INDEX_DLG_LC
+{
+ MASKCOLOR;
+ prefix = "lc";
+ IL_TOOL_2 ;
+};
+
+Image IMG_FORMFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "forms_32"; };
+ MASKCOLOR;
+};
+
+Image IMG_REPORTFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "reports_32"; };
+ MASKCOLOR;
+};
+
+Image IMG_QUERYFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "queries_32"; };
+ MASKCOLOR;
+};
+
+Image IMG_TABLEFOLDER_TREE_L
+{
+ ImageBitmap = Bitmap { File = "tables_32"; };
+ MASKCOLOR;
+};
+
+//========================================================================
+//= database object icons
+
+//------------------------------------------------------------------------
+// the whole database
+
+Image DATABASE_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "db.png"; };
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+};
+
+//------------------------------------------------------------------------
+// tables and table folders
+
+Image TABLE_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03188.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image TABLEFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03187.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+//------------------------------------------------------------------------
+// views
+
+Image VIEW_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx16670.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+//------------------------------------------------------------------------
+// queries and query folders
+
+Image QUERY_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03202.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+Image QUERYFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "sx03201.png"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+};
+
+//------------------------------------------------------------------------
+// forms and form folders
+
+Image FORM_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "form_16"; };
+ MASKCOLOR;
+};
+
+Image FORMFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "forms_16"; };
+ MASKCOLOR;
+};
+
+//------------------------------------------------------------------------
+// reports and report folders
+
+Image REPORT_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "report_16"; };
+ MASKCOLOR;
+};
+
+Image REPORTFOLDER_TREE_ICON
+{
+ ImageBitmap = Bitmap { File = "reports_16"; };
+ MASKCOLOR;
+};
diff --git a/dbaccess/source/ui/imagelists/makefile.mk b/dbaccess/source/ui/imagelists/makefile.mk
new file mode 100644
index 000000000000..3620f6329889
--- /dev/null
+++ b/dbaccess/source/ui/imagelists/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=dbaccess
+TARGET=uiimglst
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+IMGLST_SRS=$(SRS)$/$(TARGET).srs
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES=dbimagelists.src
+
+# ... object files ............................
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/dbaccess/source/ui/inc/AccessibleBaseIFace.hxx b/dbaccess/source/ui/inc/AccessibleBaseIFace.hxx
new file mode 100644
index 000000000000..adcd7bf75c4b
--- /dev/null
+++ b/dbaccess/source/ui/inc/AccessibleBaseIFace.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_ACCESSIBLE_HELPER_IFACE_HXX
+#define DBAUI_ACCESSIBLE_HELPER_IFACE_HXX
+
+#include <sal/types.h>
+
+namespace dbaui
+{
+ class SAL_NO_VTABLE IAccessibleHelper
+ {
+ protected:
+ /** isEditable returns the current editable state
+ @return true if it is editable otherwise false
+ */
+ virtual sal_Bool isEditable() const = 0;
+ public:
+ /** notifies all listeners that this object has changed
+ @param _nEventId the event id
+ @param _aOldValue the old value
+ @param _aNewValue the new value
+ */
+ virtual void notifyAccessibleEvent( sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _aOldValue,
+ const ::com::sun::star::uno::Any& _aNewValue) = 0;
+ };
+}
+#endif // DBAUI_ACCESSIBLE_HELPER_IFACE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/AppElementType.hxx b/dbaccess/source/ui/inc/AppElementType.hxx
new file mode 100644
index 000000000000..006f5ced1c73
--- /dev/null
+++ b/dbaccess/source/ui/inc/AppElementType.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_APPELEMENTTYPE_HXX
+#define DBAUI_APPELEMENTTYPE_HXX
+
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ enum ElementType
+ {
+ E_TABLE = ::com::sun::star::sdb::application::DatabaseObject::TABLE,
+ E_QUERY = ::com::sun::star::sdb::application::DatabaseObject::QUERY,
+ E_FORM = ::com::sun::star::sdb::application::DatabaseObject::FORM,
+ E_REPORT = ::com::sun::star::sdb::application::DatabaseObject::REPORT,
+
+ E_NONE = 4,
+ E_ELEMENT_TYPE_COUNT = E_NONE
+ };
+
+ enum PreviewMode
+ {
+ E_PREVIEWNONE = 0,
+ E_DOCUMENT = 1,
+ E_DOCUMENTINFO = 2
+ };
+
+ enum ElementOpenMode
+ {
+ E_OPEN_NORMAL,
+ E_OPEN_DESIGN,
+ E_OPEN_FOR_MAIL
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+#endif // DBAUI_APPELEMENTTYPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/CollectionView.hxx b/dbaccess/source/ui/inc/CollectionView.hxx
new file mode 100644
index 000000000000..395ad71f3e0c
--- /dev/null
+++ b/dbaccess/source/ui/inc/CollectionView.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_COLLECTIONVIEW_HXX
+#define DBAUI_COLLECTIONVIEW_HXX
+
+#include <svtools/fileview.hxx>
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ /* this class allows to browse through the collection of forms and reports
+ */
+ class OCollectionView : public ModalDialog
+ {
+ FixedText m_aFTCurrentPath;
+ ImageButton m_aNewFolder;
+ ImageButton m_aUp;
+ SvtFileView m_aView;
+ FixedText m_aFTName;
+ Edit m_aName;
+ FixedLine m_aFL;
+ PushButton m_aPB_OK;
+ CancelButton m_aPB_CANCEL;
+ HelpButton m_aPB_HELP;
+ String m_sPath;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xContent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ Size m_aDlgSize;
+ Size m_a6Size;
+ sal_Int32 m_nFixDeltaHeight;
+ sal_Bool m_bCreateForm;
+
+ DECL_LINK(Up_Click,PushButton*);
+ DECL_LINK(NewFolder_Click,PushButton*);
+ DECL_LINK(Save_Click,PushButton*);
+ DECL_LINK(Dbl_Click_FileView,SvtFileView*);
+
+ /// sets the fixedtext to the right content
+ void initCurrentPath();
+ public:
+ OCollectionView( Window * pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent
+ ,const ::rtl::OUString& _sDefaultName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB);
+ virtual ~OCollectionView();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> getSelectedFolder() const;
+ ::rtl::OUString getName() const;
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+#endif //DBAUI_COLLECTIONVIEW_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/ColumnControlWindow.hxx b/dbaccess/source/ui/inc/ColumnControlWindow.hxx
new file mode 100644
index 000000000000..5cd8d93a337a
--- /dev/null
+++ b/dbaccess/source/ui/inc/ColumnControlWindow.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_COLUMNCONTROLWINDOW_HXX
+#define DBAUI_COLUMNCONTROLWINDOW_HXX
+
+#include "FieldDescControl.hxx"
+#include "TypeInfo.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ // =============================================================================================
+ // OColumnControlWindow
+ // =============================================================================================
+ class OColumnControlWindow : public OFieldDescControl
+ {
+ ::com::sun::star::lang::Locale m_aLocale;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+
+ OTypeInfoMap m_aDestTypeInfo;
+ ::std::vector<OTypeInfoMap::iterator> m_aDestTypeInfoIndex;
+
+ mutable TOTypeInfoSP m_pTypeInfo; // default type
+ String m_sTypeNames; // these type names are the ones out of the resource file
+ ::rtl::OUString m_sAutoIncrementValue;
+ sal_Bool m_bAutoIncrementEnabled;
+ protected:
+ virtual void ActivateAggregate( EControlType eType );
+ virtual void DeactivateAggregate( EControlType eType );
+
+ virtual ::com::sun::star::lang::Locale GetLocale() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const;
+ virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos);
+ virtual sal_Bool isAutoIncrementValueEnabled() const;
+ virtual ::rtl::OUString getAutoIncrementValue() const;
+ virtual void CellModified(long nRow, sal_uInt16 nColId );
+
+ public:
+ OColumnControlWindow(Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+ virtual ~OColumnControlWindow();
+
+ void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xCon);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection();
+ virtual const OTypeInfoMap* getTypeInfo() const;
+ TOTypeInfoSP getDefaultTyp() const;
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+#endif // DBAUI_COLUMNCONTROLWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/ConnectionLine.hxx b/dbaccess/source/ui/inc/ConnectionLine.hxx
new file mode 100644
index 000000000000..9dfce6c0dfff
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLine.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_CONNECTIONLINE_HXX
+#define DBAUI_CONNECTIONLINE_HXX
+
+#include <tools/gen.hxx>
+#include <tools/string.hxx>
+#include "ConnectionLineData.hxx"
+#include <functional>
+
+class OutputDevice;
+namespace dbaui
+{
+
+ //==================================================================
+ // ConnData ---------->* ConnLineData
+ // ^1 ^1
+ // | |
+ // Conn ---------->* ConnLine
+ //==================================================================
+
+ /*
+ the class OConnectionLine represents the graphical line between the to two windows
+ **/
+ class OConnectionLineData;
+ class OTableConnection;
+ class OTableWindow;
+ class OConnectionLine
+ {
+ OTableConnection* m_pTabConn;
+ OConnectionLineDataRef m_pData;
+
+ Point m_aSourceConnPos,
+ m_aDestConnPos;
+ Point m_aSourceDescrLinePos,
+ m_aDestDescrLinePos;
+ public:
+ OConnectionLine( OTableConnection* pConn, OConnectionLineDataRef pLineData );
+ OConnectionLine( const OConnectionLine& rLine );
+ virtual ~OConnectionLine();
+
+ OConnectionLine& operator=( const OConnectionLine& rLine );
+
+ Rectangle GetBoundingRect();
+ sal_Bool RecalcLine();
+ void Draw( OutputDevice* pOutDev );
+ bool CheckHit( const Point& rMousePos ) const;
+ String GetSourceFieldName() const { return m_pData->GetSourceFieldName(); }
+ String GetDestFieldName() const { return m_pData->GetDestFieldName(); }
+
+ sal_Bool IsValid() const;
+
+ Rectangle GetSourceTextPos() const;
+ Rectangle GetDestTextPos() const;
+
+ OConnectionLineDataRef GetData() const { return m_pData; }
+
+ Point getMidPoint() const;
+ };
+ /// unary_function Functor object for class OConnectionLine returntype is void
+ /// draws a connectionline object on outputdevice
+ struct TConnectionLineDrawFunctor : ::std::unary_function<OConnectionLine*,void>
+ {
+ OutputDevice* pDevice;
+ TConnectionLineDrawFunctor(OutputDevice* _pDevice)
+ {
+ pDevice = _pDevice;
+ }
+ inline void operator()(OConnectionLine* _pLine)
+ {
+ _pLine->Draw(pDevice);
+ }
+ };
+ /// binary_function Functor object for class OConnectionLine returntype is bool
+ /// checks if the point is on connectionline
+ struct TConnectionLineCheckHitFunctor : ::std::binary_function<OConnectionLine*,Point,bool>
+ {
+ inline bool operator()(const OConnectionLine* lhs,const Point& rhs) const
+ {
+ return lhs->CheckHit(rhs);
+ }
+ };
+
+}
+#endif // DBAUI_CONNECTIONLINE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/ConnectionLineAccess.hxx b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx
new file mode 100644
index 000000000000..d36af945165f
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLineAccess.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_CONNECTIONLINEACCESS_HXX
+#define DBACCESS_CONNECTIONLINEACCESS_HXX
+
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+
+namespace dbaui
+{
+ typedef ::cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleRelationSet,
+ ::com::sun::star::accessibility::XAccessible
+ > OConnectionLineAccess_BASE;
+ class OTableConnection;
+ /** the class OConnectionLineAccess represents the accessible object for the connection between two table windows
+ like they are used in the QueryDesign and the RelationDesign
+ */
+ class OConnectionLineAccess : public VCLXAccessibleComponent
+ , public OConnectionLineAccess_BASE
+ {
+ const OTableConnection* m_pLine; // the window which I should give accessibility to
+ protected:
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+
+ /** isEditable returns the current editable state
+ @return true if it is editable otherwise false
+ */
+ virtual sal_Bool isEditable() const;
+ public:
+ OConnectionLineAccess(OTableConnection* _pLine);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ()
+ { // here inline is allowed because we do not use this class outside this dll
+ VCLXAccessibleComponent::acquire( );
+ }
+ virtual void SAL_CALL release( ) throw ()
+ { // here inline is allowed because we do not use this class outside this dll
+ VCLXAccessibleComponent::release( );
+ }
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::rtl::OUString getImplementationName_Static(void) throw( com::sun::star::uno::RuntimeException );
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual sal_Bool SAL_CALL contains( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isShowing( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFocusTraversable( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleRelationSet
+ virtual sal_Int32 SAL_CALL getRelationCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL getRelation( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL containsRelation( sal_Int16 aRelationType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL getRelationByType( sal_Int16 aRelationType ) throw (::com::sun::star::uno::RuntimeException);
+ };
+}
+#endif // DBACCESS_CONNECTIONLINEACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/ConnectionLineData.hxx b/dbaccess/source/ui/inc/ConnectionLineData.hxx
new file mode 100644
index 000000000000..50898937894c
--- /dev/null
+++ b/dbaccess/source/ui/inc/ConnectionLineData.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_CONNECTIONLINEDATA_HXX
+#define DBAUI_CONNECTIONLINEDATA_HXX
+
+#include "QEnumTypes.hxx"
+#include <vector>
+
+#include <rtl/ref.hxx>
+#include <salhelper/simplereferenceobject.hxx>
+#include "RefFunctor.hxx"
+#include <rtl/ustring.hxx>
+
+namespace dbaui
+{
+
+ //==================================================================
+ // ConnData ---------->* ConnLineData
+ // ^1 ^1
+ // | |
+ // Conn ---------->* ConnLine
+ //==================================================================
+
+
+ //==================================================================
+ /**
+ the class OConnectionLineData contains the data of a connection
+ e.g. the source and the destanation field
+ **/
+ class OConnectionLineData : public ::salhelper::SimpleReferenceObject
+ {
+ ::rtl::OUString m_aSourceFieldName;
+ ::rtl::OUString m_aDestFieldName;
+
+ friend bool operator==(const OConnectionLineData& lhs, const OConnectionLineData& rhs);
+ friend bool operator!=(const OConnectionLineData& lhs, const OConnectionLineData& rhs) { return !(lhs == rhs); }
+ protected:
+ virtual ~OConnectionLineData();
+ public:
+ OConnectionLineData();
+ OConnectionLineData( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName );
+ OConnectionLineData( const OConnectionLineData& rConnLineData );
+
+ // eine Kopie der eigenen Instanz liefern (das ist mir irgendwie angenehmer als ein virtueller Zuweisungsoperator)
+ void CopyFrom(const OConnectionLineData& rSource);
+
+ // Memberzugriff (schreiben)
+ void SetFieldName(EConnectionSide nWhich, const ::rtl::OUString& strFieldName)
+ {
+ if (nWhich==JTCS_FROM)
+ m_aSourceFieldName = strFieldName;
+ else
+ m_aDestFieldName = strFieldName;
+ }
+ void SetSourceFieldName( const ::rtl::OUString& rSourceFieldName){ SetFieldName(JTCS_FROM, rSourceFieldName); }
+ void SetDestFieldName( const ::rtl::OUString& rDestFieldName ){ SetFieldName(JTCS_TO, rDestFieldName); }
+
+ inline bool clearSourceFieldName() { SetSourceFieldName(::rtl::OUString()); return true;}
+ inline bool clearDestFieldName() { SetDestFieldName(::rtl::OUString()); return true;}
+
+ // Memberzugriff (lesen)
+ ::rtl::OUString GetFieldName(EConnectionSide nWhich) const { return (nWhich == JTCS_FROM) ? m_aSourceFieldName : m_aDestFieldName; }
+ ::rtl::OUString GetSourceFieldName() const { return GetFieldName(JTCS_FROM); }
+ ::rtl::OUString GetDestFieldName() const { return GetFieldName(JTCS_TO); }
+
+ bool Reset();
+ OConnectionLineData& operator=( const OConnectionLineData& rConnLineData );
+ };
+
+ //-------------------------------------------------------------------------
+ //------------------------------------------------------------------
+ typedef ::rtl::Reference< OConnectionLineData > OConnectionLineDataRef;
+ typedef ::std::vector< OConnectionLineDataRef > OConnectionLineDataVec;
+}
+#endif // DBAUI_CONNECTIONLINEDATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/DExport.hxx b/dbaccess/source/ui/inc/DExport.hxx
new file mode 100644
index 000000000000..d186b457e4a0
--- /dev/null
+++ b/dbaccess/source/ui/inc/DExport.hxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_DATABASEEXPORT_HXX
+#define DBAUI_DATABASEEXPORT_HXX
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <vector>
+#include <tools/string.hxx>
+#include <comphelper/stl_types.hxx>
+#include "TypeInfo.hxx"
+#include "WTypeSelect.hxx"
+#include "commontypes.hxx"
+#include "IUpdateHelper.hxx"
+#include "WTypeSelect.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace awt{
+ struct FontDescriptor;
+ }
+ namespace sdbc{
+ class XPreparedStatement;
+ class XDatabaseMetaData;
+ }
+}}}
+
+#define COLUMN_POSITION_NOT_FOUND ((sal_Int32)-1)
+
+class Window;
+class SvNumberFormatter;
+namespace dbaui
+{
+ class OFieldDescription;
+ class OTypeInfo;
+ class OWizTypeSelect;
+ class ODatabaseExport
+ {
+ public:
+ DECLARE_STL_MAP(::rtl::OUString,OFieldDescription*,::comphelper::UStringMixLess,TColumns);
+ typedef ::std::vector<TColumns::const_iterator> TColumnVector;
+ typedef ::std::vector< ::std::pair<sal_Int32,sal_Int32> > TPositions;
+
+ protected:
+ TPositions m_vColumns; // Welche Spalten "ubernommen werden sollen
+ ::std::vector<sal_Int32> m_vColumnTypes; // FeldTypen f"ur schnelleren Zugriff
+ ::std::vector<sal_Int32> m_vColumnSize;
+ ::std::vector<sal_Int16> m_vNumberFormat;
+ ::com::sun::star::lang::Locale m_aLocale;
+
+ TColumns m_aDestColumns; // container for new created columns
+ TColumnVector m_vDestVector;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; // dest table
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xTables; // container
+ SharedConnection m_xConnection; // dest conn
+
+ ::boost::shared_ptr<IUpdateHelper> m_pUpdateHelper;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet; //
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+ ::com::sun::star::util::Date m_aNullDate;
+
+ SvNumberFormatter* m_pFormatter;
+ SvStream& m_rInputStream;
+ //for save the selected tablename
+ ::rtl::OUString m_sDefaultTableName;
+
+ String m_sTextToken; // Zellen Inhalt
+ String m_sNumToken; /// SDNUM value
+ String m_sValToken; /// SDVAL value
+ TOTypeInfoSP m_pTypeInfo; // contains the default type
+ const TColumnVector* m_pColumnList;
+ const OTypeInfoMap* m_pInfoMap;
+ sal_Int32 m_nColumnPos; // aktuelle Spaltenposition
+ sal_Int32 m_nRows; // Anzahl der Zeilen die durchsucht werden sollen
+ sal_Int32 m_nRowCount; // current count of rows
+ rtl_TextEncoding m_nDefToken; // Sprache
+ sal_Bool m_bError; // Fehler und Abbruchstatus
+ sal_Bool m_bInTbl; // Ist gesetzt, wenn der Parser sich in der RTF Tabelle befindet
+ sal_Bool m_bHead; // ist true, wenn die Kopfzeile noch nicht gelesen wurde
+ sal_Bool m_bDontAskAgain;// Falls beim Einf"ugen ein Fehler auftritt, soll die Fehlermeldung nicht
+ sal_Bool m_bIsAutoIncrement; // if PKey is set by user
+ sal_Bool m_bFoundTable; // set to true when a table was found
+ sal_Bool m_bCheckOnly;
+ bool m_bAppendFirstLine;
+
+
+ virtual sal_Bool CreateTable(int nToken) = 0;
+ virtual TypeSelectionPageFactory
+ getTypeSelectionPageFactory() = 0;
+
+ void CreateDefaultColumn(const ::rtl::OUString& _rColumnName);
+ sal_Int16 CheckString(const String& aToken, sal_Int16 _nOldNumberFormat);
+ void adjustFormat();
+ void eraseTokens();
+ void insertValueIntoColumn();
+ sal_Bool createRowSet();
+ void showErrorDialog(const ::com::sun::star::sdbc::SQLException& e);
+ void ensureFormatter();
+
+ /** executeWizard calls a wizard to create/append data
+ @param _sTableName the tablename
+ @param _aTextColor the text color of the new created table
+ @param _rFont the font of the new table
+
+ @return true when an error occurs
+ */
+ sal_Bool executeWizard( const ::rtl::OUString& _sTableName,
+ const ::com::sun::star::uno::Any& _aTextColor,
+ const ::com::sun::star::awt::FontDescriptor& _rFont);
+
+ virtual ~ODatabaseExport();
+ public:
+ ODatabaseExport(
+ const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList,
+ const OTypeInfoMap* _pInfoMap,
+ SvStream& _rInputStream
+ );
+
+ // wird f"ur auto. Typ-Erkennung gebraucht
+ ODatabaseExport(
+ sal_Int32 nRows,
+ const TPositions& _rColumnPositions,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled,
+ SvStream& _rInputStream
+ );
+
+ void SetColumnTypes(const TColumnVector* rList,const OTypeInfoMap* _pInfoMap);
+
+ inline void SetTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName ; }
+
+ virtual void release() = 0;
+
+ void enableCheckOnly() { m_bCheckOnly = sal_True; }
+ sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > createPreparedStatment( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDestTable
+ ,const TPositions& _rvColumns);
+ };
+}
+
+#endif // DBAUI_DATABASEEXPORT_HXX
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/FieldControls.hxx b/dbaccess/source/ui/inc/FieldControls.hxx
new file mode 100644
index 000000000000..661f66a96bda
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldControls.hxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#define DBAUI_FIELDCONTROLS_HXX
+
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/svapp.hxx>
+#include "SqlNameEdit.hxx"
+#include "moduledbu.hxx"
+
+
+namespace dbaui
+{
+ namespace
+ {
+ void lcl_setSpecialReadOnly( sal_Bool _bReadOnly, Window* _pWin )
+ {
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ const Color& rNewColor = _bReadOnly ? aSystemStyle.GetDialogColor() : aSystemStyle.GetFieldColor();
+ _pWin->SetBackground(Wallpaper(rNewColor));
+ _pWin->SetControlBackground(rNewColor);
+ }
+ }
+
+ //==================================================================
+ class OPropColumnEditCtrl : public OSQLNameEdit
+ {
+ OModuleClient m_aModuleClient;
+ short m_nPos;
+ String m_strHelpText;
+ public:
+ inline OPropColumnEditCtrl(Window* pParent, ::rtl::OUString& _rAllowedChars, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+
+ inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+ inline OPropColumnEditCtrl::OPropColumnEditCtrl(Window* pParent,
+ ::rtl::OUString& _rAllowedChars,
+ sal_uInt16 nHelpId,
+ short nPosition,
+ WinBits nWinStyle)
+ :OSQLNameEdit(pParent, _rAllowedChars,nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText=String(ModuleRes(nHelpId));
+ }
+ //==================================================================
+ class OPropEditCtrl : public Edit
+ {
+ OModuleClient m_aModuleClient;
+ short m_nPos;
+ String m_strHelpText;
+
+ public:
+ inline OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropEditCtrl::OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
+ :Edit(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropEditCtrl::OPropEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
+ :Edit(pParent, _rRes)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+
+ //==================================================================
+ class OPropNumericEditCtrl : public NumericField
+ {
+ short m_nPos;
+ String m_strHelpText;
+
+ public:
+ inline OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline sal_Bool IsModified() const { return GetText() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
+ :NumericField(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropNumericEditCtrl::OPropNumericEditCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
+ :NumericField(pParent, _rRes)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+
+ //==================================================================
+ class OPropListBoxCtrl : public ListBox
+ {
+ short m_nPos;
+ String m_strHelpText;
+
+ public:
+ inline OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition = -1, WinBits nWinStyle = 0);
+ inline OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition = -1);
+
+ inline sal_Bool IsModified() const { return GetSelectEntryPos() != GetSavedValue(); }
+
+ short GetPos() const { return m_nPos; }
+ String GetHelp() const { return m_strHelpText; }
+
+ virtual void SetSpecialReadOnly(sal_Bool _bReadOnly)
+ {
+ SetReadOnly(_bReadOnly);
+ lcl_setSpecialReadOnly(_bReadOnly,this);
+ }
+ };
+
+ inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, short nPosition, WinBits nWinStyle)
+ :ListBox(pParent, nWinStyle)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+ inline OPropListBoxCtrl::OPropListBoxCtrl(Window* pParent, sal_uInt16 nHelpId, const ResId& _rRes,short nPosition)
+ :ListBox(pParent, _rRes)
+ ,m_nPos(nPosition)
+ {
+ m_strHelpText =String(ModuleRes(nHelpId));
+ }
+}
+#endif // DBAUI_FIELDCONTROLS_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx
new file mode 100644
index 000000000000..cd038229deab
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldDescControl.hxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+#define DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+
+#include <vcl/tabpage.hxx>
+#include "QEnumTypes.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include "TypeInfo.hxx"
+
+//------------------------------------------------------------------
+// die Spalten einer Feld-Beschreibung einer Tabelle
+#define FIELD_NAME 1
+#define FIELD_TYPE 2
+#define HELP_TEXT 3
+#define COLUMN_DESCRIPTION 4
+
+#define FIELD_FIRST_VIRTUAL_COLUMN 5
+
+#define FIELD_PROPERTY_REQUIRED 5
+#define FIELD_PROPERTY_NUMTYPE 6
+#define FIELD_PROPERTY_AUTOINC 7
+#define FIELD_PROPERTY_DEFAULT 8
+#define FIELD_PROPERTY_TEXTLEN 9
+#define FIELD_PROPERTY_LENGTH 10
+#define FIELD_PROPERTY_SCALE 11
+#define FIELD_PROPERTY_BOOL_DEFAULT 12
+#define FIELD_PROPERTY_FORMAT 13
+#define FIELD_PRPOERTY_COLUMNNAME 14
+#define FIELD_PRPOERTY_TYPE 15
+#define FIELD_PRPOERTY_AUTOINCREMENT 16
+
+class FixedText;
+class PushButton;
+class SvxNumberFormatShell;
+class ScrollBar;
+class Button;
+class ListBox;
+class Control;
+class SvNumberFormatter;
+
+namespace dbaui
+{
+
+ class OTableDesignHelpBar;
+ class OPropListBoxCtrl;
+ class OPropEditCtrl;
+ class OPropNumericEditCtrl;
+ class OFieldDescription;
+ class OTypeInfo;
+ class OPropColumnEditCtrl;
+ //==================================================================
+ class OFieldDescControl : public TabPage
+ {
+ private:
+ OTableDesignHelpBar* pHelp;
+ Window* pLastFocusWindow;
+ Window* m_pActFocusWindow;
+
+ FixedText* pDefaultText;
+ FixedText* pRequiredText;
+ FixedText* pAutoIncrementText;
+ FixedText* pTextLenText;
+ FixedText* pNumTypeText;
+ FixedText* pLengthText;
+ FixedText* pScaleText;
+ FixedText* pFormatText;
+ FixedText* pBoolDefaultText;
+ FixedText* m_pColumnNameText;
+ FixedText* m_pTypeText;
+ FixedText* m_pAutoIncrementValueText;
+
+ OPropListBoxCtrl* pRequired;
+ OPropListBoxCtrl* pNumType;
+ OPropListBoxCtrl* pAutoIncrement;
+ OPropEditCtrl* pDefault;
+ OPropNumericEditCtrl* pTextLen;
+ OPropNumericEditCtrl* pLength;
+ OPropNumericEditCtrl* pScale;
+ OPropEditCtrl* pFormatSample;
+ OPropListBoxCtrl* pBoolDefault;
+ OPropColumnEditCtrl* m_pColumnName;
+ OPropListBoxCtrl* m_pType;
+ OPropEditCtrl* m_pAutoIncrementValue;
+
+ PushButton* pFormat;
+
+ ScrollBar* m_pVertScroll;
+ ScrollBar* m_pHorzScroll;
+
+ TOTypeInfoSP m_pPreviousType;
+ sal_uInt16 nCurChildId;
+ short m_nPos;
+ XubString aYes;
+ XubString aNo;
+
+ long m_nOldVThumb;
+ long m_nOldHThumb;
+ sal_Int32 m_nWidth;
+
+ sal_uLong nDelayedGrabFocusEvent;
+ sal_Bool m_bAdded;
+ bool m_bRightAligned;
+
+ OFieldDescription* pActFieldDescr;
+
+ DECL_LINK( OnScroll, ScrollBar*);
+
+ DECL_LINK( FormatClickHdl, Button * );
+ DECL_LINK( ChangeHdl, ListBox * );
+
+ DECL_LINK( DelayedGrabFocus, Control** );
+ // von ActivatePropertyField benutzt
+ DECL_LINK( OnControlFocusLost, Control* );
+ DECL_LINK( OnControlFocusGot, Control* );
+
+ void UpdateFormatSample(OFieldDescription* pFieldDescr);
+ void ArrangeAggregates();
+
+ void SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol );
+
+ void ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY);
+ void ScrollAllAggregates();
+
+ sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
+ void Contruct();
+ OPropNumericEditCtrl* CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId);
+ FixedText* CreateText(sal_uInt16 _nTextRes);
+ void InitializeControl(Control* _pControl,const rtl::OString& _sHelpId,bool _bAddChangeHandler);
+
+ protected:
+ inline void setRightAligned() { m_bRightAligned = true; }
+ inline bool isRightAligned() const { return m_bRightAligned; }
+
+ inline void saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
+ inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; }
+ inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; }
+
+ sal_uInt16 CountActiveAggregates() const;
+ sal_Int32 GetMaxControlHeight() const;
+
+ virtual void ActivateAggregate( EControlType eType );
+ virtual void DeactivateAggregate( EControlType eType );
+ virtual sal_Bool IsReadOnly() { return sal_False; };
+
+ // Sind von den abgeleiteten Klassen zu impl.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const = 0;
+
+ virtual ::com::sun::star::lang::Locale GetLocale() const = 0;
+
+ virtual void CellModified(long nRow, sal_uInt16 nColId ) = 0;
+ virtual void SetModified(sal_Bool bModified); // base implementation is empty
+
+ virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) = 0;
+ virtual const OTypeInfoMap* getTypeInfo() const = 0;
+
+ virtual sal_Bool isAutoIncrementValueEnabled() const = 0;
+ virtual ::rtl::OUString getAutoIncrementValue() const = 0;
+
+ String BoolStringPersistent(const String& rUIString) const;
+ String BoolStringUI(const String& rPersistentString) const;
+
+ const OPropColumnEditCtrl* getColumnCtrl() const { return m_pColumnName; }
+
+ public:
+ OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
+ OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
+ virtual ~OFieldDescControl();
+
+ void DisplayData(OFieldDescription* pFieldDescr );
+ // void DisplayData(const OColumn* pColumn);
+
+ void SaveData( OFieldDescription* pFieldDescr );
+ // void SaveData( OColumn* pColumn);
+
+ void SetControlText( sal_uInt16 nControlId, const String& rText );
+ String GetControlText( sal_uInt16 nControlId );
+ void SetReadOnly( sal_Bool bReadOnly );
+
+ // Resize aufegrufen
+ void CheckScrollBars();
+ sal_Bool isCutAllowed();
+ sal_Bool isCopyAllowed();
+ sal_Bool isPasteAllowed();
+
+ void cut();
+ void copy();
+ void paste();
+
+ virtual void Init();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual void Resize();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() = 0;
+
+ String getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck = sal_True) const;
+
+ inline void setEditWidth(sal_Int32 _nWidth) { m_nWidth = _nWidth; }
+ protected:
+ void implFocusLost(Window* _pWhich);
+ };
+}
+#endif // DBAUI_FIELDDESCRIPTIONCONTROL_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx
new file mode 100644
index 000000000000..980b23050f3e
--- /dev/null
+++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_FIELDDESCRIPTIONS_HXX
+#define DBAUI_FIELDDESCRIPTIONS_HXX
+
+#include "QEnumTypes.hxx"
+#include <editeng/svxenum.hxx>
+#include "TypeInfo.hxx"
+#include <osl/diagnose.h>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+
+namespace dbaui
+{
+ class OFieldDescription
+ {
+ private:
+ ::com::sun::star::uno::Any m_aDefaultValue; // the default value from the database
+ ::com::sun::star::uno::Any m_aControlDefault; // the value which the control inserts as default
+ ::com::sun::star::uno::Any m_aWidth; // sal_Int32 or void
+ ::com::sun::star::uno::Any m_aRelativePosition; // sal_Int32 or void
+
+ TOTypeInfoSP m_pType;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDest;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xDestInfo;
+
+ ::rtl::OUString m_sName;
+ ::rtl::OUString m_sTypeName;
+ ::rtl::OUString m_sDescription;
+ ::rtl::OUString m_sHelpText;
+
+ ::rtl::OUString m_sAutoIncrementValue;
+ sal_Int32 m_nType; // only used when m_pType is null
+ sal_Int32 m_nPrecision;
+ sal_Int32 m_nScale;
+ sal_Int32 m_nIsNullable;
+ sal_Int32 m_nFormatKey;
+ SvxCellHorJustify m_eHorJustify;
+ sal_Bool m_bIsAutoIncrement;
+ sal_Bool m_bIsPrimaryKey;
+ sal_Bool m_bIsCurrency;
+ sal_Bool m_bHidden;
+
+ public:
+ OFieldDescription();
+ OFieldDescription( const OFieldDescription& rDescr );
+ OFieldDescription(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xAffectedCol
+ ,sal_Bool _bUseAsDest = sal_False);
+ ~OFieldDescription();
+
+ void SetName(const ::rtl::OUString& _rName);
+ void SetDescription(const ::rtl::OUString& _rDescription);
+ void SetHelpText(const ::rtl::OUString& _sHelptext);
+ void SetDefaultValue(const ::com::sun::star::uno::Any& _rDefaultValue);
+ void SetControlDefault(const ::com::sun::star::uno::Any& _rControlDefault);
+ void SetAutoIncrementValue(const ::rtl::OUString& _sAutoIncValue);
+ void SetType(TOTypeInfoSP _pType);
+ void SetTypeValue(sal_Int32 _nType);
+ void SetTypeName(const ::rtl::OUString& _sTypeName);
+ void SetPrecision(const sal_Int32& _rPrecision);
+ void SetScale(const sal_Int32& _rScale);
+ void SetIsNullable(const sal_Int32& _rIsNullable);
+ void SetFormatKey(const sal_Int32& _rFormatKey);
+ void SetHorJustify(const SvxCellHorJustify& _rHorJustify);
+ void SetAutoIncrement(sal_Bool _bAuto);
+ void SetPrimaryKey(sal_Bool _bPKey);
+ void SetCurrency(sal_Bool _bIsCurrency);
+
+ /** copies the content of the field eescription into the column
+ @param _rxColumn the dest
+ */
+ void copyColumnSettingsTo(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn);
+
+ void FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bForce,sal_Bool _bReset);
+
+ ::rtl::OUString GetName() const;
+ ::rtl::OUString GetDescription() const;
+ ::rtl::OUString GetHelpText() const;
+ ::com::sun::star::uno::Any GetControlDefault() const;
+ ::rtl::OUString GetAutoIncrementValue() const;
+ sal_Int32 GetType() const;
+ ::rtl::OUString GetTypeName() const;
+ sal_Int32 GetPrecision() const;
+ sal_Int32 GetScale() const;
+ sal_Int32 GetIsNullable() const;
+ sal_Int32 GetFormatKey() const;
+ SvxCellHorJustify GetHorJustify() const;
+ TOTypeInfoSP getTypeInfo() const;
+ TOTypeInfoSP getSpecialTypeInfo() const;
+ sal_Bool IsAutoIncrement() const;
+ sal_Bool IsPrimaryKey() const;
+ sal_Bool IsCurrency() const;
+ sal_Bool IsNullable() const;
+ };
+}
+#endif // DBAUI_FIELDDESCRIPTIONS_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/GeneralUndo.hxx b/dbaccess/source/ui/inc/GeneralUndo.hxx
new file mode 100644
index 000000000000..de99bd3706f3
--- /dev/null
+++ b/dbaccess/source/ui/inc/GeneralUndo.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_GENERALUNDO_HXX
+#define DBAUI_GENERALUNDO_HXX
+
+#include <svl/undo.hxx>
+#include "moduledbu.hxx"
+
+namespace dbaui
+{
+ // ================================================================================================
+ // SbaCommentUndoAction - Undo-Basisklasse fuer Aktionen, deren GetComment einen aus einer Sba-Ressource
+ // geladenen String liefert
+
+ class OCommentUndoAction : public SfxUndoAction
+ {
+ OModuleClient m_aModuleClient;
+
+ protected:
+ String m_strComment; // undo, redo comment
+
+ public:
+ TYPEINFO();
+ OCommentUndoAction(sal_uInt16 nCommentID) { m_strComment = String(ModuleRes(nCommentID)); }
+
+ virtual UniString GetComment() const { return m_strComment; }
+ };
+}
+#endif // DBAUI_GENERALUNDO_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/HtmlReader.hxx b/dbaccess/source/ui/inc/HtmlReader.hxx
new file mode 100644
index 000000000000..59c5bfc7f2b5
--- /dev/null
+++ b/dbaccess/source/ui/inc/HtmlReader.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_HTMLREADER_HXX
+#define DBAUI_HTMLREADER_HXX
+
+#include "DExport.hxx"
+#include <svtools/parhtml.hxx>
+#include <editeng/svxenum.hxx>
+#include <tools/stream.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+
+namespace dbaui
+{
+ //===============================================================================================
+ // OHTMLReader
+ //===============================================================================================
+ class OHTMLReader : public HTMLParser, public ODatabaseExport
+ {
+ String m_sCurrent;
+ sal_Int32 m_nTableCount;
+ sal_Int16 m_nWidth;
+ sal_Int16 m_nColumnWidth; // max. Spaltenbreite
+ sal_Bool m_bMetaOptions; // true when we scaned the meta information
+ sal_Bool m_bSDNum;
+
+ protected:
+ virtual void NextToken( int nToken ); // Basisklasse
+ virtual sal_Bool CreateTable(int nToken);
+ virtual TypeSelectionPageFactory
+ getTypeSelectionPageFactory();
+
+ void TableDataOn(SvxCellHorJustify& eVal);
+ void TableFontOn(::com::sun::star::awt::FontDescriptor& _rFont,sal_Int32 &_rTextColor);
+ sal_Int16 GetWidthPixel( const HTMLOption* pOption );
+ void setTextEncoding();
+ void fetchOptions();
+ virtual ~OHTMLReader();
+ public:
+ OHTMLReader(SvStream& rIn,
+ const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList = 0,
+ const OTypeInfoMap* _pInfoMap = 0);
+ // wird f"ur auto. Typ-Erkennung gebraucht
+ OHTMLReader(SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled);
+
+ virtual SvParserState CallParser();// Basisklasse
+ virtual void release();
+ // birgt nur korrekte Daten, wenn der 1. CTOR benutzt wurde
+ };
+
+ SV_DECL_IMPL_REF( OHTMLReader );
+}
+#endif // DBAUI_HTMLREADER_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/IClipBoardTest.hxx b/dbaccess/source/ui/inc/IClipBoardTest.hxx
new file mode 100644
index 000000000000..2f64d667379d
--- /dev/null
+++ b/dbaccess/source/ui/inc/IClipBoardTest.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#define DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+#include <sal/types.h>
+
+namespace dbaui
+{
+ class SAL_NO_VTABLE IClipboardTest
+ {
+ public:
+ virtual sal_Bool isCutAllowed() = 0;
+ virtual sal_Bool isCopyAllowed() = 0;
+ virtual sal_Bool isPasteAllowed() = 0;
+
+ virtual sal_Bool hasChildPathFocus() = 0;
+
+ virtual void copy() = 0;
+ virtual void cut() = 0;
+ virtual void paste() = 0;
+ };
+}
+#endif // DBACCESS_TABLEDESIGN_ICLIPBOARDTEST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/IItemSetHelper.hxx b/dbaccess/source/ui/inc/IItemSetHelper.hxx
new file mode 100644
index 000000000000..8d39925c33e0
--- /dev/null
+++ b/dbaccess/source/ui/inc/IItemSetHelper.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_ITEMSETHELPER_HXX
+#define DBAUI_ITEMSETHELPER_HXX
+
+#include <sal/types.h>
+#include <comphelper/uno3.hxx>
+#include "dsntypes.hxx"
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(sdbc,XDriver)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+class SfxItemSet;
+namespace dbaui
+{
+ class SAL_NO_VTABLE IItemSetHelper
+ {
+ public:
+ virtual const SfxItemSet* getOutputSet() const = 0;
+ virtual SfxItemSet* getWriteOutputSet() = 0;
+ };
+
+ class SAL_NO_VTABLE IDatabaseSettingsDialog
+ {
+ public:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const = 0;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection() = 0;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver() = 0;
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const = 0;
+ virtual void clearPassword() = 0;
+ virtual sal_Bool saveDatasource() = 0;
+ virtual void setTitle(const ::rtl::OUString& _sTitle) = 0;
+
+ /** enables or disables the user's possibility to confirm the settings
+
+ In a wizard, disabling this will usually disable the "Finish" button.
+ In a normal tab dialog, this will usually disable the "OK" button.
+ */
+ virtual void enableConfirmSettings( bool _bEnable ) = 0;
+ };
+}
+#endif // DBAUI_ITEMSETHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/IUpdateHelper.hxx b/dbaccess/source/ui/inc/IUpdateHelper.hxx
new file mode 100644
index 000000000000..b9976efe9935
--- /dev/null
+++ b/dbaccess/source/ui/inc/IUpdateHelper.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_IUPDATEHELPER_HXX
+#define DBAUI_IUPDATEHELPER_HXX
+
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Time.hpp>
+
+namespace dbaui
+{
+ class SAL_NO_VTABLE IUpdateHelper
+ {
+ public:
+ virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue) = 0;
+ virtual void updateDouble(sal_Int32 _nPos,const double& _nValue) = 0;
+ virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue) = 0;
+ virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType) = 0;
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue) = 0;
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue) = 0;
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue) = 0;
+ virtual void moveToInsertRow() = 0;
+ virtual void insertRow() = 0;
+ };
+}
+
+#endif // DBAUI_IUPDATEHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/JAccess.hxx b/dbaccess/source/ui/inc/JAccess.hxx
new file mode 100644
index 000000000000..7ecb0dbf4aa4
--- /dev/null
+++ b/dbaccess/source/ui/inc/JAccess.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_JACCESS_HXX
+#define DBACCESS_JACCESS_HXX
+
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+namespace dbaui
+{
+ class OJoinTableView;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessible
+ > OJoinDesignViewAccess_BASE;
+ /** the class OJoinDesignViewAccess represents the accessible object for join views
+ like the QueryDesign and the RelationDesign
+ */
+ class OJoinDesignViewAccess : public VCLXAccessibleComponent, public OJoinDesignViewAccess_BASE
+ {
+ OJoinTableView* m_pTableView; // the window which I should give accessibility to
+
+ protected:
+ /** isEditable returns the current editable state
+ @return true if the controller is not readonly otherwise false
+ */
+ virtual sal_Bool isEditable() const;
+ public:
+ /** OJoinDesignViewAccess needs a valid view
+ */
+ OJoinDesignViewAccess( OJoinTableView* _pTableView);
+
+ // XInterface
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // XServiceInfo - static methods
+ static ::rtl::OUString getImplementationName_Static(void) throw( com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+
+ OJoinTableView* getTableView() const { return m_pTableView; }
+
+ void notifyAccessibleEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ )
+ {
+ NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
+ }
+
+ void clearTableView();
+ };
+}
+#endif // DBACCESS_JACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx
new file mode 100644
index 000000000000..cc35323db7fd
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinController.hxx
@@ -0,0 +1,178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_JOINCONTROLLER_HXX
+#define DBAUI_JOINCONTROLLER_HXX
+
+#include "singledoccontroller.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "moduledbu.hxx"
+#include "JoinTableView.hxx"
+#include "JoinDesignView.hxx"
+#include "TableConnectionData.hxx"
+#include "TableWindowData.hxx"
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+class VCLXWindow;
+namespace dbaui
+{
+ class OAddTableDlg;
+ class AddTableDialogContext;
+ class OTableConnectionData;
+ class OTableWindowData;
+ class OTableWindow;
+ typedef OSingleDocumentController OJoinController_BASE;
+
+ class OJoinController : public OJoinController_BASE
+ {
+ OModuleClient m_aModuleClient;
+ protected:
+ TTableConnectionData m_vTableConnectionData;
+ TTableWindowData m_vTableData;
+
+ Fraction m_aZoom;
+ ::dbtools::SQLExceptionInfo m_aExceptionInfo;
+
+ OAddTableDlg* m_pAddTableDialog;
+ ::std::auto_ptr< AddTableDialogContext > m_pDialogContext;
+ Point m_aMinimumTableViewSize;
+
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ /** loads the information for the windows.
+ @param i_rViewSettings
+ The properties which comes from the layout information.
+ */
+ void loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings );
+
+ /** loads the information for one window.
+ @param _rTable
+ The properties which comes from the layout information.
+ */
+ void loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings );
+
+ /** saves the TableWindows structure in a sequence of property values
+ @param _rViewProps
+ Contains the new sequence.
+ */
+ void saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const;
+
+ virtual ~OJoinController();
+ public:
+ OJoinController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ // ---------------------------------------------------------------
+ // attribute access
+ inline TTableWindowData* getTableWindowData() { return &m_vTableData; }
+ inline TTableConnectionData* getTableConnectionData() { return &m_vTableConnectionData;}
+ inline OAddTableDlg* getAddTableDialog()const { return m_pAddTableDialog; }
+
+ // ---------------------------------------------------------------
+ // OSingleDocumentController overridables
+ virtual void reconnect( sal_Bool _bUI );
+ virtual void impl_onModifyChanged();
+
+ // ---------------------------------------------------------------
+ // own overridables
+ /** determines whether or not it's allowed for database views to participate in the game
+ */
+ virtual bool allowViews() const = 0;
+
+ /** determines whether or not it's allowed for queries to participate in the game
+ */
+ virtual bool allowQueries() const = 0;
+
+ /** provides access to the OJoinDesignView belonging to the controller, which might
+ or might not be the direct view (getView)
+ */
+ virtual OJoinDesignView* getJoinView();
+
+
+ // ---------------------------------------------------------------
+ /** erase the data in the data vector
+ @param _pData
+ the data whioch should be erased
+ */
+ void removeConnectionData(const TTableConnectionData::value_type& _pData);
+
+ void SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY );
+
+ void SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY);
+
+ // ---------------------------------------------------------------
+ // UNO interface overridables
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+ // ::com::sun::star::frame::XController
+ virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
+
+
+ // ---------------------------------------------------------------
+ // misc
+ /** only defines a method to save a SQLException in d&d methods to show the error at a later state
+ set the internal member m_aExceptionInfo to _rInfo
+ */
+ void setErrorOccurred(const ::dbtools::SQLExceptionInfo& _rInfo)
+ {
+ m_aExceptionInfo = _rInfo;
+ }
+ /**
+ just returns the internal member and clears it
+ */
+ ::dbtools::SQLExceptionInfo clearOccurredError()
+ {
+ ::dbtools::SQLExceptionInfo aInfo = m_aExceptionInfo;
+ m_aExceptionInfo = ::dbtools::SQLExceptionInfo();
+ return aInfo;
+ }
+
+ protected:
+ TTableWindowData::value_type createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName);
+ // ask the user if the design should be saved when it is modified
+ virtual short saveModified() = 0;
+ // called when the orignal state should be reseted (first time load)
+ virtual void reset() = 0;
+ virtual void describeSupportedFeatures();
+
+ AddTableDialogContext& impl_getDialogContext() const;
+ };
+}
+#endif // DBAUI_JOINCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/JoinDesignView.hxx b/dbaccess/source/ui/inc/JoinDesignView.hxx
new file mode 100644
index 000000000000..ce67cc1b8990
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinDesignView.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_JOINDESIGNVIEW_HXX
+#define DBAUI_JOINDESIGNVIEW_HXX
+
+#include "dataview.hxx"
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include <tools/string.hxx>
+#include "QEnumTypes.hxx"
+
+#include <memory>
+
+namespace dbaui
+{
+ class OTableConnection;
+ class OConnectionLineData;
+ class OJoinController;
+ class OScrollWindowHelper;
+ class OJoinTableView;
+ class OTableWindow;
+
+ class OJoinDesignView : public ODataView
+ {
+ protected:
+ OScrollWindowHelper* m_pScrollWindow; // contains only the scrollbars
+ OJoinTableView* m_pTableView; // presents the upper window
+ OJoinController& m_rController;
+
+ public:
+ OJoinDesignView(Window* pParent,
+ OJoinController& _rController,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~OJoinDesignView();
+
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly);
+ // set the statement for representation
+ /// late construction
+ virtual void Construct();
+ virtual void initialize();
+ virtual void KeyInput( const KeyEvent& rEvt );
+
+ virtual void SaveTabWinUIConfig(OTableWindow* pWin);
+ OJoinController& getController() const { return m_rController; }
+ // called when fields are deleted
+
+ OJoinTableView* getTableView() const { return m_pTableView; }
+ OScrollWindowHelper* getScrollHelper() const { return m_pScrollWindow; }
+ protected:
+ // return the Rectangle where I can paint myself
+ virtual void resizeDocumentView(Rectangle& rRect);
+ DECL_LINK( SplitHdl, void* );
+ };
+}
+#endif // DBAUI_JOINDESIGNVIEW_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/JoinExchange.hxx b/dbaccess/source/ui/inc/JoinExchange.hxx
new file mode 100644
index 000000000000..44f19b89c528
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinExchange.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_JOINEXCHANGE_HXX
+#define DBAUI_JOINEXCHANGE_HXX
+
+#include "dbexchange.hxx"
+#include "TableWindowListBox.hxx"
+
+#include <svtools/transfer.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace dbaui
+{
+ //==================================================================
+ // OJoinExchObj :
+ // Zusaetzliche Daten fuer das Erzeugen von Joins in der JoinShell
+ //==================================================================
+
+ typedef ::cppu::ImplHelper1< ::com::sun::star::lang::XUnoTunnel > OJoinExchObj_Base;
+ class OJoinExchObj
+ :public TransferableHelper
+ ,public OJoinExchObj_Base
+ {
+ static String m_sJoinFormat;
+ sal_Bool m_bFirstEntry;
+
+ protected:
+ OJoinExchangeData m_jxdSourceDescription;
+ IDragTransferableListener* m_pDragListener;
+
+ virtual ~OJoinExchObj();
+ public:
+ OJoinExchObj(const OJoinExchangeData& jxdSource,sal_Bool _bFirstEntry=sal_False);
+
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw();
+ virtual void SAL_CALL release( ) throw();
+
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& _rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+ void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, IDragTransferableListener* _pListener );
+
+ static OJoinExchangeData GetSourceDescription(const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxObject);
+ static sal_Bool isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID=SOT_FORMATSTR_ID_SBA_JOIN);
+
+ protected:
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void DragFinished( sal_Int8 nDropAction );
+
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ private:
+ using TransferableHelper::StartDrag;
+ };
+}
+#endif // DBAUI_JOINEXCHANGE_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/JoinTableView.hxx b/dbaccess/source/ui/inc/JoinTableView.hxx
new file mode 100644
index 000000000000..48073242a301
--- /dev/null
+++ b/dbaccess/source/ui/inc/JoinTableView.hxx
@@ -0,0 +1,326 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_JOINTABLEVIEW_HXX
+#define DBAUI_JOINTABLEVIEW_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/scrbar.hxx>
+#include <tools/rtti.hxx>
+#include <svtools/transfer.hxx>
+
+#include <comphelper/stl_types.hxx>
+#include "callbacks.hxx"
+#include "TableConnectionData.hxx"
+#include "TableWindowData.hxx"
+#include <memory>
+#include <vector>
+
+struct AcceptDropEvent;
+struct ExecuteDropEvent;
+class SfxUndoAction;
+namespace dbaui
+{
+ class OTableConnection;
+ class OTableWindow;
+ struct OJoinExchangeData;
+ class OJoinDesignView;
+ class OTableWindowData;
+ class OJoinDesignViewAccess;
+
+ // this class conatins only the scrollbars to avoid that the tablewindows clip the scrollbars
+ class OJoinTableView;
+ class OScrollWindowHelper : public Window
+ {
+ ScrollBar m_aHScrollBar;
+ ScrollBar m_aVScrollBar;
+ Window* m_pCornerWindow;
+ OJoinTableView* m_pTableView;
+
+ protected:
+ virtual void Resize();
+ public:
+ OScrollWindowHelper( Window* pParent);
+ ~OScrollWindowHelper();
+
+ void setTableView(OJoinTableView* _pTableView);
+
+ void resetRange(const Point& _aSize);
+
+ // own methods
+ ScrollBar* GetHScrollBar() { return &m_aHScrollBar; }
+ ScrollBar* GetVScrollBar() { return &m_aVScrollBar; }
+ };
+
+
+ class OJoinTableView : public Window
+ ,public IDragTransferableListener
+ ,public DropTargetHelper
+ {
+ friend class OJoinMoveTabWinUndoAct;
+ public:
+ DECLARE_STL_USTRINGACCESS_MAP(OTableWindow*,OTableWindowMap);
+ private:
+ OTableWindowMap m_aTableMap;
+ ::std::vector<OTableConnection*> m_vTableConnection;
+
+ Timer m_aDragScrollTimer;
+ Rectangle m_aDragRect;
+ Rectangle m_aSizingRect;
+ Point m_aDragOffset;
+ Point m_aScrollOffset;
+ Point m_ptPrevDraggingPos;
+ Size m_aOutputSize;
+
+
+ OTableWindow* m_pDragWin;
+ OTableWindow* m_pSizingWin;
+ OTableConnection* m_pSelectedConn;
+
+
+ sal_Bool m_bTrackingInitiallyMoved;
+
+ DECL_LINK(OnDragScrollTimer, void*);
+
+ protected:
+ OTableWindow* m_pLastFocusTabWin;
+ OJoinDesignView* m_pView;
+ OJoinDesignViewAccess* m_pAccessible;
+
+ public:
+ OJoinTableView( Window* pParent, OJoinDesignView* pView );
+ virtual ~OJoinTableView();
+
+ // window override
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual void KeyInput( const KeyEvent& rEvt );
+ // Accessibility
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ // own methods
+ ScrollBar* GetHScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetHScrollBar(); }
+ ScrollBar* GetVScrollBar() { return static_cast<OScrollWindowHelper*>(GetParent())->GetVScrollBar(); }
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ void DrawConnections( const Rectangle& rRect );
+ void InvalidateConnections();
+
+ void BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos );
+ void BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer );
+
+ void NotifyTitleClicked( OTableWindow* pTabWin, const Point rMousePos );
+
+ virtual void AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, sal_Bool bNewTable = sal_False);
+ virtual void RemoveTabWin( OTableWindow* pTabWin );
+
+ // alle TabWins verstecken (NICHT loeschen, sie werden in eine Undo-Action gepackt)
+ virtual void HideTabWins();
+
+ virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest) = 0;
+
+ /** RemoveConnection allows to remove connections from join table view, it implies that the same as addConnection
+
+ @param _pConnection
+ the connection which should be removed
+ @param _bDelete
+ when truie then the connection will be deleted
+
+ @return an iterator to next valid connection, so it can be used in any loop
+ */
+ virtual bool RemoveConnection(OTableConnection* _pConnection,sal_Bool _bDelete);
+
+ /** allows to add new connections to join table view, it implies an invalidation of the features
+ ID_BROWSER_ADDTABLE and SID_RELATION_ADD_RELATION also the modified flag will be set to true
+ @param _pConnection
+ the connection which should be added
+ @param _bAddData
+ <TRUE/> when the data should also be appended
+ */
+ void addConnection(OTableConnection* _pConnection,sal_Bool _bAddData = sal_True);
+
+ sal_Bool ScrollPane( long nDelta, sal_Bool bHoriz, sal_Bool bPaintScrollBars );
+ sal_uLong GetTabWinCount();
+ Point GetScrollOffset() const { return m_aScrollOffset; }
+
+ OJoinDesignView* getDesignView() const { return m_pView; }
+ OTableWindow* GetTabWindow( const String& rName );
+
+ OTableConnection* GetSelectedConn() { return m_pSelectedConn; }
+ void DeselectConn(OTableConnection* pConn); // NULL ist ausdruecklich zugelassen, dann passiert nichts
+ void SelectConn(OTableConnection* pConn);
+
+ OTableWindowMap* GetTabWinMap() { return &m_aTableMap; }
+ const OTableWindowMap* GetTabWinMap() const { return &m_aTableMap; }
+
+ /** gives a read only access to the connection vector
+ */
+ const ::std::vector<OTableConnection*>* getTableConnections() const { return &m_vTableConnection; }
+
+
+ sal_Bool ExistsAConn(const OTableWindow* pFromWin) const;
+
+ /** getTableConnections searchs for all connections of a table
+ @param _pFromWin the table for which connections should be found
+
+ @return an iterator which can be used to travel all connections of the table
+ */
+ ::std::vector<OTableConnection*>::const_iterator getTableConnections(const OTableWindow* _pFromWin) const;
+
+ /** getConnectionCount returns how many connection belongs to single table
+ @param _pFromWin the table for which connections should be found
+
+ @return the count of connections wich belongs to this table
+ */
+ sal_Int32 getConnectionCount(const OTableWindow* _pFromWin) const;
+
+ OTableConnection* GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin = false,const OTableConnection* _rpFirstAfter = NULL) const;
+
+ // clears the window map and connection vector without destroying it
+ // that means teh data of the windows and connection will be untouched
+ void clearLayoutInformation();
+
+ // set the focus to that tab win which most recently had it (or to the first available one)
+ void GrabTabWinFocus();
+
+ // ReSync ist dazu gedacht, aus dem Dokument alle WinData und ConnData zu holen und entsprechend Wins und Conns anzulegen
+ virtual void ReSync() { }
+ // ClearAll implementiert ein hartes Loeschen, es werden alle Conns und alle Wins aus ihren jeweiligen Listen geloescht
+ // sowie die entsprechenden Datas aus dem Dokument ausgetragen
+ virtual void ClearAll();
+
+ // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
+ virtual sal_Bool IsAddAllowed();
+ virtual long PreNotify(NotifyEvent& rNEvt);
+
+ // DnD stuff
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ /**
+ can be used in derevied classes to make some special ui handling
+ after d&d
+ */
+ virtual void lookForUiActivities();
+
+ // wird nach Verschieben/Groessenaenderung der TabWins aufgerufen (die Standardimplementation reicht die neuen Daten einfach
+ // an die Daten des Wins weiter)
+ virtual void TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition);
+ // die Position ist "virtuell" : der Container hat sozusagen eine virtuelle Flaeche, von der immer nur ein bestimmter Bereich
+ // - der mittels der Scrollbar veraendert werden kann - zu sehen ist. Insbesondere hat ptOldPosition immer positive Koordinaten,
+ // auch wenn er einen Punkt oberhalb des aktuell sichtbaren Bereichs bezeichnet, dessen physische Ordinate eigentlich
+ // negativ ist.
+ virtual void TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize);
+
+ void modified();
+
+ /** returns if teh given window is visible.
+ @param _rPoint
+ The Point to check
+ @param _rSize
+ The Size to be check as well
+ @return
+ <TRUE/> if the area is visible otherwise <FALSE/>
+
+ */
+ sal_Bool isMovementAllowed(const Point& _rPoint,const Size& _rSize);
+
+ Size getRealOutputSize() const { return m_aOutputSize; }
+
+
+
+ virtual void EnsureVisible(const OTableWindow* _pWin);
+ virtual void EnsureVisible(const Point& _rPoint,const Size& _rSize);
+
+ TTableWindowData::value_type createTableWindowData(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName);
+
+ protected:
+ virtual void MouseButtonUp( const MouseEvent& rEvt );
+ virtual void MouseButtonDown( const MouseEvent& rEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void ConnDoubleClicked( OTableConnection* pConnection );
+ virtual void SetDefaultTabWinPosSize( OTableWindow* pTabWin );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual void Resize();
+
+ virtual void dragFinished( );
+ // hier ist die Position (die sich waehrend des Sizings aendern kann) physisch, da waehrend des Sizens nicht gescrollt wird
+ virtual void Command(const CommandEvent& rEvt);
+
+ virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName);
+
+ /** factory method to create table windows
+ @param _pData
+ The data corresponding to the window.
+ @return
+ The new TableWindow
+ */
+ virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData) = 0;
+
+ /** determines whether the classes Init method should accept a query name, or only table names
+ */
+ virtual bool allowQueries() const;
+
+ /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no
+ exception was thrown. Expected to throw.
+ */
+ virtual void onNoColumns_throw();
+
+ virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
+
+ private:
+ void InitColors();
+ sal_Bool ScrollWhileDragging();
+
+ /** executePopup opens the context menu to delate a connection
+ @param _aPos the position where the popup menu should appear
+ @param _pSelConnection the connection which should be deleted
+ */
+ void executePopup(const Point& _aPos,OTableConnection* _pSelConnection);
+
+ /** invalidateAndModify invalidates this window without children and
+ set the controller modified
+ @param _pAction a possible undo action to add at the controller
+ */
+ void invalidateAndModify(SfxUndoAction *_pAction=NULL);
+
+ private:
+ using Window::Scroll;
+ };
+}
+#endif // DBAUI_JOINTABLEVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QEnumTypes.hxx b/dbaccess/source/ui/inc/QEnumTypes.hxx
new file mode 100644
index 000000000000..13ea803c3866
--- /dev/null
+++ b/dbaccess/source/ui/inc/QEnumTypes.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_ENUMTYPES_HXX
+#define DBAUI_ENUMTYPES_HXX
+
+namespace dbaui
+{
+ enum EOrderDir
+ {
+ ORDER_NONE=0,
+ ORDER_ASC,
+ ORDER_DESC
+ };
+
+ enum EFunctionType
+ {
+ FKT_NONE =0x00000000,
+ FKT_OTHER =0x00000001,
+ FKT_AGGREGATE =0x00000002,
+ FKT_CONDITION =0x00000004,
+ FKT_NUMERIC =0x00000008
+ // wenn dieser Fkt.Typ gesetzt handelt es sich um EXISTS oder UNIQUE, der FieldName enthält das gesamte Statement
+ };
+
+ enum EConnectionSide
+ {
+ JTCS_FROM=0,
+ JTCS_TO
+ };
+
+ enum ETableFieldType
+ {
+ TAB_NORMAL_FIELD=0,
+ TAB_PRIMARY_FIELD
+ };
+
+ enum EJoinType
+ {
+ FULL_JOIN=0,
+ LEFT_JOIN,
+ RIGHT_JOIN,
+ UNION_JOIN,
+ CROSS_JOIN,
+ INNER_JOIN
+ };
+
+ //==================================================================
+ enum EControlType
+ {
+ tpDefault = 0,
+ tpRequired,
+ tpTextLen,
+ tpNumType,
+ tpLength,
+ tpScale,
+ tpFormat,
+ tpAutoIncrement,
+ tpBoolDefault,
+ tpColumnName,
+ tpType,
+ tpAutoIncrementValue
+ };
+}
+#endif // DBAUI_ENUMTYPES_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx
new file mode 100644
index 000000000000..4fa761fa3b64
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryDesignView.hxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYDESIGNVIEW_HXX
+#define DBAUI_QUERYDESIGNVIEW_HXX
+
+#include "queryview.hxx"
+#include <vcl/split.hxx>
+#include <tools/string.hxx>
+#include "QEnumTypes.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "querycontroller.hxx"
+#include "ConnectionLineData.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+}
+
+class ComboBox;
+namespace dbaui
+{
+ enum SqlParseError
+ {
+ eIllegalJoin,
+ eStatementTooLong,
+ eNoConnection,
+ eNoSelectStatement,
+ eStatementTooComplex,
+ eColumnInLikeNotFound,
+ eNoColumnInLike,
+ eColumnNotFound,
+ eNativeMode,
+ eTooManyTables,
+ eTooManyConditions,
+ eTooManyColumns,
+ eIllegalJoinCondition,
+ eOk
+ };
+
+ class OQueryViewSwitch;
+ class OAddTableDlg;
+ class OQueryTableWindow;
+ class OSelectionBrowseBox;
+ class OTableConnection;
+ class OQueryTableConnectionData;
+ class OQueryContainerWindow;
+
+ class OQueryDesignView : public OQueryView
+ {
+ enum ChildFocusState
+ {
+ SELECTION,
+ TABLEVIEW,
+ NONE
+ };
+
+ Splitter m_aSplitter;
+
+ ::com::sun::star::lang::Locale m_aLocale;
+ ::rtl::OUString m_sDecimalSep;
+
+ OSelectionBrowseBox* m_pSelectionBox; // presents the lower window
+ ChildFocusState m_eChildFocus;
+ sal_Bool m_bInKeyEvent;
+ sal_Bool m_bInSplitHandler;
+
+ public:
+ OQueryDesignView(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~OQueryDesignView();
+
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+ // clears the whole query
+ virtual void clear();
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly);
+ // check if the statement is correct when not returning false
+ virtual sal_Bool checkStatement();
+ // set the statement for representation
+ virtual void setStatement(const ::rtl::OUString& _rsStatement);
+ // returns the current sql statement
+ virtual ::rtl::OUString getStatement();
+ /// late construction
+ virtual void Construct();
+ virtual void initialize();
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+
+ sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
+ void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
+ void setNoneVisbleRow(sal_Int32 _nRows);
+
+ ::com::sun::star::lang::Locale getLocale() const { return m_aLocale;}
+ ::rtl::OUString getDecimalSeparator() const { return m_sDecimalSep;}
+
+ SqlParseError InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis=sal_True, sal_Bool bActivate = sal_True);
+ bool HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
+ // save the position of the table window and the pos of the splitters
+ // called when fields are deleted
+ void DeleteFields( const ::rtl::OUString& rAliasName );
+ // called when a table from tabeview was deleted
+ void TableDeleted(const ::rtl::OUString& rAliasName);
+
+ sal_Int32 getColWidth( sal_uInt16 _nColPos) const;
+ void fillValidFields(const ::rtl::OUString& strTableName, ComboBox* pFieldList);
+
+ void SaveUIConfig();
+ void stopTimer();
+ void startTimer();
+ void reset();
+
+ /** initializes the view from the current parser / parse iterator of the controller
+
+ @param _pErrorInfo
+ When not <NULL/>, the instance pointed to by this parameter takes the error
+ which happened during the initialization.
+ If it is not <NULL/>, then any such error will be displayed, using the controller's
+ showError method.
+
+ @return <TRUE/> if and only if the initialization was successful
+ */
+ bool initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+
+ void initByFieldDescriptions(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rFieldDescriptions
+ );
+
+ ::connectivity::OSQLParseNode* getPredicateTreeFromEntry( OTableFieldDescRef pEntry,
+ const String& _sCriteria,
+ ::rtl::OUString& _rsErrorMessage,
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn) const;
+
+ void fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode
+ ,const ::rtl::OUString& sFunctionTerm
+ ,OTableFieldDescRef& aInfo);
+ protected:
+ // return the Rectangle where I can paint myself
+ virtual void resizeDocumentView(Rectangle& rRect);
+ DECL_LINK( SplitHdl, void* );
+
+ private:
+ using OQueryView::SaveTabWinUIConfig;
+ };
+}
+#endif // DBAUI_QUERYDESIGNVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QueryTableView.hxx b/dbaccess/source/ui/inc/QueryTableView.hxx
new file mode 100644
index 000000000000..8089b1a2744b
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryTableView.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYTABLEVIEW_HXX
+#define DBAUI_QUERYTABLEVIEW_HXX
+
+#include "JoinTableView.hxx"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "querycontroller.hxx"
+
+namespace dbaui
+{
+
+ struct TabWinsChangeNotification
+ {
+ enum ACTION_TYPE { AT_ADDED_WIN, AT_REMOVED_WIN };
+ ACTION_TYPE atActionPerformed;
+ String strAffectedTable;
+
+ TabWinsChangeNotification(ACTION_TYPE at, const String& str) : atActionPerformed(at), strAffectedTable(str) { }
+ };
+
+ //========================================================================
+ class OQueryTabWinUndoAct;
+ class OQueryTabConnUndoAction;
+ class OQueryTableConnection;
+ class OQueryTableWindow;
+ class OQueryDesignView;
+ class OQueryTableView : public OJoinTableView
+ {
+ Link m_lnkTabWinsChangeHandler;
+
+ protected:
+ virtual void ConnDoubleClicked(OTableConnection* pConnection);
+ virtual void KeyInput(const KeyEvent& rEvt);
+
+ virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData);
+
+ /** called when init fails at the tablewindowdata because the m_xTable object could not provide columns, but no
+ exception was thrown. Expected to throw.
+ */
+ virtual void onNoColumns_throw();
+
+ virtual bool supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const;
+ public:
+ OQueryTableView(Window* pParent,OQueryDesignView* pView);
+ virtual ~OQueryTableView();
+
+ // Basisklasse ueberschrieben : Fenster kreieren und loeschen
+ // (eigentlich nicht wirklich LOESCHEN, es geht in die Verantwortung einer UNDO-Action ueber)
+ virtual void AddTabWin( const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable = sal_False );
+ virtual void RemoveTabWin(OTableWindow* pTabWin);
+
+ // und ein AddTabWin, das einen Alias vorgibt
+ void AddTabWin(const ::rtl::OUString& strDatabase, const ::rtl::OUString& strTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable = sal_False);
+ // TabWin suchen
+ OQueryTableWindow* FindTable(const String& rAliasName);
+ sal_Bool FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt);
+
+ // Basisklasse ueberschrieben : Connections kreieren und loeschen
+ virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest);
+
+ virtual bool RemoveConnection( OTableConnection* _pConn ,sal_Bool _bDelete);
+
+ // Transfer von Connections von/zu einer UndoAction
+ void GetConnection(OQueryTableConnection* pConn);
+ // Einfuegen einer Connection in meine Struktur
+ void DropConnection(OQueryTableConnection* pConn);
+ // Entfernen einer Connection aus meiner Struktur
+
+ // das resultiert effektiv in einem voelligen Leeren des Abfrageentwurfs, da alle Fenster versteckt werden, und dabei
+ // natuerlich alle Connections an diesen Fenstern und alle Abfrage-Spalten, die auf diesen Tabellen basierten.
+
+ // TabWin anzeigen oder verstecken (NICHT kreieren oder loeschen)
+ sal_Bool ShowTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend);
+ void HideTabWin(OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction);
+
+ // Sichbarkeit eines TabWins sicherstellen (+ Invalidieren der Connections)
+ virtual void EnsureVisible(const OTableWindow* _pWin);
+
+ // wieviel Tabellen mit einem bestimmten Namen habe ich schon ?
+ sal_Int32 CountTableAlias(const String& rName, sal_Int32& rMax);
+
+ // ein Feld einfuegen (wird einfach an das Elter weitergereicht
+ void InsertField(const OTableFieldDescRef& rInfo);
+
+ // alles (TabWins, Connections) neu aufbauen (PRECONDITION : vorher wurde ClearAll gerufen)
+ virtual void ReSync();
+ // alles (TabWins, Connections) loeschen, und zwar hart, es erfolgen also keinerlei Notifications
+ virtual void ClearAll();
+
+ // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
+ //virtual sal_Bool IsAddAllowed();
+
+ // eine neu Connection bekanntgeben und einfuegen lassen, wenn nicht schon existent
+ void NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction = sal_True);
+
+ Link SetTabWinsChangeHandler(const Link& lnk) { Link lnkRet = m_lnkTabWinsChangeHandler; m_lnkTabWinsChangeHandler = lnk; return lnkRet; }
+ // der Handler bekommt einen Zeiger auf eine TabWinsChangeNotification-Struktur
+
+ sal_Bool ExistsAVisitedConn(const OQueryTableWindow* pFrom) const;
+
+ virtual OTableWindowData* CreateImpl(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName);
+
+ /** createNewConnection opens the join dialog and allows to create a new join connection
+ */
+ void createNewConnection();
+
+ private:
+ using OJoinTableView::EnsureVisible;
+ };
+}
+#endif // DBAUI_QUERYTABLEVIEW_HXX
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QueryTextView.hxx b/dbaccess/source/ui/inc/QueryTextView.hxx
new file mode 100644
index 000000000000..d541e972169c
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryTextView.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYVIEW_TEXT_HXX
+#define DBAUI_QUERYVIEW_TEXT_HXX
+
+#include "queryview.hxx"
+#include "querycontainerwindow.hxx"
+
+class Splitter;
+namespace dbaui
+{
+ class OSqlEdit;
+ class OQueryTextView : public Window
+ {
+ friend class OQueryViewSwitch;
+ OSqlEdit* m_pEdit;
+ public:
+ OQueryTextView( OQueryContainerWindow* pParent );
+ virtual ~OQueryTextView();
+
+ virtual void GetFocus();
+
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+ // clears the whole query
+ virtual void clear();
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly);
+ // check if the statement is correct when not returning false
+ virtual sal_Bool checkStatement();
+ // set the statement for representation
+ virtual void setStatement(const ::rtl::OUString& _rsStatement);
+ virtual ::rtl::OUString getStatement();
+ // allow access to our edit
+ OSqlEdit* getSqlEdit() const { return m_pEdit; }
+
+ OQueryContainerWindow* getContainerWindow() { return static_cast< OQueryContainerWindow* >( GetParent() ); }
+ protected:
+ virtual void Resize();
+ };
+}
+#endif // DBAUI_QUERYVIEW_TEXT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QueryViewSwitch.hxx b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
new file mode 100644
index 000000000000..9ddc6ce20108
--- /dev/null
+++ b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYVIEWSWITCH_HXX
+#define DBAUI_QUERYVIEWSWITCH_HXX
+
+#include "queryview.hxx"
+
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
+
+namespace dbaui
+{
+ class OQueryDesignView;
+ class OQueryTextView;
+ class OAddTableDlg;
+ class OQueryContainerWindow;
+ class OQueryViewSwitch
+ {
+ OQueryDesignView* m_pDesignView;
+ OQueryTextView* m_pTextView;
+ sal_Bool m_bAddTableDialogWasVisible; // true if so
+ public:
+ OQueryViewSwitch(OQueryContainerWindow* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~OQueryViewSwitch();
+
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+ // clears the whole query
+ virtual void clear();
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly);
+ // check if the statement is correct when not returning false
+ virtual sal_Bool checkStatement();
+ // set the statement for representation
+ virtual void setStatement(const ::rtl::OUString& _rsStatement);
+ // returns the current sql statement
+ virtual ::rtl::OUString getStatement();
+ /// late construction
+ virtual void Construct();
+ virtual void initialize();
+ /** show the text or the design view
+ @return
+ <TRUE/> if and only if the view could be successfully, switched, <FALSE/> otherwise
+ (In the latter case, the controller will issue another switchView call to restore the
+ old state)
+ */
+ bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void forceInitialView();
+ sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
+ void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
+ void setNoneVisbleRow(sal_Int32 _nRows);
+ void SaveUIConfig();
+ bool reset( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void GrabFocus();
+
+ // returs the add table dialog from the design view
+ OAddTableDlg* getAddTableDialog();
+
+ OQueryDesignView* getDesignView() const { return m_pDesignView; }
+ OQueryContainerWindow* getContainer() const;
+
+ void SetPosSizePixel( Point _rPt,Size _rSize);
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ protected:
+ // return the Rectangle where I can paint myself
+ virtual void resizeDocumentView(Rectangle& rRect);
+
+ private:
+ void impl_forceSQLView();
+ bool impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess );
+ };
+}
+#endif // DBAUI_QUERYVIEWSWITCH_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RTableConnectionData.hxx b/dbaccess/source/ui/inc/RTableConnectionData.hxx
new file mode 100644
index 000000000000..096f97ba4675
--- /dev/null
+++ b/dbaccess/source/ui/inc/RTableConnectionData.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
+#define DBAUI_RTABLECONNECTIONDATA_HXX
+
+#include "TableConnectionData.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "QEnumTypes.hxx"
+
+namespace dbaui
+{
+ const sal_uInt16 CARDINAL_UNDEFINED = 0x0000;
+ const sal_uInt16 CARDINAL_ONE_MANY = 0x0001;
+ const sal_uInt16 CARDINAL_MANY_ONE = 0x0002;
+ const sal_uInt16 CARDINAL_ONE_ONE = 0x0004;
+
+ class OConnectionLineData;
+ //==================================================================
+ class ORelationTableConnectionData : public OTableConnectionData
+ {
+ friend bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs);
+ friend bool operator!=(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs) { return !(lhs == rhs); }
+
+ ::osl::Mutex m_aMutex;
+
+ // @see com.sun.star.sdbc.KeyRule
+ sal_Int32 m_nUpdateRules;
+ sal_Int32 m_nDeleteRules;
+ sal_Int32 m_nCardinality;
+
+ sal_Bool checkPrimaryKey(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const;
+ sal_Bool IsSourcePrimKey() const { return checkPrimaryKey(getReferencingTable()->getTable(),JTCS_FROM); }
+ sal_Bool IsDestPrimKey() const { return checkPrimaryKey(getReferencedTable()->getTable(),JTCS_TO); }
+
+ protected:
+ virtual OConnectionLineDataRef CreateLineDataObj();
+ virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
+
+ ORelationTableConnectionData& operator=( const ORelationTableConnectionData& rConnData );
+ public:
+ ORelationTableConnectionData();
+ ORelationTableConnectionData( const ORelationTableConnectionData& rConnData );
+ ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
+ const TTableWindowData::value_type& _pReferencedTable,
+ const ::rtl::OUString& rConnName = ::rtl::OUString() );
+ virtual ~ORelationTableConnectionData();
+
+ virtual void CopyFrom(const OTableConnectionData& rSource);
+ virtual OTableConnectionData* NewInstance() const { return new ORelationTableConnectionData(); }
+
+ /** Update create a new relation
+
+ @return true if successful
+ */
+ virtual sal_Bool Update();
+
+
+ void SetCardinality();
+ inline void SetUpdateRules( sal_Int32 nAttr ){ m_nUpdateRules = nAttr; }
+ inline void SetDeleteRules( sal_Int32 nAttr ){ m_nDeleteRules = nAttr; }
+
+ inline sal_Int32 GetUpdateRules() const { return m_nUpdateRules; }
+ inline sal_Int32 GetDeleteRules() const { return m_nDeleteRules; }
+ inline sal_Int32 GetCardinality() const { return m_nCardinality; }
+
+ sal_Bool IsConnectionPossible();
+ void ChangeOrientation();
+ sal_Bool DropRelation();
+ };
+}
+
+#endif // DBAUI_RTABLECONNECTIONDATA_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RefFunctor.hxx b/dbaccess/source/ui/inc/RefFunctor.hxx
new file mode 100644
index 000000000000..41d48ca7b094
--- /dev/null
+++ b/dbaccess/source/ui/inc/RefFunctor.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_REFFUNCTOR_HXX
+#define DBAUI_REFFUNCTOR_HXX
+
+#include <rtl/ref.hxx>
+#ifndef INCLUDED_FUNCTIONAL
+#define INCLUDED_FUNCTIONAL
+#include <functional>
+#endif // INCLUDED_FUNCTIONAL
+
+namespace dbaui
+{
+ template <class T> class OUnaryRefFunctor : public ::std::unary_function< ::rtl::Reference<T> ,void>
+ {
+ ::std::mem_fun_t<bool,T> m_aFunction;
+ public:
+ OUnaryRefFunctor(const ::std::mem_fun_t<bool,T>& _aFunc) : m_aFunction(_aFunc)
+ {}
+ inline void operator()(const ::rtl::Reference<T>& _aType) const
+ {
+ m_aFunction(_aType.get());
+ }
+ };
+// -----------------------------------------------------------------------------
+} // namespace dbaui
+// -----------------------------------------------------------------------------
+#endif //DBAUI_REFFUNCTOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelControliFace.hxx b/dbaccess/source/ui/inc/RelControliFace.hxx
new file mode 100644
index 000000000000..ab0366263e50
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelControliFace.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELCONTROLIFACE_HXX
+#define DBAUI_RELCONTROLIFACE_HXX
+
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include "TableConnectionData.hxx"
+
+namespace dbaui
+{
+ class IRelationControlInterface
+ {
+ public:
+ virtual ~IRelationControlInterface(){}
+
+ /** getConnectionData returns the current connection data
+ @return the current connectiondata
+ */
+ virtual TTableConnectionData::value_type getConnectionData() const = 0;
+
+ /** setValid set the valid inside, can be used for OK buttons
+ @param _bValid true when the using control allows an update
+ */
+ virtual void setValid(sal_Bool _bValid) = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() = 0;
+
+ /** notifyConnectionChange is callback which is called when the table selection has changed and a new connection exists
+ @param _pConnectionData the connection which exists between the new tables
+ */
+ virtual void notifyConnectionChange() = 0;
+ };
+}
+#endif // DBAUI_RELCONTROLIFACE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelationControl.hrc b/dbaccess/source/ui/inc/RelationControl.hrc
new file mode 100644
index 000000000000..6f0c811db3da
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationControl.hrc
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+#define DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+
+
+
+#endif // DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+
diff --git a/dbaccess/source/ui/inc/RelationControl.hxx b/dbaccess/source/ui/inc/RelationControl.hxx
new file mode 100644
index 000000000000..62b812f4f98f
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationControl.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELATIONCONTROL_HXX
+#define DBAUI_RELATIONCONTROL_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include "JoinTableView.hxx"
+
+namespace dbaui
+{
+ //========================================================================
+ class OTableListBoxControl;
+ class OTableConnectionData;
+ class ORelationTableConnectionData;
+ class IRelationControlInterface;
+ class ORelationControl;
+
+ class OTableListBoxControl : public Window
+ {
+ FixedLine m_aFL_InvolvedTables;
+ ListBox m_lmbLeftTable,
+ m_lmbRightTable;
+ FixedLine m_aFL_InvolvedFields;
+
+ ORelationControl* m_pRC_Tables;
+ const OJoinTableView::OTableWindowMap* m_pTableMap;
+ IRelationControlInterface* m_pParentDialog;
+ String m_strCurrentLeft;
+ String m_strCurrentRight;
+ private:
+ DECL_LINK( OnTableChanged, ListBox* );
+ public:
+ OTableListBoxControl(Window* _pParent,
+ const ResId& _rResId,
+ const OJoinTableView::OTableWindowMap* _pTableMap,
+ IRelationControlInterface* _pParentDialog);
+ virtual ~OTableListBoxControl();
+
+ /** fillListBoxes fills the list boxes with the table windows
+ */
+ void fillListBoxes();
+
+ /** fillAndDisable fill the listboxes only with one entry and then disable them
+ @param _pConnectionData
+ contains the data which should be filled into the listboxes
+ */
+ void fillAndDisable(const TTableConnectionData::value_type& _pConnectionData);
+
+ /** enables the relation control
+ *
+ * \param _bEnable when sal_True enables it, otherwise disable it.
+ */
+ void enableRelation(bool _bEnable);
+
+ /** NotifyCellChange notifies the browse control that the conenction data has changed
+ */
+ void NotifyCellChange();
+
+ /** Init is a call through to the control inside this one
+ @param _pConnData
+ the connection data which is used to init the control
+ */
+ void Init(const TTableConnectionData::value_type& _pConnData);
+ void lateUIInit(Window* _pTableSeparator = NULL);
+ void lateInit();
+
+ sal_Bool SaveModified();
+
+ TTableWindowData::value_type getReferencingTable() const;
+
+ /** getContainer returns the container interface
+ @return the interface of the container
+ */
+ IRelationControlInterface* getContainer() const { return m_pParentDialog; }
+ };
+}
+#endif // DBAUI_RELATIONCONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelationController.hxx b/dbaccess/source/ui/inc/RelationController.hxx
new file mode 100644
index 000000000000..38253627fcc5
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationController.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELATIONCONTROLLER_HXX
+#define DBAUI_RELATIONCONTROLLER_HXX
+
+#include "JoinController.hxx"
+#include "RelationDesignView.hxx"
+
+class VCLXWindow;
+class WaitObject;
+namespace dbaui
+{
+ class OTableConnectionData;
+ class OTableWindowData;
+ class OAddTableDlg;
+ class OTableFieldDesc;
+ class OTableWindow;
+ class ORelationController : public OJoinController
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xTables;
+ ::std::auto_ptr<WaitObject> m_pWaitObject;
+ sal_uLong m_nThreadEvent;
+ sal_Bool m_bRelationsPossible;
+ protected:
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ ORelationDesignView* getRelationView() { return static_cast<ORelationDesignView*>( getView() ); }
+ void loadData();
+ TTableWindowData::value_type existsTable(const ::rtl::OUString& _rComposedTableName,sal_Bool _bCase) const;
+
+ // load the window positions out of the datasource
+ void loadLayoutInformation();
+ void loadTableData(const ::com::sun::star::uno::Any& _aTable);
+ public:
+ ORelationController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ ~ORelationController();
+ // temp
+ void SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY );
+
+ void mergeData(const TTableConnectionData& _aConnectionData);
+
+ virtual sal_Bool Construct(Window* pParent);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // OJoinController overridables
+ virtual bool allowViews() const;
+ virtual bool allowQueries() const;
+
+ private:
+ // ask the user if the design should be saved when it is modified
+ virtual short saveModified();
+ virtual void reset();
+ virtual void impl_initialize();
+ virtual ::rtl::OUString getPrivateTitle( ) const;
+ DECL_LINK( OnThreadFinished, void* );
+ };
+}
+#endif // DBAUI_RELATIONCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelationDesignView.hxx b/dbaccess/source/ui/inc/RelationDesignView.hxx
new file mode 100644
index 000000000000..423885b3ee38
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationDesignView.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_RELATIONDESIGNVIEW_HXX
+#define DBAUI_RELATIONDESIGNVIEW_HXX
+
+#include "JoinDesignView.hxx"
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include <tools/string.hxx>
+#include "QEnumTypes.hxx"
+#include "RelationTableView.hxx"
+
+namespace dbaui
+{
+ class OAddTableDlg;
+ class OTableConnection;
+ class ORelationTableConnectionData;
+ class OConnectionLineData;
+ class ORelationController;
+
+ class ORelationDesignView : public OJoinDesignView
+ {
+ public:
+ ORelationDesignView(Window* pParent, ORelationController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~ORelationDesignView();
+
+ // set the statement for representation
+ /// late construction
+ virtual void Construct();
+ virtual void initialize();
+
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+ };
+}
+#endif // DBAUI_RELATIONDESIGNVIEW_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelationDlg.hxx b/dbaccess/source/ui/inc/RelationDlg.hxx
new file mode 100644
index 000000000000..7320a8d14908
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationDlg.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELATIONDIALOG_HXX
+#define DBAUI_RELATIONDIALOG_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/msgbox.hxx>
+#include "JoinTableView.hxx"
+#include "RelControliFace.hxx"
+#include "moduledbu.hxx"
+
+
+namespace dbaui
+{
+ class OJoinTableView;
+ class OTableListBoxControl;
+ class ORelationTableConnectionData;
+ //========================================================================
+ class ORelationDialog : public ModalDialog
+ ,public IRelationControlInterface
+ {
+ OModuleClient m_aModuleClient;
+ ::std::auto_ptr<OTableListBoxControl> m_pTableControl;
+ OJoinTableView::OTableWindowMap* m_pTableMap;
+
+ FixedLine aFL_CascUpd;
+ RadioButton aRB_NoCascUpd,
+ aRB_CascUpd,
+ aRB_CascUpdNull,
+ aRB_CascUpdDefault;
+ FixedLine aFL_CascDel;
+ RadioButton aRB_NoCascDel,
+ aRB_CascDel,
+ aRB_CascDelNull,
+ aRB_CascDelDefault;
+
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+
+ TTableConnectionData::value_type m_pConnData;
+ TTableConnectionData::value_type m_pOrigConnData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+ sal_Bool m_bTriedOneUpdate;
+
+ public:
+ ORelationDialog(OJoinTableView* pParent,
+ const TTableConnectionData::value_type& pConnectionData,
+ sal_Bool bAllowTableSelect = sal_False );
+ virtual ~ORelationDialog();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection(){ return m_xConnection; }
+
+ virtual short Execute();
+
+ /** getTableMap gives acces to the table window map
+ @retrun the table window from the join view
+ */
+ OJoinTableView::OTableWindowMap* getTableMap() const { return m_pTableMap; }
+
+ /** getConnectionData returns the current connection data
+ @return the current connectiondata
+ */
+ virtual TTableConnectionData::value_type getConnectionData() const;
+
+ /** setValid set the valid inside, can be used for OK buttons
+ @param _bValid true when the using control allows an update
+ */
+ virtual void setValid(sal_Bool _bValid);
+
+ /** notifyConnectionChange is callback which is called when the table selection has changed and a new connection exists
+ @param _pConnectionData the connection which exists between the new tables
+ */
+ virtual void notifyConnectionChange();
+ protected:
+ void Init(const TTableConnectionData::value_type& _pConnectionData);
+
+ private:
+ DECL_LINK( OKClickHdl, Button* );
+ };
+}
+#endif // DBAUI_RELATIONDIALOG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RelationTableView.hxx b/dbaccess/source/ui/inc/RelationTableView.hxx
new file mode 100644
index 000000000000..d708cbac1424
--- /dev/null
+++ b/dbaccess/source/ui/inc/RelationTableView.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELATION_TABLEVIEW_HXX
+#define DBAUI_RELATION_TABLEVIEW_HXX
+
+#include "JoinTableView.hxx"
+#include <comphelper/containermultiplexer.hxx>
+#include <cppuhelper/basemutex.hxx>
+#include <rtl/ref.hxx>
+
+namespace dbaui
+{
+ class ORelationDesignView;
+ class ORelationTableView : public ::cppu::BaseMutex
+ , public OJoinTableView
+ , public ::comphelper::OContainerListener
+ {
+ OTableConnection* m_pExistingConnection; // is set when a connection was draged on an existing connection
+ TTableConnectionData::value_type m_pCurrentlyTabConnData; // set when we creating a connection with more than one keycolumn
+ ::rtl::Reference< comphelper::OContainerListenerAdapter>
+ m_pContainerListener;
+ bool m_bInRemove;
+
+ virtual void ConnDoubleClicked( OTableConnection* pConnection );
+ virtual void AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, sal_Bool bNewTable = sal_False);
+
+ virtual OTableWindow* createWindow(const TTableWindowData::value_type& _pData);
+
+ /** determines whether the classes Init method should accept a query name, or only table names
+ */
+ virtual bool allowQueries() const;
+
+ // OContainerListener
+ virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ ORelationTableView( Window* pParent, ORelationDesignView* pView );
+ virtual ~ORelationTableView();
+
+ virtual void RemoveTabWin( OTableWindow* pTabWin );
+ virtual void AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest);
+ virtual bool RemoveConnection(OTableConnection* pConn,sal_Bool _bDelete);
+
+ virtual void ReSync();
+
+ void AddNewRelation();
+ // reisst den Dialog fuer eine voellig neue Relation hoch
+ // wird vom AddTabDlg benutzt, um festzustellen, ob noch Tabellen hinzugefuegt werden duerfen
+ virtual sal_Bool IsAddAllowed();
+
+ virtual void lookForUiActivities();
+ };
+}
+#endif // DBAUI_RELATION_TABLEVIEW_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/RtfReader.hxx b/dbaccess/source/ui/inc/RtfReader.hxx
new file mode 100644
index 000000000000..299274aef315
--- /dev/null
+++ b/dbaccess/source/ui/inc/RtfReader.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RTFREADER_HXX
+#define DBAUI_RTFREADER_HXX
+
+#ifndef _VECTOR_
+#include <vector>
+#endif
+#include <svtools/parrtf.hxx>
+#include "DExport.hxx"
+#include <tools/stream.hxx>
+
+namespace dbaui
+{
+ class ORTFReader : public SvRTFParser , public ODatabaseExport
+ {
+ ::std::vector<sal_Int32> m_vecColor;
+
+ // void insertValueIntoColumn();
+ protected:
+ virtual sal_Bool CreateTable(int nToken);
+ virtual void NextToken( int nToken ); // Basisklasse
+ virtual TypeSelectionPageFactory
+ getTypeSelectionPageFactory();
+
+ ~ORTFReader();
+ public:
+ ORTFReader( SvStream& rIn,
+ const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList = 0,
+ const OTypeInfoMap* _pInfoMap = 0);
+ // wird f"ur auto. Typ-Erkennung gebraucht
+ ORTFReader( SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* rList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled);
+
+ virtual SvParserState CallParser();// Basisklasse
+ virtual void release();
+ // birgt nur korrekte Daten, wenn der 2. CTOR benutzt wurde
+ // ansonsten wird die SbaColumnList ohne "Anderung zur"uckgegeben
+ };
+
+ SV_DECL_IMPL_REF( ORTFReader );
+}
+#endif // DBAUI_RTFREADER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/ScrollHelper.hxx b/dbaccess/source/ui/inc/ScrollHelper.hxx
new file mode 100644
index 000000000000..6835c99eef3e
--- /dev/null
+++ b/dbaccess/source/ui/inc/ScrollHelper.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_SCROLLHELPER_HXX
+#define DBAUI_SCROLLHELPER_HXX
+
+#include <tools/link.hxx>
+#include <tools/gen.hxx>
+#include <vcl/timer.hxx>
+
+namespace dbaui
+{
+ class OScrollHelper
+ {
+ Link m_aUpScroll;
+ Link m_aDownScroll;
+ public:
+ /** default contructor
+ */
+ OScrollHelper();
+
+ ~OScrollHelper();
+
+ /** set the memthod which should be called when scrolling up
+ @param _rUpScroll
+ the method to set
+ */
+ inline void setUpScrollMethod( const Link& _rUpScroll )
+ {
+ m_aUpScroll = _rUpScroll;
+ }
+
+ /** set the memthod which should be called when scrolling down
+ @param _rDownScroll
+ the method to set
+ */
+ inline void setDownScrollMethod( const Link& _rDownScroll )
+ {
+ m_aDownScroll = _rDownScroll;
+ }
+
+ /** check if a scroll method has to be called
+ @param _rPoint
+ the current selection point
+ @param _rOutputSize
+ the output size of the window
+ */
+ void scroll(const Point& _rPoint, const Size& _rOutputSize);
+ };
+}
+#endif // DBAUI_SCROLLHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/SqlNameEdit.hxx b/dbaccess/source/ui/inc/SqlNameEdit.hxx
new file mode 100644
index 000000000000..edeed2d4f40b
--- /dev/null
+++ b/dbaccess/source/ui/inc/SqlNameEdit.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#define DBAUI_SQLNAMEEDIT_HXX
+
+#include <vcl/edit.hxx>
+#include <vcl/combobox.hxx>
+
+namespace dbaui
+{
+ class OSQLNameChecker
+ {
+ ::rtl::OUString m_sAllowedChars;
+ sal_Bool m_bOnlyUpperCase;
+ sal_Bool m_bCheck; // true when we should check for invalid chars
+ public:
+ OSQLNameChecker(const ::rtl::OUString& _rAllowedChars)
+ :m_sAllowedChars(_rAllowedChars)
+ ,m_bOnlyUpperCase(sal_False)
+ ,m_bCheck(sal_True)
+ {
+ }
+
+ void setUpperCase(sal_Bool _bUpper=sal_True)
+ {
+ m_bOnlyUpperCase = _bUpper;
+ }
+ void setAllowedChars(const ::rtl::OUString& _rAllowedChars)
+ {
+ m_sAllowedChars = _rAllowedChars;
+ }
+ // default is false because it is initialized with true
+ void setCheck(sal_Bool _bCheck = sal_False)
+ {
+ m_bCheck = _bCheck;
+ }
+ sal_Bool checkString(const ::rtl::OUString& _sOldValue,const ::rtl::OUString& _sToCheck,::rtl::OUString& _rsCorrected);
+ };
+ //==================================================================
+ class OSQLNameEdit : public Edit
+ ,public OSQLNameChecker
+ {
+ public:
+ OSQLNameEdit(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
+ : Edit(_pParent,nStyle)
+ ,OSQLNameChecker(_rAllowedChars)
+ {
+ }
+ OSQLNameEdit(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
+ : Edit(_pParent,_rRes)
+ ,OSQLNameChecker(_rAllowedChars)
+ {
+ }
+
+ // Window overload
+ // virtual long PreNotify( NotifyEvent& rNEvt );
+ // Edit
+ virtual void Modify();
+ };
+
+ class OSQLNameComboBox : public ComboBox
+ ,public OSQLNameChecker
+ {
+ public:
+ OSQLNameComboBox(Window* _pParent,const ::rtl::OUString& _rAllowedChars, WinBits nStyle = WB_BORDER)
+ : ComboBox(_pParent,nStyle)
+ ,OSQLNameChecker(_rAllowedChars)
+ {
+ }
+ OSQLNameComboBox(Window* _pParent,const ResId& _rRes,const ::rtl::OUString& _rAllowedChars = ::rtl::OUString())
+ : ComboBox(_pParent,_rRes)
+ ,OSQLNameChecker(_rAllowedChars)
+ {
+ }
+
+ // Window overload
+ // Edit
+ virtual void Modify();
+ };
+
+}
+#endif // DBAUI_SQLNAMEEDIT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableConnection.hxx b/dbaccess/source/ui/inc/TableConnection.hxx
new file mode 100644
index 000000000000..8d4629c36425
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableConnection.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLECONNECTION_HXX
+#define DBAUI_TABLECONNECTION_HXX
+
+#include <vector>
+#include <tools/debug.hxx>
+#include <vcl/window.hxx>
+#include <tools/rtti.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include "TableConnectionData.hxx"
+
+class Point;
+class Rectangle;
+
+namespace dbaui
+{
+ class OTableConnectionData;
+ class OTableWindow;
+ class OJoinTableView;
+ class OConnectionLine;
+
+ DBG_NAMEEX(OTableConnection)
+ class OTableConnection : public Window
+ {
+ ::std::vector<OConnectionLine*> m_vConnLine;
+ TTableConnectionData::value_type
+ m_pData;
+ OJoinTableView* m_pParent;
+
+ sal_Bool m_bSelected;
+
+ void Init();
+ /** clearLineData loops through the vector and deletes all lines
+ */
+ void clearLineData();
+
+ protected:
+ OConnectionLine* CreateConnLine( const OConnectionLine& rConnLine );
+
+ public:
+ OTableConnection( OJoinTableView* pContainer, const TTableConnectionData::value_type& pTabConnData );
+ OTableConnection( const OTableConnection& rConn );
+ // WICHTIG : normalerweise bekomme ich von aussen einen Zeiger auf OTableConnectionData mitgegeben, hier aber muss ich
+ // mir (ueber OTableConnectionData::NewInstance) selber eine INstanz anlegen, die ich aber - wie in allen anderen Faellen auch -
+ // NIE loesche. Der Aufrufer ist also bei Benutzung dieses Constructors dafuer verantwortlich, meine Daten abzufragen und
+ // sich irgendwo zu merken, um sie dann irgendwann zu loeschen.
+ virtual ~OTableConnection();
+
+ OTableConnection& operator=( const OTableConnection& rConn );
+
+
+ void Select();
+ void Deselect();
+ sal_Bool IsSelected() const { return m_bSelected; }
+ sal_Bool CheckHit( const Point& rMousePos ) const;
+ bool InvalidateConnection();
+ void UpdateLineList();
+
+ OTableWindow* GetSourceWin() const;
+ OTableWindow* GetDestWin() const;
+
+ bool RecalcLines();
+ /** isTableConnection
+ @param _pTable the table where we should check if we belongs to it
+
+ @return true when the source or the destination window are equal
+ */
+ bool isTableConnection(const OTableWindow* _pTable)
+ {
+ return (_pTable == GetSourceWin() || _pTable == GetDestWin());
+ }
+
+ Rectangle GetBoundingRect() const;
+
+ inline TTableConnectionData::value_type GetData() const { return m_pData; }
+ const ::std::vector<OConnectionLine*>* GetConnLineList() const { return &m_vConnLine; }
+ inline OJoinTableView* GetParent() const { return m_pParent; }
+ virtual void Draw( const Rectangle& rRect );
+ using Window::Draw;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+ };
+}
+#endif // DBAUI_TABLECONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableConnectionData.hxx b/dbaccess/source/ui/inc/TableConnectionData.hxx
new file mode 100644
index 000000000000..79ccd802d564
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableConnectionData.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#define DBAUI_TABLECONNECTIONDATA_HXX
+
+#include "ConnectionLineData.hxx"
+#include "TableWindowData.hxx"
+#include <vector>
+#include <tools/rtti.hxx>
+#include <tools/string.hxx>
+#include <boost/shared_ptr.hpp>
+
+namespace dbaui
+{
+ //==================================================================
+ // ConnData ---------->* ConnLineData
+ // ^1 ^1
+ // | |
+ // Conn ---------->* ConnLine
+ //==================================================================
+
+
+ //==================================================================
+ /*
+ the class OTableConnectionData contains all connection data which exists between two windows
+ **/
+ class OTableConnectionData
+ {
+
+ protected:
+ TTableWindowData::value_type m_pReferencingTable;
+ TTableWindowData::value_type m_pReferencedTable;
+ String m_aConnName;
+
+ OConnectionLineDataVec m_vConnLineData;
+
+ void Init();
+
+ virtual OConnectionLineDataRef CreateLineDataObj();
+ virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
+
+ OTableConnectionData& operator=( const OTableConnectionData& rConnData );
+ public:
+ OTableConnectionData();
+ OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable,const TTableWindowData::value_type& _pReferencedTable, const String& rConnName = String() );
+ OTableConnectionData( const OTableConnectionData& rConnData );
+ virtual ~OTableConnectionData();
+
+ // sich aus einer Quelle initialisieren (das ist mir irgendwie angenehmer als ein virtueller Zuweisungsoperator)
+ virtual void CopyFrom(const OTableConnectionData& rSource);
+
+ // eine neue Instanz meines eigenen Typs liefern (braucht NICHT initialisiert sein)
+ virtual OTableConnectionData* NewInstance() const;
+ // (von OTableConnectionData abgeleitete Klasse muessen entsprechend eine Instanz ihrer Klasse liefern)
+
+ sal_Bool SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName );
+ sal_Bool AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName );
+ void ResetConnLines( sal_Bool bUseDefaults = sal_True );
+
+ /** normalizeLines moves the empty lines to the back
+ */
+ void normalizeLines();
+ // loescht die Liste der ConnLines, bei bUseDefaults == sal_True werden danach MAX_CONN_COUNT neue Dummy-Linien eingefuegt
+
+ OConnectionLineDataVec* GetConnLineDataList(){ return &m_vConnLineData; }
+
+ inline TTableWindowData::value_type getReferencingTable() const { return m_pReferencingTable; }
+ inline TTableWindowData::value_type getReferencedTable() const { return m_pReferencedTable; }
+
+ inline void setReferencingTable(const TTableWindowData::value_type& _pTable) { m_pReferencingTable = _pTable; }
+ inline void setReferencedTable(const TTableWindowData::value_type& _pTable) { m_pReferencedTable = _pTable; }
+
+ String GetConnName() const { return m_aConnName; }
+
+ virtual void SetConnName( const String& rConnName ){ m_aConnName = rConnName; }
+ /** Update create a new connection
+
+ @return true if successful
+ */
+ virtual sal_Bool Update(){ return sal_True; }
+ };
+
+ typedef ::std::vector< ::boost::shared_ptr<OTableConnectionData> > TTableConnectionData;
+
+}
+#endif // DBAUI_TABLECONNECTIONDATA_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableController.hxx b/dbaccess/source/ui/inc/TableController.hxx
new file mode 100644
index 000000000000..5747cd20ac10
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableController.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBUI_TABLECONTROLLER_HXX
+#define DBUI_TABLECONTROLLER_HXX
+
+#include "singledoccontroller.hxx"
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include "TypeInfo.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+class FixedText;
+namespace dbaui
+{
+ class OTableRow;
+ class OFieldDescription;
+ typedef OSingleDocumentController OTableController_BASE;
+ class OTableController : public OTableController_BASE
+ {
+ private:
+ OModuleClient m_aModuleClient;
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_vRowList;
+ OTypeInfoMap m_aTypeInfo;
+ ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable;
+
+ ::rtl::OUString m_sCatalogName; // catalog for update data
+ ::rtl::OUString m_sSchemaName; // schema for update data
+ ::rtl::OUString m_sName; // table for update data
+ ::rtl::OUString m_sAutoIncrementValue; // the autoincrement value set in the datasource
+ String m_sTypeNames; // these type names are the ones out of the resource file
+ TOTypeInfoSP m_pTypeInfo; // fall back when type is unkown because database driver has a failure
+
+ sal_Bool m_bAllowAutoIncrementValue; // no : 1 NO BIT , is true when the datasource has a AutoIncrementValue property in their info property
+ sal_Bool m_bNew : 1; // is true when we create a new table
+
+
+ void reSyncRows();
+ void assignTable(); // set the table if a name is given
+ void loadData();
+ sal_Bool checkColumns(sal_Bool _bNew) throw(::com::sun::star::sdbc::SQLException); // check if we have double column names
+ String createUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxTables,const String& _rDefault);
+ void appendColumns(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup,sal_Bool _bNew,sal_Bool _bKeyColumns = sal_False);
+ void appendPrimaryKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup,sal_Bool _bNew);
+ void alterColumns();
+ void dropPrimaryKey();
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getKeyColumns() const;
+ ::rtl::OUString createUniqueName(const ::rtl::OUString& _rName);
+
+ void reload();
+
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ virtual void losingConnection( );
+
+ virtual ::rtl::OUString getPrivateTitle( ) const;
+
+ void doEditIndexes();
+ sal_Bool doSaveDoc(sal_Bool _bSaveAs);
+
+ virtual ~OTableController();
+ public:
+ OTableController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getTable() { return m_xTable;}
+
+ sal_Bool isAddAllowed() const;
+ sal_Bool isDropAllowed() const;
+ sal_Bool isAlterAllowed() const;
+ bool isAutoIncrementPrimaryKey() const;
+
+ inline sal_Bool isAutoIncrementValueEnabled() const { return m_bAllowAutoIncrementValue; }
+ inline const ::rtl::OUString& getAutoIncrementValue() const { return m_sAutoIncrementValue; }
+
+ virtual void impl_onModifyChanged();
+
+ inline ::std::vector< ::boost::shared_ptr<OTableRow> >* getRows() { return &m_vRowList; }
+
+ /// returns the postion of the the first empty row
+ sal_Int32 getFirstEmptyRowPosition();
+
+ inline const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; }
+
+ inline TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; }
+ TOTypeInfoSP getTypeInfoByType(sal_Int32 _nDataType) const;
+
+ inline TOTypeInfoSP getTypeInfoFallBack() const { return m_pTypeInfo; }
+
+ virtual sal_Bool Construct(Window* pParent);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XController
+ virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ //
+ virtual void Load(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxIn);
+ virtual void Save(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOut);
+
+ protected:
+ void startTableListening();
+ void stopTableListening();
+ virtual void impl_initialize();
+ };
+}
+#endif // DBUI_TABLECONTROLLER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableCopyHelper.hxx b/dbaccess/source/ui/inc/TableCopyHelper.hxx
new file mode 100644
index 000000000000..4745c232eaef
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableCopyHelper.hxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBUI_TABLECOPYHELPER_HXX
+#define DBUI_TABLECOPYHELPER_HXX
+
+#include "AppElementType.hxx"
+#include "commontypes.hxx"
+#include <svx/dataaccessdescriptor.hxx>
+#include <sot/storage.hxx>
+#include <svtools/transfer.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <functional>
+
+class SvLBoxEntry;
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+ class OGenericUnoController;
+ /// unary_function Functor object for class DataFlavorExVector::value_type returntype is bool
+ struct TAppSupportedSotFunctor : ::std::unary_function<DataFlavorExVector::value_type,bool>
+ {
+ ElementType eEntryType;
+ sal_Bool bQueryDrop;
+ TAppSupportedSotFunctor(const ElementType& _eEntryType,sal_Bool _bQueryDrop)
+ : eEntryType(_eEntryType)
+ , bQueryDrop(_bQueryDrop)
+ {
+ }
+
+ inline bool operator()(const DataFlavorExVector::value_type& _aType)
+ {
+ switch (_aType.mnSotId)
+ {
+ case SOT_FORMAT_RTF: // RTF data descriptions
+ case SOT_FORMATSTR_ID_HTML: // HTML data descriptions
+ case SOT_FORMATSTR_ID_DBACCESS_TABLE: // table descriptor
+ return (E_TABLE == eEntryType);
+ case SOT_FORMATSTR_ID_DBACCESS_QUERY: // query descriptor
+ case SOT_FORMATSTR_ID_DBACCESS_COMMAND: // SQL command
+ return ((E_QUERY == eEntryType) || ( !bQueryDrop && E_TABLE == eEntryType));
+ }
+ return false;
+ }
+ };
+
+ class OTableCopyHelper
+ {
+ private:
+ OGenericUnoController* m_pController;
+ ::rtl::OUString m_sTableNameForAppend;
+
+ public:
+ // is needed to describe the drop target
+ struct DropDescriptor
+ {
+ ::svx::ODataAccessDescriptor aDroppedData;
+
+ //for transfor the tablename
+ ::rtl::OUString sDefaultTableName;
+
+ String aUrl;
+ SotStorageStreamRef aHtmlRtfStorage;
+ ElementType nType;
+ SvLBoxEntry* pDroppedAt;
+ sal_Int8 nAction;
+ sal_Bool bHtml;
+ sal_Bool bError;
+
+ DropDescriptor() : nType(E_TABLE),pDroppedAt(NULL),nAction(DND_ACTION_NONE) { }
+ };
+
+ OTableCopyHelper(OGenericUnoController* _pControler);
+
+ /** pastes a table into the data source
+ @param _rPasteData
+ The data helper.
+ @param _sDestDataSourceName
+ The name of the dest data source.
+ */
+ void pasteTable( const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& _sDestDataSourceName
+ ,const SharedConnection& _xConnection);
+
+ /** pastes a table into the data source
+ @param _nFormatId
+ The format which should be copied.
+ @param _rPasteData
+ The data helper.
+ @param _sDestDataSourceName
+ The name of the dest data source.
+ */
+ void pasteTable( SotFormatStringId _nFormatId
+ ,const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& _sDestDataSourceName
+ ,const SharedConnection& _xConnection);
+
+ /** copies a table which was constructed by tags like HTML or RTF
+ @param _rDesc
+ The Drop descriptor
+ @param _bCheck
+ If set to <TRUE/> than the controller checks only if a copy is possible.
+ @param _xConnection
+ The connection
+ */
+ sal_Bool copyTagTable( DropDescriptor& _rDesc,
+ sal_Bool _bCheck,
+ const SharedConnection& _xConnection);
+
+ /** copies a table which was constructed by tags like HTML or RTF
+ @param _rDesc
+ The Drop descriptor
+ @param _bCheck
+ If set to <TRUE/> than the controller checks only if a copy is possible.
+ @param _xConnection
+ The connection
+ */
+ void asyncCopyTagTable( DropDescriptor& _rDesc
+ ,const ::rtl::OUString& _sDestDataSourceName
+ ,const SharedConnection& _xConnection);
+
+ /** copies a table which was constructed by tags like HTML or RTF
+ @param _aDroppedData
+ The dropped data
+ @param _rDesc
+ IN/OUT parameter
+ @param _xConnection
+ The connection
+ */
+ sal_Bool copyTagTable(const TransferableDataHelper& _aDroppedData,
+ DropDescriptor& _rAsyncDrop,
+ const SharedConnection& _xConnection);
+
+ /// returns <TRUE/> if the clipboard supports a table format, otherwise <FALSE/>.
+ sal_Bool isTableFormat(const TransferableDataHelper& _rClipboard) const;
+
+ inline void SetTableNameForAppend( const ::rtl::OUString& _rDefaultTableName ) { m_sTableNameForAppend = _rDefaultTableName; }
+ inline void ResetTableNameForAppend() { SetTableNameForAppend( ::rtl::OUString() ); }
+ inline const ::rtl::OUString& GetTableNameForAppend() const { return m_sTableNameForAppend ;}
+
+ private:
+ /** pastes a table into the data source
+ @param _rPasteData
+ The data descriptor.
+ @param _sDestDataSourceName
+ The name of the dest data source.
+ */
+ void pasteTable(
+ const ::svx::ODataAccessDescriptor& _rPasteData,
+ const ::rtl::OUString& _sDestDataSourceName,
+ const SharedConnection& _xDestConnection
+ );
+
+ /** insert a table into the data source. The source can eihter be a table or a query
+ */
+ void insertTable(
+ const ::rtl::OUString& i_rSourceDataSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rSourceConnection,
+ const ::rtl::OUString& i_rCommand,
+ const sal_Int32 i_nCommandType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& i_rSourceRows,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelection,
+ const sal_Bool i_bBookmarkSelection,
+ const ::rtl::OUString& i_rDestDataSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_rDestConnection
+ );
+
+ };
+//........................................................................
+} // namespace dbaui
+//........................................................................
+#endif // DBUI_TABLECOPYHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableDesignControl.hxx b/dbaccess/source/ui/inc/TableDesignControl.hxx
new file mode 100644
index 000000000000..0e905a459cc2
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignControl.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEDESIGNCONTROL_HXX
+#define DBAUI_TABLEDESIGNCONTROL_HXX
+
+#include <svtools/tabbar.hxx>
+#include <svtools/editbrowsebox.hxx>
+
+#include "IClipBoardTest.hxx"
+#include "TypeInfo.hxx"
+
+#define TABPAGESIZE 70
+namespace dbaui
+{
+ class OTableDesignView;
+ class OTypeInfo;
+ //==================================================================
+ class OTableRowView : public ::svt::EditBrowseBox
+ ,public IClipboardTest
+ {
+ friend class OTableDesignUndoAct;
+
+ protected:
+ long m_nDataPos; // derzeit benoetigte Zeile
+ long m_nCurrentPos; // Aktuelle Position der ausgewaehlten Column
+ private:
+ sal_uInt16 m_nCurUndoActId;
+ protected:
+ sal_Bool m_bCurrentModified;
+ sal_Bool m_bUpdatable;
+ sal_Bool m_bClipboardFilled;
+
+ public:
+ OTableRowView(Window* pParent);
+ virtual ~OTableRowView();
+
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo ) = 0;
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rNewData ) = 0;
+ virtual ::com::sun::star::uno::Any GetCellData( long nRow, sal_uInt16 nColId ) = 0;
+ virtual void SetControlText( long nRow, sal_uInt16 nColId, const String& rText ) = 0;
+ virtual String GetControlText( long nRow, sal_uInt16 nColId ) = 0;
+
+ virtual OTableDesignView* GetView() const = 0;
+
+ sal_uInt16 GetCurUndoActId(){ return m_nCurUndoActId; }
+
+ // IClipboardTest
+ virtual void cut();
+ virtual void copy();
+ virtual void paste();
+
+ protected:
+ void Paste( long nRow );
+
+ virtual void CopyRows() = 0;
+ virtual void DeleteRows() = 0;
+ virtual void InsertRows( long nRow ) = 0;
+ virtual void InsertNewRows( long nRow ) = 0;
+
+ virtual sal_Bool IsPrimaryKeyAllowed( long nRow ) = 0;
+ virtual sal_Bool IsInsertNewAllowed( long nRow ) = 0;
+ virtual sal_Bool IsDeleteAllowed( long nRow ) = 0;
+
+ virtual sal_Bool IsUpdatable() const {return m_bUpdatable;}
+ virtual void SetUpdatable( sal_Bool bUpdate=sal_True );
+
+ virtual RowStatus GetRowStatus(long nRow) const;
+ virtual void KeyInput(const KeyEvent& rEvt);
+ virtual void Command( const CommandEvent& rEvt );
+
+ virtual void Init();
+ };
+}
+#endif // DBAUI_TABLEDESIGNCONTROL_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableDesignHelpBar.hxx b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx
new file mode 100644
index 000000000000..a3bef0769a8c
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignHelpBar.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX
+#define DBAUI_TABLEDESIGNHELPBAR_HXX
+
+#include <tools/string.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+#include "IClipBoardTest.hxx"
+
+class MultiLineEdit;
+namespace dbaui
+{
+ //==================================================================
+ // Ableitung von TabPage ist ein Trick von TH,
+ // um Aenderungen der Systemfarben zu bemerken
+ class OTableDesignHelpBar : public TabPage
+ ,public IClipboardTest
+ {
+ private:
+ String m_sHelpText;
+ MultiLineEdit* m_pTextWin;
+ sal_uInt16 m_nDummy;
+
+ protected:
+ virtual void Resize();
+
+ public:
+ OTableDesignHelpBar( Window* pParent );
+ virtual ~OTableDesignHelpBar();
+
+ void SetHelpText( const String& rText );
+ String GetHelpText() const { return m_sHelpText; }
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+ };
+}
+#endif // DBAUI_TABLEDESIGNHELPBAR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableDesignView.hxx b/dbaccess/source/ui/inc/TableDesignView.hxx
new file mode 100644
index 000000000000..9f4a96b6844d
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableDesignView.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEDESIGNVIEW_HXX
+#define DBAUI_TABLEDESIGNVIEW_HXX
+
+#include "dataview.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <vcl/split.hxx>
+#include "IClipBoardTest.hxx"
+
+namespace dbaui
+{
+ class OTableController;
+ class OTableFieldDescWin;
+ class OTableEditorCtrl;
+ //==================================================================
+ class OTableBorderWindow : public Window
+ {
+ Splitter m_aHorzSplitter;
+ OTableFieldDescWin* m_pFieldDescWin;
+ OTableEditorCtrl* m_pEditorCtrl;
+
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ void ArrangeChilds( long nSplitPos ,Rectangle& rRect);
+ DECL_LINK( SplitHdl, Splitter* );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OTableBorderWindow(Window* pParent);
+ ~OTableBorderWindow();
+ // window overloads
+ virtual void Resize();
+ virtual void GetFocus();
+
+ OTableEditorCtrl* GetEditorCtrl() const { return m_pEditorCtrl; }
+ OTableFieldDescWin* GetDescWin() const { return m_pFieldDescWin; }
+ };
+ //==================================================================
+ class OTableDesignView : public ODataView
+ ,public IClipboardTest
+ {
+ enum ChildFocusState
+ {
+ DESCRIPTION,
+ EDITOR,
+ NONE
+ };
+ private:
+ ::com::sun::star::lang::Locale m_aLocale;
+ OTableBorderWindow* m_pWin;
+ OTableController& m_rController;
+ ChildFocusState m_eChildFocus;
+
+ IClipboardTest* getActiveChild() const;
+ protected:
+
+
+ // return the Rectangle where I can paint myself
+ virtual void resizeDocumentView(Rectangle& rRect);
+
+ public:
+ OTableDesignView( Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
+ OTableController& _rController);
+ virtual ~OTableDesignView();
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+
+ OTableEditorCtrl* GetEditorCtrl() const { return m_pWin ? m_pWin->GetEditorCtrl() : NULL; }
+ OTableFieldDescWin* GetDescWin() const { return m_pWin ? m_pWin->GetDescWin() : NULL; }
+ OTableController& getController() const { return m_rController; }
+
+ ::com::sun::star::lang::Locale getLocale() const { return m_aLocale;}
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly);
+
+ virtual void initialize();
+ void reSync(); // resync window data with realdata
+
+ DECL_LINK( SwitchHdl, Accelerator* );
+ };
+}
+#endif // DBAUI_TABLEDESIGNVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx
new file mode 100644
index 000000000000..6f716e30d5e8
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESC_HXX
+#define DBAUI_TABLEFIELDDESC_HXX
+
+#ifndef INCLUDED_VECTOR
+#define INCLUDED_VECTOR
+#include <vector>
+#endif
+#include "QEnumTypes.hxx"
+#include <rtl/ustring.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <rtl/ref.hxx>
+
+#include <salhelper/simplereferenceobject.hxx>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+class Window;
+namespace dbaui
+{
+ class OTableFieldDesc : public ::salhelper::SimpleReferenceObject
+ {
+ private:
+ ::std::vector< ::rtl::OUString >
+ m_aCriteria;
+
+ ::rtl::OUString m_aTableName;
+ ::rtl::OUString m_aAliasName; // table range
+ ::rtl::OUString m_aFieldName; // column
+ ::rtl::OUString m_aFieldAlias; // column alias
+ ::rtl::OUString m_aFunctionName; // enth"alt den Funktionsnamen, nur wenn m_eFunctionType != FKT_NONE gesetzt
+
+ Window* m_pTabWindow;
+
+ sal_Int32 m_eDataType;
+ sal_Int32 m_eFunctionType;
+ ETableFieldType m_eFieldType;
+ EOrderDir m_eOrderDir;
+ sal_Int32 m_nIndex;
+ sal_Int32 m_nColWidth;
+ sal_uInt16 m_nColumnId;
+ sal_Bool m_bGroupBy;
+ sal_Bool m_bVisible;
+
+ // !!!! bitte bei Erweiterung um neue Felder auch IsEmpty mitpflegen !!!!
+
+ public:
+ OTableFieldDesc();
+ OTableFieldDesc(const ::rtl::OUString& rTable, const ::rtl::OUString& rField );
+ OTableFieldDesc(const OTableFieldDesc& rRS);
+ ~OTableFieldDesc();
+
+ inline sal_Bool IsEmpty() const;
+
+ OTableFieldDesc& operator=( const OTableFieldDesc& _aField );
+ sal_Bool operator==( const OTableFieldDesc& rDesc );
+
+ sal_Bool IsVisible() const { return m_bVisible;}
+ sal_Bool IsGroupBy() const { return m_bGroupBy;}
+
+ void SetVisible( sal_Bool bVis=sal_True ){ m_bVisible = bVis;}
+ void SetGroupBy( sal_Bool bGb=sal_False ){ m_bGroupBy = bGb;}
+ void SetTabWindow( Window* pWin ){ m_pTabWindow = pWin;}
+ void SetField( const ::rtl::OUString& rF ){ m_aFieldName = rF;}
+ void SetFieldAlias( const ::rtl::OUString& rF ){ m_aFieldAlias = rF;}
+ void SetTable( const ::rtl::OUString& rT ){ m_aTableName = rT;}
+ void SetAlias( const ::rtl::OUString& rT ){ m_aAliasName = rT;}
+ void SetFunction( const ::rtl::OUString& rT ) { m_aFunctionName = rT;}
+ void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; }
+ void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; }
+ void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; }
+ void SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit);
+ void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
+ void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
+ void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; }
+ void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
+
+
+ ::rtl::OUString GetField() const { return m_aFieldName;}
+ ::rtl::OUString GetFieldAlias() const { return m_aFieldAlias;}
+ ::rtl::OUString GetTable() const { return m_aTableName;}
+ ::rtl::OUString GetAlias() const { return m_aAliasName;}
+ ::rtl::OUString GetFunction() const { return m_aFunctionName;}
+ sal_Int32 GetDataType() const { return m_eDataType; }
+ ETableFieldType GetFieldType() const { return m_eFieldType; }
+ EOrderDir GetOrderDir() const { return m_eOrderDir; }
+ ::rtl::OUString GetCriteria( sal_uInt16 nIdx ) const;
+ sal_Int32 GetColWidth() const { return m_nColWidth; }
+ sal_Int32 GetFieldIndex() const { return m_nIndex; }
+ Window* GetTabWindow() const { return m_pTabWindow;}
+ sal_Int32 GetFunctionType() const { return m_eFunctionType; }
+ sal_uInt16 GetColumnId() const { return m_nColumnId;}
+
+ inline sal_Bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; }
+ inline sal_Bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; }
+ inline sal_Bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; }
+ inline sal_Bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; }
+ inline sal_Bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; }
+ inline sal_Bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
+
+ sal_Bool HasCriteria() const
+ {
+ ::std::vector< ::rtl::OUString>::const_iterator aIter = m_aCriteria.begin();
+ ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_aCriteria.end();
+ for(;aIter != aEnd;++aIter)
+ if(aIter->getLength())
+ break;
+ return aIter != aEnd;
+ }
+
+ const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_aCriteria; }
+
+ void Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria );
+ void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria );
+ };
+
+ //------------------------------------------------------------------
+ inline sal_Bool OTableFieldDesc::IsEmpty() const
+ {
+ sal_Bool bEmpty = (!m_aTableName.getLength() &&
+ !m_aAliasName.getLength() &&
+ !m_aFieldName.getLength() &&
+ !m_aFieldAlias.getLength() &&
+ !m_aFunctionName.getLength() &&
+ !HasCriteria());
+ return bEmpty;
+ }
+ //------------------------------------------------------------------
+ typedef ::rtl::Reference< OTableFieldDesc> OTableFieldDescRef;
+ typedef ::std::vector<OTableFieldDescRef> OTableFields;
+}
+#endif //
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableGrantCtrl.hxx b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
new file mode 100644
index 000000000000..a0010fdbc82d
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableGrantCtrl.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEGRANTCONTROL_HXX
+#define DBAUI_TABLEGRANTCONTROL_HXX
+
+#include <svtools/editbrowsebox.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/stl_types.hxx>
+#include "moduledbu.hxx"
+
+class Edit;
+namespace dbaui
+{
+
+class OTableGrantControl : public ::svt::EditBrowseBox
+{
+ typedef struct
+ {
+ sal_Int32 nRights;
+ sal_Int32 nWithGrant;
+ } TPrivileges;
+
+ DECLARE_STL_USTRINGACCESS_MAP(TPrivileges,TTablePrivilegeMap);
+
+ OModuleClient m_aModuleClient;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xTables;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable> m_xGrantUser;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aTableNames;
+
+ mutable TTablePrivilegeMap m_aPrivMap;
+ ::rtl::OUString m_sUserName;
+ ::svt::CheckBoxControl* m_pCheckCell;
+ Edit* m_pEdit;
+ long m_nDataPos;
+ sal_Bool m_bEnable;
+ sal_uLong m_nDeactivateEvent;
+
+public:
+ OTableGrantControl( Window* pParent,const ResId& _RsId);
+ virtual ~OTableGrantControl();
+ void UpdateTables();
+ void setUserName(const ::rtl::OUString _sUserName);
+ void setGrantUser(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAuthorizable>& _xGrantUser);
+
+ void setTablesSupplier(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >& _xTablesSup);
+ void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB);
+
+ virtual void Init();
+
+ // IAccessibleTableProvider
+ /** Creates the accessible object of a data table cell.
+ @param nRow The row index of the cell.
+ @param nColumnId The column ID of the cell.
+ @return The XAccessible interface of the specified cell. */
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible >
+ CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId );
+
+protected:
+ virtual void Resize();
+
+ virtual long PreNotify(NotifyEvent& rNEvt );
+
+ virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
+ virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
+ virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
+ virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
+ virtual sal_Bool SeekRow( long nRow );
+ virtual sal_Bool SaveModified();
+ virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
+
+ virtual void CellModified();
+
+private:
+ DECL_LINK( AsynchActivate, void* );
+ DECL_LINK( AsynchDeactivate, void* );
+
+ sal_Bool isAllowed(sal_uInt16 _nColumnId,sal_Int32 _nPrivilege) const;
+ void fillPrivilege(sal_Int32 _nRow) const;
+ TTablePrivilegeMap::const_iterator findPrivilege(sal_Int32 _nRow) const;
+};
+
+}
+
+#endif // DBAUI_TABLEGRANTCONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableRow.hxx b/dbaccess/source/ui/inc/TableRow.hxx
new file mode 100644
index 000000000000..9e02a0df0662
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableRow.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEROW_HXX
+#define DBAUI_TABLEROW_HXX
+
+#include <comphelper/stl_types.hxx>
+#include <tools/string.hxx>
+#include <tools/stream.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "TypeInfo.hxx"
+
+
+namespace dbaui
+{
+ class OFieldDescription;
+ class OTypeInfo;
+ class OTableRow
+ {
+ private:
+ OFieldDescription* m_pActFieldDescr;
+ long m_nPos;
+ bool m_bReadOnly;
+ bool m_bOwnsDescriptions;
+
+ protected:
+ public:
+ OTableRow();
+ OTableRow(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAffectedCol);
+ OTableRow( const OTableRow& rRow, long nPosition = -1 );
+ ~OTableRow();
+
+ inline OFieldDescription* GetActFieldDescr() const { return m_pActFieldDescr; }
+ inline bool isValid() const { return GetActFieldDescr() != NULL; }
+
+ void SetFieldType( const TOTypeInfoSP& _pType, sal_Bool _bForce = sal_False );
+
+ void SetPrimaryKey( sal_Bool bSet );
+ sal_Bool IsPrimaryKey() const;
+
+ /** returns the current position in the table.
+ @return
+ the current position in the table
+ */
+ inline long GetPos() const { return m_nPos; }
+ inline void SetPos(sal_Int32 _nPos) { m_nPos = _nPos; }
+
+ /** set the row readonly
+ @param _bRead
+ if <TRUE/> then the row is redonly, otherwise not
+ */
+ inline void SetReadOnly( bool _bRead=true ){ m_bReadOnly = _bRead; }
+
+ /** returns if the row is readonly
+ @return
+ <TRUE/> if readonly, otherwise <FALSE/>
+ */
+ inline bool IsReadOnly() const { return m_bReadOnly; }
+
+ friend SvStream& operator<<( SvStream& rStr,const OTableRow& _rRow );
+ friend SvStream& operator>>( SvStream& rStr, OTableRow& _rRow );
+ };
+}
+#endif // DBAUI_TABLEROW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableRowExchange.hxx b/dbaccess/source/ui/inc/TableRowExchange.hxx
new file mode 100644
index 000000000000..4a433f7c849e
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableRowExchange.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEROW_EXCHANGE_HXX
+#define DBAUI_TABLEROW_EXCHANGE_HXX
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <svtools/transfer.hxx>
+#include <boost/shared_ptr.hpp>
+
+namespace dbaui
+{
+ class OTableRow;
+ class OTableRowExchange : public TransferableHelper
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_vTableRow;
+ public:
+ OTableRowExchange(const ::std::vector< ::boost::shared_ptr<OTableRow> >& _rvTableRow);
+ protected:
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+ };
+}
+#endif // DBAUI_TABLEROW_EXCHANGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx
new file mode 100644
index 000000000000..382a278dee2c
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindow.hxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEWINDOW_HXX
+#define DBAUI_TABLEWINDOW_HXX
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "TableWindowTitle.hxx"
+#include <tools/rtti.hxx>
+#include <rtl/ref.hxx>
+#include "TableWindowData.hxx"
+#include <vector>
+#include <vcl/window.hxx>
+
+#include <comphelper/containermultiplexer.hxx>
+#include "cppuhelper/basemutex.hxx"
+
+class SvLBoxEntry;
+namespace dbaui
+{
+ //////////////////////////////////////////////////////////////////////////
+ // Flags fuer die Groessenanpassung der SbaJoinTabWins
+ const sal_uInt16 SIZING_NONE = 0x0000;
+ const sal_uInt16 SIZING_TOP = 0x0001;
+ const sal_uInt16 SIZING_BOTTOM = 0x0002;
+ const sal_uInt16 SIZING_LEFT = 0x0004;
+ const sal_uInt16 SIZING_RIGHT = 0x0008;
+
+ class OTableWindowListBox;
+ class OJoinDesignView;
+ class OJoinTableView;
+ class OTableWindowAccess;
+
+ class OTableWindow : public ::cppu::BaseMutex
+ ,public ::comphelper::OContainerListener
+ ,public Window
+ {
+ friend class OTableWindowTitle;
+ friend class OTableWindowListBox;
+ protected:
+ // und die Tabelle selber (brauche ich, da ich sie locken will, solange das Fenster lebt)
+ FixedImage m_aTypeImage;
+ OTableWindowTitle m_aTitle;
+ OTableWindowListBox* m_pListBox;
+ OTableWindowAccess* m_pAccessible;
+
+ private:
+ TTableWindowData::value_type
+ m_pData;
+ ::rtl::Reference< comphelper::OContainerListenerAdapter>
+ m_pContainerListener;
+ sal_Int32 m_nMoveCount; // how often the arrow keys was pressed
+ sal_Int32 m_nMoveIncrement; // how many pixel we should move
+ sal_uInt16 m_nSizingFlags;
+ sal_Bool m_bActive;
+
+ void Draw3DBorder( const Rectangle& rRect );
+ // OContainerListener
+ virtual void _elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementRemoved( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void _elementReplaced( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+ virtual void MouseMove( const MouseEvent& rEvt );
+ virtual void MouseButtonDown( const MouseEvent& rEvt );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual OTableWindowListBox* CreateListBox();
+ // wird im ERSTEN Init aufgerufen
+ sal_Bool FillListBox();
+ // wird in JEDEM Init aufgerufen
+
+ virtual void OnEntryDoubleClicked(SvLBoxEntry* /*pEntry*/) { }
+ // wird aus dem DoubleClickHdl der ListBox heraus aufgerufen
+
+ /** HandleKeyInput triues to handle the KeyEvent. Movement or deletion
+ @param rEvt
+ The KEyEvent
+ @return
+ <TRUE/> when the table could handle the keyevent.
+ */
+ sal_Bool HandleKeyInput( const KeyEvent& rEvt );
+
+ /** delete the user data with the equal type as created within createUserData
+ @param _pUserData
+ The user data store in the listbox entries. Created with a call to createUserData.
+ _pUserData may be <NULL/>. _pUserData will be set to <NULL/> after call.
+ */
+ virtual void deleteUserData(void*& _pUserData);
+
+ /** creates user information that will be append at the ListBoxentry
+ @param _xColumn
+ The corresponding column, can be <NULL/>.
+ @param _bPrimaryKey
+ <TRUE/> when the column belongs to the primary key
+ @return
+ the user data which will be append at the listbox entry, may be <NULL/>
+ */
+ virtual void* createUserData(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet>& _xColumn,
+ bool _bPrimaryKey);
+
+ /** updates m_aTypeImage
+ */
+ void impl_updateImage();
+
+ OTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData );
+
+ public:
+ virtual ~OTableWindow();
+
+ // spaeter Constructor, siehe auch CreateListbox und FillListbox
+ virtual sal_Bool Init();
+
+ OJoinTableView* getTableView();
+ const OJoinTableView* getTableView() const;
+ OJoinDesignView* getDesignView();
+ void SetPosPixel( const Point& rNewPos );
+ void SetSizePixel( const Size& rNewSize );
+ void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize );
+
+ String getTitle() const;
+ void SetBoldTitle( sal_Bool bBold );
+ void setActive(sal_Bool _bActive = sal_True);
+
+ void Remove();
+ sal_Bool IsActiveWindow(){ return m_bActive; }
+
+ ::rtl::OUString GetTableName() const { return m_pData->GetTableName(); }
+ ::rtl::OUString GetWinName() const { return m_pData->GetWinName(); }
+ ::rtl::OUString GetComposedName() const { return m_pData->GetComposedName(); }
+ OTableWindowListBox* GetListBox() const { return m_pListBox; }
+ TTableWindowData::value_type GetData() const { return m_pData; }
+ OTableWindowTitle* GetTitleCtrl() { return &m_aTitle; }
+
+ /** returns the name which should be used when displaying join or relations
+ @return
+ The composed name or the window name.
+ */
+ virtual ::rtl::OUString GetName() const = 0;
+
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetOriginalColumns() const { return m_pData->getColumns(); }
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTable() const { return m_pData->getTable(); }
+
+ sal_uInt16 GetSizingFlags() const { return m_nSizingFlags; }
+ /** set the sizing flag to the direction
+ @param _rPos
+ The EndPosition after resizing.
+ */
+ void setSizingFlag(const Point& _rPos);
+ /** set the rsizing flag to NONE.
+ */
+ void resetSizingFlag() { m_nSizingFlags = SIZING_NONE; }
+
+ /** returns the new sizing
+ */
+ Rectangle getSizingRect(const Point& _rPos,const Size& _rOutputSize) const;
+
+ // window override
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual void GetFocus();
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Command(const CommandEvent& rEvt);
+
+ // Accessibility
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ // habe ich Connections nach aussen ?
+ sal_Bool ExistsAConn() const;
+
+ void EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields);
+
+ /** clears the listbox inside. Must be called be the dtor is called.
+ */
+ void clearListBox();
+
+ protected:
+ using Window::SetPosSizePixel;
+ };
+}
+#endif //DBAUI_TABLEWINDOW_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableWindowAccess.hxx b/dbaccess/source/ui/inc/TableWindowAccess.hxx
new file mode 100644
index 000000000000..f8351362c001
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowAccess.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_TABLEWINDOWACCESS_HXX
+#define DBACCESS_TABLEWINDOWACCESS_HXX
+
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <toolkit/awt/vclxaccessiblecomponent.hxx>
+
+namespace dbaui
+{
+ typedef ::cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleRelationSet,
+ ::com::sun::star::accessibility::XAccessible
+ > OTableWindowAccess_BASE;
+ class OTableWindow;
+ /** the class OTableWindowAccess represents the accessible object for table windows
+ like they are used in the QueryDesign and the RelationDesign
+ */
+ class OTableWindowAccess : public VCLXAccessibleComponent
+ , public OTableWindowAccess_BASE
+ {
+ OTableWindow* m_pTable; // the window which I should give accessibility to
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getParentChild(sal_Int32 _nIndex);
+ protected:
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+
+ /** isEditable returns the current editable state
+ @return true if it is editable otherwise false
+ */
+ virtual sal_Bool isEditable() const;
+
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+ public:
+ OTableWindowAccess( OTableWindow* _pTable);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ()
+ { // here inline is allowed because we do not use this class outside this dll
+ VCLXAccessibleComponent::acquire( );
+ }
+ virtual void SAL_CALL release( ) throw ()
+ { // here inline is allowed because we do not use this class outside this dll
+ VCLXAccessibleComponent::release( );
+ }
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( com::sun::star::uno::RuntimeException );
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException,::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleExtendedComponent
+ virtual ::rtl::OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleRelationSet
+ virtual sal_Int32 SAL_CALL getRelationCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL getRelation( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL containsRelation( sal_Int16 aRelationType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL getRelationByType( sal_Int16 aRelationType ) throw (::com::sun::star::uno::RuntimeException);
+
+ void notifyAccessibleEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ )
+ {
+ NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
+ }
+ };
+}
+#endif // DBACCESS_TABLEWINDOWACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableWindowData.hxx b/dbaccess/source/ui/inc/TableWindowData.hxx
new file mode 100644
index 000000000000..9a3bd21f1664
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowData.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEWINDOWDATA_HXX
+#define DBAUI_TABLEWINDOWDATA_HXX
+
+#include <tools/gen.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <unotools/eventlisteneradapter.hxx>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace dbaui
+{
+ class OTableWindowData : public ::utl::OEventListenerAdapter
+ {
+ mutable ::osl::Mutex m_aMutex;
+
+ void listen();
+ protected:
+ // the columns of the table
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTable; // can either be a table or a query
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xKeys;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumns;
+
+ ::rtl::OUString m_aTableName;
+ ::rtl::OUString m_aWinName;
+ ::rtl::OUString m_sComposedName;
+ Point m_aPosition;
+ Size m_aSize;
+ sal_Bool m_bShowAll;
+ bool m_bIsQuery;
+ bool m_bIsValid;
+
+ public:
+ explicit OTableWindowData( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable
+ ,const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& strTableName
+ ,const ::rtl::OUString& rWinName = ::rtl::OUString() );
+ virtual ~OTableWindowData();
+
+ /** late constructor
+ *
+ * \param _xConnection
+ * \param _bAllowQueries when true, queries are allowed
+ * \return false if the table was unaccessible otherwise true
+ */
+ bool init(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
+ ,bool _bAllowQueries);
+
+ inline ::rtl::OUString GetComposedName() const { return m_sComposedName; }
+ inline ::rtl::OUString GetTableName() const { return m_aTableName; }
+ inline ::rtl::OUString GetWinName() const { return m_aWinName; }
+ inline Point GetPosition() const { return m_aPosition; }
+ inline Size GetSize() const { return m_aSize; }
+ inline sal_Bool IsShowAll() const { return m_bShowAll; }
+ inline bool isQuery() const { return m_bIsQuery; }
+ inline bool isValid() const { return m_bIsValid; } // it is either a table or query but it is known
+ sal_Bool HasPosition() const;
+ sal_Bool HasSize() const;
+
+ inline void SetWinName( const ::rtl::OUString& rWinName ) { m_aWinName = rWinName; }
+ inline void SetPosition( const Point& rPos ) { m_aPosition=rPos; }
+ inline void SetSize( const Size& rSize ) { m_aSize = rSize; }
+ inline void ShowAll( sal_Bool bAll ) { m_bShowAll = bAll; }
+
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getTable() const { ::osl::MutexGuard aGuard( m_aMutex ); return m_xTable; }
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> getKeys() const { ::osl::MutexGuard aGuard( m_aMutex ); return m_xKeys; }
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const { ::osl::MutexGuard aGuard( m_aMutex ); return m_xColumns; }
+
+ // OEventListenerAdapter
+ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
+ };
+
+ typedef ::std::vector< ::boost::shared_ptr<OTableWindowData> > TTableWindowData;
+}
+#endif // DBAUI_TABLEWINDOWDATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableWindowListBox.hxx b/dbaccess/source/ui/inc/TableWindowListBox.hxx
new file mode 100644
index 000000000000..bf8fab0ac395
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowListBox.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEWINDOWLISTBOX_HXX
+#define DBAUI_TABLEWINDOWLISTBOX_HXX
+
+#include <svtools/svtreebx.hxx>
+#include "callbacks.hxx"
+
+struct AcceptDropEvent;
+struct ExecuteDropEvent;
+namespace dbaui
+{
+ class OTableWindowListBox;
+ struct OJoinExchangeData
+ {
+ public:
+ OTableWindowListBox* pListBox; // die ListBox innerhalb desselben (daraus kann man sich das TabWin und daraus den WinName besorgen)
+ SvLBoxEntry* pEntry; // der Eintrag, der gedraggt oder auf den gedroppt wurde
+
+ OJoinExchangeData(OTableWindowListBox* pBox);
+ OJoinExchangeData() : pListBox(NULL), pEntry(NULL) { }
+ };
+ struct OJoinDropData
+ {
+ OJoinExchangeData aSource;
+ OJoinExchangeData aDest;
+ };
+
+ class OTableWindow;
+ class OTableWindowListBox
+ :public SvTreeListBox
+ ,public IDragTransferableListener
+ {
+ DECL_LINK( OnDoubleClick, SvTreeListBox* );
+ DECL_LINK( ScrollUpHdl, SvTreeListBox* );
+ DECL_LINK( ScrollDownHdl, SvTreeListBox* );
+ DECL_LINK( DropHdl, void* );
+ DECL_LINK( LookForUiHdl, void* );
+
+ Timer m_aScrollTimer;
+ Point m_aMousePos;
+
+ OTableWindow* m_pTabWin;
+ sal_uLong m_nDropEvent;
+ sal_uLong m_nUiEvent;
+ OJoinDropData m_aDropInfo;
+
+ sal_Bool m_bReallyScrolled : 1;
+ sal_Bool m_bDragSource : 1;
+
+ protected:
+ virtual void LoseFocus();
+ virtual void GetFocus();
+ virtual void NotifyScrolled();
+ virtual void NotifyEndScroll();
+
+ virtual long PreNotify(NotifyEvent& rNEvt);
+
+ virtual void dragFinished( );
+
+
+
+ public:
+ OTableWindowListBox(OTableWindow* pParent);
+ virtual ~OTableWindowListBox();
+
+ // DnD stuff
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ // window
+ virtual void Command(const CommandEvent& rEvt);
+
+ OTableWindow* GetTabWin(){ return m_pTabWin; }
+ SvLBoxEntry* GetEntryFromText( const String& rEntryText );
+
+ private:
+ using SvTreeListBox::ExecuteDrop;
+ };
+}
+#endif // DBAUI_TABLEWINDOWLISTBOX_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TableWindowTitle.hxx b/dbaccess/source/ui/inc/TableWindowTitle.hxx
new file mode 100644
index 000000000000..e81ab0be5597
--- /dev/null
+++ b/dbaccess/source/ui/inc/TableWindowTitle.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEWINDOWTITLE_HXX
+#define DBAUI_TABLEWINDOWTITLE_HXX
+
+#include <vcl/fixed.hxx>
+
+namespace dbaui
+{
+ class OTableWindow;
+ class OTableWindowTitle : public FixedText
+ {
+ OTableWindow* m_pTabWin;
+
+ protected:
+ virtual void Command(const CommandEvent& rEvt);
+ // virtual void Paint( const Rectangle& rRect );
+ virtual void MouseButtonDown( const MouseEvent& rEvt );
+ virtual void KeyInput( const KeyEvent& rEvt );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ public:
+ OTableWindowTitle( OTableWindow* pParent );
+ virtual ~OTableWindowTitle();
+ virtual void LoseFocus();
+ virtual void GetFocus();
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ // window override
+ virtual void StateChanged( StateChangedType nStateChange );
+ };
+}
+#endif // DBAUI_TABLEWINDOWTITLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TablesSingleDlg.hxx b/dbaccess/source/ui/inc/TablesSingleDlg.hxx
new file mode 100644
index 000000000000..e9c7880caf9c
--- /dev/null
+++ b/dbaccess/source/ui/inc/TablesSingleDlg.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLESSINGLEDLG_HXX_
+#define _DBAUI_TABLESSINGLEDLG_HXX_
+
+#include <sfx2/basedlgs.hxx>
+#include "IItemSetHelper.hxx"
+#include <comphelper/uno3.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <memory>
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+class ODbDataSourceAdministrationHelper;
+ //========================================================================
+ //= OTableSubscriptionDialog
+ //========================================================================
+ class OTableSubscriptionDialog : public SfxSingleTabDialog, public IItemSetHelper
+ {
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+ sal_Bool m_bStopExecution; // set when the dialog should not be executed
+
+ DECL_LINK( OKClickHdl, OKButton* );
+ SfxItemSet* m_pOutSet;
+ public:
+
+ OTableSubscriptionDialog(Window* pParent
+ ,SfxItemSet* _pItems
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ );
+ virtual ~OTableSubscriptionDialog();
+
+ // forwards from ODbDataSourceAdministrationHelper
+ void successfullyConnected();
+ sal_Bool getCurrentSettings(::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rDriverParams);
+ void clearPassword();
+ String getConnectionURL() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getCurrentDataSource();
+ inline void endExecution() { m_bStopExecution = sal_True; }
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ virtual short Execute();
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_TABLESSINGLEDLG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TokenWriter.hxx b/dbaccess/source/ui/inc/TokenWriter.hxx
new file mode 100644
index 000000000000..e3b2ffcb3efb
--- /dev/null
+++ b/dbaccess/source/ui/inc/TokenWriter.hxx
@@ -0,0 +1,257 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TOKENWRITER_HXX
+#define DBAUI_TOKENWRITER_HXX
+
+#include "DExport.hxx"
+#include "moduledbu.hxx"
+#include "commontypes.hxx"
+
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include <tools/stream.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+
+#include <memory>
+
+namespace com { namespace sun { namespace star {
+ namespace sdbc{
+ class XRowUpdate;
+ }
+}}}
+
+namespace dbaui
+{
+ // =========================================================================
+ // ODatabaseImportExport Basisklasse f"ur Import/Export
+ // =========================================================================
+ class ODatabaseExport;
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> ODatabaseImportExport_BASE;
+ class ODatabaseImportExport : public ODatabaseImportExport_BASE
+ {
+ private:
+ void impl_initializeRowMember_throw();
+
+ protected:
+ ::com::sun::star::lang::Locale m_aLocale;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
+ sal_Bool m_bBookmarkSelection;
+ SvStream* m_pStream;
+ ::com::sun::star::awt::FontDescriptor m_aFont;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject; // table/query
+ SharedConnection m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > m_xRow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XRowLocate > m_xRowLocate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xResultSetMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xRowSetColumns;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+
+ ::rtl::OUString m_sName;
+
+ //for transfor the tablename
+ ::rtl::OUString m_sDefaultTableName;
+
+ ::rtl::OUString m_sDataSourceName;
+ sal_Int32 m_nCommandType;
+ bool m_bNeedToReInitialize;
+
+#if defined UNX
+ static const char sNewLine;
+#else
+ static const char sNewLine[];
+#endif
+
+ ODatabaseExport* m_pReader;
+ sal_Int32* m_pRowMarker; // wenn gesetzt, dann nur diese Rows kopieren
+ rtl_TextEncoding m_eDestEnc;
+ sal_Bool m_bInInitialize;
+ sal_Bool m_bCheckOnly;
+
+ // export data
+ ODatabaseImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange = String());
+
+ // import data
+ ODatabaseImportExport( const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ virtual ~ODatabaseImportExport();
+
+ virtual void initialize();
+ public:
+ void setStream(SvStream* _pStream){ m_pStream = _pStream; }
+
+ //for set the tablename
+ void setSTableName(const ::rtl::OUString &_sTableName){ m_sDefaultTableName = _sTableName; }
+
+ virtual sal_Bool Write(); // Export
+ virtual sal_Bool Read(); // Import
+
+ void initialize(const ::svx::ODataAccessDescriptor& _aDataDescriptor);
+ void dispose();
+
+ void enableCheckOnly() { m_bCheckOnly = sal_True; }
+ sal_Bool isCheckEnabled() const { return m_bCheckOnly; }
+
+
+ private:
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+ void impl_initFromDescriptor( const ::svx::ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit );
+ };
+
+ // =========================================================================
+ // RTF Im- und Export
+ // =========================================================================
+
+ class ORTFImportExport : public ODatabaseImportExport
+ {
+ void appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk);
+ public:
+ // export data
+ ORTFImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange = String())
+ : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange) {};
+
+ // import data
+ ORTFImportExport( const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
+ : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
+ {}
+
+ virtual sal_Bool Write();
+ virtual sal_Bool Read();
+ };
+ // =========================================================================
+ // HTML Im- und Export
+ // =========================================================================
+ #define SBA_HTML_FONTSIZES 7
+ const sal_Int16 nIndentMax = 23;
+ class OHTMLImportExport : public ODatabaseImportExport
+ {
+ // default HtmlFontSz[1-7]
+ static const sal_Int16 nDefaultFontSize[SBA_HTML_FONTSIZES];
+ // HtmlFontSz[1-7] in s*3.ini [user]
+ static sal_Int16 nFontSize[SBA_HTML_FONTSIZES];
+ static const sal_Int16 nCellSpacing;
+ static const char sIndentSource[];
+ char sIndent[nIndentMax+1];
+ sal_Int16 m_nIndent;
+ #if OSL_DEBUG_LEVEL > 0
+ sal_Bool m_bCheckFont;
+ #endif
+
+ void WriteHeader();
+ void WriteBody();
+ void WriteTables();
+ void WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,const String& rValue,const char* pHtmlTag);
+ void IncIndent( sal_Int16 nVal );
+ const char* GetIndentStr() { return sIndent; }
+ void FontOn();
+ inline void FontOff();
+
+ public:
+ // export data
+ OHTMLImportExport( const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange = String());
+ // import data
+ OHTMLImportExport( const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
+ : ODatabaseImportExport(_rxConnection,_rxNumberF,_rM)
+ {}
+
+ virtual sal_Bool Write();
+ virtual sal_Bool Read();
+
+ };
+ // =========================================================================
+ // normal RowSet Im- und Export
+ // =========================================================================
+
+ class ORowSetImportExport : public ODatabaseImportExport
+ {
+ OModuleClient m_aModuleClient;
+ ::std::vector<sal_Int32> m_aColumnMapping;
+ ::std::vector<sal_Int32> m_aColumnTypes;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xTargetResultSetUpdate; //
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xTargetRowUpdate; //
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xTargetResultSetMetaData; //
+ Window* m_pParent;
+ sal_Bool m_bAlreadyAsked;
+
+ sal_Bool insertNewRow();
+ protected:
+ virtual void initialize();
+
+ public:
+ // export data
+ ORowSetImportExport(Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate >& _xResultSetUpdate,
+ const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const String& rExchange = String());
+
+ // import data
+ ORowSetImportExport(const SharedConnection& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
+ : ODatabaseImportExport(_rxConnection,NULL,_rM)
+ {}
+
+ virtual sal_Bool Write();
+ virtual sal_Bool Read();
+
+ private:
+ using ODatabaseImportExport::initialize;
+ };
+
+}
+#endif // DBAUI_TOKENWRITER_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/TypeInfo.hxx b/dbaccess/source/ui/inc/TypeInfo.hxx
new file mode 100644
index 000000000000..10ea51cf58aa
--- /dev/null
+++ b/dbaccess/source/ui/inc/TypeInfo.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TYPEINFO_HXX
+#define DBAUI_TYPEINFO_HXX
+
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <boost/shared_ptr.hpp>
+#include <map>
+
+
+
+namespace dbaui
+{
+//========================================================================
+// Anhand dieser Ids werden die sprachabhaengigen ::rtl::OUString aus der Resource geholt
+const sal_uInt16 TYPE_UNKNOWN = 0;
+const sal_uInt16 TYPE_TEXT = 1;
+const sal_uInt16 TYPE_NUMERIC = 2;
+const sal_uInt16 TYPE_DATETIME = 3;
+const sal_uInt16 TYPE_DATE = 4;
+const sal_uInt16 TYPE_TIME = 5;
+const sal_uInt16 TYPE_BOOL = 6;
+const sal_uInt16 TYPE_CURRENCY = 7;
+const sal_uInt16 TYPE_MEMO = 8;
+const sal_uInt16 TYPE_COUNTER = 9;
+const sal_uInt16 TYPE_IMAGE = 10;
+const sal_uInt16 TYPE_CHAR = 11;
+const sal_uInt16 TYPE_DECIMAL = 12;
+const sal_uInt16 TYPE_BINARY = 13;
+const sal_uInt16 TYPE_VARBINARY = 14;
+const sal_uInt16 TYPE_BIGINT = 15;
+const sal_uInt16 TYPE_DOUBLE = 16;
+const sal_uInt16 TYPE_FLOAT = 17;
+const sal_uInt16 TYPE_REAL = 18;
+const sal_uInt16 TYPE_INTEGER = 19;
+const sal_uInt16 TYPE_SMALLINT = 20;
+const sal_uInt16 TYPE_TINYINT = 21;
+const sal_uInt16 TYPE_SQLNULL = 22;
+const sal_uInt16 TYPE_OBJECT = 23;
+const sal_uInt16 TYPE_DISTINCT = 24;
+const sal_uInt16 TYPE_STRUCT = 25;
+const sal_uInt16 TYPE_ARRAY = 26;
+const sal_uInt16 TYPE_BLOB = 27;
+const sal_uInt16 TYPE_CLOB = 28;
+const sal_uInt16 TYPE_REF = 29;
+const sal_uInt16 TYPE_OTHER = 30;
+const sal_uInt16 TYPE_BIT = 31;
+
+ class OTypeInfo
+ {
+ public:
+ ::rtl::OUString aUIName; // the name which is the user see (a combination of resource text and aTypeName)
+ ::rtl::OUString aTypeName; // Name des Types in der Datenbank
+ ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten
+ ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten
+ ::rtl::OUString aCreateParams; // Parameter zum Erstellen
+ ::rtl::OUString aLocalTypeName;
+
+ sal_Int32 nPrecision; // Laenge des Types
+ sal_Int32 nType; // Datenbanktyp
+
+ sal_Int16 nMaximumScale; // Nachkommastellen
+ sal_Int16 nMinimumScale; // Min Nachkommastellen
+
+ sal_Int16 nSearchType; // kann nach dem Typen gesucht werden
+
+
+ sal_Bool bCurrency : 1, // Waehrung
+ bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld
+ bNullable : 1, // Kann das Feld NULL annehmen
+ bCaseSensitive : 1, // Ist der Type Casesensitive
+ bUnsigned : 1; // Ist der Type Unsigned
+
+ OTypeInfo()
+ :nPrecision(0)
+ ,nType(::com::sun::star::sdbc::DataType::OTHER)
+ ,nMaximumScale(0)
+ ,nMinimumScale(0)
+ ,nSearchType(::com::sun::star::sdbc::ColumnSearch::FULL)
+ ,bCurrency(sal_False)
+ ,bAutoIncrement(sal_False)
+ ,bNullable(sal_True)
+ ,bCaseSensitive(sal_False)
+ ,bUnsigned(sal_False)
+ {}
+ sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; }
+ sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; }
+ inline ::rtl::OUString getDBName() const { return aTypeName; }
+
+ };
+
+ typedef ::boost::shared_ptr<OTypeInfo> TOTypeInfoSP;
+ typedef ::std::multimap<sal_Int32,TOTypeInfoSP> OTypeInfoMap;
+ /** return the most suitable typeinfo for a requested type
+ @param _rTypeInfo contains a map of type to typeinfo
+ @param _nType the requested type
+ @param _sTypeName the typename
+ @param _sCreateParams the create params
+ @param _nPrecision the precision
+ @param _nScale the scale
+ @param _bAutoIncrement if it is a auto increment
+ @param _brForceToType true when type was found which has some differenes
+ */
+ TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ sal_Int32 _nType,
+ const ::rtl::OUString& _sTypeName,
+ const ::rtl::OUString& _sCreateParams,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool _bAutoIncrement,
+ sal_Bool& _brForceToType);
+}
+
+#endif // DBAUI_TYPEINFO_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/UITools.hxx b/dbaccess/source/ui/inc/UITools.hxx
new file mode 100644
index 000000000000..c4c8ccb96d74
--- /dev/null
+++ b/dbaccess/source/ui/inc/UITools.hxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TOOLS_HXX
+#define DBAUI_TOOLS_HXX
+
+#include <connectivity/dbexception.hxx>
+#include <comphelper/stl_types.hxx>
+#include "TypeInfo.hxx"
+#include <editeng/svxenum.hxx>
+#include <vcl/taskpanelist.hxx>
+#include <connectivity/dbtools.hxx>
+
+#define RET_ALL 10
+
+// we only need forward decl here
+namespace com { namespace sun { namespace star {
+
+ namespace beans { class XPropertySet;}
+ namespace container
+ {
+ class XNameAccess;
+ class XIndexAccess;
+ class XHierarchicalNameContainer;
+ class XNameContainer;
+ }
+ namespace lang
+ {
+ class XEventListener;
+ class XMultiServiceFactory;
+ }
+ namespace awt
+ {
+ struct FontDescriptor;
+ }
+ namespace sdbc
+ {
+ class XDatabaseMetaData;
+ class XConnection;
+ }
+ namespace util
+ {
+ struct URL;
+ class XNumberFormatter;
+ }
+ namespace frame
+ {
+ class XModel;
+ }
+ namespace ucb { class XContent; }
+
+}}}
+
+namespace svt
+{
+ class EditBrowseBox;
+}
+
+class Window;
+class ToolBox;
+class Font;
+class SvNumberFormatter;
+class SfxFilter;
+class SvLBoxEntry;
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+ //class ODsnTypeCollection;
+ class DBTreeListBox;
+
+ /** creates a new connection and appends the eventlistener
+ @param _rsDataSourceName name of the datasource
+ @param _xDatabaseContext the database context
+ @param _rMF the multi service factory
+ @param _rEvtLst the eventlistener which will be added to the new created connection
+ @param _rOUTConnection this parameter will be filled with the new created connection
+ @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
+ */
+ ::dbtools::SQLExceptionInfo createConnection(
+ const ::rtl::OUString& _rsDataSourceName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
+ /** creates a new connection and appends the eventlistener
+ @param _xDataSource the datasource
+ @param _rMF the multi service factory
+ @param _rEvtLst the eventlistener which will be added to the new created connection
+ @param _rOUTConnection this parameter will be filled with the new created connection
+ @return SQLExceptionInfo contains a SQLException, SQLContext or a SQLWarning when they araised else .isValid() will return false
+ */
+ ::dbtools::SQLExceptionInfo createConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDataSource,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection );
+
+ /** creates a error dialog which displays the SQLExceptionInfo. Also it supports a "more" button where detailed information are available
+ @param _rInfo the error which should be shown, if the info is not valid no error dialog will appear
+ @param _pParent the parent of the error dialog
+ @param _xFactory need to create the dialog
+ */
+ void showError( const ::dbtools::SQLExceptionInfo& _rInfo,
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory);
+
+ /** return a vector which contains all key columns for the @see com::sun::star::sdbc::KeyType _nKeyType
+ @param _rxTable the table which must be a @see com::sun::star::sdbcx::XColumnsSupplier
+ @param _nKeyType @see com::sun::star::sdbc::KeyType
+ */
+
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> >
+ getKeyColumns( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxKeys,
+ sal_Int32 _nKeyType);
+
+ /** fills a map and a vector with localized type names
+ @param _rxConnection the connection to acces the metadata
+ @param _rsTypeNames a list of localized type names seperated with ';'
+ @param _rTypeInfoMap the filled map with the type names
+ @param _rTypeInfoIters the vector filled with map iterators
+ */
+ void fillTypeInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
+ const String& _rsTypeNames,
+ OTypeInfoMap& _rTypeInfoMap,
+ ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters);
+
+ /** fill a column with data of a field description
+ @param _rxColumn the column which should be filled
+ @param _pFieldDesc the source of the data
+ */
+ class OFieldDescription;
+ void setColumnProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxColumn,
+ const OFieldDescription* _pFieldDesc);
+
+ ::rtl::OUString createDefaultName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xTables,
+ const ::rtl::OUString& _sName);
+
+ /** checks if the given name exists in the database context
+ */
+ sal_Bool checkDataSourceAvailable( const ::rtl::OUString& _sDataSourceName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory_xORB);
+
+ /** maps SvxCellHorJustify to com::sun::star::awt::TextAlign
+ @param SvxCellHorJustify& _eAlignment
+ @return the corresponding com::sun::star::awt::TextAlign
+ */
+ sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment);
+
+ /** retrieves a data source given by name or URL, and displays an error if this fails
+
+ Any <type scope="com::sun::star::sdbc">SQLException</type>s which occur will be displayed.
+ Additionally, and Exceptions which indicate a data source name pointing to a non-existent database
+ URL will also be denoted. Yet more additionally, and other exceptions will be forwarded to
+ a <type scope="com::sun::star::sdb">InteractionHandler</type>.
+
+ @param _rDataSourceName
+ the URL of the database document, or the name of a registered data source
+ @param _pErrorMessageParent
+ the window to use as parent for error messages
+ @param _rxORB
+ a service factory to use for components to be created
+ @param _pErrorInfo
+ takes the error info in case of failure. If <NULL/>, the error is displayed to the user.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >
+ getDataSourceByName(
+ const ::rtl::OUString& _rDataSourceName,
+ Window* _pErrorMessageParent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
+ );
+
+ /** returns either the model when data source is given as parameter,
+ or returns a data source when a model is given.
+ @param _xObject Either a data source or a model.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDataSourceOrModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xObject);
+
+ /** maps com::sun::star::awt::TextAlign to SvxCellHorJustify
+ @param com::sun::star::awt::TextAlign& _nAlignment
+ @return the corresponding SvxCellHorJustify
+ */
+ SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment);
+
+ /** convert Font to ::com::sun::star::awt::FontDescriptor
+ @param _rFont Font to be converted
+ @return the new FontDescriptor
+ */
+ ::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& _rFont );
+
+ /** call teh format dialog and set the selected format at the column
+ @param _xAffectedCol Font to be converted
+ @param _xField Font to be converted
+ */
+ void callColumnFormatDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xAffectedCol,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xField,
+ SvNumberFormatter* _pFormatter,
+ Window* _pParent);
+
+ /** second variant of the function before
+ */
+ sal_Bool callColumnFormatDialog(Window* _pParent,
+ SvNumberFormatter* _pFormatter,
+ sal_Int32 _nDataType,
+ sal_Int32& _nFormatKey,
+ SvxCellHorJustify& _eJustify,
+ sal_uInt16& _nFlags,
+ sal_Bool _bHasFormat);
+ /** append a name to tablefilter of a datasource
+ @param _xConnection the connection is need to get the datasource
+ @param _sName the name which should be appended
+ @param _xFactory needed to check if datasource is available
+ @param _pParent needed when an error must be shown
+ @return false when datsource is not available otherwise true
+ */
+ sal_Bool appendToFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _sName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xFactory,
+ Window* _pParent);
+
+ /** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow.
+ @param _pWindow
+ The window which is used to search for the SystemWindow.
+ @param _pToRegister
+ The window which should be added or removed on the TaskPaneList.
+ @param _rMemFunc
+ The member function which should be called at the SystemWindow when found.
+ Possible values are:
+ ::comphelper::mem_fun(&TaskPaneList::AddWindow)
+ ::comphelper::mem_fun(&TaskPaneList::RemoveWindow)
+ */
+ void notifySystemWindow(Window* _pWindow,
+ Window* _pToRegister,
+ ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc);
+
+ /** adjustToolBoxSize checks if the size of the ToolBox is still valid. If not it will be resized.
+ @param _pToolBox
+ The Toolbox which should be resized.
+ */
+ void adjustToolBoxSize(ToolBox* _pToolBox);
+
+ void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId );
+
+ /** check if SQL92 name checking is enabled
+ @param _xConnection
+ Used to get the datasource as parent from the connection.
+ @return
+ <TRUE/> if so otherwise <FALSE/>
+ */
+ sal_Bool isSQL92CheckEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ /** check if the alias name of the table should be added at select statements
+ @param _xConnection
+ Used to get the datasource as parent from the connection.
+ @return
+ <TRUE/> if so otherwise <FALSE/>
+ */
+ sal_Bool isAppendTableAliasEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ /** determines whether when generating SQL statements, AS should be placed before a table alias
+ */
+ sal_Bool generateAsBeforeTableAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection );
+
+ /** fills the bool and string value with information out of the datasource info property
+ @param _xDatasource
+ Asked for the properties.
+ @param _rAutoIncrementValueEnabled
+ <OUT/> Set to sal_True when the property was set in the datasource.
+ @param _rsAutoIncrementValue
+ <OUT/> Set to the value when the property was set in the datasource.
+ */
+ void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDatasource
+ ,sal_Bool& _rAutoIncrementValueEnabled
+ ,::rtl::OUString& _rsAutoIncrementValue);
+
+ /** fills the bool and string value with information out of the datasource info property
+ @param _xConnection
+ Used to get the datasource as parent from the connection.
+ @param _rAutoIncrementValueEnabled
+ <OUT/> Set to sal_True when the property was set in the datasource.
+ @param _rsAutoIncrementValue
+ <OUT/> Set to the value when the property was set in the datasource.
+ */
+ void fillAutoIncrementValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
+ ,sal_Bool& _rAutoIncrementValueEnabled
+ ,::rtl::OUString& _rsAutoIncrementValue);
+
+ /** creates the URL or the help agent
+ @param _sModuleName
+ @param _nHelpId
+ @return
+ The URL for the help agent to dispatch.
+ */
+ ::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName,const rtl::OString& _rHelpId);
+
+ /** set the evaluation flag at the number formatter
+ @param _rxFormatter
+ */
+ void setEvalDateFormatForFormatter(::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter);
+
+ /** query for a type info which can be used to create a primary key column
+ @param _rTypeInfo
+ The map which contains all available types.
+ @return
+ The type info which can be used to create a primary key column.
+ */
+ TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo);
+
+ /** query for a specific type.
+ @param _nDataType
+ The type we are searching.
+ @param _rTypeInfo
+ The map which contains all available types.
+ @return
+ The type or <NULL/> if we can't find it.
+ */
+ TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo);
+
+ /** returns the configuration node name of user defined drivers.
+ @return
+ the configuration node name of user defined drivers.
+ */
+
+ /** returns the result of the user action when view the query dialog.
+ @param _pParent
+ The parent of the dialog
+ @param _nTitle
+ A string resource id for the text which will be displayed as title.
+ @param _nText
+ A string resource id for the text which will be displayed above the buttons.
+ When the string contains a #1. This will be replaced by the name.
+ @param _bAll
+ When set to <TRUE/>, the all button will be appended.
+ @param _sName
+ The name of the object to ask for.
+ @return
+ RET_YES, RET_NO, RET_ALL
+ */
+ sal_Int32 askForUserAction(Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const ::rtl::OUString& _sName);
+
+ /** creates a new view from a query or table
+ @param _sName
+ The name of the view to be created.
+ @param _xConnection
+ The source connection.
+ @param _xSourceObject
+ The object for which a view should be created.
+ @return
+ The created view.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView( const ::rtl::OUString& _sName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xSourceObject);
+
+ /** creates a view with the given command
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> createView(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::rtl::OUString& _rCommand
+ );
+
+ /** returns the stripped database name.
+ @param _xDataSource
+ The data source
+ @param _rsDatabaseName
+ Will be filled with the original data source if it is empty.
+ @return
+ The stripped database name either the registered naem or if it is a file url the last segment.
+ */
+ ::rtl::OUString getStrippedDatabaseName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource
+ ,::rtl::OUString& _rsDatabaseName);
+
+ /** returns the standard database filter
+ @retrun
+ the filter
+ */
+ const SfxFilter* getStandardDatabaseFilter();
+
+ /** opens a save dialog to store a form or report folder in the current hierachy.
+ @param _pParent
+ The parent of the dialog.
+ @param _rxORB
+ a multi service factory which can be used to instantiate usual global services
+ @param _xNames
+ Where to insert the new object.
+ @param _sParentFolder
+ The name of the parent folder.
+ @param _bForm
+ <TRUE/> if a form should be inserted
+ @param _bCollection
+ A folder should be inserted
+ @param _xContent
+ The content which should be copied.
+ @param _bMove
+ if <TRUE/> the name of the content must be inserted without any change, otherwise not.
+ @return
+ <TRUE/> if the insert opertions was successfull, otherwise <FALSE/>.
+ */
+ sal_Bool insertHierachyElement(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameContainer>& _xNames,
+ const String& _sParentFolder,
+ sal_Bool _bForm,
+ sal_Bool _bCollection = sal_True,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent>& _xContent = NULL,
+ sal_Bool _bMove = sal_False
+ );
+
+ /** creates a number formatter
+ @param _rxConnection
+ The connection is needed to create the formatter
+ @param _rMF
+ The multi service factory
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > getNumberFormatter(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF );
+
+ // this completes a help url with the system parameters "Language" and "System"
+ // detect installed locale
+ void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark );
+
+// .........................................................................
+}
+// .........................................................................
+#endif // DBAUI_TOOLS_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/UserAdminDlg.hxx b/dbaccess/source/ui/inc/UserAdminDlg.hxx
new file mode 100644
index 000000000000..6315528cda88
--- /dev/null
+++ b/dbaccess/source/ui/inc/UserAdminDlg.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_USERADMINDLG_HXX
+#define DBAUI_USERADMINDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include "dsntypes.hxx"
+#include "IItemSetHelper.hxx"
+#include <comphelper/uno3.hxx>
+#include "moduledbu.hxx"
+#include <memory>
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ class ODbDataSourceAdministrationHelper;
+ //=========================================================================
+ //= OUserAdminDlg
+ //=========================================================================
+
+ /** implements the user adin dialog
+ */
+ class OUserAdminDlg : public SfxTabDialog, public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient
+ {
+ OModuleClient m_aModuleClient;
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+ SfxItemSet* m_pItemSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ sal_Bool m_bOwnConnection;
+ protected:
+ virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage);
+ public:
+ OUserAdminDlg( Window* _pParent
+ ,SfxItemSet* _pItems
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
+
+ virtual ~OUserAdminDlg();
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ virtual short Execute();
+
+ // forwards to ODbDataSourceAdministrationHelper
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
+ virtual void clearPassword();
+ virtual sal_Bool saveDatasource();
+ virtual void setTitle(const ::rtl::OUString& _sTitle);
+ virtual void enableConfirmSettings( bool _bEnable );
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_USERADMINDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/VertSplitView.hxx b/dbaccess/source/ui/inc/VertSplitView.hxx
new file mode 100644
index 000000000000..b9d52b36fabd
--- /dev/null
+++ b/dbaccess/source/ui/inc/VertSplitView.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_VERTSPLITVIEW_HXX
+#define DBAUI_VERTSPLITVIEW_HXX
+
+#include <vcl/split.hxx>
+
+namespace dbaui
+{
+ //==================================================================
+ class OSplitterView : public Window
+ {
+ Splitter* m_pSplitter;
+ Window* m_pLeft;
+ Window* m_pRight;
+ sal_Bool m_bVertical;
+
+ void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
+ DECL_LINK( SplitHdl, Splitter* );
+ protected:
+ virtual void DataChanged(const DataChangedEvent& rDCEvt);
+ public:
+ OSplitterView(Window* _pParent,sal_Bool _bVertical = sal_True);
+ virtual ~OSplitterView();
+ // window overloads
+ virtual void GetFocus();
+
+ void setSplitter(Splitter* _pSplitter);
+ void set(Window* _pRight,Window* _pLeft = NULL);
+ virtual void Resize();
+ };
+}
+#endif // DBAUI_VERTSPLITVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WCPage.hxx b/dbaccess/source/ui/inc/WCPage.hxx
new file mode 100644
index 000000000000..f754e5d9429d
--- /dev/null
+++ b/dbaccess/source/ui/inc/WCPage.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZARD_CPAGE_HXX
+#define DBAUI_WIZARD_CPAGE_HXX
+
+#include "WTabPage.hxx"
+
+#include "QEnumTypes.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+
+namespace dbaui
+{
+ class OWizColumnSelect;
+ class OWizNormalExtend;
+ //========================================================================
+ class OCopyTable : public OWizardPage
+ {
+ protected:
+ FixedText m_ftTableName;
+ Edit m_edTableName;
+ FixedLine m_aFL_Options;
+ RadioButton m_aRB_DefData;
+ RadioButton m_aRB_Def;
+ RadioButton m_aRB_View;
+ RadioButton m_aRB_AppendData;
+ CheckBox m_aCB_UseHeaderLine;
+ CheckBox m_aCB_PrimaryColumn;
+ FixedText m_aFT_KeyName;
+ Edit m_edKeyName;
+ sal_Int16 m_nOldOperation;
+
+ OWizColumnSelect* m_pPage2;
+ OWizNormalExtend* m_pPage3;
+
+ sal_Bool m_bPKeyAllowed;
+ sal_Bool m_bUseHeaderAllowed;
+
+
+ DECL_LINK( AppendDataClickHdl, Button* );
+ DECL_LINK( RadioChangeHdl, Button* );
+ DECL_LINK( KeyClickHdl, Button* );
+
+ sal_Bool checkAppendData();
+ void SetAppendDataRadio();
+
+ public:
+ virtual void Reset();
+ virtual void ActivatePage();
+ virtual sal_Bool LeavePage();
+ virtual String GetTitle() const ;
+
+ OCopyTable( Window * pParent );
+ virtual ~OCopyTable();
+
+ inline sal_Bool IsOptionDefData() const { return m_aRB_DefData.IsChecked(); }
+ inline sal_Bool IsOptionDef() const { return m_aRB_Def.IsChecked(); }
+ inline sal_Bool IsOptionAppendData() const { return m_aRB_AppendData.IsChecked(); }
+ inline sal_Bool IsOptionView() const { return m_aRB_View.IsChecked(); }
+ inline sal_Bool UseHeaderLine() const { return m_aCB_UseHeaderLine.IsChecked(); }
+ String GetKeyName() const { return m_edKeyName.GetText(); }
+
+ void setCreateStyleAction();
+ inline void disallowViews()
+ {
+ m_aRB_View.Disable();
+ }
+ inline void disallowUseHeaderLine()
+ {
+ m_bUseHeaderAllowed = sal_False;
+ m_aCB_UseHeaderLine.Disable();
+ }
+
+ void setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName );
+ };
+}
+#endif // DBAUI_WIZARD_CPAGE_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WColumnSelect.hxx b/dbaccess/source/ui/inc/WColumnSelect.hxx
new file mode 100644
index 000000000000..a0819255f615
--- /dev/null
+++ b/dbaccess/source/ui/inc/WColumnSelect.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZ_COLUMNSELECT_HXX
+#define DBAUI_WIZ_COLUMNSELECT_HXX
+
+#include "WTabPage.hxx"
+#include "WCopyTable.hxx"
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <comphelper/stl_types.hxx>
+
+namespace dbaui
+{
+ class OFieldDescription;
+
+ // ========================================================
+ // Wizard Page: OWizColumnSelect
+ // ========================================================
+
+ class OWizColumnSelect : public OWizardPage
+ {
+
+ FixedLine m_flColumns;
+ MultiListBox m_lbOrgColumnNames; // left side
+ ImageButton m_ibColumn_RH;
+ ImageButton m_ibColumns_RH;
+ ImageButton m_ibColumn_LH;
+ ImageButton m_ibColumns_LH;
+ MultiListBox m_lbNewColumnNames; // right side
+
+
+ DECL_LINK( ButtonClickHdl, Button * );
+ DECL_LINK( ListDoubleClickHdl, MultiListBox * );
+
+
+ void clearListBox(MultiListBox& _rListBox);
+ void fillColumns( ListBox* pRight,
+ ::std::vector< ::rtl::OUString> &_rRightColumns);
+
+ void createNewColumn( ListBox* _pListbox,
+ OFieldDescription* _pSrcField,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase);
+
+ void moveColumn( ListBox* _pRight,
+ ListBox* _pLeft,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase);
+
+ void enableButtons();
+
+
+ sal_uInt16 adjustColumnPosition(ListBox* _pLeft,
+ const ::rtl::OUString& _sColumnName,
+ ODatabaseExport::TColumnVector::size_type nCurrentPos,
+ const ::comphelper::TStringMixEqualFunctor& _aCase);
+
+ public:
+ virtual void Reset ( );
+ virtual void ActivatePage();
+ virtual sal_Bool LeavePage();
+ virtual String GetTitle() const ;
+
+ OWizColumnSelect(Window* pParent);
+ virtual ~OWizColumnSelect();
+ };
+}
+#endif // DBAUI_WIZ_COLUMNSELECT_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
new file mode 100644
index 000000000000..7249dcdc1104
--- /dev/null
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -0,0 +1,423 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_WIZ_COPYTABLEDIALOG_HXX
+#define DBAUI_WIZ_COPYTABLEDIALOG_HXX
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/stl_types.hxx>
+#include "TypeInfo.hxx"
+#include <vcl/button.hxx>
+#include <svtools/wizdlg.hxx>
+#include "DExport.hxx"
+#include "WTabPage.hxx"
+#include "FieldDescriptions.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <vcl/lstbox.hxx>
+#include <functional>
+
+namespace dbaui
+{
+
+ typedef ::std::unary_function< ::rtl::OUString,bool> TColumnFindFunctorType;
+ class TColumnFindFunctor : public TColumnFindFunctorType
+ {
+ public:
+ virtual bool operator()(const ::rtl::OUString& _sColumnName) const = 0;
+ };
+
+ class TExportColumnFindFunctor : public TColumnFindFunctor
+ {
+ ODatabaseExport::TColumns* m_pColumns;
+ public:
+ TExportColumnFindFunctor(ODatabaseExport::TColumns* _pColumns)
+ {
+ m_pColumns = _pColumns;
+ }
+ inline bool operator()(const ::rtl::OUString& _sColumnName) const
+ {
+ return m_pColumns->find(_sColumnName) != m_pColumns->end();
+ }
+ };
+
+ class TMultiListBoxEntryFindFunctor : public TColumnFindFunctor
+ {
+ ::comphelper::TStringMixEqualFunctor m_aCase;
+ ::std::vector< ::rtl::OUString>* m_pVector;
+ public:
+ TMultiListBoxEntryFindFunctor(::std::vector< ::rtl::OUString>* _pVector,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+ :m_aCase(_aCase)
+ ,m_pVector(_pVector)
+ {
+ }
+ inline bool operator()(const ::rtl::OUString& _sColumnName) const
+ {
+ return ::std::find_if(m_pVector->begin(),m_pVector->end(),
+ ::std::bind2nd(m_aCase, _sColumnName)) != m_pVector->end();
+ }
+ };
+
+ // ========================================================
+ // ICopyTableSourceObject
+ // ========================================================
+ /** interface to an object to copy to another DB, using the OCopyTableWizard
+
+ when the wizard is used to copy an object to another DB, it usually requires
+ a sdbcx-level or sdb-level object (a css.sdbcx.Table or css.sdb.Query, that is).
+
+ However, to also support copying tables from sdbc-level connections, we allow to
+ work with the object name only. This implies some less features (like copying the
+ UI settings of a table is not done), but still allows to copy definition and data.
+ */
+ class ICopyTableSourceObject
+ {
+ public:
+ /// retrieves the fully qualified name of the object to copy
+ virtual ::rtl::OUString getQualifiedObjectName() const = 0;
+ /// determines whether the object is a view
+ virtual bool isView() const = 0;
+ /** copies the UI settings of the object to the given target object. Might be
+ ignored by implementations which do not have Ui settings.
+ */
+ virtual void copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const = 0;
+ /// retrieves the column names of the to-be-copied object
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getColumnNames() const = 0;
+ /// retrieves the names of the primary keys of the to-be-copied object
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getPrimaryKeyColumnNames() const = 0;
+ /// creates a OFieldDescription for the given column of the to-be-copied object
+ virtual OFieldDescription* createFieldDescription( const ::rtl::OUString& _rColumnName ) const = 0;
+ /// returns the SELECT statement which can be used to retrieve the data of the to-be-copied object
+ virtual ::rtl::OUString getSelectStatement() const = 0;
+
+ /** copies the filter and sorting
+ *
+ * \return
+ */
+ virtual void copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const = 0;
+
+ /** returns the prepared statement which can be used to retrieve the data of the to-be-copied object
+
+ The default implementation of this method will simply prepare a statement with the return value
+ of ->getSelectStatement.
+ */
+ virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
+ getPreparedSelectStatement() const = 0;
+
+ virtual ~ICopyTableSourceObject();
+ };
+
+ // ========================================================
+ // ObjectCopySource
+ // ========================================================
+ class ObjectCopySource : public ICopyTableSourceObject
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xObject;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xObjectPSI;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xObjectColumns;
+
+ public:
+ ObjectCopySource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject
+ );
+
+ // ICopyTableSourceObject overridables
+ virtual ::rtl::OUString getQualifiedObjectName() const;
+ virtual bool isView() const;
+ virtual void copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual void copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getColumnNames() const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getPrimaryKeyColumnNames() const;
+ virtual OFieldDescription* createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
+ virtual ::rtl::OUString getSelectStatement() const;
+ virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
+ getPreparedSelectStatement() const;
+ };
+
+ // ========================================================
+ // NamedTableCopySource
+ // ========================================================
+ class NamedTableCopySource : public ICopyTableSourceObject
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ ::rtl::OUString m_sTableName;
+ ::rtl::OUString m_sTableCatalog;
+ ::rtl::OUString m_sTableSchema;
+ ::rtl::OUString m_sTableBareName;
+ ::std::vector< OFieldDescription > m_aColumnInfo;
+ ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement > m_xStatement;
+
+ public:
+ NamedTableCopySource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::rtl::OUString& _rTableName
+ );
+
+ // ICopyTableSourceObject overridables
+ virtual ::rtl::OUString getQualifiedObjectName() const;
+ virtual bool isView() const;
+ virtual void copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual void copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getColumnNames() const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getPrimaryKeyColumnNames() const;
+ virtual OFieldDescription* createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
+ virtual ::rtl::OUString getSelectStatement() const;
+ virtual ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
+ getPreparedSelectStatement() const;
+
+ private:
+ void impl_ensureColumnInfo_throw();
+ ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XPreparedStatement >
+ impl_ensureStatement_throw();
+ };
+
+ // ========================================================
+ // Wizard Dialog
+ // ========================================================
+ class OCopyTableWizard : public WizardDialog
+ {
+ friend class OWizColumnSelect;
+ friend class OWizTypeSelect;
+ friend class OWizTypeSelectControl;
+ friend class OCopyTable;
+ friend class OWizNameMatching;
+
+ public:
+ DECLARE_STL_MAP(::rtl::OUString,::rtl::OUString,::comphelper::UStringMixLess,TNameMapping);
+
+ enum Wizard_Button_Style
+ {
+ WIZARD_NEXT,
+ WIZARD_PREV,
+ WIZARD_FINISH,
+
+ WIZARD_NONE
+ };
+
+ private:
+ ODatabaseExport::TColumns m_vDestColumns; // contains the columns
+ ODatabaseExport::TColumnVector m_aDestVec; // the order to insert the columns
+ ODatabaseExport::TColumns m_vSourceColumns;
+ ODatabaseExport::TColumnVector m_vSourceVec;
+
+ HelpButton m_pbHelp;
+ CancelButton m_pbCancel;
+ PushButton m_pbPrev;
+ PushButton m_pbNext;
+ OKButton m_pbFinish;
+
+ OTypeInfoMap m_aTypeInfo;
+ ::std::vector<OTypeInfoMap::iterator> m_aTypeInfoIndex;
+ OTypeInfoMap m_aDestTypeInfo;
+ ::std::vector<OTypeInfoMap::iterator> m_aDestTypeInfoIndex;
+ TNameMapping m_mNameMapping;
+
+ ODatabaseExport::TPositions m_vColumnPos;
+ ::std::vector<sal_Int32> m_vColumnTypes;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xDestConnection;
+
+ const ICopyTableSourceObject& m_rSourceObject;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xInteractionHandler;
+
+ String m_sTypeNames; // these type names are the ones out of the resource file
+ sal_uInt32 m_nPageCount;
+ sal_Bool m_bDeleteSourceColumns;
+ bool m_bInterConnectionCopy; // are we copying between different connections?
+
+ ::com::sun::star::lang::Locale m_aLocale;
+ ::rtl::OUString m_sName; // for a table the name is composed
+ ::rtl::OUString m_sSourceName;
+ ::rtl::OUString m_aKeyName;
+ TOTypeInfoSP m_pTypeInfo; // default type
+ sal_Bool m_bAddPKFirstTime;
+ sal_Int16 m_nOperation;
+ Wizard_Button_Style m_ePressed;
+ sal_Bool m_bCreatePrimaryKeyColumn;
+ sal_Bool m_bUseHeaderLine;
+
+ private:
+ DECL_LINK( ImplPrevHdl , PushButton* );
+ DECL_LINK( ImplNextHdl , PushButton* );
+ DECL_LINK( ImplOKHdl , OKButton* );
+ DECL_LINK( ImplActivateHdl, WizardDialog* );
+ sal_Bool CheckColumns(sal_Int32& _rnBreakPos);
+ void loadData( const ICopyTableSourceObject& _rSourceObject,
+ ODatabaseExport::TColumns& _rColumns,
+ ODatabaseExport::TColumnVector& _rColVector );
+ void construct();
+ // need for table creation
+ void appendColumns( ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>& _rxColSup, const ODatabaseExport::TColumnVector* _pVec, sal_Bool _bKeyColumns = sal_False ) const;
+ void appendKey(::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XKeysSupplier>& _rxSup,const ODatabaseExport::TColumnVector* _pVec) const;
+ // checks if the type is supported in the destination database
+ sal_Bool supportsType(sal_Int32 _nDataType,sal_Int32& _rNewDataType);
+
+ void impl_loadSourceData();
+
+ public:
+ // used for copy tables or queries
+ OCopyTableWizard(
+ Window * pParent,
+ const ::rtl::OUString& _rDefaultName,
+ sal_Int16 _nOperation,
+ const ICopyTableSourceObject& _rSourceObject,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xSourceConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler>& _xInteractionHandler
+ );
+
+ // used for importing rtf/html sources
+ OCopyTableWizard(
+ Window* pParent,
+ const ::rtl::OUString& _rDefaultName,
+ sal_Int16 _nOperation,
+ const ODatabaseExport::TColumns& _rDestColumns,
+ const ODatabaseExport::TColumnVector& _rSourceColVec,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _xFormatter,
+ TypeSelectionPageFactory _pTypeSelectionPageFactory,
+ SvStream& _rTypeSelectionPageArg,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM
+ );
+
+ virtual ~OCopyTableWizard();
+
+ virtual long DeactivatePage();
+ OKButton& GetOKButton() { return m_pbFinish; }
+ Wizard_Button_Style GetPressedButton() const { return m_ePressed; }
+ void EnableButton(Wizard_Button_Style eStyle,sal_Bool bEnable);
+ void AddWizardPage(OWizardPage* pPage); // Page wird von OCopyTableWizard gelöscht
+ void RemoveWizardPage(OWizardPage* pPage); // Page goes again to user
+ void CheckButtons(); // checks which button can be disabled, enabled
+
+ // returns a vector where the position of a column and if the column is in the selection
+ // when not the value is COLUMN_POSITION_NOT_FOUND == (sal_uInt32)-1
+ ODatabaseExport::TPositions GetColumnPositions() const { return m_vColumnPos; }
+ ::std::vector<sal_Int32> GetColumnTypes() const { return m_vColumnTypes; }
+ sal_Bool UseHeaderLine() const { return m_bUseHeaderLine; }
+ void setUseHeaderLine(sal_Bool _bUseHeaderLine) { m_bUseHeaderLine = _bUseHeaderLine; }
+
+ void insertColumn(sal_Int32 _nPos,OFieldDescription* _pField);
+
+ /** replaces a field description with another one. The name must not be known so far.
+ @param _nPos
+ The pos inside the vector, 0 based.
+ @param _pField
+ The field to set.
+ @param _sOldName
+ The name of column to be replaced.
+ */
+ void replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,const ::rtl::OUString& _sOldName);
+
+ /** returns whether a primary key should be created in the target database
+ */
+ sal_Bool shouldCreatePrimaryKey() const;
+ void setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName );
+
+ static bool supportsPrimaryKey( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
+ bool supportsPrimaryKey() const { return supportsPrimaryKey( m_xDestConnection ); }
+
+ static bool supportsViews( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
+ bool supportsViews() const { return supportsViews( m_xDestConnection ); }
+
+ /** returns the name of the primary key
+ @return
+ The name of the primary key.
+ */
+ ::rtl::OUString getPrimaryKeyName() const { return m_aKeyName; }
+
+ TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) const { return m_aTypeInfoIndex[_nPos]->second; }
+ const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo; }
+
+ TOTypeInfoSP getDestTypeInfo(sal_Int32 _nPos) const { return m_aDestTypeInfoIndex[_nPos]->second; }
+ const OTypeInfoMap* getDestTypeInfo() const { return &m_aDestTypeInfo; }
+
+ ::com::sun::star::lang::Locale GetLocale() const { return m_aLocale; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const { return m_xFormatter; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> GetFactory() const { return m_xFactory; }
+
+ const ODatabaseExport::TColumns* getSourceColumns() const{ return &m_vSourceColumns; }
+ const ODatabaseExport::TColumnVector* getSrcVector() const { return &m_vSourceVec; }
+ ODatabaseExport::TColumns* getDestColumns() { return &m_vDestColumns; }
+ const ODatabaseExport::TColumnVector* getDestVector() const { return &m_aDestVec; }
+ ::rtl::OUString getName() const { return m_sName; }
+
+ /** clears the dest vectors
+ */
+ void clearDestColumns();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createTable();
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createView() const;
+ sal_Int32 getMaxColumnNameLength() const;
+
+ void setOperation( const sal_Int16 _nOperation );
+ sal_Int16 getOperation() const;
+
+ ::rtl::OUString convertColumnName( const TColumnFindFunctor& _rCmpFunctor,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen);
+ TOTypeInfoSP convertType(const TOTypeInfoSP&_pType,sal_Bool& _bNotConvert);
+
+ ::rtl::OUString createUniqueName(const ::rtl::OUString& _sName);
+
+ // displays a error message that a column type is not supported
+ void showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName);
+
+ void removeColumnNameFromNameMap(const ::rtl::OUString& _sName);
+ void showError(const ::rtl::OUString& _sErrorMesage);
+ void showError(const ::com::sun::star::uno::Any& _aError);
+ };
+}
+
+#endif // DBAUI_WIZ_COPYTABLEDIALOG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WExtendPages.hxx b/dbaccess/source/ui/inc/WExtendPages.hxx
new file mode 100644
index 000000000000..b12578deda6b
--- /dev/null
+++ b/dbaccess/source/ui/inc/WExtendPages.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZ_EXTENDPAGES_HXX
+#define DBAUI_WIZ_EXTENDPAGES_HXX
+
+#include "WTypeSelect.hxx"
+
+class SvStream;
+namespace dbaui
+{
+ // ========================================================
+ // Wizard Page: OWizHTMLExtend
+ // ========================================================
+ class OWizHTMLExtend : public OWizTypeSelect
+ {
+ protected:
+ virtual SvParser* createReader(sal_Int32 _nRows);
+ public:
+ OWizHTMLExtend(Window* pParent, SvStream& _rStream)
+ : OWizTypeSelect( pParent, &_rStream )
+ {
+ }
+
+ static OWizTypeSelect* Create( Window* _pParent, SvStream& _rInput ) { return new OWizHTMLExtend( _pParent, _rInput ); }
+
+ virtual ~OWizHTMLExtend(){}
+ };
+ // ========================================================
+ // Wizard Page: OWizRTFExtend
+ // ========================================================
+ class OWizRTFExtend : public OWizTypeSelect
+ {
+ protected:
+ virtual SvParser* createReader(sal_Int32 _nRows);
+ public:
+ OWizRTFExtend(Window* pParent,SvStream& _rStream)
+ : OWizTypeSelect( pParent, &_rStream )
+ {
+ }
+
+ static OWizTypeSelect* Create( Window* _pParent, SvStream& _rInput ) { return new OWizRTFExtend( _pParent, _rInput ); }
+
+ virtual ~OWizRTFExtend(){}
+ };
+
+ // ========================================================
+ // Wizard Page: OWizNormalExtend
+ // ========================================================
+ class OWizNormalExtend : public OWizTypeSelect
+ {
+ protected:
+ virtual SvParser* createReader(sal_Int32 _nRows);
+ public:
+ OWizNormalExtend(Window* pParent);
+ };
+}
+#endif // DBAUI_WIZ_EXTENDPAGES_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WNameMatch.hxx b/dbaccess/source/ui/inc/WNameMatch.hxx
new file mode 100644
index 000000000000..06d6a76fe655
--- /dev/null
+++ b/dbaccess/source/ui/inc/WNameMatch.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZ_NAMEMATCHING_HXX
+#define DBAUI_WIZ_NAMEMATCHING_HXX
+
+#include "WTabPage.hxx"
+#include "marktree.hxx"
+#include "DExport.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include "WCopyTable.hxx"
+
+namespace dbaui
+{
+ // ========================================================
+ // columns are at root only no children
+ // ========================================================
+ class OColumnTreeBox : public OMarkableTreeListBox
+ {
+ sal_Bool m_bReadOnly;
+ protected:
+ virtual void InitEntry(SvLBoxEntry* pEntry, const String& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind);
+
+ public:
+ OColumnTreeBox( Window* pParent, const ResId& rResId );
+
+ void FillListBox( const ODatabaseExport::TColumnVector& _rList);
+ void SetReadOnly(sal_Bool _bRo=sal_True) { m_bReadOnly = _bRo; }
+ virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
+
+ private:
+ using OMarkableTreeListBox::Select;
+ };
+
+ // ========================================================
+ // Wizard Page: OWizNameMatching
+ // Name matching for data appending
+ // ========================================================
+ class OWizNameMatching : public OWizardPage
+ {
+ FixedText m_FT_TABLE_LEFT;
+ FixedText m_FT_TABLE_RIGHT;
+ OColumnTreeBox m_CTRL_LEFT; // left side
+ OColumnTreeBox m_CTRL_RIGHT; // right side
+ ImageButton m_ibColumn_up;
+ ImageButton m_ibColumn_down;
+ ImageButton m_ibColumn_up_right;
+ ImageButton m_ibColumn_down_right;
+ PushButton m_pbAll;
+ PushButton m_pbNone;
+ String m_sSourceText;
+ String m_sDestText;
+
+ sal_Bool m_bAttrsChanged;
+
+ DECL_LINK( ButtonClickHdl, Button * );
+ DECL_LINK( RightButtonClickHdl, Button * );
+ DECL_LINK( AllNoneClickHdl, Button * );
+ DECL_LINK( TableListClickHdl, void* );
+ DECL_LINK( TableListRightSelectHdl, void* );
+
+ public:
+ virtual void Reset ( );
+ virtual void ActivatePage();
+ virtual sal_Bool LeavePage();
+ virtual String GetTitle() const ;
+
+ OWizNameMatching(Window* pParent);
+ virtual ~OWizNameMatching();
+
+ };
+}
+#endif // DBAUI_WIZ_NAMEMATCHING_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WTabPage.hxx b/dbaccess/source/ui/inc/WTabPage.hxx
new file mode 100644
index 000000000000..d36a4438c554
--- /dev/null
+++ b/dbaccess/source/ui/inc/WTabPage.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_WIZ_TABBPAGE_HXX
+#define DBAUI_WIZ_TABBPAGE_HXX
+
+#include <vcl/tabpage.hxx>
+
+namespace dbaui
+{
+ // ========================================================
+ // Wizard Page
+ // ========================================================
+ class OCopyTableWizard;
+ class OWizardPage : public TabPage
+ {
+ protected:
+ OCopyTableWizard* m_pParent;
+ sal_Bool m_bFirstTime; // Page wird das erste mal gerufen ; should be set in the reset methode
+
+ OWizardPage( Window* pParent, const ResId& rResId );
+
+ public:
+ virtual void Reset ( ) = 0;
+ virtual sal_Bool LeavePage() = 0;
+ virtual String GetTitle() const = 0;
+
+ sal_Bool IsFirstTime() const { return m_bFirstTime; }
+ };
+}
+#endif // DBAUI_WIZ_TABBPAGE_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/WTypeSelect.hxx b/dbaccess/source/ui/inc/WTypeSelect.hxx
new file mode 100644
index 000000000000..ab57648adf90
--- /dev/null
+++ b/dbaccess/source/ui/inc/WTypeSelect.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZ_TYPESELECT_HXX
+#define DBAUI_WIZ_TYPESELECT_HXX
+
+#include "FieldDescControl.hxx"
+#include "TypeInfo.hxx"
+#include "WTabPage.hxx"
+
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+class SvStream;
+class SvParser;
+namespace dbaui
+{
+ class OTableDesignHelpBar;
+ // =============================================================================================
+ // OWizTypeSelectControl
+ // =============================================================================================
+ class OWizTypeSelectControl : public OFieldDescControl
+ {
+ protected:
+ virtual void ActivateAggregate( EControlType eType );
+ virtual void DeactivateAggregate( EControlType eType );
+
+ virtual void CellModified(long nRow, sal_uInt16 nColId );
+
+ virtual ::com::sun::star::lang::Locale GetLocale() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const;
+ virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos);
+ virtual const OTypeInfoMap* getTypeInfo() const;
+ virtual sal_Bool isAutoIncrementValueEnabled() const;
+ virtual ::rtl::OUString getAutoIncrementValue() const;
+
+ public:
+ OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar=NULL);
+ virtual ~OWizTypeSelectControl();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection();
+ };
+
+
+ // ========================================================
+ // Wizard Page: OWizTypeSelectList
+ // definiert nur das ::com::sun::star::ucb::Command f"ur das Contextmenu
+ // ========================================================
+ class OWizTypeSelectList : public MultiListBox
+ {
+ sal_Bool m_bPKey;
+ sal_Bool IsPrimaryKeyAllowed() const;
+ void setPrimaryKey( OFieldDescription* _pFieldDescr,
+ sal_uInt16 _nPos,
+ sal_Bool _bSet=sal_False);
+ protected:
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ public:
+ OWizTypeSelectList( Window* pParent, WinBits nStyle = WB_BORDER ) : MultiListBox(pParent,nStyle) {};
+ OWizTypeSelectList( Window* pParent, const ResId& rResId ) : MultiListBox(pParent,rResId) {};
+ void SetPKey(sal_Bool bPKey) { m_bPKey = bPKey; }
+ };
+
+ // ========================================================
+ // Wizard Page: OWizTypeSelect
+ // Dient als Basis Klasse fuer unterschiedliche Kopiereigenschaften
+ // FillColumnList wird aufgerufen, wenn der Button AUTO ausgeloest wird.
+ // ========================================================
+ class OWizTypeSelect : public OWizardPage
+ {
+ friend class OWizTypeSelectControl;
+ friend class OWizTypeSelectList;
+
+ DECL_LINK( ColumnSelectHdl, MultiListBox* );
+ DECL_LINK( ButtonClickHdl, Button * );
+ protected:
+ OWizTypeSelectList m_lbColumnNames;
+ FixedLine m_flColumns;
+ OWizTypeSelectControl m_aTypeControl;
+ FixedLine m_flAutoType;
+ FixedText m_ftAuto;
+ NumericField m_etAuto;
+ PushButton m_pbAuto;
+
+ Image m_imgPKey;
+ SvStream* m_pParserStream; // stream to read the tokens from or NULL
+ ::rtl::OUString m_sAutoIncrementValue;
+ sal_Int32 m_nDisplayRow;
+ sal_Bool m_bAutoIncrementEnabled;
+ sal_Bool m_bDuplicateName;
+
+ void fillColumnList(sal_uInt32 nRows);
+ virtual SvParser* createReader(sal_Int32 _nRows) = 0;
+
+ void EnableAuto(sal_Bool bEnable);
+ public:
+ virtual void Reset ( );
+ virtual void ActivatePage( );
+ virtual void Resize();
+ virtual sal_Bool LeavePage();
+ virtual String GetTitle() const;
+
+ OWizTypeSelect(Window* pParent, SvStream* _pStream = NULL );
+ virtual ~OWizTypeSelect();
+
+ inline void setDisplayRow(sal_Int32 _nRow) { m_nDisplayRow = _nRow - 1; }
+ inline void setDuplicateName(sal_Bool _bDuplicateName) { m_bDuplicateName = _bDuplicateName; }
+ };
+
+ // ========================================================
+ typedef OWizTypeSelect* (*TypeSelectionPageFactory)( Window*, SvStream& );
+}
+#endif // DBAUI_WIZ_TYPESELECT_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/adtabdlg.hxx b/dbaccess/source/ui/inc/adtabdlg.hxx
new file mode 100644
index 000000000000..d2d7c6d8a98e
--- /dev/null
+++ b/dbaccess/source/ui/inc/adtabdlg.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QYDLGTAB_HXX
+#define DBAUI_QYDLGTAB_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+#include <vcl/lstbox.hxx>
+#include <vcl/dialog.hxx>
+#include <tools/string.hxx>
+
+#include "tabletree.hxx"
+
+#include <memory>
+
+namespace dbaui
+{
+ //========================================================================
+ /** unifies the access to a list of table/query objects
+ */
+ class TableObjectListFacade
+ {
+ public:
+ virtual void updateTableObjectList( bool _bAllowViews ) = 0;
+ virtual String getSelectedName( String& _out_rAliasName ) const = 0;
+ virtual bool isLeafSelected() const = 0;
+
+ virtual ~TableObjectListFacade();
+ };
+
+ //========================================================================
+ class IAddTableDialogContext
+ {
+ public:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getConnection() const = 0;
+ virtual bool allowViews() const = 0;
+ virtual bool allowQueries() const = 0;
+ virtual bool allowAddition() const = 0;
+ virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName ) = 0;
+ virtual void onWindowClosing( const Window* _pWindow ) = 0;
+ };
+
+ //========================================================================
+ class OAddTableDlg : public ModelessDialog
+ {
+ RadioButton m_aCaseTables;
+ RadioButton m_aCaseQueries;
+
+ OTableTreeListBox m_aTableList;
+ SvTreeListBox m_aQueryList;
+ ::std::auto_ptr< TableObjectListFacade >
+ m_pCurrentList;
+
+ PushButton aAddButton;
+ CancelButton aCloseButton;
+ HelpButton aHelpButton;
+
+ IAddTableDialogContext&
+ m_rContext;
+
+ DECL_LINK( AddClickHdl, Button* );
+ DECL_LINK( CloseClickHdl, Button* );
+ DECL_LINK( TableListDoubleClickHdl, void* );
+ DECL_LINK( TableListSelectHdl, void* );
+ DECL_LINK( OnTypeSelected, void* );
+
+ public:
+ OAddTableDlg(
+ Window* _pParent,
+ IAddTableDialogContext& _rContext );
+ virtual ~OAddTableDlg();
+
+ void DetermineAddTable() { aAddButton.Enable( impl_isAddAllowed() ); }
+ void Update();
+
+ static String getDialogTitleForContext(
+ IAddTableDialogContext& _rContext );
+
+ private:
+ virtual sal_Bool Close();
+
+ bool impl_isAddAllowed();
+ void impl_addTable();
+
+ enum ObjectList
+ {
+ Tables,
+ Queries
+ };
+ void impl_switchTo( ObjectList _eList );
+ };
+}
+#endif // DBAUI_QYDLGTAB_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/advancedsettingsdlg.hxx b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx
new file mode 100644
index 000000000000..6afc8f6ddd1c
--- /dev/null
+++ b/dbaccess/source/ui/inc/advancedsettingsdlg.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_ADVANCEDSETTINGSDLG_HXX
+#define DBACCESS_ADVANCEDSETTINGSDLG_HXX
+
+#include "IItemSetHelper.hxx"
+#include "moduledbu.hxx"
+
+ /** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <sfx2/tabdlg.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //=========================================================================
+ //= AdvancedSettingsDialog
+ //=========================================================================
+ class ODbDataSourceAdministrationHelper;
+ /** implements the advanced page dlg of the data source properties.
+ */
+ class AdvancedSettingsDialog :public SfxTabDialog
+ ,public IItemSetHelper
+ ,public IDatabaseSettingsDialog
+ {
+ OModuleClient m_aModuleClient;
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+ SfxItemSet* m_pItemSet;
+
+ protected:
+ virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage);
+
+ public:
+ AdvancedSettingsDialog( Window* _pParent
+ ,SfxItemSet* _pItems
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName);
+
+ virtual ~AdvancedSettingsDialog();
+
+ /// determines whether or not the given data source type has any advanced setting
+ static bool doesHaveAnyAdvancedSettings( const ::rtl::OUString& _sURL );
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ virtual short Execute();
+
+ // forwards to ODbDataSourceAdministrationHelper
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
+ virtual void clearPassword();
+ virtual sal_Bool saveDatasource();
+ virtual void setTitle(const ::rtl::OUString& _sTitle);
+ virtual void enableConfirmSettings( bool _bEnable );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_ADVANCEDSETTINGSDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/asyncmodaldialog.hxx b/dbaccess/source/ui/inc/asyncmodaldialog.hxx
new file mode 100644
index 000000000000..4cdc83d70dfc
--- /dev/null
+++ b/dbaccess/source/ui/inc/asyncmodaldialog.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_ASYNCMODALDIALOG_HXX
+#define DBACCESS_ASYNCMODALDIALOG_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= AsyncDialogExecutor
+ //====================================================================
+ /** helper class for executing (UNO) dialogs modal, but asynchronously
+ */
+ class AsyncDialogExecutor
+ {
+ public:
+ /** executes the given dialog asynchronously, but still modal
+
+ @raises IllegalArgumentException
+ if the given dialog is <NULL/>
+ @todo
+ allow for a callback for the result
+ */
+ static void executeModalDialogAsync(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XExecutableDialog >& _rxDialog
+ );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_ASYNCMODALDIALOG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/browserids.hxx b/dbaccess/source/ui/inc/browserids.hxx
new file mode 100644
index 000000000000..7bd5a7c67171
--- /dev/null
+++ b/dbaccess/source/ui/inc/browserids.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#define DBACCESS_UI_BROWSER_ID_HXX
+
+#include <svx/svxids.hrc>
+#include "dbaccess_slotid.hrc"
+
+#define ID_BROWSER_COPY SID_COPY
+#define ID_BROWSER_CUT SID_CUT
+#define ID_BROWSER_EDITDOC SID_EDITDOC
+#define ID_BROWSER_UNDORECORD SID_FM_RECORD_UNDO
+#define ID_BROWSER_SAVERECORD SID_FM_RECORD_SAVE
+#define ID_BROWSER_PASTE SID_PASTE
+#define ID_BROWSER_CLIPBOARD_FORMAT_ITEMS SID_CLIPBOARD_FORMAT_ITEMS
+#define ID_BROWSER_REDO SID_REDO
+#define ID_BROWSER_SAVEDOC SID_SAVEDOC
+#define ID_BROWSER_SAVEASDOC SID_SAVEASDOC
+#define ID_BROWSER_TITLE SID_DOCINFO_TITLE
+#define ID_BROWSER_UNDO SID_UNDO
+#define ID_BROWSER_INSERTCOLUMNS SID_SBA_BRW_INSERT
+#define ID_BROWSER_FORMLETTER SID_SBA_BRW_MERGE
+#define ID_BROWSER_INSERTCONTENT SID_SBA_BRW_UPDATE
+
+#define ID_BROWSER_SEARCH SID_FM_SEARCH
+#define ID_BROWSER_SORTUP SID_FM_SORTUP
+#define ID_BROWSER_SORTDOWN SID_FM_SORTDOWN
+#define ID_BROWSER_AUTOFILTER SID_FM_AUTOFILTER
+#define ID_BROWSER_FILTERCRIT SID_FM_FILTERCRIT
+#define ID_BROWSER_ORDERCRIT SID_FM_ORDERCRIT
+#define ID_BROWSER_REMOVEFILTER SID_FM_REMOVE_FILTER_SORT
+#define ID_BROWSER_FILTERED SID_FM_FORM_FILTERED
+#define ID_BROWSER_REFRESH SID_FM_REFRESH
+#define ID_BROWSER_EXPL_PREVLEVEL SID_EXPLORER_PREVLEVEL
+#define ID_BROWSER_COLATTRSET 20 // Spaltenformatierung
+#define ID_BROWSER_COLWIDTH 21 // Spaltenbreite
+#define ID_BROWSER_TABLEATTR 22 // table format attributes
+#define ID_BROWSER_ROWHEIGHT 23 // Zeilenhoehe
+#define ID_BROWSER_COLUMNINFO 24 // copies the column description to insert it into the table design
+#define ID_BROWSER_COUNTALL SID_FM_COUNTALL // count all
+#define ID_BROWSER_ADDTABLE SID_FM_ADDTABLE
+#define ID_BROWSER_EXPLORER SID_DSBROWSER_EXPLORER
+#define ID_BROWSER_DOCUMENT_DATASOURCE SID_DOCUMENT_DATA_SOURCE
+
+// The following ids are local to special components (e.g. menus), so they don't need to be unique
+// overall. Please have this in mind when changing anything
+#define ID_TREE_EDIT_DATABASE 1
+#define ID_TREE_CLOSE_CONN 2
+ // FREE
+#define ID_TREE_ADMINISTRATE 4
+#define ID_MIGRATE_SCRIPTS 5
+
+#define ID_REPORT_NEW_TEXT 14
+#define ID_FORM_NEW_TEXT 15
+#define ID_FORM_NEW_CALC 16
+#define ID_FORM_NEW_IMPRESS 17
+#define ID_NEW_QUERY_DESIGN 20
+#define ID_EDIT_QUERY_DESIGN 21
+#define ID_NEW_QUERY_SQL 22
+#define ID_EDIT_QUERY_SQL 23
+#define ID_NEW_TABLE_DESIGN 25
+#define ID_NEW_VIEW_DESIGN 28
+#define ID_DIRECT_SQL 32
+#define ID_BROWSER_REFRESH_REBUILD 34
+#define ID_INDEX_NEW 36
+#define ID_INDEX_DROP 37
+#define ID_INDEX_RENAME 38
+#define ID_INDEX_SAVE 39
+#define ID_INDEX_RESET 40
+#define ID_DOCUMENT_CREATE_REPWIZ 41
+#define ID_BROWSER_SQL 42
+
+#define ID_APP_NEW_QUERY_AUTO_PILOT 44
+#define ID_NEW_TABLE_DESIGN_AUTO_PILOT 45
+#define ID_NEW_VIEW_DESIGN_AUTO_PILOT 46
+
+
+// other
+#define ID_BROWSER_QUERY_EXECUTE SID_FM_EXECUTE
+
+#define ID_BROWSER_CLOSE SID_CLOSEWIN
+#define ID_BROWSER_ESACPEPROCESSING SID_FM_NATIVESQL
+
+#define ID_QUERY_FUNCTION (SID_SBA_START + 41) // Funktionen anzeigen
+#define ID_QUERY_TABLENAME (SID_SBA_START + 42) // Tabellennamen anzeigen
+#define ID_QUERY_ALIASNAME (SID_SBA_START + 43) // Aliasnamen anzeigen
+#define ID_QUERY_DISTINCT (SID_SBA_START + 44) // Distinct anzeigen
+#define ID_QUERY_EDIT_JOINCONNECTION (SID_SBA_START + 45) // show-edit Join
+#define ID_BROWSER_INSERT_ROW (SID_SBA_START + 46) // insert row
+#define ID_QUERY_ZOOM_IN SID_ZOOM_IN
+#define ID_QUERY_ZOOM_OUT SID_ZOOM_OUT
+
+
+#endif // DBACCESS_UI_BROWSER_ID_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/brwctrlr.hxx b/dbaccess/source/ui/inc/brwctrlr.hxx
new file mode 100644
index 000000000000..47c510a68840
--- /dev/null
+++ b/dbaccess/source/ui/inc/brwctrlr.hxx
@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_BWRCTRLR_HXX
+#define _SBA_BWRCTRLR_HXX
+
+#include "genericcontroller.hxx"
+#include "moduledbu.hxx"
+#include "brwview.hxx"
+#include "sbagrid.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/form/XResetListener.hpp>
+#include <com/sun/star/form/XDatabaseParameterListener.hpp>
+#include <com/sun/star/form/XConfirmDeleteListener.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/frame/XModule.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/timer.hxx>
+#include <svtools/transfer.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+#include <cppuhelper/implbase9.hxx>
+#include <svtools/cliplistener.hxx>
+
+class ResMgr;
+struct FmFoundRecordInformation;
+struct FmSearchContext;
+
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
+
+namespace dbaui
+{
+ // =========================================================================
+
+ typedef ::cppu::ImplInheritanceHelper9 < OGenericUnoController
+ , ::com::sun::star::sdb::XSQLErrorListener
+ , ::com::sun::star::form::XDatabaseParameterListener
+ , ::com::sun::star::form::XConfirmDeleteListener
+ , ::com::sun::star::form::XLoadListener
+ , ::com::sun::star::form::XResetListener
+ , ::com::sun::star::awt::XFocusListener
+ , ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::frame::XModule
+ > SbaXDataBrowserController_Base;
+
+ class SbaXDataBrowserController :public SbaXDataBrowserController_Base
+ ,public SbaGridListener
+ {
+ // ==========
+ // attributes
+ private:
+ // for implementing the XFormController
+ class FormControllerImpl;
+ friend class FormControllerImpl;
+ OModuleClient m_aModuleClient;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; // our rowset
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > m_xColumnsSupplier; // queried from the rowset member
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xLoadable; // queried from the rowset member as well
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > m_xGridModel; // the model of our grid
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xFormControllerImpl;
+ mutable ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >
+ m_xParser; // for sorting 'n filtering
+
+ sal_Int32 m_nRowSetPrivileges; // cached Privileges property of m_xRowSet
+
+ AutoTimer m_aInvalidateClipboard; // for testing the state of the CUT/COPY/PASTE-slots
+
+ TransferableDataHelper m_aSystemClipboard; // content of the clipboard
+ TransferableClipboardListener*
+ m_pClipbordNotifier; // notifier for changes in the clipboard
+
+ ::osl::Mutex m_aAsyncLoadSafety; // for multi-thread access to our members
+
+ OAsyncronousLink m_aAsyncGetCellFocus;
+ OAsyncronousLink m_aAsyncDisplayError;
+ ::dbtools::SQLExceptionInfo m_aCurrentError;
+
+ String m_sStateSaveRecord;
+ String m_sStateUndoRecord;
+ ::rtl::OUString m_sModuleIdentifier;
+
+ // members for asynchronous load operations
+ FormControllerImpl* m_pFormControllerImpl; // implementing the XFormController
+
+ sal_uLong m_nPendingLoadFinished; // the event used to tell ourself that the load is finished
+ sal_uInt16 m_nFormActionNestingLevel; // see enter-/leaveFormAction
+
+ sal_Bool m_bLoadCanceled : 1; // the load was canceled somehow
+ sal_Bool m_bClosingKillOpen : 1; // are we killing the load thread because we are to be suspended ?
+ bool m_bCannotSelectUnfiltered : 1; // recieved an DATA_CANNOT_SELECT_UNFILTERED error
+
+ protected:
+ class FormErrorHelper
+ {
+ SbaXDataBrowserController* m_pOwner;
+ public:
+ FormErrorHelper(SbaXDataBrowserController* pOwner) : m_pOwner(pOwner) { m_pOwner->enterFormAction(); }
+ virtual ~FormErrorHelper() { m_pOwner->leaveFormAction(); }
+ };
+ friend class FormErrorHelper;
+
+ // ================
+ // attribute access
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > getRowSet() const { return m_xRowSet; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier > getColumnsSupplier()const { return m_xColumnsSupplier; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > getLoadable() const { return m_xLoadable; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > getFormComponent() const { return m_xGridModel; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > getControlModel() const { return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > (m_xGridModel, ::com::sun::star::uno::UNO_QUERY); }
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > getNumberFormatter()const { return m_xFormatter; }
+
+ sal_Bool isValid() const { return m_xRowSet.is() && m_xGridModel.is(); }
+ sal_Bool isValidCursor() const; // checks the ::com::sun::star::data::XDatabaseCursor-interface of m_xRowSet
+ sal_Bool isLoaded() const;
+ sal_Bool loadingCancelled() const { return m_bLoadCanceled; }
+ void onStartLoading( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable );
+ void setLoadingCancelled() { m_bLoadCanceled = sal_True; }
+
+ const TransferableDataHelper&
+ getViewClipboard() const { return m_aSystemClipboard; }
+
+ public:
+ SbaXDataBrowserController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ UnoDataBrowserView* getBrowserView() const { return static_cast< UnoDataBrowserView*>(getView()); }
+ // late construction
+ virtual sal_Bool Construct(Window* pParent);
+
+ // UNO
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::util::XModifyListener
+ virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XModule
+ virtual void SAL_CALL setIdentifier( const ::rtl::OUString& Identifier ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getIdentifier( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::awt::XFocusListener
+ virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::frame::XController
+ virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+
+ // ::com::sun::star::frame::XFrameActionListener
+ virtual void SAL_CALL frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::sdb::XSQLErrorListener
+ virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::form::XDatabaseParameterListener
+ virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::form::XConfirmDeleteListener
+ virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::form::XLoadListener
+ virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::form::XResetListener
+ virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // SbaGridListener
+ virtual void RowChanged();
+ virtual void ColumnChanged();
+ virtual void SelectionChanged();
+ virtual void CellActivated();
+ virtual void CellDeactivated();
+ virtual void BeforeDrop();
+ virtual void AfterDrop();
+
+ public:
+
+ protected:
+ virtual ~SbaXDataBrowserController();
+
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ virtual void startFrameListening( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame );
+ virtual void stopFrameListening( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > CreateForm();
+ // our default implementation simply instantiates a stardiv.one.form.component.Form service
+ // (probably this needs not to be overloaded, but you may return anything you want as long as it
+ // supports the ::com::sun::star::form::DatabaseForm service. For instance you may want to create an adapter here which
+ // is synchronized with a foreign ::com::sun::star::form::DatabaseForm you got elsewhere)
+ virtual sal_Bool InitializeForm(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties ) = 0;
+ // called immediately after a successfull CreateForm
+ // do any initialization (data source etc.) here. the form should be fully functional after that.
+ // return sal_False if you didn't succeed (don't throw exceptions, they won't be caught)
+
+ virtual sal_Bool InitializeGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
+
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > CreateGridModel();
+ // our default implementation simply instantiates a stardiv.one.form.component.Grid service
+ // you most probably don't want to override this behaviuor
+
+ // the default implementation of disposing distributes the events to the following disposingXXX functions
+ virtual void disposingGridControl(const ::com::sun::star::lang::EventObject& Source); // calls removeControlListeners
+ virtual void disposingGridModel(const ::com::sun::star::lang::EventObject& Source); // calls removeModelListeners
+ virtual void disposingFormModel(const ::com::sun::star::lang::EventObject& Source);
+ virtual void disposingColumnModel(const ::com::sun::star::lang::EventObject& Source);
+
+ // want to be a listener to the grid control ? use this !
+ virtual void addControlListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > & _xGridControl);
+ virtual void removeControlListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > & _xGridControl);
+
+ // want to be a listener to the grid model ? use this !
+ virtual void addModelListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
+ virtual void removeModelListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
+
+ // want to be a listener grid columns ? use this !
+ virtual void AddColumnListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol);
+ virtual void RemoveColumnListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol);
+
+
+ // call after "major changes" (e.g. the completion of the async load).
+ // invalidates all toolbox slots and all supported features.
+
+ virtual sal_Bool LoadForm();
+ // load the form
+ // the default implementation does an direct load or starts a load thread, depending on the multithread capabilities
+ // of the data source.
+ // the default implementation also calls LoadFinished after a syncronous load, so be sure to do the same if you override
+ // this metod and don't call the base class' method
+
+ virtual void LoadFinished(sal_Bool bWasSynch);
+ // called if the loading (the _complete_ loading process) is done (no matter if synchron or asynchron).
+
+ virtual void criticalFail();
+ // called whenever a reload operation on the rowset failed
+ // (a "operation" is not only a simple reload: If the user sets a filter, an reloading the form
+ // after setting this filter fails, the filter is reset and the form is reloaded, again. Only the
+ // whole process (_both_ XLoadable::reload calls _together_) form the "reload operation"
+
+ // --------------------
+
+ // empty the frame where our view resides
+ virtual sal_Bool CommitCurrent();
+ // commit the current column (i.e. cell)
+ virtual sal_Bool SaveModified(sal_Bool bAskFor = sal_True);
+ // save the modified record
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getBoundField(sal_uInt16 nViewPos = (sal_uInt16)-1) const;
+ // a PropertySet corresponding to the cursor field a column is bound to
+ // if nViewPos is (sal_uInt16)-1 (the default) then the field for the current column will be retrieved
+
+ void enterFormAction();
+ void leaveFormAction();
+
+ // init the formatter if form changes
+ void initFormatter();
+
+ /// loads or reloads the form
+ virtual sal_Bool reloadForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable);
+
+ virtual sal_Bool preReloadForm(){ return sal_False; }
+ virtual void postReloadForm(){}
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >
+ createParser_nothrow();
+
+ private:
+ void setCurrentModified( sal_Bool _bSet );
+
+ // execute the filter or sort slot
+ void ExecuteFilterSortCrit(sal_Bool bFilter);
+
+ // execute the search slot
+ void ExecuteSearch();
+
+ void initializeParser() const; // changes the mutable member m_xParser
+ void applyParserFilter(const ::rtl::OUString& _rOldFilter, sal_Bool _bOldFilterApplied,const ::rtl::OUString& _sOldHaving,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser);
+ void applyParserOrder(const ::rtl::OUString& _rOldOrder,const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xParser);
+
+ sal_Int16 getCurrentColumnPosition();
+ void setCurrentColumnPosition( sal_Int16 _nPos );
+ void addColumnListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
+
+ void impl_checkForCannotSelectUnfiltered( const ::dbtools::SQLExceptionInfo& _rError );
+
+ // time to check the CUT/COPY/PASTE-slot-states
+ DECL_LINK( OnInvalidateClipboard, AutoTimer* );
+ DECL_LINK( OnClipboardChanged, void* );
+
+ // search callbacks
+ DECL_LINK(OnSearchContextRequest, FmSearchContext*);
+ DECL_LINK(OnFoundData, FmFoundRecordInformation*);
+ DECL_LINK(OnCanceledNotFound, FmFoundRecordInformation*);
+
+ DECL_LINK(OnAsyncGetCellFocus, void*);
+
+ DECL_LINK( OnAsyncDisplayError, void* );
+ };
+}
+
+#endif // _SBA_BWRCTRLR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/brwview.hxx b/dbaccess/source/ui/inc/brwview.hxx
new file mode 100644
index 000000000000..b73016ea34e8
--- /dev/null
+++ b/dbaccess/source/ui/inc/brwview.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBX_BRWVIEW_HXX
+#define _SBX_BRWVIEW_HXX
+
+#include <vcl/window.hxx>
+
+#include <tools/resid.hxx>
+
+#include <com/sun/star/awt/PosSize.hpp>
+#include "dataview.hxx"
+#include <unotools/eventlisteneradapter.hxx>
+
+
+namespace com { namespace sun { namespace star { namespace awt {
+ class XControl;
+ class XControlContainer;
+ class XControlModel;
+}}}}
+
+// =========================================================================
+class ResMgr;
+class Splitter;
+
+namespace dbaui
+{
+ class DBTreeView;
+ class SbaGridControl;
+
+ class UnoDataBrowserView : public ODataView, public ::utl::OEventListenerAdapter
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xGrid; // our grid's UNO representation
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xMe; // our own UNO representation
+ DBTreeView* m_pTreeView;
+ Splitter* m_pSplitter;
+ mutable SbaGridControl* m_pVclControl; // our grid's VCL representation
+ Window* m_pStatus;
+
+ DECL_LINK( SplitHdl, void* );
+ // attribute access
+ public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > getGridControl() const { return m_xGrid; }
+ SbaGridControl* getVclControl() const;
+
+ public:
+ UnoDataBrowserView( Window* pParent,
+ IController& _rController,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~UnoDataBrowserView();
+
+ /// late construction
+ virtual void Construct(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xModel);
+
+ /** as columns may be hidden there is a difference between a columns model pos and its view pos
+ so we you may use these translation function
+ */
+ sal_uInt16 View2ModelPos(sal_uInt16 nPos) const;
+ /// for the same reason the view column count isn't the same as the model column count
+
+ void setSplitter(Splitter* _pSplitter);
+ void setTreeView(DBTreeView* _pTreeView);
+
+ void showStatus( const String& _rStatus );
+ void hideStatus();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getContainer() { return m_xMe; }
+
+ protected:
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+ virtual void resizeDocumentView(Rectangle& rRect);
+ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
+
+ private:
+ using ODataView::Construct;
+ };
+
+ class BrowserViewStatusDisplay
+ {
+ protected:
+ UnoDataBrowserView* m_pView;
+
+ public:
+ BrowserViewStatusDisplay( UnoDataBrowserView* _pView, const String& _rStatus );
+ ~BrowserViewStatusDisplay( );
+ };
+}
+#endif // _SBX_BRWVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/callbacks.hxx b/dbaccess/source/ui/inc/callbacks.hxx
new file mode 100644
index 000000000000..355e8faafcad
--- /dev/null
+++ b/dbaccess/source/ui/inc/callbacks.hxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#define _DBACCESS_UI_CALLBACKS_HXX_
+
+#include <sot/exchange.hxx>
+#include <sot/formats.hxx>
+#include <com/sun/star/container/XContainer.hpp>
+
+class CommandEvent;
+class SvLBoxEntry;
+class String;
+class Point;
+class PopupMenu;
+class Control;
+struct AcceptDropEvent;
+struct ExecuteDropEvent;
+
+namespace cppu { class OInterfaceContainerHelper; }
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ class IController;
+ //====================================================================
+ //= IControlActionListener
+ //====================================================================
+ class SAL_NO_VTABLE IControlActionListener
+ {
+ public:
+ /** requests a quick help text to display
+ @return <FALSE/> if the default quick help text should be used
+ */
+ virtual sal_Bool requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const = 0;
+
+ /** handler for StartDrag requests
+ @return <TRUE/> if a drag operation was started
+ */
+ virtual sal_Bool requestDrag( sal_Int8 _nAction, const Point& _rPosPixel ) = 0;
+
+ /** check whether or not a drop request should be accepted
+ */
+ virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ) = 0;
+
+ /** execute a drop request
+ */
+ virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ) = 0;
+ };
+
+ //====================================================================
+ //= IContextMenuProvider
+ //====================================================================
+ class SAL_NO_VTABLE IContextMenuProvider
+ {
+ public:
+ /** returns the context menu for the control
+
+ Note that the menu does not need to care for the controls selection, or its
+ state in general.
+ The control itself will, using the controller provided by getCommandController,
+ disable menu entries as needed.
+ */
+ virtual PopupMenu* getContextMenu( Control& _rControl ) const = 0;
+
+ /** returns the controller which is responsible for providing states of certain features,
+ and executing them.
+ */
+ virtual IController& getCommandController() = 0;
+
+ /** returns the container of registered context menu interceptors, or NULL if the implementation
+ does not support context menu interception
+ */
+ virtual ::cppu::OInterfaceContainerHelper*
+ getContextMenuInterceptors() = 0;
+
+ /** returns the current selection in the given control
+
+ This selection is used for filling a ContextMenuExecuteEvent event for the given
+ control.
+ */
+ virtual ::com::sun::star::uno::Any
+ getCurrentSelection( Control& _rControl ) const = 0;
+ };
+
+ //====================================================================
+ //= IDragTransferableListener
+ //====================================================================
+ class SAL_NO_VTABLE IDragTransferableListener
+ {
+ public:
+ /// called when a drag operation done with a Transferable has been finished
+ virtual void dragFinished( ) = 0;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // _DBACCESS_UI_CALLBACKS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/charsetlistbox.hxx b/dbaccess/source/ui/inc/charsetlistbox.hxx
new file mode 100644
index 000000000000..c0fde800c2e4
--- /dev/null
+++ b/dbaccess/source/ui/inc/charsetlistbox.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef CHARSETLISTBOX_HXX
+#define CHARSETLISTBOX_HXX
+
+#include "charsets.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/lstbox.hxx>
+
+class SfxItemSet;
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= CharSetListBox
+ //====================================================================
+ class CharSetListBox : public ListBox
+ {
+ public:
+ CharSetListBox( Window* _pParent, const ResId& _rResId );
+ ~CharSetListBox();
+
+ void SelectEntryByIanaName( const String& _rIanaName );
+ bool StoreSelectedCharSet( SfxItemSet& _rSet, const sal_uInt16 _nItemId );
+
+ private:
+ OCharsetDisplay m_aCharSets;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // CHARSETLISTBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/charsets.hxx b/dbaccess/source/ui/inc/charsets.hxx
new file mode 100644
index 000000000000..f5f51690178c
--- /dev/null
+++ b/dbaccess/source/ui/inc/charsets.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_CHARSETS_HXX_
+#define _DBAUI_CHARSETS_HXX_
+
+#include <tools/string.hxx>
+#include <tools/rc.hxx>
+#include <connectivity/dbcharset.hxx>
+#include <svx/txenctab.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=========================================================================
+ //= OCharsetDisplay
+ //=========================================================================
+ typedef ::dbtools::OCharsetMap OCharsetDisplay_Base;
+ class OCharsetDisplay
+ :protected OCharsetDisplay_Base
+ ,protected SvxTextEncodingTable
+ {
+ protected:
+ ::rtl::OUString m_aSystemDisplayName;
+
+ public:
+ class ExtendedCharsetIterator;
+ friend class OCharsetDisplay::ExtendedCharsetIterator;
+
+ typedef ExtendedCharsetIterator iterator;
+ typedef ExtendedCharsetIterator const_iterator;
+
+ OCharsetDisplay();
+
+ // various find operations
+ const_iterator findEncoding(const rtl_TextEncoding _eEncoding) const;
+ const_iterator findIanaName(const ::rtl::OUString& _rIanaName) const;
+ const_iterator findDisplayName(const ::rtl::OUString& _rDisplayName) const;
+
+ /// get access to the first element of the charset collection
+ const_iterator begin() const;
+ /// get access to the (last + 1st) element of the charset collection
+ const_iterator end() const;
+ // size of the map
+ sal_Int32 size() const { return OCharsetDisplay_Base::size(); }
+
+ protected:
+ virtual sal_Bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const;
+
+ private:
+ using OCharsetDisplay_Base::find;
+ };
+
+ //-------------------------------------------------------------------------
+ //- CharsetDisplayDerefHelper
+ //-------------------------------------------------------------------------
+ typedef ::dbtools::CharsetIteratorDerefHelper CharsetDisplayDerefHelper_Base;
+ class CharsetDisplayDerefHelper : protected CharsetDisplayDerefHelper_Base
+ {
+ friend class OCharsetDisplay::ExtendedCharsetIterator;
+
+ ::rtl::OUString m_sDisplayName;
+
+ public:
+ CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource);
+
+ rtl_TextEncoding getEncoding() const { return CharsetDisplayDerefHelper_Base::getEncoding(); }
+ ::rtl::OUString getIanaName() const { return CharsetDisplayDerefHelper_Base::getIanaName(); }
+ ::rtl::OUString getDisplayName() const { return m_sDisplayName; }
+
+ protected:
+ CharsetDisplayDerefHelper(const ::dbtools::CharsetIteratorDerefHelper& _rBase, const ::rtl::OUString& _rDisplayName);
+ };
+
+ //-------------------------------------------------------------------------
+ //- OCharsetDisplay::ExtendedCharsetIterator
+ //-------------------------------------------------------------------------
+ class OCharsetDisplay::ExtendedCharsetIterator
+ {
+ friend class OCharsetDisplay;
+
+ friend bool operator==(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs);
+ friend bool operator!=(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs) { return !(lhs == rhs); }
+
+ typedef ::dbtools::OCharsetMap container;
+ typedef container::CharsetIterator base_iterator;
+
+ protected:
+ const OCharsetDisplay* m_pContainer;
+ base_iterator m_aPosition;
+
+ public:
+ ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource);
+
+ CharsetDisplayDerefHelper operator*() const;
+
+ /// prefix increment
+ const ExtendedCharsetIterator& operator++();
+ /// postfix increment
+ const ExtendedCharsetIterator operator++(int) { ExtendedCharsetIterator hold(*this); ++*this; return hold; }
+
+ /// prefix decrement
+ const ExtendedCharsetIterator& operator--();
+ /// postfix decrement
+ const ExtendedCharsetIterator operator--(int) { ExtendedCharsetIterator hold(*this); --*this; return hold; }
+
+ protected:
+ ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition );
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_CHARSETS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/commontypes.hxx b/dbaccess/source/ui/inc/commontypes.hxx
new file mode 100644
index 000000000000..4fde4f6d1b38
--- /dev/null
+++ b/dbaccess/source/ui/inc/commontypes.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#define _DBAUI_COMMON_TYPES_HXX_
+
+#include <comphelper/stl_types.hxx>
+#include <unotools/sharedunocomponent.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace sdbc {
+ class XConnection;
+ }
+} } }
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ DECLARE_STL_STDKEY_SET( ::rtl::OUString, StringBag );
+ DECLARE_STL_VECTOR( sal_Int8, ByteVector );
+ DECLARE_STL_VECTOR( ::rtl::OUString, StringArray );
+
+ typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_COMMON_TYPES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/curledit.hxx b/dbaccess/source/ui/inc/curledit.hxx
new file mode 100644
index 000000000000..1257cf31f4f1
--- /dev/null
+++ b/dbaccess/source/ui/inc/curledit.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_CURLEDIT_HXX_
+#define _DBAUI_CURLEDIT_HXX_
+
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include "dsntypes.hxx"
+#include <memory>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OConnectionURLEdit
+//=========================================================================
+/** an edit control which may be used to edit connection URLs like
+ "sdbc:odbc:" or "jdbc:". It prevents the user from editing this prefix,
+ though it is normally shown.
+*/
+class OConnectionURLEdit : public Edit
+{
+ ::dbaccess::ODsnTypeCollection*
+ m_pTypeCollection;
+ FixedText* m_pForcedPrefix;
+ String m_sSaveValueNoPrefix;
+ sal_Bool m_bShowPrefix; // when <TRUE> the prefix will be visible, otherwise not
+
+public:
+ OConnectionURLEdit(Window* pParent, const ResId& rResId,sal_Bool _bShowPrefix = sal_False);
+ ~OConnectionURLEdit();
+
+public:
+ // Edit overridables
+ virtual void SetText(const String& _rStr);
+ virtual void SetText(const String& _rStr, const Selection& _rNewSelection);
+ virtual String GetText() const;
+
+
+ /** Showsthe Prefix
+ @param _bShowPrefix
+ If <TRUE/> than the prefix will be visible, otherwise not.
+ */
+ void ShowPrefix(sal_Bool _bShowPrefix);
+ /// get the currently set text, excluding the prefix indicating the type
+ virtual String GetTextNoPrefix() const;
+ /// set a new text, leave the current prefix unchanged
+ virtual void SetTextNoPrefix(const String& _rText);
+
+ inline void SaveValueNoPrefix() { m_sSaveValueNoPrefix = GetTextNoPrefix(); }
+ inline String GetSavedValueNoPrefix() const { return m_sSaveValueNoPrefix; }
+ inline void SetTypeCollection(::dbaccess::ODsnTypeCollection* _pTypeCollection) { m_pTypeCollection = _pTypeCollection; }
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_CURLEDIT_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/databaseobjectview.hxx b/dbaccess/source/ui/inc/databaseobjectview.hxx
new file mode 100644
index 000000000000..97659f454888
--- /dev/null
+++ b/dbaccess/source/ui/inc/databaseobjectview.hxx
@@ -0,0 +1,264 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_DATABASE_OBJECT_VIEW_HXX
+#define DBACCESS_DATABASE_OBJECT_VIEW_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+ /** encapsulates access to the view of a database object.
+
+ @todo
+ this is to be merged with the OLinkedDocumentAccess class
+ */
+ class DatabaseObjectView
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ m_xParentFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XComponentLoader >
+ m_xFrameLoader;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
+ m_xApplication;
+ ::rtl::OUString m_sComponentURL;
+
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ doDispatch(
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs
+ );
+
+ protected:
+ /** creates the desired view
+
+ The default implementation will call <member>fillDispatchArgs</member>, followed
+ by <member>doDispatch</member>.
+
+ @param _rDataSource
+ the data source, as passed to the <member>createNew</member> or <member>openExisting</member> method.
+ @param _rObjectName
+ the name of the object for which the view is to be opened,
+ or an empty string if a view for a new object should be created.
+ @param _rCreationArgs
+ the arguments for the view's creation
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView(
+ const ::com::sun::star::uno::Any& _rDataSource,
+ const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs
+ );
+
+ virtual void fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const ::com::sun::star::uno::Any& _rDataSource,
+ const ::rtl::OUString& _rObjectName
+ );
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >&
+ getApplicationUI() const { return m_xApplication; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getConnection() const;
+
+ public:
+ DatabaseObjectView(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
+ const ::rtl::OUString& _rComponentURL
+ );
+ virtual ~DatabaseObjectView(){}
+
+ /** sets the target frame into which the view should be loaded.
+
+ By default, the view is loaded into a top-level frame not being part of the
+ Desktop.
+ */
+ void setTargetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame )
+ {
+ m_xFrameLoader.set( _rxFrame, ::com::sun::star::uno::UNO_QUERY );
+ }
+
+ /** opens a view for a to-be-created object
+
+ @param _xDataSource
+ the data source for which a new object is to be created
+ @return
+ the controller of the newly created document
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ createNew(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _xDataSource,
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs = ::comphelper::NamedValueCollection()
+ );
+
+ /** opens a view for an existent object
+
+ @param _xDataSource
+ the data source for which a new object is to be created
+ @param _rObjectName
+ the name of the object to be edited
+ @param _rArgs
+ Additional settings which should be forwarded to the frame
+ @return
+ the frame into which the view has been loaded
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ openExisting(
+ const ::com::sun::star::uno::Any& _aDataSource,
+ const ::rtl::OUString& _rName,
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs
+ );
+ };
+
+ //======================================================================
+ //= QueryDesigner
+ //======================================================================
+ class QueryDesigner : public DatabaseObjectView
+ {
+ protected:
+ sal_Int32 m_nCommandType;
+
+ protected:
+ virtual void fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const ::com::sun::star::uno::Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName
+ );
+
+ public:
+ QueryDesigner(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
+ bool _bCreateView
+ );
+ };
+
+ //======================================================================
+ //= TableDesigner
+ //======================================================================
+ class TableDesigner : public DatabaseObjectView
+ {
+ protected:
+ virtual void fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const ::com::sun::star::uno::Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName
+ );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > doCreateView(
+ const ::com::sun::star::uno::Any& _rDataSource,
+ const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs
+ );
+
+ public:
+ TableDesigner(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame
+ );
+
+ private:
+ /** retrieves the table designer component as provided by the connection, if any
+ @param _rTableName
+ the name of the table for which a designer is to be obtained
+ @return
+ the designer component, as provided by the connection, or <NULL/>, if the connection
+ does not provide a specialized designer.
+ @see com::sun::star::sdb::application::XTableUIProvider
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ impl_getConnectionProvidedDesigner_nothrow( const ::rtl::OUString& _rTableName );
+ };
+
+ //======================================================================
+ //= ResultSetBrowser
+ //======================================================================
+ class ResultSetBrowser : public DatabaseObjectView
+ {
+ private:
+ sal_Bool m_bTable;
+
+ protected:
+ virtual void fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const ::com::sun::star::uno::Any& _aDataSource,
+ const ::rtl::OUString& _rQualifiedName
+ );
+
+ public:
+ ResultSetBrowser(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame,
+ sal_Bool _bTable
+ );
+
+ };
+ //======================================================================
+ //= RelationDesigner
+ //======================================================================
+ class RelationDesigner : public DatabaseObjectView
+ {
+ public:
+ RelationDesigner(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& _rxApplication,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxParentFrame
+ );
+ };
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+#endif // DBACCESS_DATABASE_OBJECT_VIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/datasourceconnector.hxx b/dbaccess/source/ui/inc/datasourceconnector.hxx
new file mode 100644
index 000000000000..cb2842591dd6
--- /dev/null
+++ b/dbaccess/source/ui/inc/datasourceconnector.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DATASOURCECONNECTOR_HXX_
+#define _DBAUI_DATASOURCECONNECTOR_HXX_
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
+
+class Window;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=====================================================================
+ //= ODatasourceConnector
+ //=====================================================================
+ class ODatasourceConnector
+ {
+ protected:
+ Window* m_pErrorMessageParent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::rtl::OUString m_sContextInformation;
+
+ public:
+ ODatasourceConnector(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ Window* _pMessageParent
+ );
+ ODatasourceConnector(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ Window* _pMessageParent,
+ const ::rtl::OUString& _rContextInformation
+ );
+
+ /// returns <TRUE/> if the object is able to create data source connections
+ sal_Bool isValid() const { return m_xORB.is(); }
+
+ /** creates a connection to the data source, displays the possible error to the user, or returns it
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ connect(
+ const ::rtl::OUString& _rDataSourceName,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
+ ) const;
+
+ /** creates a connection to the data source, displays the possible error to the user, or returns it
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ connect(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo
+ ) const;
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DATASOURCECONNECTOR_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/datasourcemap.hxx b/dbaccess/source/ui/inc/datasourcemap.hxx
new file mode 100644
index 000000000000..54802093e17d
--- /dev/null
+++ b/dbaccess/source/ui/inc/datasourcemap.hxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DATASOURCEMAP_HXX
+#define DBAUI_DATASOURCEMAP_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/stl_types.hxx>
+#include <tools/string.hxx>
+
+class SfxItemPool;
+class SfxItemSet;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=====================================================================
+ //= ODatasourceMap
+ //=====================================================================
+ class ODatasourceMap
+ {
+ struct DatasourceInfo
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ xDatasource;
+ SfxItemSet* pModifications;
+
+ DatasourceInfo() :pModifications (NULL) { }
+ DatasourceInfo(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDS,
+ SfxItemSet* _pMods = NULL)
+ :xDatasource(_rxDS), pModifications(_pMods) { }
+ };
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB; /// service factory
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xDatabaseContext; /// database context we're working in
+
+ DECLARE_STL_USTRINGACCESS_MAP(DatasourceInfo, DatasourceInfos);
+ DatasourceInfos m_aDatasources; /// known infos about data sources
+
+ // deleted data sources, not necessarily with distinct names, that's why accessed via unique ids
+ DECLARE_STL_MAP(sal_Int32, DatasourceInfo, ::std::less< sal_Int32 >, MapInt2Info);
+ MapInt2Info m_aDeletedDatasources;
+
+ public:
+ /// iterating through all data sources
+ class Iterator;
+ friend class ODatasourceMap::Iterator;
+
+ /// encapsulates the infos about a data source for access from outside the class
+ class ODatasourceInfo;
+ friend class ODatasourceMap::ODatasourceInfo;
+
+ ODatasourceInfo operator[](const ::rtl::OUString _rName);
+
+ ODatasourceMap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB);
+
+ // get the database context
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getContext() { return m_xDatabaseContext; }
+
+ /// first element for iterating through the datasources
+ Iterator begin();
+ /// last element for iterating through the datasources
+ Iterator end();
+
+ /// first element for iterating through the deleted datasources
+ Iterator beginDeleted();
+ /// last element for iterating through the deleted datasources
+ Iterator endDeleted();
+
+ /// check if the object contains a valid datasource enumeration
+ sal_Bool isValid() const { return m_xDatabaseContext.is(); }
+ /// check if a datasource with the given name exists
+ sal_Bool exists(const ::rtl::OUString& _rName) const;
+ /// return the number of datasources available
+ sal_Int32 size() const { return m_aDatasources.size(); }
+ /// clear the map (non-deleted <em>and</em> deleted items)
+ void clear();
+ /// clear the map (deleted items only)
+ void clearDeleted();
+
+ /// clear the modification items for a datasource
+ void clearModifiedFlag(const ::rtl::OUString& _rName);
+
+ /** tell the map that a data source is scheduled to be deleted.
+ @return id for accessing the deleted data source later. -1 if no free id existed or an error occurred
+ */
+ sal_Int32 markDeleted(const ::rtl::OUString& _rName);
+
+ /** restores a datasource which has previously been marked as deleted.<p/>
+ @param _nAccessId the access id as got from <method>markDeleted</method>
+ @param _rName contains, upon return, the name of the datasource the access key refers to
+ @return sal_True if the datasource was successfully restored, sal_False if it could not be restored
+ because of a naming conflict (e.g. because another data source now has the name of the
+ to-be-restored one).
+ @see renamed
+ @see markDeleted
+ */
+ sal_Bool restoreDeleted(sal_Int32 _nAccessId, ::rtl::OUString& _rName);
+
+ /// remove an element from the map
+ void deleted(const ::rtl::OUString& _rName);
+ // (should be an erase(const Iterator&), but this is way to general ...
+
+ /// update the infos for a data source with a given item set
+ void update(const ::rtl::OUString& _rName, SfxItemSet& _rSet);
+ /** Tells the map that an entry has been renamed in a sense that it should be accessible under
+ a new name. This does not necesssarily mean that the data source has been renamed within
+ it's database context
+ */
+ void renamed(const ::rtl::OUString& _rOldName, const ::rtl::OUString& _rNewName);
+
+ /** adjust the registration name if necessary<p/>
+ The real name of the data source (as indicated in the SfxItemSet for this ds) may be another
+ one than the name the ds is registered for. This method corrects this, the ds will become registered
+ under it's real name.
+ @param _rName the name the ds is registered for
+ @return the real name of the data source
+ */
+ ::rtl::OUString adjustRealName(const ::rtl::OUString& _rName);
+
+ protected:
+ /** ensure that the DatabaseInfo for the named object is filled<p/>
+ This method allows us lazy access to the data sources: They're retrieved from the context
+ only if they're accessed by somebody.
+ */
+ void ensureObject(const ::rtl::OUString& _rName);
+ };
+
+ //-------------------------------------------------------------------------
+ //- ODatasourceMap::ODatasourceInfo
+ //-------------------------------------------------------------------------
+ class ODatasourceMap::ODatasourceInfo
+ {
+ friend class ODatasourceMap;
+ friend class ODatasourceMap::Iterator;
+
+ private:
+ ODatasourceMap* m_pOwner;
+ const ODatasourceMap::DatasourceInfo& m_rInfoImpl;
+ ::rtl::OUString m_sName;
+ sal_Int32 m_nAccessKey;
+
+ public:
+ ODatasourceInfo(const ODatasourceInfo& _rSource)
+ :m_pOwner(_rSource.m_pOwner), m_sName(_rSource.m_sName), m_rInfoImpl(_rSource.m_rInfoImpl), m_nAccessKey(_rSource.m_nAccessKey) { }
+
+ /// check if the datasource settings are modified
+ sal_Bool isModified() const;
+ /// get the name the datasource is registered under
+ ::rtl::OUString getName() const { return m_sName; }
+ /// get the original name of a datasource (may habe been renamed)
+ ::rtl::OUString getOriginalName() const;
+ /// get the real name of the datasource, which is the name which is in the item set
+ ::rtl::OUString getRealName() const;
+ /// check if the datasource should is about to be renamed (which means the original name does not equal the real name
+ sal_Bool isRenamed() const { return !getRealName().equals(getOriginalName()); }
+ /// get the key used to acces the object in the data source map
+ sal_Int32 getAccessKey() const { return m_nAccessKey; }
+
+ /// return the datasource the object represents
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getDatasource() const;
+ /** return the modifications for the data source<p/>
+ The return value is non-NULL if and only if <method>isModified</method> returned sal_True
+ */
+ const SfxItemSet*
+ getModifications() const { return m_rInfoImpl.pModifications; }
+
+ operator ::rtl::OUString() const { return getName(); }
+ operator String() const { return getName().getStr(); }
+
+ const ODatasourceInfo* const operator->() const { return this; }
+
+ protected:
+ ODatasourceInfo(
+ ODatasourceMap* _pOwner, const ::rtl::OUString& _rName,
+ const ODatasourceMap::DatasourceInfo& _rSource, sal_Int32 _nAccessKey)
+ :m_pOwner(_pOwner), m_sName(_rName), m_rInfoImpl(_rSource), m_nAccessKey(_nAccessKey) { }
+ };
+
+ //-------------------------------------------------------------------------
+ //- ODatasourceMap::Iterator
+ //-------------------------------------------------------------------------
+ class ODatasourceMap::Iterator
+ {
+ friend class ODatasourceMap;
+ protected:
+ ODatasourceMap* m_pOwner;
+ ODatasourceMap::ConstDatasourceInfosIterator m_aPos;
+ ODatasourceMap::ConstMapInt2InfoIterator m_aPosDeleted;
+ sal_Bool m_bLoopingDeleted;
+
+ public:
+ Iterator(const Iterator& _rSource);
+
+ ODatasourceInfo operator->() const;
+ ODatasourceInfo operator*() const;
+
+ /// prefix increment
+ const Iterator& operator++();
+ /// postfix increment
+ const Iterator operator++(int) { Iterator hold(*this); ++*this; return hold; }
+
+ /// prefix decrement
+ const Iterator& operator--();
+ /// postfix decrement
+ const Iterator operator--(int) { Iterator hold(*this); --*this; return hold; }
+
+
+ // compare two iterators
+ friend bool operator==(const Iterator& lhs, const Iterator& rhs)
+ {
+ if (lhs.m_bLoopingDeleted)
+ return lhs.m_aPosDeleted == rhs.m_aPosDeleted;
+ else
+ return lhs.m_aPos == rhs.m_aPos;
+ }
+
+ friend bool operator!=(const Iterator& lhs, const Iterator& rhs) { return !(lhs == rhs); }
+
+ protected:
+ Iterator(ODatasourceMap* _pOwner, ODatasourceMap::ConstDatasourceInfosIterator _rPos);
+ Iterator(ODatasourceMap* _pOwner, ODatasourceMap::ConstMapInt2InfoIterator _rPos);
+
+ protected:
+ ::rtl::OUString implGetName(const ODatasourceMap::DatasourceInfo& _rInfo) const;
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DATASOURCEMAP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dbadmin.hxx b/dbaccess/source/ui/inc/dbadmin.hxx
new file mode 100644
index 000000000000..a01314d188c1
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbadmin.hxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DBADMIN_HXX_
+#define _DBAUI_DBADMIN_HXX_
+
+#include <sal/macros.h>
+#include <sfx2/tabdlg.hxx>
+#include "dsntypes.hxx"
+#include "IItemSetHelper.hxx"
+#include <comphelper/uno3.hxx>
+#include <memory>
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= ODbAdminDialog
+//=========================================================================
+class OGeneralPage;
+class ODbDataSourceAdministrationHelper;
+/** tab dialog for administrating the office wide registered data sources
+*/
+class ODbAdminDialog : public SfxTabDialog , public IItemSetHelper, public IDatabaseSettingsDialog
+{
+private:
+ typedef ::std::stack< sal_Int32 > PageStack;
+ PageStack m_aCurrentDetailPages; // ids of all currently enabled (type-dependent) detail pages
+
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+
+ sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing
+ sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
+ sal_uInt16 m_nMainPageID;
+
+public:
+ /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
+ after the dialog has been destroyed
+ */
+ ODbAdminDialog(Window* pParent,
+ SfxItemSet* _pItems,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+ virtual ~ODbAdminDialog();
+
+ /** create and return an item set for use with the dialog.
+ @param _pTypeCollection pointer to an <type>ODatasourceMap</type>. May be NULL, in this case
+ the pool will not contain a typecollection default.
+ */
+ static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults, ::dbaccess::ODsnTypeCollection* _pTypeCollection);
+ /** destroy and item set / item pool / pool defaults previously created by <method>createItemSet</method>
+ */
+ static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
+
+ /** selects the DataSource
+ @param _rName
+ The name of the data source
+ */
+ void selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName);
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ // forwards to ODbDataSourceAdministrationHelper
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
+ virtual void clearPassword();
+ virtual sal_Bool saveDatasource();
+ virtual void setTitle(const ::rtl::OUString& _sTitle);
+ virtual void enableConfirmSettings( bool _bEnable );
+
+protected:
+ // adds a new detail page and remove all the old ones
+ void addDetailPage(sal_uInt16 _nPageId,sal_uInt16 _nTextId,CreateTabPage pCreateFunc);
+
+ virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage);
+ virtual short Ok();
+
+protected:
+ inline sal_Bool isUIEnabled() const { return m_bUIEnabled; }
+ inline void disabledUI() { m_bUIEnabled = sal_False; }
+
+private:
+ /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
+ void impl_selectDataSource(const ::com::sun::star::uno::Any& _aDataSourceName);
+ /// reset the tag pages according to m_sCurrentDatasource and <arg>_rxDatasource</arg>
+ void impl_resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource);
+
+ enum ApplyResult
+ {
+ AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed
+ AR_LEAVE_UNCHANGED, // no changes were made
+ AR_KEEP // don't leave the page (e.g. because an error occurred)
+ };
+ /** apply all changes made
+ */
+ ApplyResult implApplyChanges();
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DBADMIN_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
new file mode 100644
index 000000000000..29a8c3c2867e
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_DBEXCHANGE_HXX
+#define DBAUI_DBEXCHANGE_HXX
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svx/dbaexchange.hxx>
+#include <comphelper/uno3.hxx>
+#include <vector>
+
+#include <rtl/ref.hxx>
+
+namespace dbaui
+{
+
+ class ORTFImportExport;
+ class OHTMLImportExport;
+
+ class ODataClipboard : public ::svx::ODataAccessObjectTransferable
+
+ {
+ ::rtl::Reference< OHTMLImportExport > m_pHtml;
+ ::rtl::Reference< ORTFImportExport > m_pRtf;
+
+ public:
+ ODataClipboard(
+ const ::rtl::OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ ODataClipboard(
+ const ::rtl::OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ ODataClipboard(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rAliveForm,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& i_rSelectedRows,
+ const sal_Bool i_bBookmarkSelection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
+ );
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ };
+}
+
+#endif // DBAUI_DBEXCHANGE_HXX
+
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
new file mode 100644
index 000000000000..86e8ee277226
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#define DBAUI_DBTREELISTBOX_HXX
+
+#include "ScrollHelper.hxx"
+#include "moduledbu.hxx"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <svtools/svtreebx.hxx>
+#include <vcl/timer.hxx>
+
+#include <set>
+
+
+namespace dbaui
+{
+ struct DBTreeEditedEntry
+ {
+ SvLBoxEntry* pEntry;
+ XubString aNewText;
+ };
+
+ class IEntryFilter
+ {
+ public:
+ virtual bool includeEntry( SvLBoxEntry* _pEntry ) const = 0;
+ };
+
+ //========================================================================
+ class IControlActionListener;
+ class IContextMenuProvider;
+ class DBTreeListBox :public SvTreeListBox
+ {
+ OModuleClient m_aModuleClient;
+ OScrollHelper m_aScrollHelper;
+ Timer m_aTimer; // is needed for table updates
+ Point m_aMousePos;
+ ::std::set< SvListEntry* > m_aSelectedEntries;
+ SvLBoxEntry* m_pDragedEntry;
+ IControlActionListener* m_pActionListener;
+ IContextMenuProvider*
+ m_pContextMenuProvider;
+
+ Link m_aPreExpandHandler; // handler to be called before a node is expanded
+ Link m_aSelChangeHdl; // handlet to be called (asynchronously) when the selection changes in any way
+ Link m_aCutHandler; // called when someone press CTRL+X
+ Link m_aCopyHandler; // called when someone press CTRL+C
+ Link m_aPasteHandler; // called when someone press CTRL+V
+ Link m_aDeleteHandler; // called when someone press DELETE Key
+ Link m_aEditingHandler; // called before someone will edit an entry
+ Link m_aEditedHandler; // called after someone edited an entry
+ Link m_aEnterKeyHdl;
+
+
+ sal_Bool m_bHandleEnterKey;
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+
+ private:
+ void init();
+ DECL_LINK( OnTimeOut, void* );
+ DECL_LINK( OnResetEntry, SvLBoxEntry* );
+ DECL_LINK( ScrollUpHdl, SvTreeListBox* );
+ DECL_LINK( ScrollDownHdl, SvTreeListBox* );
+
+ public:
+ DBTreeListBox( Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,WinBits nWinStyle=0
+ ,sal_Bool _bHandleEnterKey = sal_False);
+ DBTreeListBox( Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ResId& rResId
+ ,sal_Bool _bHandleEnterKey = sal_False);
+ ~DBTreeListBox();
+
+ void setControlActionListener( IControlActionListener* _pListener ) { m_pActionListener = _pListener; }
+ void setContextMenuProvider( IContextMenuProvider* _pContextMenuProvider ) { m_pContextMenuProvider = _pContextMenuProvider; }
+
+ inline void setORB(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB) { m_xORB = _xORB; }
+
+
+ void SetPreExpandHandler(const Link& _rHdl) { m_aPreExpandHandler = _rHdl; }
+ void SetSelChangeHdl( const Link& _rHdl ) { m_aSelChangeHdl = _rHdl; }
+ void setCutHandler(const Link& _rHdl) { m_aCutHandler = _rHdl; }
+ void setCopyHandler(const Link& _rHdl) { m_aCopyHandler = _rHdl; }
+ void setPasteHandler(const Link& _rHdl) { m_aPasteHandler = _rHdl; }
+ void setDeleteHandler(const Link& _rHdl) { m_aDeleteHandler = _rHdl; }
+ void setEditingHandler(const Link& _rHdl) { m_aEditingHandler = _rHdl; }
+ void setEditedHandler(const Link& _rHdl) { m_aEditedHandler = _rHdl; }
+
+ // modified the given entry so that the expand handler is called whenever the entry is expanded
+ // (normally, the expand handler is called only once)
+ void EnableExpandHandler(SvLBoxEntry* _pEntry);
+
+ SvLBoxEntry* GetEntryPosByName( const String& aName, SvLBoxEntry* pStart = NULL, const IEntryFilter* _pFilter = NULL ) const;
+ virtual void RequestingChilds( SvLBoxEntry* pParent );
+ virtual void SelectHdl();
+ virtual void DeselectHdl();
+ // Window
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual void InitEntry( SvLBoxEntry* pEntry, const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, SvLBoxButtonKind eButtonKind);
+
+ // enable editing for tables/views and queries
+ virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& );
+ virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
+
+ virtual sal_Bool DoubleClickHdl();
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
+
+ void SetEnterKeyHdl(const Link& rNewHdl) {m_aEnterKeyHdl = rNewHdl;}
+
+ void clearCurrentSelection() { m_aSelectedEntries.clear(); }
+
+ protected:
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+ // DragSourceHelper overridables
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ // DropTargetHelper overridables
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& _rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& _rEvt );
+
+ virtual void ModelHasRemoved( SvListEntry* pEntry );
+ virtual void ModelHasEntryInvalidated( SvListEntry* pEntry );
+
+ void implStopSelectionTimer();
+ void implStartSelectionTimer();
+
+ protected:
+ using SvTreeListBox::ExecuteDrop;
+ };
+}
+
+#endif // DBAUI_DBTREELISTBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dbu_brw.hrc b/dbaccess/source/ui/inc/dbu_brw.hrc
new file mode 100644
index 000000000000..8d49e1101045
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_brw.hrc
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_BRW_HRC_
+#define _DBU_BRW_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+ // FREE RID_STR_BRW_START + 0
+#define RID_STR_DATABROWSER_FILTERED RID_STR_BRW_START + 1
+#define SBA_BROWSER_SETTING_ORDER RID_STR_BRW_START + 2
+#define SBA_BROWSER_SETTING_FILTER RID_STR_BRW_START + 3
+#define STR_DATASOURCE_GRIDCONTROL_DESC RID_STR_BRW_START + 4
+#define RID_STR_UNDO_MODIFY_RECORD RID_STR_BRW_START + 5
+#define STR_NO_COLUMNNAME_MATCHING RID_STR_BRW_START + 6
+#define RID_STR_SAVE_CURRENT_RECORD RID_STR_BRW_START + 7
+#define STR_DATASOURCE_GRIDCONTROL_NAME RID_STR_BRW_START + 8
+#define STR_OPENTABLES_WARNINGS RID_STR_BRW_START + 9
+#define STR_OPENTABLES_WARNINGS_DETAILS RID_STR_BRW_START + 10
+#define STR_CONNECTING_DATASOURCE RID_STR_BRW_START + 11
+#define STR_LOADING_QUERY RID_STR_BRW_START + 12
+#define STR_LOADING_TABLE RID_STR_BRW_START + 13
+
+// please adjust checking before insert new strings
+
+#if STR_LOADING_TABLE > RID_STR_BRW_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif // _DBU_BRW_HRC_
diff --git a/dbaccess/source/ui/inc/dbu_control.hrc b/dbaccess/source/ui/inc/dbu_control.hrc
new file mode 100644
index 000000000000..7b597a8dc6e1
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_control.hrc
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_CONTROL_HRC_
+#define _DBU_CONTROL_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+#define STR_TABLE_PRIV_NAME RID_STR_CONTROL_START
+#define STR_TABLE_PRIV_INSERT RID_STR_CONTROL_START + 1
+#define STR_TABLE_PRIV_DELETE RID_STR_CONTROL_START + 2
+#define STR_TABLE_PRIV_UPDATE RID_STR_CONTROL_START + 3
+#define STR_TABLE_PRIV_ALTER RID_STR_CONTROL_START + 4
+#define STR_TABLE_PRIV_REFERENCE RID_STR_CONTROL_START + 5
+#define STR_TABLE_PRIV_DROP RID_STR_CONTROL_START + 6
+#define STR_TABLE_PRIV_SELECT RID_STR_CONTROL_START + 7
+#define STR_ALL_TABLES_AND_VIEWS RID_STR_CONTROL_START + 8
+#define STR_COULDNOTCONNECT RID_STR_CONTROL_START + 9
+#define STR_COULDNOTCONNECT_PLEASECHECK RID_STR_CONTROL_START + 10
+#define STR_NOTABLEINFO RID_STR_CONTROL_START + 11
+#define STR_ALL_TABLES RID_STR_CONTROL_START + 12
+#define STR_ALL_VIEWS RID_STR_CONTROL_START + 13
+
+// please adjust checking before insert new strings
+
+#if STR_ALL_VIEWS > RID_STR_CONTROL_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif //_DBU_CONTROL_HRC_
+
diff --git a/dbaccess/source/ui/inc/dbu_dlg.hrc b/dbaccess/source/ui/inc/dbu_dlg.hrc
new file mode 100644
index 000000000000..b107a0014dbb
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_dlg.hrc
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_DLG_HRC_
+#define _DBU_DLG_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+#define PAGE_X 281
+#define PAGE_Y 185
+#define WIZARD_PAGE_X 225
+#define WIZARD_PAGE_Y 210
+#define START_X 6
+#define START_Y 6
+
+
+#define CHECKBOX_HEIGHT 8
+#define LISTBOX_HEIGHT 12
+#define FIXEDTEXT_HEIGHT 8
+#define RELATED_CONTROLS 4
+#define UNRELATED_CONTROLS 7
+#define EDIT_HEIGHT 12
+#define BUTTON_HEIGHT 14
+#define BUTTON_WIDTH 50
+
+//constants for the wizards
+#define INIT_Y 28
+#define INDENTED_X 6
+#define INDENT_BELOW_RADIO 10
+#define INDENT_BELOW_CHECK 10
+
+
+#define STR_ADABAS_HELP_SYSDEVSPACE RID_STR_DLG_START
+#define STR_ADABAS_HELP_TRANSACT RID_STR_DLG_START + 1
+#define STR_ADABAS_HELP_DATADEVSPACES RID_STR_DLG_START + 2
+#define STR_ADABAS_HELP_SIZE RID_STR_DLG_START + 3
+#define STR_ADABAS_HELP_FREESIZE RID_STR_DLG_START + 4
+#define STR_ADABAS_HELP_MEMORYUSING RID_STR_DLG_START + 5
+#define STR_ADABAS_ERROR_SYSTEMTABLES RID_STR_DLG_START + 6
+#define STR_ERROR_PASSWORDS_NOT_IDENTICAL RID_STR_DLG_START + 7
+#define STR_INDEXDESIGN_DOUBLE_COLUMN_NAME RID_STR_DLG_START + 8
+ // FREE
+ // FREE
+#define STR_ERR_USE_CONNECT_TO RID_STR_DLG_START + 11
+#define STR_ALREADYEXISTOVERWRITE RID_STR_DLG_START + 12
+ // FREE
+#define STR_INDEX_NAME_ALREADY_USED RID_STR_DLG_START + 14
+#define STR_ASK_FOR_DIRECTORY_CREATION RID_STR_DLG_START + 15
+#define STR_COULD_NOT_CREATE_DIRECTORY RID_STR_DLG_START + 16
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+#define STR_COMMAND_EXECUTED_SUCCESSFULLY RID_STR_DLG_START + 23
+#define STR_DIRECTSQL_CONNECTIONLOST RID_STR_DLG_START + 24
+ // FREE
+ // FREE
+#define STR_USERADMIN_NOT_AVAILABLE RID_STR_DLG_START + 27
+#define STR_TAB_INDEX_SORTORDER RID_STR_DLG_START + 28
+#define STR_TAB_INDEX_FIELD RID_STR_DLG_START + 29
+#define STR_ORDER_ASCENDING RID_STR_DLG_START + 30
+#define STR_ORDER_DESCENDING RID_STR_DLG_START + 31
+#define STR_CONFIRM_DROP_INDEX RID_STR_DLG_START + 32
+#define STR_LOGICAL_INDEX_NAME RID_STR_DLG_START + 33
+#define STR_CONNECTION_TEST RID_STR_DLG_START + 34
+#define STR_CONNECTION_SUCCESS RID_STR_DLG_START + 35
+ // FREE
+#define STR_JDBCDRIVER_SUCCESS RID_STR_DLG_START + 37
+#define STR_JDBCDRIVER_NO_SUCCESS RID_STR_DLG_START + 38
+#define STR_MSACCESS_FILTERNAME RID_STR_DLG_START + 39
+#define STR_CONNECTION_NO_SUCCESS RID_STR_DLG_START + 40
+#define STR_DBASE_PATH_OR_FILE RID_STR_DLG_START + 41
+#define STR_TEXT_PATH_OR_FILE RID_STR_DLG_START + 45
+#define STR_FLAT_PATH_OR_FILE RID_STR_DLG_START + 46
+#define STR_CALC_PATH_OR_FILE RID_STR_DLG_START + 47
+#define STR_NAME_OF_ODBC_DATASOURCE RID_STR_DLG_START + 48
+#define STR_MYSQL_DATABASE_NAME RID_STR_DLG_START + 49
+#define STR_ORACLE_DATABASE_NAME RID_STR_DLG_START + 50
+#define STR_ADABAS_DATABASE_NAME RID_STR_DLG_START + 51
+#define STR_MSACCESS_MDB_FILE RID_STR_DLG_START + 52
+#define STR_COMMONURL RID_STR_DLG_START + 53
+#define STR_DATABASEDEFAULTNAME RID_STR_DLG_START + 54
+#define STR_NO_ADABASE_DATASOURCES RID_STR_DLG_START + 55
+#define STR_NO_ADDITIONAL_SETTINGS RID_STR_DLG_START + 56
+#define STR_HOSTNAME RID_STR_DLG_START + 57
+ // FREE
+#define STR_MOZILLA_PROFILE_NAME RID_STR_DLG_START + 59
+#define STR_THUNDERBIRD_PROFILE_NAME RID_STR_DLG_START + 60
+#define STR_EXPLAN_STRINGCONVERSION_ERROR RID_STR_DLG_START + 61
+#define STR_EXCEPTION_ERROR RID_STR_DLG_START + 62
+#define STR_EXCEPTION_WARNING RID_STR_DLG_START + 63
+#define STR_EXCEPTION_INFO RID_STR_DLG_START + 64
+#define STR_EXCEPTION_DETAILS RID_STR_DLG_START + 65
+#define STR_MSACCESS_2007_FILTERNAME RID_STR_DLG_START + 66
+#define STR_MSACCESS_ACCDB_FILE RID_STR_DLG_START + 67
+
+
+// please adjust checking before insert new strings
+
+#define LAST_STR_HERE RID_STR_DLG_START + 67
+
+#if LAST_STR_HERE > RID_STR_DLG_END
+#error Resource-Id Overflow in #file, #line
+#endif
+
+#endif //_DBU_DLG_HRC_
+
+
diff --git a/dbaccess/source/ui/inc/dbu_misc.hrc b/dbaccess/source/ui/inc/dbu_misc.hrc
new file mode 100644
index 000000000000..04017faab8f0
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_misc.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_MISC_HRC_
+#define _DBU_MISC_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+// free
+// free
+#define STR_WIZ_COLUMN_SELECT_TITEL RID_STR_MISC_START + 2
+#define STR_WIZ_TYPE_SELECT_TITEL RID_STR_MISC_START + 3
+#define STR_WIZ_PKEY_ALREADY_DEFINED RID_STR_MISC_START + 4
+#define STR_WIZ_NAME_MATCHING_TITEL RID_STR_MISC_START + 5
+#define STR_WIZ_TABLE_COPY RID_STR_MISC_START + 6
+#define STR_COPYTABLE_TITLE_COPY RID_STR_MISC_START + 7
+#define STR_COULDNOTOPEN_LINKEDDOC RID_STR_MISC_START + 8
+#define STR_SUGGEST_APPEND_TABLE_DATA RID_STR_MISC_START + 9
+#define STR_UNDO_COLON RID_STR_MISC_START + 10
+#define STR_REDO_COLON RID_STR_MISC_START + 11
+#define STR_UNKNOWN_TYPE_FOUND RID_STR_MISC_START + 12
+#define STR_FILE_DOES_NOT_EXIST RID_STR_MISC_START + 13
+#define STR_WARNINGS_DURING_CONNECT RID_STR_MISC_START + 14
+#define STR_NAMED_OBJECT_ALREADY_EXISTS RID_STR_MISC_START + 15
+#define STR_INVALID_TABLE_NAME RID_STR_MISC_START + 16
+#define STR_INVALID_TABLE_NAME_LENGTH RID_STR_MISC_START + 17
+
+// please adjust checking before insert new strings
+
+#if STR_INVALID_TABLE_NAME_LENGTH > RID_STR_MISC_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif // _DBU_MISC_HRC_
+
+
+
diff --git a/dbaccess/source/ui/inc/dbu_qry.hrc b/dbaccess/source/ui/inc/dbu_qry.hrc
new file mode 100644
index 000000000000..26bd4c82b374
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_qry.hrc
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_QRY_HRC_
+#define _DBU_QRY_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+
+#define STR_QRY_FUNCTIONS RID_STR_QRY_START
+#define STR_QRY_SORTTEXT RID_STR_QRY_START + 1
+#define STR_QUERY_UNDO_MOVETABWIN RID_STR_QRY_START + 2
+#define STR_QUERY_UNDO_SIZETABWIN RID_STR_QRY_START + 3
+#define STR_QUERY_UNDO_INSERTCONNECTION RID_STR_QRY_START + 4
+#define STR_QUERY_UNDO_REMOVECONNECTION RID_STR_QRY_START + 5
+#define STR_QUERY_UNDO_TABWINSHOW RID_STR_QRY_START + 6
+#define STR_QUERY_UNDO_TABWINDELETE RID_STR_QRY_START + 7
+#define STR_QUERY_UNDO_MODIFY_CELL RID_STR_QRY_START + 8
+#define STR_QUERY_UNDO_SIZE_COLUMN RID_STR_QRY_START + 9
+#define STR_QUERY_UNDO_TABFIELDDELETE RID_STR_QRY_START + 10
+#define STR_QUERY_UNDO_TABFIELDCREATE RID_STR_QRY_START + 11
+#define STR_QRY_TOOCOMPLEX RID_STR_QRY_START + 12
+#define RID_STR_TABLE_DOESNT_EXIST RID_STR_QRY_START + 13
+#define RID_STR_FIELD_DOESNT_EXIST RID_STR_QRY_START + 14
+#define RID_STR_TOMUCHTABLES RID_STR_QRY_START + 15
+#define STR_QUERY_INNER_JOIN RID_STR_QRY_START + 16
+#define STR_QUERY_LEFTRIGHT_JOIN RID_STR_QRY_START + 17
+#define STR_QUERY_FULL_JOIN RID_STR_QRY_START + 18
+#define STR_QUERY_SORTTEXT RID_STR_QRY_START + 19
+#define STR_QUERY_FUNCTIONS RID_STR_QRY_START + 20
+#define STR_QUERY_NOTABLE RID_STR_QRY_START + 21
+#define STR_QRY_ORDERBY_UNRELATED RID_STR_QRY_START + 22
+#define STR_QUERY_HANDLETEXT RID_STR_QRY_START + 23
+#define STR_QUERY_FALSE RID_STR_QRY_START + 24
+#define STR_QUERY_TRUE RID_STR_QRY_START + 25
+#define STR_QRY_TOO_MANY_COLUMNS RID_STR_QRY_START + 26
+#define STR_SVT_SQL_SYNTAX_ERROR RID_STR_QRY_START + 27
+#define STR_QUERYDESIGN_NO_VIEW_SUPPORT RID_STR_QRY_START + 28
+#define STR_QUERYDESIGN_NO_VIEW_ASK RID_STR_QRY_START + 29
+#define STR_QRY_NOSELECT RID_STR_QRY_START + 30
+#define STR_QRY_COLUMN_NOT_FOUND RID_STR_QRY_START + 31
+#define STR_QRY_JOIN_COLUMN_COMPARE RID_STR_QRY_START + 32
+#define STR_QRY_LIKE_LEFT_NO_COLUMN RID_STR_QRY_START + 33
+#define STR_QRY_CHECK_CASESENSITIVE RID_STR_QRY_START + 34
+#define STR_QUERY_UNDO_TABFIELDMOVED RID_STR_QRY_START + 35
+#define STR_QRY_ILLEGAL_JOIN RID_STR_QRY_START + 36
+#define STR_QRY_TOO_LONG_STATEMENT RID_STR_QRY_START + 37
+#define STR_QRY_SYNTAX RID_STR_QRY_START + 38
+#define STR_QRY_NATIVE RID_STR_QRY_START + 39
+#define STR_QRY_TOO_MANY_TABLES RID_STR_QRY_START + 40
+#define STR_QRY_TOOMANYCOND RID_STR_QRY_START + 41
+#define STR_QUERYDESIGN RID_STR_QRY_START + 42
+#define STR_VIEWDESIGN RID_STR_QRY_START + 43
+#define STR_JOIN_TYPE_HINT RID_STR_QRY_START + 44
+#define STR_QUERY_SAVEMODIFIED RID_STR_QRY_START + 45
+#define STR_ERROR_PARSING_STATEMENT RID_STR_QRY_START + 46
+#define STR_INFO_OPENING_IN_SQL_VIEW RID_STR_QRY_START + 47
+#define STR_STATEMENT_WITHOUT_RESULT_SET RID_STR_QRY_START + 48
+#define STR_NO_DATASOURCE_OR_CONNECTION RID_STR_QRY_START + 49
+#define STR_NO_ALTER_VIEW_SUPPORT RID_STR_QRY_START + 50
+#define STR_QUERY_CROSS_JOIN RID_STR_QRY_START + 51
+#define STR_QUERY_NATURAL_JOIN RID_STR_QRY_START + 52
+ // please adjust checking when inserting new strings
+
+
+#if STR_QUERY_NATURAL_JOIN > RID_STR_QRY_END
+#error resource id overflow in #file, #line
+#endif
+
+#endif // _DBU_QRY_HRC_
+
diff --git a/dbaccess/source/ui/inc/dbu_rel.hrc b/dbaccess/source/ui/inc/dbu_rel.hrc
new file mode 100644
index 000000000000..8a08e160171c
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_rel.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_REL_HRC_
+#define _DBU_REL_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+
+#define STR_QUERY_REL_EDIT_RELATION RID_STR_REL_START
+#define STR_RELATIONDESIGN RID_STR_REL_START + 1
+#define STR_RELATIONDESIGN_NOT_AVAILABLE RID_STR_REL_START + 2
+#define STR_QUERY_REL_DELETE_WINDOW RID_STR_REL_START + 3
+#define STR_QUERY_REL_EDIT RID_STR_REL_START + 4
+#define STR_QUERY_REL_CREATE RID_STR_REL_START + 5
+#define STR_QUERY_REL_COULD_NOT_CREATE RID_STR_REL_START + 6
+// please adjust checking before insert new strings
+
+#if STR_QUERY_REL_COULD_NOT_CREATE > RID_STR_REL_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif //_DBU_REL_HRC_
+
+
diff --git a/dbaccess/source/ui/inc/dbu_resource.hrc b/dbaccess/source/ui/inc/dbu_resource.hrc
new file mode 100644
index 000000000000..7ba85bc6dfcb
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_resource.hrc
@@ -0,0 +1,395 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_RESOURCE_HRC_
+#define _DBU_RESOURCE_HRC_
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+#define RID_DIALOG_START RID_DBACCESS_START
+#define RID_PAGE_START RID_DBACCESS_START
+#define RID_ERRORBOX_START RID_DBACCESS_START
+#define RID_QUERYBOX_START RID_DBACCESS_START
+#define RID_TOOLBOX_START RID_DBACCESS_START
+#define RID_BITMAP_START RID_DBACCESS_START
+#define RID_IMAGE_START RID_DBACCESS_START
+#define RID_IMAGELIST_START RID_DBACCESS_START
+#define RID_MENU_START RID_DBACCESS_START
+#define RID_STRING_START RID_DBACCESS_START
+#define RID_UNTYPED_START RID_DBACCESS_START
+#define RID_WARN_START RID_DBACCESS_START
+#define RID_CONTROL_START RID_DBACCESS_START
+#define RID_MISC_START RID_DBACCESS_START
+
+// new defines to make the strings folder specific
+#define RID_STR_BRW_START RID_DBACCESS_START
+#define RID_STR_BRW_END RID_STR_BRW_START + 40 // 0 - 39
+
+#define RID_STR_CONTROL_START RID_STR_BRW_END
+#define RID_STR_CONTROL_END RID_STR_CONTROL_START + 30 // 40 - 69
+
+#define RID_STR_DLG_START RID_STR_CONTROL_END
+#define RID_STR_DLG_END RID_STR_DLG_START + 80 // 70 - 149
+
+#define RID_STR_MISC_START RID_STR_DLG_END
+#define RID_STR_MISC_END RID_STR_MISC_START + 20 // 150 - 169
+
+#define RID_STR_QRY_START RID_STR_MISC_END
+#define RID_STR_QRY_END RID_STR_QRY_START + 80 // 170 - 249
+
+#define RID_STR_TBL_START RID_STR_QRY_END
+#define RID_STR_TBL_END RID_STR_TBL_START + 80 // 250 - 329
+
+#define RID_STR_REL_START RID_STR_TBL_END
+#define RID_STR_REL_END RID_STR_REL_START + 10 // 330 - 349
+
+#define RID_STR_UNO_START RID_STR_REL_END
+#define RID_STR_UNO_END RID_STR_UNO_START + 20 // 350 - 369
+
+#define RID_STR_GEN_START RID_STR_UNO_END
+#define RID_STR_GEN_END RID_STR_GEN_START + 55 // 370 - 424
+
+#define RID_STR_APP_START RID_STR_GEN_END
+#define RID_STR_APP_END RID_STR_APP_START + 40 // 425 - 464
+
+
+#if RID_STR_GEN_END > RID_DBACCESS_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+//========================================================================
+// dialog ids
+
+#define DLG_DATABASE_ADMINISTRATION RID_DIALOG_START + 0
+#define DLG_DBASE_INDEXES RID_DIALOG_START + 1
+#define DLG_SQLMESSAGE RID_DIALOG_START + 2
+#define DLG_SQLEXCEPTIONCHAIN RID_DIALOG_START + 3
+#define DLG_DATASOURCE_SELECTION RID_DIALOG_START + 4
+#define DLG_PARAMETERS RID_DIALOG_START + 5
+#define DLG_FILTERCRIT RID_DIALOG_START + 6
+#define DLG_ORDERCRIT RID_DIALOG_START + 7
+#define DLG_ROWHEIGHT RID_DIALOG_START + 8
+#define DLG_COLWIDTH RID_DIALOG_START + 9
+#define DLG_ATTR RID_DIALOG_START + 10
+#define DLG_SAVE_AS RID_DIALOG_START + 11
+#define DLG_ERROR RID_DIALOG_START + 12
+#define DLG_TEXT RID_DIALOG_START + 13
+#define DLG_JOIN_TABADD RID_DIALOG_START + 14
+#define DLG_QRY_JOIN RID_DIALOG_START + 15
+#define WIZ_RTFCOPYTABLE RID_DIALOG_START + 16
+#define DLG_REL_PROPERTIES RID_DIALOG_START + 17
+#define DLG_ADABASSTAT RID_DIALOG_START + 18
+#define DLG_INDEXDESIGN RID_DIALOG_START + 19
+#define DLG_DATABASE_ADABASADMIN RID_DIALOG_START + 20
+#define DLG_DATABASE_USERADMIN RID_DIALOG_START + 21
+#define DLG_DIRECTSQL RID_DIALOG_START + 22
+#define DLG_PASSWORD RID_DIALOG_START + 23
+#define DLG_DOMAINPASSWORD RID_DIALOG_START + 24
+#define DLG_RENAME RID_DIALOG_START + 25
+#define DLG_DATABASE_ADVANCED RID_DIALOG_START + 26
+#define DLG_COLLECTION_VIEW RID_DIALOG_START + 27
+#define DLG_DATABASE_TYPE_CHANGE RID_DIALOG_START + 28
+#define DLG_DATABASE_WIZARD RID_DIALOG_START + 29
+#define RID_EXTENSION_NOT_PRESENT_DLG RID_DIALOG_START + 30
+#define DLG_TEXT_CONNECTION_SETTINGS RID_DIALOG_START + 31
+#define DLG_TABLE_FILTER RID_DIALOG_START + 32
+//========================================================================
+// tab pages
+
+#define PAGE_GENERAL RID_PAGE_START + 0
+#define PAGE_DBASE RID_PAGE_START + 1
+#define PAGE_ODBC RID_PAGE_START + 3
+#define PAGE_TEXT RID_PAGE_START + 4
+#define PAGE_ADABAS RID_PAGE_START + 5
+#define PAGE_CONNECTION RID_PAGE_START + 6
+#define PAGE_ADO RID_PAGE_START + 7
+#define PAGE_QUERYADMINISTRATION RID_PAGE_START + 8
+#define TAB_WIZ_COLUMN_SELECT RID_PAGE_START + 9
+#define TAB_WIZ_TYPE_SELECT RID_PAGE_START + 10
+#define TAB_WIZ_NAME_MATCHING RID_PAGE_START + 11
+#define TAB_WIZ_COPYTABLE RID_PAGE_START + 12
+#define TAB_PAG_ADABAS_SETTINGS RID_PAGE_START + 13
+// free
+#define PAGE_LDAP RID_PAGE_START + 15
+#define TAB_PAGE_USERADMIN RID_PAGE_START + 16
+#define PAGE_MYSQL_ODBC RID_PAGE_START + 17
+#define TAB_PAGE_TABLEPRIVILEGES RID_PAGE_START + 18
+#define PAGE_USERDRIVER RID_PAGE_START + 19
+#define PAGE_MYSQL_JDBC RID_PAGE_START + 20
+#define PAGE_GENERATED_VALUES RID_PAGE_START + 22
+#define PAGE_ADVANCED_SETTINGS_SPECIAL RID_PAGE_START + 23
+#define PAGE_MYSQL_NATIVE RID_PAGE_START + 24
+ // FREE
+ // FREE
+#define PAGE_ORACLE_JDBC RID_PAGE_START + 27
+#define PAGE_TABLESUBSCRIPTION RID_PAGE_START + 28
+ // FREE
+ // FREE
+ // FREE
+#define PAGE_MOZILLA RID_PAGE_START + 32
+#define PAGE_DS_ORACLE_ADVANCED_SETTINGS RID_PAGE_START + 33
+
+
+#define PAGE_DBWIZARD_INTRO RID_PAGE_START + 40
+#define PAGE_DBWIZARD_DBASE RID_PAGE_START + 41
+#define PAGE_DBWIZARD_TEXT RID_PAGE_START + 42
+#define PAGE_DBWIZARD_MSACCESS RID_PAGE_START + 43
+#define PAGE_DBWIZARD_LDAP RID_PAGE_START + 44
+#define PAGE_DBWIZARD_ADABAS RID_PAGE_START + 45
+#define PAGE_DBWIZARD_MYSQL_INTRO RID_PAGE_START + 46
+#define PAGE_DBWIZARD_MYSQL_ODBC RID_PAGE_START + 47
+#define PAGE_DBWIZARD_ORACLE RID_PAGE_START + 48
+#define PAGE_DBWIZARD_JDBC RID_PAGE_START + 49
+#define PAGE_DBWIZARD_ADO RID_PAGE_START + 50
+#define PAGE_DBWIZARD_ODBC RID_PAGE_START + 51
+#define PAGE_DBWIZARD_SPREADSHEET RID_PAGE_START + 52
+#define PAGE_DBWIZARD_AUTHENTIFICATION RID_PAGE_START + 53
+#define PAGE_DBWIZARD_MYSQL_JDBC RID_PAGE_START + 54
+#define PAGE_DBWIZARD_FINAL RID_PAGE_START + 55
+#define PAGE_DBWIZARD_USERDEFINED RID_PAGE_START + 56
+#define PAGE_DBWIZARD_MYSQL_NATIVE RID_PAGE_START + 57
+
+//========================================================================
+// error boxes
+
+#define ERR_NOREGISTEREDDATASOURCES RID_ERRORBOX_START + 0
+// free
+#define ERR_QRY_CRITERIA_ON_ASTERISK RID_ERRORBOX_START + 2
+#define ERR_QRY_ORDERBY_ON_ASTERISK RID_ERRORBOX_START + 3
+#define ERR_QRY_AMB_FIELD RID_ERRORBOX_START + 4
+ // FREE
+#define ERR_INVALID_LISTBOX_ENTRY RID_ERRORBOX_START + 6
+// FREE
+#define ERR_NEED_INDEX_FIELDS RID_ERRORBOX_START + 8
+#define ERR_QRY_NOSTATEMENT RID_ERRORBOX_START + 9
+#define ERR_QRY_NOCRITERIA RID_ERRORBOX_START + 10
+#define ERR_CANTDOTABLEACTION RID_ERRORBOX_START + 11
+
+
+
+//========================================================================
+// query boxes
+
+#define QUERY_BRW_DELETE_ROWS RID_QUERYBOX_START + 0
+#define QUERY_BRW_SAVEMODIFIED RID_QUERYBOX_START + 1
+#define QUERY_CONNECTION_LOST RID_QUERYBOX_START + 2
+#define QUERY_BRW_DELETE_QUERY_CONFIRM RID_QUERYBOX_START + 3
+#define APP_SAVEMODIFIED RID_QUERYBOX_START + 4
+#define TABLE_DESIGN_SAVEMODIFIED RID_QUERYBOX_START + 5
+#define TABLE_QUERY_CONNECTION_LOST RID_QUERYBOX_START + 6
+#define QUERY_SAVE_CURRENT_INDEX RID_QUERYBOX_START + 7
+#define QUERY_SAVE_TABLE_EDIT_INDEXES RID_QUERYBOX_START + 8
+#define RELATION_DESIGN_SAVEMODIFIED RID_QUERYBOX_START + 9
+ // FREE
+#define APP_CLOSEDOCUMENTS RID_QUERYBOX_START + 11
+#define QUERY_USERADMIN_DELETE_USER RID_QUERYBOX_START + 12
+#define TABLE_DESIGN_ALL_ROWS_DELETED RID_QUERYBOX_START + 13
+
+
+
+
+//========================================================================
+// warning boxes
+
+
+//========================================================================
+// toolboxes
+
+#define RID_BRW_TAB_TOOLBOX RID_TOOLBOX_START + 0
+#define RID_BRW_QRY_TOOLBOX RID_TOOLBOX_START + 1
+#define RID_QRY_TOOLBOX_SQL RID_TOOLBOX_START + 2
+#define RID_BRW_QUERYDESIGN_TOOLBOX RID_TOOLBOX_START + 3
+#define RID_BRW_REALTIONDESIGN_TOOLBOX RID_TOOLBOX_START + 4
+#define RID_BRW_APPLICATION_TOOLBOX RID_TOOLBOX_START + 5
+
+//========================================================================
+// bitmaps
+
+// start with RID_BITMAP_START
+
+//========================================================================
+// images
+
+#define TABLE_TREE_ICON RID_IMAGE_START + 0
+#define VIEW_TREE_ICON RID_IMAGE_START + 1
+#define TABLEFOLDER_TREE_ICON RID_IMAGE_START + 2
+#define BMP_EXCEPTION_ERROR RID_IMAGE_START + 3
+#define BMP_EXCEPTION_WARNING RID_IMAGE_START + 4
+#define BMP_EXCEPTION_INFO RID_IMAGE_START + 5
+#define QUERYFOLDER_TREE_ICON RID_IMAGE_START + 6
+#define QUERY_TREE_ICON RID_IMAGE_START + 7
+#define DATABASE_TREE_ICON RID_IMAGE_START + 8
+// free
+// free
+// free
+#define IMG_PKEYICON RID_IMAGE_START + 12
+// free
+// free
+#define IMG_DATABASE_CONNECTED RID_IMAGE_START + 15
+// free
+// ...
+// free
+#define REPORTFOLDER_TREE_ICON RID_IMAGE_START + 24
+#define IMG_FORMFOLDER_TREE_L RID_IMAGE_START + 39
+#define IMG_REPORTFOLDER_TREE_L RID_IMAGE_START + 40
+#define IMG_QUERYFOLDER_TREE_L RID_IMAGE_START + 41
+#define IMG_TABLEFOLDER_TREE_L RID_IMAGE_START + 42
+#define IMG_NAVIGATION_BTN_UP_SC RID_IMAGE_START + 47
+#define IMG_NAVIGATION_CREATEFOLDER_SC RID_IMAGE_START + 49
+#define FORM_TREE_ICON RID_IMAGE_START + 51
+#define REPORT_TREE_ICON RID_IMAGE_START + 52
+// free
+// free
+#define FORMFOLDER_TREE_ICON RID_IMAGE_START + 55
+
+
+//========================================================================
+// image lists
+#define IMG_JOINS RID_IMAGELIST_START + 0
+#define IMG_INDEX_DLG_SC RID_IMAGELIST_START + 1
+// free
+#define IMG_INDEX_DLG_LC RID_IMAGELIST_START + 3
+// free
+#define IMP_FORM_SC RID_IMAGELIST_START + 5
+// free
+#define IMP_FORM_LC RID_IMAGELIST_START + 7
+// free
+#define IMP_REPORT_SC RID_IMAGELIST_START + 9
+// free
+#define IMP_REPORT_LC RID_IMAGELIST_START + 11
+// free
+
+//========================================================================
+// menues
+
+#define MENU_TABLETREE_POPUP RID_MENU_START + 0
+#define MENU_DATASOURCELIST_POPUP RID_MENU_START + 1
+#define RID_SBA_GRID_COLCTXMENU RID_MENU_START + 2
+#define RID_SBA_GRID_ROWCTXMENU RID_MENU_START + 3
+#define MENU_BROWSERTREE_CONTEXT RID_MENU_START + 4
+#define RID_QUERYCOLPOPUPMENU RID_MENU_START + 5
+#define RID_QUERYFUNCTION_POPUPMENU RID_MENU_START + 6
+#define RID_TABLEDESIGNROWPOPUPMENU RID_MENU_START + 7
+#define RID_BRW_TABLEDESIGN_TOOLBOX RID_MENU_START + 8
+#define RID_SBA_RTF_PKEYPOPUP RID_MENU_START + 9
+#define RID_MENU_APP_EDIT RID_MENU_START + 10
+#define RID_MENU_APP_NEW RID_MENU_START + 11
+#define RID_MENU_APP_PREVIEW RID_MENU_START + 12
+#define RID_NEW_FORM RID_MENU_START + 13
+#define MENU_BROWSER_DEFAULTCONTEXT RID_MENU_START + 14
+#define RID_MENU_REFRESH_DATA RID_MENU_START + 15
+#define RID_MENU_JOINVIEW_CONNECTION RID_MENU_START + 16
+#define RID_MENU_JOINVIEW_TABLE RID_MENU_START + 17
+
+
+
+//========================================================================
+// controls
+
+#define RID_DB_TAB_EDITOR RID_CONTROL_START + 0
+#define RID_MYSQL_NATIVE_SETTINGS RID_CONTROL_START + 1
+
+//========================================================================
+// strings
+#define STR_TBL_TITLE RID_STR_GEN_START
+#define STR_ERROR_DURING_CREATION RID_STR_GEN_START + 1
+#define RID_STR_CONNECTION_LOST RID_STR_GEN_START + 2
+#define STR_NAME_ALREADY_EXISTS RID_STR_GEN_START + 3
+// free
+#define STR_TITLE_CONFIRM_DELETION RID_STR_GEN_START + 5
+#define STR_STAT_WARNING RID_STR_GEN_START + 6
+#define STR_TABLEDESIGN_DATASOURCE_DELETED RID_STR_GEN_START + 7
+#define STR_TABLEDESIGN_DBFIELDTYPES RID_STR_GEN_START + 8
+#define STR_QRY_CONTINUE RID_STR_GEN_START + 9
+#define STR_COLUMN_NAME RID_STR_GEN_START + 10
+#define STR_ERROR_OCCURRED_WHILE_COPYING RID_STR_GEN_START + 11
+#define STR_MISSING_TABLES_XDROP RID_STR_GEN_START + 12
+#define STR_QUERY_DELETE_TABLE RID_STR_GEN_START + 13
+#define STR_BUTTON_TEXT_ALL RID_STR_GEN_START + 14
+#define STR_COULDNOTCREATE_DRIVERMANAGER RID_STR_GEN_START + 15
+#define STR_UNEXPECTED_ERROR RID_STR_GEN_START + 16
+#define STR_REMEMBERPASSWORD_SESSION RID_STR_GEN_START + 17
+#define STR_ENTER_CONNECTION_PASSWORD RID_STR_GEN_START + 18
+#define STR_NOREGISTEREDDRIVER RID_STR_GEN_START + 19
+#define STR_DATASOURCE_DELETED RID_STR_GEN_START + 20
+#define STR_QUERY_UNDO_MODIFYSQLEDIT RID_STR_GEN_START + 21
+#define STR_QRY_TITLE RID_STR_GEN_START + 22
+#define STR_VIEW_TITLE RID_STR_GEN_START + 23
+#define STR_SUB_DOCS_WITH_SCRIPTS RID_STR_GEN_START + 24
+#define STR_SUB_DOCS_WITH_SCRIPTS_DETAIL RID_STR_GEN_START + 25
+#define STR_TABLEDESIGN_DUPLICATE_NAME RID_STR_GEN_START + 26
+#define STR_COULDNOTCONNECT_DATASOURCE RID_STR_GEN_START + 27
+#define STR_NO_TABLE_FORMAT_INSIDE RID_STR_GEN_START + 28
+#define RID_STR_QUERIES_CONTAINER RID_STR_GEN_START + 29
+#define RID_STR_TABLES_CONTAINER RID_STR_GEN_START + 30
+#define STR_NEW_FOLDER RID_STR_GEN_START + 31
+#define RID_STR_FORM RID_STR_GEN_START + 32
+#define RID_STR_REPORT RID_STR_GEN_START + 33
+#define STR_FRM_LABEL RID_STR_GEN_START + 34
+#define STR_RPT_LABEL RID_STR_GEN_START + 35
+#define STR_FOLDER_LABEL RID_STR_GEN_START + 36
+#define STR_TABLEDESIGN_NO_PRIM_KEY_HEAD RID_STR_GEN_START + 37
+#define STR_TABLEDESIGN_NO_PRIM_KEY RID_STR_GEN_START + 38
+ // FREE
+#define RID_STR_EXTENSION_NOT_PRESENT RID_STR_GEN_START + 40
+#define RID_STR_EXTENSION_NAME RID_STR_GEN_START + 41
+
+//========================================================================
+// untyped resources
+
+// free
+#define RSC_CHARSETS RID_UNTYPED_START + 2
+// free
+#define RSC_QUERY_OBJECT_TYPE RID_UNTYPED_START + 4
+#define IMG_TABLESUBCRIPTION_SC RID_UNTYPED_START + 5
+// free
+#define IMG_TABLESUBCRIPTION_LC RID_UNTYPED_START + 7
+// free
+#define IMG_QUERYADMINISTRATION_SC RID_UNTYPED_START + 9
+// free
+#define IMG_QUERYADMINISTRATION_LC RID_UNTYPED_START + 11
+// free
+#define IMG_DOCUMENTLINKS_SC RID_UNTYPED_START + 13
+// free
+#define IMG_DOCUMENTLINKS_LC RID_UNTYPED_START + 15
+// free
+
+//========================================================================
+// various
+
+#define PB_FORMAT RID_MISC_START + 0
+#define FIXED_NO_CONNECTION RID_MISC_START + 1
+#define LB_LEFT_TABLE RID_MISC_START + 2
+#define LB_RIGHT_TABLE RID_MISC_START + 3
+#define LB_CONTROL RID_MISC_START + 4
+#define FL_INVOLVED_TABLES RID_MISC_START + 5
+#define FL_INVOLVED_FIELDS RID_MISC_START + 6
+
+#endif // _DBU_RESOURCE_HRC_
+
diff --git a/dbaccess/source/ui/inc/dbu_tbl.hrc b/dbaccess/source/ui/inc/dbu_tbl.hrc
new file mode 100644
index 000000000000..a0a6b2eb8736
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_tbl.hrc
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_TBL_HRC_
+#define _DBU_TBL_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+#define STR_HELP_AUTOINCREMENT_VALUE RID_STR_TBL_START
+#define STR_TABLEDESIGN_UNDO_PRIMKEY RID_STR_TBL_START + 1
+#define STR_VALUE_YES RID_STR_TBL_START + 2
+#define STR_VALUE_NO RID_STR_TBL_START + 3
+#define STR_VALUE_ASC RID_STR_TBL_START + 4
+#define STR_VALUE_DESC RID_STR_TBL_START + 5
+#define STR_VALUE_NONE RID_STR_TBL_START + 6
+#define STR_TAB_FIELD_NAME RID_STR_TBL_START + 7
+#define STR_TAB_FIELD_DATATYPE RID_STR_TBL_START + 8
+#define STR_TAB_FIELD_LENGTH RID_STR_TBL_START + 9
+#define STR_TAB_HELP_TEXT RID_STR_TBL_START + 10
+#define STR_TAB_FIELD_NULLABLE RID_STR_TBL_START + 11
+#define STR_FIELD_AUTOINCREMENT RID_STR_TBL_START + 12
+#define STR_TAB_PROPERTIES RID_STR_TBL_START + 13
+#define STR_TABPAGE_GENERAL RID_STR_TBL_START + 14
+#define STR_TAB_TABLE_DESCRIPTION RID_STR_TBL_START + 15
+#define STR_TAB_TABLE_PROPERTIES RID_STR_TBL_START + 16
+#define STR_TABED_UNDO_TYPE_CHANGED RID_STR_TBL_START + 17
+#define STR_TABED_UNDO_ROWDELETED RID_STR_TBL_START + 18
+#define STR_TABED_UNDO_ROWINSERTED RID_STR_TBL_START + 19
+#define STR_TABED_UNDO_NEWROWINSERTED RID_STR_TBL_START + 20
+#define STR_TABED_UNDO_PRIMKEY RID_STR_TBL_START + 21
+#define STR_HELP_AUTOINCREMENT RID_STR_TBL_START + 22
+#define STR_HELP_FORMAT_CODE RID_STR_TBL_START + 23
+#define STR_HELP_SCALE RID_STR_TBL_START + 24
+#define STR_HELP_LENGTH RID_STR_TBL_START + 25
+#define STR_HELP_NUMERIC_TYPE RID_STR_TBL_START + 26
+#define STR_HELP_TEXT_LENGTH RID_STR_TBL_START + 27
+#define STR_HELP_FIELD_REQUIRED RID_STR_TBL_START + 28
+#define STR_HELP_DEFAULT_VALUE RID_STR_TBL_START + 29
+#define STR_HELP_BOOL_DEFAULT RID_STR_TBL_START + 30
+#define STR_FORMAT RID_STR_TBL_START + 31
+#define STR_SCALE RID_STR_TBL_START + 32
+#define STR_LENGTH RID_STR_TBL_START + 33
+#define STR_NUMERIC_TYPE RID_STR_TBL_START + 34
+#define STR_TEXT_LENGTH RID_STR_TBL_START + 35
+#define STR_FIELD_REQUIRED RID_STR_TBL_START + 36
+#define STR_DEFAULT_VALUE RID_STR_TBL_START + 37
+#define STR_TABED_UNDO_CELLMODIFIED RID_STR_TBL_START + 38
+#define STR_TAB_FIELD_COLUMN_NAME RID_STR_TBL_START + 39
+#define STR_TBL_COLUMN_IS_KEYCOLUMN RID_STR_TBL_START + 40
+#define STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE RID_STR_TBL_START + 41
+#define STR_TABLEDESIGN_ALTER_ERROR RID_STR_TBL_START + 42
+#define STR_AUTOINCREMENT_VALUE RID_STR_TBL_START + 43
+#define STR_HELP_FORMAT_BUTTON RID_STR_TBL_START + 44
+#define STR_TABLEDESIGN_CONNECTION_MISSING RID_STR_TBL_START + 45
+#define STR_TAB_FIELD_COLUMN_DATATYPE RID_STR_TBL_START + 46
+#define STR_TABLEDESIGN_TITLE RID_STR_TBL_START + 47
+#define STR_NO_TYPE_INFO_AVAILABLE RID_STR_TBL_START + 48
+#define STR_CHANGE_COLUMN_NAME RID_STR_TBL_START + 49
+#define STR_CHANGE_COLUMN_TYPE RID_STR_TBL_START + 50
+#define STR_CHANGE_COLUMN_DESCRIPTION RID_STR_TBL_START + 51
+#define STR_CHANGE_COLUMN_ATTRIBUTE RID_STR_TBL_START + 52
+#define STR_TABLEDESIGN_SAVE_ERROR RID_STR_TBL_START + 53
+#define STR_TABLEDESIGN_COULD_NOT_DROP_COL RID_STR_TBL_START + 54
+#define STR_COLUMN_DESCRIPTION RID_STR_TBL_START + 55
+
+// please adjust checking before insert new strings
+
+#if STR_NO_TYPE_INFO_AVAILABLE > RID_STR_TBL_END
+#error Resource-Id Ueberlauf in #file, #line
+#endif
+
+#endif // _DBU_TBL_HRC_
+
+
diff --git a/dbaccess/source/ui/inc/dbu_uno.hrc b/dbaccess/source/ui/inc/dbu_uno.hrc
new file mode 100644
index 000000000000..f60fd615ec9e
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbu_uno.hrc
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_UNO_HRC_
+#define _DBU_UNO_HRC_
+
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+#define STR_REMEMBERPASSWORD_PERSISTENT ( RID_STR_UNO_START + 0 )
+#define STR_CTW_NO_VIEWS_SUPPORT ( RID_STR_UNO_START + 1 )
+#define STR_CTW_NO_PRIMARY_KEY_SUPPORT ( RID_STR_UNO_START + 2 )
+#define STR_CTW_INVALID_DATA_ACCESS_DESCRIPTOR ( RID_STR_UNO_START + 3 )
+#define STR_CTW_ONLY_TABLES_AND_QUERIES_SUPPORT ( RID_STR_UNO_START + 4 )
+#define STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ( RID_STR_UNO_START + 5 )
+#define STR_CTW_UNSUPPORTED_COLUMN_TYPE ( RID_STR_UNO_START + 6 )
+#define STR_CTW_ILLEGAL_PARAMETER_COUNT ( RID_STR_UNO_START + 7 )
+#define STR_CTW_ERROR_DURING_INITIALIZATION ( RID_STR_UNO_START + 8 )
+#define STR_CTW_ERROR_UNSUPPORTED_SETTING ( RID_STR_UNO_START + 9 )
+#define STR_CTW_ERROR_NO_QUERY ( RID_STR_UNO_START + 10 )
+#define STR_CTW_ERROR_INVALID_INTERACTIONHANDLER ( RID_STR_UNO_START + 11 )
+
+// please adjust when inserting new strings:
+#define RID_STR_UNO_LAST_USED STR_CTW_ERROR_INVALID_INTERACTIONHANDLER
+
+#if RID_STR_UNO_LAST_USED >= RID_STR_UNO_END
+#error too many resources in uno ....
+#endif
+
+#endif // _DBU_UNO_HRC_
+
+
diff --git a/dbaccess/source/ui/inc/dbwiz.hxx b/dbaccess/source/ui/inc/dbwiz.hxx
new file mode 100644
index 000000000000..414a3a0b5108
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbwiz.hxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBWIZ_HXX
+#define DBAUI_DBWIZ_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include "dsntypes.hxx"
+#include "IItemSetHelper.hxx"
+#include <comphelper/uno3.hxx>
+#include <svtools/wizardmachine.hxx>
+#include "moduledbu.hxx"
+#include <memory>
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+namespace dbaccess
+{
+ class ODsnTypeCollection;
+}
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= ODbTypeWizDialog
+//=========================================================================
+class OGeneralPage;
+class ODbDataSourceAdministrationHelper;
+/** tab dialog for administrating the office wide registered data sources
+*/
+class ODbTypeWizDialog : public svt::OWizardMachine , public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient
+{
+private:
+ OModuleClient m_aModuleClient;
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+ SfxItemSet* m_pOutSet;
+ ::dbaccess::ODsnTypeCollection*
+ m_pCollection; /// the DSN type collection instance
+ ::rtl::OUString m_eType;
+
+ sal_Bool m_bResetting : 1; /// sal_True while we're resetting the pages
+ sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing
+ sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
+
+public:
+ /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
+ after the dialog has been destroyed
+ */
+ ODbTypeWizDialog(Window* pParent
+ ,SfxItemSet* _pItems
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ );
+ virtual ~ODbTypeWizDialog();
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ // forwards to ODbDataSourceAdministrationHelper
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
+ virtual void clearPassword();
+ virtual sal_Bool saveDatasource();
+ virtual void setTitle(const ::rtl::OUString& _sTitle);
+ virtual void enableConfirmSettings( bool _bEnable );
+
+protected:
+ /// to override to create new pages
+ virtual TabPage* createPage(WizardState _nState);
+ virtual WizardState determineNextState(WizardState _nCurrentState) const;
+ virtual sal_Bool leaveState(WizardState _nState);
+ virtual ::svt::IWizardPageController*
+ getPageController( TabPage* _pCurrentPage ) const;
+ virtual sal_Bool onFinish();
+
+protected:
+ inline sal_Bool isUIEnabled() const { return m_bUIEnabled; }
+ inline void disabledUI() { m_bUIEnabled = sal_False; }
+
+ /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
+ void implSelectDatasource(const ::rtl::OUString& _rRegisteredName);
+ void resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource);
+
+ enum ApplyResult
+ {
+ AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed
+ AR_LEAVE_UNCHANGED, // no changes were made
+ AR_KEEP // don't leave the page (e.g. because an error occurred)
+ };
+ /** apply all changes made
+ */
+ ApplyResult implApplyChanges();
+
+private:
+ DECL_LINK(OnTypeSelected, OGeneralPage*);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBWIZ_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dbwizsetup.hxx b/dbaccess/source/ui/inc/dbwizsetup.hxx
new file mode 100644
index 000000000000..a6b4db6b6b02
--- /dev/null
+++ b/dbaccess/source/ui/inc/dbwizsetup.hxx
@@ -0,0 +1,197 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBWIZ2_HXX
+#define DBAUI_DBWIZ2_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include "dsntypes.hxx"
+#include "IItemSetHelper.hxx"
+#include <comphelper/uno3.hxx>
+#include <tools/urlobj.hxx>
+#include <memory>
+#include <svtools/roadmapwizard.hxx>
+#include <connectivity/dbtools.hxx>
+#include "moduledbu.hxx"
+
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(sdbc,XConnection)
+FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+class OGenericAdministrationPage;
+
+//=========================================================================
+//= ODbTypeWizDialogSetup
+//=========================================================================
+class OGeneralPage;
+class ODbDataSourceAdministrationHelper;
+/** tab dialog for administrating the office wide registered data sources
+*/
+class OMySQLIntroPageSetup;
+
+class ODbTypeWizDialogSetup : public svt::RoadmapWizard , public IItemSetHelper, public IDatabaseSettingsDialog,public dbaui::OModuleClient
+{
+
+private:
+ OModuleClient m_aModuleClient;
+ ::std::auto_ptr<ODbDataSourceAdministrationHelper> m_pImpl;
+ SfxItemSet* m_pOutSet;
+ ::rtl::OUString m_sURL;
+ ::rtl::OUString m_sOldURL;
+ sal_Bool m_bResetting : 1; /// sal_True while we're resetting the pages
+ sal_Bool m_bApplied : 1; /// sal_True if any changes have been applied while the dialog was executing
+ sal_Bool m_bUIEnabled : 1; /// <TRUE/> if the UI is enabled, false otherwise. Cannot be switched back to <TRUE/>, once it is <FALSE/>
+ sal_Bool m_bIsConnectable : 1;
+ String m_sRM_IntroText;
+ String m_sRM_dBaseText;
+ String m_sRM_TextText;
+ String m_sRM_MSAccessText;
+ String m_sRM_LDAPText;
+ String m_sRM_ADABASText;
+ String m_sRM_ADOText;
+ String m_sRM_JDBCText;
+ String m_sRM_MySQLNativePageTitle;
+ String m_sRM_OracleText;
+ String m_sRM_MySQLText;
+ String m_sRM_ODBCText;
+ String m_sRM_SpreadSheetText;
+ String m_sRM_AuthentificationText;
+ String m_sRM_FinalText;
+ INetURLObject m_aDocURL;
+ String m_sWorkPath;
+ OGeneralPage* m_pGeneralPage;
+ OMySQLIntroPageSetup* m_pMySQLIntroPage;
+ ::dbaccess::ODsnTypeCollection*
+ m_pCollection; /// the DSN type collection instance
+
+
+
+public:
+ /** ctor. The itemset given should have been created by <method>createItemSet</method> and should be destroyed
+ after the dialog has been destroyed
+ */
+ ODbTypeWizDialogSetup(Window* pParent
+ ,SfxItemSet* _pItems
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ,const ::com::sun::star::uno::Any& _aDataSourceName
+ );
+ virtual ~ODbTypeWizDialogSetup();
+
+ virtual const SfxItemSet* getOutputSet() const;
+ virtual SfxItemSet* getWriteOutputSet();
+
+ // forwards to ODbDataSourceAdministrationHelper
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const;
+ virtual ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >,sal_Bool> createConnection();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > getDriver();
+ virtual ::rtl::OUString getDatasourceType(const SfxItemSet& _rSet) const;
+ virtual void clearPassword();
+ virtual void setTitle(const ::rtl::OUString& _sTitle);
+ virtual void enableConfirmSettings( bool _bEnable );
+ virtual sal_Bool saveDatasource();
+ virtual String getStateDisplayName( WizardState _nState ) const;
+
+ /** returns <TRUE/> if the database should be opened, otherwise <FALSE/>.
+ */
+ sal_Bool IsDatabaseDocumentToBeOpened() const;
+
+ /** returns <TRUE/> if the table wizard should be opened, otherwise <FALSE/>.
+ */
+ sal_Bool IsTableWizardToBeStarted() const;
+
+protected:
+ /// to override to create new pages
+ virtual TabPage* createPage(WizardState _nState);
+ virtual sal_Bool leaveState(WizardState _nState);
+ virtual void enterState(WizardState _nState);
+ virtual ::svt::IWizardPageController* getPageController( TabPage* _pCurrentPage ) const;
+ virtual sal_Bool onFinish();
+
+protected:
+ inline sal_Bool isUIEnabled() const { return m_bUIEnabled; }
+ inline void disabledUI() { m_bUIEnabled = sal_False; }
+
+ /// select a datasource with a given name, adjust the item set accordingly, and everything like that ..
+ void implSelectDatasource(const ::rtl::OUString& _rRegisteredName);
+ void resetPages(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatasource);
+
+ enum ApplyResult
+ {
+ AR_LEAVE_MODIFIED, // somthing was modified and has successfully been committed
+ AR_LEAVE_UNCHANGED, // no changes were made
+ AR_KEEP // don't leave the page (e.g. because an error occurred)
+ };
+
+private:
+ /** declares a path with or without authentication, as indicated by the database type
+
+ @param _sURL
+ the data source type for which the path is declared. If this
+ data source type does not support authentication, the PAGE_DBSETUPWIZARD_AUTHENTIFICATION
+ state will be stripped from the sequence of states.
+ @param _nPathId
+ the ID of the path
+ @path
+ the first state in this path, following by an arbitrary number of others, as in
+ RoadmapWizard::declarePath.
+ */
+ void declareAuthDepPath( const ::rtl::OUString& _sURL, PathId _nPathId, const svt::RoadmapWizardTypes::WizardPath& _rPaths);
+
+ void RegisterDataSourceByLocation(const ::rtl::OUString& sPath);
+ sal_Bool SaveDatabaseDocument();
+ void activateDatabasePath();
+ String createUniqueFileName(const INetURLObject& rURL);
+ void CreateDatabase();
+ void createUniqueFolderName(INetURLObject* pURL);
+ ::dbaccess::DATASOURCE_TYPE VerifyDataSourceType(const ::dbaccess::DATASOURCE_TYPE _DatabaseType) const;
+
+ ::rtl::OUString getDefaultDatabaseType() const;
+
+ void updateTypeDependentStates();
+ sal_Bool callSaveAsDialog();
+ sal_Bool IsConnectionUrlRequired();
+ DECL_LINK(OnTypeSelected, OGeneralPage*);
+ DECL_LINK(OnChangeCreationMode, OGeneralPage*);
+ DECL_LINK(OnRecentDocumentSelected, OGeneralPage*);
+ DECL_LINK(OnSingleDocumentChosen, OGeneralPage*);
+ DECL_LINK(ImplClickHdl, OMySQLIntroPageSetup*);
+ DECL_LINK(ImplModifiedHdl, OGenericAdministrationPage*);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBWIZ2_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx b/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx
new file mode 100644
index 000000000000..c84b1dcdfd69
--- /dev/null
+++ b/dbaccess/source/ui/inc/defaultobjectnamecheck.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
+#define DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
+
+#include "objectnamecheck.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+#include <boost/noncopyable.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= HierarchicalNameCheck
+ //====================================================================
+ struct HierarchicalNameCheck_Impl;
+ /** class implementing the IObjectNameCheck interface, and checking given object names
+ against a hierarchical name container
+ */
+ class HierarchicalNameCheck :public ::boost::noncopyable
+ ,public IObjectNameCheck
+ {
+ private:
+ std::auto_ptr< HierarchicalNameCheck_Impl > m_pImpl;
+
+ public:
+ /** constructs a HierarchicalNameCheck instance
+ @param _rxNames
+ the hierarchic container of named objects, against which given names should be
+ checked
+ @param _rRelativeRoot
+ the root in the hierarchy against which given names should be checked
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the given container is <NULL/>
+ */
+ HierarchicalNameCheck(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess >& _rxNames,
+ const ::rtl::OUString& _rRelativeRoot
+ );
+
+ ~HierarchicalNameCheck();
+
+ // IObjectNameCheck overridables
+ virtual bool isNameValid(
+ const ::rtl::OUString& _rObjectName,
+ ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay
+ ) const;
+
+ private:
+ HierarchicalNameCheck(); // never implemented
+ };
+
+ //====================================================================
+ //= DynamicTableOrQueryNameCheck
+ //====================================================================
+ struct DynamicTableOrQueryNameCheck_Impl;
+ /** class implementing the IObjectNameCheck interface, and checking a given name
+ for being valid as either a query or a table name.
+
+ The class can be parametrized to act as either table name or query name validator.
+
+ For databases which support queries in queries, the name check is implicitly extended
+ to both queries and tables, no matter which category is checked. This prevents, for
+ such databases, that users can create a query with the name of an existing table,
+ or vice versa.
+
+ @seealso dbtools::DatabaseMetaData::supportsSubqueriesInFrom
+ @seealso com::sun::star::sdb::tools::XObjectNames::checkNameForCreate
+ */
+ class DynamicTableOrQueryNameCheck :public ::boost::noncopyable
+ ,public IObjectNameCheck
+ {
+ private:
+ std::auto_ptr< DynamicTableOrQueryNameCheck_Impl > m_pImpl;
+
+ public:
+ /** constructs a DynamicTableOrQueryNameCheck instance
+ @param _rxSdbLevelConnection
+ a connection supporting the css.sdb.Connection service, in other word, it
+ does expose the XTablesSupplier and XQueriesSupplier interfaces.
+ @param _nCommandType
+ specifies whether table names or query names should be checked. Only valid values
+ are CommandType::TABLE and CommandType::QUERY.
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if the given connection is <NULL/>, or the given command type is neither
+ CommandType::TABLE nor CommandType::QUERY.
+ */
+ DynamicTableOrQueryNameCheck(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxSdbLevelConnection,
+ sal_Int32 _nCommandType
+ );
+
+ ~DynamicTableOrQueryNameCheck();
+
+ // IObjectNameCheck overridables
+ virtual bool isNameValid(
+ const ::rtl::OUString& _rObjectName,
+ ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay
+ ) const;
+
+ private:
+ DynamicTableOrQueryNameCheck(); // never implemented
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx
new file mode 100644
index 000000000000..250c667166be
--- /dev/null
+++ b/dbaccess/source/ui/inc/directsql.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBACCESS_UI_DIRECTSQL_HXX_
+#define _DBACCESS_UI_DIRECTSQL_HXX_
+
+#include <vcl/dialog.hxx>
+#include <svtools/editsyntaxhighlighter.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <comphelper/stl_types.hxx>
+#include <deque>
+
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <unotools/eventlisteneradapter.hxx>
+#include "moduledbu.hxx"
+#include <osl/mutex.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= DirectSQLDialog
+ //====================================================================
+ class DirectSQLDialog
+ :public ModalDialog
+ ,public ::utl::OEventListenerAdapter
+ {
+ protected:
+ OModuleClient m_aModuleClient;
+ ::osl::Mutex m_aMutex;
+
+ FixedLine m_aFrame;
+ FixedText m_aSQLLabel;
+ MultiLineEditSyntaxHighlight m_aSQL;
+ PushButton m_aExecute;
+ FixedText m_aHistoryLabel;
+ ListBox* m_pSQLHistory;
+ FixedLine m_aStatusFrame;
+ MultiLineEdit m_aStatus;
+ FixedLine m_aButtonSeparator;
+ HelpButton m_aHelp;
+ PushButton m_aClose;
+
+ typedef ::std::deque< String > StringQueue;
+ StringQueue m_aStatementHistory; // previous statements
+ StringQueue m_aNormalizedHistory; // previous statements, normalized to be used in the list box
+
+ sal_Int32 m_nHistoryLimit;
+ sal_Int32 m_nStatusCount;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+
+ public:
+ DirectSQLDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn);
+ ~DirectSQLDialog();
+
+ /// number of history entries
+ sal_Int32 getHistorySize() const;
+
+ protected:
+ void executeCurrent();
+ void switchToHistory(sal_Int32 _nHistoryPos, sal_Bool _bUpdateListBox = sal_True);
+
+ // OEventListenerAdapter
+ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource );
+
+ protected:
+ DECL_LINK( OnExecute, void* );
+ DECL_LINK( OnClose, void* );
+ DECL_LINK( OnListEntrySelected, void* );
+ DECL_LINK( OnStatementModified, void* );
+
+ private:
+ /// adds a statement to the statement history
+ void implAddToStatementHistory(const String& _rStatement);
+
+ /// ensures that our history has at most m_nHistoryLimit entries
+ void implEnsureHistoryLimit();
+
+ /// executes the statement given, adds the status to the status list
+ void implExecuteStatement(const String& _rStatement);
+
+ /// adds a status text to the status list
+ void addStatusText(const String& _rMessage);
+
+#ifdef DBG_UTIL
+ const sal_Char* impl_CheckInvariants() const;
+#endif
+ };
+
+ //====================================================================
+#ifdef DBG_UTIL
+#define CHECK_INVARIANTS(methodname) \
+ { \
+ const sal_Char* pError = impl_CheckInvariants(); \
+ if (pError) \
+ OSL_FAIL((ByteString(methodname) += ByteString(": ") += ByteString(pError)).GetBuffer()); \
+ }
+#else
+#define CHECK_INVARIANTS(methodname)
+#endif
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // _DBACCESS_UI_DIRECTSQL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dlgattr.hrc b/dbaccess/source/ui/inc/dlgattr.hrc
new file mode 100644
index 000000000000..c26d7ae92280
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgattr.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_SBATTRDLG_HRC
+#define DBAUI_SBATTRDLG_HRC
+
+#define TP_ATTR_CHAR 1
+#define TP_ATTR_NUMBER 2
+#define TP_ATTR_ALIGN 4
+#define ST_ROW 5
+
+#endif//DBAUI_SBATTRDLG_HRC
+
diff --git a/dbaccess/source/ui/inc/dlgattr.hxx b/dbaccess/source/ui/inc/dlgattr.hxx
new file mode 100644
index 000000000000..e4fe6e158c96
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgattr.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_SBATTRDLG_HXX
+#define DBAUI_SBATTRDLG_HXX
+
+
+#include "dlgattr.hrc"
+
+#include <sfx2/tabdlg.hxx>
+#include <tools/solar.h>
+
+
+
+class SvxNumberInfoItem;
+class SfxItemSet;
+class SvNumberFormatter;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ class SbaSbAttrDlg : public SfxTabDialog
+ {
+ String aTitle;
+ SvxNumberInfoItem* pNumberInfoItem;
+
+ public:
+ SbaSbAttrDlg( Window * pParent, const SfxItemSet*, SvNumberFormatter*, sal_uInt16 nFlags = TP_ATTR_CHAR , sal_Bool bRow = sal_False);
+ ~SbaSbAttrDlg();
+
+ virtual void PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage );
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif//DBAUI_SBATTRDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dlgsave.hxx b/dbaccess/source/ui/inc/dlgsave.hxx
new file mode 100644
index 000000000000..315aad0e7aa5
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgsave.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DLGSAVE_HXX
+#define DBAUI_DLGSAVE_HXX
+
+#include "apitools.hxx"
+#include <vcl/dialog.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <vcl/msgbox.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace container {
+ class XNameAccess;
+ class XHierarchicalNameAccess;
+ }
+ namespace sdbc {
+ class XDatabaseMetaData;
+ class XConnection;
+ }
+}}}
+
+
+#define SAD_DEFAULT 0x0000
+#define SAD_ADDITIONAL_DESCRIPTION 0x0001
+
+#define SAD_TITLE_STORE_AS 0x0000
+#define SAD_TITLE_PASTE_AS 0x0100
+#define SAD_TITLE_RENAME 0x0200
+
+class Button;
+class Edit;
+namespace dbaui
+{
+ class OSaveAsDlgImpl;
+ class IObjectNameCheck;
+ class OSaveAsDlg : public ModalDialog
+ {
+ private:
+ OSaveAsDlgImpl* m_pImpl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ public:
+ OSaveAsDlg( Window * pParent,const sal_Int32& _rType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const String& rDefault,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags = SAD_DEFAULT | SAD_TITLE_STORE_AS);
+
+ OSaveAsDlg( Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const String& _rDefault,
+ const String& _sLabel,
+ const IObjectNameCheck& _rObjectNameCheck,
+ sal_Int32 _nFlags = SAD_DEFAULT | SAD_TITLE_STORE_AS);
+ virtual ~OSaveAsDlg();
+
+ String getName() const;
+ String getCatalog() const;
+ String getSchema() const;
+ private:
+ DECL_LINK(ButtonClickHdl, Button *);
+ DECL_LINK(EditModifyHdl, Edit * );
+
+ void implInitOnlyTitle(const String& _rLabel);
+ void implInit();
+ };
+}
+
+#endif // DBAUI_DLGSAVE_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dlgsize.hxx b/dbaccess/source/ui/inc/dlgsize.hxx
new file mode 100644
index 000000000000..7b2e0152d226
--- /dev/null
+++ b/dbaccess/source/ui/inc/dlgsize.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBAUI_DLGSIZE_HXX
+#define _DBAUI_DLGSIZE_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/field.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ class DlgSize : public ModalDialog
+ {
+ private:
+ sal_Int32 m_nPrevValue, m_nStandard;
+ void SetValue( sal_Int32 nVal );
+
+ protected:
+ DECL_LINK( CbClickHdl, Button * );
+
+ FixedText aFT_VALUE;
+ MetricField aMF_VALUE;
+ CheckBox aCB_STANDARD;
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+ public:
+ DlgSize( Window * pParent, sal_Int32 nVal, sal_Bool bRow, sal_Int32 _nAlternativeStandard = -1 );
+ ~DlgSize();
+
+ sal_Int32 GetValue();
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_DLGSIZE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dsitems.hxx b/dbaccess/source/ui/inc/dsitems.hxx
new file mode 100644
index 000000000000..9cc4d85808c8
--- /dev/null
+++ b/dbaccess/source/ui/inc/dsitems.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_DATASOURCEITEMS_HXX_
+#define _DBAUI_DATASOURCEITEMS_HXX_
+
+typedef sal_Int32 ItemID;
+
+//========================================================================
+//= item ids for the data source administration dialog
+
+#define DSID_NAME 1 // name of a data source, SfxStringItem
+#define DSID_ORIGINALNAME 2 // orginal name, internal, SfxStringItem
+#define DSID_CONNECTURL 3 // connection URL, SfxStringItem
+#define DSID_TABLEFILTER 4 // table filter, OStringListItem
+#define DSID_TYPECOLLECTION 5 // collection of data source types, ODsnTypeCollection
+#define DSID_INVALID_SELECTION 6 // is the selection (thus the set data) invalid?, SfxBoolItem
+#define DSID_READONLY 7 // is the selection (thus the set data) readonly?, SfxBoolItem
+#define DSID_USER 8 // the user name used for logon, SfxStringItem
+#define DSID_PASSWORD 9 // the password used for logon, SfxStringItem
+#define DSID_ADDITIONALOPTIONS 10 // additional options used for connecting, SfxStringItem
+#define DSID_CHARSET 11 // character set to use, SfxStringItem by now
+#define DSID_PASSWORDREQUIRED 12 // is the password required to connect?, SfxBoolItem
+#define DSID_SHOWDELETEDROWS 13 // show deleted rows?, SfxBoolItem
+#define DSID_ALLOWLONGTABLENAMES 14 // allow tables names longer than 8.3?, SfxBoolItem
+#define DSID_JDBCDRIVERCLASS 15 // JDBC driver class, SfxStringItem
+#define DSID_FIELDDELIMITER 16 // field delimiter, SfxUInt16Item
+#define DSID_TEXTDELIMITER 17 // text delimiter, SfxUInt16Item
+#define DSID_DECIMALDELIMITER 18 // decimal delimiter, SfxUInt16Item
+#define DSID_THOUSANDSDELIMITER 19 // thousands delimiter, SfxUInt16Item
+#define DSID_TEXTFILEEXTENSION 20 // extension for text files, SfxStringItem
+#define DSID_TEXTFILEHEADER 21 // the text file contains a header?, SfxBoolItem
+#define DSID_PARAMETERNAMESUBST 22
+#define DSID_CONN_PORTNUMBER 23
+#define DSID_SUPPRESSVERSIONCL 24 // meta data: sal_True if the data source described by the set is to-be-deleted
+#define DSID_DATASOURCE_UNO 25 // meta data: OPropertySetItem, the data source the set represents
+#define DSID_CONN_SHUTSERVICE 26
+#define DSID_CONN_DATAINC 27
+#define DSID_CONN_CACHESIZE 28
+#define DSID_CONN_CTRLUSER 29
+#define DSID_CONN_CTRLPWD 30
+#define DSID_USECATALOG 31 // should the driver use the catalog name when the database is filebased
+#define DSID_CONN_HOSTNAME 32
+#define DSID_CONN_LDAP_BASEDN 33
+#define DSID_CONN_LDAP_PORTNUMBER 34
+#define DSID_CONN_LDAP_ROWCOUNT 35
+#define DSID_SQL92CHECK 36
+#define DSID_AUTOINCREMENTVALUE 37
+#define DSID_AUTORETRIEVEVALUE 38
+#define DSID_AUTORETRIEVEENABLED 39
+#define DSID_APPEND_TABLE_ALIAS 40
+#define DSID_MYSQL_PORTNUMBER 41
+#define DSID_IGNOREDRIVER_PRIV 42
+#define DSID_BOOLEANCOMPARISON 43
+#define DSID_ORACLE_PORTNUMBER 44
+#define DSID_ENABLEOUTERJOIN 45
+#define DSID_CATALOG 46
+#define DSID_SCHEMA 47
+#define DSID_INDEXAPPENDIX 48
+#define DSID_CONN_LDAP_USESSL 49
+#define DSID_DOCUMENT_URL 50
+#define DSID_DOSLINEENDS 51
+#define DSID_DATABASENAME 52
+#define DSID_AS_BEFORE_CORRNAME 53
+#define DSID_CHECK_REQUIRED_FIELDS 54
+#define DSID_IGNORECURRENCY 55
+#define DSID_CONN_SOCKET 56
+#define DSID_ESCAPE_DATETIME 57
+#define DSID_NAMED_PIPE 58
+#define DSID_PRIMARY_KEY_SUPPORT 59
+#define DSID_MAX_ROW_SCAN 60
+ // don't forget to adjust DSID_LAST_ITEM_ID below!
+
+
+//========================================================================
+//= item range. Adjust this if you introduce new items above
+
+#define DSID_FIRST_ITEM_ID DSID_NAME
+#define DSID_LAST_ITEM_ID DSID_MAX_ROW_SCAN
+
+#endif // _DBAUI_DATASOURCEITEMS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/dsmeta.hxx b/dbaccess/source/ui/inc/dsmeta.hxx
new file mode 100644
index 000000000000..5efa09c0c3cb
--- /dev/null
+++ b/dbaccess/source/ui/inc/dsmeta.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_DSMETA_HXX
+#define DBACCESS_DSMETA_HXX
+
+#include "dsntypes.hxx"
+#include "dsitems.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= AutheticationMode
+ //====================================================================
+ enum AuthenticationMode
+ {
+ AuthNone,
+ AuthUserPwd,
+ AuthPwd
+ };
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ class FeatureSet;
+ class DataSourceMetaData_Impl;
+ /** encapsulates meta data for a data source
+
+ On the long run, this class should a) encapsulate *all* meta data which
+ currently is hard coded somewhere in the program logic and b) be initialized
+ from the configuration.
+
+ At the moment, the data a) is still hard coded in the, well, code and b)
+ contains meta data about the advanced settings only.
+ */
+ class DataSourceMetaData
+ {
+ public:
+ DataSourceMetaData( const ::rtl::OUString& _sURL );
+ ~DataSourceMetaData();
+
+ /// returns a struct describing this data source type's support for our known advanced settings
+ const FeatureSet& getFeatureSet() const;
+
+ /// determines whether or not the data source requires authentication
+ static AuthenticationMode getAuthentication( const ::rtl::OUString& _sURL );
+
+ private:
+ ::boost::shared_ptr< DataSourceMetaData_Impl > m_pImpl;
+ };
+
+ //====================================================================
+ //= FeatureSet
+ //====================================================================
+ /** can be used to ask for (UI) support for certain advanced features
+ */
+ class FeatureSet
+ {
+ public:
+ typedef ::std::set< ItemID >::const_iterator const_iterator;
+
+ public:
+ inline FeatureSet() { }
+
+ inline void put( const ItemID _id ) { m_aContent.insert( _id ); }
+ inline bool has( const ItemID _id ) const { return m_aContent.find( _id ) != m_aContent.end(); }
+
+ inline bool supportsAnySpecialSetting() const;
+ inline bool supportsGeneratedValues() const;
+
+ inline const_iterator begin() const { return m_aContent.begin(); }
+ inline const_iterator end() const { return m_aContent.end(); }
+
+ private:
+ ::std::set< ItemID > m_aContent;
+ };
+
+ //--------------------------------------------------------------------
+ inline bool FeatureSet::supportsGeneratedValues() const
+ {
+ return has( DSID_AUTORETRIEVEENABLED );
+ }
+
+ //--------------------------------------------------------------------
+ inline bool FeatureSet::supportsAnySpecialSetting() const
+ {
+ return has( DSID_SQL92CHECK )
+ || has( DSID_APPEND_TABLE_ALIAS )
+ || has( DSID_AS_BEFORE_CORRNAME )
+ || has( DSID_ENABLEOUTERJOIN )
+ || has( DSID_IGNOREDRIVER_PRIV )
+ || has( DSID_PARAMETERNAMESUBST )
+ || has( DSID_SUPPRESSVERSIONCL )
+ || has( DSID_CATALOG )
+ || has( DSID_SCHEMA )
+ || has( DSID_INDEXAPPENDIX )
+ || has( DSID_DOSLINEENDS )
+ || has( DSID_BOOLEANCOMPARISON )
+ || has( DSID_CHECK_REQUIRED_FIELDS )
+ || has( DSID_IGNORECURRENCY )
+ || has( DSID_ESCAPE_DATETIME )
+ || has( DSID_PRIMARY_KEY_SUPPORT )
+ || has( DSID_MAX_ROW_SCAN )
+ ;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_DSMETA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/exsrcbrw.hxx b/dbaccess/source/ui/inc/exsrcbrw.hxx
new file mode 100644
index 000000000000..34b6e96ec86d
--- /dev/null
+++ b/dbaccess/source/ui/inc/exsrcbrw.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_EXTCTRLR_HXX
+#define _SBA_EXTCTRLR_HXX
+
+#include "brwctrlr.hxx"
+
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+//==============================================================================
+//= SbaExternalSourceBrowser
+//==============================================================================
+
+namespace dbaui
+{
+ class SbaXFormAdapter;
+ class SbaExternalSourceBrowser
+ :public SbaXDataBrowserController
+ ,public ::com::sun::star::util::XModifyBroadcaster
+ {
+ ::cppu::OInterfaceContainerHelper m_aModifyListeners;
+ // for multiplexing the modify events
+ SbaXFormAdapter* m_pDataSourceImpl;
+ sal_Bool m_bInQueryDispatch;
+ // our queryDispatch will ask our frame, which first will ask our queryDispatch, so we need to protect against
+ // recursion
+
+ public:
+ SbaExternalSourceBrowser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // UNO
+ DECLARE_UNO3_DEFAULTS(SbaExternalSourceBrowser, OGenericUnoController);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+ // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > > getIdlClasses(void);
+
+ // static ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > getStaticIdlClass();
+
+ // ::com::sun::star::frame::XDispatch
+ virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::util::XModifyListener
+ virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::util::XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+
+ // ::com::sun::star::form::XLoadListener
+ virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~SbaExternalSourceBrowser();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > CreateForm();
+ virtual sal_Bool InitializeForm( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties );
+
+ virtual sal_Bool LoadForm();
+
+ void Attach(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > & xMaster);
+
+ void ClearView();
+
+ void startListening();
+ void stopListening();
+ };
+}
+
+#endif // _SBA_EXTCTRLR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/formadapter.hxx b/dbaccess/source/ui/inc/formadapter.hxx
new file mode 100644
index 000000000000..f85cc2bd62e9
--- /dev/null
+++ b/dbaccess/source/ui/inc/formadapter.hxx
@@ -0,0 +1,449 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_FORMADAPTER_HXX
+#define _SBA_FORMADAPTER_HXX
+
+#include "sbamultiplex.hxx"
+
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/form/XSubmit.hpp>
+#include <com/sun/star/form/XDatabaseParameterBroadcaster.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/implbase12.hxx>
+#include <cppuhelper/implbase10.hxx>
+#include "moduledbu.hxx"
+
+namespace dbaui
+{
+ //==================================================================
+ // SbaXFormAdapter
+ //==================================================================
+
+ typedef ::cppu::WeakImplHelper12< ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+ , ::com::sun::star::sdb::XResultSetAccess
+ , ::com::sun::star::sdbc::XResultSetUpdate
+ , ::com::sun::star::sdbc::XRowSet
+ , ::com::sun::star::sdb::XRowSetApproveBroadcaster
+ , ::com::sun::star::sdbcx::XRowLocate
+ , ::com::sun::star::sdbc::XRowUpdate
+ , ::com::sun::star::sdbc::XRow
+ , ::com::sun::star::sdbcx::XColumnsSupplier
+ , ::com::sun::star::sdbc::XColumnLocate
+ // --- stardiv::one::form::component::DatabaseForm ---
+ , ::com::sun::star::sdbc::XParameters
+ , ::com::sun::star::sdbcx::XDeleteRows
+ > SbaXFormAdapter_BASE1;
+ typedef ::cppu::ImplHelper12 < ::com::sun::star::sdbc::XWarningsSupplier
+ , ::com::sun::star::sdbc::XCloseable
+ , ::com::sun::star::form::XLoadable
+ , ::com::sun::star::sdb::XSQLErrorBroadcaster
+ , ::com::sun::star::form::XDatabaseParameterBroadcaster
+ // --- stardiv::one::form::component::Form ---
+ , ::com::sun::star::form::XForm
+ , ::com::sun::star::form::XSubmit
+ , ::com::sun::star::awt::XTabControllerModel
+ // --- stardiv::one::form::FormComponent ---
+ , ::com::sun::star::lang::XComponent
+ , ::com::sun::star::beans::XFastPropertySet
+ // already present : ::com::sun::star::form::XFormComponent (base of ::com::sun::star::form::XForm)
+ , ::com::sun::star::beans::XMultiPropertySet
+ , ::com::sun::star::container::XNamed
+ > SbaXFormAdapter_BASE2;
+ typedef ::cppu::ImplHelper10 < ::com::sun::star::io::XPersistObject
+ , ::com::sun::star::beans::XPropertySet
+ // --- stardiv::one::data::DatabaseCursor ---
+ , ::com::sun::star::util::XCancellable
+ // already present : ::com::sun::star::beans::XPropertySet
+ // --- stardiv::one::data::DatabaseComponent ---
+ // already present : ::com::sun::star::lang::XComponent
+ // already present : ::com::sun::star::container::XChild (base of ::com::sun::star::form::XForm)
+ // interfaces I don't know the service which they belong to ;)
+ // (they are supported by FmXDatabaseForm, se we support it, too)
+ , ::com::sun::star::beans::XPropertyState
+ , ::com::sun::star::form::XReset
+ , ::com::sun::star::container::XNameContainer
+ , ::com::sun::star::container::XIndexContainer
+ , ::com::sun::star::container::XContainer
+ , ::com::sun::star::container::XEnumerationAccess
+ // interfaces we need because of other reasons
+ , ::com::sun::star::beans::XPropertyChangeListener
+ > SbaXFormAdapter_BASE3;
+
+ class SbaXFormAdapter
+ :public SbaXFormAdapter_BASE1
+ ,public SbaXFormAdapter_BASE2
+ ,public SbaXFormAdapter_BASE3
+ {
+ private:
+ OModuleClient m_aModuleClient;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xMainForm;
+ ::osl::Mutex m_aMutex;
+
+ SbaXLoadMultiplexer m_aLoadListeners;
+ SbaXRowSetMultiplexer m_aRowSetListeners;
+ SbaXRowSetApproveMultiplexer m_aRowSetApproveListeners;
+ SbaXSQLErrorMultiplexer m_aErrorListeners;
+ SbaXParameterMultiplexer m_aParameterListeners;
+ SbaXSubmitMultiplexer m_aSubmitListeners;
+ SbaXResetMultiplexer m_aResetListeners;
+
+ SbaXPropertyChangeMultiplexer m_aPropertyChangeListeners;
+ SbaXVetoableChangeMultiplexer m_aVetoablePropertyChangeListeners;
+ SbaXPropertiesChangeMultiplexer m_aPropertiesChangeListeners;
+
+ ::cppu::OInterfaceContainerHelper m_aDisposeListeners;
+ ::cppu::OInterfaceContainerHelper m_aContainerListeners;
+
+ // hierarchy administration
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > > m_aChildren;
+ ::std::vector< ::rtl::OUString > m_aChildNames;
+
+ // properties
+ ::rtl::OUString m_sName;
+ sal_Int32 m_nNamePropHandle;
+
+ public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > getAttachedForm() const { return m_xMainForm; }
+
+ public:
+ SbaXFormAdapter();
+ ~SbaXFormAdapter();
+
+ // ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > getIdlClass();
+ // ::com::sun::star::uno::Sequence<::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass > > getIdlClasses();
+
+ void AttachForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xNewMaster);
+
+ // UNO
+ DECLARE_UNO3_DEFAULTS(SbaXFormAdapter, SbaXFormAdapter_BASE1);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XCloseable
+ virtual void SAL_CALL close() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn(const ::rtl::OUString& columnName) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XColumnsSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getColumns() throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XRow
+ virtual sal_Bool SAL_CALL wasNull() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark(const ::com::sun::star::uno::Any& bookmark) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark(const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks(const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark(const ::com::sun::star::uno::Any& bookmark) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XRowUpdate
+ virtual void SAL_CALL updateNull(sal_Int32 columnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte(sal_Int32 columnIndex, sal_Int8 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort(sal_Int32 columnIndex, sal_Int16 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt(sal_Int32 columnIndex, sal_Int32 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong(sal_Int32 columnIndex, sal_Int64 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat(sal_Int32 columnIndex, float x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble(sal_Int32 columnIndex, double x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString(sal_Int32 columnIndex, const ::rtl::OUString& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes(sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream(sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream(sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject(sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject(sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XResultSet
+ virtual sal_Bool SAL_CALL next() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute(sal_Int32 row) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative(sal_Int32 rows) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XResultSetUpdate
+ virtual void SAL_CALL insertRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XRowSet
+ virtual void SAL_CALL execute() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addRowSetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRowSetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >& listener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbcx::XDeleteRows
+ virtual ::com::sun::star::uno::Sequence<sal_Int32> SAL_CALL deleteRows(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdb::XRowSetApproveBroadcaster
+ virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener >& listener) throw(::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::sdbc::XSQLErrorBroadcaster
+ virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& _rListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener >& _rListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdb::XResultSetAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL createResultSet() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::form::XLoadable
+ virtual void SAL_CALL load() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unload() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reload() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLoaded() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addLoadListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeLoadListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::sdbc::XParameters
+ virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString(sal_Int32 parameterIndex, const ::rtl::OUString& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::form::XDatabaseParameterBroadcaster
+ virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XChild
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent) throw(::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::form::XSubmit
+ virtual void SAL_CALL submit(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& aControl, const ::com::sun::star::awt::MouseEvent& aMouseEvt) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addSubmitListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XSubmitListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSubmitListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XSubmitListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::awt::XTabControllerModel
+ virtual sal_Bool SAL_CALL getGroupControl() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setGroupControl(sal_Bool GroupControl) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setControlModels(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setGroup(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& _rGroup, const ::rtl::OUString& GroupName) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getGroupCount() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL getGroup(sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& _rGroup, ::rtl::OUString& Name) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL getGroupByName(const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& _rGroup) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName(const ::rtl::OUString& aName) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::io::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream >& _rxOutStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream >& _rxInStream) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XMultiPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertiesChangeListener(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertiesChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL firePropertiesChangeEvent(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertySet
+ virtual void SAL_CALL setPropertyValue(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener(const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener(const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::util::XCancellable
+ virtual void SAL_CALL cancel() throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyState
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(const ::rtl::OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyToDefault(const ::rtl::OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault(const ::rtl::OUString& aPropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::form::XReset
+ virtual void SAL_CALL reset() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeResetListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& aListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XNameContainer
+ virtual void SAL_CALL insertByName(const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByName(const ::rtl::OUString& Name) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XNameReplace
+ virtual void SAL_CALL replaceByName(const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName(const ::rtl::OUString& aName) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& aName) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XIndexContainer
+ virtual void SAL_CALL insertByIndex(sal_Int32 _rIndex, const ::com::sun::star::uno::Any& Element) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByIndex(sal_Int32 _rIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XIndexReplace
+ virtual void SAL_CALL replaceByIndex(sal_Int32 _rIndex, const ::com::sun::star::uno::Any& Element) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _rIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XContainer
+ virtual void SAL_CALL addContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeContainerListener(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // container handling
+ void implInsert(const ::com::sun::star::uno::Any& aElement, sal_Int32 nIndex, const ::rtl::OUString* pNewElName = NULL) throw(::com::sun::star::lang::IllegalArgumentException);
+ sal_Int32 implGetPos(const ::rtl::OUString& rName);
+
+ void StopListening();
+ void StartListening();
+ };
+}
+#endif // _SBA_FORMADAPTER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/imageprovider.hxx b/dbaccess/source/ui/inc/imageprovider.hxx
new file mode 100644
index 000000000000..e3b5489203b0
--- /dev/null
+++ b/dbaccess/source/ui/inc/imageprovider.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#define DBACCESS_IMAGEPROVIDER_HXX
+
+#include <vcl/image.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+/** === end UNO includes === **/
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ // for convenience of our clients
+ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+
+ //====================================================================
+ //= ImageProvider
+ //====================================================================
+ struct ImageProvider_Data;
+ /** provides images for database objects such as tables, queries, forms, reports ...
+
+ At the moment, this class cares for small icons only, that is, icons which can be used
+ in a tree control. On the medium term, we should extend it with support for different-sized
+ icons.
+ */
+ class ImageProvider
+ {
+ private:
+ ::boost::shared_ptr< ImageProvider_Data > m_pData;
+
+ public:
+ /** creates a semi-functional ImageProvider instance
+
+ The resulting instance is not able to provide any concrete object images,
+ but only default images.
+ */
+ ImageProvider();
+
+ /** creates an ImageProvider instance
+
+ @param _rxConnection
+ denotes the connection to work for. Must not be <NULL/>.
+ */
+ ImageProvider(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ );
+
+ /** returns the image to be used for a database object with the given name
+
+ @param _nDatabaseObjectType
+ the type of the object. Must be one of the css.sdb.application.DatabaseObject
+ constants.
+ @param _rName
+ the name of the object
+ @param _out_rImage
+ the normal image to use for the object
+ @return
+ the image to be used for the object.
+ */
+ void getImages(
+ const String& _rName,
+ const sal_Int32 _nDatabaseObjectType,
+ Image& _out_rImage
+ );
+
+ /** returns the default image to be used for a database object
+
+ In opposite to getImages, this method does not check the concrete object
+ for its image, but returns a default image to be used for all objects of the given
+ type.
+
+ @param _nDatabaseObjectType
+ the type of the object. Must be one of the css.sdb.application.DatabaseObject
+ constants.
+ @return
+ the image to be used for the object type.
+ */
+ Image getDefaultImage(
+ sal_Int32 _nDatabaseObjectType
+ );
+
+ /** returns the resource ID for the default image to be used for a database object
+
+ In opposite to getImages, this method does not check the concrete object
+ for its image, but returns a default image to be used for all objects of the given
+ type.
+
+ @param _nDatabaseObjectType
+ the type of the object. Must be one of the css.sdb.application.DatabaseObject
+ constants.
+ @return
+ the resource ID image to be used for the object type. Must be fed into a
+ ModuleRes instance to actually load the image.
+ */
+ sal_uInt16 getDefaultImageResourceID(
+ sal_Int32 _nDatabaseObjectType
+ );
+
+ /** retrieves the image to be used for folders of database objects
+ @param _nDatabaseObjectType
+ the type of the object. Must be one of the css.sdb.application.DatabaseObject
+ constants.
+ @param _rName
+ the name of the object
+ @return
+ the image to be used for folders of the given type
+ */
+ Image getFolderImage(
+ sal_Int32 _nDatabaseObjectType
+ );
+
+ /** retrieves the image to be used for a database as a whole.
+ @return
+ the image to be used for folders of this type
+ */
+ Image getDatabaseImage();
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_IMAGEPROVIDER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/indexcollection.hxx b/dbaccess/source/ui/inc/indexcollection.hxx
new file mode 100644
index 000000000000..7e01de118b72
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexcollection.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INDEXCOLLECTION_HXX_
+#define _DBAUI_INDEXCOLLECTION_HXX_
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "indexes.hxx"
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ //==================================================================
+ //= OIndexCollection
+ //==================================================================
+ class OIndexCollection
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xIndexes;
+
+ // cached information
+ Indexes m_aIndexes;
+
+ public:
+ // construction
+ OIndexCollection();
+ OIndexCollection(const OIndexCollection& _rSource);
+ // OIndexCollection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
+
+ const OIndexCollection& operator=(const OIndexCollection& _rSource);
+
+ // iterating through the collection
+ typedef OIndex* iterator;
+ typedef OIndex const* const_iterator;
+
+ /// get access to the first element of the index collection
+ Indexes::const_iterator begin() const { return m_aIndexes.begin(); }
+ /// get access to the first element of the index collection
+ Indexes::iterator begin() { return m_aIndexes.begin(); }
+ /// get access to the (last + 1st) element of the index collection
+ Indexes::const_iterator end() const { return m_aIndexes.end(); }
+ /// get access to the (last + 1st) element of the index collection
+ Indexes::iterator end() { return m_aIndexes.end(); }
+
+ // searching
+ Indexes::const_iterator find(const String& _rName) const;
+ Indexes::iterator find(const String& _rName);
+ Indexes::const_iterator findOriginal(const String& _rName) const;
+ Indexes::iterator findOriginal(const String& _rName);
+
+ // inserting without committing
+ // the OriginalName of the newly inserted index will be empty, thus indicating that it's new
+ Indexes::iterator insert(const String& _rName);
+ // commit a new index, which is already part if the collection, but does not have an equivalent in the
+ // data source, yet
+ void commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
+
+ // reset the data for the given index
+ void resetIndex(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
+
+ // attach to a new key container
+ void attach(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
+ // detach from the container
+ void detach();
+
+ // is the object valid?
+ sal_Bool isValid() const { return m_xIndexes.is(); }
+ // number of contained indexes
+ sal_Int32 size() const { return m_aIndexes.size(); }
+
+ /// drop an index, and remove it from the collection
+ sal_Bool drop(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
+ /// simply drop the index described by the name, but don't remove the descriptor from the collection
+ sal_Bool dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((::com::sun::star::sdbc::SQLException));
+
+ protected:
+ void implConstructFrom(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes);
+ void implFillIndexInfo(OIndex& _rIndex, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxDescriptor) SAL_THROW((::com::sun::star::uno::Exception));
+ void implFillIndexInfo(OIndex& _rIndex) SAL_THROW((::com::sun::star::uno::Exception));
+ };
+
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+#endif // _DBAUI_INDEXCOLLECTION_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/indexdialog.hxx b/dbaccess/source/ui/inc/indexdialog.hxx
new file mode 100644
index 000000000000..10839459626b
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexdialog.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INDEXDIALOG_HXX_
+#define _DBAUI_INDEXDIALOG_HXX_
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vcl/toolbox.hxx>
+#include <svtools/svtreebx.hxx>
+#include <unotools/viewoptions.hxx>
+#include "indexes.hxx"
+#include "ToolBoxHelper.hxx"
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ //==================================================================
+ //= DbaIndexList
+ //==================================================================
+ class DbaIndexList : public SvTreeListBox
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ Link m_aSelectHdl;
+ Link m_aEndEditHdl;
+ sal_Bool m_bSuspendSelectHdl;
+
+ public:
+ DbaIndexList(Window* _pParent, const ResId& _rId);
+
+ void SetSelectHdl(const Link& _rHdl) { m_aSelectHdl = _rHdl; }
+ Link GetSelectHdl() const { return m_aSelectHdl; }
+
+ void SetEndEditHdl(const Link& _rHdl) { m_aEndEditHdl = _rHdl; }
+ Link GetEndEditHdl() const { return m_aEndEditHdl; }
+
+ virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect );
+
+ void enableSelectHandler();
+ void disableSelectHandler();
+
+ void SelectNoHandlerCall( SvLBoxEntry* pEntry );
+
+ inline void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection)
+ {
+ m_xConnection = _rxConnection;
+ }
+
+ protected:
+ virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
+
+ private:
+ using SvTreeListBox::Select;
+ };
+
+ //==================================================================
+ //= DbaIndexDialog
+ //==================================================================
+ class IndexFieldsControl;
+ class OIndexCollection;
+ class DbaIndexDialog : public ModalDialog,
+ public OToolBoxHelper
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+ SvtViewOptions m_aGeometrySettings;
+
+ ToolBox m_aActions;
+ DbaIndexList m_aIndexes;
+ FixedLine m_aIndexDetails;
+ FixedText m_aDescriptionLabel;
+ FixedText m_aDescription;
+ CheckBox m_aUnique;
+ FixedText m_aFieldsLabel;
+ IndexFieldsControl* m_pFields;
+ PushButton m_aClose;
+ HelpButton m_aHelp;
+
+ OIndexCollection* m_pIndexes;
+ SvLBoxEntry* m_pPreviousSelection;
+ sal_Bool m_bEditAgain;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ public:
+ DbaIndexDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rFieldNames,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxIndexes,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ sal_Int32 _nMaxColumnsInIndex
+ );
+ virtual ~DbaIndexDialog();
+
+ virtual void StateChanged( StateChangedType nStateChange );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ /** will be called whenthe id of the image list is needed.
+ @param _eBitmapSet
+ <svtools/imgdef.hxx>
+ @param _bHiContast
+ <TRUE/> when in high contrast mode.
+ */
+ virtual ImageList getImageList(sal_Int16 _eBitmapSet) const;
+
+ /** will be called when the controls need to be resized.
+ */
+ virtual void resizeControls(const Size& _rDiff);
+
+ protected:
+ void fillIndexList();
+ void updateToolbox();
+ void updateControls(const SvLBoxEntry* _pEntry);
+
+ protected:
+ DECL_LINK( OnIndexSelected, DbaIndexList* );
+ DECL_LINK( OnIndexAction, ToolBox* );
+ DECL_LINK( OnEntryEdited, SvLBoxEntry* );
+ DECL_LINK( OnModified, void* );
+ DECL_LINK( OnCloseDialog, void* );
+
+ DECL_LINK( OnEditIndexAgain, SvLBoxEntry* );
+
+ private:
+ void OnNewIndex();
+ void OnDropIndex(sal_Bool _bConfirm = sal_True);
+ void OnRenameIndex();
+ void OnSaveIndex();
+ void OnResetIndex();
+
+ sal_Bool implCommit(SvLBoxEntry* _pEntry);
+ sal_Bool implSaveModified(sal_Bool _bPlausibility = sal_True);
+ sal_Bool implCommitPreviouslySelected();
+
+ sal_Bool implDropIndex(SvLBoxEntry* _pEntry, sal_Bool _bRemoveFromCollection);
+
+ sal_Bool implCheckPlausibility(const ConstIndexesIterator& _rPos);
+
+ /** checks if the controls have to be replaced and moved.
+ */
+ void checkControls();
+ };
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+#endif // _DBAUI_INDEXDIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/indexes.hxx b/dbaccess/source/ui/inc/indexes.hxx
new file mode 100644
index 000000000000..18e8f4ff0b5c
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexes.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INDEXES_HXX_
+#define _DBAUI_INDEXES_HXX_
+
+#include <tools/string.hxx>
+#include <comphelper/stl_types.hxx>
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+ //==================================================================
+ //= OIndexField
+ //==================================================================
+ struct OIndexField
+ {
+ String sFieldName;
+ sal_Bool bSortAscending;
+
+ OIndexField() : bSortAscending(sal_True) { }
+ };
+
+ DECLARE_STL_VECTOR( OIndexField, IndexFields );
+
+ //==================================================================
+ //= OIndex
+ //==================================================================
+ struct GrantIndexAccess
+ {
+ friend class OIndexCollection;
+ private:
+ GrantIndexAccess() { }
+ };
+
+ //..................................................................
+ struct OIndex
+ {
+ protected:
+ ::rtl::OUString sOriginalName;
+ sal_Bool bModified;
+
+ public:
+ ::rtl::OUString sName;
+ ::rtl::OUString sDescription;
+ sal_Bool bPrimaryKey;
+ sal_Bool bUnique;
+ IndexFields aFields;
+
+ public:
+ OIndex(const ::rtl::OUString& _rOriginalName)
+ : sOriginalName(_rOriginalName), bModified(sal_False), sName(_rOriginalName), bPrimaryKey(sal_False), bUnique(sal_False)
+ {
+ }
+
+ const ::rtl::OUString& getOriginalName() const { return sOriginalName; }
+
+ sal_Bool isModified() const { return bModified; }
+ void setModified(sal_Bool _bModified) { bModified = _bModified; }
+ void clearModified() { setModified(sal_False); }
+
+ sal_Bool isNew() const { return 0 == getOriginalName().getLength(); }
+ void flagAsNew(const GrantIndexAccess&) { sOriginalName = ::rtl::OUString(); }
+ void flagAsCommitted(const GrantIndexAccess&) { sOriginalName = sName; }
+
+
+ private:
+ OIndex(); // not implemented
+ };
+
+ DECLARE_STL_VECTOR( OIndex, Indexes );
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+#endif // _DBAUI_INDEXES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/indexfieldscontrol.hxx b/dbaccess/source/ui/inc/indexfieldscontrol.hxx
new file mode 100644
index 000000000000..d3802b03746d
--- /dev/null
+++ b/dbaccess/source/ui/inc/indexfieldscontrol.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INDEXFIELDSCONTROL_HXX_
+#define _DBAUI_INDEXFIELDSCONTROL_HXX_
+
+#include "moduledbu.hxx"
+#include <svtools/editbrowsebox.hxx>
+#include "indexcollection.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ //==================================================================
+ // IndexFieldsControl
+ //==================================================================
+ class IndexFieldsControl : public ::svt::EditBrowseBox
+ {
+ OModuleClient m_aModuleClient;
+ protected:
+ IndexFields m_aSavedValue;
+
+ IndexFields m_aFields; // !! order matters !!
+ ConstIndexFieldsIterator m_aSeekRow; // !!
+
+ Link m_aModifyHdl;
+
+ ::svt::ListBoxControl* m_pSortingCell;
+ ::svt::ListBoxControl* m_pFieldNameCell;
+
+ String m_sAscendingText;
+ String m_sDescendingText;
+
+ sal_Int32 m_nMaxColumnsInIndex;
+ sal_Bool m_bAddIndexAppendix;
+
+ public:
+ IndexFieldsControl( Window* _pParent, const ResId& _rId ,sal_Int32 _nMaxColumnsInIndex,sal_Bool _bAddIndexAppendix);
+ ~IndexFieldsControl();
+
+ void Init(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rAvailableFields);
+
+ void initializeFrom(const IndexFields& _rFields);
+ void commitTo(IndexFields& _rFields);
+
+ sal_Bool SaveModified();
+ sal_Bool IsModified() const;
+
+ const IndexFields& GetSavedValue() const { return m_aSavedValue; }
+ void SaveValue() { m_aSavedValue = m_aFields; }
+
+ void SetModifyHdl(const Link& _rHdl) { m_aModifyHdl = _rHdl; }
+ Link GetModifyHdl() const { return m_aModifyHdl; }
+ virtual String GetCellText(long _nRow,sal_uInt16 nColId) const;
+
+ protected:
+ // EditBrowseBox overridables
+ virtual void PaintCell( OutputDevice& _rDev, const Rectangle& _rRect, sal_uInt16 _nColumnId ) const;
+ virtual sal_Bool SeekRow(long nRow);
+ virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
+ virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
+
+ ::svt::CellController* GetController(long _nRow, sal_uInt16 _nColumnId);
+ void InitController(::svt::CellControllerRef&, long _nRow, sal_uInt16 _nColumnId);
+
+ protected:
+ String GetRowCellText(const ConstIndexFieldsIterator& _rRow,sal_uInt16 nColId) const;
+ sal_Bool implGetFieldDesc(long _nRow, ConstIndexFieldsIterator& _rPos);
+
+ sal_Bool isNewField() const { return GetCurRow() >= (sal_Int32)m_aFields.size(); }
+
+ DECL_LINK( OnListEntrySelected, ListBox* );
+
+ private:
+ using ::svt::EditBrowseBox::Init;
+ };
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+#endif // _DBAUI_INDEXFIELDSCONTROL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/linkeddocuments.hxx b/dbaccess/source/ui/inc/linkeddocuments.hxx
new file mode 100644
index 000000000000..84609bb1e5d2
--- /dev/null
+++ b/dbaccess/source/ui/inc/linkeddocuments.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
+#define _DBAUI_LINKEDDOCUMENTS_HXX_
+
+#include "AppElementType.hxx"
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
+#include <tools/link.hxx>
+#include <tools/string.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+
+class Window;
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ //==================================================================
+ //= OLinkedDocumentsAccess
+ //==================================================================
+ class OLinkedDocumentsAccess
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xDocumentContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>
+ m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
+ m_xDocumentUI;
+ Window* m_pDialogParent;
+ String m_sCurrentlyEditing;
+ ::rtl::OUString
+ m_sDataSourceName;
+
+ public:
+ OLinkedDocumentsAccess(
+ Window* _pDialogParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rDocumentUI,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
+ const ::rtl::OUString& _sDataSourceName
+ );
+ ~OLinkedDocumentsAccess();
+
+ inline sal_Bool isConnected() const { return m_xConnection.is(); }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
+ open(
+ const ::rtl::OUString& _rLinkName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _xDefinition,
+ ElementOpenMode _eOpenMode,
+ const ::comphelper::NamedValueCollection& _rAdditionalArgs
+ );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ newDocument(
+ sal_Int32 i_nActionID,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_rDefinition
+ );
+
+ void newFormWithPilot(
+ const sal_Int32 _nCommandType = -1,
+ const ::rtl::OUString& _rObjectName = ::rtl::OUString()
+ );
+ void newReportWithPilot(
+ const sal_Int32 _nCommandType = -1,
+ const ::rtl::OUString& _rObjectName = ::rtl::OUString()
+ );
+ void newQueryWithPilot();
+ void newTableWithPilot();
+
+ enum RESULT
+ {
+ ERROR,
+ SUCCESS,
+ CANCEL
+ };
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ impl_open(
+ const ::rtl::OUString& _rLinkName,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition,
+ ElementOpenMode _eOpenMode,
+ const ::comphelper::NamedValueCollection& _rAdditionalArgs
+ );
+
+ void
+ impl_newWithPilot(
+ const char* _pWizardService,
+ const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rObjectName
+ );
+
+ };
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+#endif // _DBAUI_LINKEDDOCUMENTS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/listviewitems.hxx b/dbaccess/source/ui/inc/listviewitems.hxx
new file mode 100644
index 000000000000..3cf5ba748681
--- /dev/null
+++ b/dbaccess/source/ui/inc/listviewitems.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#define _DBAUI_LISTVIEWITEMS_HXX_
+
+#include <svtools/svlbitm.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ #define SV_ITEM_ID_BOLDLBSTRING SV_ITEM_ID_LBOXSTRING
+
+ //====================================================================
+ //= OBoldListboxString
+ //====================================================================
+ class OBoldListboxString : public SvLBoxString
+ {
+ sal_Bool m_bEmphasized;
+
+ public:
+ OBoldListboxString(SvLBoxEntry* _pEntry, sal_uInt16 _nFlags, const XubString& _rStr)
+ :SvLBoxString(_pEntry, _nFlags, _rStr)
+ ,m_bEmphasized(sal_False)
+ {
+ }
+
+ virtual sal_uInt16 IsA();
+
+ virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
+ virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* _pViewData);
+
+ sal_Bool isEmphasized() const { return m_bEmphasized; }
+ void emphasize(sal_Bool _bEmphasize) { m_bEmphasized = _bEmphasize; }
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // _DBAUI_LISTVIEWITEMS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/localresaccess.hxx b/dbaccess/source/ui/inc/localresaccess.hxx
new file mode 100644
index 000000000000..9760ac354aac
--- /dev/null
+++ b/dbaccess/source/ui/inc/localresaccess.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_LOCALRESACCESS_HXX_
+#define _DBAUI_LOCALRESACCESS_HXX_
+
+#include <svtools/localresaccess.hxx>
+#include "moduledbu.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= LocalResourceAccess
+//=========================================================================
+/** helper class for acessing local resources
+*/
+typedef ::svt::OLocalResourceAccess LRA_Base;
+class LocalResourceAccess : protected LRA_Base
+{
+ OModuleClient m_aModuleClient;
+public:
+ inline LocalResourceAccess( sal_uInt16 _nId, RESOURCE_TYPE _rType )
+ :LRA_Base( ModuleRes( _nId ), _rType )
+ {
+ }
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_LOCALRESACCESS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/makefile.mk b/dbaccess/source/ui/inc/makefile.mk
new file mode 100644
index 000000000000..5e1454d57f61
--- /dev/null
+++ b/dbaccess/source/ui/inc/makefile.mk
@@ -0,0 +1,43 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=dbaccess
+TARGET=dba_uiinc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LOCALIZE_ME=toolbox_tmpl.hrc
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ui/inc/marktree.hxx b/dbaccess/source/ui/inc/marktree.hxx
new file mode 100644
index 000000000000..cc5f10791b2f
--- /dev/null
+++ b/dbaccess/source/ui/inc/marktree.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_MARKTREE_HXX_
+#define _DBAUI_MARKTREE_HXX_
+
+#include "dbtreelistbox.hxx"
+
+
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//========================================================================
+//= OMarkableTreeListBox
+//========================================================================
+/** a tree list box where all entries can be marked (with a checkbox) and
+ unmarked. In addition, inner nodes know a third state which applies
+ if some, but not all of their descendants are marked.
+*/
+class OMarkableTreeListBox : public DBTreeListBox
+{
+ SvLBoxButtonData* m_pCheckButton;
+ Link m_aCheckButtonHandler;
+
+public:
+ OMarkableTreeListBox( Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ , WinBits nWinStyle=0 );
+ OMarkableTreeListBox( Window* pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ , const ResId& rResId );
+ ~OMarkableTreeListBox();
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void CheckButtonHdl();
+ void CheckButtons(); // make the button states consistent (bottom-up)
+
+ /// the handler given is called whenever the check state of one or more items changed
+ void SetCheckHandler(const Link& _rHdl) { m_aCheckButtonHandler = _rHdl; }
+
+protected:
+ virtual void Paint(const Rectangle& _rRect);
+ virtual void checkedButton_noBroadcast(SvLBoxEntry* _pEntry);
+
+ SvButtonState implDetermineState(SvLBoxEntry* _pEntry);
+ // determines the check state of the given entry, by analyzing the states of all descendants
+
+private:
+ void InitButtonData();
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_MARKTREE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/moduledbu.hxx b/dbaccess/source/ui/inc/moduledbu.hxx
new file mode 100644
index 000000000000..4297cdef693a
--- /dev/null
+++ b/dbaccess/source/ui/inc/moduledbu.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#define _DBAUI_MODULE_DBU_HXX_
+
+#include <osl/mutex.hxx>
+#include <tools/resid.hxx>
+#include <sal/macros.h>
+
+class ResMgr;
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OModule
+//=========================================================================
+class OModuleImpl;
+class OModule
+{
+ friend class OModuleClient;
+
+private:
+ OModule();
+ // not implemented. OModule is a static class
+
+protected:
+ static ::osl::Mutex s_aMutex; /// access safety
+ static sal_Int32 s_nClients; /// number of registered clients
+ static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered
+
+public:
+ /// get the vcl res manager of the module
+ static ResMgr* getResManager();
+
+protected:
+ /// register a client for the module
+ static void registerClient();
+ /// revoke a client for the module
+ static void revokeClient();
+
+private:
+ /** ensure that the impl class exists
+ @precond m_aMutex is guarded when this method gets called
+ */
+ static void ensureImpl();
+};
+
+//=========================================================================
+//= OModuleClient
+//=========================================================================
+/** base class for objects which uses any global module-specific ressources
+*/
+class OModuleClient
+{
+public:
+ OModuleClient() { OModule::registerClient(); }
+ ~OModuleClient() { OModule::revokeClient(); }
+};
+
+//=========================================================================
+//= ModuleRes
+//=========================================================================
+/** specialized ResId, using the ressource manager provided by the global module
+*/
+class ModuleRes : public ::ResId
+{
+public:
+ ModuleRes(sal_uInt16 _nId) : ResId(_nId, *OModule::getResManager()) { }
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_MODULE_DBU_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/objectnamecheck.hxx b/dbaccess/source/ui/inc/objectnamecheck.hxx
new file mode 100644
index 000000000000..144877d56d62
--- /dev/null
+++ b/dbaccess/source/ui/inc/objectnamecheck.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
+#define DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+namespace rtl { class OUString; }
+namespace dbtools { class SQLExceptionInfo; }
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= IObjectNameCheck
+ //====================================================================
+ /** interface encapsulating the check for the validity of an object name
+ */
+ class IObjectNameCheck
+ {
+ public:
+ /** determines whether a given object name is valid
+
+ @param _rObjectName
+ the name to check
+ @param _out_rErrorToDisplay
+ output parameter taking an error message describing why the name is not
+ valid, if applicable.
+
+ @return
+ <TRUE/> if and only if the given name is valid.
+ */
+ virtual bool isNameValid(
+ const ::rtl::OUString& _rObjectName,
+ ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay
+ ) const = 0;
+
+ public:
+ virtual ~IObjectNameCheck() { }
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/opendoccontrols.hxx b/dbaccess/source/ui/inc/opendoccontrols.hxx
new file mode 100644
index 000000000000..b4c73bfb9521
--- /dev/null
+++ b/dbaccess/source/ui/inc/opendoccontrols.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+#define DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <rtl/ustring.hxx>
+#include <map>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= OpenDocumentButton
+ //====================================================================
+ /** a button which can be used to open a document
+
+ The text of the button is the same as for the "Open" command in the application
+ UI. Additionally, the icon for this command is also displayed on the button.
+ */
+ class OpenDocumentButton : public PushButton
+ {
+ private:
+ ::rtl::OUString m_sModule;
+
+ public:
+ OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId );
+
+ protected:
+ void impl_init( const sal_Char* _pAsciiModuleName );
+ };
+
+ //====================================================================
+ //= OpenDocumentListBox
+ //====================================================================
+ class OpenDocumentListBox : public ListBox
+ {
+ private:
+ typedef ::std::pair< String, String > StringPair;
+ typedef ::std::map< sal_uInt16, StringPair > MapIndexToStringPair;
+
+ ::rtl::OUString m_sModule;
+ MapIndexToStringPair m_aURLs;
+
+ public:
+ OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId );
+
+ String GetSelectedDocumentURL() const;
+ String GetSelectedDocumentFilter() const;
+
+ protected:
+ virtual void RequestHelp( const HelpEvent& _rHEvt );
+
+ StringPair impl_getDocumentAtIndex( sal_uInt16 _nListIndex, bool _bSystemNotation = false ) const;
+
+ private:
+ void impl_init( const sal_Char* _pAsciiModuleName );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/paramdialog.hxx b/dbaccess/source/ui/inc/paramdialog.hxx
new file mode 100644
index 000000000000..73d9107b6176
--- /dev/null
+++ b/dbaccess/source/ui/inc/paramdialog.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_PARAMDIALOG_HXX_
+#define _DBAUI_PARAMDIALOG_HXX_
+
+#include "commontypes.hxx"
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <connectivity/predicateinput.hxx>
+#include "svx/ParseContext.hxx"
+
+namespace connectivity
+{
+ class OSQLParseNode;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //==================================================================
+ //= OParameterDialog
+ //==================================================================
+ class OParameterDialog
+ :public ModalDialog
+ ,public ::svxform::OParseContextClient
+ {
+ protected:
+ // the controls
+ FixedLine m_aNamesFrame;
+ ListBox m_aAllParams;
+ FixedText m_aValueFrame;
+ Edit m_aParam;
+ PushButton m_aTravelNext;
+ OKButton m_aOKBtn;
+ CancelButton m_aCancelBtn;
+
+ sal_uInt16 m_nCurrentlySelected;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >
+ m_xParams;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
+ m_xFormatter;
+ ::dbtools::OPredicateInputController
+ m_aPredicateInput;
+
+ ByteVector m_aVisitedParams;
+ Timer m_aResetVisitFlag;
+ // we reset the "visited flag" 1 second after and entry has been selected
+
+ sal_Bool m_bNeedErrorOnCurrent;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ m_aFinalValues; /// the final values as entered by the user
+
+ public:
+ OParameterDialog(Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & _rParamContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > & _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ ~OParameterDialog();
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ getValues() const { return m_aFinalValues; }
+
+
+ protected:
+ void Construct();
+
+ ::connectivity::OSQLParseNode* implPredicateTree(::rtl::OUString& _rErrorMessage, const UniString& _rStatement, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxField);
+
+ private:
+ DECL_LINK(OnVisitedTimeout, Timer*);
+ DECL_LINK(OnValueModified, Control*);
+ DECL_LINK(OnEntrySelected, ListBox*);
+ DECL_LINK(OnButtonClicked, PushButton*);
+ DECL_LINK(OnValueLoseFocus, Control*);
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_PARAMDIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/propertysetitem.hxx b/dbaccess/source/ui/inc/propertysetitem.hxx
new file mode 100644
index 000000000000..fa678989c06f
--- /dev/null
+++ b/dbaccess/source/ui/inc/propertysetitem.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_PROPERTYSETITEM_HXX_
+#define _DBAUI_PROPERTYSETITEM_HXX_
+
+#include <svl/poolitem.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=========================================================================
+ //= OPropertySetItem
+ //=========================================================================
+ /** <type>SfxPoolItem</type> which transports a XPropertySet
+ */
+ class OPropertySetItem : public SfxPoolItem
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSet;
+
+ public:
+ TYPEINFO();
+ OPropertySetItem(sal_Int16 nWhich);
+ OPropertySetItem(sal_Int16 nWhich,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxSet);
+ OPropertySetItem(const OPropertySetItem& _rSource);
+
+ virtual int operator==(const SfxPoolItem& _rItem) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* _pPool = NULL) const;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getPropertySet() const { return m_xSet; }
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_PROPERTYSETITEM_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/propertystorage.hxx b/dbaccess/source/ui/inc/propertystorage.hxx
new file mode 100644
index 000000000000..689e7998f6cf
--- /dev/null
+++ b/dbaccess/source/ui/inc/propertystorage.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef PROPERTYSTORAGE_HXX
+#define PROPERTYSTORAGE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Any.hxx>
+/** === end UNO includes === **/
+
+#include <tools/solar.h>
+
+#include <boost/shared_ptr.hpp>
+#include <map>
+
+class SfxItemSet;
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyStorage
+ //====================================================================
+ class SAL_NO_VTABLE PropertyStorage
+ {
+ public:
+ virtual void getPropertyValue( ::com::sun::star::uno::Any& _out_rValue ) const = 0;
+ virtual void setPropertyValue( const ::com::sun::star::uno::Any& _rValue ) = 0;
+
+ virtual ~PropertyStorage();
+ };
+
+ typedef ::boost::shared_ptr< PropertyStorage > PPropertyStorage;
+ typedef ::std::map< sal_Int32, PPropertyStorage > PropertyValues;
+
+ //====================================================================
+ //= SetItemPropertyStorage
+ //====================================================================
+ typedef sal_uInt16 ItemId;
+
+ /** a PropertyStorage implementation which stores the value in an item set
+ */
+ class SetItemPropertyStorage : public PropertyStorage
+ {
+ public:
+ SetItemPropertyStorage( SfxItemSet& _rItemSet, const ItemId _nItemID )
+ :m_rItemSet( _rItemSet )
+ ,m_nItemID( _nItemID )
+ {
+ }
+
+ virtual ~SetItemPropertyStorage()
+ {
+ }
+
+ virtual void getPropertyValue( ::com::sun::star::uno::Any& _out_rValue ) const;
+ virtual void setPropertyValue( const ::com::sun::star::uno::Any& _rValue );
+
+ private:
+ SfxItemSet& m_rItemSet;
+ const ItemId m_nItemID;
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // PROPERTYSTORAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/querycontainerwindow.hxx b/dbaccess/source/ui/inc/querycontainerwindow.hxx
new file mode 100644
index 000000000000..7146b8306cfb
--- /dev/null
+++ b/dbaccess/source/ui/inc/querycontainerwindow.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYCONTAINERWINDOW_HXX
+#define DBAUI_QUERYCONTAINERWINDOW_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/split.hxx>
+#include "dataview.hxx"
+#include <com/sun/star/frame/XFrame.hpp>
+#include "QueryViewSwitch.hxx"
+#include <vcl/dockwin.hxx>
+
+class FixedLine;
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OBeamer
+ //=====================================================================
+ // tempoaray class until the beamer is implemented
+ class OBeamer : public DockingWindow
+ {
+ public:
+ OBeamer(Window* _pParent) : DockingWindow(_pParent,0){}
+ };
+
+ //=====================================================================
+ //= OQueryContainerWindow
+ //=====================================================================
+ class OQueryContainerWindow : public ODataView
+ {
+ OQueryViewSwitch* m_pViewSwitch;
+ OBeamer* m_pBeamer;
+ Splitter* m_pSplitter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xBeamer;
+
+ DECL_LINK( SplitHdl, void* );
+ public:
+ OQueryContainerWindow(Window* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ ~OQueryContainerWindow();
+
+ virtual void Construct();
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ // show the beamer
+ void showPreview(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame);
+ // called when the beamer has been disposed
+ void disposingPreview();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ getPreviewFrame() const { return m_xBeamer; }
+
+ OQueryDesignView* getDesignView() { return m_pViewSwitch->getDesignView(); }
+
+ sal_Bool isCutAllowed() { return m_pViewSwitch->isCutAllowed(); }
+ sal_Bool isPasteAllowed() { return m_pViewSwitch->isPasteAllowed(); }
+ sal_Bool isCopyAllowed() { return m_pViewSwitch->isCopyAllowed(); }
+ void copy() { m_pViewSwitch->copy(); }
+ void cut() { m_pViewSwitch->cut(); }
+ void paste() { m_pViewSwitch->paste(); }
+
+ void clear() { m_pViewSwitch->clear(); }
+ sal_Bool isSlotEnabled( sal_Int32 _nSlotId ) { return m_pViewSwitch->isSlotEnabled( _nSlotId ); }
+ void setSlotEnabled( sal_Int32 _nSlotId, sal_Bool _bEnable ) { m_pViewSwitch->setSlotEnabled( _nSlotId, _bEnable ); }
+ void setNoneVisbleRow(sal_Int32 _nRows) { m_pViewSwitch->setNoneVisbleRow( _nRows); }
+
+ void setReadOnly( sal_Bool _bReadOnly ) { m_pViewSwitch->setReadOnly( _bReadOnly ); }
+
+ sal_Bool checkStatement() { return m_pViewSwitch->checkStatement( ); }
+ ::rtl::OUString getStatement() { return m_pViewSwitch->getStatement( ); }
+ void setStatement( const ::rtl::OUString& _rsStatement ) { m_pViewSwitch->setStatement( _rsStatement ); }
+
+ void initialize() { m_pViewSwitch->initialize(); }
+ void SaveUIConfig() { m_pViewSwitch->SaveUIConfig(); }
+ bool reset( ::dbtools::SQLExceptionInfo* _pErrorInfo ) { return m_pViewSwitch->reset( _pErrorInfo ); }
+
+ bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void forceInitialView();
+
+ virtual void GetFocus();
+
+ protected:
+ // re-arrange the controls belonging to the document itself
+ virtual void resizeAll( const Rectangle& _rPlayground );
+
+ // arrange dericed classes controls in the rectangle given
+ virtual void resizeDocumentView(Rectangle& _rPlayground);
+ };
+ // end of temp classes
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_QUERYCONTAINERWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx
new file mode 100644
index 000000000000..363c5517050e
--- /dev/null
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -0,0 +1,261 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYCONTROLLER_HXX
+#define DBAUI_QUERYCONTROLLER_HXX
+
+#include "JoinController.hxx"
+#include "JoinTableView.hxx"
+#include "querycontainerwindow.hxx"
+#include "queryview.hxx"
+#include "svx/ParseContext.hxx"
+#include "TableFieldDescription.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XAlterView.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/sqliterator.hxx>
+#include <connectivity/sqlnode.hxx>
+#include <connectivity/sqlparse.hxx>
+#include <svl/undo.hxx>
+
+namespace comphelper
+{
+ class NamedValueCollection;
+}
+
+class VCLXWindow;
+namespace dbaui
+{
+ class OQueryView;
+ class OQueryContainerWindow;
+ class OTableConnectionData;
+ class OTableWindowData;
+ class OAddTableDlg;
+ class OTableFieldDesc;
+ class OQueryTableWindow;
+
+ class OQueryController;
+ typedef ::comphelper::OPropertyContainer OQueryController_PBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OQueryController > OQueryController_PABase;
+ class OQueryController :public OJoinController
+ ,public OQueryController_PBase
+ ,public OQueryController_PABase
+ {
+ OTableFields m_vTableFieldDesc;
+ OTableFields m_vUnUsedFieldsDesc; // contains fields which aren't visible and don't have any criteria
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aFieldInformation;
+
+ ::svxform::OSystemParseContext* m_pParseContext;
+ ::connectivity::OSQLParser m_aSqlParser;
+ ::connectivity::OSQLParseTreeIterator* m_pSqlIterator;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLQueryComposer > m_xComposer;
+ /// if we're editing an existing view, this is non-NULL
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XAlterView > m_xAlterView;
+
+ ::rtl::OUString m_sStatement; // contains the current sql statement
+ ::rtl::OUString m_sUpdateCatalogName; // catalog for update data
+ ::rtl::OUString m_sUpdateSchemaName; // schema for update data
+ ::rtl::OUString m_sUpdateTableName; // table for update data
+ mutable ::rtl::OUString
+ m_sName; // name of the query
+
+ sal_Int32 m_nVisibleRows; // which rows the selection browse should show
+ sal_Int32 m_nSplitPos; // the position of the splitter
+ sal_Int32 m_nCommandType; // the type of the object we're designing
+ sal_Bool m_bGraphicalDesign; // are we in the graphical design mode (sal_True) or in the text design (sal_False)?
+ sal_Bool m_bDistinct; // true when you want "select distinct" otherwise false
+ sal_Bool m_bViewAlias; // show the alias row in the design view
+ sal_Bool m_bViewTable; // show the table row in the design view
+ sal_Bool m_bViewFunction; // show the function row in the design view
+ sal_Bool m_bEscapeProcessing;// is true when we shouldn't parse the statement
+
+
+ /** returns the container of queries, views, or command definitions, depending on what object type
+ we design currently.
+
+ Not allowed to be called if we design an independent SQL command.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getObjectContainer() const;
+
+ inline bool editingView() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::TABLE; }
+ inline bool editingQuery() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::QUERY; }
+ inline bool editingCommand() const { return m_nCommandType == ::com::sun::star::sdb::CommandType::COMMAND; }
+
+ sal_Bool askForNewName( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xElements,
+ sal_Bool _bSaveAs);
+ // creates the querycomposer
+ void setQueryComposer();
+ void deleteIterator();
+ void executeQuery();
+ bool doSaveAsDoc(sal_Bool _bSaveAs);
+
+ void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
+ void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
+ ::rtl::OUString translateStatement( bool _bFireStatementChange = true );
+
+ ::rtl::OUString getDefaultName() const;
+
+ protected:
+ // all the features which should be handled by this class
+ virtual void describeSupportedFeatures();
+ // state of a feature. 'feature' may be the handle of a ::com::sun::star::util::URL somebody requested a dispatch interface for OR a toolbar slot.
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ // execute a feature
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ virtual void reconnect( sal_Bool _bUI );
+ virtual ::rtl::OUString getPrivateTitle( ) const;
+
+ OQueryContainerWindow* getContainer() const { return static_cast< OQueryContainerWindow* >( getView() ); }
+
+ public:
+ OQueryController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+
+ virtual ~OQueryController();
+ OTableFields& getTableFieldDesc() { return m_vTableFieldDesc; }
+ OTableFields& getUnUsedFields() { return m_vUnUsedFieldsDesc; }
+
+ void clearFields();
+
+ virtual void impl_onModifyChanged();
+
+ // should the statement be parsed by our own sql parser
+ sal_Bool isEsacpeProcessing() const { return m_bEscapeProcessing; }
+ sal_Bool isGraphicalDesign() const { return m_bGraphicalDesign; }
+ sal_Bool isDistinct() const { return m_bDistinct; }
+
+ ::rtl::OUString getStatement() const { return m_sStatement; }
+ sal_Int32 getSplitPos() const { return m_nSplitPos;}
+ sal_Int32 getVisibleRows() const { return m_nVisibleRows; }
+
+ void setDistinct(sal_Bool _bDistinct) { m_bDistinct = _bDistinct;}
+ void setSplitPos(sal_Int32 _nSplitPos) { m_nSplitPos = _nSplitPos;}
+ void setVisibleRows(sal_Int32 _nVisibleRows) { m_nVisibleRows = _nVisibleRows;}
+
+ sal_Int32 getColWidth(sal_uInt16 _nColPos) const;
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
+ getFieldInformation() const { return m_aFieldInformation; }
+
+ ::connectivity::OSQLParser& getParser() { return m_aSqlParser; }
+ ::connectivity::OSQLParseTreeIterator& getParseIterator() { return *m_pSqlIterator; }
+
+ virtual sal_Bool Construct(Window* pParent);
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+ // XPropertySet
+ virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XController
+ virtual ::com::sun::star::uno::Any SAL_CALL getViewData(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL restoreViewData(const ::com::sun::star::uno::Any& Data) throw( ::com::sun::star::uno::RuntimeException );
+
+ private:
+ virtual void onLoadedMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager);
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any& rConvertedValue,
+ ::com::sun::star::uno::Any& rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ ) throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ ) throw (::com::sun::star::uno::Exception );
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ virtual OJoinDesignView* getJoinView();
+ // ask the user if the design should be saved when it is modified
+ virtual short saveModified();
+ virtual void reset();
+ virtual void impl_initialize();
+
+ void impl_reset( const bool i_bIgnoreQuerySettings = false );
+ /// tells the user that we needed to switch to SQL view automatically
+ void impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
+
+ /** switches to the graphical or SQL view mode, as determined by m_bGraphicalDesign
+ */
+ bool impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+
+ /// sets m_sStatement, and notifies our respective property change listeners
+ void setStatement_fireEvent( const ::rtl::OUString& _rNewStatement, bool _bFireStatementChange = true );
+ /// sets the m_bEscapeProcessing member, and notifies our respective property change listeners
+ void setEscapeProcessing_fireEvent( const sal_Bool _bEscapeProcessing );
+
+ // OJoinController overridables
+ virtual bool allowViews() const;
+ virtual bool allowQueries() const;
+
+ private:
+ DECL_LINK( OnExecuteAddTable, void* );
+
+ private:
+ using OQueryController_PBase::getFastPropertyValue;
+ };
+}
+#endif // DBAUI_QUERYCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx
new file mode 100644
index 000000000000..2e4dd3c9e662
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryfilter.hxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYFILTER_HXX
+#define DBAUI_QUERYFILTER_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+#include <connectivity/sqliterator.hxx>
+
+#include <connectivity/predicateinput.hxx>
+#include "svx/ParseContext.hxx"
+
+namespace rtl
+{
+ class OUString;
+}
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace sdb
+ {
+ class XSingleSelectQueryComposer;
+ }
+ namespace sdbc
+ {
+ class XConnection;
+ class XDatabaseMetaData;
+ }
+ namespace container
+ {
+ class XNameAccess;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ }
+ }
+ }
+}
+//==================================================================
+// DlgFilterCrit
+//==================================================================
+namespace dbaui
+{
+ class DlgFilterCrit :public ModalDialog
+ ,public ::svxform::OParseContextClient
+ {
+ private:
+ ListBox aLB_WHEREFIELD1;
+ ListBox aLB_WHERECOMP1;
+ Edit aET_WHEREVALUE1;
+ ListBox aLB_WHERECOND2;
+ ListBox aLB_WHEREFIELD2;
+ ListBox aLB_WHERECOMP2;
+ Edit aET_WHEREVALUE2;
+ ListBox aLB_WHERECOND3;
+ ListBox aLB_WHEREFIELD3;
+ ListBox aLB_WHERECOMP3;
+ Edit aET_WHEREVALUE3;
+ FixedText aFT_WHEREFIELD;
+ FixedText aFT_WHERECOMP;
+ FixedText aFT_WHEREVALUE;
+ FixedText aFT_WHEREOPER;
+ FixedLine aFL_FIELDS;
+ OKButton aBT_OK;
+ CancelButton aBT_CANCEL;
+ HelpButton aBT_HELP;
+ String aSTR_NOENTRY;
+ String aSTR_COMPARE_OPERATORS;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xQueryComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData;
+
+ ::dbtools::OPredicateInputController m_aPredicateInput;
+
+ void SelectField( ListBox& rBox, const String& rField );
+ DECL_LINK( ListSelectHdl, ListBox * );
+ DECL_LINK( ListSelectCompHdl, ListBox * );
+
+ void SetLine( sal_uInt16 nIdx,const ::com::sun::star::beans::PropertyValue& _rItem,sal_Bool _bOr );
+ void EnableLines();
+ sal_Int32 GetOSQLPredicateType( const String& _rSelectedPredicate ) const;
+ sal_uInt16 GetSelectionPos(sal_Int32 eType,const ListBox& rListBox) const;
+ sal_Bool getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,::com::sun::star::beans::PropertyValue& _rFilter) const;
+ void fillLines(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& _aValues);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getMatchingColumn( const Edit& _rValueInput ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getColumn( const ::rtl::OUString& _rFieldName ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getQueryColumn( const ::rtl::OUString& _rFieldName ) const;
+
+ public:
+ DlgFilterCrit( Window * pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& _rxComposer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols
+ );
+ ~DlgFilterCrit();
+
+ void BuildWherePart();
+
+ protected:
+ DECL_LINK( PredicateLoseFocus, Edit* );
+ };
+
+}
+
+#endif // DBAUI_QUERYFILTER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/queryorder.hxx b/dbaccess/source/ui/inc/queryorder.hxx
new file mode 100644
index 000000000000..86dc874197d8
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryorder.hxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYORDER_HXX
+#define DBAUI_QUERYORDER_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/edit.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+
+#define DOG_ROWS 3
+
+namespace rtl
+{
+ class OUString;
+}
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace sdb
+ {
+ class XSingleSelectQueryComposer;
+ }
+ namespace sdbc
+ {
+ class XConnection;
+ }
+ namespace container
+ {
+ class XNameAccess;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ class XPropertySet;
+ }
+ }
+ }
+}
+
+//==================================================================
+// DlgOrderCrit
+//==================================================================
+namespace dbaui
+{
+ class DlgOrderCrit : public ModalDialog
+ {
+ protected:
+ ListBox aLB_ORDERFIELD1;
+ ListBox aLB_ORDERVALUE1;
+ ListBox aLB_ORDERFIELD2;
+ ListBox aLB_ORDERVALUE2;
+ ListBox aLB_ORDERFIELD3;
+ ListBox aLB_ORDERVALUE3;
+ FixedText aFT_ORDERFIELD;
+ FixedText aFT_ORDERAFTER1;
+ FixedText aFT_ORDERAFTER2;
+ FixedText aFT_ORDEROPER;
+ FixedText aFT_ORDERDIR;
+ OKButton aBT_OK;
+ CancelButton aBT_CANCEL;
+ HelpButton aBT_HELP;
+ FixedLine aFL_ORDER;
+ String aSTR_NOENTRY;
+ ::rtl::OUString m_sOrgOrder;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer> m_xQueryComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColumns;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+
+
+ ListBox* m_aColumnList[DOG_ROWS];
+ ListBox* m_aValueList[DOG_ROWS];
+
+ DECL_LINK( FieldListSelectHdl, ListBox * );
+ void EnableLines();
+
+ public:
+ DlgOrderCrit( Window * pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer>& _rxComposer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxCols);
+
+ ~DlgOrderCrit();
+ void BuildOrderPart();
+
+ ::rtl::OUString GetOrderList( ) const;
+ ::rtl::OUString GetOrignalOrder() const { return m_sOrgOrder; }
+
+ private:
+ void impl_initializeOrderList_nothrow();
+ };
+}
+#endif // DBAUI_QUERYORDER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/queryview.hxx b/dbaccess/source/ui/inc/queryview.hxx
new file mode 100644
index 000000000000..b1ead2c6c031
--- /dev/null
+++ b/dbaccess/source/ui/inc/queryview.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYVIEW_HXX
+#define DBAUI_QUERYVIEW_HXX
+
+#include "JoinDesignView.hxx"
+
+namespace dbaui
+{
+ class OQueryController;
+ class OQueryView : public OJoinDesignView
+ {
+ public:
+ OQueryView(Window* pParent, OQueryController& _rController,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+ virtual ~OQueryView();
+
+ virtual sal_Bool isCutAllowed() = 0;
+ virtual sal_Bool isPasteAllowed() = 0;
+ virtual sal_Bool isCopyAllowed() = 0;
+ virtual void copy() = 0;
+ virtual void cut() = 0;
+ virtual void paste() = 0;
+ // clears the whole query
+ virtual void clear() = 0;
+ // set the view readonly or not
+ virtual void setReadOnly(sal_Bool _bReadOnly) = 0;
+ // set the statement for representation
+ virtual void setStatement(const ::rtl::OUString& _rsStatement) = 0;
+ // returns the current sql statement
+ virtual ::rtl::OUString getStatement() = 0;
+ };
+}
+#endif // DBAUI_QUERYVIEW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/sbagrid.hrc b/dbaccess/source/ui/inc/sbagrid.hrc
new file mode 100644
index 000000000000..f10de1b90b68
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbagrid.hrc
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SBA_GRID_HRC
+#define DBACCESS_SBA_GRID_HRC
+
+//----------------Menueitems-------------------------------------------------
+// Tabelle
+#define SBA_WHICHID_START 100
+// Zeilenhoehe
+#define SBA_DEF_ROWHEIGHT (SBA_WHICHID_START+131) // SbaColRowSizeItem
+
+#define SBA_DEF_RANGEFONT (SBA_WHICHID_START+132) // RangeItem
+#define SBA_DEF_FONT (SBA_WHICHID_START+133) // SvxFontItem
+#define SBA_DEF_FONTHEIGHT (SBA_WHICHID_START+134) // SvxFontHeightItem
+#define SBA_DEF_FONTCOLOR (SBA_WHICHID_START+135) // SvxColorItem
+#define SBA_DEF_FONTWEIGHT (SBA_WHICHID_START+136) // SvxWeightItem
+#define SBA_DEF_POSTURE (SBA_WHICHID_START+137) // SvxPostureItem
+#define SBA_DEF_SHADOWED (SBA_WHICHID_START+138) // SvxShadowedItem
+#define SBA_DEF_CONTOUR (SBA_WHICHID_START+139) // SvxContourItem
+#define SBA_DEF_CROSSEDOUT (SBA_WHICHID_START+140) // SvxCrossedOutItem
+#define SBA_DEF_UNDERLINE (SBA_WHICHID_START+141) // SvxUnderlineItem
+#define SBA_DEF_LANGUAGE (SBA_WHICHID_START+142) // SvxLanguageItem
+
+// Spalten
+// Formatierung
+#define SBA_DEF_RANGEFORMAT (SBA_WHICHID_START+143) // RangeItem
+#define SBA_DEF_FMTVALUE (SBA_WHICHID_START+144) // SfxULONG, Format
+
+// Ausrichtung
+#define SBA_ATTR_ALIGN_HOR_JUSTIFY (SBA_WHICHID_START + 145) // SvxHorJustifyItem
+
+// Spaltenbreite
+#define SBA_DEF_FLTCOLWIDTH (SBA_WHICHID_START + 146) // SbaColRowSizeItem
+// Feldtyp
+#define SBA_DEF_FLTTYPE (SBA_WHICHID_START + 147) // DataFieldTypeItem
+// Feldlänge
+#define SBA_DEF_FLTLENGTH (SBA_WHICHID_START + 148) // SfxUInt32Item
+// Eingabe erforderlich
+#define SBA_DEF_FLTREQUIRED (SBA_WHICHID_START + 149) // SfxBoolItem
+// Position in der Tabelle, Abfrage
+#define SBA_DEF_FLTPOS (SBA_WHICHID_START + 150) // SfxUInt16Item
+// Name der zugehoerigen Tabelle
+#define SBA_DEF_FLTTABLE (SBA_WHICHID_START + 151) // SfxStringItem
+// Spalte ausblenden
+#define SBA_DEF_FLTHIDE (SBA_WHICHID_START + 152) // SfxBoolItem
+
+// Ausrichtung
+#define SBA_ATTR_ALIGN_HOR_JUSTIFY (SBA_WHICHID_START + 145) // SvxHorJustifyItem
+
+// Spaltenbreite
+#define SBA_DEF_FLTCOLWIDTH (SBA_WHICHID_START + 146) // SbaColRowSizeItem
+// Feldtyp
+#define SBA_DEF_FLTTYPE (SBA_WHICHID_START + 147) // DataFieldTypeItem
+// Feldlänge
+#define SBA_DEF_FLTLENGTH (SBA_WHICHID_START + 148) // SfxUInt32Item
+// Eingabe erforderlich
+#define SBA_DEF_FLTREQUIRED (SBA_WHICHID_START + 149) // SfxBoolItem
+// Position in der Tabelle, Abfrage
+#define SBA_DEF_FLTPOS (SBA_WHICHID_START + 150) // SfxUInt16Item
+// Name der zugehoerigen Tabelle
+#define SBA_DEF_FLTTABLE (SBA_WHICHID_START + 151) // SfxStringItem
+// Spalte ausblenden
+#define SBA_DEF_FLTHIDE (SBA_WHICHID_START + 152) // SfxBoolItem
+// Kommentar zum Feld
+#define SBA_DEF_FLTCOMMENT (SBA_WHICHID_START + 153) // SfxStringItem
+// default wert
+#define SBA_DEF_FLTDEFAULT (SBA_WHICHID_START + 154) // SfxStringItem
+// Primärschluessel
+#define SBA_DEF_FLTPRIMARY (SBA_WHICHID_START + 155) // SfxBoolItem
+// table properties
+#define SBA_DEF_TABLEPROP (SBA_WHICHID_START + 156) // SfxString
+#define SBA_DEF_SORT (SBA_WHICHID_START + 157) // SfxString
+#define SBA_DEF_FILTER (SBA_WHICHID_START + 158) // SfxString
+#define SBA_DEF_FILTERAPPLIED (SBA_WHICHID_START + 159) // SfxBool
+#define SBA_DEF_ROWHEIGHT_DEFAULT (SBA_WHICHID_START + 160) // SfxBool
+// the col has a default width ?
+#define SBA_DEF_FLTCOLWIDTH_DEFAULT (SBA_WHICHID_START + 161) // SfxBool
+#define SBA_DEF_WORDLINEMODE (SBA_WHICHID_START + 162) // SfxBool
+
+
+
+#endif // DBACCESS_SBA_GRID_HRC
diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx
new file mode 100644
index 000000000000..0d3dc746fa2b
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbagrid.hxx
@@ -0,0 +1,345 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_GRID_HXX
+#define _SBA_GRID_HXX
+
+#include <svx/fmgridcl.hxx>
+
+#include <svx/fmgridif.hxx>
+
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <comphelper/uno3.hxx>
+#include <comphelper/stl_types.hxx>
+#include "sbamultiplex.hxx"
+#include <svx/dataaccessdescriptor.hxx>
+#include <queue>
+
+class SvNumberFormatter;
+
+namespace dbaui
+{
+ //------------------------------------------------------------------
+ struct SbaURLCompare : public ::std::binary_function< ::com::sun::star::util::URL, ::com::sun::star::util::URL, bool>
+ {
+ bool operator() (const ::com::sun::star::util::URL& x, const ::com::sun::star::util::URL& y) const {return x.Complete == y.Complete ? true : false;}
+ };
+
+ struct SbaURLHash
+ {
+ sal_Int32 operator() (const ::com::sun::star::util::URL& x) const {return x.Complete.hashCode();}
+ };
+ //==================================================================
+ // SbaXGridControl
+ //==================================================================
+
+ // class ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > ;
+ FORWARD_DECLARE_INTERFACE(lang,XMultiServiceFactory)
+
+ class SbaXStatusMultiplexer;
+ class SbaXGridControl
+ :public FmXGridControl
+ ,public ::com::sun::star::frame::XDispatch
+ {
+ DECLARE_STL_MAP(::com::sun::star::util::URL, SbaXStatusMultiplexer*, SbaURLCompare,StatusMultiplexerArray);
+ StatusMultiplexerArray m_aStatusMultiplexer;
+
+ public:
+ SbaXGridControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ virtual ~SbaXGridControl();
+
+ // UNO
+ DECLARE_UNO3_DEFAULTS(SbaXGridControl, FmXGridControl);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XServiceInfo
+ ::rtl::OUString SAL_CALL getImplementationName() throw();
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw();
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ // ::com::sun::star::frame::XDispatch
+ virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer) throw( ::com::sun::star::uno::RuntimeException );
+
+ protected:
+ virtual FmXGridPeer* imp_CreatePeer(Window* pParent);
+ };
+
+ //==================================================================
+ // SbaXGridPeer
+ //==================================================================
+
+ class SbaXGridPeer
+ :public FmXGridPeer
+ ,public ::com::sun::star::frame::XDispatch
+ {
+ ::cppu::OMultiTypeInterfaceContainerHelperVar< ::com::sun::star::util::URL,SbaURLHash , SbaURLCompare> m_aStatusListeners;
+
+ public:
+ SbaXGridPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+ virtual ~SbaXGridPeer();
+
+ // UNO
+ virtual void SAL_CALL acquire() throw() { FmXGridPeer::acquire(); }
+ virtual void SAL_CALL release() throw() { FmXGridPeer::release(); }
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
+
+ static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+ sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 > & rId ) throw (::com::sun::star::uno::RuntimeException);
+ static SbaXGridPeer* getImplementation(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxIFace);
+
+ // ::com::sun::star::frame::XDispatch
+ virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::frame::XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ protected:
+ virtual FmGridControl* imp_CreateControl(Window* pParent, WinBits nStyle);
+#if defined(_MSC_VER) && (_MSC_VER >= 1310 )
+ typedef ::com::sun::star::frame::XStatusListener xstlist_type;
+ typedef ::com::sun::star::uno::Reference< xstlist_type > xlistener_type;
+ void NotifyStatusChanged(const ::com::sun::star::util::URL& aUrl, const xlistener_type & xControl = xlistener_type() );
+#else
+ void NotifyStatusChanged(const ::com::sun::star::util::URL& aUrl, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > ());
+#endif // # _MSC_VER>=1310
+
+ private:
+ // for asny execution of XDispatch::dispatch
+ struct DispatchArgs
+ {
+ ::com::sun::star::util::URL aURL;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
+ };
+ ::std::queue< DispatchArgs > m_aDispatchArgs;
+ DECL_LINK( OnDispatchEvent, void* );
+
+ // for dynamic states of our 4 dispatchable URLs
+ enum DispatchType
+ {
+ dtBrowserAttribs,
+ dtRowHeight,
+ dtColumnAttribs,
+ dtColumnWidth,
+
+ dtUnknown
+ };
+ DispatchType classifyDispatchURL( const ::com::sun::star::util::URL& _rURL );
+
+ DECLARE_STL_STDKEY_MAP( DispatchType, sal_Bool, MapDispatchToBool );
+ MapDispatchToBool m_aDispatchStates;
+ };
+
+ //==================================================================
+ // SbaGridHeader
+ //==================================================================
+
+ class SbaGridHeader
+ :public FmGridHeader
+ ,public DragSourceHelper
+ {
+ public:
+ SbaGridHeader(BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG);
+
+ protected:
+
+ // FmGridHeader overridables
+ virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu);
+ virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
+
+ private:
+ // DragSourceHelper overridables
+ virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
+
+ // Window overridables
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+ sal_Bool ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMousePos);
+
+ private:
+ using FmGridHeader::StartDrag;
+ };
+
+ // =========================================================================
+ // interfaces for communication between the vcl grid control and a controller
+ // -------------------------------------------------------------------------
+ class SbaGridListener
+ {
+ public:
+ virtual void RowChanged() = 0;
+ virtual void ColumnChanged() = 0;
+ virtual void SelectionChanged() = 0;
+ virtual void CellActivated() = 0;
+ virtual void CellDeactivated() = 0;
+ virtual void BeforeDrop() = 0;
+ virtual void AfterDrop() = 0;
+ };
+
+ //==================================================================
+ // SbaGridControl
+ //==================================================================
+ //------------------------------------------------------------------
+ class UnoDataBrowserController;
+ class SbaGridControl : public FmGridControl
+ {
+ friend class SbaGridHeader;
+ friend class SbaXGridPeer;
+
+ // Attributes
+ protected:
+ ::svx::ODataAccessDescriptor m_aDataDescriptor;
+ SbaGridListener* m_pMasterListener;
+
+ sal_Int32 m_nAsyncDropEvent;
+
+ sal_uInt16 m_nCurrentActionColId;
+ // ui actions (e.g. a context menu) may be performed on columns which aren't the current one
+ // and aren't selected, so we have to track this column id
+
+ sal_Bool m_bActivatingForDrop;
+ // Attribute Access
+ public:
+ sal_uInt16 GetCurrentActionColumn() const { return m_nCurrentActionColId; }
+
+ public:
+ SbaGridControl(::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >,Window* pParent, FmXGridPeer* _pPeer, WinBits nBits = WB_TABSTOP);
+ virtual ~SbaGridControl();
+
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void Select();
+
+ void SetMasterListener(SbaGridListener* pListener) { m_pMasterListener = pListener; }
+
+ virtual void ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bSetCellFocus = sal_True);
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+ void ActivateCell() { FmGridControl::ActivateCell(); }
+
+ sal_Bool IsAllSelected() const { return (GetSelectRowCount() == GetRowCount()) && (GetRowCount() > 0); }
+
+ HeaderBar* GetHeaderBar() const { return FmGridControl::GetHeaderBar(); }
+
+ /** return the description of the specified object.
+ @param eObjType
+ The type to ask for
+ @param _nPosition
+ The position of a tablecell (index position), header bar colum/row cell
+ @return
+ The description of the specified object.
+ */
+ virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
+
+ virtual void DeleteSelectedRows();
+ /** copies the currently selected rows to the clipboard
+ @precond
+ at least one row is selected
+ */
+ void CopySelectedRowsToClipboard();
+
+
+ protected:
+ // DragSourceHelper overridables
+ virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
+
+ // BrowseBox overridables
+ virtual void CursorMoved();
+ virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
+ virtual void MouseButtonDown( const BrowserMouseEvent& rMEvt);
+
+ // EditBrowseBox overridables
+ virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent);
+ virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
+
+ // DbGridControl overridables
+ virtual void PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu);
+ virtual void PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
+
+ // DbGridControl overridables
+ virtual void onRowChange();
+ virtual void onColumnChange();
+
+ // my own overridables
+ virtual void BeforeDrop();
+ virtual void AfterDrop();
+
+ // get a fields property set from a model pos
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getField(sal_uInt16 nModelPos);
+
+ // get my data source
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataSource() const;
+
+ // drag events
+ virtual void DoColumnDrag(sal_uInt16 nColumnPos);
+ virtual void DoRowDrag(sal_Int16 nRowPos);
+ virtual void DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos);
+
+ void SetBrowserAttrs();
+ void SetColWidth(sal_uInt16 nColId);
+ void SetRowHeight();
+ void SetColAttrs(sal_uInt16 nColId);
+
+ SvNumberFormatter* GetDatasourceFormatter();
+
+ DECL_LINK(AsynchDropEvent, void*);
+
+ private:
+ sal_Bool IsReadOnlyDB() const;
+ void implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag );
+
+ private:
+ using FmGridControl::AcceptDrop;
+ using FmGridControl::ExecuteDrop;
+ using FmGridControl::MouseButtonDown;
+ };
+}
+#endif // _SBA_GRID_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/sbamultiplex.hxx b/dbaccess/source/ui/inc/sbamultiplex.hxx
new file mode 100644
index 000000000000..0fe8ba96aae6
--- /dev/null
+++ b/dbaccess/source/ui/inc/sbamultiplex.hxx
@@ -0,0 +1,438 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_MULTIPLEX_HXX
+#define _SBA_MULTIPLEX_HXX
+
+#include <com/sun/star/beans/XVetoableChangeListener.hpp>
+#include <com/sun/star/form/XUpdateListener.hpp>
+#include <com/sun/star/form/XErrorListener.hpp>
+#include <com/sun/star/form/XRestoreListener.hpp>
+#include <com/sun/star/form/XInsertListener.hpp>
+#include <com/sun/star/form/XDeleteListener.hpp>
+#include <com/sun/star/form/XPositioningListener.hpp>
+#include <com/sun/star/form/XDatabaseParameterListener.hpp>
+#include <com/sun/star/form/XLoadListener.hpp>
+#include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/form/XSubmitListener.hpp>
+#include <com/sun/star/form/XResetListener.hpp>
+#include <com/sun/star/util/XRefreshListener.hpp>
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+#include <com/sun/star/sdb/XRowSetApproveListener.hpp>
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/weak.hxx>
+
+namespace dbaui
+{
+ //------------------------------------------------------------------
+ // TODO : replace this class if MM provides an WeakSubObject in cppu
+ class OSbaWeakSubObject : public ::cppu::OWeakObject
+ {
+ protected:
+ ::cppu::OWeakObject& m_rParent;
+
+ public:
+ OSbaWeakSubObject(::cppu::OWeakObject& rParent) : m_rParent(rParent) { }
+
+ virtual void SAL_CALL acquire() throw() { m_rParent.acquire(); }
+ virtual void SAL_CALL release() throw() { m_rParent.release(); }
+ };
+
+ //------------------------------------------------------------------
+ // declaration of a listener multiplexer class
+ #define BEGIN_DECLARE_LISTENER_MULTIPLEXER(classname, listenerclass) \
+ class classname \
+ :public OSbaWeakSubObject \
+ ,public listenerclass \
+ ,public ::cppu::OInterfaceContainerHelper \
+ { \
+ public: \
+ classname( ::cppu::OWeakObject& rSource, \
+ ::osl::Mutex& rMutex); \
+ DECLARE_UNO3_DEFAULTS(classname, OSbaWeakSubObject); \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( \
+ const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException); \
+ \
+ /* ::com::sun::star::lang::XEventListener */ \
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException); \
+
+
+ #define DECLARE_MULTIPLEXER_VOID_METHOD(methodname, eventtype) \
+ virtual void SAL_CALL methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException); \
+
+ #define DECLARE_MULTIPLEXER_BOOL_METHOD(methodname, eventtype) \
+ virtual sal_Bool SAL_CALL methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException); \
+
+
+ #define END_DECLARE_LISTENER_MULTIPLEXER() \
+ /* resolve ambiguity : both OWeakObject and OInterfaceContainerHelper have these memory operators */ \
+ void * SAL_CALL operator new( size_t size ) throw() { return OSbaWeakSubObject::operator new(size); } \
+ void SAL_CALL operator delete( void * p ) throw() { OSbaWeakSubObject::operator delete(p); } \
+ }; \
+
+ //------------------------------------------------------------------
+ // implementation of a listener multiplexer class
+
+ #define IMPLEMENT_LISTENER_MULTIPLEXER_CORE(classname, listenerclass) \
+ \
+ /*................................................................*/ \
+ classname::classname(::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex) \
+ :OSbaWeakSubObject(rSource) \
+ ,OInterfaceContainerHelper(_rMutex) \
+ { \
+ } \
+ \
+ ::com::sun::star::uno::Any SAL_CALL classname::queryInterface( \
+ const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aReturn = \
+ OSbaWeakSubObject::queryInterface(_rType); \
+ if (!aReturn.hasValue()) \
+ aReturn = ::cppu::queryInterface(_rType, \
+ static_cast< listenerclass* >(this), \
+ static_cast< ::com::sun::star::lang::XEventListener* >(static_cast< listenerclass* >(this)) \
+ ); \
+ \
+ return aReturn; \
+ } \
+ /*................................................................*/ \
+ void SAL_CALL classname::disposing(const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException)\
+ { \
+ } \
+
+
+ #define IMPLEMENT_LISTENER_MULTIPLEXER_VOID_METHOD(classname, listenerclass, methodname, eventtype) \
+ void SAL_CALL classname::methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ eventtype aMulti(e); \
+ aMulti.Source = &m_rParent; \
+ ::cppu::OInterfaceIteratorHelper aIt(*this); \
+ while (aIt.hasMoreElements()) \
+ static_cast< listenerclass*>(aIt.next())->methodname(aMulti); \
+ } \
+
+ #define IMPLEMENT_LISTENER_MULTIPLEXER_BOOL_METHOD(classname, listenerclass, methodname, eventtype) \
+ /*................................................................*/ \
+ sal_Bool SAL_CALL classname::methodname(const eventtype& e) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ eventtype aMulti(e); \
+ aMulti.Source = &m_rParent; \
+ ::cppu::OInterfaceIteratorHelper aIt(*this); \
+ sal_Bool bResult = sal_True; \
+ while (bResult && aIt.hasMoreElements()) \
+ bResult = static_cast< listenerclass*>(aIt.next())->methodname(aMulti); \
+ return bResult; \
+ } \
+
+ //------------------------------------------------------------------
+ // helper for classes which do event multiplexing
+ #define IMPLEMENT_LISTENER_ADMINISTRATION(classname, listenernamespace, listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ /*................................................................*/ \
+ void SAL_CALL classname::add##listenerdesc(const ::com::sun::star::uno::Reference< ::com::sun::star::listenernamespace::X##listenerdesc >& l) throw(::com::sun::star::uno::RuntimeException)\
+ { \
+ multiplexer.addInterface(l); \
+ if (multiplexer.getLength() == 1) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->add##listenerdesc(&multiplexer); \
+ } \
+ } \
+ /*................................................................*/ \
+ void SAL_CALL classname::remove##listenerdesc(const ::com::sun::star::uno::Reference< ::com::sun::star::listenernamespace::X##listenerdesc >& l) throw(::com::sun::star::uno::RuntimeException)\
+ { \
+ if (multiplexer.getLength() == 1) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->remove##listenerdesc(&multiplexer); \
+ } \
+ multiplexer.removeInterface(l); \
+ } \
+
+
+ #define STOP_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ if (multiplexer.getLength()) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->remove##listenerdesc(&multiplexer); \
+ } \
+
+ #define START_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ if (multiplexer.getLength()) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->add##listenerdesc(&multiplexer); \
+ } \
+
+
+
+ //------------------------------------------------------------------
+ // declaration of property listener multiplexers
+ // (with support for specialized and unspecialized property listeners)
+
+ #define DECLARE_PROPERTY_MULTIPLEXER(classname, listenerclass, methodname, eventtype, exceptions) \
+ class classname \
+ :public OSbaWeakSubObject \
+ ,public listenerclass \
+ { \
+ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< \
+ ::rtl::OUString, ::comphelper::UStringHash, ::comphelper::UStringEqual > ListenerContainerMap; \
+ ListenerContainerMap m_aListeners; \
+ \
+ public: \
+ classname( ::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex ); \
+ DECLARE_UNO3_DEFAULTS(classname, OSbaWeakSubObject); \
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( \
+ const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException); \
+ \
+ /* ::com::sun::star::lang::XEventListener */ \
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException); \
+ \
+ virtual void SAL_CALL methodname(const eventtype& e) throw exceptions; \
+ \
+ public: \
+ void addInterface(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rListener); \
+ void removeInterface(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rListener); \
+ \
+ void disposeAndClear(); \
+ \
+ sal_Int32 getOverallLen() const; \
+ \
+ ::cppu::OInterfaceContainerHelper* getContainer(const ::rtl::OUString& rName) \
+ { return m_aListeners.getContainer(rName); } \
+ \
+ protected: \
+ void Notify(::cppu::OInterfaceContainerHelper& rListeners, const eventtype& e); \
+ }; \
+
+
+ //------------------------------------------------------------------
+ // implementation of property listener multiplexers
+ #define IMPLEMENT_PROPERTY_MULTIPLEXER(classname, listenerclass, methodname, eventtype, exceptions) \
+ /*................................................................*/ \
+ classname::classname(::cppu::OWeakObject& rSource, ::osl::Mutex& rMutex) \
+ :OSbaWeakSubObject(rSource) \
+ ,m_aListeners(rMutex) \
+ { \
+ } \
+ \
+ ::com::sun::star::uno::Any SAL_CALL classname::queryInterface( \
+ const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ ::com::sun::star::uno::Any aReturn = \
+ OSbaWeakSubObject::queryInterface(_rType); \
+ if (!aReturn.hasValue()) \
+ aReturn = ::cppu::queryInterface(_rType, \
+ static_cast< listenerclass* >(this), \
+ static_cast< ::com::sun::star::lang::XEventListener* >(static_cast< listenerclass* >(this)) \
+ ); \
+ \
+ return aReturn; \
+ } \
+ /*................................................................*/ \
+ void SAL_CALL classname::disposing(const ::com::sun::star::lang::EventObject& ) throw(::com::sun::star::uno::RuntimeException)\
+ { \
+ } \
+ \
+ void SAL_CALL classname::methodname(const eventtype& e) throw exceptions \
+ { \
+ ::cppu::OInterfaceContainerHelper* pListeners = m_aListeners.getContainer(e.PropertyName); \
+ if (pListeners) \
+ Notify(*pListeners, e); \
+ \
+ /* do the notification for the unspecialized listeners, too */ \
+ pListeners = m_aListeners.getContainer(::rtl::OUString()); \
+ if (pListeners) \
+ Notify(*pListeners, e); \
+ } \
+ \
+ void classname::addInterface(const ::rtl::OUString& rName, \
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener) \
+ { \
+ m_aListeners.addInterface(rName, rListener); \
+ } \
+ \
+ void classname::removeInterface(const ::rtl::OUString& rName, \
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener) \
+ { \
+ m_aListeners.removeInterface(rName, rListener); \
+ } \
+ \
+ void classname::disposeAndClear() \
+ { \
+ ::com::sun::star::lang::EventObject aEvt(m_rParent); \
+ m_aListeners.disposeAndClear(aEvt); \
+ } \
+ \
+ sal_Int32 classname::getOverallLen() const \
+ { \
+ sal_Int32 nLen = 0; \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aContained = m_aListeners.getContainedTypes(); \
+ const ::rtl::OUString* pContained = aContained.getConstArray(); \
+ for ( sal_Int32 i=0; i<aContained.getLength(); ++i, ++pContained) \
+ nLen += m_aListeners.getContainer(*pContained)->getLength(); \
+ return nLen; \
+ } \
+ \
+ void classname::Notify(::cppu::OInterfaceContainerHelper& rListeners, const eventtype& e) \
+ { \
+ eventtype aMulti(e); \
+ aMulti.Source = &m_rParent; \
+ ::cppu::OInterfaceIteratorHelper aIt(rListeners); \
+ while (aIt.hasMoreElements()) \
+ static_cast< listenerclass*>(aIt.next())->methodname(aMulti); \
+ } \
+
+ //------------------------------------------------------------------
+ // helper for classes which do property event multiplexing
+ #define IMPLEMENT_PROPERTY_LISTENER_ADMINISTRATION(classname, listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ /*................................................................*/ \
+ void SAL_CALL classname::add##listenerdesc(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::X##listenerdesc >& l ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)\
+ { \
+ multiplexer.addInterface(rName, l); \
+ if (multiplexer.getOverallLen() == 1) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->add##listenerdesc(::rtl::OUString(), &multiplexer); \
+ } \
+ } \
+ /*................................................................*/ \
+ void SAL_CALL classname::remove##listenerdesc(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::X##listenerdesc >& l ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)\
+ { \
+ if (multiplexer.getOverallLen() == 1) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->remove##listenerdesc(::rtl::OUString(), &multiplexer); \
+ } \
+ multiplexer.removeInterface(rName, l); \
+ } \
+
+ #define STOP_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ if (multiplexer.getOverallLen()) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->remove##listenerdesc(::rtl::OUString(), &multiplexer); \
+ } \
+
+ #define START_PROPERTY_MULTIPLEXER_LISTENING(listenerdesc, multiplexer, braodcasterclass, broadcaster) \
+ if (multiplexer.getOverallLen()) \
+ { \
+ ::com::sun::star::uno::Reference< braodcasterclass > xBroadcaster(broadcaster, ::com::sun::star::uno::UNO_QUERY); \
+ if (xBroadcaster.is()) \
+ xBroadcaster->add##listenerdesc(::rtl::OUString(), &multiplexer); \
+ } \
+
+
+
+ //==================================================================
+ // some listener multiplexers
+ //==================================================================
+ // ::com::sun::star::frame::XStatusListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXStatusMultiplexer, ::com::sun::star::frame::XStatusListener)
+ DECLARE_MULTIPLEXER_VOID_METHOD(statusChanged, ::com::sun::star::frame::FeatureStateEvent)
+
+ private:
+ ::com::sun::star::frame::FeatureStateEvent m_aLastKnownStatus;
+ public: \
+ inline ::com::sun::star::frame::FeatureStateEvent getLastEvent( ) const { return m_aLastKnownStatus; }
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::form::XLoadListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXLoadMultiplexer, ::com::sun::star::form::XLoadListener)
+ DECLARE_MULTIPLEXER_VOID_METHOD(loaded, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(unloaded, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(unloading, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(reloading, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(reloaded, ::com::sun::star::lang::EventObject)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::form::XDatabaseParameterListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXParameterMultiplexer, ::com::sun::star::form::XDatabaseParameterListener)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveParameter, ::com::sun::star::form::DatabaseParameterEvent)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::form::XSubmitListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSubmitMultiplexer, ::com::sun::star::form::XSubmitListener)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveSubmit, ::com::sun::star::lang::EventObject)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::form::XResetListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXResetMultiplexer, ::com::sun::star::form::XResetListener)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveReset, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(resetted, ::com::sun::star::lang::EventObject)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::sdbc::XRowSetListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetMultiplexer, ::com::sun::star::sdbc::XRowSetListener)
+ DECLARE_MULTIPLEXER_VOID_METHOD(cursorMoved, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(rowChanged, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_VOID_METHOD(rowSetChanged, ::com::sun::star::lang::EventObject)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::sdb::XRowSetApproveListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXRowSetApproveMultiplexer, ::com::sun::star::sdb::XRowSetApproveListener)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveCursorMove, ::com::sun::star::lang::EventObject)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowChange, ::com::sun::star::sdb::RowChangeEvent)
+ DECLARE_MULTIPLEXER_BOOL_METHOD(approveRowSetChange, ::com::sun::star::lang::EventObject)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::sdb::XSQLErrorListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXSQLErrorMultiplexer, ::com::sun::star::sdb::XSQLErrorListener)
+ DECLARE_MULTIPLEXER_VOID_METHOD(errorOccured, ::com::sun::star::sdb::SQLErrorEvent)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+
+ // ::com::sun::star::beans::XPropertyChangeListener
+ DECLARE_PROPERTY_MULTIPLEXER(SbaXPropertyChangeMultiplexer, ::com::sun::star::beans::XPropertyChangeListener, propertyChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::uno::RuntimeException))
+
+ // ::com::sun::star::beans::XVetoableChangeListener
+ DECLARE_PROPERTY_MULTIPLEXER(SbaXVetoableChangeMultiplexer, ::com::sun::star::beans::XVetoableChangeListener, vetoableChange, ::com::sun::star::beans::PropertyChangeEvent, (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException))
+
+ // ::com::sun::star::beans::XPropertiesChangeListener
+ BEGIN_DECLARE_LISTENER_MULTIPLEXER(SbaXPropertiesChangeMultiplexer, ::com::sun::star::beans::XPropertiesChangeListener)
+ DECLARE_MULTIPLEXER_VOID_METHOD(propertiesChange, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >)
+ END_DECLARE_LISTENER_MULTIPLEXER()
+ // the SbaXPropertiesChangeMultiplexer doesn't care about the property names a listener logs on for, it simply
+ // forwards _all_ changes to _all_ listeners
+}
+
+#endif // _SBA_MULTIPLEXER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/singledoccontroller.hxx b/dbaccess/source/ui/inc/singledoccontroller.hxx
new file mode 100644
index 000000000000..c738bd94e81c
--- /dev/null
+++ b/dbaccess/source/ui/inc/singledoccontroller.hxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_SINGLEDOCCONTROLLER_HXX
+#define DBAUI_SINGLEDOCCONTROLLER_HXX
+
+#include "dbsubcomponentcontroller.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+class SfxUndoAction;
+class SfxUndoManager;
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= OSingleDocumentController
+ //==================================================================================================================
+ struct OSingleDocumentController_Data;
+ typedef ::cppu::ImplInheritanceHelper1 < DBSubComponentController
+ , ::com::sun::star::document::XUndoManagerSupplier
+ > OSingleDocumentController_Base;
+ class OSingleDocumentController : public OSingleDocumentController_Base
+ {
+ protected:
+ OSingleDocumentController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxORB );
+ virtual ~OSingleDocumentController();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ public:
+ /// need for undo's and redo's
+ SfxUndoManager& GetUndoManager() const;
+
+ /// complete clears the Undo/Redo stacks
+ void ClearUndoManager();
+
+ /** addUndoActionAndInvalidate adds an undo action to the undoManager,
+ additionally invalidates the UNDO and REDO slot
+ @param pAction the undo action to add
+ */
+ void addUndoActionAndInvalidate( SfxUndoAction* pAction );
+
+ // OGenericUnoController
+ virtual FeatureState GetState( sal_uInt16 nId ) const;
+ virtual void Execute( sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs );
+
+ // XUndoManagerSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL getUndoManager( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ private:
+ ::std::auto_ptr< OSingleDocumentController_Data > m_pData;
+ };
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
+
+#endif // DBAUI_SINGLEDOCCONTROLLER_HXX
diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx
new file mode 100644
index 000000000000..2e98ce3ac3c6
--- /dev/null
+++ b/dbaccess/source/ui/inc/sqledit.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_SQLEDIT_HXX
+#define DBAUI_SQLEDIT_HXX
+
+#include <svtools/editsyntaxhighlighter.hxx>
+#include <svl/lstner.hxx>
+#include <svtools/colorcfg.hxx>
+#include <unotools/sourceviewconfig.hxx>
+
+namespace dbaui
+{
+ class OQueryTextView;
+ class OSqlEdit : public MultiLineEditSyntaxHighlight, utl::ConfigurationListener
+ {
+ private:
+ Timer m_timerInvalidate;
+ Timer m_timerUndoActionCreation;
+ Link m_lnkTextModifyHdl;
+ String m_strOrigText; // wird beim Undo wiederhergestellt
+ OQueryTextView* m_pView;
+ sal_Bool m_bAccelAction; // Wird bei Cut, Copy, Paste gesetzt
+ sal_Bool m_bStopTimer;
+ utl::SourceViewConfig m_SourceViewConfig;
+ svtools::ColorConfig m_ColorConfig;
+
+ DECL_LINK(OnUndoActionTimer, void*);
+ DECL_LINK(OnInvalidateTimer, void*);
+
+ private:
+ void ImplSetFont();
+
+ protected:
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void GetFocus();
+
+ DECL_LINK(ModifyHdl, void*);
+
+ public:
+ OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle = WB_LEFT | WB_VSCROLL |WB_BORDER);
+ virtual ~OSqlEdit();
+
+ // Edit overridables
+ virtual void SetText(const String& rNewText);
+ using MultiLineEditSyntaxHighlight::SetText;
+
+ // own functionality
+ sal_Bool IsInAccelAct();
+
+ void SetTextModifyHdl(const Link& lnk) { m_lnkTextModifyHdl = lnk; }
+ // bitte nicht SetModifyHdl benutzen, den brauche ich selber, der hier wird von dem damit gesetzten Handler
+ // gerufen
+ // der Link bekommt einen Pointer-to-string, der nach dem Link nicht mehr gueltig ist
+
+ void stopTimer();
+ void startTimer();
+
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
+ using MultiLineEditSyntaxHighlight::Notify;
+ };
+}
+
+#endif // DBAUI_SQLEDIT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/sqlmessage.hxx b/dbaccess/source/ui/inc/sqlmessage.hxx
new file mode 100644
index 000000000000..554310078fb2
--- /dev/null
+++ b/dbaccess/source/ui/inc/sqlmessage.hxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_SQLMESSAGE_HXX_
+#define _DBAUI_SQLMESSAGE_HXX_
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/btndlg.hxx>
+
+#include <connectivity/dbexception.hxx>
+
+#include <memory>
+
+// some forwards
+namespace com { namespace sun { namespace star {
+ namespace sdb {
+ class SQLContext;
+ }
+ namespace sdbc {
+ class SQLException;
+ }
+} } }
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//==================================================================
+// OSQLMessageBox
+//==================================================================
+struct SQLMessageBox_Impl;
+class OSQLMessageBox : public ButtonDialog
+{
+ FixedImage m_aInfoImage;
+ FixedText m_aTitle;
+ FixedText m_aMessage;
+ ::rtl::OUString m_sHelpURL;
+
+ ::std::auto_ptr< SQLMessageBox_Impl > m_pImpl;
+
+public:
+ enum MessageType
+ {
+ Info,
+ Error,
+ Warning,
+ Query,
+
+ AUTO
+ };
+
+public:
+ /** display an SQLException with auto-recognizing a main and a detailed message
+
+ The first two messages from the exception chain are used as main and detailed message (recognizing the
+ detailed field of an <type scope="com::sun::star::sdb">SQLContext</type>).
+ */
+ OSQLMessageBox(
+ Window* _pParent,
+ const dbtools::SQLExceptionInfo& _rException,
+ WinBits _nStyle = WB_OK | WB_DEF_OK,
+ const ::rtl::OUString& _rHelpURL = ::rtl::OUString()
+ );
+
+ /** display a database related error message
+
+ @param rTitle the title to display
+ @param rMessage the detailed message to display
+ @param _eType determines the image to use. AUTO is disallowed in this constructor version
+ */
+ OSQLMessageBox(Window* pParent,
+ const UniString& rTitle,
+ const UniString& rMessage,
+ WinBits nStyle = WB_OK | WB_DEF_OK,
+ MessageType _eType = Info,
+ const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = NULL );
+
+ ~OSQLMessageBox();
+
+private:
+ void Construct( WinBits nStyle, MessageType eImage );
+
+ DECL_LINK(ButtonClickHdl, Button* );
+
+private:
+ void impl_positionControls();
+ void impl_initImage( MessageType _eImage );
+ void impl_createStandardButtons( WinBits _nStyle );
+ void impl_addDetailsButton();
+};
+
+//==================================================================
+// OSQLWarningBox
+//==================================================================
+class OSQLWarningBox : public OSQLMessageBox
+{
+public:
+ OSQLWarningBox( Window* _pParent,
+ const UniString& _rMessage,
+ WinBits _nStyle = WB_OK | WB_DEF_OK,
+ const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = NULL );
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_SQLMESSAGE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/statusbarontroller.hxx b/dbaccess/source/ui/inc/statusbarontroller.hxx
new file mode 100644
index 000000000000..57d82d317605
--- /dev/null
+++ b/dbaccess/source/ui/inc/statusbarontroller.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_STATUSBARCONTROLLER_HXX
+#define DBAUI_STATUSBARCONTROLLER_HXX
+
+#include <svtools/statusbarcontroller.hxx>
+#include <comphelper/uno3.hxx>
+#include "apitools.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace dbaui
+{
+ typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> OStatusbarController_BASE;
+ class OStatusbarController : public ::svt::StatusbarController,
+ public OStatusbarController_BASE
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ public:
+ OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB):m_xORB(_rxORB){}
+
+ DECLARE_XINTERFACE()
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+ };
+}
+#endif // DBAUI_STATUSBARCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/stringlistitem.hxx b/dbaccess/source/ui/inc/stringlistitem.hxx
new file mode 100644
index 000000000000..713026625d6f
--- /dev/null
+++ b/dbaccess/source/ui/inc/stringlistitem.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_STRINGLISTITEM_HXX_
+#define _DBAUI_STRINGLISTITEM_HXX_
+
+#include <svl/poolitem.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OStringListItem
+//=========================================================================
+/** <type>SfxPoolItem</type> which transports a sequence of <type scope="rtl">OUString</type>'s
+*/
+class OStringListItem : public SfxPoolItem
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aList;
+
+public:
+ TYPEINFO();
+ OStringListItem(sal_Int16 nWhich, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rList);
+ OStringListItem(const OStringListItem& _rSource);
+
+ virtual int operator==(const SfxPoolItem& _rItem) const;
+ virtual SfxPoolItem* Clone(SfxItemPool* _pPool = NULL) const;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > getList() const { return m_aList; }
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_STRINGLISTITEM_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/tabletree.hxx b/dbaccess/source/ui/inc/tabletree.hxx
new file mode 100644
index 000000000000..3b70a0324d46
--- /dev/null
+++ b/dbaccess/source/ui/inc/tabletree.hxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLETREE_HXX_
+#define _DBAUI_TABLETREE_HXX_
+
+#include "marktree.hxx"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdb/application/NamedDatabaseObject.hpp>
+
+#include <memory>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+class ImageProvider;
+
+//========================================================================
+//= OTableTreeListBox
+//========================================================================
+class OTableTreeListBox : public OMarkableTreeListBox
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ m_xConnection; // the connection we're working for, set in implOnNewConnection, called by UpdateTableList
+ ::std::auto_ptr< ImageProvider >
+ m_pImageProvider; // provider for our images
+ sal_Bool m_bVirtualRoot; // should the first entry be visible
+ bool m_bNoEmptyFolders; // should empty catalogs/schematas be prevented from being displayed?
+
+public:
+ OTableTreeListBox(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ WinBits nWinStyle,
+ sal_Bool _bVirtualRoot );
+
+ OTableTreeListBox(
+ Window* pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ResId& rResId,
+ sal_Bool _bVirtualRoot );
+
+ ~OTableTreeListBox();
+
+ typedef ::std::pair< ::rtl::OUString,sal_Bool> TTableViewName;
+ typedef ::std::vector< TTableViewName > TNames;
+
+ void suppressEmptyFolders() { m_bNoEmptyFolders = true; }
+
+ /** call when HiContrast change.
+ */
+ void notifyHiContrastChanged();
+
+ /** determines whether the given entry denotes a tables folder
+ */
+ bool isFolderEntry( const SvLBoxEntry* _pEntry ) const;
+
+ /** determines whether the given entry denotes a table or view
+ */
+ bool isTableOrViewEntry( const SvLBoxEntry* _pEntry ) const
+ {
+ return !isFolderEntry( _pEntry );
+ }
+
+ /** fill the table list with the tables belonging to the connection described by the parameters
+ @param _rxConnection
+ the connection, which must support the service com.sun.star.sdb.Connection
+ @throws
+ <type scope="com::sun::star::sdbc">SQLException</type> if no connection could be created
+ */
+ void UpdateTableList(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
+ ) throw(::com::sun::star::sdbc::SQLException);
+
+ /** fill the table list with the tables and views determined by the two given containers.
+ The views sequence is used to determine which table is of type view.
+ @param _rxConnection the connection where you got the object names from. Must not be NULL.
+ Used to split the full qualified names into it's parts.
+ @param _rTables table/view sequence
+ @param _rViews view sequence
+ */
+ void UpdateTableList(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rTables,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _rViews
+ );
+
+ /** returns a NamedDatabaseObject record which describes the given entry
+ */
+ ::com::sun::star::sdb::application::NamedDatabaseObject
+ describeObject( SvLBoxEntry* _pEntry );
+
+ /** to be used if a foreign instance added a table
+ */
+ SvLBoxEntry* addedTable( const ::rtl::OUString& _rName );
+
+ /** to be used if a foreign instance removed a table
+ */
+ void removedTable( const ::rtl::OUString& _rName );
+
+ /** returns the fully qualified name of a table entry
+ @param _pEntry
+ the entry whose name is to be obtained. Must not denote a folder entry.
+ */
+ String getQualifiedTableName( SvLBoxEntry* _pEntry ) const;
+
+ SvLBoxEntry* getEntryByQualifiedName( const ::rtl::OUString& _rName );
+
+ SvLBoxEntry* getAllObjectsEntry() const;
+
+ /** does a wildcard check of the given entry
+ <p>There are two different 'checked' states: If the user checks all children of an entry, this is different
+ from checking the entry itself. The second is called 'wildcard' checking, 'cause in the resulting
+ table filter it's represented by a wildcard.</p>
+ */
+ void checkWildcard(SvLBoxEntry* _pEntry);
+
+ /** determine if the given entry is 'wildcard checked'
+ @see checkWildcard
+ */
+ sal_Bool isWildcardChecked(SvLBoxEntry* _pEntry) const;
+
+protected:
+ virtual void InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind);
+
+ virtual void checkedButton_noBroadcast(SvLBoxEntry* _pEntry);
+
+ void implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants = sal_True, sal_Bool _bUpdateAncestors = sal_True);
+
+ /** adds the given entry to our list
+ @precond
+ our image provider must already have been reset to the connection to which the meta data
+ belong.
+ */
+ SvLBoxEntry* implAddEntry(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMeta,
+ const ::rtl::OUString& _rTableName,
+ sal_Bool _bCheckName = sal_True
+ );
+
+ void implSetDefaultImages();
+
+ void implOnNewConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection );
+
+ bool impl_getAndAssertMetaData( ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _out_rMetaData ) const;
+
+ sal_Bool haveVirtualRoot() const { return m_bVirtualRoot; }
+
+ /** fill the table list with the tables and views determined by the two given containers
+ @param _rxConnection the connection where you got the object names from. Must not be NULL.
+ Used to split the full qualified names into it's parts.
+ @param _rTables table/view sequence, the second argument is <TRUE/> if it is a table, otherwise it is a view.
+ */
+ void UpdateTableList(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const TNames& _rTables
+ );
+
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_TABLETREE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/textconnectionsettings.hxx b/dbaccess/source/ui/inc/textconnectionsettings.hxx
new file mode 100644
index 000000000000..dcda4a3acdb3
--- /dev/null
+++ b/dbaccess/source/ui/inc/textconnectionsettings.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef TEXTCONNECTIONSETTINGS_HXX
+#define TEXTCONNECTIONSETTINGS_HXX
+
+#include "propertystorage.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+
+#include <memory>
+
+class SfxItemSet;
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ class OTextConnectionHelper;
+
+ //====================================================================
+ //= TextConnectionSettingsDialog
+ //====================================================================
+ class TextConnectionSettingsDialog : public ModalDialog
+ {
+ public:
+ TextConnectionSettingsDialog( Window* _pParent, SfxItemSet& _rItems );
+ ~TextConnectionSettingsDialog();
+
+ /** initializes a set of PropertyStorage instaces, which are bound to
+ the text-connection relevant items in our item sets
+ */
+ static void bindItemStorages( SfxItemSet& _rSet, PropertyValues& _rValues );
+
+ virtual short Execute();
+
+ private:
+ ::std::auto_ptr< OTextConnectionHelper > m_pTextConnectionHelper;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ SfxItemSet& m_rItems;
+
+ private:
+ DECL_LINK( OnOK, PushButton* );
+ };
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+#endif // TEXTCONNECTIONSETTINGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/toolbox_tmpl.hrc b/dbaccess/source/ui/inc/toolbox_tmpl.hrc
new file mode 100644
index 000000000000..dfd035d42500
--- /dev/null
+++ b/dbaccess/source/ui/inc/toolbox_tmpl.hrc
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TOOLBOX_HXX
+#define DBAUI_TOOLBOX_HXX
+
+#define CUR_ITEM ToolBoxItem
+#define CUR_SEPARATOR CUR_ITEM {Type = TOOLBOXITEM_SEPARATOR;}
+
+#define MID_SBA_QRY_REFRESH \
+ Identifier = ID_BROWSER_REFRESH ; \
+ Text [ en-US ] = "Refresh"; \
+ Text [ x-comment ] = " "; \
+
+
+#define MID_NEW_VIEW_DESIGN \
+ Identifier = ID_NEW_VIEW_DESIGN; \
+ HelpId = HID_BROWSER_VIEW_CREATE_DESIGN ; \
+ Text [ en-US ] = "New ~View Design" ; \
+
+
+#define MID_NEW_TABLE_DESIGN \
+ Identifier = ID_NEW_TABLE_DESIGN; \
+ HelpId = HID_BROWSER_TABLE_CREATE_DESIGN ; \
+ Text [ en-US ] = "New ~Table Design" ;\
+
+
+#define MID_QUERY_WIZARD \
+ Identifier = ID_NEW_QUERY_WIZARD; \
+ HelpId = HID_BROWSER_QUERY_WIZARD ; \
+ Text[ en-US ] = "Query AutoPilot..."; \
+
+
+#define MID_QUERY_NEW_DESIGN \
+ Identifier = ID_NEW_QUERY_DESIGN; \
+ HelpId = HID_BROWSER_QUERY_CREATE_DESIGN ; \
+ Text [ en-US ] = "New ~Query (Design View)" ; \
+
+
+#define MID_QUERY_EDIT_DESIGN \
+ Identifier = ID_EDIT_QUERY_DESIGN; \
+ HelpId = HID_BROWSER_QUERY_EDIT ; \
+ Text [ en-US ] = "~Edit Query" ; \
+
+
+#define MID_QUERY_NEW_SQL \
+ Identifier = ID_NEW_QUERY_SQL; \
+ HelpId = HID_BROWSER_QUERY_CREATE_TEXT ; \
+ Text [ en-US ] = "New Query (~SQL View)" ; \
+
+
+#define MID_DBUI_QUERY_EDIT_JOINCONNECTION \
+ Identifier = ID_QUERY_EDIT_JOINCONNECTION; \
+ HelpId = HID_QUERY_EDIT_JOINCONNECTION ; \
+ Text [ en-US ] = "Edit..."; \
+
+
+#define MID_COLUMN_WIDTH\
+ Identifier = ID_BROWSER_COLWIDTH ;\
+ HelpID = HID_BROWSER_COLUMNWIDTH ;\
+ Text [ en-US ] = "Column ~Width..." ;\
+
+
+#define MID_DOCUMENT_CREATE_REPWIZ\
+ Identifier = ID_DOCUMENT_CREATE_REPWIZ ;\
+ HelpID = HID_DOCUMENT_CREATE_REPWIZ ;\
+ Text [ en-US ] = "Report Wizard..."; \
+
+
+#define MID_DOCUMENT_NEW_AUTOPILOT \
+ Identifier = SID_DB_FORM_NEW_PILOT; \
+ HelpID = SID_DB_FORM_NEW_PILOT ;\
+ Text [ en-US ] = "Form AutoPilot..."; \
+
+
+#endif // DBAUI_TOOLBOX_HXX
+
diff --git a/dbaccess/source/ui/inc/toolboxcontroller.hxx b/dbaccess/source/ui/inc/toolboxcontroller.hxx
new file mode 100644
index 000000000000..96ab7e3175d6
--- /dev/null
+++ b/dbaccess/source/ui/inc/toolboxcontroller.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBACCESS_TOOLBOXCONTROLLER_HXX
+#define DBACCESS_TOOLBOXCONTROLLER_HXX
+
+#include <svtools/toolboxcontroller.hxx>
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "apitools.hxx"
+#include "moduledbu.hxx"
+#include <memory>
+
+class PopupMenu;
+namespace dbaui
+{
+ typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> TToolboxController_BASE;
+
+ class OToolboxController : public ::svt::ToolboxController
+ ,public TToolboxController_BASE
+ {
+ DECLARE_STL_USTRINGACCESS_MAP(sal_Bool,TCommandState);
+ OModuleClient m_aModuleClient;
+ TCommandState m_aStates;
+ sal_uInt16 m_nToolBoxId;
+
+ ::std::auto_ptr<PopupMenu> getMenu();
+ public:
+ OToolboxController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ // XToolbarController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
+ };
+//..........................................................................
+} // dbaui
+//..........................................................................
+#endif //DBACCESS_TOOLBOXCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/undosqledit.hxx b/dbaccess/source/ui/inc/undosqledit.hxx
new file mode 100644
index 000000000000..0bcbcdabe095
--- /dev/null
+++ b/dbaccess/source/ui/inc/undosqledit.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_UNDOSQLEDIT_HXX
+#define DBAUI_UNDOSQLEDIT_HXX
+
+#include "GeneralUndo.hxx"
+#include "dbu_control.hrc"
+
+namespace dbaui
+{
+ class OSqlEdit;
+ // ================================================================================================
+ // OSqlEditUndoAct - Undo-class for changing sql text
+ //------------------------------------------------------------------------
+ class OSqlEditUndoAct : public OCommentUndoAction
+ {
+ protected:
+ OSqlEdit* m_pOwner;
+ String m_strNextText;
+
+ virtual void Undo() { ToggleText(); }
+ virtual void Redo() { ToggleText(); }
+
+ void ToggleText();
+ public:
+ OSqlEditUndoAct(OSqlEdit* pEdit) : OCommentUndoAction(STR_QUERY_UNDO_MODIFYSQLEDIT), m_pOwner(pEdit) { }
+
+ void SetOriginalText(const String& strText) { m_strNextText =strText; }
+ };
+}
+#endif // DBAUI_UNDOSQLEDIT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/unoadmin.hxx b/dbaccess/source/ui/inc/unoadmin.hxx
new file mode 100644
index 000000000000..3ad794e9c52e
--- /dev/null
+++ b/dbaccess/source/ui/inc/unoadmin.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_UNOADMIN_
+#define _DBAUI_UNOADMIN_
+
+#include <svtools/genericunodialog.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include "dsntypes.hxx"
+#include "moduledbu.hxx"
+
+class SfxItemSet;
+class SfxItemPool;
+class SfxPoolItem;
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+class IDatabaseSettingsDialog;
+
+//=========================================================================
+//= ODatabaseAdministrationDialog
+//=========================================================================
+typedef ::svt::OGenericUnoDialog ODatabaseAdministrationDialogBase;
+class ODatabaseAdministrationDialog
+ :public ODatabaseAdministrationDialogBase
+{
+ OModuleClient m_aModuleClient;
+protected:
+ SfxItemSet* m_pDatasourceItems; // item set for the dialog
+ SfxItemPool* m_pItemPool; // item pool for the item set for the dialog
+ SfxPoolItem** m_pItemPoolDefaults; // pool defaults
+ ::dbaccess::ODsnTypeCollection*
+ m_pCollection; // datasource type collection
+
+ ::com::sun::star::uno::Any m_aInitialSelection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection;
+
+protected:
+ ODatabaseAdministrationDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ virtual ~ODatabaseAdministrationDialog();
+protected:
+// OGenericUnoDialog overridables
+ virtual void destroyDialog();
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_UNOADMIN_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
new file mode 100644
index 000000000000..ad026e81c9f2
--- /dev/null
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -0,0 +1,500 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _SBA_UNODATBR_HXX_
+#define _SBA_UNODATBR_HXX_
+
+#include "brwctrlr.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/i18n/XCollator.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#include <com/sun/star/ui/XContextMenuInterception.hpp>
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrationsListener.hpp>
+#include <cppuhelper/implbase5.hxx>
+#include "callbacks.hxx"
+#include <vcl/timer.hxx>
+#include <svtools/transfer.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <sot/storage.hxx>
+#include "TableCopyHelper.hxx"
+#include "commontypes.hxx"
+
+// =========================================================================
+class SvLBoxEntry;
+class Splitter;
+struct SvSortData;
+
+namespace com { namespace sun{ namespace star { namespace container { class XNameContainer; } } } }
+
+class SvLBoxTreeList;
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+ class DBTreeView;
+ struct DBTreeEditedEntry;
+ class ImageProvider;
+
+ // =====================================================================
+ typedef ::cppu::ImplHelper5 < ::com::sun::star::frame::XStatusListener
+ , ::com::sun::star::view::XSelectionSupplier
+ , ::com::sun::star::document::XScriptInvocationContext
+ , ::com::sun::star::ui::XContextMenuInterception
+ , ::com::sun::star::sdb::XDatabaseRegistrationsListener
+ > SbaTableQueryBrowser_Base;
+ class SbaTableQueryBrowser
+ :public SbaXDataBrowserController
+ ,public SbaTableQueryBrowser_Base
+ ,public IControlActionListener
+ ,public IContextMenuProvider
+ {
+ protected:
+
+ // ---------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_xCollator;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xCurrentFrameParent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMainToolbar;
+
+ // ---------------------------
+ struct ExternalFeature
+ {
+ ::com::sun::star::util::URL aURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
+ xDispatcher;
+ sal_Bool bEnabled;
+
+ ExternalFeature() : bEnabled( sal_False ) { }
+ ExternalFeature( const ::com::sun::star::util::URL& _rURL ) : aURL( _rURL ), bEnabled( sal_False ) { }
+ };
+
+ typedef ::std::map< sal_uInt16, ExternalFeature, ::std::less< sal_uInt16 > > ExternalFeaturesMap;
+ ExternalFeaturesMap m_aExternalFeatures;
+
+ ::svx::ODataAccessDescriptor m_aDocumentDataSource;
+ // if we're part of a document, this is the state of the DocumentDataSource slot
+
+ ::cppu::OInterfaceContainerHelper m_aSelectionListeners;
+ ::cppu::OInterfaceContainerHelper m_aContextMenuInterceptors;
+
+ OTableCopyHelper::DropDescriptor m_aAsyncDrop;
+ OTableCopyHelper m_aTableCopyHelper;
+
+ ::rtl::OUString m_sQueryCommand; // the command of the query currently loaded (if any)
+ //::rtl::OUString m_sToBeLoaded; // contains the element name which should be loaded if any
+
+ DBTreeView* m_pTreeView;
+ Splitter* m_pSplitter;
+ SvLBoxTreeList* m_pTreeModel; // contains the datasources of the registry
+ SvLBoxEntry* m_pCurrentlyDisplayed;
+ sal_uLong m_nAsyncDrop;
+
+ sal_Int16 m_nBorder; // sal_True when border should be shown
+
+ sal_Bool m_bQueryEscapeProcessing : 1; // the escape processing flag of the query currently loaded (if any)
+ sal_Bool m_bShowMenu; // if sal_True the menu should be visible otherwise not
+ sal_Bool m_bInSuspend;
+ sal_Bool m_bEnableBrowser;
+ ::boost::optional< bool >
+ m_aDocScriptSupport; // relevant if and only if we are associated with exactly one DBDoc
+
+
+ virtual ::rtl::OUString getPrivateTitle( ) const;
+ // attribute access
+ public:
+ SbaTableQueryBrowser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM);
+ ~SbaTableQueryBrowser();
+
+ enum EntryType
+ {
+ // don't change the above definitions! There are places (in particular SbaTableQueryBrowser::getCurrentSelection)
+ // which rely on the fact that the EntryType values really equal the DatabaseObject(Container) values!
+ etDatasource = ::com::sun::star::sdb::application::DatabaseObjectContainer::DATA_SOURCE,
+ etQueryContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer::QUERIES,
+ etTableContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer::TABLES,
+ etQuery = ::com::sun::star::sdb::application::DatabaseObject::QUERY,
+ etTableOrView = ::com::sun::star::sdb::application::DatabaseObject::TABLE,
+ etUnknown = -1
+ };
+
+ /** returns a DatabaseObject value corresponding to the given EntryType
+ @param _eType
+ the entry type. Must not be etUnknown.
+ */
+ static sal_Int32 getDatabaseObjectType( EntryType _eType );
+
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
+
+ DECLARE_UNO3_DEFAULTS(SbaTableQueryBrowser,SbaXDataBrowserController);
+ // late construction
+ virtual sal_Bool Construct(Window* pParent);
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XController
+ virtual sal_Bool SAL_CALL suspend(sal_Bool bSuspend) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL attachFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL disposing();
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XSelectionSupplier
+ virtual sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& aSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException);
+ // ::com::sun::star::frame::XFrameActionListener
+ virtual void SAL_CALL frameAction(const ::com::sun::star::frame::FrameActionEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ //IController
+ virtual void notifyHiContrastChanged();
+
+ // XScriptInvocationContext
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XEmbeddedScripts > SAL_CALL getScriptContainer() throw (::com::sun::star::uno::RuntimeException);
+
+ // XContextMenuInterception
+ virtual void SAL_CALL registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDatabaseRegistrationsListener
+ virtual void SAL_CALL registeredDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL changedDatabaseLocation( const ::com::sun::star::sdb::DatabaseRegistrationEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // SbaXDataBrowserController overridables
+ virtual sal_Bool InitializeForm( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_formProperties );
+ virtual sal_Bool InitializeGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
+
+ virtual sal_Bool preReloadForm();
+ virtual void postReloadForm();
+
+ virtual void addModelListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
+ virtual void removeModelListeners(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & _xGridControlModel);
+
+ virtual void AddColumnListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol);
+ virtual void RemoveColumnListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xCol);
+
+ virtual void LoadFinished(sal_Bool _bWasSynch);
+
+ virtual void criticalFail();
+
+ virtual void describeSupportedFeatures();
+ virtual FeatureState GetState(sal_uInt16 nId) const;
+ virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
+
+ // IControlActionListener overridables
+ virtual sal_Bool requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const;
+ virtual sal_Bool requestDrag( sal_Int8 _nAction, const Point& _rPosPixel );
+ virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors );
+ virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt );
+
+ // IContextMenuProvider
+ virtual PopupMenu* getContextMenu( Control& _rControl ) const;
+ virtual IController& getCommandController();
+ virtual ::cppu::OInterfaceContainerHelper*
+ getContextMenuInterceptors();
+ virtual ::com::sun::star::uno::Any
+ getCurrentSelection( Control& _rControl ) const;
+
+ virtual void impl_initialize();
+
+ // SbaGridListener overridables
+ virtual void RowChanged();
+ virtual void ColumnChanged();
+ virtual void SelectionChanged();
+
+ // methods for showing/hiding the explorer part
+ sal_Bool haveExplorer() const;
+ void hideExplorer();
+ void showExplorer();
+ void toggleExplorer() { if (haveExplorer()) hideExplorer(); else showExplorer(); }
+
+ // methods for handling the 'selection' (paintin them bold) of SvLBoxEntries
+ // returns <TRUE/> if the entry is selected (which means it's part of the selected path)
+ sal_Bool isSelected(SvLBoxEntry* _pEntry) const;
+ // select the entry (and only the entry, not the whole path)
+ void select(SvLBoxEntry* _pEntry, sal_Bool _bSelect = sal_True);
+ // select the path of the entry (which must be an entry without children)
+ void selectPath(SvLBoxEntry* _pEntry, sal_Bool _bSelect = sal_True);
+
+ virtual void loadMenu(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame);
+
+ private:
+ // check the state of the external slot given, update any UI elements if necessary
+ void implCheckExternalSlot( sal_uInt16 _nId );
+
+ // connect to the external dispatchers (if any)
+ void connectExternalDispatches();
+
+ /** get the state of an external slot
+ <p>The slot is available if an external dispatcher is responsible for it, _and_ if this dispatcher
+ told us the slot is available.</p>
+ */
+ sal_Bool getExternalSlotState( sal_uInt16 _nId ) const;
+
+ /** add an entry (including the subentries for queries/tables) to the list model
+
+ <p>The given names and images may be empty, in this case they're filled with the correct
+ values. This way they may be reused for the next call, which saves some resource manager calls.</p>
+ */
+ void implAddDatasource(const String& _rDbName, Image& _rDbImage,
+ String& _rQueryName, Image& _rQueryImage,
+ String& _rTableName, Image& _rTableImage,
+ const SharedConnection& _rxConnection
+ );
+
+ void implAddDatasource( const String& _rDataSourceName, const SharedConnection& _rxConnection );
+
+ /// removes (and cleans up) the entry for the given data source
+ void impl_cleanupDataSourceEntry( const String& _rDataSourceName );
+
+ /// clears the tree list box
+ void clearTreeModel();
+
+ /** unloads the form, empties the grid model, cleans up anything related to the currently displayed object
+ @param _bDisposeConnection
+ <TRUE/> if the connection should be disposed
+ @param _bFlushData
+ <TRUE/> if the currently displayed object (if any) should be flushed
+ */
+ void unloadAndCleanup( sal_Bool _bDisposeConnection = sal_True );
+
+ // disposes the connection associated with the given entry (which must represent a data source)
+ void disposeConnection( SvLBoxEntry* _pDSEntry );
+
+ /// flushs and disposes the given connection, and de-registers as listener
+ void impl_releaseConnection( SharedConnection& _rxConnection );
+
+ /** close the connection (and collapse the list entries) of the given list entries
+ */
+ void closeConnection(SvLBoxEntry* _pEntry,sal_Bool _bDisposeConnection = sal_True);
+
+ void populateTree(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xNameAccess, SvLBoxEntry* _pParent, EntryType _eEntryType);
+ void initializeTreeModel();
+
+ /** search in the tree for query- or tablecontainer equal to this interface and return
+ this container entry
+ */
+ SvLBoxEntry* getEntryFromContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxNameAccess);
+ // return true when there is connection available
+ sal_Bool ensureConnection(SvLBoxEntry* _pDSEntry, void * pDSData, SharedConnection& _rConnection );
+ sal_Bool ensureConnection(SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection );
+
+ sal_Bool getExistentConnectionFor( SvLBoxEntry* _pDSEntry, SharedConnection& _rConnection );
+ /** returns an image provider which works with the connection belonging to the given entry
+ */
+ ::std::auto_ptr< ImageProvider >
+ getImageProviderFor( SvLBoxEntry* _pAnyEntry );
+
+ void implAdministrate( SvLBoxEntry* _pApplyTo );
+
+ TransferableHelper*
+ implCopyObject( SvLBoxEntry* _pApplyTo, sal_Int32 _nCommandType, sal_Bool _bAllowConnection = sal_True );
+
+ EntryType getEntryType( SvLBoxEntry* _pEntry ) const;
+ EntryType getChildType( SvLBoxEntry* _pEntry ) const;
+ sal_Bool isObject( EntryType _eType ) const { return ( etTableOrView== _eType ) || ( etQuery == _eType ); }
+ sal_Bool isContainer( EntryType _eType ) const { return (etTableContainer == _eType) || (etQueryContainer == _eType); }
+ sal_Bool isContainer( SvLBoxEntry* _pEntry ) const { return isContainer( getEntryType( _pEntry ) ); }
+
+ // ensure that the xObject for the given entry is set on the user data
+ sal_Bool ensureEntryObject( SvLBoxEntry* _pEntry );
+
+ // get the display text of the entry given
+ String GetEntryText( SvLBoxEntry* _pEntry ) const;
+
+ // is called when a table or a query was selected
+ DECL_LINK( OnSelectionChange, void* );
+ DECL_LINK( OnExpandEntry, SvLBoxEntry* );
+
+ DECL_LINK( OnCopyEntry, void* );
+
+ DECL_LINK( OnTreeEntryCompare, const SvSortData* );
+
+ DECL_LINK( OnAsyncDrop, void* );
+
+ void implRemoveStatusListeners();
+
+ sal_Bool implSelect(const ::svx::ODataAccessDescriptor& _rDescriptor,sal_Bool _bSelectDirect = sal_False);
+ bool implSelect( SvLBoxEntry* _pEntry );
+
+ /// selects the entry given and loads the grid control with the object's data
+ sal_Bool implSelect(
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rCommand,
+ const sal_Int32 _nCommandType,
+ const sal_Bool _bEscapeProcessing,
+ const SharedConnection& _rxConnection,
+ sal_Bool _bSelectDirect = sal_False
+ );
+
+ SvLBoxEntry* implGetConnectionEntry(SvLBoxEntry* _pEntry) const;
+ /// inserts an entry into the tree
+ SvLBoxEntry* implAppendEntry(
+ SvLBoxEntry* _pParent,
+ const String& _rName,
+ void* _pUserData,
+ EntryType _eEntryType
+ );
+
+ /// loads the grid control with the data object specified (which may be a table, a query or a command)
+ sal_Bool implLoadAnything(const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rCommand,
+ const sal_Int32 _nCommandType, const sal_Bool _bEscapeProcessing, const SharedConnection& _rxConnection = SharedConnection() );
+
+ /** retrieves the tree entry for the object described by <arg>_rDescriptor</arg>
+ @param _rDescriptor
+ the object descriptor
+ @param _ppDataSourceEntry
+ If not <NULL/>, the data source tree entry will be returned here
+ @param _ppContainerEntry
+ If not <NULL/>, the object container tree entry will be returned here
+ @param _bExpandAncestors
+ If <TRUE/>, all ancestor on the way to the entry will be expanded
+ */
+ SvLBoxEntry* getObjectEntry(const ::svx::ODataAccessDescriptor& _rDescriptor,
+ SvLBoxEntry** _ppDataSourceEntry = NULL, SvLBoxEntry** _ppContainerEntry = NULL,
+ sal_Bool _bExpandAncestors = sal_True
+ );
+ /** retrieves the tree entry for the object described by data source name, command and command type
+ @param _rDataSource
+ the data source name
+ @param _rCommand
+ the command
+ @param _nCommandType
+ the command type
+ @param _rDescriptor
+ the object descriptor
+ @param _ppDataSourceEntry
+ If not <NULL/>, the data source tree entry will be returned here
+ @param _ppContainerEntry
+ If not <NULL/>, the object container tree entry will be returned here
+ @param _bExpandAncestors
+ If <TRUE/>, all ancestor on the way to the entry will be expanded
+ */
+ SvLBoxEntry* getObjectEntry(
+ const ::rtl::OUString& _rDataSource, const ::rtl::OUString& _rCommand, sal_Int32 _nCommandType,
+ SvLBoxEntry** _ppDataSourceEntry = NULL, SvLBoxEntry** _ppContainerEntry = NULL,
+ sal_Bool _bExpandAncestors = sal_True,
+ const SharedConnection& _rxConnection = SharedConnection()
+ );
+
+ /// checks if m_aDocumentDataSource describes a known object
+ void checkDocumentDataSource();
+
+ void extractDescriptorProps(const ::svx::ODataAccessDescriptor& _rDescriptor,
+ ::rtl::OUString& _rDataSource, ::rtl::OUString& _rCommand, sal_Int32& _rCommandType, sal_Bool& _rEscapeProcessing);
+
+ void transferChangedControlProperty(const ::rtl::OUString& _rProperty, const ::com::sun::star::uno::Any& _rNewValue);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > connectWithStatus(
+ const ::rtl::OUString& _rDataSourceName,
+ void* _pTreeListUserData // in rela a DBTreeListUserData*, but we do not know this class here ....
+ );
+
+#if OSL_DEBUG_LEVEL > 0
+ // checks whether the given tree entry denotes a data source
+ bool impl_isDataSourceEntry( SvLBoxEntry* _pEntry ) const;
+#endif
+
+ /// retrieves the data source URL/name for the given entry representing a data source
+ String getDataSourceAcessor( SvLBoxEntry* _pDataSourceEntry ) const;
+
+ /** get the signature (command/escape processing) of the query the form is based on
+ <p>If the for is not based on a query or not even loaded, nothing happens and <FALSE/> is returned.</p>
+ */
+ sal_Bool implGetQuerySignature( ::rtl::OUString& _rCommand, sal_Bool& _bEscapeProcessing );
+
+ sal_Bool isEntryCopyAllowed(SvLBoxEntry* _pEntry) const;
+
+ void copyEntry(SvLBoxEntry* _pEntry);
+
+ // remove all grid columns and dispose them
+ void clearGridColumns(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _xColContainer);
+
+ /** checks if the currently displayed entry changed
+ @param _sName
+ Name of the changed entry
+ @param _pContainer
+ The container of the displayed entry
+ @return
+ <TRUE/> if it is the currently displayed otherwise <FALSE/>
+ */
+ sal_Bool isCurrentlyDisplayedChanged(const String& _sName,SvLBoxEntry* _pContainer);
+
+ /** called whenever the content of the browser is used for preview, as the very last action
+ of the load process
+ */
+ void initializePreviewMode();
+
+ /** checks whether the Order/Filter clauses set at our row set are valid, removes them if not so
+ */
+ void impl_sanitizeRowSetClauses_nothrow();
+ };
+
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+#endif // _SBA_UNODATBR_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/unosqlmessage.hxx b/dbaccess/source/ui/inc/unosqlmessage.hxx
new file mode 100644
index 000000000000..0022ab64af77
--- /dev/null
+++ b/dbaccess/source/ui/inc/unosqlmessage.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_UNOSQLMESSAGE_HXX_
+#define _DBAUI_UNOSQLMESSAGE_HXX_
+
+#include <svtools/genericunodialog.hxx>
+#include "moduledbu.hxx"
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+typedef ::svt::OGenericUnoDialog OSQLMessageDialogBase;
+class OSQLMessageDialog
+ :public OSQLMessageDialogBase
+ ,public ::comphelper::OPropertyArrayUsageHelper< OSQLMessageDialog >
+{
+ OModuleClient m_aModuleClient;
+protected:
+ // <properties>
+ ::com::sun::star::uno::Any m_aException;
+ ::rtl::OUString m_sHelpURL;
+ // </properties>
+
+protected:
+ OSQLMessageDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( com::sun::star::uno::RuntimeException );
+ static com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
+ SAL_CALL Create(const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+protected:
+// OPropertySetHelper overridables
+ // (overwrittin these three, because we have some special handling for our property)
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( com::sun::star::uno::Any& _rConvertedValue, com::sun::star::uno::Any& _rOldValue, sal_Int32 _nHandle, const com::sun::star::uno::Any& _rValue) throw(com::sun::star::lang::IllegalArgumentException);
+
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_UNOSQLMESSAGE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx
new file mode 100644
index 000000000000..e0b0dd4d8a34
--- /dev/null
+++ b/dbaccess/source/ui/misc/DExport.cxx
@@ -0,0 +1,904 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "DExport.hxx"
+#include "moduledbu.hxx"
+
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include "dbustrings.hrc"
+#include "dbu_misc.hrc"
+#include <connectivity/dbconversion.hxx>
+#include <sfx2/sfxhtml.hxx>
+#include <svl/numuno.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include "TypeInfo.hxx"
+#include "FieldDescriptions.hxx"
+#include "UITools.hxx"
+#include <unotools/configmgr.hxx>
+#include <memory>
+#include <o3tl/compat_functional.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <i18npool/mslangid.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include "WCopyTable.hxx"
+#include "WExtendPages.hxx"
+#include "WCPage.hxx"
+#include <unotools/syslocale.hxx>
+#include <svl/zforlist.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include "sqlmessage.hxx"
+#include "UpdateHelperImpl.hxx"
+#include <vcl/msgbox.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::awt;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+// ==========================================================================
+// ODatabaseExport
+// ==========================================================================
+DBG_NAME(ODatabaseExport)
+ODatabaseExport::ODatabaseExport(sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< XNumberFormatter >& _rxNumberF,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled,
+ SvStream& _rInputStream)
+ :m_vColumns(_rColumnPositions)
+ ,m_aDestColumns(sal_True)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_pFormatter(NULL)
+ ,m_rInputStream( _rInputStream )
+ ,m_pTypeInfo()
+ ,m_pColumnList(pList)
+ ,m_pInfoMap(_pInfoMap)
+ ,m_nColumnPos(0)
+ ,m_nRows(1)
+ ,m_nRowCount(0)
+ ,m_nDefToken( gsl_getSystemTextEncoding() )
+ ,m_bError(sal_False)
+ ,m_bInTbl(sal_False)
+ ,m_bHead(sal_True)
+ ,m_bDontAskAgain(sal_False)
+ ,m_bIsAutoIncrement(_bAutoIncrementEnabled)
+ ,m_bFoundTable(sal_False)
+ ,m_bCheckOnly(sal_False)
+ ,m_bAppendFirstLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ODatabaseExport" );
+ DBG_CTOR(ODatabaseExport,NULL);
+
+ m_nRows += nRows;
+ sal_Int32 nCount = 0;
+ for(sal_Int32 j=0;j < (sal_Int32)m_vColumns.size();++j)
+ if ( m_vColumns[j].first != COLUMN_POSITION_NOT_FOUND )
+ ++nCount;
+
+ m_vColumnSize.resize(nCount);
+ m_vNumberFormat.resize(nCount);
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ m_vColumnSize[i] = 0;
+ m_vNumberFormat[i] = 0;
+ }
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ SetColumnTypes(pList,_pInfoMap);
+}
+//---------------------------------------------------------------------------
+ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection,
+ const Reference< XNumberFormatter >& _rxNumberF,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ SvStream& _rInputStream)
+ :m_aDestColumns(_rxConnection->getMetaData().is() && _rxConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers() == sal_True)
+ ,m_xConnection(_rxConnection)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_pFormatter(NULL)
+ ,m_rInputStream( _rInputStream )
+ ,m_pTypeInfo()
+ ,m_pColumnList(NULL)
+ ,m_pInfoMap(NULL)
+ ,m_nColumnPos(0)
+ ,m_nRows(1)
+ ,m_nRowCount(0)
+ ,m_nDefToken( gsl_getSystemTextEncoding() )
+ ,m_bError(sal_False)
+ ,m_bInTbl(sal_False)
+ ,m_bHead(sal_True)
+ ,m_bDontAskAgain(sal_False)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bFoundTable(sal_False)
+ ,m_bCheckOnly(sal_False)
+ ,m_bAppendFirstLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ODatabaseExport" );
+ DBG_CTOR(ODatabaseExport,NULL);
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ Reference<XTablesSupplier> xTablesSup(m_xConnection,UNO_QUERY);
+ if(xTablesSup.is())
+ m_xTables = xTablesSup->getTables();
+
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ Reference<XResultSet> xSet = xMeta.is() ? xMeta->getTypeInfo() : Reference<XResultSet>();
+ if(xSet.is())
+ {
+ ::connectivity::ORowSetValue aValue;
+ ::std::vector<sal_Int32> aTypes;
+ ::std::vector<sal_Bool> aNullable;
+ Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xSet,UNO_QUERY_THROW)->getMetaData();
+ Reference<XRow> xRow(xSet,UNO_QUERY_THROW);
+ while(xSet->next())
+ {
+ if ( aTypes.empty() )
+ {
+ sal_Int32 nCount = xResultSetMetaData->getColumnCount();
+ if ( nCount < 1 )
+ nCount = 18;
+ aTypes.reserve(nCount+1);
+ aNullable.reserve(nCount+1);
+ aTypes.push_back(-1);
+ aNullable.push_back(sal_False);
+ for (sal_Int32 j = 1; j <= nCount ; ++j)
+ {
+ aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS );
+ aTypes.push_back(xResultSetMetaData->getColumnType(j));
+ }
+ }
+
+ sal_Int32 nPos = 1;
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ ::rtl::OUString sTypeName = aValue;
+ ++nPos;
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ sal_Int32 nType = aValue;
+ ++nPos;
+
+ if( nType == DataType::VARCHAR )
+ {
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+
+ m_pTypeInfo->aTypeName = sTypeName;
+ m_pTypeInfo->nType = nType;
+
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(aTypes.size()),"aTypes: Illegal index for vector");
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nPrecision = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLiteralPrefix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLiteralSuffix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aCreateParams = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bCaseSensitive = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nSearchType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bUnsigned = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bCurrency = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->bAutoIncrement = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->aLocalTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nMinimumScale = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ m_pTypeInfo->nMaximumScale = aValue;
+
+ // check if values are less than zero like it happens in a oracle jdbc driver
+ if( m_pTypeInfo->nPrecision < 0)
+ m_pTypeInfo->nPrecision = 0;
+ if( m_pTypeInfo->nMinimumScale < 0)
+ m_pTypeInfo->nMinimumScale = 0;
+ if( m_pTypeInfo->nMaximumScale < 0)
+ m_pTypeInfo->nMaximumScale = 0;
+ break;
+ }
+ }
+ }
+ if ( !m_pTypeInfo )
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ SetColumnTypes(pList,_pInfoMap);
+}
+//---------------------------------------------------------------------------
+ODatabaseExport::~ODatabaseExport()
+{
+ DBG_DTOR(ODatabaseExport,NULL);
+ m_pFormatter = NULL;
+ ODatabaseExport::TColumns::iterator aIter = m_aDestColumns.begin();
+ ODatabaseExport::TColumns::iterator aEnd = m_aDestColumns.end();
+
+ for(;aIter != aEnd;++aIter)
+ delete aIter->second;
+ m_vDestVector.clear();
+ m_aDestColumns.clear();
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::insertValueIntoColumn()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::insertValueIntoColumn" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ if(m_nColumnPos < sal_Int32(m_vDestVector.size()))
+ {
+ OFieldDescription* pField = m_vDestVector[m_nColumnPos]->second;
+ if(pField)
+ {
+ sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos;
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumns.size()),"m_vColumns: Illegal index for vector");
+
+ if ( (nNewPos) < static_cast<sal_Int32>(m_vColumns.size() ) )
+ {
+ sal_Int32 nPos = m_vColumns[nNewPos].first;
+ if ( nPos != COLUMN_POSITION_NOT_FOUND )
+ {
+ if ( !m_sTextToken.Len() && pField->IsNullable() )
+ m_pUpdateHelper->updateNull(nPos,pField->GetType());
+ else
+ {
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumnTypes.size()),"Illegal index for vector");
+ if (m_vColumnTypes[nNewPos] != DataType::VARCHAR && m_vColumnTypes[nNewPos] != DataType::CHAR && m_vColumnTypes[nNewPos] != DataType::LONGVARCHAR )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "ODatabaseExport::insertValueIntoColumn != DataType::VARCHAR" );
+ ensureFormatter();
+ sal_Int32 nNumberFormat = 0;
+ double fOutNumber = 0.0;
+ bool bNumberFormatError = false;
+ if ( m_pFormatter && m_sNumToken.Len() )
+ {
+ LanguageType eNumLang = LANGUAGE_NONE;
+ sal_uInt32 nNumberFormat2( nNumberFormat );
+ fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter);
+ if ( eNumLang != LANGUAGE_NONE )
+ {
+ nNumberFormat2 = m_pFormatter->GetFormatForLanguageIfBuiltIn( nNumberFormat2, eNumLang );
+ m_pFormatter->IsNumberFormat( m_sTextToken, nNumberFormat2, fOutNumber );
+ }
+ nNumberFormat = static_cast<sal_Int32>(nNumberFormat2);
+ }
+ else
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference<XNumberFormatTypes> xNumType(xSupplier->getNumberFormats(),UNO_QUERY);
+ sal_Int16 nFormats[] = {
+ NumberFormat::DATETIME
+ ,NumberFormat::DATE
+ ,NumberFormat::TIME
+ ,NumberFormat::CURRENCY
+ ,NumberFormat::NUMBER
+ ,NumberFormat::LOGICAL
+ };
+ for (size_t i = 0; i < SAL_N_ELEMENTS(nFormats); ++i)
+ {
+ try
+ {
+ nNumberFormat = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(nFormats[i],m_aLocale),m_sTextToken);
+ break;
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ try
+ {
+ fOutNumber = m_xFormatter->convertStringToNumber(nNumberFormat,m_sTextToken);
+ }
+ catch(Exception&)
+ {
+ bNumberFormatError = true;
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+ if ( !bNumberFormatError )
+ {
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+ Reference<XPropertySet> xProp = xFormats->getByKey(nNumberFormat);
+ sal_Int16 nType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case NumberFormat::DATE:
+ m_pUpdateHelper->updateDate(nPos,::dbtools::DBTypeConversion::toDate(fOutNumber,m_aNullDate));
+ break;
+ case NumberFormat::DATETIME:
+ m_pUpdateHelper->updateTimestamp(nPos,::dbtools::DBTypeConversion::toDateTime(fOutNumber,m_aNullDate));
+ break;
+ case NumberFormat::TIME:
+ m_pUpdateHelper->updateTime(nPos,::dbtools::DBTypeConversion::toTime(fOutNumber));
+ break;
+ default:
+ m_pUpdateHelper->updateDouble(nPos,fOutNumber);
+ }
+ }
+ catch(Exception&)
+ {
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+
+ }
+ else
+ m_pUpdateHelper->updateString(nPos,m_sTextToken);
+ }
+ }
+ }
+ eraseTokens();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOldNumberFormat)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::CheckString" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ double fOutNumber = 0.0;
+ sal_Int16 nNumberFormat = 0;
+
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+
+ ensureFormatter();
+ if ( m_pFormatter && m_sNumToken.Len() )
+ {
+ LanguageType eNumLang;
+ sal_uInt32 nFormatKey(0);
+ fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nFormatKey,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter);
+ if ( eNumLang != LANGUAGE_NONE )
+ {
+ nFormatKey = m_pFormatter->GetFormatForLanguageIfBuiltIn( nFormatKey, eNumLang );
+ m_pFormatter->IsNumberFormat( m_sTextToken, nFormatKey, fOutNumber );
+ }
+ Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey);
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nNumberFormat;
+ }
+ else
+ {
+ Reference<XNumberFormatTypes> xNumType(xFormats,UNO_QUERY);
+ sal_Int32 nFormatKey = m_xFormatter->detectNumberFormat(xNumType->getStandardFormat(NumberFormat::ALL,m_aLocale),aCheckToken);
+ fOutNumber = m_xFormatter->convertStringToNumber(nFormatKey,aCheckToken);
+
+ Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey);
+ sal_Int16 nType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nType;
+
+ switch(nType)
+ {
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::ALL;
+ break;
+ case NumberFormat::DEFINED:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ case NumberFormat::DATE:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::DATE:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::DATE;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+
+ }
+ break;
+ case NumberFormat::TIME:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::TIME:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::TIME;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::CURRENCY:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::NUMBER:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ case NumberFormat::CURRENCY:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::NUMBER:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::CURRENCY:
+ nNumberFormat = NumberFormat::CURRENCY;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = nType;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ case NumberFormat::TEXT:
+ case NumberFormat::UNDEFINED:
+ case NumberFormat::LOGICAL:
+ nNumberFormat = NumberFormat::TEXT; // Text "uberschreibt alles
+ break;
+ case NumberFormat::DATETIME:
+ switch(_nOldNumberFormat)
+ {
+ case NumberFormat::DATETIME:
+ case NumberFormat::TEXT:
+ case NumberFormat::TIME:
+ nNumberFormat = _nOldNumberFormat;
+ break;
+ case NumberFormat::ALL:
+ nNumberFormat = NumberFormat::DATETIME;
+ break;
+ default:
+ nNumberFormat = NumberFormat::TEXT;
+ break;
+ }
+ break;
+ default:
+ OSL_FAIL("ODatabaseExport: Unbekanntes Format");
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ nNumberFormat = NumberFormat::TEXT; // Text "uberschreibt alles
+ }
+
+ return nNumberFormat;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfoMap* _pInfoMap)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::SetColumnTypes" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ if(_pList && _pInfoMap)
+ {
+ OSL_ENSURE(m_vNumberFormat.size() == m_vColumnSize.size() && m_vColumnSize.size() == _pList->size(),"Illegal columns in list");
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats();
+ TColumnVector::const_iterator aIter = _pList->begin();
+ TColumnVector::const_iterator aEnd = _pList->end();
+ for(sal_Int32 i= 0;aIter != aEnd && (i) < static_cast<sal_Int32>(m_vNumberFormat.size()) && (i) < static_cast<sal_Int32>(m_vColumnSize.size()) ;++aIter,++i)
+ {
+ sal_Int32 nDataType;
+ sal_Int32 nLength(0),nScale(0);
+ sal_Int16 nType = m_vNumberFormat[i] & ~NumberFormat::DEFINED;
+
+ switch ( nType )
+ {
+ case NumberFormat::ALL:
+ nDataType = DataType::DOUBLE;
+ break;
+ case NumberFormat::DEFINED:
+ nDataType = DataType::VARCHAR;
+ nLength = ((m_vColumnSize[i] % 10 ) ? m_vColumnSize[i]/ 10 + 1: m_vColumnSize[i]/ 10) * 10;
+ break;
+ case NumberFormat::DATE:
+ nDataType = DataType::DATE;
+ break;
+ case NumberFormat::TIME:
+ nDataType = DataType::TIME;
+ break;
+ case NumberFormat::DATETIME:
+ nDataType = DataType::TIMESTAMP;
+ break;
+ case NumberFormat::CURRENCY:
+ nDataType = DataType::NUMERIC;
+ nScale = 4;
+ nLength = 19;
+ break;
+ case NumberFormat::NUMBER:
+ case NumberFormat::SCIENTIFIC:
+ case NumberFormat::FRACTION:
+ case NumberFormat::PERCENT:
+ nDataType = DataType::DOUBLE;
+ break;
+ case NumberFormat::TEXT:
+ case NumberFormat::UNDEFINED:
+ case NumberFormat::LOGICAL:
+ default:
+ nDataType = DataType::VARCHAR;
+ nLength = ((m_vColumnSize[i] % 10 ) ? m_vColumnSize[i]/ 10 + 1: m_vColumnSize[i]/ 10) * 10;
+ break;
+ }
+ OTypeInfoMap::const_iterator aFind = _pInfoMap->find(nDataType);
+ if(aFind != _pInfoMap->end())
+ {
+ (*aIter)->second->SetType(aFind->second);
+ (*aIter)->second->SetPrecision(::std::min<sal_Int32>(aFind->second->nPrecision,nLength));
+ (*aIter)->second->SetScale(::std::min<sal_Int32>(aFind->second->nMaximumScale,nScale));
+
+ sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( nDataType,
+ (*aIter)->second->GetScale(),
+ (*aIter)->second->IsCurrency(),
+ Reference< XNumberFormatTypes>(xFormats,UNO_QUERY),
+ m_aLocale);
+
+ (*aIter)->second->SetFormatKey(nFormatKey);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::CreateDefaultColumn(const ::rtl::OUString& _rColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::CreateDefaultColumn" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ Reference< XDatabaseMetaData> xDestMetaData(m_xConnection->getMetaData());
+ sal_Int32 nMaxNameLen(xDestMetaData->getMaxColumnNameLength());
+ ::rtl::OUString aAlias = _rColumnName;
+ if ( isSQL92CheckEnabled(m_xConnection) )
+ aAlias = ::dbtools::convertName2SQLName(_rColumnName,xDestMetaData->getExtraNameCharacters());
+
+ if(nMaxNameLen && aAlias.getLength() > nMaxNameLen)
+ aAlias = aAlias.copy(0, ::std::min<sal_Int32>( nMaxNameLen-1, aAlias.getLength() ) );
+
+ ::rtl::OUString sName(aAlias);
+ if(m_aDestColumns.find(sName) != m_aDestColumns.end())
+ {
+ sal_Int32 nPos = 0;
+ sal_Int32 nCount = 2;
+ while(m_aDestColumns.find(sName) != m_aDestColumns.end())
+ {
+ sName = aAlias;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ if(nMaxNameLen && sName.getLength() > nMaxNameLen)
+ {
+ aAlias = aAlias.copy(0,::std::min<sal_Int32>( nMaxNameLen-nCount, aAlias.getLength() ));
+ sName = aAlias;
+ sName += ::rtl::OUString::valueOf(nPos);
+ ++nCount;
+ }
+ }
+ }
+ aAlias = sName;
+ // now create a column
+ OFieldDescription* pField = new OFieldDescription();
+ pField->SetType(m_pTypeInfo);
+ pField->SetName(aAlias);
+ pField->SetPrecision(::std::min<sal_Int32>((sal_Int32)255,m_pTypeInfo->nPrecision));
+ pField->SetScale(0);
+ pField->SetIsNullable(ColumnValue::NULLABLE);
+ pField->SetAutoIncrement(sal_False);
+ pField->SetPrimaryKey(sal_False);
+ pField->SetCurrency(sal_False);
+
+ TColumns::iterator aFind = m_aDestColumns.find( aAlias );
+ if ( aFind != m_aDestColumns.end() )
+ {
+ delete aFind->second;
+ m_aDestColumns.erase(aFind);
+ }
+
+ m_vDestVector.push_back(m_aDestColumns.insert(TColumns::value_type(aAlias,pField)).first);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseExport::createRowSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::createRowSet" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+ m_pUpdateHelper.reset(new OParameterUpdateHelper(createPreparedStatment(m_xConnection->getMetaData(),m_xTable,m_vColumns)));
+
+ return m_pUpdateHelper.get() != NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseExport::executeWizard(const ::rtl::OUString& _rTableName,const Any& _aTextColor,const FontDescriptor& _rFont)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::executeWizard" );
+ DBG_CHKTHIS(ODatabaseExport,NULL);
+
+ bool bHaveDefaultTable = ( m_sDefaultTableName.getLength() != 0 );
+ ::rtl::OUString sTableName( bHaveDefaultTable ? m_sDefaultTableName : _rTableName );
+ OCopyTableWizard aWizard(
+ NULL,
+ sTableName,
+ bHaveDefaultTable ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData,
+ m_aDestColumns,
+ m_vDestVector,
+ m_xConnection,
+ m_xFormatter,
+ getTypeSelectionPageFactory(),
+ m_rInputStream,
+ m_xFactory
+ );
+
+ sal_Bool bError = sal_False;
+ try
+ {
+ if (aWizard.Execute())
+ {
+ switch(aWizard.getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ case CopyTableOperation::AppendData:
+ {
+ m_xTable = aWizard.createTable();
+ bError = !m_xTable.is();
+ if(m_xTable.is())
+ {
+ m_xTable->setPropertyValue(PROPERTY_FONT,makeAny(_rFont));
+ if(_aTextColor.hasValue())
+ m_xTable->setPropertyValue(PROPERTY_TEXTCOLOR,_aTextColor);
+ }
+ m_bIsAutoIncrement = aWizard.shouldCreatePrimaryKey();
+ m_vColumns = aWizard.GetColumnPositions();
+ m_vColumnTypes = aWizard.GetColumnTypes();
+ m_bAppendFirstLine = !aWizard.UseHeaderLine();
+ }
+ break;
+ default:
+ bError = sal_True; // there is no error but I have nothing more to do
+ }
+ }
+ else
+ bError = sal_True;
+
+ if(!bError)
+ bError = !createRowSet();
+ }
+ catch( const SQLException&)
+ {
+ ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), &aWizard, m_xFactory );
+ bError = sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return bError;
+}
+//---------------------------------------------------------------------------------
+void ODatabaseExport::showErrorDialog(const ::com::sun::star::sdbc::SQLException& e)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::showErrorDialog" );
+ if(!m_bDontAskAgain)
+ {
+ String aMsg(e.Message);
+ aMsg += '\n';
+ aMsg += String( ModuleRes( STR_QRY_CONTINUE ) );
+ OSQLWarningBox aBox( NULL, aMsg, WB_YES_NO | WB_DEF_NO );
+
+ if (aBox.Execute() == RET_YES)
+ m_bDontAskAgain = sal_True;
+ else
+ m_bError = sal_True;
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::adjustFormat()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::adjustFormat" );
+ if ( m_sTextToken.Len() )
+ {
+ sal_Int32 nNewPos = m_bIsAutoIncrement ? m_nColumnPos+1 : m_nColumnPos;
+ OSL_ENSURE((nNewPos) < static_cast<sal_Int32>(m_vColumns.size()),"Illegal index for vector");
+ if ( (nNewPos) < static_cast<sal_Int32>(m_vColumns.size()) )
+ {
+ sal_Int32 nColPos = m_vColumns[nNewPos].first;
+ if( nColPos != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND))
+ {
+ --nColPos;
+ OSL_ENSURE((nColPos) < static_cast<sal_Int32>(m_vNumberFormat.size()),"m_vFormatKey: Illegal index for vector");
+ OSL_ENSURE((nColPos) < static_cast<sal_Int32>(m_vColumnSize.size()),"m_vColumnSize: Illegal index for vector");
+ m_vNumberFormat[nColPos] = CheckString(m_sTextToken,m_vNumberFormat[nColPos]);
+ m_vColumnSize[nColPos] = ::std::max<sal_Int32>((sal_Int32)m_vColumnSize[nColPos],(sal_Int32)m_sTextToken.Len());
+ }
+ }
+ eraseTokens();
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::eraseTokens()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::eraseTokens" );
+ m_sTextToken.Erase();
+ m_sNumToken.Erase();
+ m_sValToken.Erase();
+}
+// -----------------------------------------------------------------------------
+void ODatabaseExport::ensureFormatter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::ensureFormatter" );
+ if ( !m_pFormatter )
+ {
+ Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ SvNumberFormatsSupplierObj* pSupplierImpl = (SvNumberFormatsSupplierObj*)sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ m_pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
+ Reference<XPropertySet> xNumberFormatSettings = xSupplier->getNumberFormatSettings();
+ xNumberFormatSettings->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate"))) >>= m_aNullDate;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const Reference<XDatabaseMetaData>& _xMetaData
+ ,const Reference<XPropertySet>& _xDestTable
+ ,const TPositions& _rvColumns)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseExport::createPreparedStatment" );
+ ::rtl::OUString aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")));
+ ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( _xMetaData, _xDestTable, ::dbtools::eInDataManipulation, false, false, true );
+
+ aSql += sComposedTableName;
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ( "));
+ // set values and column names
+ ::rtl::OUString aValues(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "));
+ static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
+ static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
+
+ ::rtl::OUString aQuote;
+ if ( _xMetaData.is() )
+ aQuote = _xMetaData->getIdentifierQuoteString();
+
+ Reference<XColumnsSupplier> xDestColsSup(_xDestTable,UNO_QUERY_THROW);
+
+ // create sql string and set column types
+ Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames();
+ if ( aDestColumnNames.getLength() == 0 )
+ {
+ return Reference< XPreparedStatement > ();
+ }
+ const ::rtl::OUString* pIter = aDestColumnNames.getConstArray();
+ ::std::vector< ::rtl::OUString> aInsertList;
+ aInsertList.resize(aDestColumnNames.getLength()+1);
+ sal_Int32 i = 0;
+ for(sal_uInt32 j=0; j < aInsertList.size() ;++i,++j)
+ {
+ ODatabaseExport::TPositions::const_iterator aFind = ::std::find_if(_rvColumns.begin(),_rvColumns.end(),
+ ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),i+1),::o3tl::select2nd<ODatabaseExport::TPositions::value_type>()));
+ if ( _rvColumns.end() != aFind && aFind->second != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND) && aFind->first != sal::static_int_cast< long >(CONTAINER_ENTRY_NOTFOUND) )
+ {
+ OSL_ENSURE((aFind->first) < static_cast<sal_Int32>(aInsertList.size()),"aInsertList: Illegal index for vector");
+ aInsertList[aFind->first] = ::dbtools::quoteName( aQuote,*(pIter+i));
+ }
+ }
+
+ i = 1;
+ // create the sql string
+ ::std::vector< ::rtl::OUString>::iterator aInsertEnd = aInsertList.end();
+ for (::std::vector< ::rtl::OUString>::iterator aInsertIter = aInsertList.begin(); aInsertIter != aInsertEnd; ++aInsertIter)
+ {
+ if ( aInsertIter->getLength() )
+ {
+ aSql += *aInsertIter;
+ aSql += aComma;
+ aValues += aPara;
+ }
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+ aValues = aValues.replaceAt(aValues.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
+
+ aSql += aValues;
+ // now create,fill and execute the prepared statement
+ return Reference< XPreparedStatement >(_xMetaData->getConnection()->prepareStatement(aSql));
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/HtmlReader.cxx b/dbaccess/source/ui/misc/HtmlReader.cxx
new file mode 100644
index 000000000000..d4b4c4c5e329
--- /dev/null
+++ b/dbaccess/source/ui/misc/HtmlReader.cxx
@@ -0,0 +1,593 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "HtmlReader.hxx"
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbtools.hxx>
+#include <tools/tenccvt.hxx>
+#include <comphelper/extract.hxx>
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include <sfx2/sfxhtml.hxx>
+#include <osl/diagnose.h>
+#include <tools/tenccvt.hxx>
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <svtools/htmltokn.h>
+#include <svtools/htmlkywd.hxx>
+#include <tools/color.hxx>
+#include "WCopyTable.hxx"
+#include "WExtendPages.hxx"
+#include "WNameMatch.hxx"
+#include "WColumnSelect.hxx"
+#include "QEnumTypes.hxx"
+#include "WCPage.hxx"
+#include <tools/inetmime.hxx>
+#include <svl/inettype.hxx>
+#include <rtl/tencinfo.h>
+#include "UITools.hxx"
+#include <vcl/svapp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+
+#define DBAUI_HTML_FONTSIZES 8 // wie Export, HTML-Options
+#define HTML_META_NONE 0
+#define HTML_META_AUTHOR 1
+#define HTML_META_DESCRIPTION 2
+#define HTML_META_KEYWORDS 3
+#define HTML_META_REFRESH 4
+#define HTML_META_CLASSIFICATION 5
+#define HTML_META_CREATED 6
+#define HTML_META_CHANGEDBY 7
+#define HTML_META_CHANGED 8
+#define HTML_META_GENERATOR 9
+#define HTML_META_SDFOOTNOTE 10
+#define HTML_META_SDENDNOTE 11
+#define HTML_META_CONTENT_TYPE 12
+
+// ==========================================================================
+DBG_NAME(OHTMLReader)
+// ==========================================================================
+// OHTMLReader
+// ==========================================================================
+OHTMLReader::OHTMLReader(SvStream& rIn,const SharedConnection& _rxConnection,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap)
+ :HTMLParser(rIn)
+ ,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
+ ,m_nTableCount(0)
+ ,m_nColumnWidth(87)
+ ,m_bMetaOptions(sal_False)
+ ,m_bSDNum(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
+ DBG_CTOR(OHTMLReader,NULL);
+ SetSrcEncoding( GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ // If the file starts with a BOM, switch to UCS2.
+ SetSwitchToUCS2( sal_True );
+}
+// ---------------------------------------------------------------------------
+OHTMLReader::OHTMLReader(SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled)
+ :HTMLParser(rIn)
+ ,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
+ ,m_nTableCount(0)
+ ,m_nColumnWidth(87)
+ ,m_bMetaOptions(sal_False)
+ ,m_bSDNum(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::OHTMLReader" );
+ DBG_CTOR(OHTMLReader,NULL);
+ SetSrcEncoding( GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ // If the file starts with a BOM, switch to UCS2.
+ SetSwitchToUCS2( sal_True );
+}
+// ---------------------------------------------------------------------------
+OHTMLReader::~OHTMLReader()
+{
+ DBG_DTOR(OHTMLReader,NULL);
+}
+// ---------------------------------------------------------------------------
+SvParserState OHTMLReader::CallParser()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CallParser" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+ SvParserState eParseState = HTMLParser::CallParser();
+ SetColumnTypes(m_pColumnList,m_pInfoMap);
+ return m_bFoundTable ? eParseState : SVPAR_ERROR;
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::NextToken( int nToken )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::NextToken" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
+ return;
+ if ( nToken == HTML_META )
+ setTextEncoding();
+
+ if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
+ {
+ switch(nToken)
+ {
+ case HTML_TABLE_ON:
+ ++m_nTableCount;
+ { // es kann auch TD oder TH sein, wenn es vorher kein TABLE gab
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_WIDTH:
+ { // Prozent: von Dokumentbreite bzw. aeusserer Zelle
+ m_nColumnWidth = GetWidthPixel( pOption );
+ }
+ break;
+ }
+ }
+ }
+ case HTML_THEAD_ON:
+ case HTML_TBODY_ON:
+ {
+ sal_uInt32 nTell = rInput.Tell(); // ver�ndert vielleicht die Position des Streams
+ if ( !m_xTable.is() )
+ {// erste Zeile als Header verwenden
+ m_bError = !CreateTable(nToken);
+ if ( m_bAppendFirstLine )
+ rInput.Seek(nTell);
+ }
+ }
+ break;
+ case HTML_TABLE_OFF:
+ if(!--m_nTableCount)
+ {
+ m_xTable = NULL;
+ }
+ break;
+ case HTML_TABLEROW_ON:
+ if ( m_pUpdateHelper.get() )
+ {
+ try
+ {
+ m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ }
+ else
+ m_bError = sal_True;
+ break;
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if ( m_bInTbl ) //&& !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += m_sTextToken;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_ON:
+ fetchOptions();
+ break;
+ case HTML_TABLEDATA_OFF:
+ {
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ try
+ {
+ insertValueIntoColumn();
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_sCurrent.Erase();
+ m_nColumnPos++;
+ eraseTokens();
+ m_bSDNum = m_bInTbl = sal_False;
+ }
+ break;
+ case HTML_TABLEROW_OFF:
+ if ( !m_pUpdateHelper.get() )
+ {
+ m_bError = sal_True;
+ break;
+ }
+ try
+ {
+ m_nRowCount++;
+ if (m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
+ m_pUpdateHelper->updateInt(1,m_nRowCount);
+ m_pUpdateHelper->insertRow();
+ }
+ catch(SQLException& e)
+ //////////////////////////////////////////////////////////////////////
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos = 0;
+ break;
+ }
+ }
+ else // Zweig nur f"ur Typpr"ufung g"ultig
+ {
+ switch(nToken)
+ {
+ case HTML_THEAD_ON:
+ case HTML_TBODY_ON:
+ // Der Spalten Kopf z"ahlt nicht mit
+ if(m_bHead)
+ {
+ do
+ {}
+ while(GetNextToken() != HTML_TABLEROW_OFF);
+ m_bHead = sal_False;
+ }
+ break;
+ case HTML_TABLEDATA_ON:
+ case HTML_TABLEHEADER_ON:
+ fetchOptions();
+ break;
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if ( m_bInTbl ) // && !m_bSDNum ) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += m_sTextToken;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_OFF:
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ adjustFormat();
+ m_nColumnPos++;
+ m_bSDNum = m_bInTbl = sal_False;
+ m_sCurrent.Erase();
+ break;
+ case HTML_TABLEROW_OFF:
+ if ( m_sCurrent.Len() )
+ m_sTextToken = m_sCurrent;
+ adjustFormat();
+ m_nColumnPos = 0;
+ m_nRows--;
+ m_sCurrent.Erase();
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::fetchOptions()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::fetchOptions" );
+ m_bInTbl = sal_True;
+ const HTMLOptions* options = GetOptions();
+ sal_Int16 nArrLen = options->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*options)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_SDVAL:
+ {
+ m_sValToken = pOption->GetString();
+ m_bSDNum = sal_True;
+ }
+ break;
+ case HTML_O_SDNUM:
+ m_sNumToken = pOption->GetString();
+ break;
+ }
+ }
+}
+//---------------------------------------------------------------------------------
+void OHTMLReader::TableDataOn(SvxCellHorJustify& eVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableDataOn" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_ALIGN:
+ {
+ const String& rOptVal = pOption->GetString();
+ if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_right ))
+ eVal = SVX_HOR_JUSTIFY_RIGHT;
+ else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_center ))
+ eVal = SVX_HOR_JUSTIFY_CENTER;
+ else if (rOptVal.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_left ))
+ eVal = SVX_HOR_JUSTIFY_LEFT;
+ else
+ eVal = SVX_HOR_JUSTIFY_STANDARD;
+ }
+ break;
+ case HTML_O_WIDTH:
+ m_nWidth = GetWidthPixel( pOption );
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------------------------------
+void OHTMLReader::TableFontOn(FontDescriptor& _rFont,sal_Int32 &_rTextColor)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::TableFontOn" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ const HTMLOptions* pHtmlOptions = GetOptions();
+ sal_Int16 nArrLen = pHtmlOptions->Count();
+ for ( sal_Int16 i = 0; i < nArrLen; i++ )
+ {
+ const HTMLOption* pOption = (*pHtmlOptions)[i];
+ switch( pOption->GetToken() )
+ {
+ case HTML_O_COLOR:
+ {
+ Color aColor;
+ pOption->GetColor( aColor );
+ _rTextColor = aColor.GetRGBColor();
+ }
+ break;
+ case HTML_O_FACE :
+ {
+ const String& rFace = pOption->GetString();
+ String aFontName;
+ xub_StrLen nPos = 0;
+ while( nPos != STRING_NOTFOUND )
+ { // Fontliste, VCL: Semikolon als Separator, HTML: Komma
+ String aFName = rFace.GetToken( 0, ',', nPos );
+ aFName.EraseTrailingChars().EraseLeadingChars();
+ if( aFontName.Len() )
+ aFontName += ';';
+ aFontName += aFName;
+ }
+ if ( aFontName.Len() )
+ _rFont.Name = ::rtl::OUString(aFontName);
+ }
+ break;
+ case HTML_O_SIZE :
+ {
+ sal_Int16 nSize = (sal_Int16) pOption->GetNumber();
+ if ( nSize == 0 )
+ nSize = 1;
+ else if ( nSize < DBAUI_HTML_FONTSIZES )
+ nSize = DBAUI_HTML_FONTSIZES;
+
+ _rFont.Height = nSize;
+ }
+ break;
+ }
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Int16 OHTMLReader::GetWidthPixel( const HTMLOption* pOption )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::GetWidthPixel" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ const String& rOptVal = pOption->GetString();
+ if ( rOptVal.Search('%') != STRING_NOTFOUND )
+ { // Prozent
+ OSL_ENSURE( m_nColumnWidth, "WIDTH Option: m_nColumnWidth==0 und Width%" );
+ return (sal_Int16)((pOption->GetNumber() * m_nColumnWidth) / 100);
+ }
+ else
+ {
+ if ( rOptVal.Search('*') != STRING_NOTFOUND )
+ { // relativ zu was?!?
+//TODO: ColArray aller relativen Werte sammeln und dann MakeCol
+ return 0;
+ }
+ else
+ return (sal_Int16)pOption->GetNumber(); // Pixel
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Bool OHTMLReader::CreateTable(int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::CreateTable" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ String aTempName(ModuleRes(STR_TBL_TITLE));
+ aTempName = aTempName.GetToken(0,' ');
+ aTempName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTempName )));
+
+ int nTmpToken2 = nToken;
+ sal_Bool bCaption = sal_False;
+ sal_Bool bTableHeader = sal_False;
+ String aColumnName;
+ SvxCellHorJustify eVal;
+
+ String aTableName;
+ FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
+ sal_Int32 nTextColor = 0;
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case HTML_TEXTTOKEN:
+ case HTML_SINGLECHAR:
+ if(bTableHeader)
+ aColumnName += aToken;
+ if(bCaption)
+ aTableName += aToken;
+ break;
+ case HTML_PARABREAK_OFF:
+ m_sCurrent += aColumnName;
+ break;
+ case HTML_PARABREAK_ON:
+ m_sTextToken.Erase();
+ break;
+ case HTML_TABLEDATA_ON:
+ case HTML_TABLEHEADER_ON:
+ TableDataOn(eVal);
+ bTableHeader = sal_True;
+ break;
+ case HTML_TABLEDATA_OFF:
+ case HTML_TABLEHEADER_OFF:
+ {
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if (!aColumnName.Len() || m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+ else if ( m_sCurrent.Len() )
+ aColumnName = m_sCurrent;
+
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ CreateDefaultColumn(aColumnName);
+ aColumnName.Erase();
+ m_sCurrent.Erase();
+
+ eVal = SVX_HOR_JUSTIFY_STANDARD;
+ bTableHeader = sal_False;
+ }
+ break;
+
+ case HTML_TITLE_ON:
+ case HTML_CAPTION_ON:
+ bCaption = sal_True;
+ break;
+ case HTML_TITLE_OFF:
+ case HTML_CAPTION_OFF:
+ aTableName.EraseLeadingChars();
+ aTableName.EraseTrailingChars();
+ if(!aTableName.Len())
+ aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
+ else
+ aTableName = aTempName;
+ bCaption = sal_False;
+ break;
+ case HTML_FONT_ON:
+ TableFontOn(aFont,nTextColor);
+ break;
+ case HTML_BOLD_ON:
+ aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
+ break;
+ case HTML_ITALIC_ON:
+ aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
+ break;
+ case HTML_UNDERLINE_ON:
+ aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
+ break;
+ case HTML_STRIKE_ON:
+ aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
+ break;
+ }
+ }
+ while((nTmpToken2 = GetNextToken()) != HTML_TABLEROW_OFF);
+
+ if ( m_sCurrent.Len() )
+ aColumnName = m_sCurrent;
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if(aColumnName.Len())
+ CreateDefaultColumn(aColumnName);
+
+ if ( m_vDestVector.empty() )
+ return sal_False;
+
+ if(!aTableName.Len())
+ aTableName = aTempName;
+
+ m_bInTbl = sal_False;
+ m_bFoundTable = sal_True;
+
+ if ( isCheckEnabled() )
+ return sal_True;
+
+ return !executeWizard(aTableName,makeAny(nTextColor),aFont) && m_xTable.is();
+}
+// -----------------------------------------------------------------------------
+void OHTMLReader::setTextEncoding()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::setTextEncoding" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ m_bMetaOptions = sal_True;
+ ParseMetaOptions(NULL, NULL);
+}
+
+// -----------------------------------------------------------------------------
+void OHTMLReader::release()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::release" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ ReleaseRef();
+}
+// -----------------------------------------------------------------------------
+TypeSelectionPageFactory OHTMLReader::getTypeSelectionPageFactory()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLReader::getTypeSelectionPageFactory" );
+ DBG_CHKTHIS(OHTMLReader,NULL);
+ return &OWizHTMLExtend::Create;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/ModuleHelper.cxx b/dbaccess/source/ui/misc/ModuleHelper.cxx
new file mode 100644
index 000000000000..7a38e3df08eb
--- /dev/null
+++ b/dbaccess/source/ui/misc/ModuleHelper.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "moduledbu.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ OModule& getGlobalDbuModule()
+ {
+ static OModule s_aModule("dbu");
+ return s_aModule;
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx
new file mode 100644
index 000000000000..4ac330a3fc87
--- /dev/null
+++ b/dbaccess/source/ui/misc/RowSetDrop.cxx
@@ -0,0 +1,275 @@
+
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TokenWriter.hxx"
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include "dbu_misc.hrc"
+#include "sqlmessage.hxx"
+#include <vcl/msgbox.hxx>
+#include "dbustrings.hrc"
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <functional>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+
+// export data
+ORowSetImportExport::ORowSetImportExport( Window* _pParent,
+ const Reference< XResultSetUpdate >& _xResultSetUpdate,
+ const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const String& rExchange
+ )
+ : ODatabaseImportExport(_aDataDescriptor,_rM,NULL,rExchange)
+ ,m_xTargetResultSetUpdate(_xResultSetUpdate)
+ ,m_xTargetRowUpdate(_xResultSetUpdate,UNO_QUERY)
+ ,m_pParent(_pParent)
+ ,m_bAlreadyAsked(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::ORowSetImportExport" );
+ OSL_ENSURE(_pParent,"Window can't be null!");
+}
+// -----------------------------------------------------------------------------
+void ORowSetImportExport::initialize()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::initialize" );
+ ODatabaseImportExport::initialize();
+ // do namemapping
+ Reference<XColumnLocate> xColumnLocate(m_xResultSet,UNO_QUERY);
+ OSL_ENSURE(xColumnLocate.is(),"The rowset normally should support this");
+
+ m_xTargetResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xTargetResultSetUpdate,UNO_QUERY)->getMetaData();
+ if(!m_xTargetResultSetMetaData.is() || !xColumnLocate.is() || !m_xResultSetMetaData.is() )
+ throw SQLException(String(ModuleRes(STR_UNEXPECTED_ERROR)),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+
+ sal_Int32 nCount = m_xTargetResultSetMetaData->getColumnCount();
+ m_aColumnMapping.reserve(nCount);
+ m_aColumnTypes.reserve(nCount);
+ for (sal_Int32 i = 1;i <= nCount; ++i)
+ {
+ sal_Int32 nPos = -1; // -1 means column is autoincrement or doesn't exist
+ if(!m_xTargetResultSetMetaData->isAutoIncrement(i))
+ {
+ try
+ {
+ ::rtl::OUString sColumnName = m_xTargetResultSetMetaData->getColumnName(i);
+ nPos = xColumnLocate->findColumn(sColumnName);
+ }
+ catch(const SQLException&)
+ {
+ if(m_xTargetResultSetMetaData->isNullable(i))
+ nPos = 0; // column doesn't exist but we could set it to null
+ }
+ }
+
+ m_aColumnMapping.push_back(nPos);
+ if(nPos > 0)
+ m_aColumnTypes.push_back(m_xResultSetMetaData->getColumnType(nPos));
+ else
+ m_aColumnTypes.push_back(DataType::OTHER);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::Write" );
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::Read" );
+ // check if there is any column to copy
+ if(::std::find_if(m_aColumnMapping.begin(),m_aColumnMapping.end(),
+ ::std::bind2nd(::std::greater<sal_Int32>(),0)) == m_aColumnMapping.end())
+ return sal_False;
+ sal_Bool bContinue = sal_True;
+ if(m_aSelection.getLength())
+ {
+ const Any* pBegin = m_aSelection.getConstArray();
+ const Any* pEnd = pBegin + m_aSelection.getLength();
+ for(;pBegin != pEnd && bContinue;++pBegin)
+ {
+ sal_Int32 nPos = -1;
+ *pBegin >>= nPos;
+ OSL_ENSURE(nPos != -1,"Invalid position!");
+ bContinue = (m_xResultSet.is() && m_xResultSet->absolute(nPos) && insertNewRow());
+ }
+ }
+ else
+ {
+ Reference<XPropertySet> xProp(m_xResultSet,UNO_QUERY);
+ sal_Int32 nRowCount = 0;
+ sal_Int32 nCurrentRow = 0;
+ sal_Int32 nRowFilterIndex = 0;
+ if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISROWCOUNTFINAL) )
+ {
+ sal_Bool bFinal = sal_False;
+ xProp->getPropertyValue(PROPERTY_ISROWCOUNTFINAL) >>= bFinal;
+ if ( !bFinal )
+ m_xResultSet->afterLast();
+ xProp->getPropertyValue(PROPERTY_ROWCOUNT) >>= nRowCount;
+ }
+ if ( !nRowCount )
+ {
+ m_xResultSet->afterLast();
+ nRowCount = m_xResultSet->getRow();
+ }
+ OSL_ENSURE(nRowCount,"RowCount is 0!");
+ m_xResultSet->beforeFirst();
+ while(m_xResultSet.is() && m_xResultSet->next() && bContinue && nRowCount )
+ {
+ --nRowCount;
+ ++nCurrentRow;
+ if(!m_pRowMarker || m_pRowMarker[nRowFilterIndex] == nCurrentRow)
+ {
+ ++nRowFilterIndex;
+ bContinue = insertNewRow();
+ }
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORowSetImportExport::insertNewRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORowSetImportExport::insertNewRow" );
+ try
+ {
+ m_xTargetResultSetUpdate->moveToInsertRow();
+ sal_Int32 i = 1;
+ ::std::vector<sal_Int32>::iterator aEnd = m_aColumnMapping.end();
+ for (::std::vector<sal_Int32>::iterator aIter = m_aColumnMapping.begin(); aIter != aEnd ;++aIter,++i )
+ {
+ if(*aIter > 0)
+ {
+ Any aValue;
+ switch(m_aColumnTypes[i-1])
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aValue <<= m_xRow->getString(*aIter);
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::BIGINT:
+ aValue <<= m_xRow->getLong(*aIter);
+ break;
+ case DataType::FLOAT:
+ aValue <<= m_xRow->getFloat(*aIter);
+ break;
+ case DataType::DOUBLE:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::LONGVARCHAR:
+ aValue <<= m_xRow->getString(*aIter);
+ break;
+ case DataType::LONGVARBINARY:
+ aValue <<= m_xRow->getBytes(*aIter);
+ break;
+ case DataType::DATE:
+ aValue <<= m_xRow->getDate(*aIter);
+ break;
+ case DataType::TIME:
+ aValue <<= m_xRow->getTime(*aIter);
+ break;
+ case DataType::TIMESTAMP:
+ aValue <<= m_xRow->getTimestamp(*aIter);
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aValue <<= m_xRow->getBoolean(*aIter);
+ break;
+ case DataType::TINYINT:
+ aValue <<= m_xRow->getByte(*aIter);
+ break;
+ case DataType::SMALLINT:
+ aValue <<= m_xRow->getShort(*aIter);
+ break;
+ case DataType::INTEGER:
+ aValue <<= m_xRow->getInt(*aIter);
+ break;
+ case DataType::REAL:
+ aValue <<= m_xRow->getDouble(*aIter);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ aValue <<= m_xRow->getBytes(*aIter);
+ break;
+ case DataType::BLOB:
+ aValue <<= m_xRow->getBlob(*aIter);
+ break;
+ case DataType::CLOB:
+ aValue <<= m_xRow->getClob(*aIter);
+ break;
+ default:
+ OSL_FAIL("Unknown type");
+ }
+ if(m_xRow->wasNull())
+ m_xTargetRowUpdate->updateNull(i);
+ else
+ m_xTargetRowUpdate->updateObject(i,aValue);
+ }
+ else if(*aIter == 0)//now we have know that we to set this column to null
+ m_xTargetRowUpdate->updateNull(i);
+ }
+ m_xTargetResultSetUpdate->insertRow();
+ }
+ catch(const SQLException&)
+ {
+ if(!m_bAlreadyAsked)
+ {
+ String sAskIfContinue = String(ModuleRes(STR_ERROR_OCCURRED_WHILE_COPYING));
+ OSQLWarningBox aDlg( m_pParent, sAskIfContinue, WB_YES_NO | WB_DEF_YES );
+ if(aDlg.Execute() == RET_YES)
+ m_bAlreadyAsked = sal_True;
+ else
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx
new file mode 100644
index 000000000000..fb25f77d70f1
--- /dev/null
+++ b/dbaccess/source/ui/misc/RtfReader.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RtfReader.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include "dbustrings.hrc"
+#include <svtools/rtftoken.h>
+#include "dbu_misc.hrc"
+#include <vcl/msgbox.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/extract.hxx>
+#include <tools/color.hxx>
+#include "WExtendPages.hxx"
+#include "moduledbu.hxx"
+#include "QEnumTypes.hxx"
+#include "UITools.hxx"
+#include <vcl/svapp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+
+DBG_NAME(ORTFReader)
+// ==========================================================================
+// ORTFReader
+// ==========================================================================
+ORTFReader::ORTFReader( SvStream& rIn,
+ const SharedConnection& _rxConnection,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap)
+ :SvRTFParser(rIn)
+ ,ODatabaseExport( _rxConnection, _rxNumberF, _rM, pList, _pInfoMap, rIn )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
+ DBG_CTOR(ORTFReader,NULL);
+ m_bAppendFirstLine = false;
+}
+// ---------------------------------------------------------------------------
+ORTFReader::ORTFReader(SvStream& rIn,
+ sal_Int32 nRows,
+ const TPositions &_rColumnPositions,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM,
+ const TColumnVector* pList,
+ const OTypeInfoMap* _pInfoMap,
+ sal_Bool _bAutoIncrementEnabled)
+ :SvRTFParser(rIn)
+ ,ODatabaseExport( nRows, _rColumnPositions, _rxNumberF, _rM, pList, _pInfoMap, _bAutoIncrementEnabled, rIn )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::ORTFReader" );
+ DBG_CTOR(ORTFReader,NULL);
+ m_bAppendFirstLine = false;
+}
+// ---------------------------------------------------------------------------
+ORTFReader::~ORTFReader()
+{
+ DBG_DTOR(ORTFReader,NULL);
+}
+// ---------------------------------------------------------------------------
+SvParserState ORTFReader::CallParser()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CallParser" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ rInput.Seek(STREAM_SEEK_TO_BEGIN);
+ rInput.ResetError();
+ SvParserState eParseState = SvRTFParser::CallParser();
+ SetColumnTypes(m_pColumnList,m_pInfoMap);
+ return m_bFoundTable ? eParseState : SVPAR_ERROR;
+}
+// ---------------------------------------------------------------------------
+void ORTFReader::NextToken( int nToken )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::NextToken" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ if(m_bError || !m_nRows) // falls Fehler oder keine Rows mehr zur "Uberpr"ufung dann gleich zur"uck
+ return;
+
+ if(m_xConnection.is()) // gibt an welcher CTOR gerufen wurde und damit, ob eine Tabelle erstellt werden soll
+ {
+ switch(nToken)
+ {
+ case RTF_COLORTBL:
+ {
+
+ int nTmpToken2 = GetNextToken();
+ do
+ {
+ Color aColor;
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case RTF_RED: aColor.SetRed((sal_uInt8)nTokenValue); break;
+ case RTF_BLUE: aColor.SetBlue((sal_uInt8)nTokenValue); break;
+ case RTF_GREEN: aColor.SetGreen((sal_uInt8)nTokenValue); break;
+ default: break;
+ }
+ nTmpToken2 = GetNextToken();
+ }
+ while(aToken.GetChar(0) != ';' && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ m_vecColor.push_back(aColor.GetRGBColor());
+ nTmpToken2 = GetNextToken();
+ }
+ while(nTmpToken2 == RTF_RED && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ SkipToken();
+ }
+ break;
+
+ case RTF_DEFLANG:
+ case RTF_LANG: // Sprache abfragen
+ m_nDefToken = (rtl_TextEncoding)nTokenValue;
+ break;
+ case RTF_TROWD:
+ {
+ bool bInsertRow = true;
+ if ( !m_xTable.is() ) // erste Zeile als Header verwenden
+ {
+ sal_uInt32 nTell = rInput.Tell(); // ver�ndert vielleicht die Position des Streams
+
+ m_bError = !CreateTable(nToken);
+ bInsertRow = m_bAppendFirstLine;
+ if ( m_bAppendFirstLine )
+ {
+ rInput.Seek(nTell);
+ rInput.ResetError();
+ }
+ }
+ if ( bInsertRow && !m_bError)
+ {
+ try
+ {
+ m_pUpdateHelper->moveToInsertRow(); // sonst neue Zeile anh"angen
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ }
+ }
+ break;
+ case RTF_INTBL:
+ if(m_bInTbl)
+ {
+ eraseTokens();
+ }
+
+ m_bInTbl = sal_True; // jetzt befinden wir uns in einer Tabellenbeschreibung
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl) // wichtig, da wir sonst auch die Namen der Fonts bekommen
+ m_sTextToken += aToken;
+ break;
+ case RTF_CELL:
+ {
+ try
+ {
+ insertValueIntoColumn();
+ }
+ catch(SQLException& e)
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos++;
+ eraseTokens();
+ }
+ break;
+ case RTF_ROW:
+ // es kann vorkommen, da� die letzte Celle nicht mit \cell abgeschlossen ist
+ try
+ {
+ insertValueIntoColumn();
+ m_nRowCount++;
+ if(m_bIsAutoIncrement) // if bSetAutoIncrement then I have to set the autoincrement
+ m_pUpdateHelper->updateInt(1,m_nRowCount);
+ m_pUpdateHelper->insertRow();
+ }
+ catch(SQLException& e)
+ //////////////////////////////////////////////////////////////////////
+ // UpdateFehlerbehandlung
+ {
+ showErrorDialog(e);
+ }
+ m_nColumnPos = 0;
+ break;
+ }
+ }
+ else // Zweig nur f"ur Typpr"ufung g"ultig
+ {
+ switch(nToken)
+ {
+ case RTF_TROWD:
+ // Der Spalten Kopf z"ahlt nicht mit
+ if(m_bHead)
+ {
+ do
+ {}
+ while(GetNextToken() != RTF_ROW && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+ m_bHead = sal_False;
+ }
+ break;
+ case RTF_INTBL:
+ m_bInTbl = sal_True;
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl)
+ m_sTextToken += aToken;
+ break;
+ case RTF_CELL:
+ adjustFormat();
+ m_nColumnPos++;
+ break;
+ case RTF_ROW:
+ adjustFormat();
+ m_nColumnPos = 0;
+ m_nRows--;
+ break;
+ }
+ }
+}
+// ---------------------------------------------------------------------------
+sal_Bool ORTFReader::CreateTable(int nToken)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::CreateTable" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ String aTableName(ModuleRes(STR_TBL_TITLE));
+ aTableName = aTableName.GetToken(0,' ');
+ aTableName = String(::dbtools::createUniqueName(m_xTables,::rtl::OUString(aTableName)));
+
+ int nTmpToken2 = nToken;
+ String aColumnName;
+
+ FontDescriptor aFont = ::dbaui::CreateFontDescriptor(Application::GetSettings().GetStyleSettings().GetAppFont());
+ do
+ {
+ switch(nTmpToken2)
+ {
+ case RTF_UNKNOWNCONTROL:
+ case RTF_UNKNOWNDATA:
+ m_bInTbl = sal_False;
+ aColumnName.Erase();
+ break;
+ case RTF_INTBL:
+ if(m_bInTbl)
+ aColumnName.Erase();
+
+ m_bInTbl = sal_True;
+ break;
+ case RTF_TEXTTOKEN:
+ case RTF_SINGLECHAR:
+ if(m_bInTbl)
+ aColumnName += aToken;
+ break;
+ case RTF_CELL:
+ {
+ aColumnName.EraseLeadingChars();
+ aColumnName.EraseTrailingChars();
+ if (!aColumnName.Len() || m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+
+ CreateDefaultColumn(aColumnName);
+ aColumnName.Erase();
+ }
+ break;
+ case RTF_CF:
+ break;
+ case RTF_B:
+ aFont.Weight = ::com::sun::star::awt::FontWeight::BOLD;
+ break;
+ case RTF_I:
+ aFont.Slant = ::com::sun::star::awt::FontSlant_ITALIC;
+ break;
+ case RTF_UL:
+ aFont.Underline = ::com::sun::star::awt::FontUnderline::SINGLE;
+ break;
+ case RTF_STRIKE:
+ aFont.Strikeout = ::com::sun::star::awt::FontStrikeout::SINGLE;
+ break;
+ }
+ }
+ while((nTmpToken2 = GetNextToken()) != RTF_TROWD && eState != SVPAR_ERROR && eState != SVPAR_ACCEPTED);
+
+ sal_Bool bOk = !m_vDestVector.empty();
+ if(bOk)
+ {
+ if ( aColumnName.Len() )
+ {
+ if ( m_bAppendFirstLine )
+ aColumnName = String(ModuleRes(STR_COLUMN_NAME));
+ CreateDefaultColumn(aColumnName);
+ }
+
+ m_bInTbl = sal_False;
+ m_bFoundTable = sal_True;
+
+ if ( isCheckEnabled() )
+ return sal_True;
+ Any aTextColor;
+ if(!m_vecColor.empty())
+ aTextColor <<= m_vecColor[0];
+
+ bOk = !executeWizard(aTableName,aTextColor,aFont) && m_xTable.is();
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+void ORTFReader::release()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::release" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ ReleaseRef();
+}
+
+// -----------------------------------------------------------------------------
+TypeSelectionPageFactory ORTFReader::getTypeSelectionPageFactory()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFReader::getTypeSelectionPageFactory" );
+ DBG_CHKTHIS(ORTFReader,NULL);
+ return &OWizRTFExtend::Create;
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx
new file mode 100644
index 000000000000..655484d69920
--- /dev/null
+++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx
@@ -0,0 +1,344 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableCopyHelper.hxx"
+#include "dbustrings.hrc"
+#include "sqlmessage.hxx"
+#include <vcl/msgbox.hxx>
+#include "WCopyTable.hxx"
+#include "genericcontroller.hxx"
+#include "WCPage.hxx"
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <com/sun/star/sdb/application/CopyTableWizard.hpp>
+#include <com/sun/star/sdb/DataAccessDescriptorFactory.hpp>
+
+#include "RtfReader.hxx"
+#include "HtmlReader.hxx"
+#include "TokenWriter.hxx"
+#include "UITools.hxx"
+#include "dataview.hxx"
+#include "dbu_resource.hrc"
+#include <unotools/ucbhelper.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/componentcontext.hxx>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <vcl/waitobj.hxx>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <unotools/tempfile.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include "dbexchange.hxx"
+#include <rtl/logfile.hxx>
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+using namespace ::dbtools;
+using namespace ::svx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdb::application;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ucb;
+
+// -----------------------------------------------------------------------------
+OTableCopyHelper::OTableCopyHelper(OGenericUnoController* _pControler)
+ :m_pController(_pControler)
+{
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::insertTable( const ::rtl::OUString& i_rSourceDataSource, const Reference<XConnection>& i_rSourceConnection,
+ const ::rtl::OUString& i_rCommand, const sal_Int32 i_nCommandType,
+ const Reference< XResultSet >& i_rSourceRows, const Sequence< Any >& i_rSelection, const sal_Bool i_bBookmarkSelection,
+ const ::rtl::OUString& i_rDestDataSource, const Reference<XConnection>& i_rDestConnection)
+{
+ if ( CommandType::QUERY != i_nCommandType && CommandType::TABLE != i_nCommandType )
+ {
+ OSL_FAIL( "OTableCopyHelper::insertTable: invalid call (no supported format found)!" );
+ return;
+ }
+
+ try
+ {
+ Reference<XConnection> xSrcConnection( i_rSourceConnection );
+ if ( i_rSourceDataSource == i_rDestDataSource )
+ xSrcConnection = i_rDestConnection;
+
+ if ( !xSrcConnection.is() || !i_rDestConnection.is() )
+ {
+ OSL_FAIL( "OTableCopyHelper::insertTable: no connection/s!" );
+ return;
+ }
+
+ ::comphelper::ComponentContext aContext( m_pController->getORB() );
+
+ Reference< XDataAccessDescriptorFactory > xFactory( DataAccessDescriptorFactory::get( aContext.getUNOContext() ) );
+
+ Reference< XPropertySet > xSource( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
+ xSource->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( i_nCommandType ) );
+ xSource->setPropertyValue( PROPERTY_COMMAND, makeAny( i_rCommand ) );
+ xSource->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( xSrcConnection ) );
+ xSource->setPropertyValue( PROPERTY_RESULT_SET, makeAny( i_rSourceRows ) );
+ xSource->setPropertyValue( PROPERTY_SELECTION, makeAny( i_rSelection ) );
+ xSource->setPropertyValue( PROPERTY_BOOKMARK_SELECTION, makeAny( i_bBookmarkSelection ) );
+
+ Reference< XPropertySet > xDest( xFactory->createDataAccessDescriptor(), UNO_SET_THROW );
+ xDest->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( i_rDestConnection ) );
+
+ Reference< XCopyTableWizard > xWizard( CopyTableWizard::create( aContext.getUNOContext(), xSource, xDest ), UNO_SET_THROW );
+
+ ::rtl::OUString sTableNameForAppend( GetTableNameForAppend() );
+ xWizard->setDestinationTableName( GetTableNameForAppend() );
+
+ bool bAppendToExisting = ( sTableNameForAppend.getLength() != 0 );
+ xWizard->setOperation( bAppendToExisting ? CopyTableOperation::AppendData : CopyTableOperation::CopyDefinitionAndData );
+
+ xWizard->execute();
+ }
+ catch( const SQLException& )
+ {
+ m_pController->showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( const ::svx::ODataAccessDescriptor& _rPasteData, const ::rtl::OUString& i_rDestDataSourceName,
+ const SharedConnection& i_rDestConnection )
+{
+ ::rtl::OUString sSrcDataSourceName = _rPasteData.getDataSource();
+
+ ::rtl::OUString sCommand;
+ _rPasteData[ daCommand ] >>= sCommand;
+
+ Reference<XConnection> xSrcConnection;
+ if ( _rPasteData.has(daConnection) )
+ {
+ OSL_VERIFY( _rPasteData[daConnection] >>= xSrcConnection );
+ }
+
+ Reference< XResultSet > xResultSet;
+ if ( _rPasteData.has(daCursor) )
+ {
+ OSL_VERIFY( _rPasteData[ daCursor ] >>= xResultSet );
+ }
+
+ Sequence< Any > aSelection;
+ if ( _rPasteData.has( daSelection ) )
+ {
+ OSL_VERIFY( _rPasteData[ daSelection ] >>= aSelection );
+ OSL_ENSURE( _rPasteData.has( daBookmarkSelection ), "OTableCopyHelper::pasteTable: you should specify BookmarkSelection, too, to be on the safe side!" );
+ }
+
+
+ sal_Bool bBookmarkSelection( sal_True );
+ if ( _rPasteData.has( daBookmarkSelection ) )
+ {
+ OSL_VERIFY( _rPasteData[ daBookmarkSelection ] >>= bBookmarkSelection );
+ }
+ OSL_ENSURE( bBookmarkSelection, "OTableCopyHelper::pasteTable: working with selection-indicies (instead of bookmarks) is error-prone, and thus deprecated!" );
+
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ if ( _rPasteData.has(daCommandType) )
+ _rPasteData[daCommandType] >>= nCommandType;
+
+ insertTable( sSrcDataSourceName, xSrcConnection, sCommand, nCommandType,
+ xResultSet, aSelection, bBookmarkSelection,
+ i_rDestDataSourceName, i_rDestConnection );
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( SotFormatStringId _nFormatId
+ ,const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _nFormatId == SOT_FORMATSTR_ID_DBACCESS_TABLE || _nFormatId == SOT_FORMATSTR_ID_DBACCESS_QUERY )
+ {
+ if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(_rTransData.GetDataFlavorExVector()) )
+ {
+ ::svx::ODataAccessDescriptor aPasteData = ODataAccessObjectTransferable::extractObjectDescriptor(_rTransData);
+ pasteTable( aPasteData,i_rDestDataSource,_xConnection);
+ }
+ }
+ else if ( _rTransData.HasFormat(_nFormatId) )
+ {
+ try
+ {
+ DropDescriptor aTrans;
+ if ( _nFormatId != SOT_FORMAT_RTF )
+ const_cast<TransferableDataHelper&>(_rTransData).GetSotStorageStream(SOT_FORMATSTR_ID_HTML ,aTrans.aHtmlRtfStorage);
+ else
+ const_cast<TransferableDataHelper&>(_rTransData).GetSotStorageStream(SOT_FORMAT_RTF,aTrans.aHtmlRtfStorage);
+
+ aTrans.nType = E_TABLE;
+ aTrans.bHtml = SOT_FORMATSTR_ID_HTML == _nFormatId;
+ aTrans.sDefaultTableName = GetTableNameForAppend();
+ if ( !copyTagTable(aTrans,sal_False,_xConnection) )
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),0,Any()));
+ }
+ catch(const SQLException&)
+ {
+ m_pController->showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),0,Any()));
+}
+
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::pasteTable( const TransferableDataHelper& _rTransData
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE) || _rTransData.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
+ pasteTable( SOT_FORMATSTR_ID_DBACCESS_TABLE,_rTransData,i_rDestDataSource,_xConnection);
+ else if ( _rTransData.HasFormat(SOT_FORMATSTR_ID_HTML) )
+ pasteTable( SOT_FORMATSTR_ID_HTML,_rTransData,i_rDestDataSource,_xConnection);
+ else if ( _rTransData.HasFormat(SOT_FORMAT_RTF) )
+ pasteTable( SOT_FORMAT_RTF,_rTransData,i_rDestDataSource,_xConnection);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::copyTagTable(OTableCopyHelper::DropDescriptor& _rDesc, sal_Bool _bCheck,const SharedConnection& _xConnection)
+{
+ Reference<XEventListener> xEvt;
+ ODatabaseImportExport* pImport = NULL;
+ if ( _rDesc.bHtml )
+ pImport = new OHTMLImportExport(_xConnection,getNumberFormatter(_xConnection,m_pController->getORB()),m_pController->getORB());
+ else
+ pImport = new ORTFImportExport(_xConnection,getNumberFormatter(_xConnection,m_pController->getORB()),m_pController->getORB());
+
+ xEvt = pImport;
+ SvStream* pStream = (SvStream*)(SotStorageStream*)_rDesc.aHtmlRtfStorage;
+ if ( _bCheck )
+ pImport->enableCheckOnly();
+
+ //set the selected tablename
+ pImport->setSTableName(_rDesc.sDefaultTableName);
+
+ pImport->setStream(pStream);
+ return pImport->Read();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::isTableFormat(const TransferableDataHelper& _rClipboard) const
+{
+ sal_Bool bTableFormat = _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE)
+ || _rClipboard.HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY)
+ || _rClipboard.HasFormat(SOT_FORMAT_RTF)
+ || _rClipboard.HasFormat(SOT_FORMATSTR_ID_HTML);
+
+ return bTableFormat;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedData
+ ,DropDescriptor& _rAsyncDrop
+ ,const SharedConnection& _xConnection)
+{
+ sal_Bool bRet = sal_False;
+ sal_Bool bHtml = _aDroppedData.HasFormat(SOT_FORMATSTR_ID_HTML);
+ if ( bHtml || _aDroppedData.HasFormat(SOT_FORMAT_RTF) )
+ {
+ if ( bHtml )
+ const_cast<TransferableDataHelper&>(_aDroppedData).GetSotStorageStream(SOT_FORMATSTR_ID_HTML ,_rAsyncDrop.aHtmlRtfStorage);
+ else
+ const_cast<TransferableDataHelper&>(_aDroppedData).GetSotStorageStream(SOT_FORMAT_RTF,_rAsyncDrop.aHtmlRtfStorage);
+
+ _rAsyncDrop.bHtml = bHtml;
+ _rAsyncDrop.bError = !copyTagTable(_rAsyncDrop,sal_True,_xConnection);
+
+ bRet = ( !_rAsyncDrop.bError && _rAsyncDrop.aHtmlRtfStorage.Is() );
+ if ( bRet )
+ {
+ // now we need to copy the stream
+ ::utl::TempFile aTmp;
+ aTmp.EnableKillingFile(sal_False);
+ _rAsyncDrop.aUrl = aTmp.GetURL();
+ SotStorageStreamRef aNew = new SotStorageStream( aTmp.GetFileName() );
+ _rAsyncDrop.aHtmlRtfStorage->Seek(STREAM_SEEK_TO_BEGIN);
+ _rAsyncDrop.aHtmlRtfStorage->CopyTo( aNew );
+ aNew->Commit();
+ _rAsyncDrop.aHtmlRtfStorage = aNew;
+ }
+ else
+ _rAsyncDrop.aHtmlRtfStorage = NULL;
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void OTableCopyHelper::asyncCopyTagTable( DropDescriptor& _rDesc
+ ,const ::rtl::OUString& i_rDestDataSource
+ ,const SharedConnection& _xConnection)
+{
+ if ( _rDesc.aHtmlRtfStorage.Is() )
+ {
+ copyTagTable(_rDesc,sal_False,_xConnection);
+ _rDesc.aHtmlRtfStorage = NULL;
+ // we now have to delete the temp file created in executeDrop
+ INetURLObject aURL;
+ aURL.SetURL(_rDesc.aUrl);
+ ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ }
+ else if ( !_rDesc.bError )
+ pasteTable(_rDesc.aDroppedData,i_rDestDataSource,_xConnection);
+ else
+ m_pController->showError(SQLException(String(ModuleRes(STR_NO_TABLE_FORMAT_INSIDE)),*m_pController,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),0,Any()));
+}
+// -----------------------------------------------------------------------------
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/TokenWriter.cxx b/dbaccess/source/ui/misc/TokenWriter.cxx
new file mode 100644
index 000000000000..ae08c7a38630
--- /dev/null
+++ b/dbaccess/source/ui/misc/TokenWriter.cxx
@@ -0,0 +1,1111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TokenWriter.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "RtfReader.hxx"
+#include "HtmlReader.hxx"
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <svtools/htmlkywd.hxx>
+#include <svtools/rtfkeywd.hxx>
+#include <tools/color.hxx>
+#include <svtools/htmlout.hxx>
+#include <sfx2/frmhtmlw.hxx>
+#include <svl/numuno.hxx>
+#include <vcl/svapp.hxx>
+#include "UITools.hxx"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/outdev.hxx>
+#include <svtools/rtfout.hxx>
+#include <svtools/htmlcfg.hxx>
+#include <connectivity/formattedcolumnvalue.hxx>
+#include <unotools/syslocale.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace dbaui;
+using namespace dbtools;
+using namespace svx;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::util;
+using ::com::sun::star::frame::XModel;
+
+#if defined(UNX)
+const char ODatabaseImportExport::sNewLine = '\012';
+#else
+const char ODatabaseImportExport::sNewLine[] = "\015\012";
+#endif
+
+const static char sMyBegComment[] = "<!-- ";
+const static char sMyEndComment[] = " -->";
+const static char sFontFamily[] = "font-family: ";
+const static char sFontSize[] = "font-size: ";
+
+#define SBA_FORMAT_SELECTION_COUNT 4
+#define CELL_X 1437
+
+DBG_NAME(ODatabaseImportExport)
+//======================================================================
+ODatabaseImportExport::ODatabaseImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange)
+ :m_bBookmarkSelection( sal_False )
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_nCommandType(CommandType::TABLE)
+ ,m_bNeedToReInitialize(sal_False)
+ ,m_pReader(NULL)
+ ,m_pRowMarker(NULL)
+ ,m_bInInitialize(sal_False)
+ ,m_bCheckOnly(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
+ DBG_CTOR(ODatabaseImportExport,NULL);
+
+ m_eDestEnc = osl_getThreadTextEncoding();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ impl_initFromDescriptor( _aDataDescriptor, false );
+
+ xub_StrLen nCount = rExchange.GetTokenCount(char(11));
+ if( nCount > SBA_FORMAT_SELECTION_COUNT && rExchange.GetToken(4).Len())
+ {
+ m_pRowMarker = new sal_Int32[nCount-SBA_FORMAT_SELECTION_COUNT];
+ for(xub_StrLen i=SBA_FORMAT_SELECTION_COUNT;i<nCount;++i)
+ m_pRowMarker[i-SBA_FORMAT_SELECTION_COUNT] = rExchange.GetToken(i,char(11)).ToInt32();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+// import data
+ODatabaseImportExport::ODatabaseImportExport( const ::dbtools::SharedConnection& _rxConnection,
+ const Reference< XNumberFormatter >& _rxNumberF, const Reference< XMultiServiceFactory >& _rM )
+ :m_bBookmarkSelection( sal_False )
+ ,m_xConnection(_rxConnection)
+ ,m_xFormatter(_rxNumberF)
+ ,m_xFactory(_rM)
+ ,m_nCommandType(::com::sun::star::sdb::CommandType::TABLE)
+ ,m_bNeedToReInitialize(sal_False)
+ ,m_pReader(NULL)
+ ,m_pRowMarker(NULL)
+ ,m_bInInitialize(sal_False)
+ ,m_bCheckOnly(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::ODatabaseImportExport" );
+ DBG_CTOR(ODatabaseImportExport,NULL);
+ m_eDestEnc = osl_getThreadTextEncoding();
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+}
+//-------------------------------------------------------------------
+ODatabaseImportExport::~ODatabaseImportExport()
+{
+ DBG_DTOR(ODatabaseImportExport,NULL);
+ acquire();
+
+ dispose();
+
+ if(m_pReader)
+ m_pReader->release();
+ delete m_pRowMarker;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::dispose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ // remove me as listener
+ Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->removeEventListener(xEvt);
+ }
+ m_xConnection.clear();
+
+ ::comphelper::disposeComponent(m_xRow);
+
+ m_xObject.clear();
+ m_xResultSetMetaData.clear();
+ m_xResultSet.clear();
+ m_xRow.clear();
+ m_xRowLocate.clear();
+ m_xFormatter.clear();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseImportExport::disposing( const EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::disposing" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if(m_xConnection.is() && m_xConnection == xCon)
+ {
+ m_xConnection.clear();
+ dispose();
+ m_bNeedToReInitialize = true;
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::initialize( const ODataAccessDescriptor& _aDataDescriptor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
+ impl_initFromDescriptor( _aDataDescriptor, true );
+}
+
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::impl_initFromDescriptor( const ODataAccessDescriptor& _aDataDescriptor, bool _bPlusDefaultInit)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initFromDescriptor" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ if ( !_bPlusDefaultInit )
+ {
+ m_sDataSourceName = _aDataDescriptor.getDataSource();
+ _aDataDescriptor[daCommandType] >>= m_nCommandType;
+ _aDataDescriptor[daCommand] >>= m_sName;
+ // some additonal information
+ if(_aDataDescriptor.has(daConnection))
+ {
+ Reference< XConnection > xPureConn( _aDataDescriptor[daConnection], UNO_QUERY );
+ m_xConnection.reset( xPureConn, SharedConnection::NoTakeOwnership );
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+ Reference< XComponent > xComponent(m_xConnection, UNO_QUERY);
+ if (xComponent.is() && xEvt.is())
+ xComponent->addEventListener(xEvt);
+ }
+
+ if ( _aDataDescriptor.has( daSelection ) )
+ _aDataDescriptor[ daSelection ] >>= m_aSelection;
+
+ if ( _aDataDescriptor.has( daBookmarkSelection ) )
+ _aDataDescriptor[ daBookmarkSelection ] >>= m_bBookmarkSelection;
+
+ if ( _aDataDescriptor.has( daCursor ) )
+ {
+ _aDataDescriptor[ daCursor ] >>= m_xResultSet;
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
+ }
+
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( !m_xResultSet.is() )
+ {
+ OSL_FAIL( "ODatabaseImportExport::impl_initFromDescriptor: selection without result set is nonsense!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
+
+ if ( m_aSelection.getLength() != 0 )
+ {
+ if ( m_bBookmarkSelection && !m_xRowLocate.is() )
+ {
+ OSL_FAIL( "ODatabaseImportExport::impl_initFromDescriptor: no XRowLocate -> no bookmars!" );
+ m_aSelection.realloc( 0 );
+ }
+ }
+ }
+ else
+ initialize();
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::initialize()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::initialize" );
+ DBG_CHKTHIS(ODatabaseImportExport,NULL);
+ m_bInInitialize = sal_True;
+ m_bNeedToReInitialize = false;
+
+ if ( !m_xConnection.is() )
+ { // we need a connection
+ OSL_ENSURE(m_sDataSourceName.getLength(),"There must be a datsource name!");
+ Reference<XNameAccess> xDatabaseContext = Reference< XNameAccess >(m_xFactory->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ Reference< XEventListener> xEvt((::cppu::OWeakObject*)this,UNO_QUERY);
+
+ Reference< XConnection > xConnection;
+ SQLExceptionInfo aInfo = ::dbaui::createConnection( m_sDataSourceName, xDatabaseContext, m_xFactory, xEvt, xConnection );
+ m_xConnection.reset( xConnection );
+
+ if(aInfo.isValid() && aInfo.getType() == SQLExceptionInfo::SQL_EXCEPTION)
+ throw *static_cast<const SQLException*>(aInfo);
+ }
+
+ Reference<XNameAccess> xNameAccess;
+ switch(m_nCommandType)
+ {
+ case CommandType::TABLE:
+ {
+ // only for tables
+ Reference<XTablesSupplier> xSup(m_xConnection,UNO_QUERY);
+ if(xSup.is())
+ xNameAccess = xSup->getTables();
+ }
+ break;
+ case CommandType::QUERY:
+ {
+ Reference<XQueriesSupplier> xSup(m_xConnection,UNO_QUERY);
+ if(xSup.is())
+ xNameAccess = xSup->getQueries();
+ }
+ break;
+ }
+ if(xNameAccess.is() && xNameAccess->hasByName(m_sName))
+ {
+ Reference<XPropertySet> xSourceObject;
+ xNameAccess->getByName(m_sName) >>= m_xObject;
+ }
+
+ if(m_xObject.is())
+ {
+ try
+ {
+ if(m_xObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_FONT))
+ m_xObject->getPropertyValue(PROPERTY_FONT) >>= m_aFont;
+
+ // the result set may be already set with the datadescriptor
+ if ( !m_xResultSet.is() )
+ {
+ m_xResultSet.set( m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RowSet")) ), UNO_QUERY );
+ Reference< XPropertySet > xProp( m_xResultSet, UNO_QUERY_THROW );
+ xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( m_xConnection.getTyped() ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND_TYPE, makeAny( m_nCommandType ) );
+ xProp->setPropertyValue( PROPERTY_COMMAND, makeAny( m_sName ) );
+ Reference< XRowSet > xRowSet( xProp, UNO_QUERY );
+ xRowSet->execute();
+ }
+ impl_initializeRowMember_throw();
+ }
+ catch(Exception& )
+ {
+ m_xRow = NULL;
+ m_xResultSetMetaData = NULL;
+ ::comphelper::disposeComponent(m_xResultSet);
+ throw;
+ }
+ }
+ if ( !m_aFont.Name.getLength() )
+ {
+ Font aApplicationFont = OutputDevice::GetDefaultFont(
+ DEFAULTFONT_SANS_UNICODE,
+ Application::GetSettings().GetUILanguage(),
+ DEFAULTFONT_FLAGS_ONLYONE
+ );
+ m_aFont = VCLUnoHelper::CreateFontDescriptor( aApplicationFont );
+ }
+
+ m_bInInitialize = sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseImportExport::Write()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODatabaseImportExport::Read()
+{
+ if ( m_bNeedToReInitialize )
+ {
+ if ( !m_bInInitialize )
+ initialize();
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODatabaseImportExport::impl_initializeRowMember_throw()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ODatabaseImportExport::impl_initializeRowMember_throw" );
+ if ( !m_xRow.is() && m_xResultSet.is() )
+ {
+ m_xRow.set( m_xResultSet, UNO_QUERY );
+ m_xRowLocate.set( m_xResultSet, UNO_QUERY );
+ m_xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(m_xRow,UNO_QUERY)->getMetaData();
+ Reference<XColumnsSupplier> xSup(m_xResultSet,UNO_QUERY_THROW);
+ m_xRowSetColumns.set(xSup->getColumns(),UNO_QUERY_THROW);
+ }
+}
+//======================================================================
+sal_Bool ORTFImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Write" );
+ ODatabaseImportExport::Write();
+ (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_RTF;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ANSI << ODatabaseImportExport::sNewLine;
+ rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252;
+
+ sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+
+ ByteString aFonts(String(m_aFont.Name),eDestEnc);
+ if(!aFonts.Len())
+ {
+ String aName = Application::GetSettings().GetStyleSettings().GetAppFont().GetName();
+ aFonts = ByteString (aName,eDestEnc);
+ }
+ ::rtl::OString aFormat("\\fcharset0\\fnil ");
+ ByteString aFontNr;
+
+ (*m_pStream) << "{\\fonttbl";
+ xub_StrLen nTokenCount = aFonts.GetTokenCount();
+ for(xub_StrLen j=0;j<nTokenCount;++j)
+ {
+ (*m_pStream) << "\\f";
+ m_pStream->WriteNumber(j);
+ (*m_pStream) << aFormat;
+ (*m_pStream) << aFonts.GetToken(j).GetBuffer();
+ (*m_pStream) << ';';
+ }
+ (*m_pStream) << '}' ;
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ // write the rtf color table
+ (*m_pStream) << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL << OOO_STRING_SVTOOLS_RTF_RED;
+ m_pStream->WriteNumber(aColor.GetRed());
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_GREEN;
+ m_pStream->WriteNumber(aColor.GetGreen());
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_BLUE;
+ m_pStream->WriteNumber(aColor.GetBlue());
+
+ (*m_pStream) << ";\\red255\\green255\\blue255;\\red192\\green192\\blue192;}"
+ << ODatabaseImportExport::sNewLine;
+
+ ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
+ ::rtl::OString aFS("\\fs20\\f0\\cf0\\cb2");
+ ::rtl::OString aCell1("\\clbrdrl\\brdrs\\brdrcf0\\clbrdrt\\brdrs\\brdrcf0\\clbrdrb\\brdrs\\brdrcf0\\clbrdrr\\brdrs\\brdrcf0\\clshdng10000\\clcfpat2\\cellx");
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
+ m_pStream->WriteNumber(40);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ if(m_xObject.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Sequence< ::rtl::OUString> aNames(xColumns->getElementNames());
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+
+ sal_Int32 nCount = aNames.getLength();
+ sal_Bool bUseResultMetaData = sal_False;
+ if ( !nCount )
+ {
+ nCount = m_xResultSetMetaData->getColumnCount();
+ bUseResultMetaData = sal_True;
+ }
+
+ for( sal_Int32 i=1; i<=nCount; ++i )
+ {
+ (*m_pStream) << aCell1;
+ m_pStream->WriteNumber(i*CELL_X);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ }
+
+ // Spaltenbeschreibung
+ (*m_pStream) << '{' << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << aTRRH;
+
+
+ ::rtl::OString* pHorzChar = new ::rtl::OString[nCount];
+
+ for ( sal_Int32 i=1; i <= nCount; ++i )
+ {
+ sal_Int32 nAlign = 0;
+ ::rtl::OUString sColumnName;
+ if ( bUseResultMetaData )
+ sColumnName = m_xResultSetMetaData->getColumnName(i);
+ else
+ {
+ sColumnName = *pIter;
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(sColumnName) >>= xColumn;
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+ ++pIter;
+ }
+
+ const char* pChar;
+ switch( nAlign )
+ {
+ case 1: pChar = OOO_STRING_SVTOOLS_RTF_QC; break;
+ case 2: pChar = OOO_STRING_SVTOOLS_RTF_QR; break;
+ case 0:
+ default:pChar = OOO_STRING_SVTOOLS_RTF_QL; break;
+ }
+
+ pHorzChar[i-1] = pChar; // um sp"ater nicht immer im ITEMSET zuw"uhlen
+
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '{';
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_QC; // column header always centered
+
+ if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
+ if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
+ if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
+ if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
+
+ (*m_pStream) << aFS;
+ (*m_pStream) << ' ';
+ RTFOutFuncs::Out_String(*m_pStream,sColumnName,eDestEnc);
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
+ (*m_pStream) << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ }
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW;
+ (*m_pStream) << ODatabaseImportExport::sNewLine << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+ sal_Int32 k=1;
+ sal_Int32 kk=0;
+ if ( m_aSelection.getLength() )
+ {
+ const Any* pSelIter = m_aSelection.getConstArray();
+ const Any* pEnd = pSelIter + m_aSelection.getLength();
+
+ sal_Bool bContinue = sal_True;
+ for( ; pSelIter != pEnd && bContinue; ++pSelIter )
+ {
+ if ( m_bBookmarkSelection )
+ {
+ bContinue = m_xRowLocate->moveToBookmark( *pSelIter );
+ }
+ else
+ {
+ sal_Int32 nPos = -1;
+ OSL_VERIFY( *pSelIter >>= nPos );
+ bContinue = ( m_xResultSet->absolute( nPos ) );
+ }
+
+ if ( bContinue )
+ appendRow( pHorzChar, nCount, k, kk );
+ }
+ }
+ else
+ {
+ m_xResultSet->beforeFirst(); // set back before the first row
+ while(m_xResultSet->next())
+ {
+ appendRow(pHorzChar,nCount,k,kk);
+ }
+ }
+ delete [] pHorzChar;
+ }
+
+ (*m_pStream) << '}' << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << (sal_uInt8) 0;
+ return ((*m_pStream).GetError() == SVSTREAM_OK);
+}
+// -----------------------------------------------------------------------------
+void ORTFImportExport::appendRow(::rtl::OString* pHorzChar,sal_Int32 _nColumnCount,sal_Int32& k,sal_Int32& kk)
+{
+ if(!m_pRowMarker || m_pRowMarker[kk] == k)
+ {
+ ++kk;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH;
+ m_pStream->WriteNumber(40);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+
+ static const ::rtl::OString aCell2("\\clbrdrl\\brdrs\\brdrcf2\\clbrdrt\\brdrs\\brdrcf2\\clbrdrb\\brdrs\\brdrcf2\\clbrdrr\\brdrs\\brdrcf2\\clshdng10000\\clcfpat1\\cellx");
+ static const ::rtl::OString aTRRH("\\trrh-270\\pard\\intbl");
+
+ for ( sal_Int32 i=1; i<=_nColumnCount; ++i )
+ {
+ (*m_pStream) << aCell2;
+ m_pStream->WriteNumber(i*CELL_X);
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ }
+
+ const sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ const sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ const sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ const sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+ static const ::rtl::OString aFS2("\\fs20\\f1\\cf0\\cb1");
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+
+ (*m_pStream) << '{';
+ (*m_pStream) << aTRRH;
+ for ( sal_Int32 i=1; i <= _nColumnCount; ++i )
+ {
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '{';
+ (*m_pStream) << pHorzChar[i-1];
+
+ if ( bBold ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_B;
+ if ( bItalic ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_I;
+ if ( bUnderline ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_UL;
+ if ( bStrikeout ) (*m_pStream) << OOO_STRING_SVTOOLS_RTF_STRIKE;
+
+ (*m_pStream) << aFS2;
+ (*m_pStream) << ' ';
+
+ try
+ {
+ Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
+ dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
+ ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
+ if ( sValue.getLength() )
+ RTFOutFuncs::Out_String(*m_pStream,sValue,m_eDestEnc);
+ }
+ catch (Exception&)
+ {
+ OSL_FAIL("RTF WRITE!");
+ }
+
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_CELL;
+ (*m_pStream) << '}';
+ (*m_pStream) << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ }
+ (*m_pStream) << OOO_STRING_SVTOOLS_RTF_ROW << ODatabaseImportExport::sNewLine;
+ (*m_pStream) << '}';
+ }
+ ++k;
+}
+//-------------------------------------------------------------------
+sal_Bool ORTFImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "ORTFImportExport::Read" );
+ ODatabaseImportExport::Read();
+ SvParserState eState = SVPAR_ERROR;
+ if ( m_pStream )
+ {
+ m_pReader = new ORTFReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
+ ((ORTFReader*)m_pReader)->AddRef();
+ if ( isCheckEnabled() )
+ m_pReader->enableCheckOnly();
+ eState = ((ORTFReader*)m_pReader)->CallParser();
+ m_pReader->release();
+ m_pReader = NULL;
+ }
+
+ return eState != SVPAR_ERROR;
+}
+//-------------------------------------------------------------------
+//===================================================================
+const sal_Int16 OHTMLImportExport::nDefaultFontSize[SBA_HTML_FONTSIZES] =
+{
+ HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT,
+ HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT
+};
+
+sal_Int16 OHTMLImportExport::nFontSize[SBA_HTML_FONTSIZES] = { 0 };
+
+const sal_Int16 OHTMLImportExport::nCellSpacing = 0;
+const char OHTMLImportExport::sIndentSource[nIndentMax+1] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
+
+//========================================================================
+// Macros for HTML-Export
+//========================================================================
+#define OUT_PROLOGUE() ((*m_pStream) << sHTML30_Prologue << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine)
+#define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag )
+#define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( (*m_pStream), tag, sal_False )
+#define OUT_STR( str ) HTMLOutFuncs::Out_String( (*m_pStream), str )
+#define OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine << GetIndentStr()
+#define lcl_OUT_LF() (*m_pStream) << ODatabaseImportExport::sNewLine
+#define TAG_ON_LF( tag ) (TAG_ON( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule )
+#define OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine << GetIndentStr())
+#define lcl_OUT_COMMENT( comment ) ((*m_pStream) << sMyBegComment, OUT_STR( comment ) << sMyEndComment << ODatabaseImportExport::sNewLine)
+
+//-------------------------------------------------------------------
+OHTMLImportExport::OHTMLImportExport(const ::svx::ODataAccessDescriptor& _aDataDescriptor,
+ const Reference< XMultiServiceFactory >& _rM,
+ const Reference< ::com::sun::star::util::XNumberFormatter >& _rxNumberF,
+ const String& rExchange)
+ : ODatabaseImportExport(_aDataDescriptor,_rM,_rxNumberF,rExchange)
+ ,m_nIndent(0)
+#if OSL_DEBUG_LEVEL > 0
+ ,m_bCheckFont(sal_False)
+#endif
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::OHTMLImportExport" );
+ // set HTML configuration
+ SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get();
+ m_eDestEnc = pHtmlOptions->GetTextEncoding();
+ strncpy( sIndent, sIndentSource ,std::min(sizeof(sIndent),sizeof(sIndentSource)));
+ sIndent[0] = 0;
+}
+//-------------------------------------------------------------------
+sal_Bool OHTMLImportExport::Write()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Write" );
+ ODatabaseImportExport::Write();
+ if(m_xObject.is())
+ {
+ (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_doctype << ' ' << OOO_STRING_SVTOOLS_HTML_doctype32 << '>' << ODatabaseImportExport::sNewLine << ODatabaseImportExport::sNewLine;
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
+ WriteHeader();
+ OUT_LF();
+ WriteBody();
+ OUT_LF();
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
+
+ return ((*m_pStream).GetError() == SVSTREAM_OK);
+ }
+ return sal_False;
+}
+//-------------------------------------------------------------------
+sal_Bool OHTMLImportExport::Read()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::Read" );
+ ODatabaseImportExport::Read();
+ SvParserState eState = SVPAR_ERROR;
+ if ( m_pStream )
+ {
+ m_pReader = new OHTMLReader((*m_pStream),m_xConnection,m_xFormatter,m_xFactory);
+ ((OHTMLReader*)m_pReader)->AddRef();
+ if ( isCheckEnabled() )
+ m_pReader->enableCheckOnly();
+ m_pReader->SetTableName(m_sDefaultTableName);
+ eState = ((OHTMLReader*)m_pReader)->CallParser();
+ m_pReader->release();
+ m_pReader = NULL;
+ }
+
+ return eState != SVPAR_ERROR;
+}
+//-------------------------------------------------------------------
+void OHTMLImportExport::WriteHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteHeader" );
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ m_xFactory->createInstance(::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.DocumentProperties"))),
+ uno::UNO_QUERY);
+ if (xDocProps.is()) {
+ xDocProps->setTitle(m_sName);
+ }
+
+ IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head );
+
+ SfxFrameHTMLWriter::Out_DocInfo( (*m_pStream), String(),
+ xDocProps, sIndent );
+ OUT_LF();
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteBody()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteBody" );
+
+ IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style );
+
+ (*m_pStream) << sMyBegComment; OUT_LF();
+ (*m_pStream) << OOO_STRING_SVTOOLS_HTML_body << " { " << sFontFamily << '\"' << ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(), gsl_getSystemTextEncoding()) << '\"';
+ // TODO : think about the encoding of the font name
+ (*m_pStream) << "; " << sFontSize;
+ m_pStream->WriteNumber(m_aFont.Height);
+ (*m_pStream) << '}';
+
+ OUT_LF();
+ (*m_pStream) << sMyEndComment;
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style );
+ OUT_LF();
+
+ // default Textcolour black
+ (*m_pStream) << '<' << OOO_STRING_SVTOOLS_HTML_body << ' ' << OOO_STRING_SVTOOLS_HTML_O_text << '=';
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+
+ ::rtl::OString sOut( ' ' );
+ sOut = sOut + OOO_STRING_SVTOOLS_HTML_O_bgcolor;
+ sOut = sOut + "=";
+ (*m_pStream) << sOut;
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+
+ (*m_pStream) << '>'; OUT_LF();
+
+ WriteTables();
+
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteTables" );
+ ::rtl::OString aStrOut = OOO_STRING_SVTOOLS_HTML_table;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_frame;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_TF_void;
+
+ Sequence< ::rtl::OUString> aNames;
+ Reference<XNameAccess> xColumns;
+ sal_Bool bUseResultMetaData = sal_False;
+ if(m_xObject.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xObject,UNO_QUERY);
+ xColumns = xColSup->getColumns();
+ aNames = xColumns->getElementNames();
+ if ( !aNames.getLength() )
+ {
+ sal_Int32 nCount = m_xResultSetMetaData->getColumnCount();
+ aNames.realloc(nCount);
+ for (sal_Int32 i= 0; i < nCount; ++i)
+ aNames[i] = m_xResultSetMetaData->getColumnName(i+1);
+ bUseResultMetaData = sal_True;
+ }
+ }
+
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_align;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_AL_left;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cellspacing;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + ::rtl::OString::valueOf((sal_Int32)nCellSpacing);
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_cols;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + ::rtl::OString::valueOf(aNames.getLength());
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_border;
+ aStrOut = aStrOut + "=1";
+
+ IncIndent(1);
+ TAG_ON( aStrOut );
+
+ FontOn();
+
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_caption );
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
+
+ (*m_pStream) << ::rtl::OString(m_sName,m_sName.getLength(), gsl_getSystemTextEncoding());
+ // TODO : think about the encoding of the name
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_caption );
+
+ FontOff();
+ OUT_LF();
+ // </FONT>
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+
+ if(m_xObject.is())
+ {
+ sal_Int32* pFormat = new sal_Int32[aNames.getLength()];
+
+ const char **pHorJustify = new const char*[aNames.getLength()];
+ sal_Int32 *pColWidth = new sal_Int32[aNames.getLength()];
+
+
+ sal_Int32 nHeight = 0;
+ m_xObject->getPropertyValue(PROPERTY_ROW_HEIGHT) >>= nHeight;
+
+ // 1. die Spaltenbeschreibung rauspusten
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+
+ for( sal_Int32 i=0;pIter != pEnd; ++pIter,++i )
+ {
+ sal_Int32 nAlign = 0;
+ pFormat[i] = 0;
+ pColWidth[i] = 100;
+ if ( !bUseResultMetaData )
+ {
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(*pIter) >>= xColumn;
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+ pFormat[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_FORMATKEY));
+ pColWidth[i] = ::comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_WIDTH));
+ }
+
+ switch( nAlign )
+ {
+ case 1: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_center; break;
+ case 2: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_right; break;
+ default: pHorJustify[i] = OOO_STRING_SVTOOLS_HTML_AL_left; break;
+ }
+
+ if(i == aNames.getLength()-1)
+ IncIndent(-1);
+
+ WriteCell(pFormat[i],pColWidth[i],nHeight,pHorJustify[i],*pIter,OOO_STRING_SVTOOLS_HTML_tableheader);
+ }
+
+ IncIndent(-1);
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+
+ // 2. und jetzt die Daten
+ ::comphelper::ComponentContext aContext(m_xFactory);
+ Reference< XRowSet > xRowSet(m_xRow,UNO_QUERY);
+ sal_Int32 j=1;
+ sal_Int32 kk=0;
+ m_xResultSet->beforeFirst(); // set back before the first row
+ while(m_xResultSet->next())
+ {
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+
+ if(!m_pRowMarker || m_pRowMarker[kk] == j)
+ {
+ ++kk;
+ for(sal_Int32 i=1;i<=aNames.getLength();++i)
+ {
+ if(i == aNames.getLength())
+ IncIndent(-1);
+
+ String aValue;
+ try
+ {
+ Reference<XPropertySet> xColumn(m_xRowSetColumns->getByIndex(i-1),UNO_QUERY_THROW);
+ dbtools::FormattedColumnValue aFormatedValue(aContext,xRowSet,xColumn);
+ ::rtl::OUString sValue = aFormatedValue.getFormattedValue();
+ if (sValue.getLength())
+ {
+ aValue = sValue;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ WriteCell(pFormat[i-1],pColWidth[i-1],nHeight,pHorJustify[i-1],aValue,OOO_STRING_SVTOOLS_HTML_tabledata);
+ }
+ }
+ ++j;
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ }
+
+ delete [] pFormat;
+ delete [] pHorJustify;
+ delete [] pColWidth;
+ }
+ else
+ {
+ IncIndent(-1);
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
+ TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_thead );
+
+ IncIndent(1);
+ TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ }
+
+ IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody );
+ IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::WriteCell( sal_Int32 nFormat,sal_Int32 nWidthPixel,sal_Int32 nHeightPixel,const char* pChar,
+ const String& rValue,const char* pHtmlTag)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::WriteCell" );
+ ::rtl::OString aStrTD = pHtmlTag;
+
+ nWidthPixel = nWidthPixel ? nWidthPixel : 86;
+ nHeightPixel = nHeightPixel ? nHeightPixel : 17;
+
+ // trotz der <TABLE COLS=n> und <COL WIDTH=x> Angaben noetig,
+ // da die nicht von Netscape beachtet werden..
+ // Spaltenbreite
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_width;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nWidthPixel);
+ // Zeilenhoehe
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_height;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + ::rtl::OString::valueOf((sal_Int32)nHeightPixel);
+
+ aStrTD = aStrTD + " ";
+ aStrTD = aStrTD + OOO_STRING_SVTOOLS_HTML_O_align;
+ aStrTD = aStrTD + "=";
+ aStrTD = aStrTD + pChar;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier();
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ SvNumberFormatter* pFormatter = pSupplierImpl ? pSupplierImpl->GetNumberFormatter() : NULL;
+ if(pFormatter)
+ {
+ double fVal = 0.0;
+
+ try
+ {
+ fVal = m_xFormatter->convertStringToNumber(nFormat,rValue);
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter );
+ }
+ catch(Exception&)
+ {
+ ByteString aTmpString(aStrTD);
+ HTMLOutFuncs::CreateTableDataOptionsValNum( aTmpString, sal_False, fVal,nFormat, *pFormatter );
+ }
+ }
+
+ TAG_ON( aStrTD );
+
+ FontOn();
+
+ sal_Bool bBold = ( ::com::sun::star::awt::FontWeight::BOLD == m_aFont.Weight );
+ sal_Bool bItalic = ( ::com::sun::star::awt::FontSlant_ITALIC == m_aFont.Slant );
+ sal_Bool bUnderline = ( ::com::sun::star::awt::FontUnderline::NONE != m_aFont.Underline );
+ sal_Bool bStrikeout = ( ::com::sun::star::awt::FontStrikeout::NONE != m_aFont.Strikeout );
+
+ if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
+ if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic );
+ if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline );
+ if ( bStrikeout ) TAG_ON( OOO_STRING_SVTOOLS_HTML_strike );
+
+ if ( !rValue.Len() )
+ TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // keine komplett leere Zelle
+ else
+ HTMLOutFuncs::Out_String( (*m_pStream), rValue ,m_eDestEnc);
+
+
+ if ( bStrikeout ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_strike );
+ if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
+ if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic );
+ if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
+
+ FontOff();
+
+ TAG_OFF_LF( pHtmlTag );
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::FontOn()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOn" );
+#if OSL_DEBUG_LEVEL > 0
+ m_bCheckFont = sal_True;
+#endif
+
+ // <FONT FACE="xxx">
+ ::rtl::OString aStrOut = "<";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_font;
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_face;
+ aStrOut = aStrOut + "=";
+ aStrOut = aStrOut + "\"";
+ aStrOut = aStrOut + ::rtl::OString(m_aFont.Name,m_aFont.Name.getLength(),gsl_getSystemTextEncoding());
+ // TODO : think about the encoding of the font name
+ aStrOut = aStrOut + "\"";
+ aStrOut = aStrOut + " ";
+ aStrOut = aStrOut + OOO_STRING_SVTOOLS_HTML_O_color;
+ aStrOut = aStrOut + "=";
+ (*m_pStream) << aStrOut;
+
+ sal_Int32 nColor = 0;
+ if(m_xObject.is())
+ m_xObject->getPropertyValue(PROPERTY_TEXTCOLOR) >>= nColor;
+ ::Color aColor(nColor);
+
+ HTMLOutFuncs::Out_Color( (*m_pStream), aColor );
+ (*m_pStream) << ">";
+}
+//-----------------------------------------------------------------------
+inline void OHTMLImportExport::FontOff()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::FontOff" );
+ OSL_ENSURE(m_bCheckFont,"Kein FontOn() gerufen");
+ TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
+#if OSL_DEBUG_LEVEL > 0
+ m_bCheckFont = sal_False;
+#endif
+}
+//-----------------------------------------------------------------------
+void OHTMLImportExport::IncIndent( sal_Int16 nVal )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OHTMLImportExport::IncIndent" );
+ sIndent[m_nIndent] = '\t';
+ m_nIndent = m_nIndent + nVal;
+ if ( m_nIndent < 0 )
+ m_nIndent = 0;
+ else if ( m_nIndent > nIndentMax )
+ m_nIndent = nIndentMax;
+ sIndent[m_nIndent] = 0;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/ToolBoxHelper.cxx b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
new file mode 100644
index 000000000000..4e9c5b6c565a
--- /dev/null
+++ b/dbaccess/source/ui/misc/ToolBoxHelper.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ToolBoxHelper.hxx"
+#include <vcl/toolbox.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/miscopt.hxx>
+#include "UITools.hxx"
+#include <svtools/imgdef.hxx>
+#include <vcl/event.hxx>
+
+namespace dbaui
+{
+ DBG_NAME(OToolBoxHelper)
+ OToolBoxHelper::OToolBoxHelper()
+ : m_nSymbolsSize(-1 )
+ , m_pToolBox(NULL)
+ {
+ DBG_CTOR(OToolBoxHelper,NULL);
+
+ OSL_ENSURE(m_nSymbolsSize != SvtMiscOptions().GetCurrentSymbolsSize(),"SymbolsSize should not be identical");
+ SvtMiscOptions().AddListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
+ Application::AddEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
+ }
+ // -----------------------------------------------------------------------------
+ OToolBoxHelper::~OToolBoxHelper()
+ {
+ SvtMiscOptions().RemoveListenerLink( LINK( this, OToolBoxHelper, ConfigOptionsChanged ) );
+ Application::RemoveEventListener( LINK( this, OToolBoxHelper, SettingsChanged ) );
+ DBG_DTOR(OToolBoxHelper,NULL);
+ }
+
+ // -----------------------------------------------------------------------------
+ void OToolBoxHelper::checkImageList()
+ {
+ if ( m_pToolBox )
+ {
+ sal_Int16 nCurSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
+ if ( nCurSymbolsSize != m_nSymbolsSize )
+ {
+ m_nSymbolsSize = nCurSymbolsSize;
+
+ m_pToolBox->SetImageList( getImageList(m_nSymbolsSize) );
+ Size aTbOldSize = m_pToolBox->GetSizePixel();
+ adjustToolBoxSize(m_pToolBox);
+ Size aTbNewSize = m_pToolBox->GetSizePixel();
+ resizeControls(Size(aTbNewSize.Width() - aTbOldSize.Width(),
+ aTbNewSize.Height() - aTbOldSize.Height())
+ );
+ }
+ }
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OToolBoxHelper, ConfigOptionsChanged, SvtMiscOptions*, /*_pOptions*/)
+ {
+ if ( m_pToolBox )
+ {
+ SvtMiscOptions aOptions;
+ // check if imagelist changed
+ checkImageList();
+ if ( aOptions.GetToolboxStyle() != m_pToolBox->GetOutStyle() )
+ m_pToolBox->SetOutStyle(aOptions.GetToolboxStyle());
+ }
+
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK(OToolBoxHelper, SettingsChanged, VclWindowEvent*, _pEvt)
+ {
+ if ( m_pToolBox && _pEvt && _pEvt->GetId() == VCLEVENT_APPLICATION_DATACHANGED )
+ {
+ DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData());
+ if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) ||
+ ( pData->GetType() == DATACHANGED_DISPLAY )) &&
+ ( pData->GetFlags() & SETTINGS_STYLE )))
+ // check if imagelist changed
+ checkImageList();
+ }
+
+ return 0L;
+ }
+ // -----------------------------------------------------------------------------
+ void OToolBoxHelper::setToolBox(ToolBox* _pTB)
+ {
+ sal_Bool bFirstTime = (m_pToolBox == NULL);
+ m_pToolBox = _pTB;
+ if ( m_pToolBox )
+ {
+ ConfigOptionsChanged(NULL);
+ if ( bFirstTime )
+ adjustToolBoxSize(m_pToolBox);
+ }
+ }
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
new file mode 100644
index 000000000000..a89699c002a3
--- /dev/null
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -0,0 +1,1697 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "UITools.hxx"
+#include <sfx2/docfilt.hxx>
+#include "callbacks.hxx"
+#include "dbustrings.hrc"
+#include "dbu_resource.hrc"
+#include "dlgsave.hxx"
+#include "dbtreelistbox.hxx"
+#include "defaultobjectnamecheck.hxx"
+#include <comphelper/extract.hxx>
+#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/ucb/InteractiveIOException.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <vcl/stdtext.hxx>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontRelief.hpp>
+#include <com/sun/star/awt/FontWidth.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include "dlgattr.hrc"
+#include "TypeInfo.hxx"
+#include "FieldDescriptions.hxx"
+#include <comphelper/stl_types.hxx>
+#include <comphelper/componentcontext.hxx>
+
+#include <svx/svxids.hrc>
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+#define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO
+
+#include <svl/itempool.hxx>
+#include <tools/string.hxx>
+#include "dbaccess_helpid.hrc"
+#include <svl/itemset.hxx>
+#include "sbagrid.hrc"
+#include <svl/rngitem.hxx>
+#include <svl/intitem.hxx>
+#include <svx/algitem.hxx>
+#include <svx/numinf.hxx>
+#define _ZFORLIST_DECLARE_TABLE
+#include <svx/numinf.hxx>
+#include <svl/zforlist.hxx>
+#include "dlgattr.hxx"
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include "dbu_misc.hrc"
+#include "sqlmessage.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <vcl/toolbox.hxx>
+#include "dlgsize.hxx"
+#include <svtools/editbrowsebox.hxx>
+#include <unotools/configmgr.hxx>
+#include <svtools/helpopt.hxx>
+#include <ucbhelper/content.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <svl/numuno.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/filenotation.hxx>
+#include <svtools/fileview.hxx>
+#include <connectivity/FValue.hxx>
+
+#include <editeng/justifyitem.hxx>
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+using namespace ::dbtools;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::svt;
+using ::com::sun::star::ucb::InteractiveIOException;
+using ::com::sun::star::ucb::IOErrorCode_NO_FILE;
+using ::com::sun::star::ucb::IOErrorCode_NOT_EXISTING;
+using ::com::sun::star::frame::XModel;
+
+// -----------------------------------------------------------------------------
+SQLExceptionInfo createConnection( const ::rtl::OUString& _rsDataSourceName,
+ const Reference< ::com::sun::star::container::XNameAccess >& _xDatabaseContext,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
+{
+ Reference<XPropertySet> xProp;
+ try
+ {
+ xProp.set(_xDatabaseContext->getByName(_rsDataSourceName),UNO_QUERY);
+ }
+ catch(Exception&)
+ {
+ }
+ SQLExceptionInfo aInfo;
+
+ return createConnection(xProp,_rMF,_rEvtLst,_rOUTConnection);
+}
+// -----------------------------------------------------------------------------
+SQLExceptionInfo createConnection( const Reference< ::com::sun::star::beans::XPropertySet>& _xDataSource,
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF,
+ Reference< ::com::sun::star::lang::XEventListener>& _rEvtLst,
+ Reference< ::com::sun::star::sdbc::XConnection>& _rOUTConnection )
+{
+ SQLExceptionInfo aInfo;
+ if ( !_xDataSource.is() )
+ {
+ OSL_FAIL("createConnection: coult not retrieve the data source!");
+ return aInfo;
+ }
+
+ ::rtl::OUString sPwd, sUser;
+ sal_Bool bPwdReq = sal_False;
+ try
+ {
+ _xDataSource->getPropertyValue(PROPERTY_PASSWORD) >>= sPwd;
+ bPwdReq = ::cppu::any2bool(_xDataSource->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED));
+ _xDataSource->getPropertyValue(PROPERTY_USER) >>= sUser;
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("createConnection: error while retrieving data source properties!");
+ }
+
+
+ try
+ {
+ if(bPwdReq && !sPwd.getLength())
+ { // password required, but empty -> connect using an interaction handler
+ Reference<XCompletedConnection> xConnectionCompletion(_xDataSource, UNO_QUERY);
+ if (!xConnectionCompletion.is())
+ {
+ OSL_FAIL("createConnection: missing an interface ... need an error message here!");
+ }
+ else
+ { // instantiate the default SDB interaction handler
+ Reference< XInteractionHandler > xHandler(_rMF->createInstance(SERVICE_TASK_INTERACTION_HANDLER), UNO_QUERY);
+ if (!xHandler.is())
+ {
+ OSL_FAIL("createConnection: could not instantiate an interaction handler!");
+ // TODO: a real parent!
+ }
+ else
+ _rOUTConnection = xConnectionCompletion->connectWithCompletion(xHandler);
+ }
+ }
+ else
+ {
+ Reference<XDataSource> xDataSource(_xDataSource,UNO_QUERY);
+ _rOUTConnection = xDataSource->getConnection(sUser, sPwd);
+ }
+ // be notified when connection is in disposing
+ Reference< XComponent > xComponent(_rOUTConnection, UNO_QUERY);
+ if (xComponent.is() && _rEvtLst.is())
+ xComponent->addEventListener(_rEvtLst);
+ }
+ catch(SQLContext& e) { aInfo = SQLExceptionInfo(e); }
+ catch(SQLWarning& e) { aInfo = SQLExceptionInfo(e); }
+ catch(SQLException& e) { aInfo = SQLExceptionInfo(e); }
+ catch(Exception&) { OSL_FAIL("SbaTableQueryBrowser::OnExpandEntry: could not connect - unknown exception!"); }
+
+ return aInfo;
+}
+// -----------------------------------------------------------------------------
+Reference< XDataSource > getDataSourceByName( const ::rtl::OUString& _rDataSourceName,
+ Window* _pErrorMessageParent, Reference< XMultiServiceFactory > _rxORB, ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ ::comphelper::ComponentContext aContext( _rxORB );
+ Reference< XNameAccess > xDatabaseContext( aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+
+ Reference< XDataSource > xDatasource;
+ Any aError;
+ SQLExceptionInfo aSQLError;
+ try
+ {
+ xDatabaseContext->getByName( _rDataSourceName ) >>= xDatasource;
+ }
+ catch(const WrappedTargetException& e)
+ {
+ InteractiveIOException aIOException;
+ if ( ( e.TargetException >>= aIOException )
+ && ( ( aIOException.Code == IOErrorCode_NO_FILE )
+ || ( aIOException.Code == IOErrorCode_NOT_EXISTING )
+ )
+ )
+ {
+ String sErrorMessage = String( ModuleRes( STR_FILE_DOES_NOT_EXIST ) );
+ OFileNotation aTransformer( e.Message );
+ sErrorMessage.SearchAndReplaceAscii( "$file$", aTransformer.get( OFileNotation::N_SYSTEM ) );
+ aSQLError = SQLExceptionInfo( sErrorMessage ).get();
+ }
+ else
+ {
+ aSQLError = SQLExceptionInfo( e.TargetException );
+ if ( !aSQLError.isValid() )
+ aError = e.TargetException;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( xDatasource.is() )
+ return xDatasource;
+
+ if ( aSQLError.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aSQLError;
+ }
+ else
+ {
+ showError( aSQLError, _pErrorMessageParent, _rxORB );
+ }
+ }
+
+ return Reference<XDataSource>();
+}
+// -----------------------------------------------------------------------------
+Reference< XInterface > getDataSourceOrModel(const Reference< XInterface >& _xObject)
+{
+ Reference< XInterface > xRet;
+ Reference<XDocumentDataSource> xDocumentDataSource(_xObject,UNO_QUERY);
+ if ( xDocumentDataSource.is() )
+ xRet = xDocumentDataSource->getDatabaseDocument();
+
+ if ( !xRet.is() )
+ {
+ Reference<XOfficeDatabaseDocument> xOfficeDoc(_xObject,UNO_QUERY);
+ if ( xOfficeDoc.is() )
+ xRet = xOfficeDoc->getDataSource();
+ }
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+void showError(const SQLExceptionInfo& _rInfo,Window* _pParent,const Reference< XMultiServiceFactory >& _xFactory)
+{
+ OSL_ENSURE(_pParent,"showError: Parent window must be NOT NULL!");
+ ::dbtools::showError(_rInfo,VCLUnoHelper::GetInterface(_pParent),_xFactory);
+}
+
+// -----------------------------------------------------------------------------
+::std::vector< Reference<XNameAccess> > getKeyColumns(const Reference<XIndexAccess >& _rxKeys,
+ sal_Int32 _nKeyType)
+{
+ // use keys and indexes for excat postioning
+ // first the keys
+ ::std::vector< Reference<XNameAccess> > vRet;
+ if(_rxKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ for(sal_Int32 i=0;i< _rxKeys->getCount();++i)
+ {
+ _rxKeys->getByIndex(i) >>= xProp;
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(_nKeyType == nKeyType)
+ {
+ Reference<XColumnsSupplier> xKeyColsSup(xProp,UNO_QUERY);
+ OSL_ENSURE(xKeyColsSup.is(),"Columnsupplier is null!");
+ vRet.push_back(xKeyColsSup->getColumns());
+ }
+ }
+ }
+
+ return vRet;
+}
+// -----------------------------------------------------------------------------
+
+TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ sal_Int32 _nType,
+ const ::rtl::OUString& _sTypeName,
+ const ::rtl::OUString& _sCreateParams,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool _bAutoIncrement,
+ sal_Bool& _brForceToType)
+{
+ TOTypeInfoSP pTypeInfo;
+ _brForceToType = sal_False;
+ // search for type
+ ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
+ OTypeInfoMap::const_iterator aIter = aPair.first;
+ if(aIter != _rTypeInfo.end()) // compare with end is correct here
+ {
+ for(;aIter != aPair.second;++aIter)
+ {
+ // search the best matching type
+ #ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName; (void)sDBTypeName;
+ sal_Int32 nDBTypePrecision = aIter->second->nPrecision; (void)nDBTypePrecision;
+ sal_Int32 nDBTypeScale = aIter->second->nMaximumScale; (void)nDBTypeScale;
+ sal_Bool bDBAutoIncrement = aIter->second->bAutoIncrement; (void)bDBAutoIncrement;
+ #endif
+ if ( (
+ !_sTypeName.getLength()
+ || (aIter->second->aTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ )
+ && (
+ (
+ !aIter->second->aCreateParams.getLength()
+ && !_sCreateParams.getLength()
+ )
+ || (
+ (aIter->second->nPrecision >= _nPrecision)
+ && (aIter->second->nMaximumScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ )
+ )
+ break;
+ }
+
+ if (aIter == aPair.second)
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ sal_Int32 nPrec = aIter->second->nPrecision;
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ // search the best matching type (now comparing the local names)
+ if ( (aIter->second->aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ && (nPrec >= _nPrecision)
+ && (nScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ {
+ OSL_FAIL(( ::rtl::OString("getTypeInfoFromType: assuming column type ")
+ += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString("\" (expected type name ")
+ += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString(" matches the type's local name).")).getStr());
+ break;
+ }
+ }
+ }
+
+ if (aIter == aPair.second)
+ { // no match for the names, no match for the local names
+ // -> drop the precision and the scale restriction, accept any type with the property
+ // type id (nType)
+
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+#ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
+#endif
+ sal_Int32 nPrec = aIter->second->nPrecision;
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ if ( (nPrec >= _nPrecision)
+ && (nScale >= _nScale)
+ && ( (_bAutoIncrement && aIter->second->bAutoIncrement) || !_bAutoIncrement )
+ )
+ break;
+ }
+ }
+ if (aIter == aPair.second)
+ {
+ if ( _bAutoIncrement )
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+#ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = aIter->second->aTypeName;
+#endif
+ sal_Int32 nScale = aIter->second->nMaximumScale;
+ if ( (nScale >= _nScale)
+ && (aIter->second->bAutoIncrement == _bAutoIncrement)
+ )
+ break;
+ }
+ if ( aIter == aPair.second )
+ {
+ // try it without the auto increment flag
+ pTypeInfo = getTypeInfoFromType(_rTypeInfo,
+ _nType,
+ _sTypeName,
+ _sCreateParams,
+ _nPrecision,
+ _nScale,
+ sal_False,
+ _brForceToType);
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else
+ {
+ pTypeInfo = aPair.first->second;
+ _brForceToType = sal_True;
+ }
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else
+ {
+ ::comphelper::TStringMixEqualFunctor aCase(sal_False);
+ // search for typeinfo where the typename is equal _sTypeName
+ OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin();
+ OTypeInfoMap::const_iterator typeInfoEnd = _rTypeInfo.end();
+ for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop)
+ {
+ if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) )
+ {
+ pTypeInfo = typeInfoLoop->second;
+ break;
+ }
+ }
+ }
+
+ OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxConnection,
+ const String& _rsTypeNames,
+ OTypeInfoMap& _rTypeInfoMap,
+ ::std::vector<OTypeInfoMap::iterator>& _rTypeInfoIters)
+{
+ if(!_rxConnection.is())
+ return;
+ Reference< XResultSet> xRs = _rxConnection->getMetaData ()->getTypeInfo ();
+ Reference< XRow> xRow(xRs,UNO_QUERY);
+ // Information for a single SQL type
+ if(xRs.is())
+ {
+ static const ::rtl::OUString aB1(RTL_CONSTASCII_USTRINGPARAM(" [ "));
+ static const ::rtl::OUString aB2(RTL_CONSTASCII_USTRINGPARAM(" ]"));
+ Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
+ ::connectivity::ORowSetValue aValue;
+ ::std::vector<sal_Int32> aTypes;
+ ::std::vector<sal_Bool> aNullable;
+ // Loop on the result set until we reach end of file
+ while (xRs->next())
+ {
+ TOTypeInfoSP pInfo(new OTypeInfo());
+ sal_Int32 nPos = 1;
+ if ( aTypes.empty() )
+ {
+ sal_Int32 nCount = xResultSetMetaData->getColumnCount();
+ if ( nCount < 1 )
+ nCount = 18;
+ aTypes.reserve(nCount+1);
+ aTypes.push_back(-1);
+ aNullable.push_back(sal_False);
+ for (sal_Int32 j = 1; j <= nCount ; ++j)
+ {
+ aTypes.push_back(xResultSetMetaData->getColumnType(j));
+ aNullable.push_back(xResultSetMetaData->isNullable(j) != ColumnValue::NO_NULLS);
+ }
+ }
+
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nPrecision = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLiteralPrefix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLiteralSuffix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aCreateParams = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bCaseSensitive = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nSearchType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bUnsigned = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bCurrency = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->bAutoIncrement = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->aLocalTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nMinimumScale = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+ pInfo->nMaximumScale = aValue;
+ nPos = 18;
+ aValue.fill(nPos,aTypes[nPos],aNullable[nPos],xRow);
+
+ // check if values are less than zero like it happens in a oracle jdbc driver
+ if( pInfo->nPrecision < 0)
+ pInfo->nPrecision = 0;
+ if( pInfo->nMinimumScale < 0)
+ pInfo->nMinimumScale = 0;
+ if( pInfo->nMaximumScale < 0)
+ pInfo->nMaximumScale = 0;
+
+ String aName;
+ switch(pInfo->nType)
+ {
+ case DataType::CHAR:
+ aName = _rsTypeNames.GetToken(TYPE_CHAR);
+ break;
+ case DataType::VARCHAR:
+ aName = _rsTypeNames.GetToken(TYPE_TEXT);
+ break;
+ case DataType::DECIMAL:
+ aName = _rsTypeNames.GetToken(TYPE_DECIMAL);
+ break;
+ case DataType::NUMERIC:
+ aName = _rsTypeNames.GetToken(TYPE_NUMERIC);
+ break;
+ case DataType::BIGINT:
+ aName = _rsTypeNames.GetToken(TYPE_BIGINT);
+ break;
+ case DataType::FLOAT:
+ aName = _rsTypeNames.GetToken(TYPE_FLOAT);
+ break;
+ case DataType::DOUBLE:
+ aName = _rsTypeNames.GetToken(TYPE_DOUBLE);
+ break;
+ case DataType::LONGVARCHAR:
+ aName = _rsTypeNames.GetToken(TYPE_MEMO);
+ break;
+ case DataType::LONGVARBINARY:
+ aName = _rsTypeNames.GetToken(TYPE_IMAGE);
+ break;
+ case DataType::DATE:
+ aName = _rsTypeNames.GetToken(TYPE_DATE);
+ break;
+ case DataType::TIME:
+ aName = _rsTypeNames.GetToken(TYPE_TIME);
+ break;
+ case DataType::TIMESTAMP:
+ aName = _rsTypeNames.GetToken(TYPE_DATETIME);
+ break;
+ case DataType::BIT:
+ if ( pInfo->aCreateParams.getLength() )
+ {
+ aName = _rsTypeNames.GetToken(TYPE_BIT);
+ break;
+ }
+ // run through
+ case DataType::BOOLEAN:
+ aName = _rsTypeNames.GetToken(TYPE_BOOL);
+ break;
+ case DataType::TINYINT:
+ aName = _rsTypeNames.GetToken(TYPE_TINYINT);
+ break;
+ case DataType::SMALLINT:
+ aName = _rsTypeNames.GetToken(TYPE_SMALLINT);
+ break;
+ case DataType::INTEGER:
+ aName = _rsTypeNames.GetToken(TYPE_INTEGER);
+ break;
+ case DataType::REAL:
+ aName = _rsTypeNames.GetToken(TYPE_REAL);
+ break;
+ case DataType::BINARY:
+ aName = _rsTypeNames.GetToken(TYPE_BINARY);
+ break;
+ case DataType::VARBINARY:
+ aName = _rsTypeNames.GetToken(TYPE_VARBINARY);
+ break;
+ case DataType::SQLNULL:
+ aName = _rsTypeNames.GetToken(TYPE_SQLNULL);
+ break;
+ case DataType::OBJECT:
+ aName = _rsTypeNames.GetToken(TYPE_OBJECT);
+ break;
+ case DataType::DISTINCT:
+ aName = _rsTypeNames.GetToken(TYPE_DISTINCT);
+ break;
+ case DataType::STRUCT:
+ aName = _rsTypeNames.GetToken(TYPE_STRUCT);
+ break;
+ case DataType::ARRAY:
+ aName = _rsTypeNames.GetToken(TYPE_ARRAY);
+ break;
+ case DataType::BLOB:
+ aName = _rsTypeNames.GetToken(TYPE_BLOB);
+ break;
+ case DataType::CLOB:
+ aName = _rsTypeNames.GetToken(TYPE_CLOB);
+ break;
+ case DataType::REF:
+ aName = _rsTypeNames.GetToken(TYPE_REF);
+ break;
+ case DataType::OTHER:
+ aName = _rsTypeNames.GetToken(TYPE_OTHER);
+ break;
+ }
+ if ( aName.Len() )
+ {
+ pInfo->aUIName = aName.GetBuffer();
+ pInfo->aUIName += aB1;
+ }
+ pInfo->aUIName += pInfo->aTypeName;
+ if ( aName.Len() )
+ pInfo->aUIName += aB2;
+ // Now that we have the type info, save it in the multimap
+ _rTypeInfoMap.insert(OTypeInfoMap::value_type(pInfo->nType,pInfo));
+ }
+ // for a faster index access
+ _rTypeInfoIters.reserve(_rTypeInfoMap.size());
+
+ OTypeInfoMap::iterator aIter = _rTypeInfoMap.begin();
+ OTypeInfoMap::iterator aEnd = _rTypeInfoMap.end();
+ for(;aIter != aEnd;++aIter)
+ _rTypeInfoIters.push_back(aIter);
+
+ // Close the result set/statement.
+
+ ::comphelper::disposeComponent(xRs);
+ }
+}
+// -----------------------------------------------------------------------------
+void setColumnProperties(const Reference<XPropertySet>& _rxColumn,const OFieldDescription* _pFieldDesc)
+{
+ _rxColumn->setPropertyValue(PROPERTY_NAME,makeAny(_pFieldDesc->GetName()));
+ _rxColumn->setPropertyValue(PROPERTY_TYPENAME,makeAny(_pFieldDesc->getTypeInfo()->aTypeName));
+ _rxColumn->setPropertyValue(PROPERTY_TYPE,makeAny(_pFieldDesc->GetType()));
+ _rxColumn->setPropertyValue(PROPERTY_PRECISION,makeAny(_pFieldDesc->GetPrecision()));
+ _rxColumn->setPropertyValue(PROPERTY_SCALE,makeAny(_pFieldDesc->GetScale()));
+ _rxColumn->setPropertyValue(PROPERTY_ISNULLABLE, makeAny(_pFieldDesc->GetIsNullable()));
+ _rxColumn->setPropertyValue(PROPERTY_ISAUTOINCREMENT,::cppu::bool2any(_pFieldDesc->IsAutoIncrement()));
+ _rxColumn->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_pFieldDesc->GetDescription()));
+ if ( _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ISCURRENCY) && _pFieldDesc->IsCurrency() )
+ _rxColumn->setPropertyValue(PROPERTY_ISCURRENCY,::cppu::bool2any(_pFieldDesc->IsCurrency()));
+ // set autoincrement value when available
+ // and only set when the entry is not empty, that lets the value in the column untouched
+ if ( _pFieldDesc->IsAutoIncrement() && _pFieldDesc->GetAutoIncrementValue().getLength() && _rxColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ _rxColumn->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_pFieldDesc->GetAutoIncrementValue()));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString createDefaultName(const Reference< XDatabaseMetaData>& _xMetaData,const Reference<XNameAccess>& _xTables,const ::rtl::OUString& _sName)
+{
+ OSL_ENSURE(_xMetaData.is(),"No MetaData!");
+ ::rtl::OUString sDefaultName = _sName;
+ try
+ {
+ ::rtl::OUString sCatalog,sSchema,sCompsedName;
+ if(_xMetaData->supportsCatalogsInTableDefinitions())
+ {
+ try
+ {
+ Reference< XConnection> xCon = _xMetaData->getConnection();
+ if ( xCon.is() )
+ sCatalog = xCon->getCatalog();
+ if ( !sCatalog.getLength() )
+ {
+ Reference<XResultSet> xRes = _xMetaData->getCatalogs();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while(xRes.is() && xRes->next())
+ {
+ sCatalog = xRow->getString(1);
+ if(!xRow->wasNull())
+ break;
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+ }
+ if(_xMetaData->supportsSchemasInTableDefinitions())
+ {
+ sSchema = _xMetaData->getUserName();
+ }
+ sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, sal_False, ::dbtools::eInDataManipulation );
+ sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName);
+ }
+ catch(const SQLException&)
+ {
+ }
+ return sDefaultName;
+}
+// -----------------------------------------------------------------------------
+sal_Bool checkDataSourceAvailable(const ::rtl::OUString& _sDataSourceName,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
+{
+ sal_Bool bRet = sal_False;
+ Reference< XNameAccess > xDataBaseContext(_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT), UNO_QUERY);
+ if ( xDataBaseContext.is() )
+ {
+ bRet = xDataBaseContext->hasByName(_sDataSourceName);
+ if ( !bRet )
+ { // try if this one is a URL
+ try
+ {
+ bRet = xDataBaseContext->getByName(_sDataSourceName).hasValue();
+ }
+ catch(Exception)
+ {
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 mapTextAllign(const SvxCellHorJustify& _eAlignment)
+{
+ sal_Int32 nAlignment = com::sun::star::awt::TextAlign::LEFT;
+ switch (_eAlignment)
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ case SVX_HOR_JUSTIFY_LEFT: nAlignment = ::com::sun::star::awt::TextAlign::LEFT; break;
+ case SVX_HOR_JUSTIFY_CENTER: nAlignment = ::com::sun::star::awt::TextAlign::CENTER; break;
+ case SVX_HOR_JUSTIFY_RIGHT: nAlignment = ::com::sun::star::awt::TextAlign::RIGHT; break;
+ default:
+ OSL_FAIL("Invalid TextAlign!");
+ }
+ return nAlignment;
+}
+// -----------------------------------------------------------------------------
+SvxCellHorJustify mapTextJustify(const sal_Int32& _nAlignment)
+{
+ SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_LEFT;
+ switch (_nAlignment)
+ {
+ case ::com::sun::star::awt::TextAlign::LEFT : eJustify = SVX_HOR_JUSTIFY_LEFT; break;
+ case ::com::sun::star::awt::TextAlign::CENTER : eJustify = SVX_HOR_JUSTIFY_CENTER; break;
+ case ::com::sun::star::awt::TextAlign::RIGHT : eJustify = SVX_HOR_JUSTIFY_RIGHT; break;
+ default:
+ OSL_FAIL("Invalid TextAlign!");
+ }
+ return eJustify;
+}
+// -----------------------------------------------------------------------------
+float ConvertFontWeight( ::FontWeight eWeight )
+{
+ if( eWeight == WEIGHT_DONTKNOW )
+ return ::com::sun::star::awt::FontWeight::DONTKNOW;
+ else if( eWeight == WEIGHT_THIN )
+ return ::com::sun::star::awt::FontWeight::THIN;
+ else if( eWeight == WEIGHT_ULTRALIGHT )
+ return ::com::sun::star::awt::FontWeight::ULTRALIGHT;
+ else if( eWeight == WEIGHT_LIGHT )
+ return ::com::sun::star::awt::FontWeight::LIGHT;
+ else if( eWeight == WEIGHT_SEMILIGHT )
+ return ::com::sun::star::awt::FontWeight::SEMILIGHT;
+ else if( ( eWeight == WEIGHT_NORMAL ) || ( eWeight == WEIGHT_MEDIUM ) )
+ return ::com::sun::star::awt::FontWeight::NORMAL;
+ else if( eWeight == WEIGHT_SEMIBOLD )
+ return ::com::sun::star::awt::FontWeight::SEMIBOLD;
+ else if( eWeight == WEIGHT_BOLD )
+ return ::com::sun::star::awt::FontWeight::BOLD;
+ else if( eWeight == WEIGHT_ULTRABOLD )
+ return ::com::sun::star::awt::FontWeight::ULTRABOLD;
+ else if( eWeight == WEIGHT_BLACK )
+ return ::com::sun::star::awt::FontWeight::BLACK;
+
+ OSL_FAIL("Unknown FontWeigth" );
+ return ::com::sun::star::awt::FontWeight::DONTKNOW;
+}
+// -----------------------------------------------------------------------------
+float ConvertFontWidth( ::FontWidth eWidth )
+{
+ if( eWidth == WIDTH_DONTKNOW )
+ return ::com::sun::star::awt::FontWidth::DONTKNOW;
+ else if( eWidth == WIDTH_ULTRA_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::ULTRACONDENSED;
+ else if( eWidth == WIDTH_EXTRA_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::EXTRACONDENSED;
+ else if( eWidth == WIDTH_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::CONDENSED;
+ else if( eWidth == WIDTH_SEMI_CONDENSED )
+ return ::com::sun::star::awt::FontWidth::SEMICONDENSED;
+ else if( eWidth == WIDTH_NORMAL )
+ return ::com::sun::star::awt::FontWidth::NORMAL;
+ else if( eWidth == WIDTH_SEMI_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::SEMIEXPANDED;
+ else if( eWidth == WIDTH_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::EXPANDED;
+ else if( eWidth == WIDTH_EXTRA_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::EXTRAEXPANDED;
+ else if( eWidth == WIDTH_ULTRA_EXPANDED )
+ return ::com::sun::star::awt::FontWidth::ULTRAEXPANDED;
+
+ OSL_FAIL("Unknown FontWidth" );
+ return ::com::sun::star::awt::FontWidth::DONTKNOW;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::awt::FontDescriptor CreateFontDescriptor( const Font& rFont )
+{
+ ::com::sun::star::awt::FontDescriptor aFD;
+ aFD.Name = rFont.GetName();
+ aFD.StyleName = rFont.GetStyleName();
+ aFD.Height = (sal_Int16)rFont.GetSize().Height();
+ aFD.Width = (sal_Int16)rFont.GetSize().Width();
+ aFD.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamily());
+ aFD.CharSet = rFont.GetCharSet();
+ aFD.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
+ aFD.CharacterWidth = ConvertFontWidth( rFont.GetWidthType() );
+ aFD.Weight = ConvertFontWeight( rFont.GetWeight() );
+ aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
+ aFD.Underline = sal::static_int_cast< sal_Int16 >(
+ rFont.GetUnderline());
+ aFD.Strikeout = sal::static_int_cast< sal_Int16 >(
+ rFont.GetStrikeout());
+ aFD.Orientation = rFont.GetOrientation();
+ aFD.Kerning = rFont.IsKerning();
+ aFD.WordLineMode = rFont.IsWordLineMode();
+ aFD.Type = 0; // ??? => Nur an Metric...
+ return aFD;
+}
+// -----------------------------------------------------------------------------
+void callColumnFormatDialog(const Reference<XPropertySet>& xAffectedCol,
+ const Reference<XPropertySet>& xField,
+ SvNumberFormatter* _pFormatter,
+ Window* _pParent)
+{
+ if (xAffectedCol.is() && xField.is())
+ {
+ try
+ {
+ Reference< XPropertySetInfo > xInfo = xAffectedCol->getPropertySetInfo();
+ sal_Bool bHasFormat = xInfo->hasPropertyByName(PROPERTY_FORMATKEY);
+ sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(PROPERTY_TYPE));
+
+ SvxCellHorJustify eJustify(SVX_HOR_JUSTIFY_STANDARD);
+ Any aAlignment = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
+ if (aAlignment.hasValue())
+ eJustify = dbaui::mapTextJustify(::comphelper::getINT16(aAlignment));
+ sal_Int32 nFormatKey = 0;
+ if ( bHasFormat )
+ nFormatKey = ::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY));
+
+ sal_uInt16 nFlags = 0;
+ if(callColumnFormatDialog(_pParent,_pFormatter,nDataType,nFormatKey,eJustify,nFlags,bHasFormat))
+ {
+ xAffectedCol->setPropertyValue(PROPERTY_ALIGN, makeAny((sal_Int16)dbaui::mapTextAllign(eJustify)));
+ if (nFlags & TP_ATTR_NUMBER)
+ xAffectedCol->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey));
+
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool callColumnFormatDialog(Window* _pParent,
+ SvNumberFormatter* _pFormatter,
+ sal_Int32 _nDataType,
+ sal_Int32& _nFormatKey,
+ SvxCellHorJustify& _eJustify,
+ sal_uInt16& _nFlags,
+ sal_Bool _bHasFormat)
+{
+ sal_Bool bRet = sal_False;
+ // the allowed format changes depending on the type of the field ...
+ _nFlags = TP_ATTR_ALIGN;
+
+ if (_bHasFormat)
+ _nFlags |= TP_ATTR_NUMBER;
+
+ // ------------
+ // UNO->ItemSet
+ static SfxItemInfo aItemInfos[] =
+ {
+ { 0, 0 },
+ { SID_ATTR_NUMBERFORMAT_VALUE, SFX_ITEM_POOLABLE },
+ { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE },
+ { SID_ATTR_NUMBERFORMAT_ONE_AREA, SFX_ITEM_POOLABLE },
+ { SID_ATTR_NUMBERFORMAT_INFO, SFX_ITEM_POOLABLE }
+ };
+ static sal_uInt16 aAttrMap[] =
+ {
+ SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY,
+ SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ 0
+ };
+
+ SfxPoolItem* pDefaults[] =
+ {
+ new SfxRangeItem(SBA_DEF_RANGEFORMAT, SBA_DEF_FMTVALUE, SBA_ATTR_ALIGN_HOR_JUSTIFY),
+ new SfxUInt32Item(SBA_DEF_FMTVALUE),
+ new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, SBA_ATTR_ALIGN_HOR_JUSTIFY),
+ new SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_False),
+ new SvxNumberInfoItem(SID_ATTR_NUMBERFORMAT_INFO)
+ };
+
+ SfxItemPool* pPool = new SfxItemPool(String::CreateFromAscii("GridBrowserProperties"), SBA_DEF_RANGEFORMAT, SBA_ATTR_ALIGN_HOR_JUSTIFY, aItemInfos, pDefaults);
+ pPool->SetDefaultMetric( SFX_MAPUNIT_TWIP ); // ripped, don't understand why
+ pPool->FreezeIdRanges(); // the same
+
+ SfxItemSet* pFormatDescriptor = new SfxItemSet(*pPool, aAttrMap);
+ // fill it
+ pFormatDescriptor->Put(SvxHorJustifyItem(_eJustify, SBA_ATTR_ALIGN_HOR_JUSTIFY));
+ sal_Bool bText = sal_False;
+ if (_bHasFormat)
+ {
+ // if the col is bound to a text field we have to disallow all non-text formats
+ if ((DataType::CHAR == _nDataType) || (DataType::VARCHAR == _nDataType) || (DataType::LONGVARCHAR == _nDataType) || (DataType::CLOB == _nDataType))
+ {
+ bText = sal_True;
+ pFormatDescriptor->Put(SfxBoolItem(SID_ATTR_NUMBERFORMAT_ONE_AREA, sal_True));
+ if (!_pFormatter->IsTextFormat(_nFormatKey))
+ // text fields can only have text formats
+ _nFormatKey = _pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT,_pParent->GetSettings().GetLanguage());
+ }
+
+ pFormatDescriptor->Put(SfxUInt32Item(SBA_DEF_FMTVALUE, _nFormatKey));
+ }
+
+ if (!bText)
+ {
+ double dPreviewVal = 1234.56789;
+ SvxNumberInfoItem aFormatter(_pFormatter, dPreviewVal, SID_ATTR_NUMBERFORMAT_INFO);
+ pFormatDescriptor->Put(aFormatter);
+ }
+
+ { // want the dialog to be destroyed before our set
+ SbaSbAttrDlg aDlg(_pParent, pFormatDescriptor, _pFormatter, _nFlags);
+ if (RET_OK == aDlg.Execute())
+ {
+ // ------------
+ // ItemSet->UNO
+ // UNO-properties
+ const SfxItemSet* pSet = aDlg.GetExampleSet();
+ // (of course we could put the modified items directly into the column, but then the UNO-model
+ // won't reflect these changes, and why do we have a model, then ?)
+
+ // horizontal justify
+ SFX_ITEMSET_GET(*pSet, pHorJustify, SvxHorJustifyItem, SBA_ATTR_ALIGN_HOR_JUSTIFY, sal_True);
+
+ _eJustify = (SvxCellHorJustify)pHorJustify->GetValue();
+
+ // format key
+ if (_nFlags & TP_ATTR_NUMBER)
+ {
+ SFX_ITEMSET_GET(*pSet, pFormat, SfxUInt32Item, SBA_DEF_FMTVALUE, sal_True);
+ _nFormatKey = (sal_Int32)pFormat->GetValue();
+ }
+ bRet = sal_True;
+ }
+ // deleted formats
+ const SfxItemSet* pResult = aDlg.GetOutputItemSet();
+ if (pResult)
+ {
+ const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+ const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
+ if (pInfoItem && pInfoItem->GetDelCount())
+ {
+ const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
+
+ for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
+ _pFormatter->DeleteEntry(*pDeletedKeys);
+ }
+ }
+ }
+
+ delete pFormatDescriptor;
+ SfxItemPool::Free(pPool);
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(pDefaults); ++i)
+ delete pDefaults[i];
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+const SfxFilter* getStandardDatabaseFilter()
+{
+ 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!");
+ return pFilter;
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool appendToFilter(const Reference<XConnection>& _xConnection,
+ const ::rtl::OUString& _sName,
+ const Reference< XMultiServiceFactory >& _xFactory,
+ Window* _pParent)
+{
+ sal_Bool bRet = sal_False;
+ Reference< XChild> xChild(_xConnection,UNO_QUERY);
+ if(xChild.is())
+ {
+ Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
+ if(xProp.is())
+ {
+ Sequence< ::rtl::OUString > aFilter;
+ xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter;
+ // first check if we have something like SCHEMA.%
+ sal_Bool bHasToInsert = sal_True;
+ static ::rtl::OUString sPattern(RTL_CONSTASCII_USTRINGPARAM("%"));
+ const ::rtl::OUString* pBegin = aFilter.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aFilter.getLength();
+ for (;pBegin != pEnd; ++pBegin)
+ {
+ if(pBegin->indexOf('%') != -1)
+ {
+ sal_Int32 nLen;
+ if((nLen = pBegin->lastIndexOf('.')) != -1 && !pBegin->compareTo(_sName,nLen))
+ bHasToInsert = sal_False;
+ else if(pBegin->getLength() == 1)
+ bHasToInsert = sal_False;
+ }
+ }
+
+ bRet = sal_True;
+ if(bHasToInsert)
+ {
+ if(! ::dbaui::checkDataSourceAvailable(::comphelper::getString(xProp->getPropertyValue(PROPERTY_NAME)),_xFactory))
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_DATASOURCE_DELETED));
+ OSQLWarningBox( _pParent, aMessage ).Execute();
+ bRet = sal_False;
+ }
+ else
+ {
+ aFilter.realloc(aFilter.getLength()+1);
+ aFilter.getArray()[aFilter.getLength()-1] = _sName;
+ xProp->setPropertyValue(PROPERTY_TABLEFILTER,makeAny(aFilter));
+ }
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc)
+{
+ OSL_ENSURE(_pWindow,"Window can not be null!");
+ SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL;
+ if ( pSystemWindow )
+ {
+ _rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
+ }
+}
+// -----------------------------------------------------------------------------
+void adjustToolBoxSize(ToolBox* _pToolBox)
+{
+ // adjust the toolbox size, otherwise large bitmaps don't fit into
+ Size aOldSize = _pToolBox->GetSizePixel();
+ Size aSize = _pToolBox->CalcWindowSizePixel();
+ if ( !aSize.Width() )
+ aSize.Width() = aOldSize.Width();
+ else if ( !aSize.Height() )
+ aSize.Height() = aOldSize.Height();
+
+ Size aTbSize = _pToolBox->GetSizePixel();
+ if ( (aSize.Width() && aSize.Width() != aTbSize.Width()) ||
+ (aSize.Height() && aSize.Height() != aTbSize.Height()) )
+ {
+ _pToolBox->SetPosSizePixel( _pToolBox->GetPosPixel(), aSize );
+ _pToolBox->Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void adjustBrowseBoxColumnWidth( ::svt::EditBrowseBox* _pBox, sal_uInt16 _nColId )
+{
+ sal_Int32 nColSize = -1;
+ sal_uInt32 nDefaultWidth = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
+ if ( nDefaultWidth != _pBox->GetColumnWidth( _nColId ) )
+ {
+ Size aSizeMM = _pBox->PixelToLogic( Size( _pBox->GetColumnWidth( _nColId ), 0 ), MapMode( MAP_MM ) );
+ nColSize = aSizeMM.Width() * 10;
+ }
+
+ Size aDefaultMM = _pBox->PixelToLogic( Size( nDefaultWidth, 0 ), MapMode( MAP_MM ) );
+
+ DlgSize aColumnSizeDlg( _pBox, nColSize, sal_False, aDefaultMM.Width() * 10 );
+ if ( aColumnSizeDlg.Execute() )
+ {
+ sal_Int32 nValue = aColumnSizeDlg.GetValue();
+ if ( -1 == nValue )
+ { // default width
+ nValue = _pBox->GetDefaultColumnWidth( _pBox->GetColumnTitle( _nColId ) );
+ }
+ else
+ {
+ Size aSizeMM( nValue / 10, 0 );
+ nValue = _pBox->LogicToPixel( aSizeMM, MapMode( MAP_MM ) ).Width();
+ }
+ _pBox->SetColumnWidth( _nColId, nValue );
+ }
+}
+// -----------------------------------------------------------------------------
+// check if SQL92 name checking is enabled
+sal_Bool isSQL92CheckEnabled(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_ENABLESQL92CHECK );
+}
+// -----------------------------------------------------------------------------
+sal_Bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_APPEND_TABLE_ALIAS );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool generateAsBeforeTableAlias(const Reference<XConnection>& _xConnection)
+{
+ return ::dbtools::getBooleanDataSourceSetting( _xConnection, INFO_AS_BEFORE_CORRELATION_NAME );
+}
+
+// -----------------------------------------------------------------------------
+void fillAutoIncrementValue(const Reference<XPropertySet>& _xDatasource,
+ sal_Bool& _rAutoIncrementValueEnabled,
+ ::rtl::OUString& _rsAutoIncrementValue)
+{
+ if ( _xDatasource.is() )
+ {
+ OSL_ENSURE(_xDatasource->getPropertySetInfo()->hasPropertyByName(PROPERTY_INFO),"NO datasource supplied!");
+ Sequence<PropertyValue> aInfo;
+ _xDatasource->getPropertyValue(PROPERTY_INFO) >>= aInfo;
+
+ // search the right propertyvalue
+ const PropertyValue* pValue =::std::find_if(aInfo.getConstArray(),
+ aInfo.getConstArray() + aInfo.getLength(),
+ ::std::bind2nd(TPropertyValueEqualFunctor(),PROPERTY_AUTOINCREMENTCREATION));
+ if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
+ pValue->Value >>= _rsAutoIncrementValue;
+ pValue =::std::find_if(aInfo.getConstArray(),
+ aInfo.getConstArray() + aInfo.getLength(),
+ ::std::bind2nd(TPropertyValueEqualFunctor(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled")) ));
+ if ( pValue && pValue != (aInfo.getConstArray() + aInfo.getLength()) )
+ pValue->Value >>= _rAutoIncrementValueEnabled;
+ }
+}
+// -----------------------------------------------------------------------------
+void fillAutoIncrementValue(const Reference<XConnection>& _xConnection,
+ sal_Bool& _rAutoIncrementValueEnabled,
+ ::rtl::OUString& _rsAutoIncrementValue)
+{
+ Reference< XChild> xChild(_xConnection,UNO_QUERY);
+ if(xChild.is())
+ {
+ Reference< XPropertySet> xProp(xChild->getParent(),UNO_QUERY);
+ fillAutoIncrementValue(xProp,_rAutoIncrementValueEnabled,_rsAutoIncrementValue);
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString getStrippedDatabaseName(const Reference<XPropertySet>& _xDataSource,::rtl::OUString& _rsDatabaseName)
+{
+ if ( !_rsDatabaseName.getLength() && _xDataSource.is() )
+ {
+ try
+ {
+ _xDataSource->getPropertyValue(PROPERTY_NAME) >>= _rsDatabaseName;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ ::rtl::OUString sName = _rsDatabaseName;
+ INetURLObject aURL(sName);
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ sName = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void AppendConfigToken( ::rtl::OUString& _rURL, sal_Bool _bQuestionMark )
+{
+ Any aLocale =
+ ::utl::ConfigManager::GetConfigManager().GetDirectConfigProperty( ::utl::ConfigManager::LOCALE );
+ ::rtl::OUString sLocaleStr;
+ if ( !( aLocale >>= sLocaleStr ) )
+ // fallback is english
+ sLocaleStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));
+
+ // query part exists?
+ if ( _bQuestionMark )
+ // no, so start with '?'
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?"));
+ else
+ // yes, so only append with '&'
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&"));
+
+ // set parameters
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Language="));
+ _rURL += sLocaleStr;
+ _rURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&System="));
+ _rURL += SvtHelpOptions().GetSystem();
+}
+
+namespace
+{
+ // -----------------------------------------------------------------------
+
+ sal_Bool GetHelpAnchor_Impl( const ::rtl::OUString& _rURL, ::rtl::OUString& _rAnchor )
+ {
+ sal_Bool bRet = sal_False;
+ ::rtl::OUString sAnchor;
+
+ try
+ {
+ ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::NO_DECODE ),
+ Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if ( ( aCnt.getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorName")) ) >>= sAnchor ) )
+ {
+
+ if ( sAnchor.getLength() > 0 )
+ {
+ _rAnchor = sAnchor;
+ bRet = sal_True;
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "Property 'AnchorName' is missing" );
+ }
+ }
+ catch( Exception& )
+ {
+ }
+
+ return bRet;
+ }
+// .........................................................................
+} // annonymous
+// .........................................................................
+// -----------------------------------------------------------------------------
+::com::sun::star::util::URL createHelpAgentURL(const ::rtl::OUString& _sModuleName, const rtl::OString& sHelpId)
+{
+ ::com::sun::star::util::URL aURL;
+ aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.help://" ) );
+ aURL.Complete += _sModuleName;
+ aURL.Complete += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ aURL.Complete += ::rtl::OUString(sHelpId, sHelpId.getLength(), RTL_TEXTENCODING_UTF8);
+
+ ::rtl::OUString sAnchor;
+ ::rtl::OUString sTempURL = aURL.Complete;
+ AppendConfigToken( sTempURL, sal_True );
+ sal_Bool bHasAnchor = GetHelpAnchor_Impl( sTempURL, sAnchor );
+ AppendConfigToken(aURL.Complete,sal_True);
+ if ( bHasAnchor )
+ {
+ aURL.Complete += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("#"));
+ aURL.Complete += sAnchor;
+ }
+ return aURL;
+}
+// -----------------------------------------------------------------------------
+void setEvalDateFormatForFormatter(Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
+{
+ OSL_ENSURE( _rxFormatter.is(),"setEvalDateFormatForFormatter: Formatter is NULL!");
+ if ( _rxFormatter.is() )
+ {
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = _rxFormatter->getNumberFormatsSupplier();
+
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ SvNumberFormatsSupplierObj* pSupplierImpl = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ OSL_ENSURE(pSupplierImpl,"No Supplier!");
+
+ if ( pSupplierImpl )
+ {
+ SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
+ pFormatter->SetEvalDateFormat(NF_EVALDATEFORMAT_FORMAT);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo)
+{
+ TOTypeInfoSP pTypeInfo;
+ // first we search for a type which supports autoIncrement
+ OTypeInfoMap::const_iterator aIter = _rTypeInfo.begin();
+ OTypeInfoMap::const_iterator aEnd = _rTypeInfo.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ // OJ: we don't want to set an autoincrement column to be key
+ // because we don't have the possiblity to know how to create
+ // such auto increment column later on
+ // so until we know how to do it, we create a column without autoincrement
+ // if ( !aIter->second->bAutoIncrement )
+ { // therefor we have searched
+ if ( aIter->second->nType == DataType::INTEGER )
+ {
+ pTypeInfo = aIter->second; // alternative
+ break;
+ }
+ else if ( !pTypeInfo.get() && aIter->second->nType == DataType::DOUBLE )
+ pTypeInfo = aIter->second; // alternative
+ else if ( !pTypeInfo.get() && aIter->second->nType == DataType::REAL )
+ pTypeInfo = aIter->second; // alternative
+ }
+ }
+ if ( !pTypeInfo.get() ) // just a fallback
+ pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo);
+
+ OSL_ENSURE(pTypeInfo.get(),"checkColumns: cann't find a type which is useable as a key!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP queryTypeInfoByType(sal_Int32 _nDataType,const OTypeInfoMap& _rTypeInfo)
+{
+ OTypeInfoMap::const_iterator aIter = _rTypeInfo.find(_nDataType);
+ if(aIter != _rTypeInfo.end())
+ return aIter->second;
+ // fall back if the type is unknown
+ TOTypeInfoSP pTypeInfo;
+ switch(_nDataType)
+ {
+ case DataType::TINYINT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::SMALLINT,_rTypeInfo))
+ break;
+ // run through
+ case DataType::SMALLINT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::INTEGER,_rTypeInfo))
+ break;
+ // run through
+ case DataType::INTEGER:
+ if( pTypeInfo = queryTypeInfoByType(DataType::FLOAT,_rTypeInfo))
+ break;
+ // run through
+ case DataType::FLOAT:
+ if( pTypeInfo = queryTypeInfoByType(DataType::REAL,_rTypeInfo))
+ break;
+ // run through
+ case DataType::DATE:
+ case DataType::TIME:
+ if( DataType::DATE == _nDataType || DataType::TIME == _nDataType )
+ {
+ if( pTypeInfo = queryTypeInfoByType(DataType::TIMESTAMP,_rTypeInfo))
+ break;
+ }
+ // run through
+ case DataType::TIMESTAMP:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) )
+ break;
+ // run through
+ case DataType::DOUBLE:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) )
+ break;
+ // run through
+ case DataType::NUMERIC:
+ pTypeInfo = queryTypeInfoByType(DataType::DECIMAL,_rTypeInfo);
+ break;
+ case DataType::DECIMAL:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::NUMERIC,_rTypeInfo) )
+ break;
+ if ( pTypeInfo = queryTypeInfoByType(DataType::DOUBLE,_rTypeInfo) )
+ break;
+ break;
+ case DataType::VARCHAR:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::LONGVARCHAR,_rTypeInfo) )
+ break;
+ break;
+ case DataType::LONGVARCHAR:
+ if ( pTypeInfo = queryTypeInfoByType(DataType::CLOB,_rTypeInfo) )
+ break;
+ break;
+ default:
+ ;
+ }
+ if ( !pTypeInfo )
+ {
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x")),sTypeName;
+ sal_Bool bForce = sal_True;
+ pTypeInfo = ::dbaui::getTypeInfoFromType(_rTypeInfo,DataType::VARCHAR,sTypeName,sCreate,50,0,sal_False,bForce);
+ }
+ OSL_ENSURE(pTypeInfo,"Wrong DataType supplied!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 askForUserAction(Window* _pParent,sal_uInt16 _nTitle,sal_uInt16 _nText,sal_Bool _bAll,const ::rtl::OUString& _sName)
+{
+ SolarMutexGuard aGuard;
+ String aMsg = String(ModuleRes(_nText));
+ aMsg.SearchAndReplace(String::CreateFromAscii("%1"),String(_sName));
+ OSQLMessageBox aAsk(_pParent,String(ModuleRes(_nTitle )),aMsg,WB_YES_NO | WB_DEF_YES,OSQLMessageBox::Query);
+ if ( _bAll )
+ {
+ aAsk.AddButton(String(ModuleRes(STR_BUTTON_TEXT_ALL)), RET_ALL, 0);
+ aAsk.GetPushButton(RET_ALL)->SetHelpId(HID_CONFIRM_DROP_BUTTON_ALL);
+ }
+ return aAsk.Execute();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ static ::rtl::OUString lcl_createSDBCLevelStatement( const ::rtl::OUString& _rStatement, const Reference< XConnection >& _rxConnection )
+ {
+ ::rtl::OUString sSDBCLevelStatement( _rStatement );
+ try
+ {
+ Reference< XMultiServiceFactory > xAnalyzerFactory( _rxConnection, UNO_QUERY_THROW );
+ Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xAnalyzerFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
+ xAnalyzer->setQuery( _rStatement );
+ sSDBCLevelStatement = xAnalyzer->getQueryWithSubstitution();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sSDBCLevelStatement;
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection,
+ const ::rtl::OUString& _rCommand )
+{
+ Reference<XViewsSupplier> xSup(_rxConnection,UNO_QUERY);
+ Reference< XNameAccess > xViews;
+ if(xSup.is())
+ xViews = xSup->getViews();
+ Reference<XDataDescriptorFactory> xFact(xViews,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
+ if(!xFact.is())
+ return NULL;
+
+ Reference<XPropertySet> xView = xFact->createDataDescriptor();
+ if ( !xView.is() )
+ return NULL;
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(_rxConnection->getMetaData(),
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ xView->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xView->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xView->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
+
+ xView->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
+
+ Reference<XAppend> xAppend(xViews,UNO_QUERY);
+ if(xAppend.is())
+ xAppend->appendByDescriptor(xView);
+
+ xView = NULL;
+ // we need to reget the view because after appending it it is no longer valid
+ // but this time it isn't a view object it is a table object with type "VIEW"
+ Reference<XTablesSupplier> xTabSup(_rxConnection,UNO_QUERY);
+ Reference< XNameAccess > xTables;
+ if ( xTabSup.is() )
+ {
+ xTables = xTabSup->getTables();
+ if ( xTables.is() && xTables->hasByName( _rName ) )
+ xTables->getByName( _rName ) >>= xView;
+ }
+
+ return xView;
+}
+
+// -----------------------------------------------------------------------------
+Reference<XPropertySet> createView( const ::rtl::OUString& _rName, const Reference< XConnection >& _rxConnection
+ ,const Reference<XPropertySet>& _rxSourceObject)
+{
+ ::rtl::OUString sCommand;
+ Reference< XPropertySetInfo > xPSI( _rxSourceObject->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ {
+ _rxSourceObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( _rxSourceObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+ if ( bEscapeProcessing )
+ sCommand = lcl_createSDBCLevelStatement( sCommand, _rxConnection );
+ }
+ else
+ {
+ sCommand = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SELECT * FROM " ) );
+ sCommand += composeTableNameForSelect( _rxConnection, _rxSourceObject );
+ }
+ return createView( _rName, _rxConnection, sCommand );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool insertHierachyElement( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference<XHierarchicalNameContainer>& _xNames,
+ const String& _sParentFolder,
+ sal_Bool _bForm,
+ sal_Bool _bCollection,
+ const Reference<XContent>& _xContent,
+ sal_Bool _bMove)
+{
+ OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" );
+ if ( !_xNames.is() )
+ return sal_False;
+
+ Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY );
+ ::rtl::OUString sName = _sParentFolder;
+ if ( _xNames->hasByHierarchicalName(sName) )
+ {
+ Reference<XChild> xChild(_xNames->getByHierarchicalName(sName),UNO_QUERY);
+ xNameAccess.set(xChild,UNO_QUERY);
+ if ( !xNameAccess.is() && xChild.is() )
+ xNameAccess.set(xChild->getParent(),UNO_QUERY);
+ }
+
+ OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" );
+ if ( !xNameAccess.is() )
+ return sal_False;
+
+ ::rtl::OUString sNewName;
+ Reference<XPropertySet> xProp(_xContent,UNO_QUERY);
+ if ( xProp.is() )
+ xProp->getPropertyValue(PROPERTY_NAME) >>= sNewName;
+
+ if ( !_bMove || !sNewName.getLength() )
+ {
+ String sTargetName,sLabel;
+ if ( !sNewName.getLength() || xNameAccess->hasByName(sNewName) )
+ {
+ if ( sNewName.getLength() )
+ sTargetName = sNewName;
+ else
+ sTargetName = String(ModuleRes( _bCollection ? STR_NEW_FOLDER : ((_bForm) ? RID_STR_FORM : RID_STR_REPORT)));
+ sLabel = String(ModuleRes( _bCollection ? STR_FOLDER_LABEL : ((_bForm) ? STR_FRM_LABEL : STR_RPT_LABEL)));
+ sTargetName = ::dbtools::createUniqueName(xNameAccess,sTargetName);
+
+
+ // here we have everything needed to create a new query object ...
+ HierarchicalNameCheck aNameChecker( _xNames.get(), sName );
+ // ... ehm, except a new name
+ OSaveAsDlg aAskForName( _pParent,
+ _rxORB,
+ sTargetName,
+ sLabel,
+ aNameChecker,
+ SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS);
+ if ( RET_OK != aAskForName.Execute() )
+ // cancelled by the user
+ return sal_False;
+
+ sNewName = aAskForName.getName();
+ }
+ }
+ else if ( xNameAccess->hasByName(sNewName) )
+ {
+ String sError(ModuleRes(STR_NAME_ALREADY_EXISTS));
+ sError.SearchAndReplaceAscii("#",sNewName);
+ throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any());
+ }
+
+ try
+ {
+ Reference<XMultiServiceFactory> xORB( xNameAccess, UNO_QUERY_THROW );
+ Sequence< Any > aArguments(3);
+ PropertyValue aValue;
+ // set as folder
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ aValue.Value <<= sNewName;
+ aArguments[0] <<= aValue;
+ //parent
+ aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
+ aValue.Value <<= xNameAccess;
+ aArguments[1] <<= aValue;
+
+ aValue.Name = PROPERTY_EMBEDDEDOBJECT;
+ aValue.Value <<= _xContent;
+ aArguments[2] <<= aValue;
+
+ ::rtl::OUString sServiceName(_bCollection ? ((_bForm) ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION) : SERVICE_SDB_DOCUMENTDEFINITION);
+
+ Reference<XContent > xNew( xORB->createInstanceWithArguments( sServiceName, aArguments ), UNO_QUERY_THROW );
+ Reference< XNameContainer > xNameContainer( xNameAccess, UNO_QUERY_THROW );
+ xNameContainer->insertByName( sNewName, makeAny( xNew ) );
+ }
+ catch( const IllegalArgumentException& e )
+ {
+ ::dbtools::throwGenericSQLException( e.Message, e.Context );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > getNumberFormatter(const Reference< XConnection >& _rxConnection,const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rMF )
+{
+ // ---------------------------------------------------------------
+ // create a formatter working with the connections format supplier
+ Reference< XNumberFormatter > xFormatter;
+
+ try
+ {
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(_rxConnection, sal_True,_rMF));
+
+ if ( xSupplier.is() )
+ {
+ // create a new formatter
+ xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (
+ _rMF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ if ( xFormatter.is() )
+ xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xFormatter;
+}
+
+
+// .........................................................................
+} // dbaui
+// .........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/UpdateHelperImpl.hxx b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
new file mode 100644
index 000000000000..cff3c9f11a72
--- /dev/null
+++ b/dbaccess/source/ui/misc/UpdateHelperImpl.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_UPDATEHELPERIMPL_HXX
+#define DBAUI_UPDATEHELPERIMPL_HXX
+
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include "IUpdateHelper.hxx"
+#include <rtl/logfile.hxx>
+
+namespace dbaui
+{
+ class ORowUpdateHelper : public IUpdateHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate > m_xRowUpdate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xResultSetUpdate; //
+ public:
+ ORowUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _xRowSet)
+ :m_xRowUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
+ ,m_xResultSetUpdate(_xRowSet,::com::sun::star::uno::UNO_QUERY)
+ {
+ }
+ virtual ~ORowUpdateHelper() {}
+ virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
+ {
+ m_xRowUpdate->updateString(_nPos, _sValue);
+ }
+ virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
+ {
+ m_xRowUpdate->updateDouble(_nPos, _nValue);
+ }
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ m_xRowUpdate->updateDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ m_xRowUpdate->updateTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ m_xRowUpdate->updateTimestamp(_nPos, _nValue);
+ }
+ virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
+ {
+ m_xRowUpdate->updateInt(_nPos, _nValue);
+ }
+ virtual void updateNull(sal_Int32 _nPos, ::sal_Int32)
+ {
+ m_xRowUpdate->updateNull(_nPos);
+ }
+ virtual void moveToInsertRow()
+ {
+ m_xResultSetUpdate->moveToInsertRow();
+ }
+ virtual void insertRow()
+ {
+ m_xResultSetUpdate->insertRow();
+ }
+ };
+
+ class OParameterUpdateHelper : public IUpdateHelper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > m_xPrepared;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters > m_xParameters;
+
+ public:
+ OParameterUpdateHelper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement >& _xPrepared)
+ :m_xPrepared(_xPrepared)
+ ,m_xParameters(_xPrepared,::com::sun::star::uno::UNO_QUERY)
+ {
+ }
+ virtual ~OParameterUpdateHelper() {}
+ virtual void updateString(sal_Int32 _nPos, const ::rtl::OUString& _sValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateString" );
+ m_xParameters->setString(_nPos, _sValue);
+ }
+ virtual void updateDouble(sal_Int32 _nPos,const double& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setDouble(_nPos, _nValue);
+ }
+ virtual void updateDate(sal_Int32 _nPos,const ::com::sun::star::util::Date& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setDate(_nPos, _nValue);
+ }
+ virtual void updateTime(sal_Int32 _nPos,const ::com::sun::star::util::Time& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTime(_nPos, _nValue);
+ }
+ virtual void updateTimestamp(sal_Int32 _nPos,const ::com::sun::star::util::DateTime& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateDouble" );
+ m_xParameters->setTimestamp(_nPos, _nValue);
+ }
+ virtual void updateInt(sal_Int32 _nPos,const sal_Int32& _nValue)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateInt" );
+ m_xParameters->setInt(_nPos, _nValue);
+ }
+ virtual void updateNull(sal_Int32 _nPos, ::sal_Int32 sqlType)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::updateNull" );
+ m_xParameters->setNull(_nPos,sqlType);
+ }
+ virtual void moveToInsertRow()
+ {
+ }
+ virtual void insertRow()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OParameterUpdateHelper::insertRow" );
+ m_xPrepared->executeUpdate();
+ }
+ };
+}
+
+#endif // DBAUI_UPDATEHELPERIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx
new file mode 100644
index 000000000000..b0df6f61f1b5
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCPage.cxx
@@ -0,0 +1,383 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "WCPage.hxx"
+#include "WCopyTable.hxx"
+
+#include "defaultobjectnamecheck.hxx"
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "dbu_misc.hrc"
+#include "WizardPages.hrc"
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <vcl/msgbox.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include "UITools.hxx"
+#include "moduledbu.hxx"
+#include <cppuhelper/exc_hlp.hxx>
+
+using namespace ::dbaui;
+using namespace ::dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+//========================================================================
+// Klasse OCopyTable
+//========================================================================
+DBG_NAME(OCopyTable)
+//------------------------------------------------------------------------
+OCopyTable::OCopyTable( Window * pParent )
+ :OWizardPage( pParent, ModuleRes(TAB_WIZ_COPYTABLE) )
+ ,m_ftTableName( this, ModuleRes( FT_TABLENAME ) )
+ ,m_edTableName( this, ModuleRes( ET_TABLENAME ) )
+ ,m_aFL_Options( this, ModuleRes( FL_OPTIONS ) )
+ ,m_aRB_DefData( this, ModuleRes( RB_DEFDATA ) )
+ ,m_aRB_Def( this, ModuleRes( RB_DEF ) )
+ ,m_aRB_View( this, ModuleRes( RB_VIEW ) )
+ ,m_aRB_AppendData( this, ModuleRes( RB_APPENDDATA ) )
+ ,m_aCB_UseHeaderLine( this, ModuleRes( CB_USEHEADERLINE ) )
+ ,m_aCB_PrimaryColumn( this, ModuleRes( CB_PRIMARY_COLUMN ) )
+ ,m_aFT_KeyName( this, ModuleRes( FT_KEYNAME ) )
+ ,m_edKeyName( this, ModuleRes( ET_KEYNAME ) )
+ ,m_pPage2(NULL)
+ ,m_pPage3(NULL)
+ ,m_bUseHeaderAllowed(sal_True)
+{
+ DBG_CTOR(OCopyTable,NULL);
+
+ m_edTableName.SetMaxTextLen( EDIT_NOLIMIT );
+
+ if ( m_pParent->m_xDestConnection.is() )
+ {
+ if ( !m_pParent->supportsViews() )
+ m_aRB_View.Disable();
+
+ m_aCB_UseHeaderLine.Check(sal_True);
+ m_bPKeyAllowed = m_pParent->supportsPrimaryKey();
+
+ m_aCB_PrimaryColumn.Enable(m_bPKeyAllowed);
+
+ m_aRB_AppendData.SetClickHdl( LINK( this, OCopyTable, AppendDataClickHdl ) );
+
+ m_aRB_DefData.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+ m_aRB_Def.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+ m_aRB_View.SetClickHdl( LINK( this, OCopyTable, RadioChangeHdl ) );
+
+ m_aCB_PrimaryColumn.SetClickHdl(LINK( this, OCopyTable, KeyClickHdl ) );
+
+ m_aFT_KeyName.Enable(sal_False);
+ m_edKeyName.Enable(sal_False);
+ ::rtl::OUString sKeyName(RTL_CONSTASCII_USTRINGPARAM("ID"));
+ sKeyName = m_pParent->createUniqueName(sKeyName);
+ m_edKeyName.SetText(sKeyName);
+
+ sal_Int32 nMaxLen = m_pParent->getMaxColumnNameLength();
+ m_edKeyName.SetMaxTextLen(nMaxLen ? (xub_StrLen)nMaxLen : EDIT_NOLIMIT);
+ }
+
+ FreeResource();
+
+ SetText(String(ModuleRes(STR_COPYTABLE_TITLE_COPY)));
+}
+
+//------------------------------------------------------------------------
+OCopyTable::~OCopyTable()
+{
+ DBG_DTOR(OCopyTable,NULL);
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OCopyTable, AppendDataClickHdl, Button*, /*pButton*/ )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+
+ SetAppendDataRadio();
+ return 0;
+}
+
+void OCopyTable::SetAppendDataRadio()
+{
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_True);
+ m_aFT_KeyName.Enable(sal_False);
+ m_aCB_PrimaryColumn.Enable(sal_False);
+ m_edKeyName.Enable(sal_False);
+ m_pParent->setOperation(CopyTableOperation::AppendData);
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( OCopyTable, RadioChangeHdl, Button*, pButton )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,pButton != &m_aRB_View);
+ sal_Bool bKey = m_bPKeyAllowed && pButton != &m_aRB_View;
+ m_aFT_KeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
+ m_edKeyName.Enable(bKey && m_aCB_PrimaryColumn.IsChecked());
+ m_aCB_PrimaryColumn.Enable(bKey);
+ m_aCB_UseHeaderLine.Enable(m_bUseHeaderAllowed && IsOptionDefData());
+
+ // set typ what to do
+ if( IsOptionDefData() )
+ m_pParent->setOperation( CopyTableOperation::CopyDefinitionAndData );
+ else if( IsOptionDef() )
+ m_pParent->setOperation( CopyTableOperation::CopyDefinitionOnly );
+ else if( IsOptionView() )
+ m_pParent->setOperation( CopyTableOperation::CreateAsView );
+
+ return 0;
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OCopyTable, KeyClickHdl, Button*, /*pButton*/ )
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_edKeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
+ m_aFT_KeyName.Enable(m_aCB_PrimaryColumn.IsChecked());
+ return 0;
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTable::LeavePage()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->m_bCreatePrimaryKeyColumn = (m_bPKeyAllowed && m_aCB_PrimaryColumn.IsEnabled()) ? m_aCB_PrimaryColumn.IsChecked() : sal_False;
+ m_pParent->m_aKeyName = m_pParent->m_bCreatePrimaryKeyColumn ? m_edKeyName.GetText() : String();
+ m_pParent->setUseHeaderLine( m_aCB_UseHeaderLine.IsChecked() );
+
+ // first check if the table already exists in the database
+ if( m_pParent->getOperation() != CopyTableOperation::AppendData )
+ {
+ m_pParent->clearDestColumns();
+ DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE );
+ SQLExceptionInfo aErrorInfo;
+ if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) )
+ {
+ aErrorInfo.append( SQLExceptionInfo::SQL_CONTEXT, String( ModuleRes( STR_SUGGEST_APPEND_TABLE_DATA ) ) );
+ m_pParent->showError(aErrorInfo.get());
+
+ return sal_False;
+ }
+
+ // have to check the length of the table name
+ Reference< XDatabaseMetaData > xMeta = m_pParent->m_xDestConnection->getMetaData();
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ ::dbtools::qualifiedNameComponents( xMeta,
+ m_edTableName.GetText(),
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ sal_Int32 nMaxLength = xMeta->getMaxTableNameLength();
+ if ( nMaxLength && sTable.getLength() > nMaxLength )
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME_LENGTH));
+ m_pParent->showError(sError);
+ return sal_False;
+ }
+
+ // now we have to check if the name of the primary key already exists
+ if ( m_pParent->m_bCreatePrimaryKeyColumn
+ && m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
+ {
+ String aInfoString( ModuleRes(STR_WIZ_PKEY_ALREADY_DEFINED) );
+ aInfoString += String(' ');
+ aInfoString += String(m_pParent->m_aKeyName);
+ m_pParent->showError(aInfoString);
+ return sal_False;
+ }
+ }
+
+ if ( !m_edTableName.GetSavedValue().Equals(m_edTableName.GetText()) )
+ { // table exists and name has changed
+ if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
+ {
+ if(!checkAppendData())
+ return sal_False;
+ }
+ else if ( m_nOldOperation == CopyTableOperation::AppendData )
+ {
+ m_edTableName.SaveValue();
+ return LeavePage();
+ }
+ }
+ else
+ { // table exist and is not new or doesn't exist and so on
+ if ( CopyTableOperation::AppendData == m_pParent->getOperation() )
+ {
+ if( !checkAppendData() )
+ return sal_False;
+ }
+ }
+ m_pParent->m_sName = m_edTableName.GetText();
+ m_edTableName.SaveValue();
+
+ if(!m_pParent->m_sName.getLength())
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
+ return sal_False;
+ }
+
+ return sal_True;
+}
+//------------------------------------------------------------------------
+void OCopyTable::ActivatePage()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->GetOKButton().Enable( sal_True );
+ m_nOldOperation = m_pParent->getOperation();
+ m_edTableName.GrabFocus();
+ m_aCB_UseHeaderLine.Check(m_pParent->UseHeaderLine());
+}
+//------------------------------------------------------------------------
+String OCopyTable::GetTitle() const
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ return String(ModuleRes(STR_WIZ_TABLE_COPY));
+}
+//------------------------------------------------------------------------
+void OCopyTable::Reset()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_bFirstTime = sal_False;
+
+ m_edTableName.SetText( m_pParent->m_sName );
+ m_edTableName.SaveValue();
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTable::checkAppendData()
+{
+ DBG_CHKTHIS(OCopyTable,NULL);
+ m_pParent->clearDestColumns();
+ Reference< XPropertySet > xTable;
+ Reference< XTablesSupplier > xSup( m_pParent->m_xDestConnection, UNO_QUERY );
+ Reference<XNameAccess> xTables;
+ if(xSup.is())
+ xTables = xSup->getTables();
+ if(xTables.is() && xTables->hasByName(m_edTableName.GetText()))
+ {
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+ const sal_uInt32 nSrcSize = pSrcColumns->size();
+ m_pParent->m_vColumnPos.resize( nSrcSize, ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
+ m_pParent->m_vColumnTypes.resize( nSrcSize , COLUMN_POSITION_NOT_FOUND );
+
+ // set new destination
+ xTables->getByName( m_edTableName.GetText() ) >>= xTable;
+ ObjectCopySource aTableCopySource( m_pParent->m_xDestConnection, xTable );
+ m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end();
+ const sal_uInt32 nDestSize = pDestColumns->size();
+ sal_Bool bNotConvert;
+ sal_uInt32 i = 0;
+ for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i)
+ {
+ bNotConvert = sal_True;
+ m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos);
+ TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
+ if ( !bNotConvert )
+ {
+ m_pParent->showColumnTypeNotSupported((*aDestIter)->first);
+ return sal_False;
+ }
+
+ if ( pTypeInfo.get() )
+ m_pParent->m_vColumnTypes[i] = pTypeInfo->nType;
+ else
+ m_pParent->m_vColumnTypes[i] = DataType::VARCHAR;
+ }
+
+ }
+
+ if ( !xTable.is() )
+ {
+ String sError(ModuleRes(STR_INVALID_TABLE_NAME));
+ m_pParent->showError(sError);
+ return sal_False;
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OCopyTable::setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName )
+{
+ bool bCreatePK = m_bPKeyAllowed && _bDoCreate;
+ m_aCB_PrimaryColumn.Check( bCreatePK );
+ m_edKeyName.SetText( _rSuggestedName );
+
+ m_aFT_KeyName.Enable( bCreatePK );
+ m_edKeyName.Enable( bCreatePK );
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTable::setCreateStyleAction()
+{
+ // reselect the last action before
+ switch(m_pParent->getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ m_aRB_DefData.Check(sal_True);
+ RadioChangeHdl(&m_aRB_DefData);
+ break;
+ case CopyTableOperation::CopyDefinitionOnly:
+ m_aRB_Def.Check(sal_True);
+ RadioChangeHdl(&m_aRB_Def);
+ break;
+ case CopyTableOperation::AppendData:
+ m_aRB_AppendData.Check(sal_True);
+ SetAppendDataRadio();
+ break;
+ case CopyTableOperation::CreateAsView:
+ if ( m_aRB_View.IsEnabled() )
+ {
+ m_aRB_View.Check(sal_True);
+ RadioChangeHdl(&m_aRB_View);
+ }
+ else
+ {
+ m_aRB_DefData.Check(sal_True);
+ RadioChangeHdl(&m_aRB_DefData);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
new file mode 100644
index 000000000000..07affc1c2015
--- /dev/null
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -0,0 +1,426 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "WColumnSelect.hxx"
+#include "dbu_misc.hrc"
+#include <osl/diagnose.h>
+#include "WizardPages.hrc"
+#include "WCopyTable.hxx"
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include "dbustrings.hrc"
+#include <functional>
+#include <o3tl/compat_functional.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace dbaui;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+// -----------------------------------------------------------------------
+String OWizColumnSelect::GetTitle() const { return String(ModuleRes(STR_WIZ_COLUMN_SELECT_TITEL)); }
+// -----------------------------------------------------------------------------
+OWizardPage::OWizardPage( Window* pParent, const ResId& rResId )
+ : TabPage(pParent,rResId)
+ ,m_pParent(static_cast<OCopyTableWizard*>(pParent))
+ ,m_bFirstTime(sal_True)
+{
+}
+//========================================================================
+// OWizColumnSelect
+DBG_NAME(OWizColumnSelect);
+//========================================================================
+OWizColumnSelect::OWizColumnSelect( Window* pParent)
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_COLUMN_SELECT ))
+ ,m_flColumns( this, ModuleRes( FL_COLUMN_SELECT ) )
+ ,m_lbOrgColumnNames( this, ModuleRes( LB_ORG_COLUMN_NAMES ) )
+ ,m_ibColumn_RH( this, ModuleRes( IB_COLUMN_RH ) )
+ ,m_ibColumns_RH( this, ModuleRes( IB_COLUMNS_RH ) )
+ ,m_ibColumn_LH( this, ModuleRes( IB_COLUMN_LH ) )
+ ,m_ibColumns_LH( this, ModuleRes( IB_COLUMNS_LH ) )
+ ,m_lbNewColumnNames( this, ModuleRes( LB_NEW_COLUMN_NAMES ) )
+{
+ DBG_CTOR(OWizColumnSelect,NULL);
+ m_ibColumn_RH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumn_LH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumns_RH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+ m_ibColumns_LH.SetClickHdl(LINK(this,OWizColumnSelect,ButtonClickHdl));
+
+ m_lbOrgColumnNames.EnableMultiSelection(sal_True);
+ m_lbNewColumnNames.EnableMultiSelection(sal_True);
+
+ m_lbOrgColumnNames.SetDoubleClickHdl(LINK(this,OWizColumnSelect,ListDoubleClickHdl));
+ m_lbNewColumnNames.SetDoubleClickHdl(LINK(this,OWizColumnSelect,ListDoubleClickHdl));
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizColumnSelect::~OWizColumnSelect()
+{
+ DBG_DTOR(OWizColumnSelect,NULL);
+ while ( m_lbNewColumnNames.GetEntryCount() )
+ {
+ void* pData = m_lbNewColumnNames.GetEntryData(0);
+ if ( pData )
+ delete static_cast<OFieldDescription*>(pData);
+
+ m_lbNewColumnNames.RemoveEntry(0);
+ }
+ m_lbNewColumnNames.Clear();
+}
+
+// -----------------------------------------------------------------------
+void OWizColumnSelect::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+
+ clearListBox(m_lbOrgColumnNames);
+ clearListBox(m_lbNewColumnNames);
+ m_pParent->m_mNameMapping.clear();
+
+ // insert the source columns in the left listbox
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aIter = pSrcColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pSrcColumns->end();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos = m_lbOrgColumnNames.InsertEntry((*aIter)->first);
+ m_lbOrgColumnNames.SetEntryData(nPos,(*aIter)->second);
+ }
+
+ if(m_lbOrgColumnNames.GetEntryCount())
+ m_lbOrgColumnNames.SelectEntryPos(0);
+
+ m_bFirstTime = sal_False;
+}
+// -----------------------------------------------------------------------
+void OWizColumnSelect::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+ // if there are no dest columns reset the left side with the origibnal columns
+ if(m_pParent->getDestColumns()->size() == 0)
+ Reset();
+
+ clearListBox(m_lbNewColumnNames);
+
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+
+ ODatabaseExport::TColumnVector::const_iterator aIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pDestColumns->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos = m_lbNewColumnNames.InsertEntry((*aIter)->first);
+ m_lbNewColumnNames.SetEntryData(nPos,new OFieldDescription(*((*aIter)->second)));
+ m_lbOrgColumnNames.RemoveEntry((*aIter)->first);
+ }
+ m_pParent->GetOKButton().Enable(m_lbNewColumnNames.GetEntryCount() != 0);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,m_lbNewColumnNames.GetEntryCount() && m_pParent->getOperation() != CopyTableOperation::AppendData);
+ m_ibColumns_RH.GrabFocus();
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizColumnSelect::LeavePage()
+{
+ DBG_CHKTHIS(OWizColumnSelect,NULL);
+
+ m_pParent->clearDestColumns();
+
+ for(sal_uInt16 i=0 ; i< m_lbNewColumnNames.GetEntryCount();++i)
+ {
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbNewColumnNames.GetEntryData(i));
+ OSL_ENSURE(pField,"The field information can not be null!");
+ m_pParent->insertColumn(i,pField);
+ }
+
+ clearListBox(m_lbNewColumnNames);
+
+
+ if ( m_pParent->GetPressedButton() == OCopyTableWizard::WIZARD_NEXT
+ || m_pParent->GetPressedButton() == OCopyTableWizard::WIZARD_FINISH
+ )
+ return m_pParent->getDestColumns()->size() != 0;
+ else
+ return sal_True;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizColumnSelect, ButtonClickHdl, Button *, pButton )
+{
+ MultiListBox *pLeft = NULL;
+ MultiListBox *pRight = NULL;
+ sal_Bool bAll = sal_False;
+
+ if(pButton == &m_ibColumn_RH)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ }
+ else if(pButton == &m_ibColumn_LH)
+ {
+ pLeft = &m_lbNewColumnNames;
+ pRight = &m_lbOrgColumnNames;
+ }
+ else if(pButton == &m_ibColumns_RH)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ bAll = sal_True;
+ }
+ else if(pButton == &m_ibColumns_LH)
+ {
+ pLeft = &m_lbNewColumnNames;
+ pRight = &m_lbOrgColumnNames;
+ bAll = sal_True;
+ }
+ // else ????
+
+ Reference< XDatabaseMetaData > xMetaData( m_pParent->m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = m_pParent->getMaxColumnNameLength();
+
+ ::comphelper::TStringMixEqualFunctor aCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
+ ::std::vector< ::rtl::OUString> aRightColumns;
+ fillColumns(pRight,aRightColumns);
+
+ String aColumnName;
+ if(!bAll)
+ {
+ for(sal_uInt16 i=0; i < pLeft->GetSelectEntryCount(); ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetSelectEntry(i),sExtraChars,nMaxNameLen,aCase);
+
+ for(sal_uInt16 j=pLeft->GetSelectEntryCount(); j ; --j)
+ pLeft->RemoveEntry(pLeft->GetSelectEntry(j-1));
+ }
+ else
+ {
+ sal_uInt16 nEntries = pLeft->GetEntryCount();
+ for(sal_uInt16 i=0; i < nEntries; ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetEntry(i),sExtraChars,nMaxNameLen,aCase);
+ for(sal_uInt16 j=pLeft->GetEntryCount(); j ; --j)
+ pLeft->RemoveEntry(j-1);
+ }
+
+ enableButtons();
+
+ if(m_lbOrgColumnNames.GetEntryCount())
+ m_lbOrgColumnNames.SelectEntryPos(0);
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizColumnSelect, ListDoubleClickHdl, MultiListBox *, pListBox )
+{
+ MultiListBox *pLeft,*pRight;
+ if(pListBox == &m_lbOrgColumnNames)
+ {
+ pLeft = &m_lbOrgColumnNames;
+ pRight = &m_lbNewColumnNames;
+ }
+ else
+ {
+ pRight = &m_lbOrgColumnNames;
+ pLeft = &m_lbNewColumnNames;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenbank PrimaryKeys verarbeiten kann, PrimaryKey anlegen
+ Reference< XDatabaseMetaData > xMetaData( m_pParent->m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = m_pParent->getMaxColumnNameLength();
+
+ ::comphelper::TStringMixEqualFunctor aCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
+ ::std::vector< ::rtl::OUString> aRightColumns;
+ fillColumns(pRight,aRightColumns);
+
+ String aColumnName;
+ for(sal_uInt16 i=0; i < pLeft->GetSelectEntryCount(); ++i)
+ moveColumn(pRight,pLeft,aRightColumns,pLeft->GetSelectEntry(i),sExtraChars,nMaxNameLen,aCase);
+ for(sal_uInt16 j=pLeft->GetSelectEntryCount(); j ; --j)
+ pLeft->RemoveEntry(pLeft->GetSelectEntry(j-1));
+
+ enableButtons();
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::clearListBox(MultiListBox& _rListBox)
+{
+ while(_rListBox.GetEntryCount())
+ _rListBox.RemoveEntry(0);
+ _rListBox.Clear();
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::fillColumns(ListBox* pRight,::std::vector< ::rtl::OUString> &_rRightColumns)
+{
+ sal_uInt16 nCount = pRight->GetEntryCount();
+ _rRightColumns.reserve(nCount);
+ for(sal_uInt16 i=0; i < nCount;++i)
+ _rRightColumns.push_back(pRight->GetEntry(i));
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::createNewColumn( ListBox* _pListbox,
+ OFieldDescription* _pSrcField,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ ::rtl::OUString sConvertedName = m_pParent->convertColumnName(TMultiListBoxEntryFindFunctor(&_rRightColumns,_aCase),
+ _sColumnName,
+ _sExtraChars,
+ _nMaxNameLen);
+ OFieldDescription* pNewField = new OFieldDescription(*_pSrcField);
+ pNewField->SetName(sConvertedName);
+ sal_Bool bNotConvert = sal_True;
+ pNewField->SetType(m_pParent->convertType(_pSrcField->getSpecialTypeInfo(),bNotConvert));
+ if ( !m_pParent->supportsPrimaryKey() )
+ pNewField->SetPrimaryKey(sal_False);
+
+ _pListbox->SetEntryData(_pListbox->InsertEntry(sConvertedName),pNewField);
+ _rRightColumns.push_back(sConvertedName);
+
+ if ( !bNotConvert )
+ m_pParent->showColumnTypeNotSupported(sConvertedName);
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::moveColumn( ListBox* _pRight,
+ ListBox* _pLeft,
+ ::std::vector< ::rtl::OUString>& _rRightColumns,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ if(_pRight == &m_lbNewColumnNames)
+ {
+ // we copy the column into the new format for the dest
+ OFieldDescription* pSrcField = static_cast<OFieldDescription*>(_pLeft->GetEntryData(_pLeft->GetEntryPos(String(_sColumnName))));
+ createNewColumn(_pRight,pSrcField,_rRightColumns,_sColumnName,_sExtraChars,_nMaxNameLen,_aCase);
+ }
+ else
+ {
+ // find the new column in the dest name mapping to obtain the old column
+ OCopyTableWizard::TNameMapping::iterator aIter = ::std::find_if(m_pParent->m_mNameMapping.begin(),m_pParent->m_mNameMapping.end(),
+ ::o3tl::compose1(
+ ::std::bind2nd(_aCase, _sColumnName),
+ ::o3tl::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ OSL_ENSURE(aIter != m_pParent->m_mNameMapping.end(),"Column must be defined");
+ if ( aIter == m_pParent->m_mNameMapping.end() )
+ return; // do nothing
+ const ODatabaseExport::TColumns* pSrcColumns = m_pParent->getSourceColumns();
+ ODatabaseExport::TColumns::const_iterator aSrcIter = pSrcColumns->find((*aIter).first);
+ if ( aSrcIter != pSrcColumns->end() )
+ {
+ // we need also the old position of this column to insert it back on that position again
+ const ODatabaseExport::TColumnVector* pSrcVector = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aPos = ::std::find(pSrcVector->begin(),pSrcVector->end(),aSrcIter);
+ OSL_ENSURE( aPos != pSrcVector->end(),"Invalid position for the iterator here!");
+ ODatabaseExport::TColumnVector::size_type nPos = (aPos - pSrcVector->begin()) - adjustColumnPosition(_pLeft, _sColumnName, (aPos - pSrcVector->begin()), _aCase);
+
+ _pRight->SetEntryData( _pRight->InsertEntry( (*aIter).first, sal::static_int_cast< sal_uInt16 >(nPos)),aSrcIter->second );
+ _rRightColumns.push_back((*aIter).first);
+ m_pParent->removeColumnNameFromNameMap(_sColumnName);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// Simply returning fields back to their original position is
+// not enough. We need to take into acccount what fields have
+// been removed earlier and adjust accordingly. Based on the
+// algorithm employed in moveColumn().
+sal_uInt16 OWizColumnSelect::adjustColumnPosition( ListBox* _pLeft,
+ const ::rtl::OUString& _sColumnName,
+ ODatabaseExport::TColumnVector::size_type nCurrentPos,
+ const ::comphelper::TStringMixEqualFunctor& _aCase)
+{
+ sal_uInt16 nAdjustedPos = 0;
+
+ // if returning all entries to their original position,
+ // then there is no need to adjust the positions.
+ if (m_ibColumns_LH.HasFocus())
+ return nAdjustedPos;
+
+ sal_uInt16 nCount = _pLeft->GetEntryCount();
+ ::rtl::OUString sColumnString;
+ for(sal_uInt16 i=0; i < nCount; ++i)
+ {
+ sColumnString = _pLeft->GetEntry(i);
+ if(_sColumnName != sColumnString)
+ {
+ // find the new column in the dest name mapping to obtain the old column
+ OCopyTableWizard::TNameMapping::iterator aIter = ::std::find_if(m_pParent->m_mNameMapping.begin(),m_pParent->m_mNameMapping.end(),
+ ::o3tl::compose1(
+ ::std::bind2nd(_aCase, sColumnString),
+ ::o3tl::select2nd<OCopyTableWizard::TNameMapping::value_type>())
+ );
+
+ OSL_ENSURE(aIter != m_pParent->m_mNameMapping.end(),"Column must be defined");
+ const ODatabaseExport::TColumns* pSrcColumns = m_pParent->getSourceColumns();
+ ODatabaseExport::TColumns::const_iterator aSrcIter = pSrcColumns->find((*aIter).first);
+ if ( aSrcIter != pSrcColumns->end() )
+ {
+ // we need also the old position of this column to insert it back on that position again
+ const ODatabaseExport::TColumnVector* pSrcVector = m_pParent->getSrcVector();
+ ODatabaseExport::TColumnVector::const_iterator aPos = ::std::find(pSrcVector->begin(),pSrcVector->end(),aSrcIter);
+ ODatabaseExport::TColumnVector::size_type nPos = aPos - pSrcVector->begin();
+ if( nPos < nCurrentPos)
+ {
+ nAdjustedPos++;
+ }
+ }
+ }
+ }
+
+ return nAdjustedPos;
+}
+// -----------------------------------------------------------------------------
+void OWizColumnSelect::enableButtons()
+{
+ sal_Bool bEntries = m_lbNewColumnNames.GetEntryCount() != 0;
+ if(!bEntries)
+ m_pParent->m_mNameMapping.clear();
+
+ m_pParent->GetOKButton().Enable(bEntries);
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,bEntries && m_pParent->getOperation() != CopyTableOperation::AppendData);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
new file mode 100644
index 000000000000..ceb8f6d6745e
--- /dev/null
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -0,0 +1,1693 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "sqlmessage.hxx"
+#include "UITools.hxx"
+#include "WColumnSelect.hxx"
+#include "WCopyTable.hxx"
+#include "WCPage.hxx"
+#include "WExtendPages.hxx"
+#include "WizardPages.hrc"
+#include "WNameMatch.hxx"
+#include "WTypeSelect.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/interaction.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <connectivity/dbexception.hxx>
+
+#include <rtl/logfile.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/lstbox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+
+#include <functional>
+#include <o3tl/compat_functional.hxx>
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace dbtools;
+
+namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+
+#define MAX_PAGES 4 // max. Pages die angezeigt werden
+
+DBG_NAME(OCopyTableWizard)
+namespace
+{
+ //....................................................................
+ void clearColumns(ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColumnsVec)
+ {
+ ODatabaseExport::TColumns::iterator aIter = _rColumns.begin();
+ ODatabaseExport::TColumns::iterator aEnd = _rColumns.end();
+
+ for(;aIter != aEnd;++aIter)
+ delete aIter->second;
+
+ _rColumnsVec.clear();
+ _rColumns.clear();
+ }
+}
+
+//========================================================================
+//= ICopyTableSourceObject
+//========================================================================
+//------------------------------------------------------------------------
+ICopyTableSourceObject::~ICopyTableSourceObject()
+{
+}
+
+//========================================================================
+//= ObjectCopySource
+//========================================================================
+//------------------------------------------------------------------------
+ObjectCopySource::ObjectCopySource( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet >& _rxObject )
+ :m_xConnection( _rxConnection, UNO_SET_THROW )
+ ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
+ ,m_xObject( _rxObject, UNO_SET_THROW )
+ ,m_xObjectPSI( _rxObject->getPropertySetInfo(), UNO_SET_THROW )
+ ,m_xObjectColumns( Reference< XColumnsSupplier >( _rxObject, UNO_QUERY_THROW )->getColumns(), UNO_SET_THROW )
+{
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString ObjectCopySource::getQualifiedObjectName() const
+{
+ ::rtl::OUString sName;
+
+ if ( !m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ sName = ::dbtools::composeTableName( m_xMetaData, m_xObject, ::dbtools::eInDataManipulation, false, false, false );
+ else
+ m_xObject->getPropertyValue( PROPERTY_NAME ) >>= sName;
+ return sName;
+}
+
+//------------------------------------------------------------------------
+bool ObjectCopySource::isView() const
+{
+ bool bIsView = false;
+ try
+ {
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_TYPE ) )
+ {
+ ::rtl::OUString sObjectType;
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_TYPE ) >>= sObjectType );
+ bIsView = sObjectType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VIEW" ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsView;
+}
+
+//------------------------------------------------------------------------
+void ObjectCopySource::copyUISettingsTo( const Reference< XPropertySet >& _rxObject ) const
+{
+ const ::rtl::OUString aCopyProperties[] = {
+ PROPERTY_FONT, PROPERTY_ROW_HEIGHT, PROPERTY_TEXTCOLOR,PROPERTY_TEXTLINECOLOR,PROPERTY_TEXTEMPHASIS,PROPERTY_TEXTRELIEF
+ };
+ for ( size_t i=0; i < SAL_N_ELEMENTS( aCopyProperties ); ++i )
+ {
+ if ( m_xObjectPSI->hasPropertyByName( aCopyProperties[i] ) )
+ _rxObject->setPropertyValue( aCopyProperties[i], m_xObject->getPropertyValue( aCopyProperties[i] ) );
+ }
+}
+//------------------------------------------------------------------------
+void ObjectCopySource::copyFilterAndSortingTo( const Reference< XConnection >& _xConnection,const Reference< XPropertySet >& _rxObject ) const
+{
+ ::std::pair< ::rtl::OUString, ::rtl::OUString > aProperties[] = {
+ ::std::pair< ::rtl::OUString, ::rtl::OUString >(PROPERTY_FILTER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" AND ")))
+ ,::std::pair< ::rtl::OUString, ::rtl::OUString >(PROPERTY_ORDER,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY ")))
+ };
+
+ size_t i = 0;
+
+ try
+ {
+ const String sSourceName = (::dbtools::composeTableNameForSelect(m_xConnection,m_xObject) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+ const ::rtl::OUString sTargetName = ::dbtools::composeTableNameForSelect(_xConnection,_rxObject);
+ const String sTargetNameTemp = (sTargetName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")));
+
+ ::rtl::OUString sStatement(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM "));
+ sStatement += sTargetName;
+ sStatement += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE 0=1"));
+
+
+ for ( i=0; i < SAL_N_ELEMENTS( aProperties ); ++i )
+ {
+ if ( m_xObjectPSI->hasPropertyByName( aProperties[i].first ) )
+ {
+ ::rtl::OUString sFilter;
+ m_xObject->getPropertyValue( aProperties[i].first ) >>= sFilter;
+ if ( sFilter.getLength() )
+ {
+ sStatement += aProperties[i].second;
+ String sReplace = sFilter;
+ sReplace.SearchAndReplace(sSourceName,sTargetNameTemp);
+ sFilter = sReplace;
+ _rxObject->setPropertyValue( aProperties[i].first, makeAny(sFilter) );
+ sStatement += sFilter;
+ }
+ }
+ }
+
+ _xConnection->createStatement()->executeQuery(sStatement);
+
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_APPLYFILTER ) )
+ _rxObject->setPropertyValue( PROPERTY_APPLYFILTER, m_xObject->getPropertyValue( PROPERTY_APPLYFILTER ) );
+ }
+ catch(Exception&)
+ {
+ }
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ObjectCopySource::getColumnNames() const
+{
+ return m_xObjectColumns->getElementNames();
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ObjectCopySource::getPrimaryKeyColumnNames() const
+{
+ const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(m_xObject);
+ Sequence< ::rtl::OUString > aKeyColNames;
+ if ( xPrimaryKeyColumns.is() )
+ aKeyColNames = xPrimaryKeyColumns->getElementNames();
+ return aKeyColNames;
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* ObjectCopySource::createFieldDescription( const ::rtl::OUString& _rColumnName ) const
+{
+ Reference< XPropertySet > xColumn( m_xObjectColumns->getByName( _rColumnName ), UNO_QUERY_THROW );
+ return new OFieldDescription( xColumn );
+}
+//------------------------------------------------------------------------
+::rtl::OUString ObjectCopySource::getSelectStatement() const
+{
+ ::rtl::OUString sSelectStatement;
+ if ( m_xObjectPSI->hasPropertyByName( PROPERTY_COMMAND ) )
+ { // query
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sSelectStatement );
+ }
+ else
+ { // table
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.appendAscii( "SELECT " );
+
+ // we need to create the sql stmt with column names
+ // otherwise it is possible that names don't match
+ const ::rtl::OUString sQuote = m_xMetaData->getIdentifierQuoteString();
+
+ Sequence< ::rtl::OUString > aColumnNames = getColumnNames();
+ const ::rtl::OUString* pColumnName = aColumnNames.getConstArray();
+ const ::rtl::OUString* pEnd = pColumnName + aColumnNames.getLength();
+ for ( ; pColumnName != pEnd; )
+ {
+ aSQL.append( ::dbtools::quoteName( sQuote, *pColumnName++ ) );
+
+ if ( pColumnName == pEnd )
+ aSQL.appendAscii( " " );
+ else
+ aSQL.appendAscii( ", " );
+ }
+
+ aSQL.appendAscii( "FROM " );
+ aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_xObject ) );
+
+ sSelectStatement = aSQL.makeStringAndClear();
+ }
+
+ return sSelectStatement;
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > ObjectCopySource::getPreparedSelectStatement() const
+{
+ ::utl::SharedUNOComponent< XPreparedStatement > xStatement(
+ m_xConnection->prepareStatement( getSelectStatement() ),
+ ::utl::SharedUNOComponent< XPreparedStatement >::TakeOwnership
+ );
+ return xStatement;
+}
+
+//========================================================================
+//= NamedTableCopySource
+//========================================================================
+//------------------------------------------------------------------------
+NamedTableCopySource::NamedTableCopySource( const Reference< XConnection >& _rxConnection, const ::rtl::OUString& _rTableName )
+ :m_xConnection( _rxConnection, UNO_SET_THROW )
+ ,m_xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW )
+ ,m_sTableName( _rTableName )
+ ,m_aColumnInfo()
+{
+ ::dbtools::qualifiedNameComponents( m_xMetaData, m_sTableName, m_sTableCatalog, m_sTableSchema, m_sTableBareName, ::dbtools::eComplete );
+ impl_ensureColumnInfo_throw();
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString NamedTableCopySource::getQualifiedObjectName() const
+{
+ return m_sTableName;
+}
+
+//------------------------------------------------------------------------
+bool NamedTableCopySource::isView() const
+{
+ ::rtl::OUString sTableType;
+ try
+ {
+ Reference< XResultSet > xTableDesc( m_xMetaData->getTables( makeAny( m_sTableCatalog ), m_sTableSchema, m_sTableBareName,
+ Sequence< ::rtl::OUString >() ) );
+ Reference< XRow > xTableDescRow( xTableDesc, UNO_QUERY_THROW );
+ OSL_VERIFY( xTableDesc->next() );
+ sTableType = xTableDescRow->getString( 4 );
+ OSL_ENSURE( !xTableDescRow->wasNull(), "NamedTableCopySource::isView: invalid table type!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sTableType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VIEW" ) );
+}
+
+//------------------------------------------------------------------------
+void NamedTableCopySource::copyUISettingsTo( const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+ // not supported: we do not have UI settings to copy
+}
+// -----------------------------------------------------------------------------
+void NamedTableCopySource::copyFilterAndSortingTo( const Reference< XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
+//------------------------------------------------------------------------
+void NamedTableCopySource::impl_ensureColumnInfo_throw()
+{
+ if ( !m_aColumnInfo.empty() )
+ return;
+
+ Reference< XResultSetMetaDataSupplier > xStatementMetaSupp( impl_ensureStatement_throw().getTyped(), UNO_QUERY_THROW );
+ Reference< XResultSetMetaData > xStatementMeta( xStatementMetaSupp->getMetaData(), UNO_SET_THROW );
+
+ sal_Int32 nColCount( xStatementMeta->getColumnCount() );
+ for ( sal_Int32 i = 1; i <= nColCount; ++i )
+ {
+ OFieldDescription aDesc;
+
+ aDesc.SetName( xStatementMeta->getColumnName( i ) );
+ aDesc.SetHelpText( xStatementMeta->getColumnLabel( i ) );
+ aDesc.SetTypeValue( xStatementMeta->getColumnType( i ) );
+ aDesc.SetTypeName( xStatementMeta->getColumnTypeName( i ) );
+ aDesc.SetPrecision( xStatementMeta->getPrecision( i ) );
+ aDesc.SetScale( xStatementMeta->getScale( i ) );
+ aDesc.SetIsNullable( xStatementMeta->isNullable( i ) );
+ aDesc.SetCurrency( xStatementMeta->isCurrency( i ) );
+ aDesc.SetAutoIncrement( xStatementMeta->isAutoIncrement( i ) );
+
+ m_aColumnInfo.push_back( aDesc );
+ }
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > NamedTableCopySource::impl_ensureStatement_throw()
+{
+ if ( !m_xStatement.is() )
+ m_xStatement.set( m_xConnection->prepareStatement( getSelectStatement() ), UNO_SET_THROW );
+ return m_xStatement;
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > NamedTableCopySource::getColumnNames() const
+{
+ Sequence< ::rtl::OUString > aNames( m_aColumnInfo.size() );
+ for ( ::std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
+ col != m_aColumnInfo.end();
+ ++col
+ )
+ aNames[ col - m_aColumnInfo.begin() ] = col->GetName();
+
+ return aNames;
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > NamedTableCopySource::getPrimaryKeyColumnNames() const
+{
+ Sequence< ::rtl::OUString > aPKColNames;
+
+ try
+ {
+ Reference< XResultSet > xPKDesc( m_xMetaData->getPrimaryKeys( makeAny( m_sTableCatalog ), m_sTableSchema, m_sTableBareName ) );
+ Reference< XRow > xPKDescRow( xPKDesc, UNO_QUERY_THROW );
+ while ( xPKDesc->next() )
+ {
+ sal_Int32 len( aPKColNames.getLength() );
+ aPKColNames.realloc( len + 1 );
+ aPKColNames[ len ] = xPKDescRow->getString( 4 ); // COLUMN_NAME
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aPKColNames;
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* NamedTableCopySource::createFieldDescription( const ::rtl::OUString& _rColumnName ) const
+{
+ for ( ::std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
+ col != m_aColumnInfo.end();
+ ++col
+ )
+ if ( col->GetName() == _rColumnName )
+ return new OFieldDescription( *col );
+
+ return NULL;
+}
+//------------------------------------------------------------------------
+::rtl::OUString NamedTableCopySource::getSelectStatement() const
+{
+ ::rtl::OUStringBuffer aSQL;
+ aSQL.appendAscii( "SELECT * FROM " );
+
+ aSQL.append( ::dbtools::composeTableNameForSelect( m_xConnection, m_sTableCatalog, m_sTableSchema, m_sTableBareName ) );
+
+ return aSQL.makeStringAndClear();
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > NamedTableCopySource::getPreparedSelectStatement() const
+{
+ return const_cast< NamedTableCopySource* >( this )->impl_ensureStatement_throw();
+}
+
+// ========================================================
+// DummyCopySource
+// ========================================================
+class DummyCopySource : public ICopyTableSourceObject
+{
+public:
+ DummyCopySource() { }
+
+ static const DummyCopySource& Instance();
+
+ // ICopyTableSourceObject overridables
+ virtual ::rtl::OUString getQualifiedObjectName() const;
+ virtual bool isView() const;
+ virtual void copyUISettingsTo( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual void copyFilterAndSortingTo(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject ) const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getColumnNames() const;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getPrimaryKeyColumnNames() const;
+ virtual OFieldDescription* createFieldDescription( const ::rtl::OUString& _rColumnName ) const;
+ virtual ::rtl::OUString getSelectStatement() const;
+ virtual ::utl::SharedUNOComponent< XPreparedStatement >
+ getPreparedSelectStatement() const;
+};
+
+//------------------------------------------------------------------------
+const DummyCopySource& DummyCopySource::Instance()
+{
+ static DummyCopySource s_aTheInstance;
+ return s_aTheInstance;
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString DummyCopySource::getQualifiedObjectName() const
+{
+ OSL_FAIL( "DummyCopySource::getQualifiedObjectName: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+bool DummyCopySource::isView() const
+{
+ OSL_FAIL( "DummyCopySource::isView: not to be called!" );
+ return false;
+}
+
+//------------------------------------------------------------------------
+void DummyCopySource::copyUISettingsTo( const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+ // no support
+}
+// -----------------------------------------------------------------------------
+void DummyCopySource::copyFilterAndSortingTo( const Reference< XConnection >& ,const Reference< XPropertySet >& /*_rxObject*/ ) const
+{
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > DummyCopySource::getColumnNames() const
+{
+ return Sequence< ::rtl::OUString >();
+}
+
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > DummyCopySource::getPrimaryKeyColumnNames() const
+{
+ OSL_FAIL( "DummyCopySource::getPrimaryKeyColumnNames: not to be called!" );
+ return Sequence< ::rtl::OUString >();
+}
+
+//------------------------------------------------------------------------
+OFieldDescription* DummyCopySource::createFieldDescription( const ::rtl::OUString& /*_rColumnName*/ ) const
+{
+ OSL_FAIL( "DummyCopySource::createFieldDescription: not to be called!" );
+ return NULL;
+}
+//------------------------------------------------------------------------
+::rtl::OUString DummyCopySource::getSelectStatement() const
+{
+ OSL_FAIL( "DummyCopySource::getSelectStatement: not to be called!" );
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > DummyCopySource::getPreparedSelectStatement() const
+{
+ OSL_FAIL( "DummyCopySource::getPreparedSelectStatement: not to be called!" );
+ return ::utl::SharedUNOComponent< XPreparedStatement >();
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ bool lcl_canCreateViewFor_nothrow( const Reference< XConnection >& _rxConnection )
+ {
+ Reference< XViewsSupplier > xSup( _rxConnection, UNO_QUERY );
+ Reference< XDataDescriptorFactory > xViewFac;
+ if ( xSup.is() )
+ xViewFac.set( xSup->getViews(), UNO_QUERY );
+ return xViewFac.is();
+ }
+
+ bool lcl_sameConnection_throw( const Reference< XConnection >& _rxLHS, const Reference< XConnection >& _rxRHS )
+ {
+ Reference< XDatabaseMetaData > xMetaLHS( _rxLHS->getMetaData(), UNO_QUERY_THROW );
+ Reference< XDatabaseMetaData > xMetaRHS( _rxRHS->getMetaData(), UNO_QUERY_THROW );
+ return xMetaLHS->getURL().equals( xMetaRHS->getURL() );
+ }
+}
+
+//========================================================================
+//= OCopyTableWizard
+//========================================================================
+//------------------------------------------------------------------------
+OCopyTableWizard::OCopyTableWizard( Window * pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation,
+ const ICopyTableSourceObject& _rSourceObject, const Reference< XConnection >& _xSourceConnection,
+ const Reference< XConnection >& _xConnection, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XInteractionHandler>& _xInteractionHandler)
+ : WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE))
+ ,m_pbHelp( this , ModuleRes(PB_HELP))
+ ,m_pbCancel( this , ModuleRes(PB_CANCEL))
+ ,m_pbPrev( this , ModuleRes(PB_PREV))
+ ,m_pbNext( this , ModuleRes(PB_NEXT))
+ ,m_pbFinish( this , ModuleRes(PB_OK))
+ ,m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
+ ,m_xDestConnection( _xConnection )
+ ,m_rSourceObject( _rSourceObject )
+ ,m_xFormatter( getNumberFormatter( _xConnection, _rxORB ) )
+ ,m_xFactory(_rxORB)
+ ,m_xInteractionHandler(_xInteractionHandler)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_nPageCount(0)
+ ,m_bDeleteSourceColumns(sal_True)
+ ,m_bInterConnectionCopy( _xSourceConnection != _xConnection )
+ ,m_sName( _rDefaultName )
+ ,m_nOperation( _nOperation )
+ ,m_ePressed( WIZARD_NONE )
+ ,m_bCreatePrimaryKeyColumn(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::OCopyTableWizard" );
+ DBG_CTOR(OCopyTableWizard,NULL);
+ construct();
+
+ // extract table name
+ ::rtl::OUString sInitialTableName( _rDefaultName );
+ try
+ {
+ m_sSourceName = m_rSourceObject.getQualifiedObjectName();
+ OSL_ENSURE( m_sSourceName.getLength() > 0, "OCopyTableWizard::OCopyTableWizard: unable to retrieve the source object's name!" );
+
+ if ( !sInitialTableName.getLength() )
+ sInitialTableName = m_sSourceName;
+
+ if ( !m_sName.getLength() )
+ {
+ if ( _xSourceConnection == m_xDestConnection )
+ {
+ Reference< XTablesSupplier > xSup( m_xDestConnection, UNO_QUERY_THROW );
+ m_sName = ::dbtools::createUniqueName( xSup->getTables(), sInitialTableName, sal_False );
+ }
+ else
+ m_sName = sInitialTableName;
+ }
+ }
+ catch ( const Exception& )
+ {
+ m_sName = sInitialTableName;
+ }
+
+ ::dbaui::fillTypeInfo( _xSourceConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
+ ::dbaui::fillTypeInfo( m_xDestConnection, m_sTypeNames, m_aDestTypeInfo, m_aDestTypeInfoIndex );
+ impl_loadSourceData();
+
+ bool bAllowViews = true;
+ // if the source is a, don't allow creating views
+ if ( m_rSourceObject.isView() )
+ bAllowViews = false;
+ // no views if the target connection does not support creating them
+ if ( !lcl_canCreateViewFor_nothrow( m_xDestConnection ) )
+ bAllowViews = false;
+ // no views if we're copying to a different database
+ if ( !lcl_sameConnection_throw( _xSourceConnection, m_xDestConnection ) )
+ bAllowViews = false;
+
+ if ( m_bInterConnectionCopy )
+ {
+ Reference< XDatabaseMetaData > xSrcMeta = _xSourceConnection->getMetaData();
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ ::dbtools::qualifiedNameComponents( xSrcMeta,
+ m_sName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ m_sName = ::dbtools::composeTableName(m_xDestConnection->getMetaData(),sCatalog,sSchema,sTable,sal_False,::dbtools::eInTableDefinitions);
+ }
+
+ OCopyTable* pPage1( new OCopyTable( this ) );
+ pPage1->disallowUseHeaderLine();
+ if ( !bAllowViews )
+ pPage1->disallowViews();
+ pPage1->setCreateStyleAction();
+ AddWizardPage(pPage1);
+
+ AddWizardPage( new OWizNameMatching( this ) );
+ AddWizardPage( new OWizColumnSelect( this ) );
+ AddWizardPage( new OWizNormalExtend( this ) );
+ ActivatePage();
+}
+
+// -----------------------------------------------------------------------------
+OCopyTableWizard::OCopyTableWizard( Window* pParent, const ::rtl::OUString& _rDefaultName, sal_Int16 _nOperation,
+ const ODatabaseExport::TColumns& _rSourceColumns, const ODatabaseExport::TColumnVector& _rSourceColVec,
+ const Reference< XConnection >& _xConnection, const Reference< XNumberFormatter >& _xFormatter,
+ TypeSelectionPageFactory _pTypeSelectionPageFactory, SvStream& _rTypeSelectionPageArg, const Reference< XMultiServiceFactory >& _rM )
+ :WizardDialog( pParent, ModuleRes(WIZ_RTFCOPYTABLE))
+ ,m_vSourceColumns(_rSourceColumns)
+ ,m_pbHelp( this , ModuleRes(PB_HELP))
+ ,m_pbCancel( this , ModuleRes(PB_CANCEL))
+ ,m_pbPrev( this , ModuleRes(PB_PREV))
+ ,m_pbNext( this , ModuleRes(PB_NEXT))
+ ,m_pbFinish( this , ModuleRes(PB_OK))
+ ,m_mNameMapping(_xConnection->getMetaData().is() && _xConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers())
+ ,m_xDestConnection( _xConnection )
+ ,m_rSourceObject( DummyCopySource::Instance() )
+ ,m_xFormatter(_xFormatter)
+ ,m_xFactory(_rM)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_nPageCount(0)
+ ,m_bDeleteSourceColumns(sal_False)
+ ,m_bInterConnectionCopy( false )
+ ,m_sName(_rDefaultName)
+ ,m_nOperation( _nOperation )
+ ,m_ePressed( WIZARD_NONE )
+ ,m_bCreatePrimaryKeyColumn(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::OCopyTableWizard" );
+ DBG_CTOR(OCopyTableWizard,NULL);
+ construct();
+ ODatabaseExport::TColumnVector::const_iterator aIter = _rSourceColVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _rSourceColVec.end();
+ for (; aIter != aEnd ; ++aIter)
+ {
+ m_vSourceVec.push_back(m_vSourceColumns.find((*aIter)->first));
+ }
+
+ ::dbaui::fillTypeInfo( _xConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
+ ::dbaui::fillTypeInfo( _xConnection, m_sTypeNames, m_aDestTypeInfo, m_aDestTypeInfoIndex );
+
+ m_xInteractionHandler.set( m_xFactory->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY);
+
+ OCopyTable* pPage1( new OCopyTable( this ) );
+ pPage1->disallowViews();
+ pPage1->setCreateStyleAction();
+ AddWizardPage( pPage1 );
+
+ AddWizardPage( new OWizNameMatching( this ) );
+ AddWizardPage( new OWizColumnSelect( this ) );
+ AddWizardPage( (*_pTypeSelectionPageFactory)( this, _rTypeSelectionPageArg ) );
+
+ ActivatePage();
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::construct" );
+ AddButton( &m_pbHelp, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbCancel, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbPrev );
+ AddButton( &m_pbNext, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &m_pbFinish );
+
+ m_pbPrev.SetClickHdl( LINK( this, OCopyTableWizard, ImplPrevHdl ) );
+ m_pbNext.SetClickHdl( LINK( this, OCopyTableWizard, ImplNextHdl ) );
+ m_pbFinish.SetClickHdl( LINK( this, OCopyTableWizard, ImplOKHdl ) );
+
+ SetActivatePageHdl( LINK( this, OCopyTableWizard, ImplActivateHdl ) );
+
+ SetPrevButton( &m_pbPrev );
+ SetNextButton( &m_pbNext );
+
+ ShowButtonFixedLine( sal_True );
+
+ m_pbNext.GrabFocus();
+
+ if (m_vDestColumns.size())
+ // source is a html or rtf table
+ m_pbNext.SetStyle(m_pbFinish.GetStyle() | WB_DEFBUTTON);
+ else
+ m_pbFinish.SetStyle(m_pbFinish.GetStyle() | WB_DEFBUTTON);
+
+ FreeResource();
+
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+ m_bAddPKFirstTime = sal_True;
+}
+//------------------------------------------------------------------------
+OCopyTableWizard::~OCopyTableWizard()
+{
+ DBG_DTOR(OCopyTableWizard,NULL);
+ for ( ;; )
+ {
+ TabPage *pPage = GetPage(0);
+ if ( pPage == NULL )
+ break;
+ RemovePage( pPage );
+ delete pPage;
+ }
+
+ if ( m_bDeleteSourceColumns )
+ clearColumns(m_vSourceColumns,m_vSourceVec);
+
+ clearColumns(m_vDestColumns,m_aDestVec);
+
+ // clear the type information
+ m_aTypeInfoIndex.clear();
+ m_aTypeInfo.clear();
+ m_aDestTypeInfoIndex.clear();
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplPrevHdl, PushButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_PREV;
+ if ( GetCurLevel() )
+ {
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ if(GetCurLevel() == 2)
+ ShowPage(GetCurLevel()-2);
+ else
+ ShowPrevPage();
+ }
+ else
+ ShowPrevPage();
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( OCopyTableWizard, ImplNextHdl, PushButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_NEXT;
+ if ( GetCurLevel() < MAX_PAGES )
+ {
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ if(GetCurLevel() == 0)
+ ShowPage(GetCurLevel()+2);
+ else
+ ShowNextPage();
+ }
+ else
+ ShowNextPage();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------
+sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::CheckColumns" );
+ sal_Bool bRet = sal_True;
+ m_vColumnPos.clear();
+ m_vColumnTypes.clear();
+
+ OSL_ENSURE( m_xDestConnection.is(), "OCopyTableWizard::CheckColumns: No connection!" );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenbank PrimaryKeys verarbeiten kann, PrimaryKey anlegen
+ if ( m_xDestConnection.is() )
+ {
+ sal_Bool bPKeyAllowed = supportsPrimaryKey();
+
+ sal_Bool bContainsColumns = !m_vDestColumns.empty();
+
+ if ( bPKeyAllowed && shouldCreatePrimaryKey() )
+ {
+ // add extra column for the primary key
+ TOTypeInfoSP pTypeInfo = queryPrimaryKeyType(m_aDestTypeInfo);
+ if ( pTypeInfo.get() )
+ {
+ if ( m_bAddPKFirstTime )
+ {
+ OFieldDescription* pField = new OFieldDescription();
+ pField->SetName(m_aKeyName);
+ pField->FillFromTypeInfo(pTypeInfo,sal_True,sal_True);
+ pField->SetPrimaryKey(sal_True);
+ m_bAddPKFirstTime = sal_False;
+ insertColumn(0,pField);
+ }
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(1,1));
+ m_vColumnTypes.push_back(pTypeInfo->nType);
+ }
+ }
+
+ if ( bContainsColumns )
+ { // we have dest columns so look for the matching column
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
+ for(;aSrcIter != aSrcEnd;++aSrcIter)
+ {
+ ODatabaseExport::TColumns::iterator aDestIter = m_vDestColumns.find(m_mNameMapping[(*aSrcIter)->first]);
+
+ if ( aDestIter != m_vDestColumns.end() )
+ {
+ ODatabaseExport::TColumnVector::const_iterator aFind = ::std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
+ sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(nPos,nPos));
+ m_vColumnTypes.push_back((*aFind)->second->GetType());
+ }
+ else
+ {
+ m_vColumnPos.push_back( ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
+ m_vColumnTypes.push_back(0);
+ }
+ }
+ }
+ else
+ {
+ Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData() );
+ ::rtl::OUString sExtraChars = xMetaData->getExtraNameCharacters();
+ sal_Int32 nMaxNameLen = getMaxColumnNameLength();
+
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
+ for(_rnBreakPos=0;aSrcIter != aSrcEnd && bRet ;++aSrcIter,++_rnBreakPos)
+ {
+ OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second);
+ pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen));
+ TOTypeInfoSP pType = convertType((*aSrcIter)->second->getSpecialTypeInfo(),bRet);
+ pField->SetType(pType);
+ if ( !bPKeyAllowed )
+ pField->SetPrimaryKey(sal_False);
+
+ // now create a column
+ insertColumn(m_vDestColumns.size(),pField);
+ m_vColumnPos.push_back(ODatabaseExport::TPositions::value_type(m_vDestColumns.size(),m_vDestColumns.size()));
+ m_vColumnTypes.push_back((*aSrcIter)->second->GetType());
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplOKHdl, OKButton*, EMPTYARG )
+{
+ m_ePressed = WIZARD_FINISH;
+ sal_Bool bFinish = DeactivatePage() != 0;
+
+ if(bFinish)
+ {
+ WaitObject aWait(this);
+ switch(getOperation())
+ {
+ case CopyTableOperation::CopyDefinitionAndData:
+ case CopyTableOperation::CopyDefinitionOnly:
+ {
+ sal_Bool bOnFirstPage = GetCurLevel() == 0;
+ if ( bOnFirstPage )
+ {
+ // we came from the first page so we have to clear
+ // all column information already collected
+ clearDestColumns();
+ m_mNameMapping.clear();
+ }
+ sal_Int32 nBreakPos = 0;
+ sal_Bool bCheckOk = CheckColumns(nBreakPos);
+ if ( bOnFirstPage && !bCheckOk )
+ {
+ showColumnTypeNotSupported(m_vSourceVec[nBreakPos-1]->first);
+ OWizTypeSelect* pPage = static_cast<OWizTypeSelect*>(GetPage(3));
+ if ( pPage )
+ {
+ m_mNameMapping.clear();
+ pPage->setDisplayRow(nBreakPos);
+ ShowPage(3);
+ return 0;
+ }
+ }
+ if ( m_xDestConnection.is() )
+ {
+ if ( supportsPrimaryKey() )
+ {
+ ODatabaseExport::TColumns::iterator aFind = ::std::find_if(m_vDestColumns.begin(),m_vDestColumns.end()
+ ,::o3tl::compose1(::std::mem_fun(&OFieldDescription::IsPrimaryKey),::o3tl::select2nd<ODatabaseExport::TColumns::value_type>()));
+ if ( aFind == m_vDestColumns.end() && m_xInteractionHandler.is() )
+ {
+
+ String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+ String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+ SQLContext aError;
+ aError.Message = sMsg;
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) );
+ ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove;
+ xRequest->addContinuation( xYes.get() );
+ xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
+ ::rtl::Reference< ::comphelper::OInteractionAbort > xAbort = new ::comphelper::OInteractionAbort;
+ xRequest->addContinuation( xAbort.get() );
+
+ m_xInteractionHandler->handle( xRequest.get() );
+
+ if ( xYes->wasSelected() )
+ {
+ OCopyTable* pPage = static_cast<OCopyTable*>(GetPage(0));
+ m_bCreatePrimaryKeyColumn = sal_True;
+ m_aKeyName = pPage->GetKeyName();
+ if ( !m_aKeyName.getLength() )
+ m_aKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) );
+ m_aKeyName = createUniqueName( m_aKeyName );
+ sal_Int32 nBreakPos2 = 0;
+ CheckColumns(nBreakPos2);
+ }
+ else if ( xAbort->wasSelected() )
+ {
+ ShowPage(3);
+ return 0;
+ }
+ }
+ }
+ }
+ break;
+ }
+ case CopyTableOperation::AppendData:
+ case CopyTableOperation::CreateAsView:
+ break;
+ default:
+ {
+ OSL_FAIL("OCopyTableWizard::ImplOKHdl: invalid creation style!");
+ }
+ }
+
+ EndDialog(RET_OK);
+ }
+ return bFinish;
+}
+//------------------------------------------------------------------------
+sal_Bool OCopyTableWizard::shouldCreatePrimaryKey() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::shouldCreatePrimaryKey" );
+ return m_bCreatePrimaryKeyColumn;
+}
+
+// -----------------------------------------------------------------------
+void OCopyTableWizard::setCreatePrimaryKey( bool _bDoCreate, const ::rtl::OUString& _rSuggestedName )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::setCreatePrimaryKey" );
+ m_bCreatePrimaryKeyColumn = _bDoCreate;
+ if ( _rSuggestedName.getLength() )
+ m_aKeyName = _rSuggestedName;
+
+ OCopyTable* pSettingsPage = dynamic_cast< OCopyTable* >( GetPage( 0 ) );
+ OSL_ENSURE( pSettingsPage, "OCopyTableWizard::setCreatePrimaryKey: page should have been added in the ctor!" );
+ if ( pSettingsPage )
+ pSettingsPage->setCreatePrimaryKey( _bDoCreate, _rSuggestedName );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( OCopyTableWizard, ImplActivateHdl, WizardDialog*, EMPTYARG )
+{
+ OWizardPage* pCurrent = (OWizardPage*)GetPage(GetCurLevel());
+ if(pCurrent)
+ {
+ sal_Bool bFirstTime = pCurrent->IsFirstTime();
+ if(bFirstTime)
+ pCurrent->Reset();
+
+ CheckButtons();
+
+ SetText(pCurrent->GetTitle());
+
+ Invalidate();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::CheckButtons()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::CheckButtons" );
+ if(GetCurLevel() == 0) // the first page has no back button
+ {
+ if(m_nPageCount > 1)
+ m_pbNext.Enable(sal_True);
+ else
+ m_pbNext.Enable(sal_False);
+
+ m_pbPrev.Enable(sal_False);
+ }
+ else if(GetCurLevel() == m_nPageCount-1) // the last page has no next button
+ {
+ m_pbNext.Enable(sal_False);
+ m_pbPrev.Enable(sal_True);
+ }
+ else
+ {
+ m_pbPrev.Enable(sal_True);
+ // next already has its state
+ }
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::EnableButton(Wizard_Button_Style eStyle,sal_Bool bEnable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::EnableButton" );
+ Button* pButton;
+ if(eStyle == WIZARD_NEXT)
+ pButton = &m_pbNext;
+ else if(eStyle == WIZARD_PREV)
+ pButton = &m_pbPrev;
+ else
+ pButton = &m_pbFinish;
+ pButton->Enable(bEnable);
+
+}
+// -----------------------------------------------------------------------
+long OCopyTableWizard::DeactivatePage()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::DeactivatePage" );
+ OWizardPage* pPage = (OWizardPage*)GetPage(GetCurLevel());
+ return pPage ? pPage->LeavePage() : sal_False;
+}
+// -----------------------------------------------------------------------
+void OCopyTableWizard::AddWizardPage(OWizardPage* pPage)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::AddWizardPage" );
+ AddPage(pPage);
+ ++m_nPageCount;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::insertColumn(sal_Int32 _nPos,OFieldDescription* _pField)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::insertColumn" );
+ OSL_ENSURE(_pField,"FieldDescrioption is null!");
+ if ( _pField )
+ {
+ ODatabaseExport::TColumns::iterator aFind = m_vDestColumns.find(_pField->GetName());
+ if ( aFind != m_vDestColumns.end() )
+ {
+ delete aFind->second;
+ m_vDestColumns.erase(aFind);
+ }
+
+ m_aDestVec.insert(m_aDestVec.begin() + _nPos,
+ m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first);
+ m_mNameMapping[_pField->GetName()] = _pField->GetName();
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,const ::rtl::OUString& _sOldName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::replaceColumn" );
+ OSL_ENSURE(_pField,"FieldDescrioption is null!");
+ if ( _pField )
+ {
+ m_vDestColumns.erase(_sOldName);
+ OSL_ENSURE( m_vDestColumns.find(_pField->GetName()) == m_vDestColumns.end(),"Column with that name already exist!");
+
+ m_aDestVec[_nPos] =
+ m_vDestColumns.insert(ODatabaseExport::TColumns::value_type(_pField->GetName(),_pField)).first;
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::impl_loadSourceData()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::impl_loadSourceData" );
+ loadData( m_rSourceObject, m_vSourceColumns, m_vSourceVec );
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::loadData( const ICopyTableSourceObject& _rSourceObject, ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColVector )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::loadData" );
+ ODatabaseExport::TColumns::iterator colEnd = _rColumns.end();
+ for ( ODatabaseExport::TColumns::iterator col = _rColumns.begin(); col != colEnd; ++col )
+ delete col->second;
+
+ _rColVector.clear();
+ _rColumns.clear();
+
+ OFieldDescription* pActFieldDescr = NULL;
+ String aType;
+ ::rtl::OUString sCreateParam(RTL_CONSTASCII_USTRINGPARAM("x"));
+ //////////////////////////////////////////////////////////////////////
+ // ReadOnly-Flag
+ // Bei Drop darf keine Zeile editierbar sein.
+ // Bei Add duerfen nur die leeren Zeilen editierbar sein.
+ // Bei Add und Drop koennen alle Zeilen editiert werden.
+ Sequence< ::rtl::OUString > aColumns( _rSourceObject.getColumnNames() );
+ const ::rtl::OUString* pColumn = aColumns.getConstArray();
+ const ::rtl::OUString* pColumnEnd = pColumn + aColumns.getLength();
+
+ for ( ; pColumn != pColumnEnd; ++pColumn )
+ {
+ // get the properties of the column
+ pActFieldDescr = _rSourceObject.createFieldDescription( *pColumn );
+ OSL_ENSURE( pActFieldDescr, "OCopyTableWizard::loadData: illegal field description!" );
+ if ( !pActFieldDescr )
+ continue;
+
+ sal_Int32 nType = pActFieldDescr->GetType();
+ sal_Int32 nScale = pActFieldDescr->GetScale();
+ sal_Int32 nPrecision = pActFieldDescr->GetPrecision();
+ sal_Bool bAutoIncrement = pActFieldDescr->IsAutoIncrement();
+ ::rtl::OUString sTypeName = pActFieldDescr->GetTypeName();
+
+ // search for type
+ sal_Bool bForce;
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
+ if ( !pTypeInfo.get() )
+ pTypeInfo = m_pTypeInfo;
+
+ pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False);
+ _rColVector.push_back(_rColumns.insert(ODatabaseExport::TColumns::value_type(pActFieldDescr->GetName(),pActFieldDescr)).first);
+ }
+
+ // determine which coumns belong to the primary key
+ Sequence< ::rtl::OUString > aPrimaryKeyColumns( _rSourceObject.getPrimaryKeyColumnNames() );
+ const ::rtl::OUString* pKeyColName = aPrimaryKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyColEnd = pKeyColName + aPrimaryKeyColumns.getLength();
+
+ for( ; pKeyColName != pKeyColEnd; ++pKeyColName )
+ {
+ ODatabaseExport::TColumns::iterator keyPos = _rColumns.find( *pKeyColName );
+ if ( keyPos != _rColumns.end() )
+ {
+ keyPos->second->SetPrimaryKey( sal_True );
+ keyPos->second->SetIsNullable( ColumnValue::NO_NULLS );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::clearDestColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::clearDestColumns" );
+ clearColumns(m_vDestColumns,m_aDestVec);
+ m_bAddPKFirstTime = sal_True;
+ m_mNameMapping.clear();
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::appendColumns( Reference<XColumnsSupplier>& _rxColSup, const ODatabaseExport::TColumnVector* _pVec, sal_Bool _bKeyColumns) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::appendColumns" );
+ // now append the columns
+ OSL_ENSURE(_rxColSup.is(),"No columns supplier");
+ if(!_rxColSup.is())
+ return;
+ Reference<XNameAccess> xColumns = _rxColSup->getColumns();
+ OSL_ENSURE(xColumns.is(),"No columns");
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ ODatabaseExport::TColumnVector::const_iterator aIter = _pVec->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _pVec->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pField = (*aIter)->second;
+ if(!pField)
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(pField->IsPrimaryKey() || !_bKeyColumns)
+ xColumn = xColumnFactory->createDataDescriptor();
+ if(xColumn.is())
+ {
+ if(!_bKeyColumns)
+ dbaui::setColumnProperties(xColumn,pField);
+ else
+ xColumn->setPropertyValue(PROPERTY_NAME,makeAny(pField->GetName()));
+
+ xAppend->appendByDescriptor(xColumn);
+ xColumn = NULL;
+ // now only the settings are missing
+ if(xColumns->hasByName(pField->GetName()))
+ {
+ xColumn.set(xColumns->getByName(pField->GetName()),UNO_QUERY);
+ OSL_ENSURE(xColumn.is(),"OCopyTableWizard::appendColumns: Column is NULL!");
+ if ( xColumn.is() )
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_FAIL("OCopyTableWizard::appendColumns: invalid field name!");
+ }
+
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::appendKey( Reference<XKeysSupplier>& _rxSup, const ODatabaseExport::TColumnVector* _pVec) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::appendKey" );
+ if(!_rxSup.is())
+ return; // the database doesn't support keys
+ OSL_ENSURE(_rxSup.is(),"No XKeysSupplier!");
+ Reference<XDataDescriptorFactory> xKeyFactory(_rxSup->getKeys(),UNO_QUERY);
+ OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
+ if ( !xKeyFactory.is() )
+ return;
+ Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
+ OSL_ENSURE(xKey.is(),"Key is null!");
+ xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::PRIMARY));
+
+ Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
+ if(xColSup.is())
+ {
+ appendColumns(xColSup,_pVec,sal_True);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ if(xColumns.is() && xColumns->getElementNames().getLength())
+ xAppend->appendByDescriptor(xKey);
+ }
+
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OCopyTableWizard::createView() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createView" );
+ ::rtl::OUString sCommand( m_rSourceObject.getSelectStatement() );
+ OSL_ENSURE( sCommand.getLength(), "OCopyTableWizard::createView: no statement in the source object!" );
+ // there are legitimate cases in which getSelectStatement does not provide a statement,
+ // but in all those cases, this method here should never be called.
+ return ::dbaui::createView( m_sName, m_xDestConnection, sCommand );
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OCopyTableWizard::createTable()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createTable" );
+ Reference< XPropertySet > xTable;
+
+ Reference<XTablesSupplier> xSup( m_xDestConnection, UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if(xSup.is())
+ xTables = xSup->getTables();
+ if ( getOperation() != CopyTableOperation::AppendData )
+ {
+ Reference<XDataDescriptorFactory> xFact(xTables,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"No XDataDescriptorFactory available!");
+ if(!xFact.is())
+ return NULL;
+
+ xTable = xFact->createDataDescriptor();
+ OSL_ENSURE(xTable.is(),"Could not create a new object!");
+ if(!xTable.is())
+ return NULL;
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ Reference< XDatabaseMetaData> xMetaData = m_xDestConnection->getMetaData();
+ ::dbtools::qualifiedNameComponents(xMetaData,
+ m_sName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+
+ if ( !sCatalog.getLength() && xMetaData->supportsCatalogsInTableDefinitions() )
+ {
+ sCatalog = m_xDestConnection->getCatalog();
+ }
+
+ if ( !sSchema.getLength() && xMetaData->supportsSchemasInTableDefinitions() )
+ {
+ sSchema = xMetaData->getUserName();
+ }
+
+ xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xTable->setPropertyValue(PROPERTY_NAME,makeAny(sTable));
+
+ Reference< XColumnsSupplier > xSuppDestinationColumns( xTable, UNO_QUERY );
+ // now append the columns
+ const ODatabaseExport::TColumnVector* pVec = getDestVector();
+ appendColumns( xSuppDestinationColumns, pVec );
+ // now append the primary key
+ Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
+ appendKey(xKeySup,pVec);
+
+ Reference<XAppend> xAppend(xTables,UNO_QUERY);
+ if(xAppend.is())
+ xAppend->appendByDescriptor(xTable);
+
+ // xTable = NULL;
+ // we need to reget the table because after appending it it is no longer valid
+ if(xTables->hasByName(m_sName))
+ xTables->getByName(m_sName) >>= xTable;
+ else
+ {
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( m_xDestConnection->getMetaData(), xTable, ::dbtools::eInDataManipulation, false, false, false ) );
+ if(xTables->hasByName(sComposedName))
+ {
+ xTables->getByName(sComposedName) >>= xTable;
+ m_sName = sComposedName;
+ }
+ else
+ xTable = NULL;
+ }
+ if(xTable.is())
+ {
+ xSuppDestinationColumns.set( xTable, UNO_QUERY_THROW );
+ // insert new table name into table filter
+ ::dbaui::appendToFilter( m_xDestConnection, m_sName, GetFactory(), this );
+
+ // copy ui settings
+ m_rSourceObject.copyUISettingsTo( xTable );
+ //copy filter and sorting
+ m_rSourceObject.copyFilterAndSortingTo(m_xDestConnection,xTable);
+ // set column mappings
+ Reference<XNameAccess> xNameAccess = xSuppDestinationColumns->getColumns();
+ Sequence< ::rtl::OUString> aSeq = xNameAccess->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+
+ ::std::vector<int> aAlreadyFound(m_vColumnPos.size(),0);
+
+ for(sal_Int32 nNewPos=1;pIter != pEnd;++pIter,++nNewPos)
+ {
+ ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(*pIter);
+
+ if ( aDestIter != m_vDestColumns.end() )
+ {
+ ODatabaseExport::TColumnVector::const_iterator aFind = ::std::find(m_aDestVec.begin(),m_aDestVec.end(),aDestIter);
+ sal_Int32 nPos = (aFind - m_aDestVec.begin())+1;
+
+ ODatabaseExport::TPositions::iterator aPosFind = ::std::find_if(
+ m_vColumnPos.begin(),
+ m_vColumnPos.end(),
+ ::o3tl::compose1( ::std::bind2nd( ::std::equal_to< sal_Int32 >(), nPos ),
+ ::o3tl::select1st< ODatabaseExport::TPositions::value_type >()
+ )
+ );
+
+ if ( m_vColumnPos.end() != aPosFind )
+ {
+ aPosFind->second = nNewPos;
+ OSL_ENSURE( m_vColumnTypes.size() > size_t( aPosFind - m_vColumnPos.begin() ),
+ "Invalid index for vector!" );
+ m_vColumnTypes[ aPosFind - m_vColumnPos.begin() ] = (*aFind)->second->GetType();
+ }
+ }
+ }
+ }
+ }
+ else if(xTables.is() && xTables->hasByName(m_sName))
+ xTables->getByName(m_sName) >>= xTable;
+
+ return xTable;
+}
+
+// -----------------------------------------------------------------------------
+bool OCopyTableWizard::supportsPrimaryKey( const Reference< XConnection >& _rxConnection )
+{
+ OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsPrimaryKey: invalid connection!" );
+ if ( !_rxConnection.is() )
+ return false;
+
+ ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
+ return aMetaData.supportsPrimaryKeys();
+}
+
+// -----------------------------------------------------------------------------
+bool OCopyTableWizard::supportsViews( const Reference< XConnection >& _rxConnection )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::supportsViews" );
+ OSL_PRECOND( _rxConnection.is(), "OCopyTableWizard::supportsViews: invalid connection!" );
+ if ( !_rxConnection.is() )
+ return false;
+
+ bool bSupportsViews( false );
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_SET_THROW );
+ Reference< XViewsSupplier > xViewSups( _rxConnection, UNO_QUERY );
+ bSupportsViews = xViewSups.is();
+ if ( !bSupportsViews )
+ {
+ try
+ {
+ Reference< XResultSet > xRs( xMetaData->getTableTypes(), UNO_SET_THROW );
+ Reference< XRow > xRow( xRs, UNO_QUERY_THROW );
+ while ( xRs->next() )
+ {
+ ::rtl::OUString sValue = xRow->getString( 1 );
+ if ( !xRow->wasNull() && sValue.equalsIgnoreAsciiCaseAscii( "View" ) )
+ {
+ bSupportsViews = true;
+ break;
+ }
+ }
+ }
+ catch( const SQLException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bSupportsViews;
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 OCopyTableWizard::getMaxColumnNameLength() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::getMaxColumnNameLength" );
+ sal_Int32 nLen = 0;
+ if ( m_xDestConnection.is() )
+ {
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData( m_xDestConnection->getMetaData(), UNO_SET_THROW );
+ nLen = xMetaData->getMaxColumnNameLength();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return nLen;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::setOperation" );
+ m_nOperation = _nOperation;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 OCopyTableWizard::getOperation() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::getOperation" );
+ return m_nOperation;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFunctor,
+ const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sExtraChars,
+ sal_Int32 _nMaxNameLen)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::convertColumnName" );
+ ::rtl::OUString sAlias = _sColumnName;
+ if ( isSQL92CheckEnabled( m_xDestConnection ) )
+ sAlias = ::dbtools::convertName2SQLName(_sColumnName,_sExtraChars);
+ if((_nMaxNameLen && sAlias.getLength() > _nMaxNameLen) || _rCmpFunctor(sAlias))
+ {
+ sal_Int32 nDiff = 1;
+ do
+ {
+ ++nDiff;
+ if(_nMaxNameLen && sAlias.getLength() >= _nMaxNameLen)
+ sAlias = sAlias.copy(0,sAlias.getLength() - (sAlias.getLength()-_nMaxNameLen+nDiff));
+
+ ::rtl::OUString sName(sAlias);
+ sal_Int32 nPos = 1;
+ sName += ::rtl::OUString::valueOf(nPos);
+
+ while(_rCmpFunctor(sName))
+ {
+ sName = sAlias;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ }
+ sAlias = sName;
+ // we have to check again, it could happen that the name is already to long
+ }
+ while(_nMaxNameLen && sAlias.getLength() > _nMaxNameLen);
+ }
+ OSL_ENSURE(m_mNameMapping.find(_sColumnName) == m_mNameMapping.end(),"name doubled!");
+ m_mNameMapping[_sColumnName] = sAlias;
+ return sAlias;
+}
+
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::removeColumnNameFromNameMap(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::removeColumnNameFromNameMap" );
+ m_mNameMapping.erase(_sName);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OCopyTableWizard::supportsType(sal_Int32 _nDataType,sal_Int32& _rNewDataType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::supportsType" );
+ sal_Bool bRet = m_aDestTypeInfo.find(_nDataType) != m_aDestTypeInfo.end();
+ if ( bRet )
+ _rNewDataType = _nDataType;
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OCopyTableWizard::convertType(const TOTypeInfoSP& _pType,sal_Bool& _bNotConvert)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::convertType" );
+ if ( !m_bInterConnectionCopy )
+ // no need to convert if the source and destination connection are the same
+ return _pType;
+
+ sal_Bool bForce;
+ TOTypeInfoSP pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,_pType->nType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
+ if ( !pType.get() || bForce )
+ { // no type found so we have to find the correct one ourself
+ sal_Int32 nDefaultType = DataType::VARCHAR;
+ switch(_pType->nType)
+ {
+ case DataType::TINYINT:
+ if(supportsType(DataType::SMALLINT,nDefaultType))
+ break;
+ // run through
+ case DataType::SMALLINT:
+ if(supportsType(DataType::INTEGER,nDefaultType))
+ break;
+ // run through
+ case DataType::INTEGER:
+ if(supportsType(DataType::FLOAT,nDefaultType))
+ break;
+ // run through
+ case DataType::FLOAT:
+ if(supportsType(DataType::REAL,nDefaultType))
+ break;
+ // run through
+ case DataType::DATE:
+ case DataType::TIME:
+ if( DataType::DATE == _pType->nType || DataType::TIME == _pType->nType )
+ {
+ if(supportsType(DataType::TIMESTAMP,nDefaultType))
+ break;
+ }
+ // run through
+ case DataType::TIMESTAMP:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ if ( supportsType(DataType::DOUBLE,nDefaultType) )
+ break;
+ // run through
+ case DataType::DOUBLE:
+ if ( supportsType(DataType::NUMERIC,nDefaultType) )
+ break;
+ // run through
+ case DataType::NUMERIC:
+ supportsType(DataType::DECIMAL,nDefaultType);
+ break;
+ case DataType::DECIMAL:
+ if ( supportsType(DataType::NUMERIC,nDefaultType) )
+ break;
+ if ( supportsType(DataType::DOUBLE,nDefaultType) )
+ break;
+ break;
+ case DataType::VARCHAR:
+ if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
+ break;
+ break;
+ case DataType::LONGVARCHAR:
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
+ case DataType::BINARY:
+ if ( supportsType(DataType::VARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::VARBINARY:
+ if ( supportsType(DataType::LONGVARBINARY,nDefaultType) )
+ break;
+ break;
+ case DataType::LONGVARBINARY:
+ if ( supportsType(DataType::BLOB,nDefaultType) )
+ break;
+ if ( supportsType(DataType::LONGVARCHAR,nDefaultType) )
+ break;
+ if ( supportsType(DataType::CLOB,nDefaultType) )
+ break;
+ break;
+ default:
+ nDefaultType = DataType::VARCHAR;
+ }
+ pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,nDefaultType,_pType->aTypeName,_pType->aCreateParams,_pType->nPrecision,_pType->nMaximumScale,_pType->bAutoIncrement,bForce);
+ if ( !pType.get() )
+ {
+ _bNotConvert = sal_False;
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x"));
+ pType = ::dbaui::getTypeInfoFromType(m_aDestTypeInfo,DataType::VARCHAR,_pType->aTypeName,sCreate,50,0,sal_False,bForce);
+ if ( !pType.get() )
+ pType = m_pTypeInfo;
+ }
+ else if ( bForce )
+ _bNotConvert = sal_False;
+ }
+ return pType;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OCopyTableWizard::createUniqueName(const ::rtl::OUString& _sName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::createUniqueName" );
+ ::rtl::OUString sName = _sName;
+ Sequence< ::rtl::OUString > aColumnNames( m_rSourceObject.getColumnNames() );
+ if ( aColumnNames.getLength() )
+ sName = ::dbtools::createUniqueName( aColumnNames, sName, sal_False );
+ else
+ {
+ if ( m_vSourceColumns.find(sName) != m_vSourceColumns.end())
+ {
+ sal_Int32 nPos = 0;
+ while(m_vSourceColumns.find(sName) != m_vSourceColumns.end())
+ {
+ sName = _sName;
+ sName += ::rtl::OUString::valueOf(++nPos);
+ }
+ }
+ }
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OCopyTableWizard::showColumnTypeNotSupported(const ::rtl::OUString& _rColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "misc", "Ocke.Janssen@sun.com", "OCopyTableWizard::showColumnTypeNotSupported" );
+ String sMessage( ModuleRes( STR_UNKNOWN_TYPE_FOUND ) );
+ sMessage.SearchAndReplaceAscii("#1",_rColumnName);
+ showError(sMessage);
+}
+//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const ::rtl::OUString& _sErrorMesage)
+{
+ SQLExceptionInfo aInfo(_sErrorMesage);
+ showError(aInfo.get());
+}
+//-------------------------------------------------------------------------------
+void OCopyTableWizard::showError(const Any& _aError)
+{
+ if ( _aError.hasValue() && m_xInteractionHandler.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( _aError ) );
+ m_xInteractionHandler->handle( xRequest.get() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WExtendPages.cxx b/dbaccess/source/ui/misc/WExtendPages.cxx
new file mode 100644
index 000000000000..3b00f2289359
--- /dev/null
+++ b/dbaccess/source/ui/misc/WExtendPages.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "WExtendPages.hxx"
+#include "RtfReader.hxx"
+#include "HtmlReader.hxx"
+#include "WCopyTable.hxx"
+
+using namespace dbaui;
+//========================================================================
+SvParser* OWizHTMLExtend::createReader(sal_Int32 _nRows)
+{
+ return new OHTMLReader(*m_pParserStream,
+ _nRows,
+ m_pParent->GetColumnPositions(),
+ m_pParent->GetFormatter(),
+ m_pParent->GetFactory(),
+ m_pParent->getDestVector(),
+ m_pParent->getTypeInfo(),
+ m_pParent->shouldCreatePrimaryKey());
+}
+//========================================================================
+SvParser* OWizRTFExtend::createReader(sal_Int32 _nRows)
+{
+ return new ORTFReader(*m_pParserStream,
+ _nRows,
+ m_pParent->GetColumnPositions(),
+ m_pParent->GetFormatter(),
+ m_pParent->GetFactory(),
+ m_pParent->getDestVector(),
+ m_pParent->getTypeInfo(),
+ m_pParent->shouldCreatePrimaryKey());
+}
+//========================================================================
+OWizNormalExtend::OWizNormalExtend(Window* pParent) : OWizTypeSelect( pParent )
+{
+ EnableAuto(sal_False);
+ Size aflSize( m_flColumns.GetSizePixel() );
+ Point aPos(m_flColumns.GetPosPixel());
+
+ m_flColumns.SetPosSizePixel(aPos, aflSize );
+
+ sal_Int32 nHeight = m_lbColumnNames.GetSizePixel().Height() +6;
+ aPos = m_aTypeControl.GetPosPixel();
+ Size aNewSize(m_aTypeControl.GetSizePixel().Width(),nHeight - aPos.Y()-6);
+
+ aflSize = m_aTypeControl.GetSizePixel();
+ m_aTypeControl.SetPosSizePixel(aPos,aNewSize);
+}
+// -----------------------------------------------------------------------------
+SvParser* OWizNormalExtend::createReader(sal_Int32 /*_nRows*/)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx
new file mode 100644
index 000000000000..8f3222181146
--- /dev/null
+++ b/dbaccess/source/ui/misc/WNameMatch.cxx
@@ -0,0 +1,412 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "WNameMatch.hxx"
+#include <osl/diagnose.h>
+#include "FieldDescriptions.hxx"
+#include "WCopyTable.hxx"
+#include "dbaccess_helpid.hrc"
+#include "dbu_misc.hrc"
+#include "WizardPages.hrc"
+#include <vcl/scrbar.hxx>
+#include "WCopyTable.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+
+using namespace ::dbaui;
+//========================================================================
+// OWizColumnSelect
+DBG_NAME(OWizNameMatching)
+//========================================================================
+OWizNameMatching::OWizNameMatching( Window* pParent)
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_NAME_MATCHING ) )
+ ,m_FT_TABLE_LEFT( this, ModuleRes( FT_TABLE_LEFT ) )
+ ,m_FT_TABLE_RIGHT( this, ModuleRes( FT_TABLE_RIGHT ) )
+ ,m_CTRL_LEFT( this, ModuleRes( CTRL_LEFT ) )
+ ,m_CTRL_RIGHT( this, ModuleRes( CTRL_RIGHT ) )
+ ,m_ibColumn_up( this, ModuleRes( IB_COLUMN_UP ) )
+ ,m_ibColumn_down( this, ModuleRes( IB_COLUMN_DOWN ) )
+ ,m_ibColumn_up_right( this, ModuleRes( IB_COLUMN_UP_RIGHT ) )
+ ,m_ibColumn_down_right( this, ModuleRes( IB_COLUMN_DOWN_RIGHT ) )
+ ,m_pbAll( this, ModuleRes( PB_ALL ) )
+ ,m_pbNone( this, ModuleRes( PB_NONE ) )
+
+{
+ DBG_CTOR(OWizNameMatching,NULL);
+
+ m_ibColumn_up.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl));
+ m_ibColumn_down.SetClickHdl(LINK(this,OWizNameMatching,ButtonClickHdl));
+
+ m_ibColumn_up_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl));
+ m_ibColumn_down_right.SetClickHdl(LINK(this,OWizNameMatching,RightButtonClickHdl));
+
+ m_pbAll.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl));
+ m_pbNone.SetClickHdl(LINK(this,OWizNameMatching,AllNoneClickHdl));
+
+ m_CTRL_LEFT.SetSelectHdl(LINK(this,OWizNameMatching,TableListClickHdl));
+ m_CTRL_RIGHT.SetSelectHdl(LINK(this,OWizNameMatching,TableListRightSelectHdl));
+ m_CTRL_RIGHT.EnableCheckButton( NULL );
+
+ m_CTRL_LEFT.SetStyle( m_CTRL_LEFT.GetStyle() | WB_FORCE_MAKEVISIBLE );
+ m_CTRL_RIGHT.SetStyle( m_CTRL_RIGHT.GetStyle() | WB_FORCE_MAKEVISIBLE );
+
+ m_sSourceText = m_FT_TABLE_LEFT.GetText();
+ m_sSourceText.AppendAscii("\n");
+ m_sDestText = m_FT_TABLE_RIGHT.GetText();
+ m_sDestText.AppendAscii("\n");
+
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizNameMatching::~OWizNameMatching()
+{
+ DBG_DTOR(OWizNameMatching,NULL);
+}
+
+// -----------------------------------------------------------------------
+void OWizNameMatching::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+ // the left tree contains bitmaps so i need to resize the right one
+ if(m_bFirstTime)
+ {
+ m_CTRL_RIGHT.SetReadOnly(); // sets autoinc to readonly
+ m_CTRL_RIGHT.SetEntryHeight(m_CTRL_LEFT.GetEntryHeight());
+ m_CTRL_RIGHT.SetIndent(m_CTRL_LEFT.GetIndent());
+ m_CTRL_RIGHT.SetSpaceBetweenEntries(m_CTRL_LEFT.GetSpaceBetweenEntries());
+
+ m_bFirstTime = sal_False;
+ }
+
+}
+// -----------------------------------------------------------------------
+void OWizNameMatching::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+
+ // set source table name
+ String aName = m_sSourceText;
+ aName += String(m_pParent->m_sSourceName);
+
+ m_FT_TABLE_LEFT.SetText(aName);
+
+ // set dest table name
+ aName = m_sDestText;
+ aName += String(m_pParent->m_sName);
+ m_FT_TABLE_RIGHT.SetText(aName);
+
+
+ m_CTRL_LEFT.FillListBox(*m_pParent->getSrcVector());
+ m_CTRL_RIGHT.FillListBox(*m_pParent->getDestVector());
+
+ m_ibColumn_up.Enable( m_CTRL_LEFT.GetEntryCount() > 1 );
+ m_ibColumn_down.Enable( m_CTRL_LEFT.GetEntryCount() > 1 );
+
+ m_ibColumn_up_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 );
+ m_ibColumn_down_right.Enable( m_CTRL_RIGHT.GetEntryCount() > 1 );
+
+
+ m_pParent->EnableButton(OCopyTableWizard::WIZARD_NEXT,sal_False);
+ m_CTRL_LEFT.GrabFocus();
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizNameMatching::LeavePage()
+{
+ DBG_CHKTHIS(OWizNameMatching,NULL);
+
+ const ODatabaseExport::TColumnVector* pSrcColumns = m_pParent->getSrcVector();
+
+ m_pParent->m_vColumnPos.clear();
+ m_pParent->m_vColumnTypes.clear();
+ m_pParent->m_vColumnPos.resize( pSrcColumns->size(), ODatabaseExport::TPositions::value_type( COLUMN_POSITION_NOT_FOUND, COLUMN_POSITION_NOT_FOUND ) );
+ m_pParent->m_vColumnTypes.resize( pSrcColumns->size(), COLUMN_POSITION_NOT_FOUND );
+
+
+ sal_Int32 nParamPos = 0;
+ SvLBoxEntry* pLeftEntry = m_CTRL_LEFT.GetModel()->First();
+ SvLBoxEntry* pRightEntry = m_CTRL_RIGHT.GetModel()->First();
+ while(pLeftEntry && pRightEntry)
+ {
+ OFieldDescription* pSrcField = static_cast<OFieldDescription*>(pLeftEntry->GetUserData());
+ OSL_ENSURE(pSrcField,"OWizNameMatching: OColumn can not be null!");
+
+ ODatabaseExport::TColumnVector::const_iterator aSrcIter = pSrcColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aSrcEnd = pSrcColumns->end();
+ for(;aSrcIter != aSrcEnd && (*aSrcIter)->second != pSrcField;++aSrcIter)
+ ;
+ const sal_Int32 nPos = ::std::distance(pSrcColumns->begin(),aSrcIter);
+
+ if(m_CTRL_LEFT.GetCheckButtonState(pLeftEntry) == SV_BUTTON_CHECKED)
+ {
+ OFieldDescription* pDestField = static_cast<OFieldDescription*>(pRightEntry->GetUserData());
+ OSL_ENSURE(pDestField,"OWizNameMatching: OColumn can not be null!");
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aDestIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aDestEnd = pDestColumns->end();
+
+ for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter)
+ ;
+
+ OSL_ENSURE((nPos) < static_cast<sal_Int32>(m_pParent->m_vColumnPos.size()),"m_pParent->m_vColumnPos: Illegal index for vector");
+ m_pParent->m_vColumnPos[nPos].first = ++nParamPos;
+ m_pParent->m_vColumnPos[nPos].second = ::std::distance(pDestColumns->begin(),aDestIter) + 1;
+ sal_Bool bNotConvert = sal_True;
+ TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
+ sal_Int32 nType = ::com::sun::star::sdbc::DataType::VARCHAR;
+ if ( pTypeInfo.get() )
+ nType = pTypeInfo->nType;
+ m_pParent->m_vColumnTypes[nPos] = nType;
+ }
+ else
+ {
+ m_pParent->m_vColumnPos[nPos].first = COLUMN_POSITION_NOT_FOUND;
+ m_pParent->m_vColumnPos[nPos].second = COLUMN_POSITION_NOT_FOUND;
+ }
+
+ pLeftEntry = m_CTRL_LEFT.GetModel()->Next(pLeftEntry);
+ pRightEntry = m_CTRL_RIGHT.GetModel()->Next(pRightEntry);
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------
+String OWizNameMatching::GetTitle() const { return String(ModuleRes(STR_WIZ_NAME_MATCHING_TITEL)); }
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, ButtonClickHdl, Button *, pButton )
+{
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected();
+ if ( pEntry )
+ {
+ sal_Int32 nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry);
+ if(pButton == &m_ibColumn_up && nPos)
+ --nPos;
+ else if(pButton == &m_ibColumn_down)
+ nPos += 2;
+
+ m_CTRL_LEFT.ModelIsMoving(pEntry,NULL,nPos);
+ m_CTRL_LEFT.GetModel()->Move(pEntry,NULL,nPos);
+ m_CTRL_LEFT.ModelHasMoved(pEntry);
+
+ long nThumbPos = m_CTRL_LEFT.GetVScroll()->GetThumbPos();
+ long nVisibleSize = m_CTRL_LEFT.GetVScroll()->GetVisibleSize();
+
+ if(pButton == &m_ibColumn_down && (nThumbPos+nVisibleSize+1) < nPos)
+ {
+ m_CTRL_LEFT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ }
+
+ TableListClickHdl(&m_CTRL_LEFT);
+ }
+
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, RightButtonClickHdl, Button *, pButton )
+{
+ SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected();
+ if ( pEntry )
+ {
+ sal_Int32 nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry);
+ if(pButton == &m_ibColumn_up_right && nPos)
+ --nPos;
+ else if(pButton == &m_ibColumn_down_right)
+ nPos += 2;
+
+ m_CTRL_RIGHT.ModelIsMoving(pEntry,NULL,nPos);
+ m_CTRL_RIGHT.GetModel()->Move(pEntry,NULL,nPos);
+ m_CTRL_RIGHT.ModelHasMoved(pEntry);
+ long nThumbPos = m_CTRL_RIGHT.GetVScroll()->GetThumbPos();
+ long nVisibleSize = m_CTRL_RIGHT.GetVScroll()->GetVisibleSize();
+
+ if(pButton == &m_ibColumn_down_right && (nThumbPos+nVisibleSize+1) < nPos)
+ m_CTRL_RIGHT.GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ TableListRightSelectHdl(&m_CTRL_RIGHT);
+ }
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, TableListClickHdl, void*, /*NOTINTERESTEDIN*/ )
+{
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.FirstSelected();
+ if(pEntry)
+ {
+ sal_uLong nPos = m_CTRL_LEFT.GetModel()->GetAbsPos(pEntry);
+ SvLBoxEntry* pOldEntry = m_CTRL_RIGHT.FirstSelected();
+ if(pOldEntry && nPos != m_CTRL_RIGHT.GetModel()->GetAbsPos(pOldEntry))
+ {
+ if(pOldEntry)
+ m_CTRL_RIGHT.Select(pOldEntry,sal_False);
+ pOldEntry = m_CTRL_RIGHT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ sal_uLong nNewPos = m_CTRL_LEFT.GetModel()->GetAbsPos(m_CTRL_LEFT.GetFirstEntryInView());
+ if ( nNewPos - nPos == 1 )
+ --nNewPos;
+ m_CTRL_RIGHT.MakeVisible(m_CTRL_RIGHT.GetEntry(nNewPos),sal_True);
+ m_CTRL_RIGHT.Select(pOldEntry,sal_True);
+ }
+ }
+ else if(!pOldEntry)
+ {
+ pOldEntry = m_CTRL_RIGHT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ m_CTRL_RIGHT.Select(pOldEntry,sal_True);
+ }
+ }
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, TableListRightSelectHdl, void*, /*NOTINTERESTEDIN*/ )
+{
+ SvLBoxEntry* pEntry = m_CTRL_RIGHT.FirstSelected();
+ if(pEntry)
+ {
+ sal_uLong nPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(pEntry);
+ SvLBoxEntry* pOldEntry = m_CTRL_LEFT.FirstSelected();
+ if(pOldEntry && nPos != m_CTRL_LEFT.GetModel()->GetAbsPos(pOldEntry))
+ {
+ if(pOldEntry)
+ m_CTRL_LEFT.Select(pOldEntry,sal_False);
+ pOldEntry = m_CTRL_LEFT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ sal_uLong nNewPos = m_CTRL_RIGHT.GetModel()->GetAbsPos(m_CTRL_RIGHT.GetFirstEntryInView());
+ if ( nNewPos - nPos == 1 )
+ nNewPos--;
+ m_CTRL_LEFT.MakeVisible(m_CTRL_LEFT.GetEntry(nNewPos),sal_True);
+ m_CTRL_LEFT.Select(pOldEntry,sal_True);
+ }
+ }
+ else if(!pOldEntry)
+ {
+ pOldEntry = m_CTRL_LEFT.GetEntry(nPos);
+ if(pOldEntry)
+ {
+ m_CTRL_LEFT.Select(pOldEntry,sal_True);
+ }
+ }
+ }
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizNameMatching, AllNoneClickHdl, Button *, pButton )
+{
+ sal_Bool bAll = pButton == &m_pbAll;
+ SvLBoxEntry* pEntry = m_CTRL_LEFT.First();
+ while(pEntry)
+ {
+ m_CTRL_LEFT.SetCheckButtonState( pEntry, bAll ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED);
+ pEntry = m_CTRL_LEFT.Next(pEntry);
+ }
+
+ return 0;
+}
+// -----------------------------------------------------------------------
+//========================================================================
+// class OColumnString
+//========================================================================
+class OColumnString : public SvLBoxString
+{
+ sal_Bool m_bReadOnly;
+public:
+ OColumnString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr,sal_Bool _RO)
+ :SvLBoxString(pEntry,nFlags,rStr)
+ ,m_bReadOnly(_RO)
+ {
+ }
+
+ virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
+};
+//------------------------------------------------------------------------
+void OColumnString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ )
+{
+ if(m_bReadOnly)
+ {
+ const StyleSettings& rStyleSettings = rDev.GetSettings().GetStyleSettings();
+ rDev.SetTextColor( rStyleSettings.GetDisableColor() );
+ rDev.SetTextFillColor( rStyleSettings.GetFieldColor() );
+ }
+ rDev.DrawText( rPos, GetText() );
+}
+//========================================================================
+OColumnTreeBox::OColumnTreeBox( Window* pParent, const ResId& rResId )
+ : OMarkableTreeListBox(pParent,NULL,rResId)
+{
+ SetDragDropMode( 0 );
+ EnableInplaceEditing( sal_False );
+ SetStyle(GetStyle() | WB_BORDER | WB_HASBUTTONS | WB_HSCROLL);
+ SetSelectionMode( SINGLE_SELECTION );
+}
+//------------------------------------------------------------------------
+void OColumnTreeBox::InitEntry(SvLBoxEntry* pEntry, const String& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind)
+{
+ DBTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
+ SvLBoxString* pString = new OColumnString(pEntry, 0, rStr,sal_False);
+ if (pString)
+ pEntry->ReplaceItem( pString, pEntry->ItemCount() - 1 );
+}
+//------------------------------------------------------------------------
+sal_Bool OColumnTreeBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
+{
+ if(bSelect)
+ {
+ OFieldDescription* pColumn = static_cast<OFieldDescription*>(pEntry->GetUserData());
+ if(!(pColumn->IsAutoIncrement() && m_bReadOnly))
+ bSelect = DBTreeListBox::Select( pEntry,bSelect );
+ }
+ else
+ bSelect = DBTreeListBox::Select( pEntry,bSelect );
+ return bSelect;
+}
+//------------------------------------------------------------------------
+void OColumnTreeBox::FillListBox( const ODatabaseExport::TColumnVector& _rList)
+{
+ Clear();
+ ODatabaseExport::TColumnVector::const_iterator aIter = _rList.begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = _rList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ SvLBoxEntry* pEntry = InsertEntry((*aIter)->first,0,sal_False,LIST_APPEND,(*aIter)->second);
+ SvButtonState eState = !(m_bReadOnly && (*aIter)->second->IsAutoIncrement()) ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED;
+ SetCheckButtonState( pEntry, eState );
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
new file mode 100644
index 000000000000..2991ba00bf32
--- /dev/null
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -0,0 +1,483 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "WTypeSelect.hxx"
+#include "WizardPages.hrc"
+#include "dbustrings.hrc"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "FieldDescriptions.hxx"
+#include "WCopyTable.hxx"
+#include "dbaccess_helpid.hrc"
+#include "dbu_misc.hrc"
+#include <tools/stream.hxx>
+#include <svtools/svparser.hxx>
+#include "UITools.hxx"
+#include "sqlmessage.hxx"
+#include "FieldControls.hxx"
+
+#include "dbaccess_slotid.hrc"
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdbc;
+
+//========================================================================
+// OWizTypeSelectControl
+DBG_NAME(OWizTypeSelectControl)
+//========================================================================
+OWizTypeSelectControl::OWizTypeSelectControl(Window* pParent, const ResId& rResId,OTableDesignHelpBar* pHelpBar)
+ : OFieldDescControl(pParent,rResId,pHelpBar)
+{
+ DBG_CTOR(OWizTypeSelectControl,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OWizTypeSelectControl::~OWizTypeSelectControl()
+{
+
+ DBG_DTOR(OWizTypeSelectControl,NULL);
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::ActivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpAutoIncrement:
+ case tpAutoIncrementValue:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::DeactivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+ case tpAutoIncrement:
+ case tpAutoIncrementValue:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
+{
+ OSL_ENSURE(nRow == -1,"nRow muss -1 sein!");
+ (void)nRow;
+
+ MultiListBox &aListBox = ((OWizTypeSelect*)GetParent())->m_lbColumnNames;
+
+ OFieldDescription* pCurFieldDescr = getCurrentFieldDescData();
+
+ sal_uInt16 nPos = aListBox.GetEntryPos( String( pCurFieldDescr->GetName() ) );
+ pCurFieldDescr = static_cast< OFieldDescription* >( aListBox.GetEntryData( nPos ) );
+ OSL_ENSURE( pCurFieldDescr, "OWizTypeSelectControl::CellModified: Columnname/type not found in the listbox!" );
+ if ( !pCurFieldDescr )
+ return;
+ setCurrentFieldDescData( pCurFieldDescr );
+
+ ::rtl::OUString sName = pCurFieldDescr->GetName();
+ ::rtl::OUString sNewName;
+ const OPropColumnEditCtrl* pColumnName = getColumnCtrl();
+ if ( pColumnName )
+ sNewName = pColumnName->GetText();
+
+ switch(nColId)
+ {
+ case FIELD_PRPOERTY_COLUMNNAME:
+ {
+ OCopyTableWizard* pWiz = static_cast<OCopyTableWizard*>(GetParent()->GetParent());
+ // first we have to check if this name already exists
+ sal_Bool bDoubleName = sal_False;
+ sal_Bool bCase = sal_True;
+ if ( getMetaData().is() && !getMetaData()->supportsMixedCaseQuotedIdentifiers() )
+ {
+ bCase = sal_False;
+ sal_uInt16 nCount = aListBox.GetEntryCount();
+ for (sal_uInt16 i=0 ; !bDoubleName && i < nCount ; ++i)
+ {
+ ::rtl::OUString sEntry(aListBox.GetEntry(i));
+ bDoubleName = sNewName.equalsIgnoreAsciiCase(sEntry);
+ }
+ if ( !bDoubleName && pWiz->shouldCreatePrimaryKey() )
+ bDoubleName = sNewName.equalsIgnoreAsciiCase(pWiz->getPrimaryKeyName());
+
+ }
+ else
+ bDoubleName = ((aListBox.GetEntryPos(String(sNewName)) != LISTBOX_ENTRY_NOTFOUND)
+ || ( pWiz->shouldCreatePrimaryKey()
+ && pWiz->getPrimaryKeyName() == sNewName) );
+
+ if ( bDoubleName )
+ {
+ String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
+ strMessage.SearchAndReplaceAscii("$column$", sNewName);
+ pWiz->showError(strMessage);
+ pCurFieldDescr->SetName(sName);
+ DisplayData(pCurFieldDescr);
+ static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_True);
+ return;
+ }
+
+ ::rtl::OUString sOldName = pCurFieldDescr->GetName();
+ pCurFieldDescr->SetName(sNewName);
+ static_cast<OWizTypeSelect*>(GetParent())->setDuplicateName(sal_False);
+
+ // now we change the name
+ OCopyTableWizard::TNameMapping::iterator aIter = pWiz->m_mNameMapping.begin();
+ OCopyTableWizard::TNameMapping::iterator aEnd = pWiz->m_mNameMapping.end();
+
+ ::comphelper::UStringMixEqual aCase(bCase);
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aCase(aIter->second,sName) )
+ {
+ aIter->second = sNewName;
+ break;
+ }
+ }
+
+ aListBox.RemoveEntry(nPos);
+ aListBox.InsertEntry(pCurFieldDescr->GetName(),nPos);
+ aListBox.SetEntryData(nPos,pCurFieldDescr);
+
+ pWiz->replaceColumn(nPos,pCurFieldDescr,sOldName);
+ }
+ break;
+ }
+ saveCurrentFieldDescData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::lang::Locale OWizTypeSelectControl::GetLocale() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->GetLocale();
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OWizTypeSelectControl::GetFormatter() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->GetFormatter();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OWizTypeSelectControl::getTypeInfo(sal_Int32 _nPos)
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->getDestTypeInfo(_nPos);
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OWizTypeSelectControl::getTypeInfo() const
+{
+ return static_cast<OWizTypeSelect*>(GetParent())->m_pParent->getDestTypeInfo();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OWizTypeSelectControl::getMetaData()
+{
+ return ((OWizTypeSelect*)GetParent())->m_pParent->m_xDestConnection->getMetaData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OWizTypeSelectControl::getConnection()
+{
+ return ((OWizTypeSelect*)GetParent())->m_pParent->m_xDestConnection;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OWizTypeSelectControl::isAutoIncrementValueEnabled() const
+{
+ return ((OWizTypeSelect*)GetParent())->m_bAutoIncrementEnabled;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OWizTypeSelectControl::getAutoIncrementValue() const
+{
+ return ((OWizTypeSelect*)GetParent())->m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+
+//========================================================================
+DBG_NAME(OWizTypeSelect);
+#define IMG_PRIMARY_KEY 1
+//========================================================================
+OWizTypeSelect::OWizTypeSelect( Window* pParent, SvStream* _pStream )
+ :OWizardPage( pParent, ModuleRes( TAB_WIZ_TYPE_SELECT ))
+ ,m_lbColumnNames( this, ModuleRes( LB_NEW_COLUMN_NAMES ) )
+ ,m_flColumns( this, ModuleRes( FL_COLUMN_NAME ) )
+ ,m_aTypeControl( this, ModuleRes( CONTROL_CONTAINER ))
+ ,m_flAutoType( this, ModuleRes( FL_AUTO_TYPE ) )
+ ,m_ftAuto( this, ModuleRes( FT_AUTO ) )
+ ,m_etAuto( this, ModuleRes( ET_AUTO ) )
+ ,m_pbAuto( this, ModuleRes( PB_AUTO ) )
+ ,m_pParserStream( _pStream )
+ ,m_nDisplayRow(0)
+ ,m_bAutoIncrementEnabled(sal_False)
+ ,m_bDuplicateName(sal_False)
+{
+ DBG_CTOR(OWizTypeSelect,NULL);
+ m_lbColumnNames.SetSelectHdl(LINK(this,OWizTypeSelect,ColumnSelectHdl));
+
+ ModuleRes aModuleRes(IMG_JOINS);
+ ImageList aImageList(aModuleRes);
+ m_imgPKey = aImageList.GetImage(IMG_PRIMARY_KEY);
+
+ m_aTypeControl.Show();
+ m_aTypeControl.Init();
+ m_etAuto.SetText(String::CreateFromAscii("10"));
+ m_etAuto.SetDecimalDigits(0);
+ m_pbAuto.SetClickHdl(LINK(this,OWizTypeSelect,ButtonClickHdl));
+ m_lbColumnNames.EnableMultiSelection(sal_True);
+
+ try
+ {
+ m_lbColumnNames.SetPKey( m_pParent->supportsPrimaryKey() );
+ ::dbaui::fillAutoIncrementValue( m_pParent->m_xDestConnection, m_bAutoIncrementEnabled, m_sAutoIncrementValue );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ FreeResource();
+}
+// -----------------------------------------------------------------------
+OWizTypeSelect::~OWizTypeSelect()
+{
+ DBG_DTOR(OWizTypeSelect,NULL);
+}
+// -----------------------------------------------------------------------------
+String OWizTypeSelect::GetTitle() const
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ return String(ModuleRes(STR_WIZ_TYPE_SELECT_TITEL));
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::Resize()
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+}
+// -----------------------------------------------------------------------
+IMPL_LINK( OWizTypeSelect, ColumnSelectHdl, MultiListBox *, /*pListBox*/ )
+{
+ String aColumnName( m_lbColumnNames.GetSelectEntry() );
+
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbColumnNames.GetEntryData(m_lbColumnNames.GetEntryPos(aColumnName)));
+ if(pField)
+ m_aTypeControl.DisplayData(pField);
+
+ m_aTypeControl.Enable(m_lbColumnNames.GetSelectEntryCount() == 1 );
+ return 0;
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::Reset()
+{
+ // urspr"unglichen zustand wiederherstellen
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+
+ while(m_lbColumnNames.GetEntryCount())
+ m_lbColumnNames.RemoveEntry(0);
+ m_lbColumnNames.Clear();
+ sal_Int32 nBreakPos;
+ m_pParent->CheckColumns(nBreakPos);
+
+ const ODatabaseExport::TColumnVector* pDestColumns = m_pParent->getDestVector();
+ ODatabaseExport::TColumnVector::const_iterator aIter = pDestColumns->begin();
+ ODatabaseExport::TColumnVector::const_iterator aEnd = pDestColumns->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ sal_uInt16 nPos;
+ if((*aIter)->second->IsPrimaryKey())
+ nPos = m_lbColumnNames.InsertEntry((*aIter)->first, m_imgPKey );
+ else
+ nPos = m_lbColumnNames.InsertEntry((*aIter)->first);
+ m_lbColumnNames.SetEntryData(nPos,(*aIter)->second);
+ }
+ m_bFirstTime = sal_False;
+}
+// -----------------------------------------------------------------------
+void OWizTypeSelect::ActivatePage( )
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_Bool bOldFirstTime = m_bFirstTime;
+ Reset();
+ m_bFirstTime = bOldFirstTime;
+
+ m_lbColumnNames.SelectEntryPos(static_cast<sal_uInt16>(m_nDisplayRow));
+ m_nDisplayRow = 0;
+ m_lbColumnNames.GetSelectHdl().Call(&m_lbColumnNames);
+}
+// -----------------------------------------------------------------------
+sal_Bool OWizTypeSelect::LeavePage()
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ String aColumnName( m_lbColumnNames.GetSelectEntry() );
+
+ sal_Bool bDuplicateName = sal_False;
+ OFieldDescription* pField = static_cast<OFieldDescription*>(m_lbColumnNames.GetEntryData(m_lbColumnNames.GetEntryPos(aColumnName)));
+ if ( pField )
+ {
+ m_aTypeControl.SaveData(pField);
+ bDuplicateName = m_bDuplicateName;
+ }
+ return !bDuplicateName;
+}
+//------------------------------------------------------------------------------
+void OWizTypeSelect::EnableAuto(sal_Bool bEnable)
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ m_ftAuto.Show(bEnable);
+ m_etAuto.Show(bEnable);
+ m_pbAuto.Show(bEnable);
+ m_flAutoType.Show(bEnable);
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OWizTypeSelect, ButtonClickHdl, Button *, /*pButton*/ )
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_Int32 nBreakPos;
+ m_pParent->CheckColumns(nBreakPos);
+ fillColumnList(m_etAuto.GetText().ToInt32());
+
+ ActivatePage();
+
+ return 0;
+}
+//------------------------------------------------------------------------
+sal_Bool OWizTypeSelectList::IsPrimaryKeyAllowed() const
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ sal_uInt16 nCount = GetSelectEntryCount();
+ sal_uInt16 j;
+
+ for( j = 0; m_bPKey && j < nCount; ++j )
+ {
+ OFieldDescription* pField = static_cast<OFieldDescription*>(GetEntryData(GetSelectEntryPos(j)));
+ if(!pField || pField->getTypeInfo()->nSearchType == ColumnSearch::NONE)
+ break;
+ }
+ return j == nCount;
+}
+// -----------------------------------------------------------------------------
+void OWizTypeSelectList::setPrimaryKey(OFieldDescription* _pFieldDescr,sal_uInt16 _nPos,sal_Bool _bSet)
+{
+ String sColumnName = GetEntry(_nPos);
+ RemoveEntry(_nPos);
+ _pFieldDescr->SetPrimaryKey(_bSet);
+ if( _bSet )
+ InsertEntry(sColumnName,((OWizTypeSelect*)GetParent())->m_imgPKey,_nPos);
+ else if( _pFieldDescr->getTypeInfo()->bNullable )
+ {
+ _pFieldDescr->SetControlDefault(Any());
+ InsertEntry(sColumnName,_nPos);
+ }
+ SetEntryData(_nPos,_pFieldDescr);
+}
+//------------------------------------------------------------------------
+long OWizTypeSelectList::PreNotify( NotifyEvent& rEvt )
+{
+ long nDone = 0;
+ switch( rEvt.GetType() )
+ {
+ case EVENT_MOUSEBUTTONDOWN:
+ {
+ const MouseEvent* pMEvt = rEvt.GetMouseEvent();
+ if(pMEvt->IsRight() && !pMEvt->GetModifier())
+ nDone = 1;
+ }
+ break;
+ case EVENT_COMMAND:
+ {
+ if(!IsPrimaryKeyAllowed())
+ break;
+
+ const CommandEvent* pComEvt = rEvt.GetCommandEvent();
+ if(pComEvt->GetCommand() != COMMAND_CONTEXTMENU)
+ break;
+ // die Stelle, an der geklickt wurde
+ Point ptWhere(0,0);
+ if (pComEvt->IsMouseEvent())
+ ptWhere = pComEvt->GetMousePosPixel();
+
+ PopupMenu aContextMenu(ModuleRes(RID_SBA_RTF_PKEYPOPUP));
+ switch( aContextMenu.Execute( this, ptWhere ) )
+ {
+ case SID_TABLEDESIGN_TABED_PRIMARYKEY:
+ {
+ String sColumnName;
+ sal_uInt16 nCount = GetEntryCount();
+ for(sal_uInt16 j = 0 ; j < nCount ; ++j)
+ {
+ OFieldDescription* pFieldDescr = static_cast<OFieldDescription*>(GetEntryData(j));
+ if( pFieldDescr )
+ {
+ if(pFieldDescr->IsPrimaryKey() && !IsEntryPosSelected(j))
+ setPrimaryKey(pFieldDescr,j);
+ else if(IsEntryPosSelected(j))
+ {
+ setPrimaryKey(pFieldDescr,j,!pFieldDescr->IsPrimaryKey());
+ SelectEntryPos(j);
+ }
+ }
+ }
+ GetSelectHdl().Call(this);
+ }
+ break;
+ }
+ nDone = 1;
+ }
+ break;
+ }
+ return nDone ? nDone : MultiListBox::PreNotify(rEvt);
+}
+// -----------------------------------------------------------------------------
+void OWizTypeSelect::fillColumnList(sal_uInt32 nRows)
+{
+ DBG_CHKTHIS(OWizTypeSelect,NULL);
+ if(m_pParserStream)
+ {
+ sal_uInt32 nTell = m_pParserStream->Tell(); // verändert vielleicht die Position des Streams
+
+ SvParser *pReader = createReader(nRows);
+ if(pReader)
+ {
+ pReader->AddRef();
+ pReader->CallParser();
+ pReader->ReleaseRef();
+ }
+ m_pParserStream->Seek(nTell);
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/WizardPages.hrc b/dbaccess/source/ui/misc/WizardPages.hrc
new file mode 100644
index 000000000000..224071b529ec
--- /dev/null
+++ b/dbaccess/source/ui/misc/WizardPages.hrc
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#define DBAUI_WIZARD_PAGES_HRC
+
+
+#define LB_ORG_COLUMN_NAMES 1
+#define LB_NEW_COLUMN_NAMES 2
+
+#define IB_COLUMN_RH 1
+#define IB_COLUMN_LH 2
+#define IB_COLUMNS_RH 3
+#define IB_COLUMNS_LH 4
+#define PB_AUTO 5
+#define PB_OK 6
+#define PB_CANCEL 7
+#define PB_HELP 8
+#define PB_NEXT 9
+#define PB_PREV 10
+#define PB_UNDO 11
+#define IB_COLUMN_UP 12
+#define IB_COLUMN_DOWN 13
+#define IB_COLUMN_UP_RIGHT 14
+#define IB_COLUMN_DOWN_RIGHT 15
+#define PB_ALL 16
+#define PB_NONE 17
+
+#define ET_AUTO 1
+#define ET_TABLENAME 2
+#define ET_KEYNAME 3
+
+#define FT_AUTO 1
+#define FT_TABLE_LEFT 2
+#define FT_TABLE_RIGHT 3
+#define FT_TABLENAME 4
+#define FT_KEYNAME 5
+
+#define FL_COLUMN_SELECT 1
+#define FL_COLUMN_NAME 2
+#define FL_AUTO_TYPE 3
+#define FL_OPTIONS 5
+
+#define RB_DEFDATA 1
+#define RB_DEF 2
+#define RB_VIEW 3
+#define RB_APPENDDATA 4
+#define CB_PRIMARY_COLUMN 5
+#define CB_USEHEADERLINE 6
+
+#define CONTROL_CONTAINER 1
+// controls
+#define CTRL_LEFT 1
+#define CTRL_RIGHT 2
+
+#endif // DBAUI_WIZARD_PAGES_HRC
+
+
diff --git a/dbaccess/source/ui/misc/WizardPages.src b/dbaccess/source/ui/misc/WizardPages.src
new file mode 100644
index 000000000000..360ab879a102
--- /dev/null
+++ b/dbaccess/source/ui/misc/WizardPages.src
@@ -0,0 +1,592 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_WIZARD_PAGES_HRC
+#include "WizardPages.hrc"
+#endif
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+#include "dbaccess_slotid.hrc"
+
+#define WINDOW_SIZE_X 276
+#define WINDOW_SIZE_Y 185
+
+#define WINDOW_BORDER_X 12
+#define WINDOW_BORDER_Y 14
+
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+String STR_WIZ_COLUMN_SELECT_TITEL
+{
+ Text [ en-US ] = "Apply columns";
+};
+
+String STR_WIZ_TYPE_SELECT_TITEL
+{
+ Text [ en-US ] = "Type formatting";
+};
+
+String STR_WIZ_PKEY_ALREADY_DEFINED
+{
+ Text [ en-US ] = "The following fields have already been set as primary keys:\n";
+};
+
+String STR_WIZ_NAME_MATCHING_TITEL
+{
+ Text [ en-US ] = "Assign columns" ;
+};
+
+ModalDialog WIZ_RTFCOPYTABLE
+{
+ HelpID = "dbaccess:ModalDialog:WIZ_RTFCOPYTABLE";
+
+ Text [ en-US ] = "Copy RTF Table" ;
+
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+
+ HelpButton PB_HELP
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Help";
+ };
+ CancelButton PB_CANCEL
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Cancel";
+ };
+ PushButton PB_PREV
+ {
+ HelpID = "dbaccess:PushButton:WIZ_RTFCOPYTABLE:PB_PREV";
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "< ~Back";
+ };
+ PushButton PB_NEXT
+ {
+ HelpID = "dbaccess:PushButton:WIZ_RTFCOPYTABLE:PB_NEXT";
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "~Next>";
+ };
+ OKButton PB_OK
+ {
+ TabStop = TRUE ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ Text [ en-US ] = "C~reate";
+ };
+
+};
+
+//==================================================================
+ // TAB_WIZ_COLUMN_SELECT
+ //==================================================================
+TabPage TAB_WIZ_COLUMN_SELECT
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_COLUMN_SELECT;
+ Hide = TRUE;
+
+ FixedLine FL_COLUMN_SELECT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ;
+ Text [ en-US ] = "Existing columns" ;
+ };
+ MultiListBox LB_ORG_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_COLUMN_SELECT:LB_ORG_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X , WINDOW_BORDER_Y ) ;
+ Size = MAP_APPFONT ( 95 , WINDOW_SIZE_Y - 23 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ Sort = FALSE;
+ };
+ ImageButton IB_COLUMN_RH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMN_RH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 25 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_right.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMNS_RH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMNS_RH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 45 ) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_right.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_LH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMN_LH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 65) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "one_left.png1" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+ ImageButton IB_COLUMNS_LH
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_COLUMN_SELECT:IB_COLUMNS_LH";
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 116 , WINDOW_BORDER_Y + 85) ;
+ Size = MAP_APPFONT ( 20 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "all_left.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF;
+ Green = 0x0000;
+ Blue = 0xFFFF;
+ };
+ };
+ };
+
+ MultiListBox LB_NEW_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_COLUMN_SELECT:LB_NEW_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( WINDOW_BORDER_X + 157, WINDOW_BORDER_Y) ;
+ Size = MAP_APPFONT ( 95 , WINDOW_SIZE_Y - 23 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ Sort = FALSE;
+ };
+};
+
+//==================================================================
+ // TAB_WIZ_TYPE_SELECT
+ //==================================================================
+TabPage TAB_WIZ_TYPE_SELECT
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_TYPE_SELECT;
+ Hide = TRUE;
+
+ MultiListBox LB_NEW_COLUMN_NAMES
+ {
+ HelpID = "dbaccess:MultiListBox:TAB_WIZ_TYPE_SELECT:LB_NEW_COLUMN_NAMES";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 87 , WINDOW_SIZE_Y - 12 ) ;
+ TabStop = TRUE ;
+ HScroll = TRUE;
+ VScroll = TRUE;
+ AutoHScroll = TRUE;
+ SimpleMode = TRUE;
+ };
+
+ FixedLine FL_COLUMN_NAME
+ {
+ Pos = MAP_APPFONT ( 99 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 105, 8 ) ;
+ Text [ en-US ] = "Column information" ;
+ };
+
+ TabPage CONTROL_CONTAINER
+ {
+ HelpID = "dbaccess:TabPage:CONTROL_CONTAINER";
+ Pos = MAP_APPFONT ( 102 , WINDOW_BORDER_Y ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 111, WINDOW_SIZE_Y - WINDOW_BORDER_Y - 67 );
+ SVLook = TRUE;
+ DialogControl = TRUE;
+ };
+
+ FixedLine FL_AUTO_TYPE
+ {
+ Pos = MAP_APPFONT ( 99 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 41 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 105, 8 ) ;
+ Text [ en-US ] = "Automatic type recognition" ;
+ };
+
+ FixedText FT_AUTO
+ {
+ Pos = MAP_APPFONT ( 105 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 28 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "Lines (ma~x)";
+ };
+
+ NumericField ET_AUTO
+ {
+ HelpID = "dbaccess:NumericField:TAB_WIZ_TYPE_SELECT:ET_AUTO";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 151 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 29) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+
+ PushButton PB_AUTO
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_TYPE_SELECT:PB_AUTO";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 62 , WINDOW_SIZE_Y - WINDOW_BORDER_Y - 30 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X , BUTTON_SIZE_Y ) ;
+ TabStop = TRUE ;
+ Text = "~Auto" ;
+ };
+};
+
+Menu RID_SBA_RTF_PKEYPOPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ HelpID = HID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Primary Key" ;
+ };
+ };
+};
+
+//==================================================================
+ // TAB_WIZ_NAME_MATCHING
+ //==================================================================
+TabPage TAB_WIZ_NAME_MATCHING
+{
+ HelpID = "dbaccess:TabPage:TAB_WIZ_NAME_MATCHING";
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Hide = TRUE;
+
+ FixedText FT_TABLE_LEFT
+ {
+ Pos = MAP_APPFONT ( 52 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 20) ;
+ Text [ en-US ] = "Source table: \n";
+ };
+
+ FixedText FT_TABLE_RIGHT
+ {
+ Pos = MAP_APPFONT ( 144, 6 ) ;
+ Size = MAP_APPFONT ( 75 , 20) ;
+ Text [ en-US ] = "Destination table: \n";
+ };
+
+ Control CTRL_LEFT
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 52, 28) ;
+ Size = MAP_APPFONT ( 82 , WINDOW_SIZE_Y - 34 ) ;
+ TabStop = TRUE;
+ HelpId = HID_TAB_NAMEMATCHING_COLS_AVAIL;
+ /*DialogControl = TRUE;*/
+ };
+
+ Control CTRL_RIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 144, 28) ;
+ Size = MAP_APPFONT ( 82 , WINDOW_SIZE_Y - 34 ) ;
+ TabStop = TRUE;
+ HelpId = HID_TAB_NAMEMATCHING_COLS_ASSIGN;
+ /*DialogControl = TRUE;*/
+ };
+
+ ImageButton IB_COLUMN_UP
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_UP";
+ Pos = MAP_APPFONT ( 19 , 45 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortup.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_DOWN
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_DOWN";
+ Pos = MAP_APPFONT ( 19 , 63 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_UP_RIGHT
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_UP_RIGHT";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 33, 45 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE;
+ DefButton = TRUE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortup.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+ ImageButton IB_COLUMN_DOWN_RIGHT
+ {
+ HelpID = "dbaccess:ImageButton:TAB_WIZ_NAME_MATCHING:IB_COLUMN_DOWN_RIGHT";
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 33, 63) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "sortdown.png" ;
+ };
+ MaskColor = Color
+ {
+ Red = 0xFFFF ;
+ Green = 0x0000 ;
+ Blue = 0xFFFF ;
+ };
+ };
+ };
+
+ PushButton PB_ALL
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_NAME_MATCHING:PB_ALL";
+ Pos = MAP_APPFONT ( 6, 83) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~All" ;
+ };
+
+ PushButton PB_NONE
+ {
+ HelpID = "dbaccess:PushButton:TAB_WIZ_NAME_MATCHING:PB_NONE";
+ Pos = MAP_APPFONT ( 6, 103) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Non~e" ;
+ };
+};
+
+TabPage TAB_WIZ_COPYTABLE
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X, WINDOW_SIZE_Y ) ;
+
+ HelpId = HID_TAB_WIZ_COPYTABLE;
+ Hide = TRUE;
+
+ FixedText FT_TABLENAME
+ {
+ Pos = MAP_APPFONT ( 12 , 11) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Ta~ble name";
+ };
+
+ Edit ET_TABLENAME
+ {
+ HelpId = HID_TAB_WIZ_TABLENAME_EDIT;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 9) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 92 , 12 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 24 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 12 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ RadioButton RB_DEFDATA
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_DEFDATA";
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "De~finition and data" ;
+ };
+ RadioButton RB_DEF
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_DEF";
+ Pos = MAP_APPFONT ( 12, 49 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Def~inition" ;
+ };
+
+ RadioButton RB_VIEW
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_VIEW";
+ Pos = MAP_APPFONT ( 12, 63 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "A~s table view";
+ };
+
+ RadioButton RB_APPENDDATA
+ {
+ HelpID = "dbaccess:RadioButton:TAB_WIZ_COPYTABLE:RB_APPENDDATA";
+ Pos = MAP_APPFONT ( 12, 77 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "Append ~data" ;
+ };
+
+ CheckBox CB_USEHEADERLINE
+ {
+ HelpID = "dbaccess:CheckBox:TAB_WIZ_COPYTABLE:CB_USEHEADERLINE";
+ Pos = MAP_APPFONT ( 12, 93 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 18, 10 ) ;
+ Text [ en-US ] = "Use first ~line as column names" ;
+ };
+
+ CheckBox CB_PRIMARY_COLUMN
+ {
+ HelpID = "dbaccess:CheckBox:TAB_WIZ_COPYTABLE:CB_PRIMARY_COLUMN";
+ Pos = MAP_APPFONT ( 12, 107 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "Crea~te primary key";
+ };
+ FixedText FT_KEYNAME
+ {
+ Pos = MAP_APPFONT ( 21 , 122 ) ;
+ Size = MAP_APPFONT ( 39 , 8 ) ;
+ Text [ en-US ] = "Name";
+ };
+
+ Edit ET_KEYNAME
+ {
+ HelpID = "dbaccess:Edit:TAB_WIZ_COPYTABLE:ET_KEYNAME";
+ Pos = MAP_APPFONT ( 80, 120 ) ;
+ Size = MAP_APPFONT ( 65 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+};
+
+String STR_WIZ_TABLE_COPY
+{
+ Text [ en-US ] = "Copy table" ;
+};
+
+String STR_COPYTABLE_TITLE_COPY
+{
+ Text [ en-US ] = "Copy table" ;
+};
+
+String STR_INVALID_TABLE_NAME
+{
+ Text [ en-US ] = "This table name is not valid in the current database.";
+};
+String STR_SUGGEST_APPEND_TABLE_DATA
+{
+ Text [ en-US ] = "Choose the option 'Append data' on the first page to append data to an existing table.";
+};
+
+String STR_INVALID_TABLE_NAME_LENGTH
+{
+ Text [ en-US ] = "Please change the table name. It is too long.";
+};
diff --git a/dbaccess/source/ui/misc/asyncmodaldialog.cxx b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
new file mode 100644
index 000000000000..5d866839748e
--- /dev/null
+++ b/dbaccess/source/ui/misc/asyncmodaldialog.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "asyncmodaldialog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/svapp.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::ui::dialogs::XExecutableDialog;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= AsyncDialogExecutor
+ //====================================================================
+ class DialogExecutor_Impl
+ {
+ Reference< XExecutableDialog > m_xDialog;
+
+ public:
+ DialogExecutor_Impl( const Reference< XExecutableDialog >& _rxDialog )
+ :m_xDialog( _rxDialog )
+ {
+ }
+
+ void execute()
+ {
+ Application::PostUserEvent( LINK( this, DialogExecutor_Impl, onExecute ) );
+ }
+
+ protected:
+ ~DialogExecutor_Impl()
+ {
+ }
+
+ private:
+ DECL_LINK( onExecute, void* );
+ };
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DialogExecutor_Impl, onExecute, void*, /* _notInterestedIn */ )
+ {
+ try
+ {
+ m_xDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ delete this;
+ return 0L;
+ }
+
+ //====================================================================
+ //= AsyncDialogExecutor
+ //====================================================================
+ //--------------------------------------------------------------------
+ void AsyncDialogExecutor::executeModalDialogAsync( const Reference< XExecutableDialog >& _rxDialog )
+ {
+ if ( !_rxDialog.is() )
+ throw IllegalArgumentException();
+
+
+ DialogExecutor_Impl* pExecutor = new DialogExecutor_Impl( _rxDialog );
+ pExecutor->execute();
+ // will delete itself
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/charsets.cxx b/dbaccess/source/ui/misc/charsets.cxx
new file mode 100644
index 000000000000..425aef75db87
--- /dev/null
+++ b/dbaccess/source/ui/misc/charsets.cxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "charsets.hxx"
+#include <osl/diagnose.h>
+#include "dbu_misc.hrc"
+#include <rtl/tencinfo.h>
+#include <tools/rcid.h>
+#include "localresaccess.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::dbtools;
+
+ //=========================================================================
+ //= OCharsetDisplay
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::OCharsetDisplay()
+ :OCharsetMap()
+ ,SvxTextEncodingTable()
+ {
+ {
+ LocalResourceAccess aCharsetStrings( RSC_CHARSETS, RSC_RESOURCE );
+ m_aSystemDisplayName = String( ModuleRes( 1 ) );
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool OCharsetDisplay::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const
+ {
+ if ( !OCharsetMap::approveEncoding( _eEncoding, _rInfo ) )
+ return sal_False;
+
+ if ( RTL_TEXTENCODING_DONTKNOW == _eEncoding )
+ return sal_True;
+
+ return 0 != GetTextString( _eEncoding ).Len();
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::begin() const
+ {
+ return const_iterator( this, OCharsetMap::begin() );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::end() const
+ {
+ return const_iterator( this, OCharsetMap::end() );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findEncoding(const rtl_TextEncoding _eEncoding) const
+ {
+ OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_eEncoding);
+ return const_iterator( this, aBaseIter );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findIanaName(const ::rtl::OUString& _rIanaName) const
+ {
+ OCharsetMap::const_iterator aBaseIter = OCharsetMap::find(_rIanaName, OCharsetMap::IANA());
+ return const_iterator( this, aBaseIter );
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::const_iterator OCharsetDisplay::findDisplayName(const ::rtl::OUString& _rDisplayName) const
+ {
+ rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if ( _rDisplayName != m_aSystemDisplayName )
+ {
+ eEncoding = GetTextEncoding( _rDisplayName );
+ OSL_ENSURE( RTL_TEXTENCODING_DONTKNOW != eEncoding,
+ "OCharsetDisplay::find: non-empty display name, but DONTKNOW!" );
+ }
+ return const_iterator( this, OCharsetMap::find( eEncoding ) );
+ }
+
+ //=========================================================================
+ //= CharsetDisplayDerefHelper
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource)
+ :CharsetDisplayDerefHelper_Base(_rSource)
+ ,m_sDisplayName(m_sDisplayName)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper::CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper_Base& _rBase, const ::rtl::OUString& _rDisplayName)
+ :CharsetDisplayDerefHelper_Base(_rBase)
+ ,m_sDisplayName(_rDisplayName)
+ {
+ OSL_ENSURE( m_sDisplayName.getLength(), "CharsetDisplayDerefHelper::CharsetDisplayDerefHelper: invalid display name!" );
+ }
+
+ //=========================================================================
+ //= OCharsetDisplay::ExtendedCharsetIterator
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition )
+ :m_pContainer(_pContainer)
+ ,m_aPosition(_rPosition)
+ {
+ OSL_ENSURE(m_pContainer, "OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator : invalid container!");
+ }
+
+ //-------------------------------------------------------------------------
+ OCharsetDisplay::ExtendedCharsetIterator::ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource)
+ :m_pContainer( _rSource.m_pContainer )
+ ,m_aPosition( _rSource.m_aPosition )
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ CharsetDisplayDerefHelper OCharsetDisplay::ExtendedCharsetIterator::operator*() const
+ {
+ OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator* : invalid position!");
+
+ rtl_TextEncoding eEncoding = (*m_aPosition).getEncoding();
+ return CharsetDisplayDerefHelper(
+ *m_aPosition,
+ RTL_TEXTENCODING_DONTKNOW == eEncoding ? m_pContainer->m_aSystemDisplayName : (::rtl::OUString)m_pContainer->GetTextString( eEncoding )
+ );
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator++()
+ {
+ OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::end(), "OCharsetDisplay::ExtendedCharsetIterator::operator++ : invalid position!");
+ if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::end() )
+ ++m_aPosition;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ const OCharsetDisplay::ExtendedCharsetIterator& OCharsetDisplay::ExtendedCharsetIterator::operator--()
+ {
+ OSL_ENSURE( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin(), "OCharsetDisplay::ExtendedCharsetIterator::operator-- : invalid position!");
+ if ( m_aPosition != m_pContainer->OCharsetDisplay_Base::begin() )
+ --m_aPosition;
+ return *this;
+ }
+
+ //-------------------------------------------------------------------------
+ bool operator==(const OCharsetDisplay::ExtendedCharsetIterator& lhs, const OCharsetDisplay::ExtendedCharsetIterator& rhs)
+ {
+ return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_aPosition == rhs.m_aPosition);
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/controllerframe.cxx b/dbaccess/source/ui/misc/controllerframe.cxx
new file mode 100644
index 000000000000..54d612329400
--- /dev/null
+++ b/dbaccess/source/ui/misc/controllerframe.cxx
@@ -0,0 +1,441 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "controllerframe.hxx"
+#include "IController.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/frame/XController2.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <sfx2/objsh.hxx>
+#include <tools/diagnose_ex.h>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::FrameAction;
+ using ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED;
+ using ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED;
+ using ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING;
+ using ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XController2;
+ using ::com::sun::star::frame::XFramesSupplier;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::awt::XTopWindow;
+ using ::com::sun::star::awt::XTopWindowListener;
+ using ::com::sun::star::awt::XWindow2;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::document::XDocumentEventBroadcaster;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= FrameWindowActivationListener
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XTopWindowListener
+ > FrameWindowActivationListener_Base;
+ class FrameWindowActivationListener : public FrameWindowActivationListener_Base
+ {
+ public:
+ FrameWindowActivationListener( ControllerFrame_Data& _rData );
+
+ void dispose();
+
+ protected:
+ ~FrameWindowActivationListener();
+
+ // XTopWindowListener
+ virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ void impl_checkDisposed_throw() const;
+ void impl_registerOnFrameContainerWindow_nothrow( bool _bRegister );
+
+ private:
+ ControllerFrame_Data* m_pData;
+ };
+
+ //====================================================================
+ //= ControllerFrame_Data
+ //====================================================================
+ struct ControllerFrame_Data
+ {
+ ControllerFrame_Data( IController& _rController )
+ :m_rController( _rController )
+ ,m_xFrame()
+ ,m_xDocEventBroadcaster()
+ ,m_pListener()
+ ,m_bActive( false )
+ ,m_bIsTopLevelDocumentWindow( false )
+ {
+ }
+
+ IController& m_rController;
+ Reference< XFrame > m_xFrame;
+ Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster;
+ ::rtl::Reference< FrameWindowActivationListener > m_pListener;
+ bool m_bActive;
+ bool m_bIsTopLevelDocumentWindow;
+ };
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ static void lcl_setFrame_nothrow( ControllerFrame_Data& _rData, const Reference< XFrame >& _rxFrame )
+ {
+ // release old listener
+ if ( _rData.m_pListener.get() )
+ {
+ _rData.m_pListener->dispose();
+ _rData.m_pListener = NULL;
+ }
+
+ // remember new frame
+ _rData.m_xFrame = _rxFrame;
+
+ // create new listener
+ if ( _rData.m_xFrame.is() )
+ _rData.m_pListener = new FrameWindowActivationListener( _rData );
+
+ // at this point in time, we can assume the controller also has a model set, if it supports models
+ try
+ {
+ Reference< XController > xController( _rData.m_rController.getXController(), UNO_SET_THROW );
+ Reference< XModel > xModel( xController->getModel() );
+ if ( xModel.is() )
+ _rData.m_xDocEventBroadcaster.set( xModel, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ static bool lcl_isActive_nothrow( const Reference< XFrame >& _rxFrame )
+ {
+ bool bIsActive = false;
+ try
+ {
+ if ( _rxFrame.is() )
+ {
+ Reference< XWindow2 > xWindow( _rxFrame->getContainerWindow(), UNO_QUERY_THROW );
+ bIsActive = xWindow->isActive();
+ }
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsActive;
+ }
+
+ //--------------------------------------------------------------------
+ /** updates various global and local states with a new active component
+
+ In particular, the following are updated
+ * the global working document (aka Basic's ThisComponent in the application
+ Basic), with our controller's model, or the controller itself if there is no such
+ model.
+ */
+ static void lcl_updateActiveComponents_nothrow( const ControllerFrame_Data& _rData )
+ {
+ try
+ {
+ Reference< XController > xCompController( _rData.m_rController.getXController() );
+ OSL_ENSURE( xCompController.is(), "lcl_updateActiveComponents_nothrow: can't do anything without a controller!" );
+ if ( !xCompController.is() )
+ return;
+
+ if ( _rData.m_bActive && _rData.m_bIsTopLevelDocumentWindow )
+ {
+ // set the "current component" at the SfxObjectShell
+ Reference< XModel > xModel( xCompController->getModel() );
+ Reference< XInterface > xCurrentComponent;
+ if ( xModel.is() )
+ xCurrentComponent = xModel;
+ else
+ xCurrentComponent = xCompController;
+ SfxObjectShell::SetCurrentComponent( xCurrentComponent );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ /** broadcasts the OnFocus resp. OnUnfocus event
+ */
+ static void lcl_notifyFocusChange_nothrow( ControllerFrame_Data& _rData, bool _bActive )
+ {
+ try
+ {
+ if ( _rData.m_xDocEventBroadcaster.is() )
+ {
+ ::rtl::OUString sEventName = _bActive ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnFocus")) : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnfocus"));
+ Reference< XController2 > xController( _rData.m_rController.getXController(), UNO_QUERY_THROW );
+ _rData.m_xDocEventBroadcaster->notifyDocumentEvent( sEventName, xController, Any() );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ static void lcl_updateActive_nothrow( ControllerFrame_Data& _rData, bool _bActive )
+ {
+ if ( _rData.m_bActive == _bActive )
+ return;
+ _rData.m_bActive = _bActive;
+
+ lcl_updateActiveComponents_nothrow( _rData );
+ lcl_notifyFocusChange_nothrow( _rData, _bActive );
+ }
+
+ //--------------------------------------------------------------------
+ FrameWindowActivationListener::FrameWindowActivationListener( ControllerFrame_Data& _rData )
+ :m_pData( &_rData )
+ {
+ impl_registerOnFrameContainerWindow_nothrow( true );
+ }
+
+ //--------------------------------------------------------------------
+ FrameWindowActivationListener::~FrameWindowActivationListener()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::dispose()
+ {
+ impl_registerOnFrameContainerWindow_nothrow( false );
+ m_pData = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow( bool _bRegister )
+ {
+ OSL_ENSURE( m_pData && m_pData->m_xFrame.is(), "FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow: no frame!" );
+ if ( !m_pData || !m_pData->m_xFrame.is() )
+ return;
+
+ try
+ {
+ void ( SAL_CALL XTopWindow::*pListenerAction )( const Reference< XTopWindowListener >& ) =
+ _bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener;
+
+ const Reference< XWindow > xContainerWindow( m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW );
+ if ( _bRegister )
+ {
+ const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no Window implementation for the frame's container window!" );
+
+ m_pData->m_bIsTopLevelDocumentWindow = ( pContainerWindow->GetExtendedStyle() & WB_EXT_DOCUMENT ) != 0;
+ }
+
+ const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY );
+ if ( xFrameContainer.is() )
+ (xFrameContainer.get()->*pListenerAction)( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FrameWindowActivationListener::impl_checkDisposed_throw() const
+ {
+ if ( !m_pData )
+ throw DisposedException( ::rtl::OUString(), *const_cast< FrameWindowActivationListener* >( this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowOpened( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowClosing( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowClosed( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowMinimized( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowNormalized( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowActivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+ lcl_updateActive_nothrow( *m_pData, true );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::windowDeactivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+ lcl_updateActive_nothrow( *m_pData, false );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FrameWindowActivationListener::disposing( const EventObject& /*_rEvent*/ ) throw (RuntimeException)
+ {
+ dispose();
+ }
+
+ //====================================================================
+ //= ControllerFrame
+ //====================================================================
+ //--------------------------------------------------------------------
+ ControllerFrame::ControllerFrame( IController& _rController )
+ :m_pData( new ControllerFrame_Data( _rController ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ControllerFrame::~ControllerFrame()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XFrame >& ControllerFrame::attachFrame( const Reference< XFrame >& _rxFrame )
+ {
+ // set new frame, including listener handling
+ lcl_setFrame_nothrow( *m_pData, _rxFrame );
+
+ // determine whether we're active
+ m_pData->m_bActive = lcl_isActive_nothrow( m_pData->m_xFrame );
+
+ // update active component
+ if ( m_pData->m_bActive )
+ {
+ lcl_updateActiveComponents_nothrow( *m_pData );
+ lcl_notifyFocusChange_nothrow( *m_pData, true );
+ }
+
+ return m_pData->m_xFrame;
+ }
+
+ //--------------------------------------------------------------------
+ const Reference< XFrame >& ControllerFrame::getFrame() const
+ {
+ return m_pData->m_xFrame;
+ }
+
+ //--------------------------------------------------------------------
+ bool ControllerFrame::isActive() const
+ {
+ return m_pData->m_bActive;
+ }
+
+ //--------------------------------------------------------------------
+ void ControllerFrame::frameAction( FrameAction _eAction )
+ {
+ bool bActive = m_pData->m_bActive;
+
+ switch ( _eAction )
+ {
+ case FrameAction_FRAME_ACTIVATED:
+ case FrameAction_FRAME_UI_ACTIVATED:
+ bActive = true;
+ break;
+
+ case FrameAction_FRAME_DEACTIVATING:
+ case FrameAction_FRAME_UI_DEACTIVATING:
+ bActive = false;
+ break;
+
+ default:
+ break;
+ }
+
+ lcl_updateActive_nothrow( *m_pData, bActive );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
new file mode 100644
index 000000000000..967f9752eb4d
--- /dev/null
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -0,0 +1,346 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "databaseobjectview.hxx"
+#include "dbustrings.hrc"
+#include "asyncmodaldialog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbtools.hxx>
+#include <osl/diagnose.h>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/window.hxx>
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdb::application;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::awt;
+
+ //======================================================================
+ //= DatabaseObjectView
+ //======================================================================
+ DatabaseObjectView::DatabaseObjectView( const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XDatabaseDocumentUI >& _rxApplication,
+ const Reference< XFrame >& _rxParentFrame,
+ const ::rtl::OUString& _rComponentURL )
+ :m_xORB ( _rxORB )
+ ,m_xParentFrame ( _rxParentFrame )
+ ,m_xFrameLoader ( )
+ ,m_xApplication ( _rxApplication )
+ ,m_sComponentURL ( _rComponentURL )
+ {
+ OSL_ENSURE( m_xORB.is(), "DatabaseObjectView::DatabaseObjectView: invalid service factory!" );
+ OSL_ENSURE( m_xApplication.is(), "DatabaseObjectView::DatabaseObjectView: invalid connection!" );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XConnection > DatabaseObjectView::getConnection() const
+ {
+ Reference< XConnection > xConnection;
+ if ( m_xApplication.is() )
+ xConnection = m_xApplication->getActiveConnection();
+ return xConnection;
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::createNew( const Reference< XDataSource >& _xDataSource, const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ return doCreateView( makeAny( _xDataSource ), ::rtl::OUString(), i_rDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::openExisting( const Any& _rDataSource, const ::rtl::OUString& _rName,
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ return doCreateView( _rDataSource, _rName, i_rDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
+ {
+ ::comphelper::NamedValueCollection aDispatchArgs;
+
+ aDispatchArgs.merge( i_rCreationArgs, false ); // false => do not overwrite
+ fillDispatchArgs( aDispatchArgs, _rDataSource, _rObjectName );
+ aDispatchArgs.merge( i_rCreationArgs, true ); // true => do overwrite
+
+ return doDispatch( aDispatchArgs );
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > DatabaseObjectView::doDispatch( const ::comphelper::NamedValueCollection& i_rDispatchArgs )
+ {
+ Reference< XComponent > xReturn;
+ if ( m_xORB.is() )
+ {
+ try
+ {
+ // if we have no externally provided frame, create one
+ if ( !m_xFrameLoader.is() )
+ {
+ Reference< XSingleServiceFactory > xFact(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.TaskCreator"))), UNO_QUERY_THROW);
+ Sequence< Any > lArgs(2);
+ NamedValue aProp;
+ sal_Int32 nArg = 0;
+
+ aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame"));
+ aProp.Value <<= m_xParentFrame;
+ lArgs[nArg++] <<= aProp;
+
+ aProp.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TopWindow"));
+ aProp.Value <<= sal_True;
+ lArgs[nArg++] <<= aProp;
+
+ m_xFrameLoader.set(xFact->createInstanceWithArguments(lArgs), UNO_QUERY_THROW);
+
+ // everything we load can be considered a "top level document", so set the respective bit at the window.
+ // This, amongst other things, triggers that the component in this task participates in the
+ // "ThisComponent"-game for the global application Basic.
+ const Reference< XFrame > xFrame( m_xFrameLoader, UNO_QUERY_THROW );
+ const Reference< XWindow > xFrameWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
+ Window* pContainerWindow = VCLUnoHelper::GetWindow( xFrameWindow );
+ ENSURE_OR_THROW( pContainerWindow, "no implementation access to the frame's container window!" );
+ pContainerWindow->SetExtendedStyle( pContainerWindow->GetExtendedStyle() | WB_EXT_DOCUMENT );
+ }
+
+ Reference< XComponentLoader > xFrameLoader( m_xFrameLoader, UNO_QUERY_THROW );
+ xReturn = xFrameLoader->loadComponentFromURL(
+ m_sComponentURL,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")),
+ 0,
+ i_rDispatchArgs.getPropertyValues()
+ );
+
+ if ( !xReturn.is() )
+ xReturn.set( m_xFrameLoader, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return xReturn;
+ }
+
+ //----------------------------------------------------------------------
+ void DatabaseObjectView::fillDispatchArgs(
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
+ const Any& _aDataSource,
+ const ::rtl::OUString& /* _rName */
+ )
+ {
+ ::rtl::OUString sDataSource;
+ Reference<XDataSource> xDataSource;
+ if ( _aDataSource >>= sDataSource )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCENAME, sDataSource );
+ }
+ else if ( _aDataSource >>= xDataSource )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCE, xDataSource );
+ }
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, getConnection() );
+ }
+
+ //======================================================================
+ //= QueryDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ QueryDesigner::QueryDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication,
+ const Reference< XFrame >& _rxParentFrame, bool _bCreateView )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, _bCreateView ? URL_COMPONENT_VIEWDESIGN : URL_COMPONENT_QUERYDESIGN )
+ ,m_nCommandType( _bCreateView ? CommandType::TABLE : CommandType::QUERY )
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void QueryDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName )
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
+
+ const bool bIncludeQueryName = 0 != _rObjectName.getLength();
+ const bool bGraphicalDesign = i_rDispatchArgs.getOrDefault( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, sal_True );
+ const bool bEditViewAsSQLCommand = ( m_nCommandType == CommandType::TABLE ) && !bGraphicalDesign;
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, m_nCommandType );
+
+ if ( bIncludeQueryName )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rObjectName );
+ }
+
+ if ( bEditViewAsSQLCommand )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, sal_False );
+ }
+ }
+
+ //======================================================================
+ //= TableDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ TableDesigner::TableDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( URL_COMPONENT_TABLEDESIGN ) )
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void TableDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rObjectName )
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
+
+ if ( 0 != _rObjectName.getLength() )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_CURRENTTABLE, _rObjectName );
+ }
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XComponent > TableDesigner::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
+ {
+ bool bIsNewDesign = ( _rObjectName.getLength() == 0 );
+
+ // let's see whether the connection can provide a dedicated table desginer
+ Reference< XInterface > xDesigner;
+ if ( !bIsNewDesign )
+ xDesigner = impl_getConnectionProvidedDesigner_nothrow( _rObjectName );
+
+ if ( !xDesigner.is() )
+ return DatabaseObjectView::doCreateView( _rDataSource, _rObjectName, i_rCreationArgs );
+
+ // try whether the designer is a dialog
+ Reference< XExecutableDialog > xDialog( xDesigner, UNO_QUERY_THROW );
+ if ( xDialog.is() )
+ {
+ try { AsyncDialogExecutor::executeModalDialogAsync( xDialog ); }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ return NULL;
+ }
+
+ Reference< XComponent > xDesignerComponent( xDesigner, UNO_QUERY );
+ OSL_ENSURE( xDesignerComponent.is(), "TableDesigner::doCreateView: a designer which is no dialog and no component?" );
+ return xDesignerComponent;
+ }
+
+ //----------------------------------------------------------------------
+ Reference< XInterface > TableDesigner::impl_getConnectionProvidedDesigner_nothrow( const ::rtl::OUString& _rTableName )
+ {
+ Reference< XInterface > xDesigner;
+ try
+ {
+ Reference< XTableUIProvider > xTableUIProv( getConnection(), UNO_QUERY );
+ if ( xTableUIProv.is() )
+ xDesigner = xTableUIProv->getTableEditor( getApplicationUI(), _rTableName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xDesigner;
+ }
+
+ //======================================================================
+ //= ResultSetBrowser
+ //======================================================================
+ //----------------------------------------------------------------------
+ ResultSetBrowser::ResultSetBrowser( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame,
+ sal_Bool _bTable )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast < ::rtl::OUString >( URL_COMPONENT_DATASOURCEBROWSER ) )
+ ,m_bTable(_bTable)
+ {
+ }
+
+ //----------------------------------------------------------------------
+ void ResultSetBrowser::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
+ const ::rtl::OUString& _rQualifiedName)
+ {
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rQualifiedName );
+ OSL_ENSURE( 0 != _rQualifiedName.getLength(),"A Table name must be set");
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+ if ( m_bTable )
+ ::dbtools::qualifiedNameComponents( getConnection()->getMetaData(), _rQualifiedName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, (m_bTable ? CommandType::TABLE : CommandType::QUERY) );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rQualifiedName );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ENABLE_BROWSER, sal_False );
+
+ if ( m_bTable )
+ {
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_CATALOGNAME, sCatalog );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_SCHEMANAME, sSchema );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_TABLENAME, sTable );
+ }
+ }
+
+ //======================================================================
+ //= RelationDesigner
+ //======================================================================
+ //----------------------------------------------------------------------
+ RelationDesigner::RelationDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication, const Reference< XFrame >& _rxParentFrame )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( URL_COMPONENT_RELATIONDESIGN ) )
+ {
+ }
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
new file mode 100644
index 000000000000..abd0aceb9433
--- /dev/null
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -0,0 +1,235 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "datasourceconnector.hxx"
+#include <osl/diagnose.h>
+#include "dbustrings.hrc"
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <osl/thread.h>
+#include <comphelper/extract.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include "UITools.hxx"
+#include <vcl/stdtext.hxx>
+#include <vcl/button.hxx>
+#include <svl/filenotation.hxx>
+#include <tools/diagnose_ex.h>
+#include <cppuhelper/exc_hlp.hxx>
+#include "dbu_misc.hrc"
+#include "moduledbu.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+ using namespace ::dbtools;
+ using ::svt::OFileNotation;
+
+ //=====================================================================
+ //= ODatasourceConnector
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODatasourceConnector::ODatasourceConnector(const Reference< XMultiServiceFactory >& _rxORB, Window* _pMessageParent)
+ :m_pErrorMessageParent(_pMessageParent)
+ ,m_xORB(_rxORB)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ ODatasourceConnector::ODatasourceConnector( const Reference< XMultiServiceFactory >& _rxORB, Window* _pMessageParent,
+ const ::rtl::OUString& _rContextInformation )
+ :m_pErrorMessageParent(_pMessageParent)
+ ,m_xORB(_rxORB)
+ ,m_sContextInformation( _rContextInformation )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > ODatasourceConnector::connect( const ::rtl::OUString& _rDataSourceName,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
+ {
+ Reference< XConnection > xConnection;
+
+ OSL_ENSURE(isValid(), "ODatasourceConnector::connect: invalid object!");
+ if (!isValid())
+ return xConnection;
+
+ // get the data source
+ Reference< XDataSource > xDatasource(
+ getDataSourceByName( _rDataSourceName, m_pErrorMessageParent, m_xORB, _pErrorInfo ),
+ UNO_QUERY
+ );
+
+ if ( xDatasource.is() )
+ xConnection = connect( xDatasource, _pErrorInfo );
+ return xConnection;
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > ODatasourceConnector::connect(const Reference< XDataSource>& _xDataSource,
+ ::dbtools::SQLExceptionInfo* _pErrorInfo ) const
+ {
+ Reference< XConnection > xConnection;
+
+ OSL_ENSURE( isValid() && _xDataSource.is(), "ODatasourceConnector::connect: invalid object or argument!" );
+ if ( !isValid() || !_xDataSource.is() )
+ return xConnection;
+
+ // get user/password
+ ::rtl::OUString sPassword, sUser;
+ sal_Bool bPwdRequired = sal_False;
+ Reference<XPropertySet> xProp(_xDataSource,UNO_QUERY);
+ try
+ {
+ xProp->getPropertyValue(PROPERTY_PASSWORD) >>= sPassword;
+ xProp->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED) >>= bPwdRequired;
+ xProp->getPropertyValue(PROPERTY_USER) >>= sUser;
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // try to connect
+ SQLExceptionInfo aInfo;
+ try
+ {
+ if (bPwdRequired && !sPassword.getLength())
+ { // password required, but empty -> connect using an interaction handler
+ Reference< XCompletedConnection > xConnectionCompletion( _xDataSource, UNO_QUERY_THROW );
+
+ Reference< XModel > xModel( getDataSourceOrModel( _xDataSource ), UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aArgs( xModel->getArgs() );
+ Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) );
+
+ if ( !xHandler.is() )
+ {
+ // instantiate the default SDB interaction handler
+ xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_TASK_INTERACTION_HANDLER ), UNO_QUERY );
+ if ( !xHandler.is() )
+ ShowServiceNotAvailableError(m_pErrorMessageParent, (::rtl::OUString)SERVICE_TASK_INTERACTION_HANDLER, sal_True);
+ }
+
+ if ( xHandler.is() )
+ {
+ xConnection = xConnectionCompletion->connectWithCompletion(xHandler);
+ }
+ }
+ else
+ {
+ xConnection = _xDataSource->getConnection(sUser, sPassword);
+ }
+ }
+ catch( const SQLException& )
+ {
+ aInfo = ::cppu::getCaughtException();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !aInfo.isValid() )
+ {
+ // there was no error during connecting, but perhaps a warning?
+ Reference< XWarningsSupplier > xConnectionWarnings( xConnection, UNO_QUERY );
+ if ( xConnectionWarnings.is() )
+ {
+ try
+ {
+ Any aWarnings( xConnectionWarnings->getWarnings() );
+ if ( aWarnings.hasValue() )
+ {
+ String sMessage( ModuleRes( STR_WARNINGS_DURING_CONNECT ) );
+ sMessage.SearchAndReplaceAscii( "$buttontext$", Button::GetStandardText( BUTTON_MORE ) );
+ sMessage = OutputDevice::GetNonMnemonicString( sMessage );
+
+ SQLWarning aContext;
+ aContext.Message = sMessage;
+ aContext.NextException = aWarnings;
+ aInfo = aContext;
+ }
+ xConnectionWarnings->clearWarnings();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ else
+ {
+ if ( m_sContextInformation.getLength() )
+ {
+ SQLException aError;
+ aError.Message = m_sContextInformation;
+ aError.NextException = aInfo.get();
+
+ aInfo = aError;
+ }
+ }
+
+ // was there an error?
+ if ( aInfo.isValid() )
+ {
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = aInfo;
+ }
+ else
+ {
+ showError( aInfo, m_pErrorMessageParent, m_xORB );
+ }
+ }
+ return xConnection;
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/dbaundomanager.cxx b/dbaccess/source/ui/misc/dbaundomanager.cxx
new file mode 100644
index 000000000000..83f55e0cbc5e
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbaundomanager.cxx
@@ -0,0 +1,394 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_dbaccess.hxx"
+
+#include "dbaundomanager.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <svl/undo.hxx>
+#include <vcl/svapp.hxx>
+#include <framework/undomanagerhelper.hxx>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::document::UndoContextNotClosedException;
+ using ::com::sun::star::document::UndoFailedException;
+ using ::com::sun::star::document::EmptyUndoStackException;
+ using ::com::sun::star::util::InvalidStateException;
+ using ::com::sun::star::document::XUndoAction;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::document::XUndoManagerListener;
+ using ::com::sun::star::util::NotLockedException;
+ using ::com::sun::star::lang::NoSupportException;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= UndoManager_Impl
+ //==================================================================================================================
+ struct UndoManager_Impl : public ::framework::IUndoManagerImplementation
+ {
+ UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :rAntiImpl( i_antiImpl )
+ ,rParent( i_parent )
+ ,rMutex( i_mutex )
+ ,bDisposed( false )
+ ,aUndoManager()
+ ,aUndoHelper( *this )
+ {
+ }
+
+ virtual ~UndoManager_Impl()
+ {
+ }
+
+ UndoManager& rAntiImpl;
+ ::cppu::OWeakObject& rParent;
+ ::osl::Mutex& rMutex;
+ bool bDisposed;
+ SfxUndoManager aUndoManager;
+ ::framework::UndoManagerHelper aUndoHelper;
+
+ // IUndoManagerImplementation
+ virtual ::svl::IUndoManager& getImplUndoManager();
+ virtual Reference< XUndoManager > getThis();
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::svl::IUndoManager& UndoManager_Impl::getImplUndoManager()
+ {
+ return aUndoManager;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XUndoManager > UndoManager_Impl::getThis()
+ {
+ return static_cast< XUndoManager* >( &rAntiImpl );
+ }
+
+ //==============================================================================================================
+ //= OslMutexFacade
+ //==============================================================================================================
+ class OslMutexFacade : public ::framework::IMutex
+ {
+ public:
+ OslMutexFacade( ::osl::Mutex& i_mutex )
+ :m_rMutex( i_mutex )
+ {
+ }
+
+ virtual void acquire();
+ virtual void release();
+
+ private:
+ ::osl::Mutex& m_rMutex;
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ void OslMutexFacade::acquire()
+ {
+ m_rMutex.acquire();
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void OslMutexFacade::release()
+ {
+ m_rMutex.release();
+ }
+
+ //==============================================================================================================
+ //= UndoManagerMethodGuard
+ //==============================================================================================================
+ /** guard for public UNO methods of the UndoManager
+ */
+ class UndoManagerMethodGuard : public ::framework::IMutexGuard
+ {
+ public:
+ UndoManagerMethodGuard( UndoManager_Impl& i_impl )
+ :m_aGuard( i_impl.rMutex )
+ ,m_aMutexFacade( i_impl.rMutex )
+ {
+ // throw if the instance is already disposed
+ if ( i_impl.bDisposed )
+ throw DisposedException( ::rtl::OUString(), i_impl.getThis() );
+ }
+ virtual ~UndoManagerMethodGuard()
+ {
+ }
+
+ // IMutexGuard
+ virtual ::framework::IMutex& getGuardedMutex();
+
+ // IGuard
+ virtual void clear();
+ virtual void reset();
+
+ private:
+ ::osl::ResettableMutexGuard m_aGuard;
+ OslMutexFacade m_aMutexFacade;
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex()
+ {
+ return m_aMutexFacade;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::clear()
+ {
+ m_aGuard.clear();
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::reset()
+ {
+ m_aGuard.reset();
+ }
+
+ //==================================================================================================================
+ //= UndoManager
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pImpl( new UndoManager_Impl( *this, i_parent, i_mutex ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::~UndoManager()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ SfxUndoManager& UndoManager::GetSfxUndoManager() const
+ {
+ return m_pImpl->aUndoManager;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::acquire( ) throw ()
+ {
+ m_pImpl->rParent.acquire();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::release( ) throw ()
+ {
+ m_pImpl->rParent.release();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UndoManager::disposing()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_pImpl->rMutex );
+ m_pImpl->bDisposed = true;
+ }
+ m_pImpl->aUndoHelper.disposing();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.enterUndoContext( i_title, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.enterHiddenUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.leaveUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (IllegalArgumentException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.addUndoAction( i_action, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ // (all our UndoActions work directly on VCL code, usually, so ...)
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.undo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ // (all our UndoActions work directly on VCL code, usually, so ...)
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.redo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isUndoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isUndoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isRedoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isRedoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getCurrentUndoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getCurrentRedoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllUndoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getAllUndoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllRedoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.getAllRedoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.clear( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.clearRedo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::reset( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.reset( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.addUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.removeUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::lock( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.lock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::unlock( ) throw (NotLockedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->aUndoHelper.unlock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isLocked( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->aUndoHelper.isLocked();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL UndoManager::getParent( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return *&m_pImpl->rParent;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException)
+ {
+ (void)i_parent;
+ throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() );
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
new file mode 100644
index 000000000000..eb1b34710ff8
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
@@ -0,0 +1,672 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "browserids.hxx"
+#include "commontypes.hxx"
+#include "dataview.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "dbsubcomponentcontroller.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::sdbc::XDataSource;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::sdb::XOfficeDatabaseDocument;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdb::XDocumentDataSource;
+ using ::com::sun::star::document::XEmbeddedScripts;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::frame::XUntitledNumbers;
+ using ::com::sun::star::beans::PropertyVetoException;
+ /** === end UNO using === **/
+
+ class DataSourceHolder
+ {
+ public:
+ DataSourceHolder()
+ {
+ }
+
+ DataSourceHolder( const Reference< XDataSource >& _rxDataSource )
+ {
+ m_xDataSource = _rxDataSource;
+ Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY );
+ if ( xDocDS.is() )
+ m_xDocument = xDocDS->getDatabaseDocument();
+
+ m_xDataSourceProps.set( m_xDataSource, UNO_QUERY );
+ }
+
+ const Reference< XDataSource >& getDataSource() const { return m_xDataSource; }
+ const Reference< XPropertySet >& getDataSourceProps() const { return m_xDataSourceProps; }
+ const Reference< XOfficeDatabaseDocument > getDatabaseDocument() const { return m_xDocument; }
+
+ bool is() const { return m_xDataSource.is(); }
+
+ void clear()
+ {
+ m_xDataSource.clear();
+ m_xDocument.clear();
+ }
+
+ private:
+ Reference< XDataSource > m_xDataSource;
+ Reference< XPropertySet > m_xDataSourceProps;
+ Reference< XOfficeDatabaseDocument > m_xDocument;
+ };
+
+ struct DBSubComponentController_Impl
+ {
+ private:
+ ::boost::optional< bool > m_aDocScriptSupport;
+
+ public:
+ OModuleClient m_aModuleClient;
+ ::dbtools::SQLExceptionInfo m_aCurrentError;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aModifyListeners;
+
+ // <properties>
+ SharedConnection m_xConnection;
+ ::dbtools::DatabaseMetaData m_aSdbMetaData;
+ // </properties>
+ ::rtl::OUString m_sDataSourceName; // the data source we're working for
+ DataSourceHolder m_aDataSource;
+ Reference< XModel > m_xDocument;
+ Reference< XNumberFormatter > m_xFormatter; // a number formatter working with the connection's NumberFormatsSupplier
+ sal_Int32 m_nDocStartNumber;
+ sal_Bool m_bSuspended; // is true when the controller was already suspended
+ sal_Bool m_bEditable; // is the control readonly or not
+ sal_Bool m_bModified; // is the data modified
+ bool m_bNotAttached;
+
+ DBSubComponentController_Impl( ::osl::Mutex& i_rMutex )
+ :m_aDocScriptSupport()
+ ,m_aModifyListeners( i_rMutex )
+ ,m_nDocStartNumber(0)
+ ,m_bSuspended( sal_False )
+ ,m_bEditable(sal_True)
+ ,m_bModified(sal_False)
+ ,m_bNotAttached(true)
+ {
+ }
+
+ bool documentHasScriptSupport() const
+ {
+ OSL_PRECOND( !!m_aDocScriptSupport,
+ "DBSubComponentController_Impl::documentHasScriptSupport: not completely initialized, yet - don't know!?" );
+ return !!m_aDocScriptSupport && *m_aDocScriptSupport;
+ }
+
+ void setDocumentScriptSupport( const bool _bSupport )
+ {
+ OSL_PRECOND( !m_aDocScriptSupport,
+ "DBSubComponentController_Impl::setDocumentScriptSupport: already initialized!" );
+ m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
+ }
+ };
+
+ //====================================================================
+ //= DBSubComponentController
+ //====================================================================
+ //--------------------------------------------------------------------
+ DBSubComponentController::DBSubComponentController(const Reference< XMultiServiceFactory >& _rxORB)
+ :DBSubComponentController_Base( _rxORB )
+ ,m_pImpl( new DBSubComponentController_Impl( getMutex() ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DBSubComponentController::~DBSubComponentController()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::impl_initialize()
+ {
+ OGenericUnoController::impl_initialize();
+
+ const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
+
+ Reference< XConnection > xConnection;
+ xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, xConnection );
+
+ if ( !xConnection.is() )
+ ::dbtools::isEmbeddedInDatabase( getModel(), xConnection );
+
+ if ( xConnection.is() )
+ initializeConnection( xConnection );
+
+ bool bShowError = true;
+ if ( !isConnected() )
+ {
+ reconnect( sal_False );
+ bShowError = false;
+ }
+ if ( !isConnected() )
+ {
+ if ( bShowError )
+ connectionLostMessage();
+ throw IllegalArgumentException();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL DBSubComponentController::queryInterface(const Type& _rType) throw (RuntimeException)
+ {
+ if ( _rType.equals( XScriptInvocationContext::static_type() ) )
+ {
+ if ( m_pImpl->documentHasScriptSupport() )
+ return makeAny( Reference< XScriptInvocationContext >( this ) );
+ return Any();
+ }
+
+ return DBSubComponentController_Base::queryInterface( _rType );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL DBSubComponentController::getTypes( ) throw (RuntimeException)
+ {
+ Sequence< Type > aTypes( DBSubComponentController_Base::getTypes() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ {
+ Sequence< Type > aStrippedTypes( aTypes.getLength() - 1 );
+ ::std::remove_copy_if(
+ aTypes.getConstArray(),
+ aTypes.getConstArray() + aTypes.getLength(),
+ aStrippedTypes.getArray(),
+ ::std::bind2nd( ::std::equal_to< Type >(), XScriptInvocationContext::static_type() )
+ );
+ aTypes = aStrippedTypes;
+ }
+ return aTypes;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::initializeConnection( const Reference< XConnection >& _rxForeignConn )
+ {
+ DBG_ASSERT( !isConnected(), "DBSubComponentController::initializeConnection: not to be called when already connected!" );
+ // usually this gets called from within initialize of derived classes ...
+ if ( isConnected() )
+ disconnect();
+
+ m_pImpl->m_xConnection.reset( _rxForeignConn, SharedConnection::NoTakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ startConnectionListening( m_pImpl->m_xConnection );
+
+ // get the data source the connection belongs to
+ try
+ {
+ // determine our data source
+ OSL_PRECOND( !m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: already a data source in this phase?" );
+ {
+ Reference< XChild > xConnAsChild( m_pImpl->m_xConnection, UNO_QUERY );
+ Reference< XDataSource > xDS;
+ if ( xConnAsChild.is() )
+ xDS = Reference< XDataSource >( xConnAsChild->getParent(), UNO_QUERY );
+
+ // (take the indirection through XDataSource to ensure we have a correct object ....)
+ m_pImpl->m_aDataSource = xDS;
+ }
+ OSL_POSTCOND( m_pImpl->m_aDataSource.is(), "DBSubComponentController::initializeConnection: unable to obtain the data source object!" );
+
+ if ( m_pImpl->m_bNotAttached )
+ {
+ Reference< XUntitledNumbers > xUntitledProvider( getDatabaseDocument(), UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+ }
+
+ // determine the availability of script support in our document. Our own XScriptInvocationContext
+ // interface depends on this
+ m_pImpl->setDocumentScriptSupport( Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY ).is() );
+
+ // get a number formatter
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps(), UNO_SET_THROW );
+ xDataSourceProps->getPropertyValue( PROPERTY_NAME ) >>= m_pImpl->m_sDataSourceName;
+ DBG_ASSERT( m_pImpl->m_sDataSourceName.getLength(), "DBSubComponentController::initializeConnection: invalid data source name!" );
+ Reference< XNumberFormatsSupplier> xSupplier = ::dbtools::getNumberFormats(m_pImpl->m_xConnection);
+ if(xSupplier.is())
+ {
+ m_pImpl->m_xFormatter = Reference< XNumberFormatter >(getORB()
+ ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY);
+ m_pImpl->m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ OSL_ENSURE(m_pImpl->m_xFormatter.is(),"No NumberFormatter!");
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::reconnect( sal_Bool _bUI )
+ {
+ OSL_ENSURE(!m_pImpl->m_bSuspended, "Cannot reconnect while suspended!");
+
+ stopConnectionListening( m_pImpl->m_xConnection );
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ // reconnect
+ sal_Bool bReConnect = sal_True;
+ if ( _bUI )
+ {
+ QueryBox aQuery( getView(), ModuleRes(QUERY_CONNECTION_LOST) );
+ bReConnect = ( RET_YES == aQuery.Execute() );
+ }
+
+ // now really reconnect ...
+ if ( bReConnect )
+ {
+ m_pImpl->m_xConnection.reset( connect( m_pImpl->m_aDataSource.getDataSource(), NULL ), SharedConnection::TakeOwnership );
+ m_pImpl->m_aSdbMetaData.reset( m_pImpl->m_xConnection );
+ }
+
+ // invalidate all slots
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::disconnect()
+ {
+ stopConnectionListening(m_pImpl->m_xConnection);
+ m_pImpl->m_aSdbMetaData.reset( NULL );
+ m_pImpl->m_xConnection.clear();
+
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::losingConnection()
+ {
+ // our connection was disposed so we need a new one
+ reconnect( sal_True );
+ InvalidateAll();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing()
+ {
+ DBSubComponentController_Base::disposing();
+
+ disconnect();
+
+ attachFrame( Reference < XFrame >() );
+
+ m_pImpl->m_aDataSource.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::disposing(const EventObject& _rSource) throw( RuntimeException )
+ {
+ if ( _rSource.Source == getConnection() )
+ {
+ if ( !m_pImpl->m_bSuspended // when already suspended then we don't have to reconnect
+ && !getBroadcastHelper().bInDispose
+ && !getBroadcastHelper().bDisposed
+ && isConnected()
+ )
+ {
+ losingConnection();
+ }
+ else
+ {
+ m_pImpl->m_xConnection.reset( m_pImpl->m_xConnection, SharedConnection::NoTakeOwnership );
+ // this prevents the "disposeComponent" call in disconnect
+ disconnect();
+ }
+ }
+ else
+ DBSubComponentController_Base::disposing( _rSource );
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::appendError( const ::rtl::OUString& _rErrorMessage, const ::dbtools::StandardSQLState _eSQLState,
+ const sal_Int32 _nErrorCode )
+ {
+ m_pImpl->m_aCurrentError.append( ::dbtools::SQLExceptionInfo::SQL_EXCEPTION, _rErrorMessage, getStandardSQLStateAscii( _eSQLState ),
+ _nErrorCode );
+ }
+ //--------------------------------------------------------------------
+ void DBSubComponentController::clearError()
+ {
+ m_pImpl->m_aCurrentError = ::dbtools::SQLExceptionInfo();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool DBSubComponentController::hasError() const
+ {
+ return m_pImpl->m_aCurrentError.isValid();
+ }
+
+ //--------------------------------------------------------------------
+ const ::dbtools::SQLExceptionInfo& DBSubComponentController::getError() const
+ {
+ return m_pImpl->m_aCurrentError;
+ }
+
+ //--------------------------------------------------------------------
+ void DBSubComponentController::displayError()
+ {
+ showError( m_pImpl->m_aCurrentError );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::suspend(sal_Bool bSuspend) throw( RuntimeException )
+ {
+ m_pImpl->m_bSuspended = bSuspend;
+ if ( !bSuspend && !isConnected() )
+ reconnect(sal_True);
+
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL DBSubComponentController::attachModel( const Reference< XModel > & _rxModel) throw( RuntimeException )
+ {
+ if ( !_rxModel.is() )
+ return sal_False;
+ if ( !DBSubComponentController_Base::attachModel( _rxModel ) )
+ return sal_False;
+
+ m_pImpl->m_bNotAttached = false;
+ if ( m_pImpl->m_nDocStartNumber == 1 )
+ releaseNumberForComponent();
+
+ Reference< XUntitledNumbers > xUntitledProvider( _rxModel, UNO_QUERY );
+ m_pImpl->m_nDocStartNumber = 1;
+ if ( xUntitledProvider.is() )
+ m_pImpl->m_nDocStartNumber = xUntitledProvider->leaseNumber( static_cast< XWeak* >( this ) );
+
+ return sal_True;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs)
+ {
+ if ( _nId == ID_BROWSER_CLOSE )
+ {
+ closeTask();
+ return;
+ }
+
+ DBSubComponentController_Base::Execute( _nId, _rArgs );
+ InvalidateFeature( _nId );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString DBSubComponentController::getDataSourceName() const
+ {
+ ::rtl::OUString sName;
+ Reference< XPropertySet > xDataSourceProps( m_pImpl->m_aDataSource.getDataSourceProps() );
+ if ( xDataSourceProps.is() )
+ xDataSourceProps->getPropertyValue(PROPERTY_NAME) >>= sName;
+ return sName;
+ }
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::connectionLostMessage() const
+ {
+ String aMessage(ModuleRes(RID_STR_CONNECTION_LOST));
+ Reference< XWindow > xWindow = getTopMostContainerWindow();
+ Window* pWin = NULL;
+ if ( xWindow.is() )
+ pWin = VCLUnoHelper::GetWindow(xWindow);
+ if ( !pWin )
+ pWin = getView()->Window::GetParent();
+
+ InfoBox(pWin, aMessage).Execute();
+ }
+ // -----------------------------------------------------------------------------
+ const Reference< XConnection >& DBSubComponentController::getConnection() const
+ {
+ return m_pImpl->m_xConnection;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isReadOnly() const
+ {
+ return !m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isEditable() const
+ {
+ return m_pImpl->m_bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::setEditable(sal_Bool _bEditable)
+ {
+ m_pImpl->m_bEditable = _bEditable;
+ }
+
+ // -----------------------------------------------------------------------------
+ const ::dbtools::DatabaseMetaData& DBSubComponentController::getSdbMetaData() const
+ {
+ return m_pImpl->m_aSdbMetaData;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::isConnected() const
+ {
+ return m_pImpl->m_xConnection.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XDatabaseMetaData > DBSubComponentController::getMetaData( ) const
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ try
+ {
+ if ( isConnected() )
+ xMeta.set( m_pImpl->m_xConnection->getMetaData(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xMeta;
+ }
+
+ // -----------------------------------------------------------------------------
+ const Reference< XPropertySet >& DBSubComponentController::getDataSource() const
+ {
+ return m_pImpl->m_aDataSource.getDataSourceProps();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::haveDataSource() const
+ {
+ return m_pImpl->m_aDataSource.is();
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getDatabaseDocument() const
+ {
+ return Reference< XModel >( m_pImpl->m_aDataSource.getDatabaseDocument(), UNO_QUERY );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XNumberFormatter > DBSubComponentController::getNumberFormatter() const
+ {
+ return m_pImpl->m_xFormatter;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XModel > DBSubComponentController::getPrivateModel() const
+ {
+ return getDatabaseDocument();
+ }
+ // -----------------------------------------------------------------------------
+ // XTitle
+ ::rtl::OUString SAL_CALL DBSubComponentController::getTitle()
+ throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( m_bExternalTitle )
+ return impl_getTitleHelper_throw()->getTitle ();
+
+ ::rtl::OUStringBuffer sTitle;
+ Reference< XTitle > xTitle(getPrivateModel(),UNO_QUERY);
+ if ( xTitle.is() )
+ {
+ sTitle.append( xTitle->getTitle() );
+ sTitle.appendAscii(" : ");
+ }
+ sTitle.append( getPrivateTitle() );
+ return sTitle.makeStringAndClear();
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Int32 DBSubComponentController::getCurrentStartNumber() const
+ {
+ return m_pImpl->m_nDocStartNumber;
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XEmbeddedScripts > SAL_CALL DBSubComponentController::getScriptContainer() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !m_pImpl->documentHasScriptSupport() )
+ return NULL;
+
+ return Reference< XEmbeddedScripts >( getDatabaseDocument(), UNO_QUERY_THROW );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::addModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.addInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::removeModifyListener( const Reference< XModifyListener >& i_Listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ m_pImpl->m_aModifyListeners.removeInterface( i_Listener );
+ }
+
+ // -----------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL DBSubComponentController::isModified( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ return impl_isModified();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL DBSubComponentController::setModified( ::sal_Bool i_bModified ) throw (PropertyVetoException, RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( getMutex() );
+
+ if ( m_pImpl->m_bModified == i_bModified )
+ return;
+
+ m_pImpl->m_bModified = i_bModified;
+ impl_onModifyChanged();
+
+ EventObject aEvent( *this );
+ aGuard.clear();
+ m_pImpl->m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvent );
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool DBSubComponentController::impl_isModified() const
+ {
+ return m_pImpl->m_bModified;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DBSubComponentController::impl_onModifyChanged()
+ {
+ InvalidateFeature( ID_BROWSER_SAVEDOC );
+ if ( isFeatureSupported( ID_BROWSER_SAVEASDOC ) )
+ InvalidateFeature( ID_BROWSER_SAVEASDOC );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/misc/dbumiscres.hrc b/dbaccess/source/ui/misc/dbumiscres.hrc
new file mode 100644
index 000000000000..81b72e5dda87
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbumiscres.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_MISCRES_HRC_
+#define _DBU_MISCRES_HRC_
+
+//========================================================================
+// string ids (relative to other resources, that's why not unique)
+
+#define STR_MYSQL_ODBC 1
+#define STR_MYSQL_JDBC 2
+#define STR_ADABAS 3
+#define STR_ORACLE_JDBC 4
+#define STR_JDBC 5
+#define STR_ODBC 6
+#define STR_DBASE 7
+#define STR_MSACCESS 8
+#define STR_MSACCESS2007 9
+#define STR_ADO 10
+#define STR_FLAT 11
+#define STR_CALC 12
+#define STR_MOZILLA 13
+#define STR_LDAP 14
+#define STR_OUTLOOK 15
+#define STR_OUTLOOKEXP 16
+#define STR_EVOLUTION 17
+#define STR_EVOLUTION_GROUPWISE 18
+#define STR_EVOLUTION_LDAP 19
+#define STR_KAB 20
+#define STR_MACAB 21
+#define STR_EMBEDDED_HSQLDB 22
+#define STR_THUNDERBIRD 23
+#define STR_MYSQL_NATIVE 24
+
+#define STR_END STR_MYSQL_NATIVE + 1
+
+#endif // _DBU_MISCRES_HRC_
+
diff --git a/dbaccess/source/ui/misc/dbumiscres.src b/dbaccess/source/ui/misc/dbumiscres.src
new file mode 100644
index 000000000000..974b36e68005
--- /dev/null
+++ b/dbaccess/source/ui/misc/dbumiscres.src
@@ -0,0 +1,100 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+************************************************************************/
+
+#ifndef _DBU_MISC_HRC_
+#include "dbu_misc.hrc"
+#endif
+
+
+Resource RSC_CHARSETS
+{
+ String 1
+ {
+ Text [ en-US ] = "System";
+ };
+};
+
+String STR_ERROR_DURING_CREATION
+{
+ Text [ en-US ] = "Error during creation";
+};
+
+String STR_UNEXPECTED_ERROR
+{
+ Text [ en-US ] = "An unexpected error occurred. The operation could not be performed.";
+};
+
+String STR_COULDNOTOPEN_LINKEDDOC
+{
+ Text [ en-US ] = "The document \"$file$\" could not be opened.";
+};
+
+String STR_MISSING_TABLES_XDROP
+{
+ Text [ en-US ] = "The table cannot be deleted because the database connection does not support this.";
+};
+
+String STR_BUTTON_TEXT_ALL
+{
+ Text [ en-US ] = "~All";
+};
+
+String STR_UNDO_COLON
+{
+ Text [ en-US ] = "Undo:";
+};
+
+String STR_REDO_COLON
+{
+ Text [ en-US ] = "Redo:";
+};
+
+String STR_UNKNOWN_TYPE_FOUND
+{
+ Text [ en-US ] = "No corresponding column type could be found for column '#1'." ;
+};
+
+String STR_FILE_DOES_NOT_EXIST
+{
+ Text[ en-US ] = "The file \"$file$\" does not exist.";
+};
+
+String STR_WARNINGS_DURING_CONNECT
+{
+ Text [ en-US ] = "Warnings were encountered while connecting to the data source. Press \"$buttontext$\" to view them.";
+};
+
+String STR_NAMED_OBJECT_ALREADY_EXISTS
+{
+ Text [ en-US ] = "The name '$#$' already exists.\nPlease enter another name." ;
+};
+
+String RID_STR_EXTENSION_NOT_PRESENT
+{
+ // #i96130# use hard coded name
+ Text [ en-US ] = "The report, \"$file$\", requires the extension Oracle Report Builder.";
+};
diff --git a/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
new file mode 100644
index 000000000000..bac5dfbaa5f6
--- /dev/null
+++ b/dbaccess/source/ui/misc/defaultobjectnamecheck.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "defaultobjectnamecheck.hxx"
+
+#include "dbu_misc.hrc"
+
+#include "moduledbu.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/tools/XConnectionTools.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbmetadata.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <tools/diagnose_ex.h>
+#include <tools/string.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::container::XHierarchicalNameAccess;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::sdb::tools::XObjectNames;
+ using ::com::sun::star::sdb::tools::XConnectionTools;
+ using ::com::sun::star::uno::UNO_QUERY;
+ /** === end UNO using === **/
+
+ using namespace dbtools;
+
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ void lcl_fillNameExistsError( const ::rtl::OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay )
+ {
+ String sErrorMessage = String( ModuleRes( STR_NAMED_OBJECT_ALREADY_EXISTS ) );
+ sErrorMessage.SearchAndReplaceAllAscii( "$#$", _rObjectName );
+ SQLException aError;
+ aError.Message = sErrorMessage;
+ _out_rErrorToDisplay = aError;
+ }
+
+ }
+
+ //====================================================================
+ //= HierarchicalNameCheck_Impl
+ //====================================================================
+ struct HierarchicalNameCheck_Impl
+ {
+ Reference< XHierarchicalNameAccess > xHierarchicalNames;
+ ::rtl::OUString sRelativeRoot;
+ };
+
+ //====================================================================
+ //= HierarchicalNameCheck
+ //====================================================================
+ //--------------------------------------------------------------------
+ HierarchicalNameCheck::HierarchicalNameCheck( const Reference< XHierarchicalNameAccess >& _rxNames, const ::rtl::OUString& _rRelativeRoot )
+ :m_pImpl( new HierarchicalNameCheck_Impl )
+ {
+ m_pImpl->xHierarchicalNames = _rxNames;
+ m_pImpl->sRelativeRoot = _rRelativeRoot;
+
+ if ( !m_pImpl->xHierarchicalNames.is() )
+ throw IllegalArgumentException();
+ }
+
+ //--------------------------------------------------------------------
+ HierarchicalNameCheck::~HierarchicalNameCheck()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool HierarchicalNameCheck::isNameValid( const ::rtl::OUString& _rObjectName, SQLExceptionInfo& _out_rErrorToDisplay ) const
+ {
+ try
+ {
+ ::rtl::OUStringBuffer aCompleteName;
+ if ( m_pImpl->sRelativeRoot.getLength() )
+ {
+ aCompleteName.append( m_pImpl->sRelativeRoot );
+ aCompleteName.appendAscii( "/" );
+ }
+ aCompleteName.append( _rObjectName );
+
+ ::rtl::OUString sCompleteName( aCompleteName.makeStringAndClear() );
+ if ( !m_pImpl->xHierarchicalNames->hasByHierarchicalName( sCompleteName ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ lcl_fillNameExistsError( _rObjectName, _out_rErrorToDisplay );
+ return false;
+ }
+
+ //====================================================================
+ //= DynamicTableOrQueryNameCheck_Impl
+ //====================================================================
+ struct DynamicTableOrQueryNameCheck_Impl
+ {
+ sal_Int32 nCommandType;
+ Reference< XObjectNames > xObjectNames;
+ };
+
+ //====================================================================
+ //= DynamicTableOrQueryNameCheck
+ //====================================================================
+ //--------------------------------------------------------------------
+ DynamicTableOrQueryNameCheck::DynamicTableOrQueryNameCheck( const Reference< XConnection >& _rxSdbLevelConnection, sal_Int32 _nCommandType )
+ :m_pImpl( new DynamicTableOrQueryNameCheck_Impl )
+ {
+ Reference< XConnectionTools > xConnTools( _rxSdbLevelConnection, UNO_QUERY );
+ if ( xConnTools.is() )
+ m_pImpl->xObjectNames.set( xConnTools->getObjectNames() );
+ if ( !m_pImpl->xObjectNames.is() )
+ throw IllegalArgumentException();
+
+ if ( ( _nCommandType != CommandType::QUERY ) && ( _nCommandType != CommandType::TABLE ) )
+ throw IllegalArgumentException();
+ m_pImpl->nCommandType = _nCommandType;
+ }
+
+ //--------------------------------------------------------------------
+ DynamicTableOrQueryNameCheck::~DynamicTableOrQueryNameCheck()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool DynamicTableOrQueryNameCheck::isNameValid( const ::rtl::OUString& _rObjectName, ::dbtools::SQLExceptionInfo& _out_rErrorToDisplay ) const
+ {
+ try
+ {
+ m_pImpl->xObjectNames->checkNameForCreate( m_pImpl->nCommandType, _rObjectName );
+ return true;
+ }
+ catch( const SQLException& )
+ {
+ _out_rErrorToDisplay = ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() );
+ }
+ return false;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/dsmeta.cxx b/dbaccess/source/ui/misc/dsmeta.cxx
new file mode 100644
index 000000000000..945489cf7b62
--- /dev/null
+++ b/dbaccess/source/ui/misc/dsmeta.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dsmeta.hxx"
+#include <connectivity/DriversConfig.hxx>
+#include "dsntypes.hxx"
+#include <comphelper/processfactory.hxx>
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <map>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace dbaccess;
+ using namespace ::com::sun::star;
+ /** === end UNO using === **/
+
+ struct FeatureSupport
+ {
+ // authentication mode of the data source
+ AuthenticationMode eAuthentication;
+
+ FeatureSupport()
+ :eAuthentication( AuthUserPwd )
+ {
+ }
+
+ FeatureSupport( AuthenticationMode _Auth )
+ :eAuthentication( _Auth )
+ {
+ }
+ };
+
+ struct FeatureMapping
+ {
+ /// one of the items from dsitems.hxx
+ ItemID nItemID;
+ const sal_Char* pAsciiFeatureName;
+ };
+
+ //====================================================================
+ //= global tables
+ //====================================================================
+ //--------------------------------------------------------------------
+ static const FeatureMapping* lcl_getFeatureMappings()
+ {
+ static const FeatureMapping s_aMappings[] = {
+ { DSID_AUTORETRIEVEENABLED, "GeneratedValues" },
+ { DSID_AUTOINCREMENTVALUE, "GeneratedValues" },
+ { DSID_AUTORETRIEVEVALUE, "GeneratedValues" },
+ { DSID_SQL92CHECK, "UseSQL92NamingConstraints" },
+ { DSID_APPEND_TABLE_ALIAS, "AppendTableAliasInSelect" },
+ { DSID_AS_BEFORE_CORRNAME, "UseKeywordAsBeforeAlias" },
+ { DSID_ENABLEOUTERJOIN, "UseBracketedOuterJoinSyntax" },
+ { DSID_IGNOREDRIVER_PRIV, "IgnoreDriverPrivileges" },
+ { DSID_PARAMETERNAMESUBST, "ParameterNameSubstitution" },
+ { DSID_SUPPRESSVERSIONCL, "DisplayVersionColumns" },
+ { DSID_CATALOG, "UseCatalogInSelect" },
+ { DSID_SCHEMA, "UseSchemaInSelect" },
+ { DSID_INDEXAPPENDIX, "UseIndexDirectionKeyword" },
+ { DSID_DOSLINEENDS, "UseDOSLineEnds" },
+ { DSID_BOOLEANCOMPARISON, "BooleanComparisonMode" },
+ { DSID_CHECK_REQUIRED_FIELDS, "FormsCheckRequiredFields" },
+ { DSID_IGNORECURRENCY, "IgnoreCurrency" },
+ { DSID_ESCAPE_DATETIME, "EscapeDateTime" },
+ { DSID_PRIMARY_KEY_SUPPORT, "PrimaryKeySupport" },
+ { DSID_MAX_ROW_SCAN, "MaxRowScan" },
+ { 0, NULL }
+ };
+ return s_aMappings;
+ }
+
+ //--------------------------------------------------------------------
+ static const FeatureSet& lcl_getFeatureSet( const ::rtl::OUString _rURL )
+ {
+ typedef ::std::map< ::rtl::OUString, FeatureSet, ::comphelper::UStringLess > FeatureSets;
+ static FeatureSets s_aFeatureSets;
+ if ( s_aFeatureSets.empty() )
+ {
+ ::connectivity::DriversConfig aDriverConfig( ::comphelper::getProcessServiceFactory() );
+ const uno::Sequence< ::rtl::OUString > aPatterns = aDriverConfig.getURLs();
+ for ( const ::rtl::OUString* pattern = aPatterns.getConstArray();
+ pattern != aPatterns.getConstArray() + aPatterns.getLength();
+ ++pattern
+ )
+ {
+ FeatureSet aCurrentSet;
+ const ::comphelper::NamedValueCollection aCurrentFeatures( aDriverConfig.getFeatures( *pattern ).getNamedValues() );
+
+ const FeatureMapping* pFeatureMapping = lcl_getFeatureMappings();
+ while ( pFeatureMapping->pAsciiFeatureName )
+ {
+ if ( aCurrentFeatures.has( pFeatureMapping->pAsciiFeatureName ) )
+ aCurrentSet.put( pFeatureMapping->nItemID );
+ ++pFeatureMapping;
+ }
+
+ s_aFeatureSets[ *pattern ] = aCurrentSet;
+ }
+ }
+
+ OSL_ENSURE( s_aFeatureSets.find( _rURL ) != s_aFeatureSets.end(), "invalid URL/pattern!" );
+ return s_aFeatureSets[ _rURL ];
+ }
+
+ //--------------------------------------------------------------------
+ static AuthenticationMode getAuthenticationMode( const ::rtl::OUString& _sURL )
+ {
+ DECLARE_STL_USTRINGACCESS_MAP( FeatureSupport, Supported);
+ static Supported s_aSupport;
+ if ( s_aSupport.empty() )
+ {
+ ::connectivity::DriversConfig aDriverConfig(::comphelper::getProcessServiceFactory());
+ const uno::Sequence< ::rtl::OUString > aURLs = aDriverConfig.getURLs();
+ const ::rtl::OUString* pIter = aURLs.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aURLs.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ FeatureSupport aInit( AuthNone );
+ const ::comphelper::NamedValueCollection& aMetaData = aDriverConfig.getMetaData(*pIter);
+ if ( aMetaData.has("Authentication") )
+ {
+ ::rtl::OUString sAuth;
+ aMetaData.get("Authentication") >>= sAuth;
+ if ( sAuth.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UserPassword")) )
+ aInit = AuthUserPwd;
+ else if ( sAuth.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Password")) )
+ aInit = AuthPwd;
+ }
+ s_aSupport.insert(Supported::value_type(*pIter,aInit));
+ }
+ }
+ OSL_ENSURE(s_aSupport.find(_sURL) != s_aSupport.end(),"Illegal URL!");
+ return s_aSupport[ _sURL ].eAuthentication;
+ }
+
+ //====================================================================
+ //= DataSourceMetaData_Impl
+ //====================================================================
+ class DataSourceMetaData_Impl
+ {
+ public:
+ DataSourceMetaData_Impl( const ::rtl::OUString& _sURL );
+
+ inline ::rtl::OUString getType() const { return m_sURL; }
+
+ private:
+ const ::rtl::OUString m_sURL;
+ };
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData_Impl::DataSourceMetaData_Impl( const ::rtl::OUString& _sURL )
+ :m_sURL( _sURL )
+ {
+ }
+
+ //====================================================================
+ //= DataSourceMetaData
+ //====================================================================
+ //--------------------------------------------------------------------
+ DataSourceMetaData::DataSourceMetaData( const ::rtl::OUString& _sURL )
+ :m_pImpl( new DataSourceMetaData_Impl( _sURL ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DataSourceMetaData::~DataSourceMetaData()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const FeatureSet& DataSourceMetaData::getFeatureSet() const
+ {
+ return lcl_getFeatureSet( m_pImpl->getType() );
+ }
+
+ //--------------------------------------------------------------------
+ AuthenticationMode DataSourceMetaData::getAuthentication( const ::rtl::OUString& _sURL )
+ {
+ return getAuthenticationMode( _sURL );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
new file mode 100644
index 000000000000..7f8522ee9070
--- /dev/null
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "imageprovider.hxx"
+#include "dbu_resource.hrc"
+#include "moduledbu.hxx"
+#include "dbustrings.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/graphic/GraphicColorMode.hpp>
+#include <com/sun/star/sdb/application/XTableUIProvider.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::graphic::XGraphic;
+ using ::com::sun::star::sdb::application::XTableUIProvider;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::sdbcx::XViewsSupplier;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ /** === end UNO using === **/
+ namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode;
+
+ //====================================================================
+ //= ImageProvider_Data
+ //====================================================================
+ struct ImageProvider_Data
+ {
+ /// the connection we work with
+ Reference< XConnection > xConnection;
+ /// the views of the connection, if the DB supports views
+ Reference< XNameAccess > xViews;
+ /// interface for providing table's UI
+ Reference< XTableUIProvider > xTableUI;
+ };
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ static void lcl_getConnectionProvidedTableIcon_nothrow( const ImageProvider_Data& _rData,
+ const ::rtl::OUString& _rName, Reference< XGraphic >& _out_rxGraphic )
+ {
+ try
+ {
+ if ( _rData.xTableUI.is() )
+ _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //................................................................
+ static void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const ::rtl::OUString& _rName,
+ sal_uInt16& _out_rResourceID)
+ {
+ _out_rResourceID = 0;
+ try
+ {
+ bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName );
+ if ( bIsView )
+ {
+ _out_rResourceID = VIEW_TREE_ICON;
+ }
+ else
+ {
+ _out_rResourceID = TABLE_TREE_ICON;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ //====================================================================
+ //= ImageProvider
+ //====================================================================
+ //--------------------------------------------------------------------
+ ImageProvider::ImageProvider()
+ :m_pData( new ImageProvider_Data )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ImageProvider::ImageProvider( const Reference< XConnection >& _rxConnection )
+ :m_pData( new ImageProvider_Data )
+ {
+ m_pData->xConnection = _rxConnection;
+ try
+ {
+ Reference< XViewsSupplier > xSuppViews( m_pData->xConnection, UNO_QUERY );
+ if ( xSuppViews.is() )
+ m_pData->xViews.set( xSuppViews->getViews(), UNO_SET_THROW );
+
+ m_pData->xTableUI.set( _rxConnection, UNO_QUERY );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ImageProvider::getImages( const String& _rName, const sal_Int32 _nDatabaseObjectType, Image& _out_rImage )
+ {
+ if ( _nDatabaseObjectType != DatabaseObject::TABLE )
+ {
+ // for types other than tables, the icon does not depend on the concrete object
+ _out_rImage = getDefaultImage( _nDatabaseObjectType );
+ }
+ else
+ {
+ // check whether the connection can give us an icon
+ Reference< XGraphic > xGraphic;
+ lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic );
+ if ( xGraphic.is() )
+ _out_rImage = Image( xGraphic );
+
+ if ( !_out_rImage )
+ {
+ // no -> determine by type
+ sal_uInt16 nImageResourceID = 0;
+ lcl_getTableImageResourceID_nothrow( *m_pData, _rName, nImageResourceID );
+
+ if ( nImageResourceID && !_out_rImage )
+ _out_rImage = Image( ModuleRes( nImageResourceID ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDefaultImage( sal_Int32 _nDatabaseObjectType )
+ {
+ Image aObjectImage;
+ sal_uInt16 nImageResourceID( getDefaultImageResourceID( _nDatabaseObjectType) );
+ if ( nImageResourceID )
+ aObjectImage = Image( ModuleRes( nImageResourceID ) );
+ return aObjectImage;
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt16 ImageProvider::getDefaultImageResourceID( sal_Int32 _nDatabaseObjectType)
+ {
+ sal_uInt16 nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = QUERY_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = FORM_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = REPORT_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = TABLE_TREE_ICON;
+ break;
+ default:
+ OSL_FAIL( "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+ return nImageResourceID;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getFolderImage( sal_Int32 _nDatabaseObjectType )
+ {
+ sal_uInt16 nImageResourceID( 0 );
+ switch ( _nDatabaseObjectType )
+ {
+ case DatabaseObject::QUERY:
+ nImageResourceID = QUERYFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::FORM:
+ nImageResourceID = FORMFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::REPORT:
+ nImageResourceID = REPORTFOLDER_TREE_ICON;
+ break;
+ case DatabaseObject::TABLE:
+ nImageResourceID = TABLEFOLDER_TREE_ICON;
+ break;
+ default:
+ OSL_FAIL( "ImageProvider::getDefaultImage: invalid database object type!" );
+ break;
+ }
+
+ Image aFolderImage;
+ if ( nImageResourceID )
+ aFolderImage = Image( ModuleRes( nImageResourceID ) );
+ return aFolderImage;
+ }
+
+ //--------------------------------------------------------------------
+ Image ImageProvider::getDatabaseImage()
+ {
+ return Image( ModuleRes( DATABASE_TREE_ICON ) );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx
new file mode 100644
index 000000000000..ae68cd988f55
--- /dev/null
+++ b/dbaccess/source/ui/misc/indexcollection.cxx
@@ -0,0 +1,402 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "indexcollection.hxx"
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::sdbc;
+
+ //==================================================================
+ //= OIndexCollection
+ //==================================================================
+ //------------------------------------------------------------------
+ OIndexCollection::OIndexCollection()
+ {
+ }
+
+ //------------------------------------------------------------------
+ OIndexCollection::OIndexCollection(const OIndexCollection& _rSource)
+ {
+ *this = _rSource;
+ }
+
+ //------------------------------------------------------------------
+ const OIndexCollection& OIndexCollection::operator=(const OIndexCollection& _rSource)
+ {
+ detach();
+ m_xIndexes = _rSource.m_xIndexes;
+ m_aIndexes = _rSource.m_aIndexes;
+ return *this;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::attach(const Reference< XNameAccess >& _rxIndexes)
+ {
+ implConstructFrom(_rxIndexes);
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::detach()
+ {
+ m_xIndexes.clear();
+ m_aIndexes.clear();
+ }
+
+ //------------------------------------------------------------------
+ Indexes::const_iterator OIndexCollection::find(const String& _rName) const
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::const_iterator aSearch = m_aIndexes.begin();
+ Indexes::const_iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->sName == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::find(const String& _rName)
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::iterator aSearch = m_aIndexes.begin();
+ Indexes::iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->sName == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::const_iterator OIndexCollection::findOriginal(const String& _rName) const
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::const_iterator aSearch = m_aIndexes.begin();
+ Indexes::const_iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->getOriginalName() == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::findOriginal(const String& _rName)
+ {
+ ::rtl::OUString sNameCompare(_rName);
+
+ // loop'n'compare
+ Indexes::iterator aSearch = m_aIndexes.begin();
+ Indexes::iterator aEnd = m_aIndexes.end();
+ for (; aSearch != aEnd; ++aSearch)
+ if (aSearch->getOriginalName() == sNameCompare)
+ break;
+
+ return aSearch;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::commitNewIndex(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE(_rPos->isNew(), "OIndexCollection::commitNewIndex: index must be new!");
+
+ try
+ {
+ Reference< XDataDescriptorFactory > xIndexFactory(m_xIndexes, UNO_QUERY);
+ Reference< XAppend > xAppendIndex(xIndexFactory, UNO_QUERY);
+ if (!xAppendIndex.is())
+ {
+ OSL_FAIL("OIndexCollection::commitNewIndex: missing an interface of the index container!");
+ return;
+ }
+
+ Reference< XPropertySet > xIndexDescriptor = xIndexFactory->createDataDescriptor();
+ Reference< XColumnsSupplier > xColsSupp(xIndexDescriptor, UNO_QUERY);
+ Reference< XNameAccess > xCols;
+ if (xColsSupp.is())
+ xCols = xColsSupp->getColumns();
+
+ Reference< XDataDescriptorFactory > xColumnFactory(xCols, UNO_QUERY);
+ Reference< XAppend > xAppendCols(xColumnFactory, UNO_QUERY);
+ if (!xAppendCols.is())
+ {
+ OSL_FAIL("OIndexCollection::commitNewIndex: invalid index descriptor returned!");
+ return;
+ }
+
+ // set the properties
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUnique"));
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAscending"));
+ static const ::rtl::OUString s_sNamePropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"));
+ // the index' own props
+ xIndexDescriptor->setPropertyValue(s_sUniquePropertyName, ::cppu::bool2any(_rPos->bUnique));
+ xIndexDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(_rPos->sName));
+
+ // the fields
+ for ( ConstIndexFieldsIterator aFieldLoop = _rPos->aFields.begin();
+ aFieldLoop != _rPos->aFields.end();
+ ++aFieldLoop
+ )
+ {
+ OSL_ENSURE(!xCols->hasByName(aFieldLoop->sFieldName), "OIndexCollection::commitNewIndex: double column name (need to prevent this outside)!");
+
+ Reference< XPropertySet > xColDescriptor = xColumnFactory->createDataDescriptor();
+ OSL_ENSURE(xColDescriptor.is(), "OIndexCollection::commitNewIndex: invalid column descriptor!");
+ if (xColDescriptor.is())
+ {
+ xColDescriptor->setPropertyValue(s_sSortPropertyName, ::cppu::bool2any(aFieldLoop->bSortAscending));
+ xColDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(::rtl::OUString(aFieldLoop->sFieldName)));
+ xAppendCols->appendByDescriptor(xColDescriptor);
+ }
+ }
+
+ xAppendIndex->appendByDescriptor(xIndexDescriptor);
+
+ _rPos->flagAsCommitted(GrantIndexAccess());
+ _rPos->clearModified();
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OIndexCollection::dropNoRemove(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ try
+ {
+ OSL_ENSURE(m_xIndexes->hasByName(_rPos->getOriginalName()), "OIndexCollection::drop: invalid name!");
+
+ Reference< XDrop > xDropIndex(m_xIndexes, UNO_QUERY);
+ if (!xDropIndex.is())
+ {
+ OSL_FAIL("OIndexCollection::drop: no XDrop interface!");
+ return sal_False;
+ }
+
+ xDropIndex->dropByName(_rPos->getOriginalName());
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+
+ // adjust the OIndex structure
+ Indexes::iterator aDropped = findOriginal(_rPos->getOriginalName());
+ OSL_ENSURE(aDropped != m_aIndexes.end(), "OIndexCollection::drop: invalid original name, but successfull commit?!");
+ aDropped->flagAsNew(GrantIndexAccess());
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OIndexCollection::drop(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE((_rPos >= m_aIndexes.begin()) && (_rPos < m_aIndexes.end()),
+ "OIndexCollection::drop: invalid position (fasten your seatbelt .... this will crash)!");
+
+ if (!_rPos->isNew())
+ if (!dropNoRemove(_rPos))
+ return sal_False;
+
+ // adjust the index array
+ m_aIndexes.erase(_rPos);
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implFillIndexInfo(OIndex& _rIndex) SAL_THROW((Exception))
+ {
+ // get the UNO descriptor for the index
+ Reference< XPropertySet > xIndex;
+ m_xIndexes->getByName(_rIndex.getOriginalName()) >>= xIndex;
+ if (!xIndex.is())
+ {
+ OSL_FAIL("OIndexCollection::implFillIndexInfo: got an invalid index object!");
+ }
+ else
+ implFillIndexInfo(_rIndex, xIndex);
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implFillIndexInfo(OIndex& _rIndex, Reference< XPropertySet > _rxDescriptor) SAL_THROW((Exception))
+ {
+ static const ::rtl::OUString s_sPrimaryIndexPropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsPrimaryKeyIndex"));
+ static const ::rtl::OUString s_sUniquePropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUnique"));
+ static const ::rtl::OUString s_sSortPropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAscending"));
+ static const ::rtl::OUString s_sCatalogPropertyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Catalog"));
+
+ _rIndex.bPrimaryKey = ::cppu::any2bool(_rxDescriptor->getPropertyValue(s_sPrimaryIndexPropertyName));
+ _rIndex.bUnique = ::cppu::any2bool(_rxDescriptor->getPropertyValue(s_sUniquePropertyName));
+ _rxDescriptor->getPropertyValue(s_sCatalogPropertyName) >>= _rIndex.sDescription;
+
+ // the columns
+ Reference< XColumnsSupplier > xSuppCols(_rxDescriptor, UNO_QUERY);
+ Reference< XNameAccess > xCols;
+ if (xSuppCols.is())
+ xCols = xSuppCols->getColumns();
+ OSL_ENSURE(xCols.is(), "OIndexCollection::implFillIndexInfo: the index does not have columns!");
+ if (xCols.is())
+ {
+ Sequence< ::rtl::OUString > aFieldNames = xCols->getElementNames();
+ _rIndex.aFields.resize(aFieldNames.getLength());
+
+ const ::rtl::OUString* pFieldNames = aFieldNames.getConstArray();
+ const ::rtl::OUString* pFieldNamesEnd = pFieldNames + aFieldNames.getLength();
+ IndexFields::iterator aCopyTo = _rIndex.aFields.begin();
+
+ Reference< XPropertySet > xIndexColumn;
+ for (;pFieldNames < pFieldNamesEnd; ++pFieldNames, ++aCopyTo)
+ {
+ // extract the column
+ xIndexColumn.clear();
+ xCols->getByName(*pFieldNames) >>= xIndexColumn;
+ if (!xIndexColumn.is())
+ {
+ OSL_FAIL("OIndexCollection::implFillIndexInfo: invalid index column!");
+ --aCopyTo;
+ continue;
+ }
+
+ // get the relevant properties
+ aCopyTo->sFieldName = *pFieldNames;
+ aCopyTo->bSortAscending = ::cppu::any2bool(xIndexColumn->getPropertyValue(s_sSortPropertyName));
+ }
+
+ _rIndex.aFields.resize(aCopyTo - _rIndex.aFields.begin());
+ // (just in case some fields were invalid ...)
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::resetIndex(const Indexes::iterator& _rPos) SAL_THROW((SQLException))
+ {
+ OSL_ENSURE(_rPos >= m_aIndexes.begin() && _rPos < m_aIndexes.end(),
+ "OIndexCollection::resetIndex: invalid position!");
+
+ try
+ {
+ _rPos->sName = _rPos->getOriginalName();
+ implFillIndexInfo(*_rPos);
+
+ _rPos->clearModified();
+ _rPos->flagAsCommitted(GrantIndexAccess());
+ }
+ catch(SQLException&)
+ { // allowed to pass
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ Indexes::iterator OIndexCollection::insert(const String& _rName)
+ {
+ OSL_ENSURE(end() == find(_rName), "OIndexCollection::insert: invalid new name!");
+ String tmpName;
+ OIndex aNewIndex(tmpName); // the empty string indicates the index is a new one
+ aNewIndex.sName = _rName;
+ m_aIndexes.push_back(aNewIndex);
+ return m_aIndexes.end() - 1; // the last element is the new one ...
+ }
+
+ //------------------------------------------------------------------
+ void OIndexCollection::implConstructFrom(const Reference< XNameAccess >& _rxIndexes)
+ {
+ detach();
+
+ m_xIndexes = _rxIndexes;
+ if (m_xIndexes.is())
+ {
+ // loop through all the indexes
+ Sequence< ::rtl::OUString > aNames = m_xIndexes->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pNames + aNames.getLength();
+ for (; pNames < pEnd; ++pNames)
+ {
+ // extract the index object
+ Reference< XPropertySet > xIndex;
+ m_xIndexes->getByName(*pNames) >>= xIndex;
+ if (!xIndex.is())
+ {
+ OSL_FAIL("OIndexCollection::implConstructFrom: got an invalid index object ... ignoring!");
+ continue;
+ }
+
+ // fill the OIndex structure
+ OIndex aCurrentIndex(*pNames);
+ implFillIndexInfo(aCurrentIndex);
+ m_aIndexes.push_back(aCurrentIndex);
+ }
+ }
+ }
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/linkeddocuments.cxx b/dbaccess/source/ui/misc/linkeddocuments.cxx
new file mode 100644
index 000000000000..d1c5ccd14fe1
--- /dev/null
+++ b/dbaccess/source/ui/misc/linkeddocuments.cxx
@@ -0,0 +1,411 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "linkeddocuments.hxx"
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#include "dbustrings.hrc"
+#include <comphelper/classids.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ucb/OpenCommandArgument.hpp>
+#include <com/sun/star/ucb/OpenMode.hpp>
+#include <com/sun/star/task/XJobExecutor.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/msgbox.hxx>
+#include <ucbhelper/content.hxx>
+#include "dbu_misc.hrc"
+#include <svl/filenotation.hxx>
+#include "browserids.hxx"
+#include <sfx2/new.hxx>
+#include "moduledbu.hxx"
+// -----------------
+// for calling basic
+#include <sfx2/app.hxx>
+#include <basic/sbx.hxx>
+#include <basic/sbuno.hxx>
+#include <svtools/ehdl.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
+#include <vcl/waitobj.hxx>
+#include <comphelper/mimeconfighelper.hxx>
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <connectivity/dbtools.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/io/WrongFormatException.hpp>
+#include "com/sun/star/sdb/RowSetVetoException.hpp"
+
+//......................................................................
+namespace dbaui
+{
+//......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb::application;
+ using namespace ::com::sun::star::task;
+ using namespace ::svt;
+
+ namespace
+ {
+ Sequence< sal_Int8 > lcl_GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
+ sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
+ sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
+ {
+ Sequence< sal_Int8 > aResult( 16 );
+ aResult[0] = static_cast<sal_Int8>(n1 >> 24);
+ aResult[1] = static_cast<sal_Int8>(( n1 << 8 ) >> 24);
+ aResult[2] = static_cast<sal_Int8>(( n1 << 16 ) >> 24);
+ aResult[3] = static_cast<sal_Int8>(( n1 << 24 ) >> 24);
+ aResult[4] = static_cast<sal_Int8>(n2 >> 8);
+ aResult[5] = static_cast<sal_Int8>(( n2 << 8 ) >> 8);
+ aResult[6] = static_cast<sal_Int8>(n3 >> 8);
+ aResult[7] = static_cast<sal_Int8>(( n3 << 8 ) >> 8);
+ aResult[8] = b8;
+ aResult[9] = b9;
+ aResult[10] = b10;
+ aResult[11] = b11;
+ aResult[12] = b12;
+ aResult[13] = b13;
+ aResult[14] = b14;
+ aResult[15] = b15;
+
+ return aResult;
+ }
+ }
+
+
+ //==================================================================
+ //= OLinkedDocumentsAccess
+ //==================================================================
+ DBG_NAME(OLinkedDocumentsAccess)
+ //------------------------------------------------------------------
+ OLinkedDocumentsAccess::OLinkedDocumentsAccess( Window* _pDialogParent, const Reference< XDatabaseDocumentUI >& i_rDocumentUI,
+ const Reference< XMultiServiceFactory >& _rxORB, const Reference< XNameAccess >& _rxContainer,
+ const Reference< XConnection>& _xConnection, const ::rtl::OUString& _sDataSourceName )
+ :m_xORB(_rxORB)
+ ,m_xDocumentContainer(_rxContainer)
+ ,m_xConnection(_xConnection)
+ ,m_xDocumentUI( i_rDocumentUI )
+ ,m_pDialogParent(_pDialogParent)
+ ,m_sDataSourceName(_sDataSourceName)
+ {
+ DBG_CTOR(OLinkedDocumentsAccess,NULL);
+ OSL_ENSURE(m_xORB.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid service factory!");
+ OSL_ENSURE(m_pDialogParent, "OLinkedDocumentsAccess::OLinkedDocumentsAccess: really need a dialog parent!");
+ }
+ //------------------------------------------------------------------
+ OLinkedDocumentsAccess::~OLinkedDocumentsAccess()
+ {
+ DBG_DTOR(OLinkedDocumentsAccess,NULL);
+ }
+ //------------------------------------------------------------------
+ Reference< XComponent> OLinkedDocumentsAccess::impl_open( const ::rtl::OUString& _rLinkName, Reference< XComponent >& _xDefinition,
+ ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
+ {
+ Reference< XComponent> xRet;
+ OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid document container!");
+ Reference< XComponentLoader > xComponentLoader(m_xDocumentContainer,UNO_QUERY);
+ if ( !xComponentLoader.is() )
+ return xRet;
+
+ WaitObject aWaitCursor( m_pDialogParent );
+
+ ::comphelper::NamedValueCollection aArguments;
+ ::rtl::OUString sOpenMode;
+ switch ( _eOpenMode )
+ {
+ case E_OPEN_NORMAL:
+ sOpenMode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) );
+ break;
+
+ case E_OPEN_FOR_MAIL:
+ aArguments.put( "Hidden", true );
+ // fall through
+
+ case E_OPEN_DESIGN:
+ sOpenMode = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "openDesign" ) );
+ break;
+
+ default:
+ OSL_FAIL( "OLinkedDocumentsAccess::implOpen: invalid open mode!" );
+ break;
+ }
+ aArguments.put( "OpenMode", sOpenMode );
+
+ aArguments.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, m_xConnection );
+ try
+ {
+ Reference<XHierarchicalNameContainer> xHier(m_xDocumentContainer,UNO_QUERY);
+ if ( xHier.is() && xHier->hasByHierarchicalName(_rLinkName) )
+ {
+ _xDefinition.set(xHier->getByHierarchicalName(_rLinkName),UNO_QUERY);
+ }
+
+ aArguments.merge( _rAdditionalArgs, true );
+
+ xRet = xComponentLoader->loadComponentFromURL( _rLinkName, ::rtl::OUString(), 0, aArguments.getPropertyValues() );
+ }
+ catch(const Exception&)
+ {
+ throw;
+ }
+
+ return xRet;
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::impl_newWithPilot( const char* _pWizardService,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rObjectName )
+ {
+ try
+ {
+ ::comphelper::NamedValueCollection aArgs;
+ aArgs.put( "DataSourceName", m_sDataSourceName );
+
+ if ( m_xConnection.is() )
+ aArgs.put( "ActiveConnection", m_xConnection );
+
+ if ( _rObjectName.getLength() && ( _nCommandType != -1 ) )
+ {
+ aArgs.put( "CommandType", _nCommandType );
+ aArgs.put( "Command", _rObjectName );
+ }
+
+ aArgs.put( "DocumentUI", m_xDocumentUI );
+
+ Reference< XJobExecutor > xWizard;
+ {
+ WaitObject aWaitCursor( m_pDialogParent );
+ xWizard.set( m_xORB->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii( _pWizardService ),
+ aArgs.getWrappedPropertyValues()
+ ), UNO_QUERY_THROW );
+ }
+
+ xWizard->trigger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "start" ) ) );
+ ::comphelper::disposeComponent( xWizard );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newFormWithPilot( const sal_Int32 _nCommandType,const ::rtl::OUString& _rObjectName )
+ {
+ impl_newWithPilot( "com.sun.star.wizards.form.CallFormWizard", _nCommandType, _rObjectName );
+ }
+
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newReportWithPilot( const sal_Int32 _nCommandType, const ::rtl::OUString& _rObjectName )
+ {
+ impl_newWithPilot( "com.sun.star.wizards.report.CallReportWizard", _nCommandType, _rObjectName );
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newTableWithPilot()
+ {
+ impl_newWithPilot( "com.sun.star.wizards.table.CallTableWizard", -1, ::rtl::OUString() );
+ }
+ //------------------------------------------------------------------
+ void OLinkedDocumentsAccess::newQueryWithPilot()
+ {
+ impl_newWithPilot( "com.sun.star.wizards.query.CallQueryWizard", -1, ::rtl::OUString() );
+ }
+ //------------------------------------------------------------------
+ Reference< XComponent > OLinkedDocumentsAccess::newDocument( sal_Int32 i_nActionID,
+ const ::comphelper::NamedValueCollection& i_rCreationArgs, Reference< XComponent >& o_rDefinition )
+ {
+ OSL_ENSURE(m_xDocumentContainer.is(), "OLinkedDocumentsAccess::newDocument: invalid document container!");
+ // determine the class ID to use for the new document
+ Sequence<sal_Int8> aClassId;
+ if ( !i_rCreationArgs.has( "ClassID" )
+ && !i_rCreationArgs.has( "MediaType" )
+ && !i_rCreationArgs.has( "DocumentServiceName" )
+ )
+ {
+ switch ( i_nActionID )
+ {
+ case ID_FORM_NEW_TEXT:
+ aClassId = lcl_GetSequenceClassID(SO3_SW_CLASSID);
+ OSL_ENSURE(aClassId == comphelper::MimeConfigurationHelper::GetSequenceClassID(SO3_SW_CLASSID),"Not equal");
+ break;
+
+ case ID_FORM_NEW_CALC:
+ aClassId = lcl_GetSequenceClassID(SO3_SC_CLASSID);
+ break;
+
+ case ID_FORM_NEW_IMPRESS:
+ aClassId = lcl_GetSequenceClassID(SO3_SIMPRESS_CLASSID);
+ break;
+
+ case ID_REPORT_NEW_TEXT:
+ aClassId = comphelper::MimeConfigurationHelper::GetSequenceClassID(SO3_RPT_CLASSID_90);
+ break;
+
+ default:
+ OSL_FAIL( "OLinkedDocumentsAccess::newDocument: please use newFormWithPilot!" );
+ return Reference< XComponent >();
+
+ }
+ }
+
+ // load the document as template
+ Reference< XComponent > xNewDocument;
+ try
+ { // get the desktop object
+
+ Reference<XMultiServiceFactory> xORB(m_xDocumentContainer,UNO_QUERY);
+ if ( xORB.is() )
+ {
+ ::comphelper::NamedValueCollection aCreationArgs( i_rCreationArgs );
+ if ( aClassId.getLength() )
+ aCreationArgs.put( "ClassID", aClassId );
+ aCreationArgs.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, m_xConnection );
+
+ // separate values which are real creation args from args relevant for opening the doc
+ ::comphelper::NamedValueCollection aCommandArgs;
+ if ( aCreationArgs.has( "Hidden" ) )
+ {
+ aCommandArgs.put( "Hidden", aCreationArgs.get( "Hidden" ) );
+ aCreationArgs.remove( "Hidden" );
+ }
+
+ Reference< XCommandProcessor > xContent( xORB->createInstanceWithArguments(
+ SERVICE_SDB_DOCUMENTDEFINITION,
+ aCreationArgs.getWrappedPropertyValues()
+ ),
+ UNO_QUERY_THROW
+ );
+ o_rDefinition.set( xContent, UNO_QUERY );
+
+ // put the OpenMode into the OpenArgs
+ OpenCommandArgument aOpenModeArg;
+ aOpenModeArg.Mode = OpenMode::DOCUMENT;
+ aCommandArgs.put( "OpenMode", aOpenModeArg );
+
+ Command aCommand;
+ aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "openDesign" ) );
+ aCommand.Argument <<= aCommandArgs.getPropertyValues();
+ WaitObject aWaitCursor( m_pDialogParent );
+ xNewDocument.set( xContent->execute( aCommand, xContent->createCommandIdentifier(), NULL ), UNO_QUERY );
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xNewDocument;
+ }
+
+ //------------------------------------------------------------------
+ Reference< XComponent > OLinkedDocumentsAccess::open( const ::rtl::OUString& _rLinkName, Reference< XComponent >& _xDefinition,
+ ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
+ {
+ dbtools::SQLExceptionInfo aInfo;
+ Reference< XComponent > xRet;
+ try
+ {
+ xRet = impl_open( _rLinkName, _xDefinition, _eOpenMode, _rAdditionalArgs );
+ if ( !xRet.is() )
+ {
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = sMessage;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+ }
+ return xRet;
+ }
+ catch(const com::sun::star::io::WrongFormatException &e)
+ {
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = e.Message;
+ aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+
+ // more like a hack, insert an empty message
+ String sText( ModuleRes( RID_STR_EXTENSION_NOT_PRESENT ) );
+ sText.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sText);
+
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sMessage);
+ }
+ catch(const Exception& e)
+ {
+ Any aAny = ::cppu::getCaughtException();
+ com::sun::star::sdbc::SQLException a;
+ if ( !(aAny >>= a) || (a.ErrorCode != dbtools::ParameterInteractionCancelled) )
+ {
+ com::sun::star::sdbc::SQLException aSQLException;
+ aSQLException.Message = e.Message;
+ aSQLException.Context = e.Context;
+ aInfo = dbtools::SQLExceptionInfo(aSQLException);
+
+ // more like a hack, insert an empty message
+ aInfo.prepend(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" \n")));
+
+ String sMessage = String(ModuleRes(STR_COULDNOTOPEN_LINKEDDOC));
+ sMessage.SearchAndReplaceAscii("$file$",_rLinkName);
+ aInfo.prepend(sMessage);
+ }
+ }
+ if (aInfo.isValid())
+ {
+ showError(aInfo, VCLUnoHelper::GetInterface(m_pDialogParent), m_xORB );
+ }
+ return xRet;
+ }
+
+
+//......................................................................
+} // namespace dbaui
+//......................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/makefile.mk b/dbaccess/source/ui/misc/makefile.mk
new file mode 100644
index 000000000000..534d90e3995c
--- /dev/null
+++ b/dbaccess/source/ui/misc/makefile.mk
@@ -0,0 +1,88 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=../../..
+PRJINC=$(PRJ)/source
+PRJNAME=dbaccess
+TARGET=uimisc
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)/util/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dbumiscres.src \
+ WizardPages.src
+
+# ... object files ............................
+
+SLOFILES= \
+ $(SLO)/asyncmodaldialog.obj \
+ $(SLO)/imageprovider.obj \
+ $(SLO)/singledoccontroller.obj \
+ $(SLO)/dbsubcomponentcontroller.obj \
+ $(SLO)/datasourceconnector.obj \
+ $(SLO)/linkeddocuments.obj \
+ $(SLO)/indexcollection.obj \
+ $(SLO)/UITools.obj \
+ $(SLO)/WCPage.obj \
+ $(SLO)/WCopyTable.obj \
+ $(SLO)/WTypeSelect.obj \
+ $(SLO)/TokenWriter.obj \
+ $(SLO)/HtmlReader.obj \
+ $(SLO)/RtfReader.obj \
+ $(SLO)/propertysetitem.obj \
+ $(SLO)/databaseobjectview.obj \
+ $(SLO)/DExport.obj \
+ $(SLO)/uiservices.obj \
+ $(SLO)/RowSetDrop.obj \
+ $(SLO)/TableCopyHelper.obj \
+ $(SLO)/moduledbu.obj \
+ $(SLO)/WColumnSelect.obj \
+ $(SLO)/WExtendPages.obj \
+ $(SLO)/WNameMatch.obj \
+ $(SLO)/ToolBoxHelper.obj \
+ $(SLO)/stringlistitem.obj \
+ $(SLO)/charsets.obj \
+ $(SLO)/defaultobjectnamecheck.obj \
+ $(SLO)/dsmeta.obj \
+ $(SLO)/controllerframe.obj \
+ $(SLO)/propertystorage.obj \
+ $(SLO)/dbaundomanager.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ui/misc/moduledbu.cxx b/dbaccess/source/ui/misc/moduledbu.cxx
new file mode 100644
index 000000000000..3e8457361222
--- /dev/null
+++ b/dbaccess/source/ui/misc/moduledbu.cxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "moduledbu.hxx"
+
+#include <tools/resmgr.hxx>
+#include <svl/solar.hrc>
+#include <tools/debug.hxx>
+
+#define ENTER_MOD_METHOD() \
+ ::osl::MutexGuard aGuard(s_aMutex); \
+ ensureImpl()
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//=========================================================================
+//= OModuleImpl
+//=========================================================================
+/** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
+*/
+class OModuleImpl
+{
+ ResMgr* m_pRessources;
+
+public:
+ /// ctor
+ OModuleImpl();
+ ~OModuleImpl();
+
+ /// get the manager for the ressources of the module
+ ResMgr* getResManager();
+};
+
+DBG_NAME(OModuleImpl)
+//-------------------------------------------------------------------------
+OModuleImpl::OModuleImpl()
+ :m_pRessources(NULL)
+{
+ DBG_CTOR(OModuleImpl,NULL);
+
+}
+
+//-------------------------------------------------------------------------
+OModuleImpl::~OModuleImpl()
+{
+ if (m_pRessources)
+ delete m_pRessources;
+
+ DBG_DTOR(OModuleImpl,NULL);
+}
+
+//-------------------------------------------------------------------------
+ResMgr* OModuleImpl::getResManager()
+{
+ // note that this method is not threadsafe, which counts for the whole class !
+
+ if (!m_pRessources)
+ {
+ // create a manager with a fixed prefix
+ ByteString aMgrName = ByteString( "dbu" );
+ m_pRessources = ResMgr::CreateResMgr(aMgrName.GetBuffer());
+ }
+ return m_pRessources;
+}
+
+//=========================================================================
+//= OModule
+//=========================================================================
+::osl::Mutex OModule::s_aMutex;
+sal_Int32 OModule::s_nClients = 0;
+OModuleImpl* OModule::s_pImpl = NULL;
+//-------------------------------------------------------------------------
+ResMgr* OModule::getResManager()
+{
+ ENTER_MOD_METHOD();
+ return s_pImpl->getResManager();
+}
+
+//-------------------------------------------------------------------------
+void OModule::registerClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nClients;
+}
+
+//-------------------------------------------------------------------------
+void OModule::revokeClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!--s_nClients && s_pImpl)
+ {
+ delete s_pImpl;
+ s_pImpl = NULL;
+ }
+}
+
+//-------------------------------------------------------------------------
+void OModule::ensureImpl()
+{
+ if (s_pImpl)
+ return;
+ s_pImpl = new OModuleImpl();
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/propertysetitem.cxx b/dbaccess/source/ui/misc/propertysetitem.cxx
new file mode 100644
index 000000000000..817b4a68aee8
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertysetitem.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "propertysetitem.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //=========================================================================
+ //= OPropertySetItem
+ //=========================================================================
+ TYPEINIT1(OPropertySetItem, SfxPoolItem);
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(sal_Int16 _nWhich)
+ :SfxPoolItem(_nWhich)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(sal_Int16 _nWhich, const Reference< XPropertySet >& _rxSet)
+ :SfxPoolItem(_nWhich)
+ ,m_xSet(_rxSet)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OPropertySetItem::OPropertySetItem(const OPropertySetItem& _rSource)
+ :SfxPoolItem(_rSource)
+ ,m_xSet(_rSource.m_xSet)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ int OPropertySetItem::operator==(const SfxPoolItem& _rItem) const
+ {
+ const OPropertySetItem* pCompare = PTR_CAST(OPropertySetItem, &_rItem);
+ if ((!pCompare) || (pCompare->m_xSet.get() != m_xSet.get()))
+ return 0;
+
+ return 1;
+ }
+
+ //-------------------------------------------------------------------------
+ SfxPoolItem* OPropertySetItem::Clone(SfxItemPool* /* _pPool */) const
+ {
+ return new OPropertySetItem(*this);
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/propertystorage.cxx b/dbaccess/source/ui/misc/propertystorage.cxx
new file mode 100644
index 000000000000..b1dbfb27558d
--- /dev/null
+++ b/dbaccess/source/ui/misc/propertystorage.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "propertystorage.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= PropertyStorage
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyStorage::~PropertyStorage()
+ {
+ }
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //----------------------------------------------------------------
+ template < class ITEMTYPE, class UNOTYPE >
+ class ItemAdapter
+ {
+ public:
+ static bool trySet( SfxItemSet& _rSet, ItemId _nItemId, const Any& _rValue )
+ {
+ const SfxPoolItem& rItem( _rSet.Get( _nItemId ) );
+ const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &rItem );
+ if ( !pTypedItem )
+ return false;
+
+ UNOTYPE aValue( pTypedItem->GetValue() );
+ OSL_VERIFY( _rValue >>= aValue );
+ // TODO: one could throw an IllegalArgumentException here - finally, this method
+ // is (to be) used from within an XPropertySet::setPropertyValue implementation,
+ // where this would be the appropriate reaction on wrong value types
+ ::std::auto_ptr< ITEMTYPE > pClone( dynamic_cast< ITEMTYPE* >( pTypedItem->Clone() ) );
+ pClone->SetValue( aValue );
+ _rSet.Put( *pClone );
+ return true;
+ }
+
+ static bool tryGet( const SfxPoolItem& _rItem, Any& _out_rValue )
+ {
+ const ITEMTYPE* pTypedItem = dynamic_cast< const ITEMTYPE* >( &_rItem );
+ if ( !pTypedItem )
+ return false;
+
+ _out_rValue <<= UNOTYPE( pTypedItem->GetValue() );
+ return true;
+ }
+ };
+ }
+
+ //====================================================================
+ //= SetItemPropertyStorage
+ //====================================================================
+ //--------------------------------------------------------------------
+ void SetItemPropertyStorage::getPropertyValue( Any& _out_rValue ) const
+ {
+ const SfxPoolItem& rItem( m_rItemSet.Get( m_nItemID ) );
+
+ // try some known item types
+ if ( ItemAdapter< SfxBoolItem, sal_Bool >::tryGet( rItem, _out_rValue )
+ || ItemAdapter< SfxStringItem, ::rtl::OUString >::tryGet( rItem, _out_rValue )
+ )
+ return;
+
+ OSL_FAIL( "SetItemPropertyStorage::getPropertyValue: unsupported item type!" );
+ }
+
+ //--------------------------------------------------------------------
+ void SetItemPropertyStorage::setPropertyValue( const Any& _rValue )
+ {
+ // try some known item types
+ if ( ItemAdapter< SfxBoolItem, sal_Bool >::trySet( m_rItemSet, m_nItemID, _rValue )
+ || ItemAdapter< SfxStringItem, ::rtl::OUString >::trySet( m_rItemSet, m_nItemID, _rValue )
+ )
+ return;
+
+ OSL_FAIL( "SetItemPropertyStorage::setPropertyValue: unsupported item type!" );
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx
new file mode 100644
index 000000000000..4f6d7b909d55
--- /dev/null
+++ b/dbaccess/source/ui/misc/singledoccontroller.cxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_dbaccess.hxx"
+
+#include "dbaundomanager.hxx"
+#include "singledoccontroller.hxx"
+#include "browserids.hxx"
+#include "dbu_misc.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/undo.hxx>
+#include <osl/diagnose.h>
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace dbaui
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::lang::EventObject;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= OSingleDocumentController_Data
+ //==================================================================================================================
+ struct OSingleDocumentController_Data
+ {
+ ::boost::scoped_ptr< UndoManager > m_pUndoManager;
+
+ OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pUndoManager( new UndoManager( i_parent, i_mutex ) )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= OSingleDocumentController
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ OSingleDocumentController::OSingleDocumentController( const Reference< XMultiServiceFactory >& _rxORB )
+ :OSingleDocumentController_Base( _rxORB )
+ ,m_pData( new OSingleDocumentController_Data( *this, getMutex() ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ OSingleDocumentController::~OSingleDocumentController()
+ {
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing()
+ {
+ OSingleDocumentController_Base::disposing();
+ ClearUndoManager();
+ m_pData->m_pUndoManager->disposing();
+ }
+
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OSingleDocumentController::disposing( const EventObject& i_event ) throw( RuntimeException )
+ {
+ // simply disambiguate
+ OSingleDocumentController_Base::disposing( i_event );
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::ClearUndoManager()
+ {
+ GetUndoManager().Clear();
+ }
+
+ // -----------------------------------------------------------------------------
+ SfxUndoManager& OSingleDocumentController::GetUndoManager() const
+ {
+ return m_pData->m_pUndoManager->GetSfxUndoManager();
+ }
+
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::addUndoActionAndInvalidate(SfxUndoAction *_pAction)
+ {
+ // add undo action
+ GetUndoManager().AddUndoAction( _pAction );
+
+ // when we add an undo action the controller was modified
+ setModified( sal_True );
+
+ // now inform me that or states changed
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ }
+
+ // -----------------------------------------------------------------------------
+ Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) throw (RuntimeException)
+ {
+ return m_pData->m_pUndoManager.get();
+ }
+
+ // -----------------------------------------------------------------------------
+ FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const
+ {
+ FeatureState aReturn;
+ switch ( _nId )
+ {
+ case ID_BROWSER_UNDO:
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetUndoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sUndo(ModuleRes(STR_UNDO_COLON));
+ sUndo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sUndo += GetUndoManager().GetUndoActionComment();
+ aReturn.sTitle = sUndo;
+ }
+ break;
+
+ case ID_BROWSER_REDO:
+ aReturn.bEnabled = isEditable() && GetUndoManager().GetRedoActionCount() != 0;
+ if ( aReturn.bEnabled )
+ {
+ String sRedo(ModuleRes(STR_REDO_COLON));
+ sRedo += String(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sRedo += GetUndoManager().GetRedoActionComment();
+ aReturn.sTitle = sRedo;
+ }
+ break;
+
+ default:
+ aReturn = OSingleDocumentController_Base::GetState(_nId);
+ }
+ return aReturn;
+ }
+ // -----------------------------------------------------------------------------
+ void OSingleDocumentController::Execute( sal_uInt16 _nId, const Sequence< PropertyValue >& _rArgs )
+ {
+ switch ( _nId )
+ {
+ case ID_BROWSER_UNDO:
+ GetUndoManager().Undo();
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ break;
+
+ case ID_BROWSER_REDO:
+ GetUndoManager().Redo();
+ InvalidateFeature( ID_BROWSER_UNDO );
+ InvalidateFeature( ID_BROWSER_REDO );
+ break;
+
+ default:
+ OSingleDocumentController_Base::Execute( _nId, _rArgs );
+ break;
+ }
+ InvalidateFeature(_nId);
+ }
+
+//......................................................................................................................
+} // namespace dbaui
+//......................................................................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/dbaccess/source/ui/misc/stringlistitem.cxx b/dbaccess/source/ui/misc/stringlistitem.cxx
new file mode 100644
index 000000000000..655dce15c4e8
--- /dev/null
+++ b/dbaccess/source/ui/misc/stringlistitem.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "stringlistitem.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+
+//=========================================================================
+//= OStringListItem
+//=========================================================================
+TYPEINIT1(OStringListItem, SfxPoolItem);
+//-------------------------------------------------------------------------
+OStringListItem::OStringListItem(sal_Int16 _nWhich, const Sequence< ::rtl::OUString >& _rList)
+ :SfxPoolItem(_nWhich)
+ ,m_aList(_rList)
+{
+}
+
+//-------------------------------------------------------------------------
+OStringListItem::OStringListItem(const OStringListItem& _rSource)
+ :SfxPoolItem(_rSource)
+ ,m_aList(_rSource.m_aList)
+{
+}
+
+//-------------------------------------------------------------------------
+int OStringListItem::operator==(const SfxPoolItem& _rItem) const
+{
+ const OStringListItem* pCompare = PTR_CAST(OStringListItem, &_rItem);
+ if ((!pCompare) || (pCompare->m_aList.getLength() != m_aList.getLength()))
+ return 0;
+
+ // compare all strings individually
+ const ::rtl::OUString* pMyStrings = m_aList.getConstArray();
+ const ::rtl::OUString* pCompareStrings = pCompare->m_aList.getConstArray();
+
+ for (sal_Int32 i=0; i<m_aList.getLength(); ++i, ++pMyStrings, ++pCompareStrings)
+ if (!pMyStrings->equals(*pCompareStrings))
+ return 0;
+
+ return 1;
+}
+
+//-------------------------------------------------------------------------
+SfxPoolItem* OStringListItem::Clone(SfxItemPool* /* _pPool */) const
+{
+ return new OStringListItem(*this);
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/misc/uiservices.cxx b/dbaccess/source/ui/misc/uiservices.cxx
new file mode 100644
index 000000000000..0a2dafc25bd0
--- /dev/null
+++ b/dbaccess/source/ui/misc/uiservices.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+#include "dbu_reghelper.hxx"
+#include "dbaccessdllapi.h"
+
+/********************************************************************************************/
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//***************************************************************************************
+//
+// registry functions
+extern "C" void SAL_CALL createRegistryInfo_OTableFilterDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODataSourcePropertyDialog();
+extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog();
+extern "C" void SAL_CALL createRegistryInfo_OBrowser();
+extern "C" void SAL_CALL createRegistryInfo_OFormGridView();
+extern "C" void SAL_CALL createRegistryInfo_DBContentLoader();
+extern "C" void SAL_CALL writeDBLoaderInfo(void* pRegistryKey);
+extern "C" void SAL_CALL createRegistryInfo_OInteractionHandler();
+extern "C" void SAL_CALL createRegistryInfo_SbaXGridControl();
+extern "C" void SAL_CALL createRegistryInfo_OQueryControl();
+extern "C" void SAL_CALL createRegistryInfo_OViewControl();
+extern "C" void SAL_CALL createRegistryInfo_OTableControl();
+extern "C" void SAL_CALL createRegistryInfo_ORelationControl();
+extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs();
+extern "C" void SAL_CALL createRegistryInfo_ODBApplication();
+extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog();
+extern "C" void SAL_CALL createRegistryInfo_OAdvancedSettingsDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialog();
+extern "C" void SAL_CALL createRegistryInfo_OUserSettingsDialog();
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup();
+extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel();
+extern "C" void SAL_CALL createRegistryInfo_OColumnControl();
+extern "C" void SAL_CALL createRegistryInfo_OToolboxController();
+extern "C" void SAL_CALL createRegistryInfo_OStatusbarController();
+extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard();
+extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog();
+
+//***************************************************************************************
+extern "C" void SAL_CALL createRegistryInfo_DBU()
+{
+ static sal_Bool bInit = sal_False;
+ if (!bInit)
+ {
+ createRegistryInfo_OTableFilterDialog();
+ createRegistryInfo_ODataSourcePropertyDialog();
+ createRegistryInfo_OSQLMessageDialog();
+ createRegistryInfo_OBrowser();
+ createRegistryInfo_OFormGridView();
+ createRegistryInfo_DBContentLoader();
+ createRegistryInfo_OInteractionHandler();
+ createRegistryInfo_SbaXGridControl();
+ createRegistryInfo_OQueryControl();
+ createRegistryInfo_OViewControl();
+ createRegistryInfo_OTableControl();
+ createRegistryInfo_ORelationControl();
+ createRegistryInfo_ComposerDialogs();
+ createRegistryInfo_ODBApplication();
+ createRegistryInfo_ODirectSQLDialog();
+ createRegistryInfo_OAdvancedSettingsDialog();
+ createRegistryInfo_ODBTypeWizDialog();
+ createRegistryInfo_ODBTypeWizDialogSetup();
+ createRegistryInfo_OUserSettingsDialog();
+ createRegistryInfo_OColumnControlModel();
+ createRegistryInfo_OColumnControl();
+ createRegistryInfo_OToolboxController();
+ createRegistryInfo_OStatusbarController();
+ createRegistryInfo_CopyTableWizard();
+ createRegistryInfo_OTextConnectionSettingsDialog();
+ bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" DBACCESS_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ createRegistryInfo_DBU();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" DBACCESS_DLLPUBLIC void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dbaui::OModuleRegistration::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/ConnectionLine.cxx b/dbaccess/source/ui/querydesign/ConnectionLine.cxx
new file mode 100644
index 000000000000..91d67b82108c
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLine.cxx
@@ -0,0 +1,385 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionLine.hxx"
+#include "ConnectionLineData.hxx"
+#include "TableWindow.hxx"
+#include "TableWindowListBox.hxx"
+#include "TableConnection.hxx"
+#include <vcl/svapp.hxx>
+#ifndef _INC_MATH
+#include <math.h>
+#endif
+#include <osl/diagnose.h>
+#include <vcl/lineinfo.hxx>
+
+
+using namespace dbaui;
+const long DESCRIPT_LINE_WIDTH = 15;
+const long HIT_SENSITIVE_RADIUS = 5;
+
+namespace
+{
+ /** calcRect creates a new rectangle with the given points
+ @param _rBase the base point
+ @param _aVector the vector which will be added
+ */
+ inline Rectangle calcRect(const Point& _rBase,const Point& _aVector)
+ {
+ return Rectangle( _rBase - _aVector, _rBase + _aVector );
+ }
+ // -----------------------------------------------------------------------------
+ /** GetTextPos calculate the rectangle for the connection to be drawn
+ @param _pWin the table window where to draw it
+ @param _aConnPos the connection point
+ @param _aDescrLinePos the description line pos
+ */
+ Rectangle GetTextPos(const OTableWindow* _pWin, const Point& _aConnPos,const Point& _aDescrLinePos)
+ {
+ OTableWindowListBox* pListBox = _pWin ? _pWin->GetListBox() : NULL;
+ OSL_ENSURE(_pWin && pListBox, "OConnectionLine::GetSourceTextPos : invalid call !");
+
+ Rectangle aReturn;
+ if ( pListBox )
+ {
+ const long nRowHeight = pListBox->GetEntryHeight();
+ aReturn.Top() = _aConnPos.Y() - nRowHeight;
+ aReturn.Bottom() = aReturn.Top() + nRowHeight;
+ if (_aDescrLinePos.X() < _aConnPos.X())
+ {
+ aReturn.Left() = _aDescrLinePos.X();
+ aReturn.Right() = aReturn.Left() + _aConnPos.X() - _aDescrLinePos.X();
+ }
+ else
+ {
+ aReturn.Left() = _aConnPos.X();
+ aReturn.Right() = aReturn.Left() + _aDescrLinePos.X() - _aConnPos.X();
+ }
+ }
+
+ return aReturn;
+ }
+ // -----------------------------------------------------------------------------
+ /** calcPointsYValue calculate the points Y value in relation to the listbox entry
+ @param _pWin the corresponding window
+ @param _pEntry the source or dest entry
+ @param _rNewConPos (in/out) the connection pos
+ @param _rNewDescrPos (in/out) the description pos
+ */
+ void calcPointsYValue(const OTableWindow* _pWin,SvLBoxEntry* _pEntry,Point& _rNewConPos,Point& _rNewDescrPos)
+ {
+ const OTableWindowListBox* pListBox = _pWin->GetListBox();
+ _rNewConPos.Y() = _pWin->GetPosPixel().Y();
+ if ( _pEntry )
+ {
+ const long nRowHeight = pListBox->GetEntryHeight();
+ _rNewConPos.Y() += pListBox->GetPosPixel().Y();
+ long nEntryPos = pListBox->GetEntryPosition( _pEntry ).Y();
+
+ if( nEntryPos >= 0 )
+ {
+ _rNewConPos.Y() += nEntryPos;
+ _rNewConPos.Y() += (long)( 0.5 * nRowHeight );
+ }
+ else
+ _rNewConPos.Y() -= (long)( 0.5 * nRowHeight );
+
+ long nListBoxBottom = _pWin->GetPosPixel().Y()
+ + pListBox->GetPosPixel().Y()
+ + pListBox->GetSizePixel().Height();
+ if( _rNewConPos.Y() > nListBoxBottom )
+ _rNewConPos.Y() = nListBoxBottom + 2;
+ }
+ else
+ _rNewConPos.Y() += static_cast<sal_Int32>(pListBox->GetPosPixel().Y()*0.5);
+
+ _rNewDescrPos.Y() = _rNewConPos.Y();
+ }
+ // -----------------------------------------------------------------------------
+}
+
+//========================================================================
+// class OConnectionLine
+//========================================================================
+DBG_NAME(OConnectionLine)
+//------------------------------------------------------------------------
+OConnectionLine::OConnectionLine( OTableConnection* _pConn, OConnectionLineDataRef _pLineData )
+ : m_pTabConn( _pConn )
+ ,m_pData( _pLineData )
+{
+ DBG_CTOR(OConnectionLine,NULL);
+}
+
+//------------------------------------------------------------------------
+OConnectionLine::OConnectionLine( const OConnectionLine& _rLine )
+{
+ DBG_CTOR(OConnectionLine,NULL);
+ m_pData = new OConnectionLineData( *_rLine.GetData() );
+ *this = _rLine;
+}
+
+//------------------------------------------------------------------------
+OConnectionLine::~OConnectionLine()
+{
+ DBG_DTOR(OConnectionLine,NULL);
+}
+
+//------------------------------------------------------------------------
+OConnectionLine& OConnectionLine::operator=( const OConnectionLine& rLine )
+{
+ if( &rLine != this )
+ {
+ // da mir die Daten nicht gehoeren, loesche ich die alten nicht
+ m_pData->CopyFrom(*rLine.GetData());
+ // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist
+
+ m_pTabConn = rLine.m_pTabConn;
+ m_aSourceConnPos = rLine.m_aSourceConnPos;
+ m_aDestConnPos = rLine.m_aDestConnPos;
+ m_aSourceDescrLinePos = rLine.m_aSourceDescrLinePos;
+ m_aDestDescrLinePos = rLine.m_aDestDescrLinePos;
+ }
+
+ return *this;
+}
+
+//------------------------------------------------------------------------
+Rectangle OConnectionLine::GetBoundingRect()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Umgebendes Rechteck bestimmen
+ Rectangle aBoundingRect( Point(0,0), Point(0,0) );
+ if( !IsValid() )
+ return aBoundingRect;
+
+ Point aTopLeft;
+ Point aBottomRight;
+
+ if( m_aSourceDescrLinePos.Y() <= m_aDestDescrLinePos.Y() )
+ {
+ aTopLeft.Y() = m_aSourceDescrLinePos.Y();
+ aBottomRight.Y() = m_aDestDescrLinePos.Y();
+ }
+ else
+ {
+ aTopLeft.Y() = m_aDestDescrLinePos.Y();
+ aBottomRight.Y() = m_aSourceDescrLinePos.Y();
+ }
+
+ if( m_aSourceDescrLinePos.X() <= m_aDestDescrLinePos.X() )
+ {
+ aTopLeft.X() = m_aSourceDescrLinePos.X();
+ aBottomRight.X() = m_aDestDescrLinePos.X();
+ }
+ else
+ {
+ aTopLeft.X() = m_aDestDescrLinePos.X();
+ aBottomRight.X() = m_aSourceDescrLinePos.X();
+ }
+
+ const OTableWindow* pSourceWin = m_pTabConn->GetSourceWin();
+ const OTableWindow* pDestWin = m_pTabConn->GetDestWin();
+ //////////////////////////////////////////////////////////////////////
+ // Linie verlaeuft in z-Form
+ if( pSourceWin == pDestWin || Abs(m_aSourceConnPos.X() - m_aDestConnPos.X()) > Abs(m_aSourceDescrLinePos.X() - m_aDestDescrLinePos.X()) )
+ {
+ aTopLeft.X() -= DESCRIPT_LINE_WIDTH;
+ aBottomRight.X() += DESCRIPT_LINE_WIDTH;
+ }
+
+ aBoundingRect = Rectangle( aTopLeft-Point(2,17), aBottomRight+Point(2,2) );
+
+ return aBoundingRect;
+}
+// -----------------------------------------------------------------------------
+void calcPointX1(const OTableWindow* _pWin,Point& _rNewConPos,Point& _rNewDescrPos)
+{
+ _rNewConPos.X() = _pWin->GetPosPixel().X() + _pWin->GetSizePixel().Width();
+ _rNewDescrPos.X() = _rNewConPos.X();
+ _rNewConPos.X() += DESCRIPT_LINE_WIDTH;
+}
+// -----------------------------------------------------------------------------
+void calcPointX2(const OTableWindow* _pWin,Point& _rNewConPos,Point& _rNewDescrPos)
+{
+ _rNewConPos.X() = _pWin->GetPosPixel().X();
+ _rNewDescrPos.X() = _rNewConPos.X();
+ _rNewConPos.X() -= DESCRIPT_LINE_WIDTH;
+}
+//------------------------------------------------------------------------
+sal_Bool OConnectionLine::RecalcLine()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Fenster und Entries muessen gesetzt sein
+ const OTableWindow* pSourceWin = m_pTabConn->GetSourceWin();
+ const OTableWindow* pDestWin = m_pTabConn->GetDestWin();
+
+ if( !pSourceWin || !pDestWin )
+ return sal_False;
+
+ SvLBoxEntry* pSourceEntry = pSourceWin->GetListBox()->GetEntryFromText( GetData()->GetSourceFieldName() );
+ SvLBoxEntry* pDestEntry = pDestWin->GetListBox()->GetEntryFromText( GetData()->GetDestFieldName() );
+
+ //////////////////////////////////////////////////////////////////////
+ // X-Koordinaten bestimmen
+ Point aSourceCenter( 0, 0 );
+ Point aDestCenter( 0, 0 );
+
+ aSourceCenter.X() = pSourceWin->GetPosPixel().X() + (long)( 0.5*pSourceWin->GetSizePixel().Width() );
+ aDestCenter.X() = pDestWin->GetPosPixel().X() + (long)( 0.5*pDestWin->GetSizePixel().Width() );
+
+ const OTableWindow* pFirstWin = pDestWin;
+ const OTableWindow* pSecondWin = pSourceWin;
+ Point* pFirstConPos = &m_aDestConnPos;
+ Point* pFirstDescrPos = &m_aDestDescrLinePos;
+ Point* pSecondConPos = &m_aSourceConnPos;
+ Point* pSecondDescrPos = &m_aSourceDescrLinePos;
+ if( aDestCenter.X() > aSourceCenter.X() )
+ {
+ pFirstWin = pSourceWin;
+ pSecondWin = pDestWin;
+ pFirstConPos = &m_aSourceConnPos;
+ pFirstDescrPos = &m_aSourceDescrLinePos;
+ pSecondConPos = &m_aDestConnPos;
+ pSecondDescrPos = &m_aDestDescrLinePos;
+ }
+
+ if ( pFirstWin == pSecondWin && pSourceEntry != pDestEntry )
+ calcPointX2(pFirstWin,*pFirstConPos,*pFirstDescrPos);
+ else
+ calcPointX1(pFirstWin,*pFirstConPos,*pFirstDescrPos);
+ calcPointX2(pSecondWin,*pSecondConPos,*pSecondDescrPos);
+
+ //////////////////////////////////////////////////////////////////////
+ // aSourceConnPosY bestimmen
+ calcPointsYValue(pSourceWin,pSourceEntry,m_aSourceConnPos,m_aSourceDescrLinePos);
+
+ //////////////////////////////////////////////////////////////////////
+ // aDestConnPosY bestimmen
+ calcPointsYValue(pDestWin,pDestEntry,m_aDestConnPos,m_aDestDescrLinePos);
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+void OConnectionLine::Draw( OutputDevice* pOutDev )
+{
+ const sal_uInt16 nRectSize = 3;
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Dimensionen berechnen
+ if( !RecalcLine() )
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Zeichnen der Linien
+ if (m_pTabConn->IsSelected())
+ pOutDev->SetLineColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
+ else
+ pOutDev->SetLineColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
+
+ LineInfo aLineInfo;
+ if ( m_pTabConn->IsSelected() )
+ aLineInfo.SetWidth(3);
+ Polygon aPoly;
+ aPoly.Insert(0,m_aSourceDescrLinePos);
+ aPoly.Insert(1,m_aSourceConnPos);
+ aPoly.Insert(2,m_aDestConnPos);
+ aPoly.Insert(3,m_aDestDescrLinePos);
+ pOutDev->DrawPolyLine(aPoly,aLineInfo);
+
+ //////////////////////////////////////////////////////////////////////
+ // draw the connection rectangles
+ pOutDev->SetFillColor(Application::GetSettings().GetStyleSettings().GetWindowColor());
+
+ Point aVector(nRectSize,nRectSize);
+ pOutDev->DrawRect( calcRect(m_aSourceDescrLinePos,aVector) );
+ pOutDev->DrawRect( calcRect( m_aDestDescrLinePos,aVector) );
+}
+// -----------------------------------------------------------------------------
+sal_Bool OConnectionLine::IsValid() const
+{
+ return m_pData.is();
+}
+//------------------------------------------------------------------------
+double dist_Euklid(const Point &p1, const Point& p2,const Point& pM, Point& q)
+{
+ Point v(p2 - p1);
+ Point w(pM - p1);
+ double a = sqrt((double)(v.X()*v.X() + v.Y()*v.Y()));
+ double l = (v.X() * w.Y() - v.Y() * w.X()) / a;
+ double a2 = w.X()*v.X()+w.Y()*v.Y();
+ a = a2 / (a * a);
+ q.X() = long(p1.X() + a * v.X());
+ q.Y() = long(p1.Y() + a * v.Y());
+ return l;
+}
+//------------------------------------------------------------------------
+bool OConnectionLine::CheckHit( const Point& rMousePos ) const
+{
+ //////////////////////////////////////////////////////////////////////
+ /*
+ Vorgehensweise beim HitTest:
+ Es wird der Abstand nach Euklid berechnet.
+ */
+ Point q;
+ double l = fabs(dist_Euklid(m_aSourceConnPos,m_aDestConnPos,rMousePos,q));
+ if( l < HIT_SENSITIVE_RADIUS)
+ {
+ if(::std::min(m_aSourceConnPos.X(),m_aDestConnPos.X()) <= q.X() && ::std::min(m_aSourceConnPos.Y(),m_aDestConnPos.Y()) <= q.Y()
+ && q.X() <= ::std::max(m_aDestConnPos.X(),m_aSourceConnPos.X()) && q.Y() <= ::std::max(m_aDestConnPos.Y(),m_aSourceConnPos.Y()))
+ return true;
+ }
+
+ return false;
+}
+// -----------------------------------------------------------------------------
+Rectangle OConnectionLine::GetSourceTextPos() const
+{
+ return GetTextPos(m_pTabConn->GetSourceWin(),m_aSourceConnPos,m_aSourceDescrLinePos);
+}
+// -----------------------------------------------------------------------------
+Rectangle OConnectionLine::GetDestTextPos() const
+{
+ return GetTextPos(m_pTabConn->GetDestWin(),m_aDestConnPos,m_aDestDescrLinePos);
+}
+// -----------------------------------------------------------------------------
+Point OConnectionLine::getMidPoint() const
+{
+ Point aDest = m_aDestConnPos - m_aSourceConnPos;
+ aDest.X() /= 2;
+ aDest.Y() /= 2;
+
+ return m_aSourceConnPos + aDest;
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
new file mode 100644
index 000000000000..a1297dfc68b0
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionLineAccess.hxx"
+#include "JoinTableView.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <toolkit/awt/vclxwindow.hxx>
+#include "TableConnection.hxx"
+#include "TableWindow.hxx"
+#include <comphelper/uno3.hxx>
+#include "JoinDesignView.hxx"
+#include "JoinController.hxx"
+#include <comphelper/sequence.hxx>
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::accessibility;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star;
+
+ OConnectionLineAccess::OConnectionLineAccess(OTableConnection* _pLine)
+ : VCLXAccessibleComponent(_pLine->GetComponentInterface().is() ? _pLine->GetWindowPeer() : NULL)
+ ,m_pLine(_pLine)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OConnectionLineAccess::disposing()
+ {
+ m_pLine = NULL;
+ VCLXAccessibleComponent::disposing();
+ }
+ // -----------------------------------------------------------------------------
+ Any SAL_CALL OConnectionLineAccess::queryInterface( const Type& aType ) throw (RuntimeException)
+ {
+ Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
+ return aRet.hasValue() ? aRet : OConnectionLineAccess_BASE::queryInterface( aType );
+ }
+ // -----------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OConnectionLineAccess::getTypes( ) throw (RuntimeException)
+ {
+ return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OConnectionLineAccess_BASE::getTypes());
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OConnectionLineAccess::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+ // -----------------------------------------------------------------------------
+ // XServiceInfo - static methods
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OConnectionLineAccess::getImplementationName_Static(void) throw( RuntimeException )
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ConnectionLineAccessibility"));
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleContext
+ sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleChildCount( ) throw (RuntimeException)
+ {
+ return 0;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleChild( sal_Int32 /*i*/ ) throw (RuntimeException)
+ {
+ return Reference< XAccessible >();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int32 SAL_CALL OConnectionLineAccess::getAccessibleIndexInParent( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nIndex = -1;
+ if( m_pLine )
+ {
+ // search the postion of our table window in the table window map
+ nIndex = m_pLine->GetParent()->GetTabWinMap()->size();
+ const ::std::vector<OTableConnection*>* pVec = m_pLine->GetParent()->getTableConnections();
+ ::std::vector<OTableConnection*>::const_iterator aIter = pVec->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pVec->end();
+ for (; aIter != aEnd && (*aIter) != m_pLine; ++nIndex,++aIter)
+ ;
+ nIndex = ( aIter != aEnd ) ? nIndex : -1;
+ }
+ return nIndex;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int16 SAL_CALL OConnectionLineAccess::getAccessibleRole( ) throw (RuntimeException)
+ {
+ return AccessibleRole::UNKNOWN; // ? or may be an AccessibleRole::WINDOW
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OConnectionLineAccess::getAccessibleDescription( ) throw (RuntimeException)
+ {
+ static ::rtl::OUString sDescription(RTL_CONSTASCII_USTRINGPARAM("Relation"));
+ return sDescription;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessibleRelationSet > SAL_CALL OConnectionLineAccess::getAccessibleRelationSet( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return this;
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleComponent
+ sal_Bool SAL_CALL OConnectionLineAccess::contains( const awt::Point& _aPoint ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Point aPoint(_aPoint.X,_aPoint.Y);
+ return m_pLine ? m_pLine->CheckHit(aPoint) : sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > SAL_CALL OConnectionLineAccess::getAccessibleAtPoint( const awt::Point& /*_aPoint*/ ) throw (RuntimeException)
+ {
+ return Reference< XAccessible >();
+ }
+ // -----------------------------------------------------------------------------
+ awt::Rectangle SAL_CALL OConnectionLineAccess::getBounds( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Rectangle aRect(m_pLine ? m_pLine->GetBoundingRect() : Rectangle());
+ return awt::Rectangle(aRect.getX(),aRect.getY(),aRect.getWidth(),aRect.getHeight());
+ }
+ // -----------------------------------------------------------------------------
+ awt::Point SAL_CALL OConnectionLineAccess::getLocation( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Point aPoint(m_pLine ? m_pLine->GetBoundingRect().TopLeft() : Point());
+ return awt::Point(aPoint.X(),aPoint.Y());
+ }
+ // -----------------------------------------------------------------------------
+ awt::Point SAL_CALL OConnectionLineAccess::getLocationOnScreen( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Point aPoint(m_pLine ? m_pLine->GetParent()->ScreenToOutputPixel(m_pLine->GetBoundingRect().TopLeft()) : Point());
+ return awt::Point(aPoint.X(),aPoint.Y());
+ }
+ // -----------------------------------------------------------------------------
+ awt::Size SAL_CALL OConnectionLineAccess::getSize( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Size aSize(m_pLine ? m_pLine->GetBoundingRect().GetSize() : Size());
+ return awt::Size(aSize.Width(),aSize.Height());
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OConnectionLineAccess::isShowing( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pLine ? m_pLine->GetParent()->GetWindowRegionPixel().IsInside(m_pLine->GetBoundingRect()) : sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OConnectionLineAccess::isVisible( ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OConnectionLineAccess::isFocusTraversable( ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleRelationSet
+ // -----------------------------------------------------------------------------
+ sal_Int32 SAL_CALL OConnectionLineAccess::getRelationCount( ) throw (RuntimeException)
+ {
+ return 1;
+ }
+ // -----------------------------------------------------------------------------
+ AccessibleRelation SAL_CALL OConnectionLineAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if( nIndex < 0 || nIndex >= getRelationCount() )
+ throw IndexOutOfBoundsException();
+
+ Sequence< Reference<XInterface> > aSeq(m_pLine ? 2 : 0);
+ if( m_pLine )
+ {
+ aSeq[0] = m_pLine->GetSourceWin()->GetAccessible();
+ aSeq[1] = m_pLine->GetDestWin()->GetAccessible();
+ }
+
+ return AccessibleRelation(AccessibleRelationType::CONTROLLED_BY,aSeq);
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OConnectionLineAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
+ {
+ return AccessibleRelationType::CONTROLLED_BY == aRelationType;
+ }
+ // -----------------------------------------------------------------------------
+ AccessibleRelation SAL_CALL OConnectionLineAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
+ {
+ if( AccessibleRelationType::CONTROLLED_BY == aRelationType )
+ return getRelation(0);
+ return AccessibleRelation();
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > OTableConnection::CreateAccessible()
+ {
+ return new OConnectionLineAccess(this);
+ }
+ // -----------------------------------------------------------------------------
+ OTableConnection::~OTableConnection()
+ {
+ DBG_DTOR(OTableConnection,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // clear vector
+ clearLineData();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OConnectionLineAccess::isEditable() const
+ {
+
+ return m_pLine ? !m_pLine->GetParent()->getDesignView()->getController().isReadOnly() : sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessibleContext > SAL_CALL OConnectionLineAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return this;
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/ConnectionLineData.cxx b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx
new file mode 100644
index 000000000000..49360b0959b5
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/ConnectionLineData.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ConnectionLineData.hxx"
+#include <tools/debug.hxx>
+
+
+using namespace dbaui;
+DBG_NAME(OConnectionLineData)
+//==================================================================
+//class OConnectionLineData
+//==================================================================
+//------------------------------------------------------------------------
+OConnectionLineData::OConnectionLineData()
+{
+ DBG_CTOR(OConnectionLineData,NULL);
+}
+
+//------------------------------------------------------------------------
+OConnectionLineData::OConnectionLineData( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName )
+ :m_aSourceFieldName( rSourceFieldName )
+ ,m_aDestFieldName( rDestFieldName )
+{
+ DBG_CTOR(OConnectionLineData,NULL);
+}
+
+//------------------------------------------------------------------------
+OConnectionLineData::OConnectionLineData( const OConnectionLineData& rConnLineData )
+ : ::salhelper::SimpleReferenceObject()
+{
+ DBG_CTOR(OConnectionLineData,NULL);
+ *this = rConnLineData;
+}
+
+//------------------------------------------------------------------------
+OConnectionLineData::~OConnectionLineData()
+{
+ DBG_DTOR(OConnectionLineData,NULL);
+}
+
+//------------------------------------------------------------------------
+void OConnectionLineData::CopyFrom(const OConnectionLineData& rSource)
+{
+ *this = rSource;
+ // hier ziehe ich mich auf das (nicht-virtuelle) operator= zurueck, das nur meine Members kopiert
+}
+
+//------------------------------------------------------------------------
+OConnectionLineData& OConnectionLineData::operator=( const OConnectionLineData& rConnLineData )
+{
+ if (&rConnLineData == this)
+ return *this;
+
+ m_aSourceFieldName = rConnLineData.GetSourceFieldName();
+ m_aDestFieldName = rConnLineData.GetDestFieldName();
+
+ return *this;
+}
+
+//------------------------------------------------------------------------
+bool OConnectionLineData::Reset()
+{
+ m_aDestFieldName = m_aSourceFieldName = ::rtl::OUString();
+ return true;
+}
+// -----------------------------------------------------------------------------
+namespace dbaui
+{
+//-------------------------------------------------------------------------
+bool operator==(const OConnectionLineData& lhs, const OConnectionLineData& rhs)
+{
+ return (lhs.m_aSourceFieldName == rhs.m_aSourceFieldName)
+ && (lhs.m_aDestFieldName == rhs.m_aDestFieldName);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/JAccess.cxx b/dbaccess/source/ui/querydesign/JAccess.cxx
new file mode 100644
index 000000000000..90feae92b25d
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JAccess.cxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "JAccess.hxx"
+#include "JoinTableView.hxx"
+#include "JoinTableView.hxx"
+#include "TableWindow.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include "JoinDesignView.hxx"
+#include "JoinController.hxx"
+#include "TableConnection.hxx"
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::accessibility;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+
+ OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView)
+ :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : NULL)
+ ,m_pTableView(_pTableView)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OJoinDesignViewAccess::getImplementationName_Static(void) throw( RuntimeException )
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.JoinViewAccessibility"));
+ }
+ // -----------------------------------------------------------------------------
+ void OJoinDesignViewAccess::clearTableView()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_pTableView = NULL;
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleContext
+ sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) throw (RuntimeException)
+ {
+ // TODO may be this will change to only visible windows
+ // this is the same assumption mt implements
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nChildCount = 0;
+ if ( m_pTableView )
+ nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections()->size();
+ return nChildCount;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException)
+ {
+ Reference< XAccessible > aRet;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if(i >= 0 && i < getAccessibleChildCount() && m_pTableView )
+ {
+ // check if we should return a table window or a connection
+ sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
+ if( i < nTableWindowCount )
+ {
+ OJoinTableView::OTableWindowMap::iterator aIter = m_pTableView->GetTabWinMap()->begin();
+ for (sal_Int32 j=i; j; ++aIter,--j)
+ ;
+ aRet = aIter->second->GetAccessible();
+ }
+ else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections()->size() )
+ aRet = (*m_pTableView->getTableConnections())[i - nTableWindowCount]->GetAccessible();
+ }
+ else
+ throw IndexOutOfBoundsException();
+ return aRet;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OJoinDesignViewAccess::isEditable() const
+ {
+ return m_pTableView && !m_pTableView->getDesignView()->getController().isReadOnly();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( ) throw (RuntimeException)
+ {
+ return AccessibleRole::VIEW_PORT;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return this;
+ }
+ // -----------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------
+ // XInterface
+ // -----------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
+ // -----------------------------------------------------------------------------
+ // XTypeProvider
+ // -----------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
+}
+
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx
new file mode 100644
index 000000000000..f4552253d84f
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinController.cxx
@@ -0,0 +1,475 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <sfx2/sfxsids.hrc>
+#include "dbu_qry.hrc"
+#include "browserids.hxx"
+#include <comphelper/types.hxx>
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <comphelper/streamsection.hxx>
+#include <comphelper/basicio.hxx>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include "sqlmessage.hxx"
+#include "JoinController.hxx"
+#include <vcl/msgbox.hxx>
+#include "TableWindowData.hxx"
+#include "TableWindow.hxx"
+#include "TableConnectionData.hxx"
+#include "adtabdlg.hxx"
+#include <vcl/waitobj.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include "UITools.hxx"
+#include <osl/diagnose.h>
+
+#include <boost/optional.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+// .............................................................................
+namespace dbaui
+{
+// .............................................................................
+
+// =============================================================================
+// = AddTableDialogContext
+// =============================================================================
+class AddTableDialogContext : public IAddTableDialogContext
+{
+ OJoinController& m_rController;
+
+public:
+ AddTableDialogContext( OJoinController& _rController )
+ :m_rController( _rController )
+ {
+ }
+
+ // IAddTableDialogContext
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getConnection() const;
+ virtual bool allowViews() const;
+ virtual bool allowQueries() const;
+ virtual bool allowAddition() const;
+ virtual void addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName );
+ virtual void onWindowClosing( const Window* _pWindow );
+
+private:
+ OJoinTableView* getTableView() const;
+};
+
+// -----------------------------------------------------------------------------
+Reference< XConnection > AddTableDialogContext::getConnection() const
+{
+ return m_rController.getConnection();
+}
+
+// -----------------------------------------------------------------------------
+bool AddTableDialogContext::allowViews() const
+{
+ return m_rController.allowViews();
+}
+
+// -----------------------------------------------------------------------------
+bool AddTableDialogContext::allowQueries() const
+{
+ return m_rController.allowQueries();
+}
+
+// -----------------------------------------------------------------------------
+bool AddTableDialogContext::allowAddition() const
+{
+ return const_cast< OJoinController& >( m_rController ).getJoinView()->getTableView()->IsAddAllowed();
+}
+
+// -----------------------------------------------------------------------------
+void AddTableDialogContext::addTableWindow( const String& _rQualifiedTableName, const String& _rAliasName )
+{
+ getTableView()->AddTabWin( _rQualifiedTableName, _rAliasName, sal_True );
+}
+
+// -----------------------------------------------------------------------------
+void AddTableDialogContext::onWindowClosing( const Window* _pWindow )
+{
+ if ( !m_rController.getView() )
+ return;
+
+ ::dbaui::notifySystemWindow(
+ m_rController.getView(), const_cast< Window* >( _pWindow ), ::comphelper::mem_fun( &TaskPaneList::RemoveWindow ) );
+
+ m_rController.InvalidateFeature( ID_BROWSER_ADDTABLE );
+ m_rController.getView()->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+OJoinTableView* AddTableDialogContext::getTableView() const
+{
+ if ( m_rController.getJoinView() )
+ return m_rController.getJoinView()->getTableView();
+ return NULL;
+}
+
+// =============================================================================
+// = OJoinController
+// =============================================================================
+
+DBG_NAME(OJoinController)
+// -----------------------------------------------------------------------------
+OJoinController::OJoinController(const Reference< XMultiServiceFactory >& _rM)
+ :OJoinController_BASE(_rM)
+ ,m_pAddTableDialog(NULL)
+{
+ DBG_CTOR(OJoinController,NULL);
+}
+// -----------------------------------------------------------------------------
+OJoinController::~OJoinController()
+{
+ DBG_DTOR(OJoinController,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OJoinController::disposing( const EventObject& _rSource ) throw(RuntimeException)
+{
+ OJoinController_BASE::disposing( _rSource );
+}
+
+// -----------------------------------------------------------------------------
+OJoinDesignView* OJoinController::getJoinView()
+{
+ return static_cast< OJoinDesignView* >( getView() );
+}
+
+// -----------------------------------------------------------------------------
+void OJoinController::disposing()
+{
+ {
+ ::std::auto_ptr< Window > pEnsureDelete( m_pAddTableDialog );
+ m_pAddTableDialog = NULL;
+ }
+
+ OJoinController_BASE::disposing();
+
+ clearView();
+
+ m_vTableConnectionData.clear();
+ m_vTableData.clear();
+}
+// -----------------------------------------------------------------------------
+void OJoinController::reconnect( sal_Bool _bUI )
+{
+ OJoinController_BASE::reconnect( _bUI );
+ if ( isConnected() && m_pAddTableDialog )
+ m_pAddTableDialog->Update();
+}
+
+// -----------------------------------------------------------------------------
+void OJoinController::impl_onModifyChanged()
+{
+ OJoinController_BASE::impl_onModifyChanged();
+ InvalidateFeature( SID_RELATION_ADD_RELATION );
+}
+// -----------------------------------------------------------------------------
+void OJoinController::SaveTabWinPosSize(OTableWindow* pTabWin, long nOffsetX, long nOffsetY)
+{
+ // die Daten zum Fenster
+ TTableWindowData::value_type pData = pTabWin->GetData();
+ OSL_ENSURE(pData != NULL, "SaveTabWinPosSize : TabWin hat keine Daten !");
+
+ // Position & Size der Daten neu setzen (aus den aktuellen Fenster-Parametern)
+ Point aPos = pTabWin->GetPosPixel();
+ aPos.X() += nOffsetX;
+ aPos.Y() += nOffsetY;
+ pData->SetPosition(aPos);
+ pData->SetSize(pTabWin->GetSizePixel());
+
+}
+// -----------------------------------------------------------------------------
+FeatureState OJoinController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ // (disabled automatically)
+ aReturn.bEnabled = sal_True;
+
+ switch (_nId)
+ {
+ case ID_BROWSER_EDITDOC:
+ aReturn.bChecked = isEditable();
+ break;
+ case ID_BROWSER_ADDTABLE:
+ aReturn.bEnabled = ( getView() != NULL )
+ && const_cast< OJoinController* >( this )->getJoinView()->getTableView()->IsAddAllowed();
+ aReturn.bChecked = aReturn.bEnabled && m_pAddTableDialog != NULL && m_pAddTableDialog->IsVisible() ;
+ if ( aReturn.bEnabled )
+ aReturn.sTitle = OAddTableDlg::getDialogTitleForContext( impl_getDialogContext() );
+ break;
+
+ default:
+ aReturn = OJoinController_BASE::GetState(_nId);
+ }
+ return aReturn;
+}
+
+// -----------------------------------------------------------------------------
+AddTableDialogContext& OJoinController::impl_getDialogContext() const
+{
+ if ( !m_pDialogContext.get() )
+ {
+ OJoinController* pNonConstThis = const_cast< OJoinController* >( this );
+ pNonConstThis->m_pDialogContext.reset( new AddTableDialogContext( *pNonConstThis ) );
+ }
+ return *m_pDialogContext;
+}
+
+// -----------------------------------------------------------------------------
+void OJoinController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch(_nId)
+ {
+ case ID_BROWSER_EDITDOC:
+ if(isEditable())
+ { // the state should be changed to not editable
+ switch (saveModified())
+ {
+ case RET_CANCEL:
+ // don't change anything here so return
+ return;
+ case RET_NO:
+ reset();
+ setModified(sal_False); // and we are not modified yet
+ break;
+ default:
+ break;
+ }
+ }
+ setEditable(!isEditable());
+ getJoinView()->setReadOnly(!isEditable());
+ InvalidateAll();
+ return;
+ case ID_BROWSER_ADDTABLE:
+ if ( !m_pAddTableDialog )
+ m_pAddTableDialog = new OAddTableDlg( getView(), impl_getDialogContext() );
+
+ if ( m_pAddTableDialog->IsVisible() )
+ {
+ m_pAddTableDialog->Show( sal_False );
+ getView()->GrabFocus();
+ }
+ else
+ {
+ {
+ WaitObject aWaitCursor( getView() );
+ m_pAddTableDialog->Update();
+ }
+ m_pAddTableDialog->Show( sal_True );
+ ::dbaui::notifySystemWindow(getView(),m_pAddTableDialog,::comphelper::mem_fun(&TaskPaneList::AddWindow));
+ }
+ break;
+ default:
+ OJoinController_BASE::Execute(_nId,aArgs);
+ }
+ InvalidateFeature(_nId);
+}
+// -----------------------------------------------------------------------------
+void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabWinList, long nOffsetX, long nOffsetY )
+{
+ // Das Loeschen und Neuanlegen der alten Implementation ist unter dem aktuellen Modell nicht mehr richtig : Die TabWins
+ // habe einen Zeiger auf ihre Daten, verwaltet werden sie aber von mir. Wenn ich die alten loesche, haben die TabWins
+ // ploetzlich Zeiger auf nicht mehr existente Objekte.
+ // Wenn die TabWins ein SetData haetten, koennte ich mir das sparen ... haben sie aber nicht, ausserdem muesste ich dann immer
+ // noch Informationen, die sich eigentlich nicht geaendert haben, auch neu setzen.
+ // Also loesche ich die TabWinDatas nicht, sondern aktualisiere sie nur.
+ OSL_ENSURE(m_vTableData.size() == pTabWinList->size(),
+ "OJoinController::SaveTabWinsPosSize : inkonsistenter Zustand : sollte genausviel TabWinDatas haben wie TabWins !");
+
+ OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end();
+ for(;aIter != aEnd;++aIter)
+ SaveTabWinPosSize(aIter->second, nOffsetX, nOffsetY);
+}
+// -----------------------------------------------------------------------------
+void OJoinController::removeConnectionData(const TTableConnectionData::value_type& _pData)
+{
+ m_vTableConnectionData.erase( ::std::remove(m_vTableConnectionData.begin(),m_vTableConnectionData.end(),_pData),m_vTableConnectionData.end());
+}
+// -----------------------------------------------------------------------------
+void OJoinController::describeSupportedFeatures()
+{
+ OJoinController_BASE::describeSupportedFeatures();
+ implDescribeSupportedFeature( ".uno:Redo", ID_BROWSER_REDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:AddTable", ID_BROWSER_ADDTABLE,CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:EditDoc", ID_BROWSER_EDITDOC, CommandGroup::EDIT );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OJoinController::suspend(sal_Bool _bSuspend) throw( RuntimeException )
+{
+ if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
+ return sal_True;
+
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( getView() && getView()->IsInModalMode() )
+ return sal_False;
+ sal_Bool bCheck = sal_True;
+ if ( _bSuspend )
+ {
+ bCheck = saveModified() != RET_CANCEL;
+ if ( bCheck )
+ OSingleDocumentController::suspend(_bSuspend);
+ }
+ return bCheck;
+}
+// -----------------------------------------------------------------------------
+void OJoinController::loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings )
+{
+ m_vTableData.clear();
+
+ m_aMinimumTableViewSize = Point();
+
+ Sequence< PropertyValue > aWindowData;
+ aWindowData = i_rViewSettings.getOrDefault( "Tables", aWindowData );
+
+ const PropertyValue* pTablesIter = aWindowData.getConstArray();
+ const PropertyValue* pTablesEnd = pTablesIter + aWindowData.getLength();
+ for ( ; pTablesIter != pTablesEnd; ++pTablesIter )
+ {
+ ::comphelper::NamedValueCollection aSingleTableData( pTablesIter->Value );
+ loadTableWindow( aSingleTableData );
+ }
+ if ( m_aMinimumTableViewSize != Point() )
+ {
+ getJoinView()->getScrollHelper()->resetRange( m_aMinimumTableViewSize );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OJoinController::loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings )
+{
+ sal_Int32 nX = -1, nY = -1, nHeight = -1, nWidth = -1;
+
+ ::rtl::OUString sComposedName,sTableName,sWindowName;
+ sal_Bool bShowAll = false;
+
+ sComposedName = i_rTableWindowSettings.getOrDefault( "ComposedName", sComposedName );
+ sTableName = i_rTableWindowSettings.getOrDefault( "TableName", sTableName );
+ sWindowName = i_rTableWindowSettings.getOrDefault( "WindowName", sWindowName );
+ nY = i_rTableWindowSettings.getOrDefault( "WindowTop", nY );
+ nX = i_rTableWindowSettings.getOrDefault( "WindowLeft", nX );
+ nWidth = i_rTableWindowSettings.getOrDefault( "WindowWidth", nWidth );
+ nHeight = i_rTableWindowSettings.getOrDefault( "WindowHeight", nHeight );
+ bShowAll = i_rTableWindowSettings.getOrDefault( "ShowAll", bShowAll );
+
+ TTableWindowData::value_type pData = createTableWindowData(sComposedName,sTableName,sWindowName);
+ if ( pData )
+ {
+ pData->SetPosition(Point(nX,nY));
+ pData->SetSize( Size( nWidth, nHeight ) );
+ pData->ShowAll(bShowAll);
+ m_vTableData.push_back(pData);
+ if ( m_aMinimumTableViewSize.X() < (nX+nWidth) )
+ m_aMinimumTableViewSize.X() = (nX+nWidth);
+ if ( m_aMinimumTableViewSize.Y() < (nY+nHeight) )
+ m_aMinimumTableViewSize.Y() = (nY+nHeight);
+ }
+}
+// -----------------------------------------------------------------------------
+void OJoinController::saveTableWindows( ::comphelper::NamedValueCollection& o_rViewSettings ) const
+{
+ if ( !m_vTableData.empty() )
+ {
+ ::comphelper::NamedValueCollection aAllTablesData;
+
+ TTableWindowData::const_iterator aIter = m_vTableData.begin();
+ TTableWindowData::const_iterator aEnd = m_vTableData.end();
+ for ( sal_Int32 i = 1; aIter != aEnd; ++aIter, ++i )
+ {
+ ::comphelper::NamedValueCollection aWindowData;
+ aWindowData.put( "ComposedName", (*aIter)->GetComposedName() );
+ aWindowData.put( "TableName", (*aIter)->GetTableName() );
+ aWindowData.put( "WindowName", (*aIter)->GetWinName() );
+ aWindowData.put( "WindowTop", static_cast<sal_Int32>((*aIter)->GetPosition().Y()) );
+ aWindowData.put( "WindowLeft", static_cast<sal_Int32>((*aIter)->GetPosition().X()) );
+ aWindowData.put( "WindowWidth", static_cast<sal_Int32>((*aIter)->GetSize().Width()) );
+ aWindowData.put( "WindowHeight", static_cast<sal_Int32>((*aIter)->GetSize().Height()) );
+ aWindowData.put( "ShowAll", (*aIter)->IsShowAll() );
+
+ const ::rtl::OUString sTableName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ) + ::rtl::OUString::valueOf( i ) );
+ aAllTablesData.put( sTableName, aWindowData.getPropertyValues() );
+ }
+
+ o_rViewSettings.put( "Tables", aAllTablesData.getPropertyValues() );
+ }
+}
+// -----------------------------------------------------------------------------
+TTableWindowData::value_type OJoinController::createTableWindowData(const ::rtl::OUString& _sComposedName,const ::rtl::OUString& _sTableName,const ::rtl::OUString& _sWindowName)
+{
+ OJoinDesignView* pView = getJoinView();
+ if( pView )
+ return pView->getTableView()->createTableWindowData(_sComposedName,_sTableName,_sWindowName);
+ OSL_FAIL("We should never ever reach this point!");
+
+ return TTableWindowData::value_type();
+}
+// .............................................................................
+} // namespace dbaui
+// .............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/JoinDesignView.cxx b/dbaccess/source/ui/querydesign/JoinDesignView.cxx
new file mode 100644
index 000000000000..397bb804c829
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinDesignView.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "JoinDesignView.hxx"
+#include "JoinTableView.hxx"
+#include "JoinController.hxx"
+#include <svl/undo.hxx>
+#include "adtabdlg.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include "browserids.hxx"
+#include "dbu_qry.hrc"
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "TableConnection.hxx"
+#include "ConnectionLine.hxx"
+#include "ConnectionLineData.hxx"
+#include "TableConnectionData.hxx"
+#include "dbustrings.hrc"
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+#include "JoinTableView.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+
+namespace dbaui
+{
+
+// =============================================================================
+// = OJoinDesignView
+// =============================================================================
+// -----------------------------------------------------------------------------
+OJoinDesignView::OJoinDesignView(Window* _pParent, OJoinController& _rController,const Reference< XMultiServiceFactory >& _rFactory)
+ :ODataView( _pParent, _rController, _rFactory )
+ ,m_pTableView(NULL)
+ ,m_rController( _rController )
+{
+ m_pScrollWindow = new OScrollWindowHelper(this);
+}
+// -----------------------------------------------------------------------------
+OJoinDesignView::~OJoinDesignView()
+{
+ ::std::auto_ptr<Window> aT3(m_pScrollWindow);
+ m_pScrollWindow = NULL;
+ ::std::auto_ptr<Window> aT2(m_pTableView);
+ m_pTableView = NULL;
+}
+// -------------------------------------------------------------------------
+void OJoinDesignView::Construct()
+{
+ m_pScrollWindow->setTableView(m_pTableView);
+ m_pScrollWindow->Show();
+ m_pTableView->Show();
+
+ SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
+
+ ODataView::Construct();
+}
+// -----------------------------------------------------------------------------
+void OJoinDesignView::initialize()
+{
+}
+// -------------------------------------------------------------------------
+void OJoinDesignView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ m_pScrollWindow->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+// -----------------------------------------------------------------------------
+void OJoinDesignView::setReadOnly(sal_Bool /*_bReadOnly*/)
+{
+}
+// -----------------------------------------------------------------------------
+void OJoinDesignView::SaveTabWinUIConfig(OTableWindow* pWin)
+{
+ getController().SaveTabWinPosSize(pWin, m_pScrollWindow->GetHScrollBar()->GetThumbPos(), m_pScrollWindow->GetVScrollBar()->GetThumbPos());
+}
+// -----------------------------------------------------------------------------
+void OJoinDesignView::KeyInput( const KeyEvent& rEvt )
+{
+ if ( m_pTableView && m_pTableView->IsVisible() )
+ m_pTableView->KeyInput( rEvt );
+ else
+ ODataView::KeyInput(rEvt);
+}
+// -----------------------------------------------------------------------------
+
+} // namespace dbaui
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx
new file mode 100644
index 000000000000..75d69afa5b09
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "JoinExchange.hxx"
+#include <sot/formats.hxx>
+#include <svx/dbexch.hrc>
+#include <cppuhelper/typeprovider.hxx>
+#include <sot/formats.hxx>
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::datatransfer;
+
+ String OJoinExchObj::m_sJoinFormat;
+ //==================================================================
+ // class OJoinExchObj
+ //==================================================================
+ DBG_NAME(OJoinExchObj)
+ //------------------------------------------------------------------------
+ OJoinExchObj::OJoinExchObj(const OJoinExchangeData& jxdSource,sal_Bool _bFirstEntry)
+ :m_bFirstEntry(_bFirstEntry)
+ ,m_jxdSourceDescription(jxdSource)
+ ,m_pDragListener(NULL)
+ {
+ DBG_CTOR(OJoinExchObj,NULL);
+ // Verfuegbare Typen in Liste einfuegen
+ }
+
+ //------------------------------------------------------------------------
+ OJoinExchObj::~OJoinExchObj()
+ {
+ DBG_DTOR(OJoinExchObj,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void OJoinExchObj::StartDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, IDragTransferableListener* _pListener )
+ {
+ m_pDragListener = _pListener;
+ TransferableHelper::StartDrag(_pWindow, _nDragSourceActions);
+ }
+
+ //------------------------------------------------------------------------
+ void OJoinExchObj::DragFinished( sal_Int8 /*nDropAction*/ )
+ {
+ if (m_pDragListener)
+ m_pDragListener->dragFinished();
+ m_pDragListener = NULL;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotFormatStringId _nSlotID)
+ {
+ DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
+ for ( DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
+ aCheck != aCheckEnd;
+ ++aCheck
+ )
+ {
+ if ( _nSlotID == aCheck->mnSotId )
+ return sal_True;
+ }
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ OJoinExchangeData OJoinExchObj::GetSourceDescription(const Reference< XTransferable >& _rxObject)
+ {
+ OJoinExchangeData aReturn;
+ Reference< XUnoTunnel > xTunnel(_rxObject, UNO_QUERY);
+ if (xTunnel.is())
+ {
+ OJoinExchObj* pImplementation = reinterpret_cast<OJoinExchObj*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
+ if (pImplementation)
+ aReturn = pImplementation->m_jxdSourceDescription;
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< sal_Int8 > OJoinExchObj::getUnoTunnelImplementationId()
+ {
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int64 SAL_CALL OJoinExchObj::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
+ {
+ if (_rIdentifier.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
+ return reinterpret_cast<sal_Int64>(this);
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ void OJoinExchObj::AddSupportedFormats()
+ {
+ AddFormat( SOT_FORMATSTR_ID_SBA_JOIN );
+ if ( m_bFirstEntry )
+ AddFormat( SOT_FORMATSTR_ID_SBA_TABID );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OJoinExchObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+ {
+ sal_uInt32 nFormat = SotExchange::GetFormat(rFlavor);
+ if ( SOT_FORMATSTR_ID_SBA_JOIN == nFormat )
+ // this is a HACK
+ // we don't really copy our data, the instances using us have to call GetSourceDescription ....
+ // if, one day, we have a _lot_ of time, this hack should be removed ....
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL OJoinExchObj::queryInterface( const Type& _rType ) throw(RuntimeException)
+ {
+ Any aReturn = TransferableHelper::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = OJoinExchObj_Base::queryInterface(_rType);
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OJoinExchObj::acquire( ) throw()
+ {
+ TransferableHelper::acquire( );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OJoinExchObj::release( ) throw()
+ {
+ TransferableHelper::release( );
+ }
+
+
+} // namespace dbaui
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
new file mode 100644
index 000000000000..f2d906e5017a
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -0,0 +1,1717 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "JoinTableView.hxx"
+#include <osl/diagnose.h>
+#include "querycontroller.hxx"
+#include "JoinDesignView.hxx"
+#include "dbu_qry.hrc"
+#include "TableWindow.hxx"
+#include "TableWindowListBox.hxx"
+#include "TableConnection.hxx"
+#include "TableConnectionData.hxx"
+#include "ConnectionLine.hxx"
+#include "ConnectionLineData.hxx"
+#include "browserids.hxx"
+#include <svl/urlbmk.hxx>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "QueryMoveTabWinUndoAct.hxx"
+#include "QuerySizeTabWinUndoAct.hxx"
+#include <vcl/svapp.hxx>
+#include "TableWindowData.hxx"
+#include "JAccess.hxx"
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include "UITools.hxx"
+#include <cppuhelper/exc_hlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+#define LINE_SIZE 50
+////////////////////////////////////////////////////////////////
+// Konstanten fuer das Fensterlayout
+#define TABWIN_SPACING_X 17
+#define TABWIN_SPACING_Y 17
+
+#define TABWIN_WIDTH_STD 120
+#define TABWIN_HEIGHT_STD 120
+
+DBG_NAME(OScrollWindowHelper)
+OScrollWindowHelper::OScrollWindowHelper( Window* pParent) : Window( pParent)
+ ,m_aHScrollBar( this, WB_HSCROLL|WB_REPEAT|WB_DRAG )
+ ,m_aVScrollBar( this, WB_VSCROLL|WB_REPEAT|WB_DRAG )
+ ,m_pCornerWindow(new ScrollBarBox(this, WB_3DLOOK))
+ ,m_pTableView(NULL)
+{
+ DBG_CTOR(OScrollWindowHelper,NULL);
+
+ //////////////////////////////////////////////////////////////////////
+ // ScrollBars
+
+ GetHScrollBar()->SetRange( Range(0, 1000) );
+ GetVScrollBar()->SetRange( Range(0, 1000) );
+
+ GetHScrollBar()->SetLineSize( LINE_SIZE );
+ GetVScrollBar()->SetLineSize( LINE_SIZE );
+
+ GetHScrollBar()->Show();
+ GetVScrollBar()->Show();
+ m_pCornerWindow->Show();
+
+ // normally we should be SCROLL_PANE
+ SetAccessibleRole(AccessibleRole::SCROLL_PANE);
+}
+
+// -----------------------------------------------------------------------------
+OScrollWindowHelper::~OScrollWindowHelper()
+{
+ DBG_DTOR(OScrollWindowHelper,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pCornerWindow);
+ m_pCornerWindow = NULL;
+ m_pTableView = NULL;
+}
+
+// -----------------------------------------------------------------------------
+void OScrollWindowHelper::setTableView(OJoinTableView* _pTableView)
+{
+ m_pTableView = _pTableView;
+ //////////////////////////////////////////////////////////////////////
+ // ScrollBars
+ GetHScrollBar()->SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
+ GetVScrollBar()->SetScrollHdl( LINK(m_pTableView, OJoinTableView, ScrollHdl) );
+}
+// -----------------------------------------------------------------------------
+void OScrollWindowHelper::resetRange(const Point& _aSize)
+{
+ Point aPos = PixelToLogic(_aSize);
+ GetHScrollBar()->SetRange( Range(0, aPos.X() + TABWIN_SPACING_X) );
+ GetVScrollBar()->SetRange( Range(0, aPos.Y() + TABWIN_SPACING_Y) );
+}
+//------------------------------------------------------------------------------
+void OScrollWindowHelper::Resize()
+{
+ Window::Resize();
+
+ Size aTotalOutputSize = GetOutputSizePixel();
+ long nHScrollHeight = GetHScrollBar()->GetSizePixel().Height();
+ long nVScrollWidth = GetVScrollBar()->GetSizePixel().Width();
+
+ GetHScrollBar()->SetPosSizePixel(
+ Point( 0, aTotalOutputSize.Height()-nHScrollHeight ),
+ Size( aTotalOutputSize.Width()-nVScrollWidth, nHScrollHeight )
+ );
+
+ GetVScrollBar()->SetPosSizePixel(
+ Point( aTotalOutputSize.Width()-nVScrollWidth, 0 ),
+ Size( nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight )
+ );
+
+ m_pCornerWindow->SetPosSizePixel(
+ Point( aTotalOutputSize.Width() - nVScrollWidth, aTotalOutputSize.Height() - nHScrollHeight),
+ Size( nVScrollWidth, nHScrollHeight )
+ );
+
+ GetHScrollBar()->SetPageSize( aTotalOutputSize.Width() );
+ GetHScrollBar()->SetVisibleSize( aTotalOutputSize.Width() );
+
+ GetVScrollBar()->SetPageSize( aTotalOutputSize.Height() );
+ GetVScrollBar()->SetVisibleSize( aTotalOutputSize.Height() );
+
+ // adjust the ranges of the scrollbars if neccessary
+ long lRange = GetHScrollBar()->GetRange().Max() - GetHScrollBar()->GetRange().Min();
+ if (m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() > lRange)
+ GetHScrollBar()->SetRangeMax(m_pTableView->GetScrollOffset().X() + aTotalOutputSize.Width() + GetHScrollBar()->GetRange().Min());
+
+ lRange = GetVScrollBar()->GetRange().Max() - GetVScrollBar()->GetRange().Min();
+ if (m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() > lRange)
+ GetVScrollBar()->SetRangeMax(m_pTableView->GetScrollOffset().Y() + aTotalOutputSize.Height() + GetVScrollBar()->GetRange().Min());
+
+ m_pTableView->SetPosSizePixel(Point( 0, 0 ),Size( aTotalOutputSize.Width()-nVScrollWidth, aTotalOutputSize.Height()-nHScrollHeight ));
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+//==================================================================
+// class OJoinTableView
+//==================================================================
+
+DBG_NAME(OJoinTableView);
+//------------------------------------------------------------------------------
+OJoinTableView::OJoinTableView( Window* pParent, OJoinDesignView* pView )
+ :Window( pParent,WB_BORDER )
+ ,DropTargetHelper(this)
+ ,m_aDragOffset( Point(0,0) )
+ ,m_aScrollOffset( Point(0,0) )
+ ,m_pDragWin( NULL )
+ ,m_pSizingWin( NULL )
+ ,m_pSelectedConn( NULL )
+ ,m_bTrackingInitiallyMoved(sal_False)
+ ,m_pLastFocusTabWin(NULL)
+ ,m_pView( pView )
+ ,m_pAccessible(NULL)
+{
+ DBG_CTOR(OJoinTableView,NULL);
+ SetSizePixel( Size(1000, 1000) );
+
+ InitColors();
+
+ m_aDragScrollTimer.SetTimeoutHdl(LINK(this, OJoinTableView, OnDragScrollTimer));
+}
+
+//------------------------------------------------------------------------------
+OJoinTableView::~OJoinTableView()
+{
+ DBG_DTOR(OJoinTableView,NULL);
+ if( m_pAccessible )
+ {
+ m_pAccessible->clearTableView();
+ m_pAccessible = NULL;
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Listen loeschen
+ clearLayoutInformation();
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OJoinTableView, ScrollHdl, ScrollBar*, pScrollBar )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Alle Fenster verschieben
+ ScrollPane( pScrollBar->GetDelta(), (pScrollBar == GetHScrollBar()), sal_False );
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::Resize()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ Window::Resize();
+ m_aOutputSize = GetSizePixel();
+
+ // tab win positions may not be up-to-date
+ if (m_aTableMap.empty())
+ // no tab wins ...
+ return;
+
+ // we have at least one table so resize it
+ m_aScrollOffset.X() = GetHScrollBar()->GetThumbPos();
+ m_aScrollOffset.Y() = GetVScrollBar()->GetThumbPos();
+
+ OTableWindow* pCheck = m_aTableMap.begin()->second;
+ Point aRealPos = pCheck->GetPosPixel();
+ Point aAssumedPos = pCheck->GetData()->GetPosition() - GetScrollOffset();
+
+ if (aRealPos == aAssumedPos)
+ // all ok
+ return;
+
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableWindow* pCurrent = aIter->second;
+ Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset());
+ pCurrent->SetPosPixel(aPos);
+ }
+}
+//------------------------------------------------------------------------------
+sal_uLong OJoinTableView::GetTabWinCount()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ return m_aTableMap.size();
+}
+
+//------------------------------------------------------------------------------
+bool OJoinTableView::RemoveConnection( OTableConnection* _pConn,sal_Bool _bDelete )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ DeselectConn(_pConn);
+
+ // to force a redraw
+ _pConn->InvalidateConnection();
+
+ m_pView->getController().removeConnectionData( _pConn->GetData() );
+
+ m_vTableConnection.erase(
+ ::std::find(m_vTableConnection.begin(),m_vTableConnection.end(),_pConn) );
+
+ modified();
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ makeAny(_pConn->GetAccessible()),
+ Any());
+ if ( _bDelete )
+ {
+ delete _pConn;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+OTableWindow* OJoinTableView::GetTabWindow( const String& rName )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ OTableWindowMapIterator aIter = m_aTableMap.find(rName);
+
+ return aIter == m_aTableMap.end() ? NULL : aIter->second;
+}
+// -----------------------------------------------------------------------------
+TTableWindowData::value_type OJoinTableView::createTableWindowData(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName)
+{
+ TTableWindowData::value_type pData( CreateImpl(_rComposedName, _sTableName,_rWinName) );
+ OJoinDesignView* pParent = getDesignView();
+ try
+ {
+ if ( !pData->init(pParent->getController().getConnection(),allowQueries()) )
+ {
+ if ( pData->isValid() )
+ onNoColumns_throw();
+ else
+ pData.reset();
+ }
+ }
+ catch ( const SQLException& )
+ {
+ ::dbaui::showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ),
+ pParent, pParent->getController().getORB() );
+ }
+ catch( const WrappedTargetException& e )
+ {
+ SQLException aSql;
+ if ( e.TargetException >>= aSql )
+ ::dbaui::showError( ::dbtools::SQLExceptionInfo( aSql ), pParent, pParent->getController().getORB() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return pData;
+}
+// -----------------------------------------------------------------------------
+OTableWindowData* OJoinTableView::CreateImpl(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName)
+{
+ return new OTableWindowData( NULL,_rComposedName,_sTableName, _rWinName );
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, sal_Bool /*bNewTable*/)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ OSL_ENSURE(_rComposedName.getLength(),"There must be a table name supplied!");
+
+ TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
+
+ //////////////////////////////////////////////////////////////////
+ // Neues Fenster in Fensterliste eintragen
+ OTableWindow* pNewTabWin = createWindow( pNewTabWinData );
+ if ( pNewTabWin->Init() )
+ {
+ m_pView->getController().getTableWindowData()->push_back( pNewTabWinData);
+ // when we already have a table with this name insert the full qualified one instead
+ if(m_aTableMap.find(rWinName) != m_aTableMap.end())
+ m_aTableMap[_rComposedName] = pNewTabWin;
+ else
+ m_aTableMap[rWinName] = pNewTabWin;
+
+ SetDefaultTabWinPosSize( pNewTabWin );
+ pNewTabWin->Show();
+
+ modified();
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ Any(),
+ makeAny(pNewTabWin->GetAccessible()));
+ }
+ else
+ {
+ pNewTabWin->clearListBox();
+ delete pNewTabWin;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::RemoveTabWin( OTableWindow* pTabWin )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // first delete all connections of this window to others
+ bool bRemove = true;
+ TTableWindowData::value_type pData = pTabWin->GetData();
+ sal_Int32 nCount = m_vTableConnection.size();
+ ::std::vector<OTableConnection*>::reverse_iterator aIter = m_vTableConnection.rbegin();
+ while(aIter != m_vTableConnection.rend() && bRemove)
+ {
+ OTableConnection* pTabConn = (*aIter);
+ if(
+ ( pData == pTabConn->GetData()->getReferencingTable()) ||
+ ( pData == pTabConn->GetData()->getReferencedTable())
+ )
+ {
+ bRemove = RemoveConnection( pTabConn ,sal_True);
+ aIter = m_vTableConnection.rbegin();
+ }
+ else
+ ++aIter;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // then delete the window itself
+ if ( bRemove )
+ {
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ makeAny(pTabWin->GetAccessible()),Any()
+ );
+
+ pTabWin->Hide();
+ OJoinController& rController = m_pView->getController();
+ TTableWindowData::iterator aFind = ::std::find(rController.getTableWindowData()->begin(),rController.getTableWindowData()->end(),pData);
+ if(aFind != rController.getTableWindowData()->end())
+ {
+ rController.getTableWindowData()->erase(aFind);
+ rController.setModified(sal_True);
+ }
+
+ String aWinName = pTabWin->GetWinName();
+ if(m_aTableMap.find(aWinName) != m_aTableMap.end())
+ m_aTableMap.erase( aWinName );
+ else
+ m_aTableMap.erase( pTabWin->GetComposedName() );
+
+ if (pTabWin == m_pLastFocusTabWin)
+ m_pLastFocusTabWin = NULL;
+
+ pTabWin->clearListBox();
+ delete pTabWin;
+
+ }
+ if ( (sal_Int32)m_vTableConnection.size() < (nCount-1) ) // if some connections could be removed
+ modified();
+}
+namespace
+{
+ // -----------------------------------------------------------------------------
+ sal_Bool isScrollAllowed( OJoinTableView* _pView,long nDelta, sal_Bool bHoriz)
+ {
+ //////////////////////////////////////////////////////////////////////
+ // adjust ScrollBar-Positions
+ ScrollBar* pBar = _pView->GetVScrollBar();
+ if( bHoriz )
+ pBar = _pView->GetHScrollBar();
+
+ long nOldThumbPos = pBar->GetThumbPos();
+ long nNewThumbPos = nOldThumbPos + nDelta;
+ if( nNewThumbPos < 0 )
+ nNewThumbPos = 0;
+ else if( nNewThumbPos > pBar->GetRangeMax() )
+ nNewThumbPos = pBar->GetRangeMax();
+
+ if ( bHoriz )
+ {
+ if( nNewThumbPos == _pView->GetScrollOffset().X() )
+ return sal_False;
+ }
+ else if ( nNewThumbPos == _pView->GetScrollOffset().Y() )
+ return sal_False;
+
+ return sal_True;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool getMovementImpl(OJoinTableView* _pView,const Point& _rPoint,const Size& _rSize,long& _nScrollX,long& _nScrollY)
+ {
+ _nScrollY = _nScrollX = 0;
+ // data about the tab win
+ Point aUpperLeft = _rPoint;
+ // normalize with respect to visibility
+ aUpperLeft -= _pView->GetScrollOffset();
+ Point aLowerRight(aUpperLeft.X() + _rSize.Width(), aUpperLeft.Y() + _rSize.Height());
+
+ // data about ourself
+ Size aSize = _pView->getRealOutputSize(); //GetOutputSizePixel();
+
+ sal_Bool bVisbile = sal_True;
+ sal_Bool bFitsHor = (aUpperLeft.X() >= 0) && (aLowerRight.X() <= aSize.Width());
+ sal_Bool bFitsVert= (aUpperLeft.Y() >= 0) && (aLowerRight.Y() <= aSize.Height());
+ if (!bFitsHor || !bFitsVert)
+ {
+ if (!bFitsHor)
+ {
+ // ensure the visibility of the right border
+ if ( aLowerRight.X() > aSize.Width() )
+ _nScrollX = aLowerRight.X() - aSize.Width() + TABWIN_SPACING_X;
+
+ // ensure the visibility of the left border (higher priority)
+ if ( aUpperLeft.X() < 0 )
+ _nScrollX = aUpperLeft.X() - TABWIN_SPACING_X;
+ }
+
+ if (!bFitsVert)
+ {
+ // lower border
+ if ( aLowerRight.Y() > aSize.Height() )
+ _nScrollY = aLowerRight.Y() - aSize.Height() + TABWIN_SPACING_Y;
+ // upper border
+ if ( aUpperLeft.Y() < 0 )
+ _nScrollY = aUpperLeft.Y() - TABWIN_SPACING_Y;
+ }
+
+ if ( _nScrollX ) // aSize.Width() > _rSize.Width() &&
+ bVisbile = isScrollAllowed(_pView,_nScrollX, sal_True);
+
+ if ( _nScrollY ) // aSize.Height() > _rSize.Height() &&
+ bVisbile = bVisbile && isScrollAllowed(_pView,_nScrollY, sal_False);
+
+ if ( bVisbile )
+ {
+ sal_Int32 nHRangeMax = _pView->GetHScrollBar()->GetRangeMax();
+ sal_Int32 nVRangeMax = _pView->GetVScrollBar()->GetRangeMax();
+
+ if ( aSize.Width() + _pView->GetHScrollBar()->GetThumbPos() + _nScrollX > nHRangeMax )
+ bVisbile = sal_False;
+ if ( bVisbile && aSize.Height() + _pView->GetVScrollBar()->GetThumbPos() + _nScrollY > nVRangeMax )
+ bVisbile = sal_False;
+ }
+ }
+
+
+ return bVisbile;
+ }
+} // end of ano namespace
+// -----------------------------------------------------------------------------
+sal_Bool OJoinTableView::isMovementAllowed(const Point& _rPoint,const Size& _rSize)
+{
+ long nX,nY;
+ return getMovementImpl(this,_rPoint,_rSize,nX,nY);
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::EnsureVisible(const OTableWindow* _pWin)
+{
+ // data about the tab win
+ TTableWindowData::value_type pData = _pWin->GetData();
+ EnsureVisible( pData->GetPosition() , pData->GetSize());
+ Invalidate(INVALIDATE_NOCHILDREN);
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::EnsureVisible(const Point& _rPoint,const Size& _rSize)
+{
+ long nScrollX,nScrollY;
+
+ if ( getMovementImpl(this,_rPoint,_rSize,nScrollX,nScrollY) )
+ {
+ sal_Bool bVisbile = sal_True;
+ if (nScrollX)
+ bVisbile = ScrollPane(nScrollX, sal_True, sal_True);
+
+ if (nScrollY)
+ bVisbile = bVisbile && ScrollPane(nScrollY, sal_False, sal_True);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ //////////////////////////////////////////////////////////////////
+ // Position bestimmen:
+ // Das Fenster wird in Zeilen der Hoehe TABWIN_SPACING_Y+TABWIN_HEIGTH_STD aufgeteilt.
+ // Dann wird fuer jede Zeile geprueft, ob noch Platz fuer ein weiteres Fenster ist.
+ // Wenn kein Platz ist, wird die naechste Zeile ueberprueft.
+ Size aOutSize = GetSizePixel();
+ Point aNewPos( 0,0 );
+ sal_uInt16 nRow = 0;
+ sal_Bool bEnd = sal_False;
+ while( !bEnd )
+ {
+ //////////////////////////////////////////////////////////////////
+ // Neue Position auf Zeilenbeginn setzen
+ aNewPos.X() = TABWIN_SPACING_X;
+ aNewPos.Y() = (nRow+1) * TABWIN_SPACING_Y;
+
+ //////////////////////////////////////////////////////////////////
+ // Rectangle fuer die jeweilige Zeile bestimmen
+ Rectangle aRowRect( Point(0,0), aOutSize );
+ aRowRect.Top() = nRow * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
+ aRowRect.Bottom() = (nRow+1) * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD );
+
+ //////////////////////////////////////////////////////////////////
+ // Belegte Bereiche dieser Zeile pruefen
+ OTableWindow* pOtherTabWin;
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ pOtherTabWin = aIter->second;
+ Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
+
+ if(
+ ( (aOtherTabWinRect.Top()>aRowRect.Top()) && (aOtherTabWinRect.Top()<aRowRect.Bottom()) ) ||
+ ( (aOtherTabWinRect.Bottom()>aRowRect.Top()) && (aOtherTabWinRect.Bottom()<aRowRect.Bottom()) )
+ )
+ {
+ //////////////////////////////////////////////////////////////////
+ // TabWin liegt in der Zeile
+ if( aOtherTabWinRect.Right()>aNewPos.X() )
+ aNewPos.X() = aOtherTabWinRect.Right() + TABWIN_SPACING_X;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Ist in dieser Zeile noch Platz?
+ if( (aNewPos.X()+TABWIN_WIDTH_STD)<aRowRect.Right() )
+ {
+ aNewPos.Y() = aRowRect.Top() + TABWIN_SPACING_Y;
+ bEnd = sal_True;
+ }
+ else
+ {
+ if( (aRowRect.Bottom()+aRowRect.GetHeight()) > aOutSize.Height() )
+ {
+ // insert it in the first row
+ sal_Int32 nCount = m_aTableMap.size() % (nRow+1);
+ ++nCount;
+ aNewPos.Y() = nCount * TABWIN_SPACING_Y + (nCount-1)*CalcZoom(TABWIN_HEIGHT_STD);
+ bEnd = sal_True;
+ }
+ else
+ nRow++;
+
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Groesse bestimmen
+ Size aNewSize( CalcZoom(TABWIN_WIDTH_STD), CalcZoom(TABWIN_HEIGHT_STD) );
+
+ // check if the new position in inside the scrollbars ranges
+ Point aBottom(aNewPos);
+ aBottom.X() += aNewSize.Width();
+ aBottom.Y() += aNewSize.Height();
+
+ if(!GetHScrollBar()->GetRange().IsInside(aBottom.X()))
+ GetHScrollBar()->SetRange( Range(0, aBottom.X()) );
+ if(!GetVScrollBar()->GetRange().IsInside(aBottom.Y()))
+ GetVScrollBar()->SetRange( Range(0, aBottom.Y()) );
+
+ pTabWin->SetPosSizePixel( aNewPos, aNewSize );
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::DataChanged(const DataChangedEvent& rDCEvt)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
+ {
+ // nehmen wir den worst-case an : die Farben haben sich geaendert, also
+ // mich anpassen
+ InitColors();
+ Invalidate(INVALIDATE_NOCHILDREN);
+ // durch das Invalidate werden auch die Connections neu gezeichnet, so dass die auch
+ // gleich in den neuen Farben dargestellt werden
+ }
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::InitColors()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ // die Farben fuer die Darstellung sollten die Systemfarben sein
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ SetBackground(Wallpaper(Color(aSystemStyle.GetDialogColor())));
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::BeginChildMove( OTableWindow* pTabWin, const Point& rMousePos )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+
+ if (m_pView->getController().isReadOnly())
+ return;
+
+ m_pDragWin = pTabWin;
+ SetPointer(Pointer(POINTER_MOVE));
+ Point aMousePos = ScreenToOutputPixel( rMousePos );
+ m_aDragOffset = aMousePos - pTabWin->GetPosPixel();
+ m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+ m_bTrackingInitiallyMoved = sal_False;
+ StartTracking();
+}
+
+void OJoinTableView::NotifyTitleClicked( OTableWindow* pTabWin, const Point rMousePos )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ DeselectConn(GetSelectedConn());
+ BeginChildMove(pTabWin, rMousePos);
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::BeginChildSizing( OTableWindow* pTabWin, const Pointer& rPointer )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+
+ if (m_pView->getController().isReadOnly())
+ return;
+
+ SetPointer( rPointer );
+ m_pSizingWin = pTabWin;
+ StartTracking();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OJoinTableView::ScrollPane( long nDelta, sal_Bool bHoriz, sal_Bool bPaintScrollBars )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ sal_Bool bRet = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // ScrollBar-Positionen anpassen
+ if( bPaintScrollBars )
+ {
+ if( bHoriz )
+ {
+ long nOldThumbPos = GetHScrollBar()->GetThumbPos();
+ long nNewThumbPos = nOldThumbPos + nDelta;
+ if( nNewThumbPos < 0 )
+ {
+ nNewThumbPos = 0;
+ bRet = sal_False;
+ }
+ if( nNewThumbPos > GetHScrollBar()->GetRange().Max() )
+ {
+ nNewThumbPos = GetHScrollBar()->GetRange().Max();
+ bRet = sal_False;
+ }
+ GetHScrollBar()->SetThumbPos( nNewThumbPos );
+ nDelta = GetHScrollBar()->GetThumbPos() - nOldThumbPos;
+ }
+ else
+ {
+ long nOldThumbPos = GetVScrollBar()->GetThumbPos();
+ long nNewThumbPos = nOldThumbPos+nDelta;
+ if( nNewThumbPos < 0 )
+ {
+ nNewThumbPos = 0;
+ bRet = sal_False;
+ }
+ if( nNewThumbPos > GetVScrollBar()->GetRange().Max() )
+ {
+ nNewThumbPos = GetVScrollBar()->GetRange().Max();
+ bRet = sal_False;
+ }
+ GetVScrollBar()->SetThumbPos( nNewThumbPos );
+ nDelta = GetVScrollBar()->GetThumbPos() - nOldThumbPos;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn ScrollOffset bereits an den Grenzen liegt, kein Neuzeichnen
+ if( (GetHScrollBar()->GetThumbPos()==m_aScrollOffset.X()) &&
+ (GetVScrollBar()->GetThumbPos()==m_aScrollOffset.Y()) )
+ return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // ScrollOffset neu setzen
+ if (bHoriz)
+ m_aScrollOffset.X() = GetHScrollBar()->GetThumbPos();
+ else
+ m_aScrollOffset.Y() = GetVScrollBar()->GetThumbPos();
+
+ //////////////////////////////////////////////////////////////////////
+ // Alle Fenster verschieben
+ OTableWindow* pTabWin;
+ Point aPos;
+
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ pTabWin = aIter->second;
+ aPos = pTabWin->GetPosPixel();
+
+ if( bHoriz )
+ aPos.X() -= nDelta;
+ else aPos.Y() -= nDelta;
+
+ pTabWin->SetPosPixel( aPos );
+ }
+
+ Invalidate(); // INVALIDATE_NOCHILDREN
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::Tracking( const TrackingEvent& rTEvt )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ HideTracking();
+
+ if (rTEvt.IsTrackingEnded())
+ {
+ if( m_pDragWin )
+ {
+ if (m_aDragScrollTimer.IsActive())
+ m_aDragScrollTimer.Stop();
+
+ //////////////////////////////////////////////////////////////////////
+ // Position des Childs nach Verschieben anpassen
+ //////////////////////////////////////////////////////////////////////
+ // Fenster duerfen nicht aus Anzeigebereich herausbewegt werden
+ Point aDragWinPos = rTEvt.GetMouseEvent().GetPosPixel() - m_aDragOffset;
+ Size aDragWinSize = m_pDragWin->GetSizePixel();
+ if( aDragWinPos.X() < 0 )
+ aDragWinPos.X() = 0;
+ if( aDragWinPos.Y() < 0 )
+ aDragWinPos.Y() = 0;
+ if( (aDragWinPos.X() + aDragWinSize.Width()) > m_aOutputSize.Width() )
+ aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width() - 1;
+ if( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() )
+ aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height() - 1;
+ if( aDragWinPos.X() < 0 )
+ aDragWinPos.X() = 0;
+ if( aDragWinPos.Y() < 0 )
+ aDragWinPos.Y() = 0;
+ // TODO : nicht das Fenster neu positionieren, wenn es uebersteht, sondern einfach meinen Bereich erweitern
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Fenster positionieren
+ EndTracking();
+ m_pDragWin->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+ // erst mal testen, ob ich mich ueberhaupt bewegt habe
+ // (das verhindert das Setzen des modified-Flags, wenn sich eigentlich gar nichts getan hat)
+ TTableWindowData::value_type pData = m_pDragWin->GetData();
+ if ( ! (pData && pData->HasPosition() && (pData->GetPosition() == aDragWinPos)))
+ {
+ // die alten logischen Koordinaten
+ Point ptOldPos = m_pDragWin->GetPosPixel() + Point(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos());
+ // neu positionieren
+ m_pDragWin->SetPosPixel(aDragWinPos);
+ TabWinMoved(m_pDragWin, ptOldPos);
+
+ m_pDragWin->GrabFocus();
+ }
+ m_pDragWin = NULL;
+ SetPointer(Pointer(POINTER_ARROW));
+ }
+ // else we handle the resizing
+ else if( m_pSizingWin )
+ {
+ SetPointer( Pointer() );
+ EndTracking();
+
+ // die alten physikalischen Koordinaten
+
+ Size szOld = m_pSizingWin->GetSizePixel();
+ Point ptOld = m_pSizingWin->GetPosPixel();
+ Size aNewSize(CalcZoom(m_aSizingRect.GetSize().Width()),CalcZoom(m_aSizingRect.GetSize().Height()));
+ m_pSizingWin->SetPosSizePixel( m_aSizingRect.TopLeft(), aNewSize );
+ TabWinSized(m_pSizingWin, ptOld, szOld);
+
+ m_pSizingWin->Invalidate( m_aSizingRect );
+ m_pSizingWin = NULL;
+ }
+ }
+ else if (rTEvt.IsTrackingCanceled())
+ {
+ if (m_aDragScrollTimer.IsActive())
+ m_aDragScrollTimer.Stop();
+ EndTracking();
+ }
+ else
+ {
+ if( m_pDragWin )
+ {
+ m_ptPrevDraggingPos = rTEvt.GetMouseEvent().GetPosPixel();
+ // an Fenstergrenzen scrollen
+ ScrollWhileDragging();
+ }
+
+ if( m_pSizingWin )
+ {
+ Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
+ m_aSizingRect = m_pSizingWin->getSizingRect(aMousePos,m_aOutputSize);
+ Update();
+ ShowTracking( m_aSizingRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::ConnDoubleClicked( OTableConnection* /*pConnection*/ )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::MouseButtonDown( const MouseEvent& rEvt )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ GrabFocus();
+ Window::MouseButtonDown(rEvt);
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ Window::MouseButtonUp(rEvt);
+ //////////////////////////////////////////////////////////////////////
+ // Wurde eine Connection ausgewaehlt?
+ if( !m_vTableConnection.empty() )
+ {
+ DeselectConn(GetSelectedConn());
+
+ ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if( (*aIter)->CheckHit(rEvt.GetPosPixel()) )
+ {
+ SelectConn((*aIter));
+
+ // Doppelclick
+ if( rEvt.GetClicks() == 2 )
+ ConnDoubleClicked( (*aIter) );
+
+ break;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::KeyInput( const KeyEvent& rEvt )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
+ sal_Bool bShift = rEvt.GetKeyCode().IsShift();
+ sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1();
+
+ if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
+ {
+ if (GetSelectedConn())
+ RemoveConnection( GetSelectedConn() ,sal_True);
+ }
+ else
+ Window::KeyInput( rEvt );
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::DeselectConn(OTableConnection* pConn)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ if (!pConn || !pConn->IsSelected())
+ return;
+
+ // die zugehoerigen Eitnraege in der ListBox des Tabellenfenster deselektieren
+ OTableWindow* pWin = pConn->GetSourceWin();
+ if (pWin && pWin->GetListBox())
+ pWin->GetListBox()->SelectAll(sal_False);
+
+ pWin = pConn->GetDestWin();
+ if (pWin && pWin->GetListBox())
+ pWin->GetListBox()->SelectAll(sal_False);
+
+ pConn->Deselect();
+ m_pSelectedConn = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::SelectConn(OTableConnection* pConn)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ DeselectConn(GetSelectedConn());
+
+ pConn->Select();
+ m_pSelectedConn = pConn;
+ GrabFocus(); // has to be called here because a table window may still be focused
+
+ // die betroffenene Eintraege in den Windows selektieren
+ OTableWindow* pConnSource = pConn->GetSourceWin();
+ OTableWindow* pConnDest = pConn->GetDestWin();
+ if (pConnSource && pConnDest)
+ {
+ OTableWindowListBox* pSourceBox = pConnSource->GetListBox();
+ OTableWindowListBox* pDestBox = pConnDest->GetListBox();
+ if (pSourceBox && pDestBox)
+ {
+ pSourceBox->SelectAll(sal_False);
+ pDestBox->SelectAll(sal_False);
+
+ SvLBoxEntry* pFirstSourceVisible = pSourceBox->GetFirstEntryInView();
+ SvLBoxEntry* pFirstDestVisible = pDestBox->GetFirstEntryInView();
+
+ const ::std::vector<OConnectionLine*>* pLines = pConn->GetConnLineList();
+ ::std::vector<OConnectionLine*>::const_reverse_iterator aIter = pLines->rbegin();
+ for(;aIter != pLines->rend();++aIter)
+ {
+ if ((*aIter)->IsValid())
+ {
+ SvLBoxEntry* pSourceEntry = pSourceBox->GetEntryFromText((*aIter)->GetData()->GetSourceFieldName());
+ if (pSourceEntry)
+ {
+ pSourceBox->Select(pSourceEntry, sal_True);
+ pSourceBox->MakeVisible(pSourceEntry);
+ }
+
+ SvLBoxEntry* pDestEntry = pDestBox->GetEntryFromText((*aIter)->GetData()->GetDestFieldName());
+ if (pDestEntry)
+ {
+ pDestBox->Select(pDestEntry, sal_True);
+ pDestBox->MakeVisible(pDestEntry);
+ }
+
+ }
+ }
+
+ if ((pFirstSourceVisible != pSourceBox->GetFirstEntryInView())
+ || (pFirstDestVisible != pDestBox->GetFirstEntryInView()))
+ // es wurde gescrollt -> neu zeichnen
+ Invalidate(INVALIDATE_NOCHILDREN);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::Paint( const Rectangle& rRect )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ DrawConnections( rRect );
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::InvalidateConnections()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Die Joins zeichnen
+ ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),
+ ::std::mem_fun(& OTableConnection::InvalidateConnection));
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::DrawConnections( const Rectangle& rRect )
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Die Joins zeichnen
+ ::std::for_each(m_vTableConnection.begin(),m_vTableConnection.end(),boost::bind( &OTableConnection::Draw, _1, boost::cref( rRect )));
+ // zum Schluss noch mal die selektierte ueber alle anderen drueber
+ if (GetSelectedConn())
+ GetSelectedConn()->Draw( rRect );
+}
+
+
+//------------------------------------------------------------------------------
+::std::vector<OTableConnection*>::const_iterator OJoinTableView::getTableConnections(const OTableWindow* _pFromWin) const
+{
+ return ::std::find_if( m_vTableConnection.begin(),
+ m_vTableConnection.end(),
+ ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OJoinTableView::getConnectionCount(const OTableWindow* _pFromWin) const
+{
+ return ::std::count_if( m_vTableConnection.begin(),
+ m_vTableConnection.end(),
+ ::std::bind2nd(::std::mem_fun(&OTableConnection::isTableConnection),_pFromWin));
+}
+//------------------------------------------------------------------------------
+sal_Bool OJoinTableView::ExistsAConn(const OTableWindow* pFrom) const
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ return getTableConnections(pFrom) != m_vTableConnection.end();
+}
+//------------------------------------------------------------------------
+void OJoinTableView::ClearAll()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ SetUpdateMode(sal_False);
+
+ HideTabWins();
+
+ // und das selbe mit den Connections
+ ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
+ for(;aIter != aEnd;++aIter)
+ RemoveConnection( *aIter ,sal_True);
+ m_vTableConnection.clear();
+
+ m_pLastFocusTabWin = NULL;
+ m_pSelectedConn = NULL;
+
+ // scroll to the upper left
+ ScrollPane(-GetScrollOffset().X(), sal_True, sal_True);
+ ScrollPane(-GetScrollOffset().Y(), sal_False, sal_True);
+ Invalidate();
+}
+
+//------------------------------------------------------------------------
+sal_Bool OJoinTableView::ScrollWhileDragging()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ OSL_ENSURE(m_pDragWin != NULL, "OJoinTableView::ScrollWhileDragging darf nur waehrend Dragging eines Fensters aufgerufen werden !");
+
+ // den Timer schon mal killen
+ if (m_aDragScrollTimer.IsActive())
+ m_aDragScrollTimer.Stop();
+
+ Point aDragWinPos = m_ptPrevDraggingPos - m_aDragOffset;
+ Size aDragWinSize = m_pDragWin->GetSizePixel();
+ Point aLowerRight(aDragWinPos.X() + aDragWinSize.Width(), aDragWinPos.Y() + aDragWinSize.Height());
+
+ if (!m_bTrackingInitiallyMoved && (aDragWinPos == m_pDragWin->GetPosPixel()))
+ return sal_True;
+
+ // Darstellungsfehler vermeiden (wenn bei aktivem TrackingRect gescrollt wird)
+ HideTracking();
+
+ sal_Bool bScrolling = sal_False;
+ sal_Bool bNeedScrollTimer = sal_False;
+
+ // An Fenstergrenzen scrollen
+ // TODO : nur dann abfangen, wenn das Fenster komplett verschwinden wuerde (nicht, solange noch ein Pixel sichtbar ist)
+ if( aDragWinPos.X() < 5 )
+ {
+ bScrolling = ScrollPane( -LINE_SIZE, sal_True, sal_True );
+ if( !bScrolling && (aDragWinPos.X()<0) )
+ aDragWinPos.X() = 0;
+
+ // brauche ich weiteres (timergesteuertes) Scrolling ?
+ bNeedScrollTimer = bScrolling && (aDragWinPos.X() < 5);
+ }
+
+ if( aLowerRight.X() > m_aOutputSize.Width() - 5 )
+ {
+ bScrolling = ScrollPane( LINE_SIZE, sal_True, sal_True ) ;
+ if( !bScrolling && ( aLowerRight.X() > m_aOutputSize.Width() ) )
+ aDragWinPos.X() = m_aOutputSize.Width() - aDragWinSize.Width();
+
+ // brauche ich weiteres (timergesteuertes) Scrolling ?
+ bNeedScrollTimer = bScrolling && (aLowerRight.X() > m_aOutputSize.Width() - 5);
+ }
+
+ if( aDragWinPos.Y() < 5 )
+ {
+ bScrolling = ScrollPane( -LINE_SIZE, sal_False, sal_True );
+ if( !bScrolling && (aDragWinPos.Y()<0) )
+ aDragWinPos.Y() = 0;
+
+ bNeedScrollTimer = bScrolling && (aDragWinPos.Y() < 5);
+ }
+
+ if( aLowerRight.Y() > m_aOutputSize.Height() - 5 )
+ {
+ bScrolling = ScrollPane( LINE_SIZE, sal_False, sal_True );
+ if( !bScrolling && ( (aDragWinPos.Y() + aDragWinSize.Height()) > m_aOutputSize.Height() ) )
+ aDragWinPos.Y() = m_aOutputSize.Height() - aDragWinSize.Height();
+
+ bNeedScrollTimer = bScrolling && (aLowerRight.Y() > m_aOutputSize.Height() - 5);
+ }
+
+ // Timer neu setzen, wenn noch notwendig
+ if (bNeedScrollTimer)
+ {
+ m_aDragScrollTimer.SetTimeout(100);
+ m_aDragScrollTimer.Start();
+ }
+
+ // das DraggingRect neu zeichnen
+ m_aDragRect = Rectangle(m_ptPrevDraggingPos - m_aDragOffset, m_pDragWin->GetSizePixel());
+ Update();
+ ShowTracking( m_aDragRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+
+ return bScrolling;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK(OJoinTableView, OnDragScrollTimer, void*, EMPTYARG)
+{
+ ScrollWhileDragging();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::invalidateAndModify(SfxUndoAction *_pAction)
+{
+ Invalidate(INVALIDATE_NOCHILDREN);
+ m_pView->getController().addUndoActionAndInvalidate(_pAction);
+}
+//------------------------------------------------------------------------
+void OJoinTableView::TabWinMoved(OTableWindow* ptWhich, const Point& ptOldPosition)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ Point ptThumbPos(GetHScrollBar()->GetThumbPos(), GetVScrollBar()->GetThumbPos());
+ ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel() + ptThumbPos);
+
+ invalidateAndModify(new OJoinMoveTabWinUndoAct(this, ptOldPosition, ptWhich));
+}
+
+//------------------------------------------------------------------------
+void OJoinTableView::TabWinSized(OTableWindow* ptWhich, const Point& ptOldPosition, const Size& szOldSize)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ ptWhich->GetData()->SetSize(ptWhich->GetSizePixel());
+ ptWhich->GetData()->SetPosition(ptWhich->GetPosPixel());
+
+ invalidateAndModify(new OJoinSizeTabWinUndoAct(this, ptOldPosition, szOldSize, ptWhich));
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OJoinTableView::IsAddAllowed()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+
+ // nicht wenn Db readonly
+ if (m_pView->getController().isReadOnly())
+ return sal_False;
+
+ try
+ {
+ Reference< XConnection> xConnection = m_pView->getController().getConnection();
+ if(!xConnection.is())
+ return sal_False;
+ // nicht wenn schon zuviele Tabellen
+ Reference < XDatabaseMetaData > xMetaData( xConnection->getMetaData() );
+
+ sal_Int32 nMax = xMetaData.is() ? xMetaData->getMaxTablesInSelect() : 0;
+ if (nMax && nMax <= (sal_Int32)m_aTableMap.size())
+ return sal_False;
+ }
+ catch(SQLException&)
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::executePopup(const Point& _aPos,OTableConnection* _pSelConnection)
+{
+ PopupMenu aContextMenu( ModuleRes( RID_MENU_JOINVIEW_CONNECTION ) );
+ switch (aContextMenu.Execute(this, _aPos))
+ {
+ case SID_DELETE:
+ RemoveConnection( _pSelConnection ,sal_True);
+ break;
+ case ID_QUERY_EDIT_JOINCONNECTION:
+ ConnDoubleClicked( _pSelConnection ); // is the same as double clicked
+ break;
+ }
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::Command(const CommandEvent& rEvt)
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+
+ sal_Bool bHandled = sal_False;
+
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if( m_vTableConnection.empty() )
+ return;
+
+ OTableConnection* pSelConnection = GetSelectedConn();
+ // when it wasn't a mouse event use the selected connection
+ if (!rEvt.IsMouseEvent())
+ {
+ if( pSelConnection )
+ {
+ const ::std::vector<OConnectionLine*>* pLines = pSelConnection->GetConnLineList();
+ ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(pLines->begin(),pLines->end(),::std::mem_fun(&OConnectionLine::IsValid));
+ if( aIter != pLines->end() )
+ executePopup((*aIter)->getMidPoint(),pSelConnection);
+ }
+ }
+ else
+ {
+ DeselectConn(pSelConnection);
+
+ const Point& aMousePos = rEvt.GetMousePosPixel();
+ ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if( (*aIter)->CheckHit(aMousePos) )
+ {
+ SelectConn(*aIter);
+ if(!getDesignView()->getController().isReadOnly() && getDesignView()->getController().isConnected())
+ executePopup(rEvt.GetMousePosPixel(),*aIter);
+ break;
+ }
+ }
+ }
+ bHandled = sal_True;
+ }
+ }
+ if (!bHandled)
+ Window::Command(rEvt);
+}
+
+//------------------------------------------------------------------------------
+OTableConnection* OJoinTableView::GetTabConn(const OTableWindow* pLhs,const OTableWindow* pRhs,bool _bSupressCrossOrNaturalJoin,const OTableConnection* _rpFirstAfter) const
+{
+ OTableConnection* pConn = NULL;
+ OSL_ENSURE(pRhs || pLhs, "OJoinTableView::GetTabConn : invalid args !");
+ // only one NULL-arg allowed
+
+ if ((!pLhs || pLhs->ExistsAConn()) && (!pRhs || pRhs->ExistsAConn()))
+ {
+ sal_Bool bFoundStart = _rpFirstAfter ? sal_False : sal_True;
+
+ ::std::vector<OTableConnection*>::const_iterator aIter = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = m_vTableConnection.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableConnection* pData = *aIter;
+
+ if ( ( (pData->GetSourceWin() == pLhs)
+ && ( (pData->GetDestWin() == pRhs)
+ || (NULL == pRhs)
+ )
+ )
+ || ( (pData->GetSourceWin() == pRhs)
+ && ( (pData->GetDestWin() == pLhs)
+ || (NULL == pLhs)
+ )
+ )
+ )
+ {
+ if ( _bSupressCrossOrNaturalJoin )
+ {
+ if ( supressCrossNaturalJoin(pData->GetData()) )
+ continue;
+ }
+ if (bFoundStart)
+ {
+ pConn = pData;
+ break;
+ }
+
+ if (!pConn)
+ // used as fallback : if there is no conn after _rpFirstAfter the first conn between the two tables
+ // will be used
+ pConn = pData;
+
+ if (pData == _rpFirstAfter)
+ bFoundStart = sal_True;
+ }
+ }
+ }
+ return pConn;
+}
+
+//------------------------------------------------------------------------------
+long OJoinTableView::PreNotify(NotifyEvent& rNEvt)
+{
+ sal_Bool bHandled = sal_False;
+ switch (rNEvt.GetType())
+ {
+ case EVENT_COMMAND:
+ {
+ const CommandEvent* pCommand = rNEvt.GetCommandEvent();
+ if (pCommand->GetCommand() == COMMAND_WHEEL)
+ {
+ const CommandWheelData* pData = rNEvt.GetCommandEvent()->GetWheelData();
+ if (pData->GetMode() == COMMAND_WHEEL_SCROLL)
+ {
+ if (pData->GetDelta() > 0)
+ ScrollPane(-10 * pData->GetScrollLines(), pData->IsHorz(), sal_True);
+ else
+ ScrollPane(10 * pData->GetScrollLines(), pData->IsHorz(), sal_True);
+ bHandled = sal_True;
+ }
+ }
+ }
+ break;
+ case EVENT_KEYINPUT:
+ {
+ if (m_aTableMap.empty())
+ // no tab wins -> no conns -> no traveling
+ break;
+
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ if (!pKeyEvent->GetKeyCode().IsMod1())
+ {
+ switch (pKeyEvent->GetKeyCode().GetCode())
+ {
+ case KEY_TAB:
+ {
+ if (!HasChildPathFocus())
+ break;
+
+ sal_Bool bForward = !pKeyEvent->GetKeyCode().IsShift();
+ // is there an active tab win ?
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ if (aIter->second && aIter->second->HasChildPathFocus())
+ break;
+
+ OTableWindow* pNextWin = NULL;
+ OTableConnection* pNextConn = NULL;
+
+ if (aIter != m_aTableMap.end())
+ { // there is a currently active tab win
+ // check if there is an "overflow" and we should select a conn instead of a win
+ if (!m_vTableConnection.empty())
+ {
+ if ((aIter->second == m_aTableMap.rbegin()->second) && bForward)
+ // the last win is active and we're travelling forward -> select the first conn
+ pNextConn = *m_vTableConnection.begin();
+ if ((aIter == m_aTableMap.begin()) && !bForward)
+ // the first win is active an we're traveling backward -> select the last conn
+ pNextConn = *m_vTableConnection.rbegin();
+ }
+
+ if (!pNextConn)
+ {
+ // no conn for any reason -> select the next or previous tab win
+ if(bForward)
+ {
+ if ((aIter->second == m_aTableMap.rbegin()->second))
+ pNextWin = m_aTableMap.begin()->second;
+ else
+ {
+ ++aIter;
+ pNextWin = aIter->second;
+ }
+ }
+ else
+ {
+ if (aIter == m_aTableMap.begin())
+ pNextWin = m_aTableMap.rbegin()->second;
+ else
+ {
+ --aIter;
+ pNextWin = aIter->second;
+ }
+ }
+ }
+ }
+ else
+ { // no active tab win -> travel the connections
+ // find the currently selected conn within the conn list
+ sal_Int32 i(0);
+ for ( ::std::vector<OTableConnection*>::iterator connectionIter = m_vTableConnection.begin();
+ connectionIter != m_vTableConnection.end();
+ ++connectionIter, ++i
+ )
+ {
+ if ( (*connectionIter) == GetSelectedConn() )
+ break;
+ }
+ if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward)
+ // the last conn is active and we're travelling forward -> select the first win
+ pNextWin = m_aTableMap.begin()->second;
+ if ((i == 0) && !bForward && !m_aTableMap.empty())
+ // the first conn is active and we're travelling backward -> select the last win
+ pNextWin = m_aTableMap.rbegin()->second;
+
+ if (pNextWin)
+ DeselectConn(GetSelectedConn());
+ else
+ // no win for any reason -> select the next or previous conn
+ if (i < (sal_Int32)m_vTableConnection.size())
+ // there is a currently active conn
+ pNextConn = m_vTableConnection[(i + (bForward ? 1 : m_vTableConnection.size() - 1)) % m_vTableConnection.size()];
+ else
+ { // no tab win selected, no conn selected
+ if (!m_vTableConnection.empty())
+ pNextConn = m_vTableConnection[bForward ? 0 : m_vTableConnection.size() - 1];
+ else if (!m_aTableMap.empty())
+ {
+ if(bForward)
+ pNextWin = m_aTableMap.begin()->second;
+ else
+ pNextWin = m_aTableMap.rbegin()->second;
+ }
+ }
+ }
+
+ // now select the object
+ if (pNextWin)
+ {
+ if (pNextWin->GetListBox())
+ pNextWin->GetListBox()->GrabFocus();
+ else
+ pNextWin->GrabFocus();
+ EnsureVisible(pNextWin);
+ }
+ else if (pNextConn)
+ {
+ GrabFocus();
+ // neccessary : a conn may be selected even if a tab win has the focus, in this case
+ // the next travel would select the same conn again if we would not reset te focus ...
+ SelectConn(pNextConn);
+ }
+ }
+ break;
+ case KEY_RETURN:
+ {
+ if (!pKeyEvent->GetKeyCode().IsShift() && GetSelectedConn() && HasFocus())
+ ConnDoubleClicked(GetSelectedConn());
+ break;
+ }
+ }
+ }
+ }
+ break;
+ case EVENT_GETFOCUS:
+ {
+ if (m_aTableMap.empty())
+ // no tab wins -> no conns -> no focus change
+ break;
+ Window* pSource = rNEvt.GetWindow();
+ if (pSource)
+ {
+ Window* pSearchFor = NULL;
+ if (pSource->GetParent() == this)
+ // it may be one of the tab wins
+ pSearchFor = pSource;
+ else if (pSource->GetParent() && (pSource->GetParent()->GetParent() == this))
+ // it may be one of th list boxes of one of the tab wins
+ pSearchFor = pSource->GetParent();
+
+ if (pSearchFor)
+ {
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if (aIter->second == pSearchFor)
+ {
+ m_pLastFocusTabWin = aIter->second;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ if (!bHandled)
+ return Window::PreNotify(rNEvt);
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+void OJoinTableView::GrabTabWinFocus()
+{
+ if (m_pLastFocusTabWin && m_pLastFocusTabWin->IsVisible())
+ {
+ if (m_pLastFocusTabWin->GetListBox())
+ m_pLastFocusTabWin->GetListBox()->GrabFocus();
+ else
+ m_pLastFocusTabWin->GrabFocus();
+ }
+ else if (!m_aTableMap.empty() && m_aTableMap.begin()->second && m_aTableMap.begin()->second->IsVisible())
+ {
+ OTableWindow* pFirstWin = m_aTableMap.begin()->second;
+ if (pFirstWin->GetListBox())
+ pFirstWin->GetListBox()->GrabFocus();
+ else
+ pFirstWin->GrabFocus();
+ }
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::StateChanged( StateChangedType nType )
+{
+ Window::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_ZOOM )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ Font aFont = rStyleSettings.GetGroupFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetZoomedPointFont( aFont );
+
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ aIter->second->SetZoom(GetZoom());
+ Size aSize(CalcZoom(aIter->second->GetSizePixel().Width()),CalcZoom(aIter->second->GetSizePixel().Height()));
+ aIter->second->SetSizePixel(aSize);
+ }
+ Resize();
+ }
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::HideTabWins()
+{
+ DBG_CHKTHIS(OJoinTableView,NULL);
+ SetUpdateMode(sal_False);
+
+ OTableWindowMap* pTabWins = GetTabWinMap();
+ if ( pTabWins )
+ {
+ // working on a copy because the real list will be cleared in inner calls
+ OTableWindowMap aCopy(*pTabWins);
+ OTableWindowMap::iterator aIter = aCopy.begin();
+ OTableWindowMap::iterator aEnd = aCopy.end();
+ for(;aIter != aEnd;++aIter)
+ RemoveTabWin(aIter->second);
+ }
+
+ m_pView->getController().setModified(sal_True);
+
+ SetUpdateMode(sal_True);
+
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OJoinTableView::AcceptDrop( const AcceptDropEvent& /*_rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OJoinTableView::ExecuteDrop( const ExecuteDropEvent& /*_rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::dragFinished( )
+{
+}
+//------------------------------------------------------------------------------
+void OJoinTableView::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
+{
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::clearLayoutInformation()
+{
+ m_pLastFocusTabWin = NULL;
+ m_pSelectedConn = NULL;
+ //////////////////////////////////////////////////////////////////////
+ // Listen loeschen
+ OTableWindowMapIterator aIter = m_aTableMap.begin();
+ OTableWindowMapIterator aEnd = m_aTableMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( aIter->second )
+ aIter->second->clearListBox();
+ ::std::auto_ptr<Window> aTemp(aIter->second);
+ aIter->second = NULL;
+ }
+
+ m_aTableMap.clear();
+
+ ::std::vector<OTableConnection*>::const_iterator aIter2 = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd2 = m_vTableConnection.end();
+ for(;aIter2 != aEnd2;++aIter2)
+ delete *aIter2;
+
+ m_vTableConnection.clear();
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::lookForUiActivities()
+{
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::LoseFocus()
+{
+ DeselectConn(GetSelectedConn());
+ Window::LoseFocus();
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::GetFocus()
+{
+ Window::GetFocus();
+ if ( !m_aTableMap.empty() && !GetSelectedConn() )
+ GrabTabWinFocus();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > OJoinTableView::CreateAccessible()
+{
+ m_pAccessible = new OJoinDesignViewAccess(this);
+ return m_pAccessible;
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::modified()
+{
+ OJoinController& rController = m_pView->getController();
+ rController.setModified( sal_True );
+ rController.InvalidateFeature(ID_BROWSER_ADDTABLE);
+ rController.InvalidateFeature(SID_RELATION_ADD_RELATION);
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::addConnection(OTableConnection* _pConnection,sal_Bool _bAddData)
+{
+ if ( _bAddData )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
+ OSL_ENSURE( ::std::find(pTabConnDataList->begin(),pTabConnDataList->end(),_pConnection->GetData()) == pTabConnDataList->end(),"Data already in vector!");
+#endif
+ m_pView->getController().getTableConnectionData()->push_back(_pConnection->GetData());
+ }
+ m_vTableConnection.push_back(_pConnection);
+ _pConnection->RecalcLines();
+ _pConnection->InvalidateConnection();
+
+ modified();
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ Any(),
+ makeAny(_pConnection->GetAccessible()));
+}
+// -----------------------------------------------------------------------------
+bool OJoinTableView::allowQueries() const
+{
+ return true;
+}
+// -----------------------------------------------------------------------------
+void OJoinTableView::onNoColumns_throw()
+{
+ OSL_FAIL( "OTableWindow::onNoColumns_throw: cannot really handle this!" );
+ throw SQLException();
+}
+//------------------------------------------------------------------------------
+bool OJoinTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& ) const
+{
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableConnection.cxx b/dbaccess/source/ui/querydesign/QTableConnection.cxx
new file mode 100644
index 000000000000..8e18232e02ff
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnection.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QTableConnection.hxx"
+#include <osl/diagnose.h>
+#include "QueryTableView.hxx"
+#include "ConnectionLine.hxx"
+using namespace dbaui;
+//========================================================================
+// class OQueryTableConnection
+//========================================================================
+DBG_NAME(OQueryTableConnection)
+
+//------------------------------------------------------------------------
+OQueryTableConnection::OQueryTableConnection(OQueryTableView* pContainer, const TTableConnectionData::value_type& pTabConnData)
+ :OTableConnection(pContainer, pTabConnData)
+ ,m_bVisited(sal_False)
+{
+ DBG_CTOR(OQueryTableConnection,NULL);
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnection::OQueryTableConnection(const OQueryTableConnection& rConn)
+ :OTableConnection( rConn )
+{
+ DBG_CTOR(OQueryTableConnection,NULL);
+ // keine eigenen Members, also reicht die Basisklassenfunktionalitaet
+}
+//------------------------------------------------------------------------
+OQueryTableConnection::~OQueryTableConnection()
+{
+ DBG_DTOR(OQueryTableConnection,NULL);
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnection& OQueryTableConnection::operator=(const OQueryTableConnection& rConn)
+{
+ if (&rConn == this)
+ return *this;
+
+ OTableConnection::operator=(rConn);
+ // keine eigenen Members ...
+ return *this;
+}
+
+//------------------------------------------------------------------------
+sal_Bool OQueryTableConnection::operator==(const OQueryTableConnection& rCompare)
+{
+ OSL_ENSURE(GetData() && rCompare.GetData(), "OQueryTableConnection::operator== : einer der beiden Teilnehmer hat keine Daten !");
+
+ // allzuviel brauche ich nicht vergleichen (schon gar nicht alle Member) : lediglich die Fenster, an denen wir haengen, und
+ // die Indizies in der entsprechenden Tabelle muessen uebereinstimmen
+ OQueryTableConnectionData* pMyData = static_cast<OQueryTableConnectionData*>(GetData().get());
+ OQueryTableConnectionData* pCompData = static_cast<OQueryTableConnectionData*>(rCompare.GetData().get());
+
+ // Connections werden als gleich angesehen, wenn sie in Source-/Dest-Fenstername und Source-/Dest-FieldIndex uebereinstimmen ...
+ return ( ( (pMyData->getReferencedTable() == pCompData->getReferencedTable()) &&
+ (pMyData->getReferencingTable() == pCompData->getReferencingTable()) &&
+ (pMyData->GetFieldIndex(JTCS_TO) == pCompData->GetFieldIndex(JTCS_TO)) &&
+ (pMyData->GetFieldIndex(JTCS_FROM) == pCompData->GetFieldIndex(JTCS_FROM))
+ )
+ || // ... oder diese Uebereinstimmung ueber Kreuz besteht
+ ( (pMyData->getReferencingTable() == pCompData->getReferencedTable()) &&
+ (pMyData->getReferencedTable() == pCompData->getReferencingTable()) &&
+ (pMyData->GetFieldIndex(JTCS_TO) == pCompData->GetFieldIndex(JTCS_FROM)) &&
+ (pMyData->GetFieldIndex(JTCS_FROM) == pCompData->GetFieldIndex(JTCS_TO))
+ )
+ );
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableConnection.hxx b/dbaccess/source/ui/querydesign/QTableConnection.hxx
new file mode 100644
index 000000000000..a2402acab43b
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnection.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYTABLECONNECTION_HXX
+#define DBAUI_QUERYTABLECONNECTION_HXX
+
+#include "TableConnection.hxx"
+#include "QTableConnectionData.hxx"
+#include "QEnumTypes.hxx"
+
+namespace dbaui
+{
+ //==================================================================
+ class OQueryTableView;
+ class OQueryTableConnection : public OTableConnection
+ {
+ sal_Bool m_bVisited; // is true if the conn was already visited through the join algorithm
+ public:
+ OQueryTableConnection(OQueryTableView* pContainer, const TTableConnectionData::value_type& pTabConnData);
+ OQueryTableConnection(const OQueryTableConnection& rConn);
+ virtual ~OQueryTableConnection();
+
+ OQueryTableConnection& operator=(const OQueryTableConnection& rConn);
+ sal_Bool operator==(const OQueryTableConnection& rCompare);
+
+ inline ::rtl::OUString GetAliasName(EConnectionSide nWhich) const { return static_cast<OQueryTableConnectionData*>(GetData().get())->GetAliasName(nWhich); }
+
+ inline sal_Bool IsVisited() const { return m_bVisited; }
+ inline void SetVisited(sal_Bool bVisited) { m_bVisited = bVisited; }
+
+ };
+}
+#endif // DBAUI_QUERYTABLECONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.cxx b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx
new file mode 100644
index 000000000000..fc702cf94cfa
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnectionData.cxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QTableConnectionData.hxx"
+#include <tools/debug.hxx>
+#include "QTableConnectionData.hxx"
+#include "QTableWindow.hxx"
+
+using namespace dbaui;
+
+//========================================================================
+// class OQueryTableConnectionData
+//========================================================================
+DBG_NAME(OQueryTableConnectionData)
+//------------------------------------------------------------------------
+OQueryTableConnectionData::OQueryTableConnectionData()
+ :OTableConnectionData()
+ ,m_eJoinType (INNER_JOIN)
+ ,m_bNatural(false)
+{
+ DBG_CTOR(OQueryTableConnectionData,NULL);
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnectionData::OQueryTableConnectionData( const OQueryTableConnectionData& rConnData )
+ :OTableConnectionData( rConnData )
+{
+ DBG_CTOR(OQueryTableConnectionData,NULL);
+ m_nFromEntryIndex = rConnData.m_nFromEntryIndex;
+ m_nDestEntryIndex = rConnData.m_nDestEntryIndex;
+
+ m_eFromType = rConnData.m_eFromType;
+ m_eDestType = rConnData.m_eDestType;
+ m_eJoinType = rConnData.m_eJoinType;
+ m_bNatural = rConnData.m_bNatural;
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnectionData::OQueryTableConnectionData(const TTableWindowData::value_type& _pReferencingTable
+ ,const TTableWindowData::value_type& _pReferencedTable
+ ,const ::rtl::OUString& rConnName)
+ :OTableConnectionData( _pReferencingTable,_pReferencedTable, rConnName )
+ ,m_nFromEntryIndex(0)
+ ,m_nDestEntryIndex(0)
+ ,m_eJoinType (INNER_JOIN)
+ ,m_bNatural(false)
+ ,m_eFromType(TAB_NORMAL_FIELD)
+ ,m_eDestType(TAB_NORMAL_FIELD)
+{
+ DBG_CTOR(OQueryTableConnectionData,NULL);
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnectionData::~OQueryTableConnectionData()
+{
+ DBG_DTOR(OQueryTableConnectionData,NULL);
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj()
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ // keine Spezialisierung bei den LineDatas, also eine Instanz der Standard-Klasse
+ return new OConnectionLineData();
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef OQueryTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ return new OConnectionLineData( rConnLineData );
+}
+
+//------------------------------------------------------------------------
+void OQueryTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ // wie in der Basisklasse zurueckziehen auf das (nicht-virtuelle) operator=
+ *this = (const OQueryTableConnectionData&)rSource;
+}
+
+//------------------------------------------------------------------------
+OQueryTableConnectionData& OQueryTableConnectionData::operator=(const OQueryTableConnectionData& rConnData)
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ if (&rConnData == this)
+ return *this;
+
+ OTableConnectionData::operator=(rConnData);
+
+ m_nFromEntryIndex = rConnData.m_nFromEntryIndex;
+ m_nDestEntryIndex = rConnData.m_nDestEntryIndex;
+
+ m_eFromType = rConnData.m_eFromType;
+ m_eDestType = rConnData.m_eDestType;
+ m_eJoinType = rConnData.m_eJoinType;
+ m_bNatural = rConnData.m_bNatural;
+
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OQueryTableConnectionData::GetAliasName(EConnectionSide nWhich) const
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ return nWhich == JTCS_FROM ? m_pReferencingTable->GetWinName() : m_pReferencedTable->GetWinName();
+}
+
+//------------------------------------------------------------------------------
+void OQueryTableConnectionData::InitFromDrag(const OTableFieldDescRef& rDragLeft, const OTableFieldDescRef& rDragRight)
+{
+ DBG_CHKTHIS(OQueryTableConnectionData,NULL);
+ // die Infos in rDrag in Parameter fuer das Basisklassen-Init umsetzen ...
+ OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(rDragLeft->GetTabWindow());
+ OQueryTableWindow* pDestWin = static_cast<OQueryTableWindow*>(rDragRight->GetTabWindow());
+ OSL_ENSURE(pSourceWin,"NO Source window found!");
+ OSL_ENSURE(pDestWin,"NO Dest window found!");
+ m_pReferencingTable = pSourceWin->GetData();
+ m_pReferencedTable = pDestWin->GetData();
+
+ // und dann meine Members setzen
+ SetFieldIndex(JTCS_FROM, rDragLeft->GetFieldIndex());
+ SetFieldIndex(JTCS_TO, rDragRight->GetFieldIndex());
+
+ SetFieldType(JTCS_FROM, rDragLeft->GetFieldType());
+ SetFieldType(JTCS_TO, rDragRight->GetFieldType());
+
+ AppendConnLine((::rtl::OUString)rDragLeft->GetField(),(::rtl::OUString)rDragRight->GetField());
+}
+// -----------------------------------------------------------------------------
+OTableConnectionData* OQueryTableConnectionData::NewInstance() const
+{
+ return new OQueryTableConnectionData();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryTableConnectionData::Update()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableConnectionData.hxx b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx
new file mode 100644
index 000000000000..0b4c78d394a5
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableConnectionData.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QTABLECONNECTIONDATA_HXX
+#define DBAUI_QTABLECONNECTIONDATA_HXX
+
+#include "TableConnectionData.hxx"
+#include "TableFieldDescription.hxx"
+#include "QEnumTypes.hxx"
+#include <tools/rtti.hxx>
+
+namespace dbaui
+{
+ class OQueryTableConnectionData : public OTableConnectionData
+ {
+ sal_Int32 m_nFromEntryIndex;
+ sal_Int32 m_nDestEntryIndex;
+ EJoinType m_eJoinType;
+ bool m_bNatural;
+
+ ETableFieldType m_eFromType;
+ ETableFieldType m_eDestType;
+
+ protected:
+ // fuer das Anlegen und Duplizieren von Lines vom eigenen Typ
+ virtual OConnectionLineDataRef CreateLineDataObj();
+ virtual OConnectionLineDataRef CreateLineDataObj( const OConnectionLineData& rConnLineData );
+
+ OQueryTableConnectionData& operator=( const OQueryTableConnectionData& rConnData );
+ public:
+ OQueryTableConnectionData();
+ OQueryTableConnectionData( const OQueryTableConnectionData& rConnData );
+ OQueryTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,const TTableWindowData::value_type& _pReferencedTable,
+ const ::rtl::OUString& rConnName=::rtl::OUString());
+ virtual ~OQueryTableConnectionData();
+
+ virtual void CopyFrom(const OTableConnectionData& rSource);
+ virtual OTableConnectionData* NewInstance() const;
+
+
+ /** Update create a new connection
+
+ @return true if successful
+ */
+ virtual sal_Bool Update();
+
+ ::rtl::OUString GetAliasName(EConnectionSide nWhich) const;
+
+ sal_Int32 GetFieldIndex(EConnectionSide nWhich) const { return nWhich==JTCS_TO ? m_nDestEntryIndex : m_nFromEntryIndex; }
+ void SetFieldIndex(EConnectionSide nWhich, sal_Int32 nVal) { if (nWhich==JTCS_TO) m_nDestEntryIndex=nVal; else m_nFromEntryIndex=nVal; }
+
+ ETableFieldType GetFieldType(EConnectionSide nWhich) const { return nWhich==JTCS_TO ? m_eDestType : m_eFromType; }
+ void SetFieldType(EConnectionSide nWhich, ETableFieldType eType) { if (nWhich==JTCS_TO) m_eDestType=eType; else m_eFromType=eType; }
+
+ void InitFromDrag(const OTableFieldDescRef& rDragLeft, const OTableFieldDescRef& rDragRight);
+
+ EJoinType GetJoinType() const { return m_eJoinType; };
+ void SetJoinType(const EJoinType& eJT) { m_eJoinType = eJT; };
+
+ inline void setNatural(bool _bNatural) { m_bNatural = _bNatural; }
+ inline bool isNatural() const { return m_bNatural; }
+ };
+
+}
+#endif // DBAUI_QTABLECONNECTIONDATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.cxx b/dbaccess/source/ui/querydesign/QTableWindow.cxx
new file mode 100644
index 000000000000..e20ca59c5494
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindow.cxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QTableWindow.hxx"
+#include "QueryTableView.hxx"
+#include "dbustrings.hrc"
+#include <osl/diagnose.h>
+#include "dbaccess_helpid.hrc"
+#include "QueryDesignView.hxx"
+#include "browserids.hxx"
+#include "querycontroller.hxx"
+#include <vcl/image.hxx>
+#include "TableWindowListBox.hxx"
+#include "dbu_qry.hrc"
+#include "Query.hrc"
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include "TableFieldInfo.hxx"
+#include <comphelper/uno3.hxx>
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace dbaui;
+//========================================================================
+// class OQueryTableWindow
+//========================================================================
+DBG_NAME(OQueryTableWindow)
+//------------------------------------------------------------------------------
+OQueryTableWindow::OQueryTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData, sal_Unicode* pszInitialAlias)
+ :OTableWindow( pParent, pTabWinData )
+ ,m_nAliasNum(0)
+{
+ DBG_CTOR(OQueryTableWindow,NULL);
+ if (pszInitialAlias != NULL)
+ m_strInitialAlias = ::rtl::OUString(pszInitialAlias);
+ else
+ m_strInitialAlias = GetAliasName();
+
+ // wenn der Tabellen- gleich dem Aliasnamen ist, dann darf ich das nicht an InitialAlias weiterreichen, denn das Anhaengen
+ // eines eventuelle Tokens nicht klappen ...
+ if (m_strInitialAlias == pTabWinData->GetTableName())
+ m_strInitialAlias = ::rtl::OUString();
+
+ SetHelpId(HID_CTL_QRYDGNTAB);
+}
+
+//------------------------------------------------------------------------------
+OQueryTableWindow::~OQueryTableWindow()
+{
+ DBG_DTOR(OQueryTableWindow,NULL);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OQueryTableWindow::Init()
+{
+ sal_Bool bSuccess = OTableWindow::Init();
+ if(!bSuccess)
+ return bSuccess;
+
+ OQueryTableView* pContainer = static_cast<OQueryTableView*>(getTableView());
+
+ // zuerst Alias bestimmen
+ ::rtl::OUString sAliasName;
+
+ TTableWindowData::value_type pWinData = GetData();
+
+ if (m_strInitialAlias.getLength() )
+ // Der Alias wurde explizit mit angegeben
+ sAliasName = m_strInitialAlias;
+ else if ( GetTable().is() )
+ GetTable()->getPropertyValue( PROPERTY_NAME ) >>= sAliasName;
+ else
+ return sal_False;
+
+ // Alias mit fortlaufender Nummer versehen
+ if (pContainer->CountTableAlias(sAliasName, m_nAliasNum))
+ {
+ sAliasName += ::rtl::OUString('_');
+ sAliasName += ::rtl::OUString::valueOf(m_nAliasNum);
+ }
+
+
+ sAliasName = String(sAliasName).EraseAllChars('"');
+ SetAliasName(sAliasName);
+ // SetAliasName reicht das als WinName weiter, dadurch benutzt es die Basisklasse
+ // reset the title
+ m_aTitle.SetText( pWinData->GetWinName() );
+ m_aTitle.Show();
+
+ if (!bSuccess)
+ { // es soll nur ein Dummy-Window aufgemacht werden ...
+ OSL_ENSURE(GetAliasName().getLength(), "OQueryTableWindow::Init : kein Alias- UND kein Tabellenname geht nicht !");
+ // .. aber das braucht wenigstens einen Alias
+
+ // ::com::sun::star::form::ListBox anlegen
+ if (!m_pListBox)
+ m_pListBox = CreateListBox();
+
+ // Titel setzen
+ m_aTitle.SetText(GetAliasName());
+ m_aTitle.Show();
+
+ clearListBox();
+ // neu zu fuellen brauche ich die nicht, da ich ja keine Tabelle habe
+ m_pListBox->Show();
+ }
+
+ getTableView()->getDesignView()->getController().InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+void* OQueryTableWindow::createUserData(const Reference< XPropertySet>& _xColumn,bool _bPrimaryKey)
+{
+ OTableFieldInfo* pInfo = new OTableFieldInfo();
+ pInfo->SetKey(_bPrimaryKey ? TAB_PRIMARY_FIELD : TAB_NORMAL_FIELD);
+ if ( _xColumn.is() )
+ pInfo->SetDataType(::comphelper::getINT32(_xColumn->getPropertyValue(PROPERTY_TYPE)));
+ return pInfo;
+}
+// -----------------------------------------------------------------------------
+void OQueryTableWindow::deleteUserData(void*& _pUserData)
+{
+ delete static_cast<OTableFieldInfo*>(_pUserData);
+ _pUserData = NULL;
+}
+//------------------------------------------------------------------------------
+void OQueryTableWindow::OnEntryDoubleClicked(SvLBoxEntry* pEntry)
+{
+ OSL_ENSURE(pEntry != NULL, "OQueryTableWindow::OnEntryDoubleClicked : pEntry darf nicht NULL sein !");
+ // man koennte das auch abfragen und dann ein return hinsetzen, aber so weist es vielleicht auf Fehler bei Aufrufer hin
+
+ if (getTableView()->getDesignView()->getController().isReadOnly())
+ return;
+
+ OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData());
+ OSL_ENSURE(pInf != NULL, "OQueryTableWindow::OnEntryDoubleClicked : Feld hat keine FieldInfo !");
+
+ // eine DragInfo aufbauen
+ OTableFieldDescRef aInfo = new OTableFieldDesc(GetTableName(),m_pListBox->GetEntryText(pEntry));
+ aInfo->SetTabWindow(this);
+ aInfo->SetAlias(GetAliasName());
+ aInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry));
+ aInfo->SetDataType(pInf->GetDataType());
+
+ // und das entsprechende Feld einfuegen
+ static_cast<OQueryTableView*>(getTableView())->InsertField(aInfo);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OQueryTableWindow::ExistsField(const ::rtl::OUString& strFieldName, OTableFieldDescRef& rInfo)
+{
+ OSL_ENSURE(m_pListBox != NULL, "OQueryTableWindow::ExistsField : habe keine ::com::sun::star::form::ListBox !");
+ OSL_ENSURE(rInfo.is(),"OQueryTableWindow::ExistsField: invlid argument for OTableFieldDescRef!");
+ Reference< XConnection> xConnection = getTableView()->getDesignView()->getController().getConnection();
+ sal_Bool bExists = sal_False;
+ if(xConnection.is())
+ {
+ SvLBoxEntry* pEntry = m_pListBox->First();
+ try
+ {
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+
+ while (pEntry)
+ {
+ if (bCase(strFieldName,::rtl::OUString(m_pListBox->GetEntryText(pEntry))))
+ {
+ OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(pEntry->GetUserData());
+ OSL_ENSURE(pInf != NULL, "OQueryTableWindow::ExistsField : Feld hat keine FieldInfo !");
+
+ rInfo->SetTabWindow(this);
+ rInfo->SetField(strFieldName);
+ rInfo->SetTable(GetTableName());
+ rInfo->SetAlias(GetAliasName());
+ rInfo->SetFieldIndex(m_pListBox->GetModel()->GetAbsPos(pEntry));
+ rInfo->SetDataType(pInf->GetDataType());
+ bExists = sal_True;
+ break;
+ }
+ pEntry = m_pListBox->Next(pEntry);
+ }
+ }
+ catch(SQLException&)
+ {
+ }
+ }
+
+ return bExists;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OQueryTableWindow::ExistsAVisitedConn() const
+{
+ return static_cast<const OQueryTableView*>(getTableView())->ExistsAVisitedConn(this);
+}
+
+//------------------------------------------------------------------------------
+void OQueryTableWindow::KeyInput( const KeyEvent& rEvt )
+{
+ OTableWindow::KeyInput( rEvt );
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableWindow.hxx b/dbaccess/source/ui/querydesign/QTableWindow.hxx
new file mode 100644
index 000000000000..16b5097ca6d0
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindow.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERY_TABLEWINDOW_HXX
+#define DBAUI_QUERY_TABLEWINDOW_HXX
+
+#include "TableWindow.hxx"
+#include "QTableWindowData.hxx"
+#include "TableFieldDescription.hxx"
+#include <tools/rtti.hxx>
+
+namespace dbaui
+{
+ //==================================================================
+ class OQueryTableWindow : public OTableWindow
+ {
+ sal_Int32 m_nAliasNum;
+ ::rtl::OUString m_strInitialAlias;
+ public:
+ OQueryTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData, sal_Unicode* pszInitialAlias = NULL );
+ virtual ~OQueryTableWindow();
+
+ ::rtl::OUString GetAliasName() const
+ {
+ return static_cast<OQueryTableWindowData*>(GetData().get())->GetAliasName();
+ }
+ void SetAliasName(const ::rtl::OUString& strNewAlias)
+ {
+ static_cast<OQueryTableWindowData*>(GetData().get())->SetAliasName(strNewAlias);
+ }
+
+ // spaeter Constructor, die Basisklasse ERZEUGT beim ersten Aufruf die Listbox
+ virtual sal_Bool Init();
+
+ inline sal_Int32 GetAliasNum() const { return m_nAliasNum; }
+
+ sal_Bool ExistsField(const ::rtl::OUString& strFieldName, OTableFieldDescRef& rInfo);
+ sal_Bool ExistsAVisitedConn() const;
+
+ virtual ::rtl::OUString GetName() const { return GetWinName(); }
+
+ protected:
+ virtual void KeyInput( const KeyEvent& rEvt );
+
+ virtual void OnEntryDoubleClicked(SvLBoxEntry* pEntry);
+ // wird aus dem DoubleClickHdl der ListBox heraus aufgerufen
+ /** delete the user data with the equal type as created within createUserData
+ @param _pUserData
+ The user data store in the listbox entries. Created with a call to createUserData.
+ _pUserData may be <NULL/>.
+ */
+ virtual void deleteUserData(void*& _pUserData);
+
+ /** creates user information that will be append at the ListBoxentry
+ @param _xColumn
+ The corresponding column, can be <NULL/>.
+ @param _bPrimaryKey
+ <TRUE/> when the column belongs to the primary key
+ @return
+ the user data which will be append at the listbox entry, may be <NULL/>
+ */
+ virtual void* createUserData(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet>& _xColumn,
+ bool _bPrimaryKey);
+ };
+}
+#endif // DBAUI_QUERY_TABLEWINDOW_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableWindowData.cxx b/dbaccess/source/ui/querydesign/QTableWindowData.cxx
new file mode 100644
index 000000000000..5fc047a9fbcf
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindowData.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QTableWindowData.hxx"
+#include <tools/debug.hxx>
+
+
+using namespace dbaui;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+
+DBG_NAME(OQueryTableWindowData)
+//==================================================================
+// class OQueryTableWindowData
+//==================================================================
+//------------------------------------------------------------------------------
+OQueryTableWindowData::OQueryTableWindowData(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rTableName, const ::rtl::OUString& rTableAlias )
+ :OTableWindowData(NULL,_rComposedName, rTableName, rTableAlias)
+{
+ DBG_CTOR(OQueryTableWindowData,NULL);
+}
+
+//------------------------------------------------------------------------------
+OQueryTableWindowData::~OQueryTableWindowData()
+{
+ DBG_DTOR(OQueryTableWindowData,NULL);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QTableWindowData.hxx b/dbaccess/source/ui/querydesign/QTableWindowData.hxx
new file mode 100644
index 000000000000..9a54e738a764
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QTableWindowData.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERY_TABLEWINDOWDATA_HXX
+#define DBAUI_QUERY_TABLEWINDOWDATA_HXX
+
+#include "TableWindowData.hxx"
+#ifndef INCLUDED_VECTOR
+#define INCLUDED_VECTOR
+#include <vector>
+#endif
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+
+
+namespace dbaui
+{
+ class OQueryTableWindowData : public OTableWindowData
+ {
+ public:
+ explicit OQueryTableWindowData(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rTableName, const ::rtl::OUString& rTableAlias);
+ virtual ~OQueryTableWindowData();
+
+ ::rtl::OUString GetAliasName() { return GetWinName(); }
+ void SetAliasName(const ::rtl::OUString& rNewAlias) { SetWinName(rNewAlias); }
+ };
+}
+#endif // DBAUI_QUERY_TABLEWINDOWDATA_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/Query.hrc b/dbaccess/source/ui/querydesign/Query.hrc
new file mode 100644
index 000000000000..6fb9bb9ac5d0
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/Query.hrc
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERY_HRC
+#define DBAUI_QUERY_HRC
+
+#define IMG_PRIMARY_KEY 1
+#define IMG_FOREIGN_KEY 2
+
+
+#endif // DBAUI_QUERY_HRC
+
diff --git a/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx
new file mode 100644
index 000000000000..c0ef7d5ef1ef
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryAddTabConnUndoAction.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYADDTABCONNUNDOACTION_HXX
+#define DBAUI_QUERYADDTABCONNUNDOACTION_HXX
+
+#include "QueryTabConnUndoAction.hxx"
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryAddTabConnUndoAction - Undo-Klasse fuer Einfuegen einer Connection
+
+ class OQueryTableView;
+ class OQueryAddTabConnUndoAction : public OQueryTabConnUndoAction
+ {
+ public:
+ OQueryAddTabConnUndoAction(OQueryTableView* pOwner);
+
+ virtual void Undo();
+ virtual void Redo();
+ };
+
+ // ================================================================================================
+ // OQueryDelTabConnUndoAction - Undo-Klasse fuer Einfuegen einer Connection
+
+ class OQueryDelTabConnUndoAction : public OQueryTabConnUndoAction
+ {
+ public:
+ OQueryDelTabConnUndoAction(OQueryTableView* pOwner);
+
+ virtual void Undo();
+ virtual void Redo();
+ };
+}
+#endif // DBAUI_QUERYADDTABCONNUNDOACTION_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx
new file mode 100644
index 000000000000..92a79f257efd
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignFieldUndoAct.hxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
+#define DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
+
+#include "GeneralUndo.hxx"
+#include "dbu_qry.hrc"
+#include "SelectionBrowseBox.hxx"
+
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryDesignFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf
+
+
+ class OQueryDesignFieldUndoAct : public OCommentUndoAction
+ {
+ protected:
+ OSelectionBrowseBox* pOwner;
+ sal_uInt16 m_nColumnPostion;
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+
+ public:
+ OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID);
+ virtual ~OQueryDesignFieldUndoAct();
+
+ inline void SetColumnPosition(sal_uInt16 _nColumnPostion)
+ {
+ m_nColumnPostion = _nColumnPostion;
+ OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
+ OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
+ }
+ };
+
+ // ================================================================================================
+ // OTabFieldCellModifiedUndoAct - Undo-Klasse fuer Aendern einer Zelle einer Spaltenbeschreibung
+
+ class OTabFieldCellModifiedUndoAct : public OQueryDesignFieldUndoAct
+ {
+ protected:
+ String m_strNextCellContents;
+ sal_Int32 m_nCellIndex;
+
+ public:
+ OTabFieldCellModifiedUndoAct(OSelectionBrowseBox* pSelBrwBox)
+ : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_MODIFY_CELL)
+ ,m_nCellIndex(BROWSER_INVALIDID){ }
+
+ inline void SetCellContents(const String& str) { m_strNextCellContents = str; }
+ inline void SetCellIndex(sal_Int32 nIndex) { m_nCellIndex = nIndex; }
+
+ virtual void Undo();
+ virtual void Redo() { Undo(); }
+ };
+
+ // ================================================================================================
+ // OTabFieldSizedUndoAct - Undo-Klasse fuer Aendern einer Spaltenbreite
+
+ class OTabFieldSizedUndoAct : public OQueryDesignFieldUndoAct
+ {
+ protected:
+ long m_nNextWidth;
+
+ public:
+ OTabFieldSizedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OQueryDesignFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_SIZE_COLUMN), m_nNextWidth(0) { }
+
+ inline void SetOriginalWidth(long nWidth) { m_nNextWidth = nWidth; }
+
+ virtual void Undo();
+ virtual void Redo() { Undo(); }
+ };
+
+ // ================================================================================================
+ // OTabFieldUndoAct - Basisklasse fuer Undos in der Feldauflistung im Abfrageentwurf, die mit Veraendern einer kompletten Feldbeschreibung zu tun haben
+
+ class OTabFieldUndoAct : public OQueryDesignFieldUndoAct
+ {
+ protected:
+ OTableFieldDescRef pDescr; // geloeschte Spaltenbeschreibung
+
+ public:
+ OTabFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID) : OQueryDesignFieldUndoAct(pSelBrwBox, nCommentID) { }
+
+ void SetTabFieldDescr(OTableFieldDescRef pDescription) { pDescr = pDescription; }
+ };
+
+ // ================================================================================================
+ // OTabFieldDelUndoAct - Undo-Klasse fuer Loeschen eines Feldes
+
+ class OTabFieldDelUndoAct : public OTabFieldUndoAct
+ {
+ protected:
+ virtual void Undo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode(); }
+ virtual void Redo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode(); }
+
+ public:
+ OTabFieldDelUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDDELETE) { }
+ };
+
+ // ================================================================================================
+ // OTabFieldDelUndoAct - Undo-Klasse fuer Anlegen eines Feldes
+
+ class OTabFieldCreateUndoAct : public OTabFieldUndoAct
+ {
+ protected:
+ virtual void Undo() { pOwner->EnterUndoMode();pOwner->RemoveColumn(pDescr->GetColumnId());pOwner->LeaveUndoMode();}
+ virtual void Redo() { pOwner->EnterUndoMode();pOwner->InsertColumn(pDescr, m_nColumnPostion);pOwner->LeaveUndoMode();}
+
+ public:
+ OTabFieldCreateUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDCREATE) { }
+ };
+
+ // ================================================================================================
+ // OTabFieldMovedUndoAct - Undo-class when a field was moved inside the selection
+
+ class OTabFieldMovedUndoAct : public OTabFieldUndoAct
+ {
+ protected:
+ virtual void Undo();
+ virtual void Redo()
+ {
+ Undo();
+ }
+
+ public:
+ OTabFieldMovedUndoAct(OSelectionBrowseBox* pSelBrwBox) : OTabFieldUndoAct(pSelBrwBox, STR_QUERY_UNDO_TABFIELDMOVED) { }
+ };
+}
+#endif // DBAUI_QUERYDESIGNFIELDUNDOACT_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx
new file mode 100644
index 000000000000..f0f862cf3611
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignUndoAction.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYDESIGNUNDOACTION_HXX
+#define DBAUI_QUERYDESIGNUNDOACTION_HXX
+
+#include "GeneralUndo.hxx"
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryDesignUndoAction - Undo-Basisklasse fuer Aktionen im graphischen Abfrageentwurf (ohne Feldliste)
+
+ class OJoinTableView;
+ class OQueryDesignUndoAction : public OCommentUndoAction
+ {
+ protected:
+ OJoinTableView* m_pOwner; // in diesem Container spielt sich alles ab
+
+ public:
+ OQueryDesignUndoAction(OJoinTableView* pOwner, sal_uInt16 nCommentID) : OCommentUndoAction(nCommentID), m_pOwner(pOwner) { }
+ };
+}
+#endif // DBAUI_QUERYDESIGNUNDOACTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
new file mode 100644
index 000000000000..ccd9b3af9533
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -0,0 +1,3217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryDesignView.hxx"
+#include "QueryTableView.hxx"
+#include "QTableWindow.hxx"
+#include <vcl/toolbox.hxx>
+#include "querycontroller.hxx"
+#include <vcl/split.hxx>
+#include <svl/undo.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "adtabdlg.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/msgbox.hxx>
+#include "browserids.hxx"
+#include "SelectionBrowseBox.hxx"
+#include "dbu_qry.hrc"
+#include <unotools/configmgr.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/i18n/XLocaleData.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <connectivity/PColumn.hxx>
+#include "QTableConnection.hxx"
+#include "ConnectionLine.hxx"
+#include "ConnectionLineData.hxx"
+#include "QTableConnectionData.hxx"
+#include "dbustrings.hrc"
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+#include "querycontainerwindow.hxx"
+#include "QueryTableView.hxx"
+#include "sqlmessage.hxx"
+#include <unotools/syslocale.hxx>
+
+using namespace ::dbaui;
+using namespace ::utl;
+using namespace ::connectivity;
+using namespace ::dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
+
+// here we define our functions used in the anonymous namespace to get our header file smaller
+// please look at the book LargeScale C++ to know why
+namespace
+{
+ static const ::rtl::OUString C_AND(RTL_CONSTASCII_USTRINGPARAM(" AND "));
+ static const ::rtl::OUString C_OR(RTL_CONSTASCII_USTRINGPARAM(" OR "));
+
+ // forward declarations
+ sal_Bool InsertJoin( const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode *pNode);
+
+ SqlParseError InstallFields(OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode* pNode,
+ OJoinTableView::OTableWindowMap* pTabList );
+
+ SqlParseError GetGroupCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pSelectRoot );
+
+ SqlParseError GetHavingCriteria(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pSelectRoot,
+ sal_uInt16& rLevel );
+
+ SqlParseError GetOrderCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pParseRoot );
+
+ SqlParseError AddFunctionCondition(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ const sal_uInt16 nLevel,
+ sal_Bool bHaving,
+ bool _bAddOrOnOneLine);
+
+ //------------------------------------------------------------------------------
+ ::rtl::OUString quoteTableAlias(sal_Bool _bQuote, const ::rtl::OUString& _sAliasName, const ::rtl::OUString& _sQuote)
+ {
+ ::rtl::OUString sRet;
+ if ( _bQuote && _sAliasName.getLength() )
+ {
+ sRet = ::dbtools::quoteName(_sQuote,_sAliasName);
+ const static ::rtl::OUString sTableSeparater('.');
+ sRet += sTableSeparater;
+ }
+ return sRet;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString getTableRange(const OQueryDesignView* _pView,const ::connectivity::OSQLParseNode* _pTableRef)
+ {
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
+ ::rtl::OUString sTableRange;
+ if ( _pTableRef )
+ {
+ sTableRange = ::connectivity::OSQLParseNode::getTableRange(_pTableRef);
+ if ( !sTableRange.getLength() )
+ _pTableRef->parseNodeToStr(sTableRange,xConnection,NULL,sal_False,sal_False);
+ }
+ return sTableRange;
+ }
+ //------------------------------------------------------------------------------
+ void insertConnection(const OQueryDesignView* _pView,const EJoinType& _eJoinType,OTableFieldDescRef _aDragLeft,OTableFieldDescRef _aDragRight,bool _bNatural = false)
+ {
+ OQueryTableView* pTableView = static_cast<OQueryTableView*>(_pView->getTableView());
+ OQueryTableConnection* pConn = static_cast<OQueryTableConnection*>( pTableView->GetTabConn(static_cast<OTableWindow*>(_aDragLeft->GetTabWindow()),static_cast<OTableWindow*>(_aDragRight->GetTabWindow()),true));
+
+ if ( !pConn )
+ {
+ OQueryTableConnectionData* pInfoData = new OQueryTableConnectionData();
+ TTableConnectionData::value_type aInfoData(pInfoData);
+ pInfoData->InitFromDrag(_aDragLeft, _aDragRight);
+ pInfoData->SetJoinType(_eJoinType);
+
+ if ( _bNatural )
+ {
+ aInfoData->ResetConnLines();
+ pInfoData->setNatural(_bNatural);
+ try
+ {
+ Reference<XNameAccess> xReferencedTableColumns(aInfoData->getReferencedTable()->getColumns());
+ Sequence< ::rtl::OUString> aSeq = aInfoData->getReferencingTable()->getColumns()->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( xReferencedTableColumns->hasByName(*pIter) )
+ aInfoData->AppendConnLine(*pIter,*pIter);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ OQueryTableConnection aInfo(pTableView, aInfoData);
+ // da ein OQueryTableConnection-Objekt nie den Besitz der uebergebenen Daten uebernimmt, sondern sich nur den Zeiger merkt,
+ // ist dieser Zeiger auf eine lokale Variable hier unkritisch, denn aInfoData und aInfo haben die selbe Lebensdauer
+ pTableView->NotifyTabConnection( aInfo );
+ }
+ else
+ {
+ ::rtl::OUString aSourceFieldName(_aDragLeft->GetField());
+ ::rtl::OUString aDestFieldName(_aDragRight->GetField());
+ // the connection could point on the other side
+ if(pConn->GetSourceWin() == _aDragRight->GetTabWindow())
+ {
+ ::rtl::OUString aTmp(aSourceFieldName);
+ aSourceFieldName = aDestFieldName;
+ aDestFieldName = aTmp;
+ }
+ pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName);
+ pConn->UpdateLineList();
+ // Modified-Flag
+ // SetModified();
+ // und neu zeichnen
+ pConn->RecalcLines();
+ // fuer das unten folgende Invalidate muss ich dieser neuen Connection erst mal die Moeglichkeit geben,
+ // ihr BoundingRect zu ermitteln
+ pConn->InvalidateConnection();
+ }
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString ParseCondition( OQueryController& rController
+ ,const ::connectivity::OSQLParseNode* pCondition
+ ,const ::rtl::OUString _sDecimal
+ ,const ::com::sun::star::lang::Locale& _rLocale
+ ,sal_uInt32 _nStartIndex)
+ {
+ ::rtl::OUString aCondition;
+ Reference< XConnection> xConnection = rController.getConnection();
+ if ( xConnection.is() )
+ {
+ sal_uInt32 nCount = pCondition->count();
+ for(sal_uInt32 i = _nStartIndex ; i < nCount ; ++i)
+ pCondition->getChild(i)->parseNodeToPredicateStr(aCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ _rLocale,
+ static_cast<sal_Char>(_sDecimal.toChar()),
+ &rController.getParser().getContext());
+ }
+ return aCondition;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError FillOuterJoins(OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode* pTableRefList)
+ {
+ SqlParseError eErrorCode = eOk;
+ sal_uInt32 nCount = pTableRefList->count();
+ sal_Bool bError = sal_False;
+ for (sal_uInt32 i=0; !bError && i < nCount; ++i)
+ {
+ const ::connectivity::OSQLParseNode* pParseNode = pTableRefList->getChild(i);
+ const ::connectivity::OSQLParseNode* pJoinNode = NULL;
+
+ if ( SQL_ISRULE( pParseNode, qualified_join ) || SQL_ISRULE( pParseNode, joined_table ) || SQL_ISRULE( pParseNode, cross_union ) )
+ pJoinNode = pParseNode;
+ else if( SQL_ISRULE(pParseNode,table_ref)
+ && pParseNode->count() == 4 ) // '{' SQL_TOKEN_OJ joined_table '}'
+ pJoinNode = pParseNode->getChild(2);
+
+ if ( pJoinNode )
+ {
+ if ( !InsertJoin(_pView,pJoinNode) )
+ bError = sal_True;
+ }
+ }
+ // check if error occurred
+ if ( bError )
+ eErrorCode = eIllegalJoin;
+
+ return eErrorCode;
+ }
+ // -----------------------------------------------------------------------------
+
+ /** FillDragInfo fills the field description out of the table
+ */
+ //------------------------------------------------------------------------------
+ SqlParseError FillDragInfo( const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode* pColumnRef,
+ OTableFieldDescRef& _rDragInfo)
+ {
+ SqlParseError eErrorCode = eOk;
+
+ sal_Bool bErg = sal_False;
+
+ ::rtl::OUString aTableRange,aColumnName;
+ sal_uInt16 nCntAccount;
+ ::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator();
+ rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange );
+
+ if ( aTableRange.getLength() )
+ {
+ OQueryTableWindow* pSTW = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( aTableRange );
+ bErg = (pSTW && pSTW->ExistsField( aColumnName, _rDragInfo ) );
+ }
+ if ( !bErg )
+ {
+ bErg = static_cast<OQueryTableView*>(_pView->getTableView())->FindTableFromField(aColumnName, _rDragInfo, nCntAccount);
+ if ( !bErg )
+ bErg = _pView->HasFieldByAliasName(aColumnName, _rDragInfo);
+ }
+ if ( !bErg )
+ {
+ eErrorCode = eColumnNotFound;
+ String sError(ModuleRes(STR_QRY_COLUMN_NOT_FOUND));
+ sError.SearchAndReplaceAscii("$name$",aColumnName);
+ _pView->getController().appendError( sError );
+
+ try
+ {
+ Reference<XDatabaseMetaData> xMeta = _pView->getController().getConnection()->getMetaData();
+ if ( xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers() )
+ _pView->getController().appendError( String( ModuleRes( STR_QRY_CHECK_CASESENSITIVE ) ) );
+ }
+ catch(Exception&)
+ {
+ }
+ }
+
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildJoinCriteria( const Reference< XConnection>& _xConnection,
+ OConnectionLineDataVec* pLineDataList,
+ OQueryTableConnectionData* pData)
+ {
+ ::rtl::OUStringBuffer aCondition;
+ if ( _xConnection.is() )
+ {
+ OConnectionLineDataVec::iterator aIter = pLineDataList->begin();
+ OConnectionLineDataVec::iterator aEnd = pLineDataList->end();
+ try
+ {
+ const Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
+ const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+ const ::rtl::OUString sEqual(RTL_CONSTASCII_USTRINGPARAM(" = "));
+
+ for(;aIter != aEnd;++aIter)
+ {
+ OConnectionLineDataRef pLineData = *aIter;
+ if(aCondition.getLength())
+ aCondition.append(C_AND);
+ aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_FROM),aQuote));
+ aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_FROM) ));
+ aCondition.append(sEqual);
+ aCondition.append(quoteTableAlias(sal_True,pData->GetAliasName(JTCS_TO),aQuote));
+ aCondition.append(::dbtools::quoteName(aQuote, pLineData->GetFieldName(JTCS_TO) ));
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("Failure while building Join criteria!");
+ }
+ }
+
+ return aCondition.makeStringAndClear();
+ }
+ //------------------------------------------------------------------------------
+ /** JoinCycle looks for a join cycle and append it to the string
+ @param _xConnection the connection
+ @param _pEntryConn the table connection which holds the data
+ @param _pEntryTabTo the corresponding table window
+ @param _rJoin the String which will contain the resulting string
+ */
+ void JoinCycle( const Reference< XConnection>& _xConnection,
+ OQueryTableConnection* _pEntryConn,
+ const OQueryTableWindow* _pEntryTabTo,
+ ::rtl::OUString& _rJoin )
+ {
+ OSL_ENSURE(_pEntryConn,"TableConnection can not be null!");
+
+ OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pEntryConn->GetData().get());
+ if ( pData->GetJoinType() != INNER_JOIN && _pEntryTabTo->ExistsAVisitedConn() )
+ {
+ sal_Bool bBrace = sal_False;
+ if(_rJoin.getLength() && _rJoin.lastIndexOf(')') == (_rJoin.getLength()-1))
+ {
+ bBrace = sal_True;
+ _rJoin = _rJoin.replaceAt(_rJoin.getLength()-1,1,::rtl::OUString(' '));
+ }
+ (_rJoin += C_AND) += BuildJoinCriteria(_xConnection,pData->GetConnLineDataList(),pData);
+ if(bBrace)
+ _rJoin += ::rtl::OUString(')');
+ _pEntryConn->SetVisited(sal_True);
+ }
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildTable( const Reference< XConnection>& _xConnection,
+ const OQueryTableWindow* pEntryTab,
+ bool _bForce = false
+ )
+ {
+ ::rtl::OUString aDBName(pEntryTab->GetComposedName());
+
+ if( _xConnection.is() )
+ {
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
+
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( xMetaData, aDBName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ ::rtl::OUString aTableListStr = ::dbtools::composeTableNameForSelect( _xConnection, sCatalog, sSchema, sTable );
+
+ ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+ if ( _bForce || isAppendTableAliasEnabled( _xConnection ) || pEntryTab->GetAliasName() != aDBName )
+ {
+ aTableListStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ if ( generateAsBeforeTableAlias( _xConnection ) )
+ aTableListStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AS "));
+ aTableListStr += ::dbtools::quoteName( aQuote, pEntryTab->GetAliasName() );
+ }
+ aDBName = aTableListStr;
+ }
+ catch(const SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return aDBName;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
+ const ::rtl::OUString& rLh,
+ const ::rtl::OUString& rRh,
+ OQueryTableConnectionData* pData)
+ {
+
+ String aErg(rLh);
+ if ( pData->isNatural() && pData->GetJoinType() != CROSS_JOIN )
+ aErg.AppendAscii(" NATURAL ");
+ switch(pData->GetJoinType())
+ {
+ case LEFT_JOIN:
+ aErg.AppendAscii(" LEFT OUTER ");
+ break;
+ case RIGHT_JOIN:
+ aErg.AppendAscii(" RIGHT OUTER ");
+ break;
+ case CROSS_JOIN:
+ OSL_ENSURE(!pData->isNatural(),"OQueryDesignView::BuildJoin: This should not happen!");
+ aErg.AppendAscii(" CROSS ");
+ break;
+ case INNER_JOIN:
+ OSL_ENSURE(pData->isNatural(),"OQueryDesignView::BuildJoin: This should not happen!");
+ aErg.AppendAscii(" INNER ");
+ break;
+ default:
+ aErg.AppendAscii(" FULL OUTER ");
+ break;
+ }
+ aErg.AppendAscii("JOIN ");
+ aErg += String(rRh);
+ if ( CROSS_JOIN != pData->GetJoinType() && !pData->isNatural() )
+ {
+ aErg.AppendAscii(" ON ");
+ aErg += String(BuildJoinCriteria(_xConnection,pData->GetConnLineDataList(),pData));
+ }
+
+ return aErg;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
+ OQueryTableWindow* pLh,
+ OQueryTableWindow* pRh,
+ OQueryTableConnectionData* pData
+ )
+ {
+ bool bForce = pData->GetJoinType() == CROSS_JOIN || pData->isNatural();
+ return BuildJoin(_xConnection,BuildTable(_xConnection,pLh,bForce),BuildTable(_xConnection,pRh,bForce),pData);
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
+ const ::rtl::OUString &rLh,
+ OQueryTableWindow* pRh,
+ OQueryTableConnectionData* pData
+ )
+ {
+ return BuildJoin(_xConnection,rLh,BuildTable(_xConnection,pRh),pData);
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString BuildJoin( const Reference< XConnection>& _xConnection,
+ OQueryTableWindow* pLh,
+ const ::rtl::OUString &rRh,
+ OQueryTableConnectionData* pData
+ )
+ {
+ return BuildJoin(_xConnection,BuildTable(_xConnection,pLh),rRh,pData);
+ }
+ //------------------------------------------------------------------------------
+ void GetNextJoin( const Reference< XConnection>& _xConnection,
+ OQueryTableConnection* pEntryConn,
+ OQueryTableWindow* pEntryTabTo,
+ ::rtl::OUString &aJoin)
+ {
+ OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get());
+ if ( pEntryConnData->GetJoinType() == INNER_JOIN && !pEntryConnData->isNatural() )
+ return;
+
+ if(!aJoin.getLength())
+ {
+ OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
+ aJoin = BuildJoin(_xConnection,pEntryTabFrom,pEntryTabTo,pEntryConnData);
+ }
+ else if(pEntryTabTo == pEntryConn->GetDestWin())
+ {
+ aJoin = BuildJoin(_xConnection,aJoin,pEntryTabTo,pEntryConnData);
+ }
+ else if(pEntryTabTo == pEntryConn->GetSourceWin())
+ {
+ aJoin = BuildJoin(_xConnection,pEntryTabTo,aJoin,pEntryConnData);
+ }
+
+ pEntryConn->SetVisited(sal_True);
+
+ // first search for the "to" window
+ const ::std::vector<OTableConnection*>* pConnections = pEntryConn->GetParent()->getTableConnections();
+ ::std::vector<OTableConnection*>::const_iterator aIter = pConnections->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter);
+ if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabTo || pNext->GetDestWin() == pEntryTabTo))
+ {
+ OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabTo ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
+ // exists there a connection to a OQueryTableWindow that holds a connection that has been already visited
+ JoinCycle(_xConnection,pNext,pEntryTab,aJoin);
+ if(!pNext->IsVisited())
+ GetNextJoin(_xConnection,pNext,pEntryTab,aJoin);
+ }
+ }
+
+ // when nothing found found look for the "from" window
+ if(aIter == aEnd)
+ {
+ OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
+ aIter = pConnections->begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(*aIter);
+ if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabFrom || pNext->GetDestWin() == pEntryTabFrom))
+ {
+ OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabFrom ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
+ // exists there a connection to a OQueryTableWindow that holds a connection that has been already visited
+ JoinCycle(_xConnection,pNext,pEntryTab,aJoin);
+ if(!pNext->IsVisited())
+ GetNextJoin(_xConnection,pNext,pEntryTab,aJoin);
+ }
+ }
+ }
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError InsertJoinConnection( const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode *pNode,
+ const EJoinType& _eJoinType,
+ const ::connectivity::OSQLParseNode *pLeftTable,
+ const ::connectivity::OSQLParseNode *pRightTable)
+ {
+ SqlParseError eErrorCode = eOk;
+ if (pNode->count() == 3 && // Ausdruck is geklammert
+ SQL_ISPUNCTUATION(pNode->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pNode->getChild(2),")"))
+ {
+ eErrorCode = InsertJoinConnection(_pView,pNode->getChild(1), _eJoinType,pLeftTable,pRightTable);
+ }
+ else if (SQL_ISRULEOR2(pNode,search_condition,boolean_term) && // AND/OR-Verknuepfung:
+ pNode->count() == 3)
+ {
+ // nur AND Verknüpfung zulassen
+ if (!SQL_ISTOKEN(pNode->getChild(1),AND))
+ eErrorCode = eIllegalJoinCondition;
+ else if ( eOk == (eErrorCode = InsertJoinConnection(_pView,pNode->getChild(0), _eJoinType,pLeftTable,pRightTable)) )
+ eErrorCode = InsertJoinConnection(_pView,pNode->getChild(2), _eJoinType,pLeftTable,pRightTable);
+ }
+ else if (SQL_ISRULE(pNode,comparison_predicate))
+ {
+ // only the comparison of columns is allowed
+ OSL_ENSURE(pNode->count() == 3,"OQueryDesignView::InsertJoinConnection: Fehler im Parse Tree");
+ if (!(SQL_ISRULE(pNode->getChild(0),column_ref) &&
+ SQL_ISRULE(pNode->getChild(2),column_ref) &&
+ pNode->getChild(1)->getNodeType() == SQL_NODE_EQUAL))
+ {
+ String sError(ModuleRes(STR_QRY_JOIN_COLUMN_COMPARE));
+ _pView->getController().appendError( sError );
+ return eIllegalJoin;
+ }
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ OTableFieldDescRef aDragRight = new OTableFieldDesc();
+ if ( eOk != ( eErrorCode = FillDragInfo(_pView,pNode->getChild(0),aDragLeft)) ||
+ eOk != ( eErrorCode = FillDragInfo(_pView,pNode->getChild(2),aDragRight)))
+ return eErrorCode;
+
+ if ( pLeftTable )
+ {
+ OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pLeftTable->getByRule(OSQLParseNode::table_ref) ));
+ if ( pLeftWindow == aDragLeft->GetTabWindow() )
+ insertConnection(_pView,_eJoinType,aDragLeft,aDragRight);
+ else
+ insertConnection(_pView,_eJoinType,aDragRight,aDragLeft);
+ }
+ else
+ insertConnection(_pView,_eJoinType,aDragLeft,aDragRight);
+ }
+ else
+ eErrorCode = eIllegalJoin;
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ sal_Bool GetInnerJoinCriteria( const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode *pCondition)
+ {
+ return InsertJoinConnection(_pView,pCondition, INNER_JOIN,NULL,NULL) != eOk;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString GenerateSelectList( const OQueryDesignView* _pView,
+ OTableFields& _rFieldList,
+ sal_Bool bAlias)
+ {
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
+ if ( !xConnection.is() )
+ return ::rtl::OUString();
+
+ ::rtl::OUStringBuffer aTmpStr,aFieldListStr;
+
+ sal_Bool bAsterix = sal_False;
+ int nVis = 0;
+ OTableFields::iterator aIter = _rFieldList.begin();
+ OTableFields::iterator aEnd = _rFieldList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ if ( pEntryField->IsVisible() )
+ {
+ if ( pEntryField->GetField().toChar() == '*' )
+ bAsterix = sal_True;
+ ++nVis;
+ }
+ }
+ if(nVis == 1)
+ bAsterix = sal_False;
+
+ try
+ {
+ const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+
+ OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap();
+
+ const static ::rtl::OUString sFieldSeparator(RTL_CONSTASCII_USTRINGPARAM(", "));
+ const static ::rtl::OUString s_sAs(RTL_CONSTASCII_USTRINGPARAM(" AS "));
+
+ aIter = _rFieldList.begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ ::rtl::OUString rFieldName = pEntryField->GetField();
+ if ( rFieldName.getLength() && pEntryField->IsVisible() )
+ {
+ aTmpStr = ::rtl::OUString();
+ const ::rtl::OUString rAlias = pEntryField->GetAlias();
+ const ::rtl::OUString rFieldAlias = pEntryField->GetFieldAlias();
+
+ aTmpStr.append(quoteTableAlias((bAlias || bAsterix),rAlias,aQuote));
+
+ // if we have a none numeric field, the table alias could be in the name
+ // otherwise we are not allowed to do this (e.g. 0.1 * PRICE )
+ if ( !pEntryField->isOtherFunction() )
+ {
+ // we have to look if we have alias.* here but before we have to check if the column doesn't already exist
+ String sTemp = rFieldName;
+ OTableFieldDescRef aInfo = new OTableFieldDesc();
+ OJoinTableView::OTableWindowMap::iterator tableIter = pTabList->begin();
+ OJoinTableView::OTableWindowMap::iterator tableEnd = pTabList->end();
+ sal_Bool bFound = sal_False;
+ for(;!bFound && tableIter != tableEnd ;++tableIter)
+ {
+ OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(tableIter->second);
+
+ bFound = pTabWin->ExistsField( rFieldName, aInfo );
+ if ( bFound )
+ rFieldName = aInfo->GetField();
+ }
+ if ( ( rFieldName.toChar() != '*' ) && ( rFieldName.indexOf( aQuote ) == -1 ) )
+ {
+ OSL_ENSURE(pEntryField->GetTable().getLength(),"No table field name!");
+ aTmpStr.append(::dbtools::quoteName(aQuote, rFieldName));
+ }
+ else
+ aTmpStr.append(rFieldName);
+ }
+ else
+ aTmpStr.append(rFieldName);
+
+ if ( pEntryField->isAggreateFunction() )
+ {
+ OSL_ENSURE(pEntryField->GetFunction().getLength(),"Functionname darf hier nicht leer sein! ;-(");
+ ::rtl::OUStringBuffer aTmpStr2( pEntryField->GetFunction());
+ aTmpStr2.appendAscii("(");
+ aTmpStr2.append(aTmpStr.makeStringAndClear());
+ aTmpStr2.appendAscii(")");
+ aTmpStr = aTmpStr2;
+ }
+
+ if (rFieldAlias.getLength() &&
+ (rFieldName.toChar() != '*' ||
+ pEntryField->isNumericOrAggreateFunction() ||
+ pEntryField->isOtherFunction()))
+ {
+ aTmpStr.append(s_sAs);
+ aTmpStr.append(::dbtools::quoteName(aQuote, rFieldAlias));
+ }
+ aFieldListStr.append(aTmpStr.makeStringAndClear());
+ aFieldListStr.append(sFieldSeparator);
+ }
+ }
+ if(aFieldListStr.getLength())
+ aFieldListStr.setLength(aFieldListStr.getLength()-2);
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("Failure while building select list!");
+ }
+ return aFieldListStr.makeStringAndClear();
+ }
+ //------------------------------------------------------------------------------
+ sal_Bool GenerateCriterias( OQueryDesignView* _pView,
+ ::rtl::OUStringBuffer& rRetStr,
+ ::rtl::OUStringBuffer& rHavingStr,
+ OTableFields& _rFieldList,
+ sal_Bool bMulti )
+ {
+ // * darf keine Filter enthalten : habe ich die entsprechende Warnung schon angezeigt ?
+ sal_Bool bCritsOnAsterikWarning = sal_False; // ** TMFS **
+
+ ::rtl::OUString aFieldName,aCriteria,aWhereStr,aHavingStr,aWork/*,aOrderStr*/;
+ // Zeilenweise werden die Ausdr"ucke mit AND verknuepft
+ sal_uInt16 nMaxCriteria = 0;
+ OTableFields::iterator aIter = _rFieldList.begin();
+ OTableFields::iterator aEnd = _rFieldList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ nMaxCriteria = ::std::max<sal_uInt16>(nMaxCriteria,(sal_uInt16)(*aIter)->GetCriteria().size());
+ }
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(_pView->getController()).getConnection();
+ if(!xConnection.is())
+ return sal_False;
+ try
+ {
+ const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+ const IParseContext& rContext = static_cast<OQueryController&>(_pView->getController()).getParser().getContext();
+
+ for (sal_uInt16 i=0 ; i < nMaxCriteria ; i++)
+ {
+ aHavingStr = aWhereStr = ::rtl::OUString();
+
+ for(aIter = _rFieldList.begin();aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ aFieldName = pEntryField->GetField();
+
+ if (!aFieldName.getLength())
+ continue;
+ aCriteria = pEntryField->GetCriteria( i );
+ if ( aCriteria.getLength() )
+ {
+ // * is not allowed to contain any filter, only when used in combination an aggregate function
+ if ( aFieldName.toChar() == '*' && pEntryField->isNoneFunction() )
+ {
+ // only show the messagebox the first time
+ if (!bCritsOnAsterikWarning)
+ ErrorBox(_pView, ModuleRes( ERR_QRY_CRITERIA_ON_ASTERISK)).Execute();
+ bCritsOnAsterikWarning = sal_True;
+ continue;
+ }
+ aWork = ::rtl::OUString();
+
+
+ aWork += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
+
+ if ( (pEntryField->GetFunctionType() & (FKT_OTHER|FKT_NUMERIC)) || (aFieldName.toChar() == '*') )
+ aWork += aFieldName;
+ else
+ aWork += ::dbtools::quoteName(aQuote, aFieldName);
+
+ if ( pEntryField->isAggreateFunction() || pEntryField->IsGroupBy() )
+ {
+ if (!aHavingStr.getLength()) // noch keine Kriterien
+ aHavingStr += ::rtl::OUString('('); // Klammern
+ else
+ aHavingStr += C_AND;
+
+ if ( pEntryField->isAggreateFunction() )
+ {
+ OSL_ENSURE(pEntryField->GetFunction().getLength(),"No function name for aggregate given!");
+ aHavingStr += pEntryField->GetFunction();
+ aHavingStr += ::rtl::OUString('('); // Klammern
+ aHavingStr += aWork;
+ aHavingStr += ::rtl::OUString(')'); // Klammern
+ }
+ else
+ aHavingStr += aWork;
+
+ ::rtl::OUString aTmp = aCriteria;
+ ::rtl::OUString aErrorMsg;
+ Reference<XPropertySet> xColumn;
+ ::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
+ if (pParseNode.get())
+ {
+ if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*')))
+ pParseNode->replaceNodeValue(pEntryField->GetAlias(),aFieldName);
+ ::rtl::OUString sHavingStr = aHavingStr;
+
+ sal_uInt32 nCount = pParseNode->count();
+ for( sal_uInt32 node = 1 ; node < nCount ; ++node)
+ pParseNode->getChild(node)->parseNodeToStr( sHavingStr,
+ xConnection,
+ &rContext,
+ sal_False,
+ !pEntryField->isOtherFunction());
+ aHavingStr = sHavingStr;
+ }
+ else
+ aHavingStr += aCriteria;
+ }
+ else
+ {
+ if ( !aWhereStr.getLength() ) // noch keine Kriterien
+ aWhereStr += ::rtl::OUString('('); // Klammern
+ else
+ aWhereStr += C_AND;
+
+ aWhereStr += ::rtl::OUString(' ');
+ // aCriteria could have some german numbers so I have to be sure here
+ ::rtl::OUString aTmp = aCriteria;
+ ::rtl::OUString aErrorMsg;
+ Reference<XPropertySet> xColumn;
+ ::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode( _pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
+ if (pParseNode.get())
+ {
+ if (bMulti && !(pEntryField->isOtherFunction() || (aFieldName.toChar() == '*')))
+ pParseNode->replaceNodeValue(pEntryField->GetAlias(),aFieldName);
+ ::rtl::OUString aWhere = aWhereStr;
+ pParseNode->parseNodeToStr( aWhere,
+ xConnection,
+ &rContext,
+ sal_False,
+ !pEntryField->isOtherFunction() );
+ aWhereStr = aWhere;
+ }
+ else
+ {
+ aWhereStr += aWork;
+ aWhereStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("="));
+ aWhereStr += aCriteria;
+ }
+ }
+ }
+ // nur einmal für jedes Feld
+ else if ( !i && pEntryField->isCondition() )
+ {
+ if (!aWhereStr.getLength()) // noch keine Kriterien
+ aWhereStr += ::rtl::OUString('('); // Klammern
+ else
+ aWhereStr += C_AND;
+ aWhereStr += pEntryField->GetField();
+ }
+ }
+ if (aWhereStr.getLength())
+ {
+ aWhereStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig
+ if (rRetStr.getLength()) // schon Feldbedingungen ?
+ rRetStr.append(C_OR);
+ else // Klammern auf fuer 'OR' Zweig
+ rRetStr.append(sal_Unicode('('));
+ rRetStr.append(aWhereStr);
+ }
+ if (aHavingStr.getLength())
+ {
+ aHavingStr += ::rtl::OUString(')'); // Klammern zu fuer 'AND' Zweig
+ if (rHavingStr.getLength()) // schon Feldbedingungen ?
+ rHavingStr.append(C_OR);
+ else // Klammern auf fuer 'OR' Zweig
+ rHavingStr.append(sal_Unicode('('));
+ rHavingStr.append(aHavingStr);
+ }
+ }
+
+ if (rRetStr.getLength())
+ rRetStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig
+ if (rHavingStr.getLength())
+ rHavingStr.append(sal_Unicode(')')); // Klammern zu fuer 'OR' Zweig
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("Failure while building where clause!");
+ }
+ return sal_True;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError GenerateOrder( OQueryDesignView* _pView,
+ OTableFields& _rFieldList,
+ sal_Bool bMulti,
+ ::rtl::OUString& _rsRet)
+ {
+ const OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ Reference< XConnection> xConnection = rController.getConnection();
+ if ( !xConnection.is() )
+ return eNoConnection;
+
+ SqlParseError eErrorCode = eOk;
+
+ ::rtl::OUString aColumnName;
+ ::rtl::OUString aWorkStr;
+ try
+ {
+ const bool bColumnAliasInOrderBy = rController.getSdbMetaData().supportsColumnAliasInOrderBy();
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+ // * darf keine Filter enthalten : habe ich die entsprechende Warnung schon angezeigt ?
+ sal_Bool bCritsOnAsterikWarning = sal_False; // ** TMFS **
+ OTableFields::iterator aIter = _rFieldList.begin();
+ OTableFields::iterator aEnd = _rFieldList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ EOrderDir eOrder = pEntryField->GetOrderDir();
+
+ // nur wenn eine Sortierung und ein Tabellenname vorhanden ist-> erzeugen
+ // sonst werden die Expressions vom Order By im GenerateCriteria mit erzeugt
+ if ( eOrder != ORDER_NONE )
+ {
+ aColumnName = pEntryField->GetField();
+ if(aColumnName.toChar() == '*')
+ {
+ // die entsprechende MessageBox nur beim ersten mal anzeigen
+ if (!bCritsOnAsterikWarning)
+ ErrorBox(_pView, ModuleRes( ERR_QRY_ORDERBY_ON_ASTERISK)).Execute();
+ bCritsOnAsterikWarning = sal_True;
+ continue;
+ }
+
+ if ( bColumnAliasInOrderBy && pEntryField->GetFieldAlias().getLength() )
+ {
+ aWorkStr += ::dbtools::quoteName(aQuote, pEntryField->GetFieldAlias());
+ }
+ else if ( pEntryField->isNumericOrAggreateFunction() )
+ {
+ OSL_ENSURE(pEntryField->GetFunction().getLength(),"Functionname darf hier nicht leer sein! ;-(");
+ aWorkStr += pEntryField->GetFunction();
+ aWorkStr += ::rtl::OUString('(');
+ aWorkStr += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
+ // only quote column name when we don't have a numeric
+ if ( pEntryField->isNumeric() )
+ aWorkStr += aColumnName;
+ else
+ aWorkStr += ::dbtools::quoteName(aQuote, aColumnName);
+
+ aWorkStr += ::rtl::OUString(')');
+ }
+ else if ( pEntryField->isOtherFunction() )
+ {
+ aWorkStr += aColumnName;
+ }
+ else
+ {
+ aWorkStr += quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
+ aWorkStr += ::dbtools::quoteName(aQuote, aColumnName);
+ }
+ aWorkStr += ::rtl::OUString(' ');
+ aWorkStr += String::CreateFromAscii( ";ASC;DESC" ).GetToken( (sal_uInt16)eOrder );
+ aWorkStr += ::rtl::OUString(',');
+ }
+ }
+
+ {
+ String sTemp(aWorkStr);
+ sTemp.EraseTrailingChars( ',' );
+ aWorkStr = sTemp;
+ }
+
+ if ( aWorkStr.getLength() )
+ {
+ const sal_Int32 nMaxOrder = xMetaData->getMaxColumnsInOrderBy();
+ String sToken(aWorkStr);
+ if ( nMaxOrder && nMaxOrder < sToken.GetTokenCount(',') )
+ eErrorCode = eStatementTooLong;
+ else
+ {
+ _rsRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ORDER BY "));
+ _rsRet += aWorkStr;
+ }
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("Failure while building group by!");
+ }
+
+ return eErrorCode;
+ }
+
+ //------------------------------------------------------------------------------
+ void GenerateInnerJoinCriterias(const Reference< XConnection>& _xConnection,
+ ::rtl::OUString& _rJoinCrit,
+ const ::std::vector<OTableConnection*>* _pConnList)
+ {
+ ::std::vector<OTableConnection*>::const_iterator aIter = _pConnList->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = _pConnList->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ const OQueryTableConnection* pEntryConn = static_cast<const OQueryTableConnection*>(*aIter);
+ OQueryTableConnectionData* pEntryConnData = static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get());
+ if ( pEntryConnData->GetJoinType() == INNER_JOIN && !pEntryConnData->isNatural() )
+ {
+ if(_rJoinCrit.getLength())
+ _rJoinCrit += C_AND;
+ _rJoinCrit += BuildJoinCriteria(_xConnection,pEntryConnData->GetConnLineDataList(),pEntryConnData);
+ }
+ }
+ }
+ //------------------------------------------------------------------------------
+ void searchAndAppendName(const Reference< XConnection>& _xConnection,
+ const OQueryTableWindow* _pTableWindow,
+ ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess>& _rTableNames,
+ ::rtl::OUString& _rsTableListStr
+ )
+ {
+ ::rtl::OUString sTabName(BuildTable(_xConnection,_pTableWindow));
+
+ if(_rTableNames.find(sTabName) == _rTableNames.end())
+ {
+ _rTableNames[sTabName] = sal_True;
+ _rsTableListStr += sTabName;
+ _rsTableListStr += ::rtl::OUString(',');
+ }
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString GenerateFromClause( const Reference< XConnection>& _xConnection,
+ const OQueryTableView::OTableWindowMap* pTabList,
+ const ::std::vector<OTableConnection*>* pConnList
+ )
+ {
+
+ ::rtl::OUString aTableListStr;
+ // wird gebraucht um sicher zustelllen das eine Tabelle nicht doppelt vorkommt
+ ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aTableNames;
+
+ // generate outer join clause in from
+ if(!pConnList->empty())
+ {
+ ::std::vector<OTableConnection*>::const_iterator aIter = pConnList->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pConnList->end();
+ ::std::map<OTableWindow*,sal_Int32> aConnectionCount;
+ for(;aIter != aEnd;++aIter)
+ {
+ static_cast<OQueryTableConnection*>(*aIter)->SetVisited(sal_False);
+ if ( aConnectionCount.find((*aIter)->GetSourceWin()) == aConnectionCount.end() )
+ aConnectionCount.insert(::std::map<OTableWindow*,sal_Int32>::value_type((*aIter)->GetSourceWin(),0));
+ else
+ aConnectionCount[(*aIter)->GetSourceWin()]++;
+ if ( aConnectionCount.find((*aIter)->GetDestWin()) == aConnectionCount.end() )
+ aConnectionCount.insert(::std::map<OTableWindow*,sal_Int32>::value_type((*aIter)->GetDestWin(),0));
+ else
+ aConnectionCount[(*aIter)->GetDestWin()]++;
+ }
+ ::std::multimap<sal_Int32 , OTableWindow*> aMulti;
+ ::std::map<OTableWindow*,sal_Int32>::iterator aCountIter = aConnectionCount.begin();
+ ::std::map<OTableWindow*,sal_Int32>::iterator aCountEnd = aConnectionCount.end();
+ for(;aCountIter != aCountEnd;++aCountIter)
+ {
+ aMulti.insert(::std::multimap<sal_Int32 , OTableWindow*>::value_type(aCountIter->second,aCountIter->first));
+ }
+
+ const sal_Bool bUseEscape = ::dbtools::getBooleanDataSourceSetting( _xConnection, PROPERTY_OUTERJOINESCAPE );
+ ::std::multimap<sal_Int32 , OTableWindow*>::reverse_iterator aRIter = aMulti.rbegin();
+ ::std::multimap<sal_Int32 , OTableWindow*>::reverse_iterator aREnd = aMulti.rend();
+ for(;aRIter != aREnd;++aRIter)
+ {
+ ::std::vector<OTableConnection*>::const_iterator aConIter = aRIter->second->getTableView()->getTableConnections(aRIter->second);
+ for(;aConIter != aEnd;++aConIter)
+ {
+ OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aConIter);
+ if(!pEntryConn->IsVisited() && pEntryConn->GetSourceWin() == aRIter->second )
+ {
+ ::rtl::OUString aJoin;
+ GetNextJoin(_xConnection,pEntryConn,static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin()),aJoin);
+
+ if(aJoin.getLength())
+ {
+ // insert tables into table list to avoid double entries
+ OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
+ OQueryTableWindow* pEntryTabTo = static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin());
+
+ ::rtl::OUString sTabName(BuildTable(_xConnection,pEntryTabFrom));
+ if(aTableNames.find(sTabName) == aTableNames.end())
+ aTableNames[sTabName] = sal_True;
+ sTabName = BuildTable(_xConnection,pEntryTabTo);
+ if(aTableNames.find(sTabName) == aTableNames.end())
+ aTableNames[sTabName] = sal_True;
+
+ ::rtl::OUString aStr;
+ switch(static_cast<OQueryTableConnectionData*>(pEntryConn->GetData().get())->GetJoinType())
+ {
+ case LEFT_JOIN:
+ case RIGHT_JOIN:
+ case FULL_JOIN:
+ {
+ // create outer join
+ if ( bUseEscape )
+ aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("{ OJ "));
+ aStr += aJoin;
+ if ( bUseEscape )
+ aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" }"));
+ }
+ break;
+ default:
+ aStr += aJoin;
+ break;
+ }
+ aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ aTableListStr += aStr;
+ }
+ }
+ }
+ }
+
+ // and now all inner joins
+ aIter = pConnList->begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableConnection* pEntryConn = static_cast<OQueryTableConnection*>(*aIter);
+ if(!pEntryConn->IsVisited())
+ {
+ searchAndAppendName(_xConnection,
+ static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin()),
+ aTableNames,
+ aTableListStr);
+
+ searchAndAppendName(_xConnection,
+ static_cast<OQueryTableWindow*>(pEntryConn->GetDestWin()),
+ aTableNames,
+ aTableListStr);
+ }
+ }
+ }
+ // all tables that haven't a connection to anyone
+ OQueryTableView::OTableWindowMap::const_iterator aTabIter = pTabList->begin();
+ OQueryTableView::OTableWindowMap::const_iterator aTabEnd = pTabList->end();
+ for(;aTabIter != aTabEnd;++aTabIter)
+ {
+ const OQueryTableWindow* pEntryTab = static_cast<const OQueryTableWindow*>(aTabIter->second);
+ if(!pEntryTab->ExistsAConn())
+ {
+ aTableListStr += BuildTable(_xConnection,pEntryTab);
+ aTableListStr += ::rtl::OUString(',');
+ }
+ }
+
+ if(aTableListStr.getLength())
+ aTableListStr = aTableListStr.replaceAt(aTableListStr.getLength()-1,1, ::rtl::OUString() );
+ return aTableListStr;
+ }
+ //------------------------------------------------------------------------------
+ ::rtl::OUString GenerateGroupBy(const OQueryDesignView* _pView,OTableFields& _rFieldList, sal_Bool bMulti )
+ {
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ const Reference< XConnection> xConnection = rController.getConnection();
+ if(!xConnection.is())
+ return ::rtl::OUString();
+
+ ::std::map< rtl::OUString,bool> aGroupByNames;
+
+ ::rtl::OUString aGroupByStr;
+ try
+ {
+ const Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ const ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString();
+
+ OTableFields::iterator aIter = _rFieldList.begin();
+ OTableFields::iterator aEnd = _rFieldList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ if ( pEntryField->IsGroupBy() )
+ {
+ OSL_ENSURE(pEntryField->GetField().getLength(),"Kein FieldName vorhanden!;-(");
+ ::rtl::OUString sGroupByPart = quoteTableAlias(bMulti,pEntryField->GetAlias(),aQuote);
+
+ // only quote the field name when it isn't calculated
+ if ( pEntryField->isNoneFunction() )
+ {
+ sGroupByPart += ::dbtools::quoteName(aQuote, pEntryField->GetField());
+ }
+ else
+ {
+ ::rtl::OUString aTmp = pEntryField->GetField();
+ ::rtl::OUString aErrorMsg;
+ Reference<XPropertySet> xColumn;
+ ::std::auto_ptr< ::connectivity::OSQLParseNode> pParseNode(_pView->getPredicateTreeFromEntry(pEntryField,aTmp,aErrorMsg,xColumn));
+ if (pParseNode.get())
+ {
+ ::rtl::OUString sGroupBy;
+ pParseNode->getChild(0)->parseNodeToStr( sGroupBy,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_False,
+ !pEntryField->isOtherFunction());
+ sGroupByPart += sGroupBy;
+ }
+ else
+ sGroupByPart += pEntryField->GetField();
+ }
+ if ( aGroupByNames.find(sGroupByPart) == aGroupByNames.end() )
+ {
+ aGroupByNames.insert(::std::map< rtl::OUString,bool>::value_type(sGroupByPart,true));
+ aGroupByStr += sGroupByPart;
+ aGroupByStr += ::rtl::OUString(',');
+ }
+ }
+ }
+ if ( aGroupByStr.getLength() )
+ {
+ aGroupByStr = aGroupByStr.replaceAt(aGroupByStr.getLength()-1,1, ::rtl::OUString(' ') );
+ ::rtl::OUString aGroupByStr2(RTL_CONSTASCII_USTRINGPARAM(" GROUP BY "));
+ aGroupByStr2 += aGroupByStr;
+ aGroupByStr = aGroupByStr2;
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("Failure while building group by!");
+ }
+ return aGroupByStr;
+ }
+ // -----------------------------------------------------------------------------
+ SqlParseError GetORCriteria(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ sal_uInt16& nLevel ,
+ sal_Bool bHaving = sal_False,
+ bool bAddOrOnOneLine = false);
+ // -----------------------------------------------------------------------------
+ SqlParseError GetSelectionCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pNode,
+ sal_uInt16& rLevel )
+ {
+ if (!SQL_ISRULE(pNode, select_statement))
+ return eNoSelectStatement;
+
+ // nyi: mehr Pruefung auf korrekte Struktur!
+ pNode = pNode ? pNode->getChild(3)->getChild(1) : NULL;
+ // no where clause found
+ if (!pNode || pNode->isLeaf())
+ return eOk;
+
+ // Naechster freier Satz ...
+ SqlParseError eErrorCode = eOk;
+ ::connectivity::OSQLParseNode * pCondition = pNode->getChild(1);
+ if ( pCondition ) // no where clause
+ {
+ // now we have to chech the other conditions
+ // first make the logical easier
+ ::connectivity::OSQLParseNode::negateSearchCondition(pCondition);
+ ::connectivity::OSQLParseNode *pNodeTmp = pNode->getChild(1);
+
+ ::connectivity::OSQLParseNode::disjunctiveNormalForm(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
+ ::connectivity::OSQLParseNode::absorptions(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
+ // compress sort the criteria @see http://www.openoffice.org/issues/show_bug.cgi?id=24079
+ OSQLParseNode::compress(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
+
+ // first extract the inner joins conditions
+ GetInnerJoinCriteria(_pView,pNodeTmp);
+ // now simplify again, join are checked in ComparisonPredicate
+ ::connectivity::OSQLParseNode::absorptions(pNodeTmp);
+ pNodeTmp = pNode->getChild(1);
+
+ // it could happen that pCondition is not more valid
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pNodeTmp, rLevel);
+ }
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError GetANDCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ sal_uInt16& nLevel,
+ sal_Bool bHaving,
+ bool bAddOrOnOneLine);
+ //------------------------------------------------------------------------------
+ SqlParseError ComparisonPredicate(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ const sal_uInt16 nLevel,
+ sal_Bool bHaving,
+ bool bAddOrOnOneLine);
+ //------------------------------------------------------------------------------
+ SqlParseError GetORCriteria(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ sal_uInt16& nLevel ,
+ sal_Bool bHaving,
+ bool bAddOrOnOneLine)
+ {
+ SqlParseError eErrorCode = eOk;
+
+ // Runde Klammern um den Ausdruck
+ if (pCondition->count() == 3 &&
+ SQL_ISPUNCTUATION(pCondition->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pCondition->getChild(2),")"))
+ {
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pCondition->getChild(1),nLevel,bHaving,bAddOrOnOneLine);
+ }
+ // oder Verknuepfung
+ // a searchcondition can only look like this: search_condition SQL_TOKEN_OR boolean_term
+ else if (SQL_ISRULE(pCondition,search_condition))
+ {
+ for (int i = 0; i < 3 && eErrorCode == eOk ; i+=2)
+ {
+ const ::connectivity::OSQLParseNode* pChild = pCondition->getChild(i);
+ if ( SQL_ISRULE(pChild,search_condition) )
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pChild,nLevel,bHaving,bAddOrOnOneLine);
+ else
+ {
+ eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pChild, nLevel,bHaving, i == 0 ? false : bAddOrOnOneLine);
+ if ( !bAddOrOnOneLine)
+ nLevel++;
+ }
+ }
+ }
+ else
+ eErrorCode = GetANDCriteria( _pView,_pSelectionBrw,pCondition, nLevel, bHaving,bAddOrOnOneLine );
+
+ return eErrorCode;
+ }
+ //--------------------------------------------------------------------------------------------------
+ bool CheckOrCriteria(const ::connectivity::OSQLParseNode* _pCondition,::connectivity::OSQLParseNode* _pFirstColumnRef)
+ {
+ bool bRet = true;
+ ::connectivity::OSQLParseNode* pFirstColumnRef = _pFirstColumnRef;
+ for (int i = 0; i < 3 && bRet; i+=2)
+ {
+ const ::connectivity::OSQLParseNode* pChild = _pCondition->getChild(i);
+ if ( SQL_ISRULE(pChild,search_condition) )
+ bRet = CheckOrCriteria(pChild,pFirstColumnRef);
+ else
+ {
+ // this is a simple way to test columns are the same, may be we have to adjust this algo a little bit in future. :-)
+ ::connectivity::OSQLParseNode* pSecondColumnRef = pChild->getByRule(::connectivity::OSQLParseNode::column_ref);
+ if ( pFirstColumnRef && pSecondColumnRef )
+ bRet = *pFirstColumnRef == *pSecondColumnRef;
+ else if ( !pFirstColumnRef )
+ pFirstColumnRef = pSecondColumnRef;
+ }
+ }
+ return bRet;
+ }
+ //--------------------------------------------------------------------------------------------------
+ SqlParseError GetANDCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ sal_uInt16& nLevel,
+ sal_Bool bHaving,
+ bool bAddOrOnOneLine)
+ {
+ const ::com::sun::star::lang::Locale aLocale = _pView->getLocale();
+ const ::rtl::OUString sDecimal = _pView->getDecimalSeparator();
+
+ // ich werde ein paar Mal einen gecasteten Pointer auf meinen ::com::sun::star::sdbcx::Container brauchen
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ SqlParseError eErrorCode = eOk;
+
+ // Runde Klammern
+ if (SQL_ISRULE(pCondition,boolean_primary))
+ {
+ // check if we have to put the or criteria on one line.
+ const ::connectivity::OSQLParseNode* pSearchCondition = pCondition->getChild(1);
+ bool bMustAddOrOnOneLine = CheckOrCriteria(pSearchCondition,NULL);
+ if ( SQL_ISRULE( pSearchCondition, search_condition) ) // we have a or
+ {
+ _pSelectionBrw->DuplicateConditionLevel( nLevel);
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(0), nLevel,bHaving,bMustAddOrOnOneLine );
+ ++nLevel;
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition->getChild(2), nLevel,bHaving,bMustAddOrOnOneLine );
+ }
+ else
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSearchCondition, nLevel,bHaving,bMustAddOrOnOneLine );
+ }
+ // Das erste Element ist (wieder) eine AND-Verknuepfung
+ else if ( SQL_ISRULE(pCondition,boolean_term) )
+ {
+ OSL_ENSURE(pCondition->count() == 3,"Illegal definifiton of boolean_term");
+ eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pCondition->getChild(0), nLevel,bHaving,bAddOrOnOneLine );
+ if ( eErrorCode == eOk )
+ eErrorCode = GetANDCriteria(_pView,_pSelectionBrw,pCondition->getChild(2), nLevel,bHaving,bAddOrOnOneLine );
+ }
+ else if (SQL_ISRULE( pCondition, comparison_predicate))
+ {
+ eErrorCode = ComparisonPredicate(_pView,_pSelectionBrw,pCondition,nLevel,bHaving,bAddOrOnOneLine);
+ }
+ else if( SQL_ISRULE(pCondition,like_predicate) )
+ {
+ const ::connectivity::OSQLParseNode* pValueExp = pCondition->getChild(0);
+ if (SQL_ISRULE(pValueExp, column_ref ) )
+ {
+ ::rtl::OUString aColumnName;
+ ::rtl::OUString aCondition;
+ Reference< XConnection> xConnection = rController.getConnection();
+ if ( xConnection.is() )
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ // the international doesn't matter I have a string
+ pCondition->parseNodeToPredicateStr(aCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ aLocale,
+ static_cast<sal_Char>(sDecimal.toChar()),
+ &rController.getParser().getContext());
+
+ pValueExp->parseNodeToPredicateStr( aColumnName,
+ xConnection,
+ rController.getNumberFormatter(),
+ aLocale,
+ static_cast<sal_Char>(sDecimal.toChar()),
+ &rController.getParser().getContext());
+
+ // don't display the column name
+ aCondition = aCondition.copy(aColumnName.getLength());
+ aCondition = aCondition.trim();
+ }
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ if ( eOk == ( eErrorCode = FillDragInfo(_pView,pValueExp,aDragLeft) ))
+ {
+ if ( bHaving )
+ aDragLeft->SetGroupBy(sal_True);
+ _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
+ }
+ }
+ else if(SQL_ISRULEOR2(pValueExp,general_set_fct ,set_fct_spec) ||
+ SQL_ISRULEOR2(pValueExp,position_exp,extract_exp) ||
+ SQL_ISRULEOR2(pValueExp,fold,char_substring_fct) ||
+ SQL_ISRULEOR2(pValueExp,length_exp,char_value_fct))
+ {
+ AddFunctionCondition( _pView,
+ _pSelectionBrw,
+ pCondition,
+ nLevel,
+ bHaving,
+ bAddOrOnOneLine);
+ }
+ else
+ {
+ eErrorCode = eNoColumnInLike;
+ String sError(ModuleRes(STR_QRY_LIKE_LEFT_NO_COLUMN));
+ _pView->getController().appendError( sError );
+ }
+ }
+ else if( SQL_ISRULEOR2(pCondition,test_for_null,in_predicate)
+ || SQL_ISRULEOR2(pCondition,all_or_any_predicate,between_predicate))
+ {
+ if ( SQL_ISRULEOR2(pCondition->getChild(0), set_fct_spec , general_set_fct ) )
+ {
+ AddFunctionCondition( _pView,
+ _pSelectionBrw,
+ pCondition,
+ nLevel,
+ bHaving,
+ bAddOrOnOneLine);
+ }
+ else if ( SQL_ISRULE(pCondition->getChild(0), column_ref ) )
+ {
+ // parse condition
+ ::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1);
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ if ( eOk == ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(0),aDragLeft)) )
+ {
+ if ( bHaving )
+ aDragLeft->SetGroupBy(sal_True);
+ _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
+ }
+ }
+ else
+ {
+ // Funktions-Bedingung parsen
+ ::rtl::OUString sCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,1);
+ Reference< XConnection> xConnection = rController.getConnection();
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ // the international doesn't matter I have a string
+ ::rtl::OUString sName;
+ pCondition->getChild(0)->parseNodeToPredicateStr(sName,
+ xConnection,
+ rController.getNumberFormatter(),
+ aLocale,
+ static_cast<sal_Char>(sDecimal.toChar()),
+ &rController.getParser().getContext());
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetField(sName);
+ aDragLeft->SetFunctionType(FKT_OTHER);
+
+ if ( bHaving )
+ aDragLeft->SetGroupBy(sal_True);
+ _pSelectionBrw->AddCondition(aDragLeft, sCondition, nLevel,bAddOrOnOneLine);
+ }
+ }
+ else if( SQL_ISRULEOR2(pCondition,existence_test,unique_test) )
+ {
+ // Funktions-Bedingung parsen
+ ::rtl::OUString aCondition = ParseCondition(rController,pCondition,sDecimal,aLocale,0);
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetField(aCondition);
+ aDragLeft->SetFunctionType(FKT_CONDITION);
+
+ eErrorCode = _pSelectionBrw->InsertField(aDragLeft,BROWSER_INVALIDID,sal_False,sal_True).is() ? eOk : eTooManyColumns;
+ }
+ else //! TODO not supported yet
+ eErrorCode = eStatementTooComplex;
+ // Fehler einfach weiterreichen.
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError AddFunctionCondition(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ const sal_uInt16 nLevel,
+ sal_Bool bHaving,
+ bool bAddOrOnOneLine)
+ {
+ SqlParseError eErrorCode = eOk;
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+
+ OSQLParseNode* pFunction = pCondition->getChild(0);
+
+ OSL_ENSURE(SQL_ISRULEOR2(pFunction,general_set_fct ,set_fct_spec) ||
+ SQL_ISRULEOR2(pFunction,position_exp,extract_exp) ||
+ SQL_ISRULEOR2(pFunction,fold,char_substring_fct) ||
+ SQL_ISRULEOR2(pFunction,length_exp,char_value_fct),"Illegal call!");
+ ::rtl::OUString aCondition;
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+
+ ::rtl::OUString aColumnName;
+ Reference< XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ pCondition->parseNodeToPredicateStr(aCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ _pView->getLocale(),
+ static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ &rController.getParser().getContext());
+
+ pFunction->parseNodeToStr( aColumnName,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True,
+ sal_True); // quote is to true because we need quoted elements inside the function
+ // don't display the column name
+ aCondition = aCondition.copy(aColumnName.getLength());
+ aCondition = aCondition.trim();
+ if ( aCondition.indexOf('=',0) == 0 ) // ignore the equal sign
+ aCondition = aCondition.copy(1);
+
+
+ if ( SQL_ISRULE(pFunction, general_set_fct ) )
+ {
+ sal_Int32 nFunctionType = FKT_AGGREGATE;
+ OSQLParseNode* pParamNode = pFunction->getChild(pFunction->count()-2);
+ if ( pParamNode && pParamNode->getTokenValue().toChar() == '*' )
+ {
+ OJoinTableView::OTableWindowMap* pTabList = _pView->getTableView()->GetTabWinMap();
+ OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin();
+ OJoinTableView::OTableWindowMap::iterator aTabEnd = pTabList->end();
+ for(;aIter != aTabEnd;++aIter)
+ {
+ OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
+ if (pTabWin->ExistsField( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), aDragLeft ))
+ {
+ aDragLeft->SetAlias(String());
+ aDragLeft->SetTable(String());
+ break;
+ }
+ }
+ }
+ else if( eOk != ( eErrorCode = FillDragInfo(_pView,pParamNode,aDragLeft))
+ && SQL_ISRULE(pParamNode,num_value_exp) )
+ {
+ ::rtl::OUString sParameterValue;
+ pParamNode->parseNodeToStr( sParameterValue,
+ xConnection,
+ &rController.getParser().getContext());
+ nFunctionType |= FKT_NUMERIC;
+ aDragLeft->SetField(sParameterValue);
+ eErrorCode = eOk;
+ }
+ aDragLeft->SetFunctionType(nFunctionType);
+ if ( bHaving )
+ aDragLeft->SetGroupBy(sal_True);
+ sal_Int32 nIndex = 0;
+ aDragLeft->SetFunction(aColumnName.getToken(0,'(',nIndex));
+ }
+ else
+ {
+ // bei unbekannten Funktionen wird der gesamte Text in das Field gechrieben
+ aDragLeft->SetField(aColumnName);
+ if(bHaving)
+ aDragLeft->SetGroupBy(sal_True);
+ aDragLeft->SetFunctionType(FKT_OTHER|FKT_NUMERIC);
+ }
+ _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
+ }
+
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError ComparisonPredicate(OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode * pCondition,
+ const sal_uInt16 nLevel,
+ sal_Bool bHaving
+ ,bool bAddOrOnOneLine)
+ {
+ SqlParseError eErrorCode = eOk;
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+
+ OSL_ENSURE(SQL_ISRULE( pCondition, comparison_predicate),"ComparisonPredicate: pCondition ist kein ComparisonPredicate");
+ if ( SQL_ISRULE(pCondition->getChild(0), column_ref )
+ || SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref) )
+ {
+ ::rtl::OUString aCondition;
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+
+ if ( SQL_ISRULE(pCondition->getChild(0), column_ref ) && SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref ) )
+ {
+ OTableFieldDescRef aDragRight = new OTableFieldDesc();
+ if (eOk != ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(0),aDragLeft)) ||
+ eOk != ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(2),aDragRight)))
+ return eErrorCode;
+
+ OQueryTableConnection* pConn = static_cast<OQueryTableConnection*>(
+ _pView->getTableView()->GetTabConn(static_cast<OQueryTableWindow*>(aDragLeft->GetTabWindow()),
+ static_cast<OQueryTableWindow*>(aDragRight->GetTabWindow()),
+ true));
+ if ( pConn )
+ {
+ OConnectionLineDataVec* pLineDataList = pConn->GetData()->GetConnLineDataList();
+ OConnectionLineDataVec::iterator aIter = pLineDataList->begin();
+ OConnectionLineDataVec::iterator aEnd = pLineDataList->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if((*aIter)->GetSourceFieldName() == aDragLeft->GetField() ||
+ (*aIter)->GetDestFieldName() == aDragLeft->GetField() )
+ break;
+ }
+ if(aIter != aEnd)
+ return eOk;
+ }
+ }
+
+ sal_uInt32 nPos = 0;
+ if(SQL_ISRULE(pCondition->getChild(0), column_ref ))
+ {
+ nPos = 0;
+ sal_uInt32 i=1;
+
+ // don't display the equal
+ if (pCondition->getChild(i)->getNodeType() == SQL_NODE_EQUAL)
+ i++;
+
+ // Bedingung parsen
+ aCondition = ParseCondition(rController
+ ,pCondition
+ ,_pView->getDecimalSeparator()
+ ,_pView->getLocale()
+ ,i);
+ }
+ else if( SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref ) )
+ {
+ nPos = pCondition->count()-1;
+
+ sal_Int32 i = static_cast<sal_Int32>(pCondition->count() - 2);
+ switch (pCondition->getChild(i)->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // don't display the equal
+ i--;
+ break;
+ case SQL_NODE_LESS:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">"));
+ break;
+ case SQL_NODE_LESSEQ:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(">="));
+ break;
+ case SQL_NODE_GREAT:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<"));
+ break;
+ case SQL_NODE_GREATEQ:
+ // take the opposite as we change the order
+ i--;
+ aCondition = aCondition + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<="));
+ break;
+ default:
+ break;
+ }
+
+ // go backward
+ Reference< XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ for (; i >= 0; i--)
+ pCondition->getChild(i)->parseNodeToPredicateStr(aCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ _pView->getLocale(),
+ static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ &rController.getParser().getContext());
+ }
+ }
+ // else ???
+
+
+ if( eOk == ( eErrorCode = FillDragInfo(_pView,pCondition->getChild(nPos),aDragLeft)))
+ {
+ if(bHaving)
+ aDragLeft->SetGroupBy(sal_True);
+ _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
+ }
+ }
+ else if( SQL_ISRULEOR2(pCondition->getChild(0), set_fct_spec , general_set_fct ) )
+ {
+ AddFunctionCondition( _pView,
+ _pSelectionBrw,
+ pCondition,
+ nLevel,
+ bHaving,
+ bAddOrOnOneLine);
+ }
+ else // kann sich nur um einen Expr. Ausdruck handeln
+ {
+ ::rtl::OUString aName,aCondition;
+
+ ::connectivity::OSQLParseNode *pLhs = pCondition->getChild(0);
+ ::connectivity::OSQLParseNode *pRhs = pCondition->getChild(2);
+ // Feldnamen
+ Reference< XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ pLhs->parseNodeToStr(aName,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True);
+ // Kriterium
+ aCondition = pCondition->getChild(1)->getTokenValue();
+ pRhs->parseNodeToPredicateStr(aCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ _pView->getLocale(),
+ static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ &rController.getParser().getContext());
+ }
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetField(aName);
+ aDragLeft->SetFunctionType(FKT_OTHER|FKT_NUMERIC);
+ // und anh"angen
+ _pSelectionBrw->AddCondition(aDragLeft, aCondition, nLevel,bAddOrOnOneLine);
+ }
+ return eErrorCode;
+ }
+
+ //------------------------------------------------------------------------------
+ namespace
+ {
+ OQueryTableWindow* lcl_findColumnInTables( const ::rtl::OUString& _rColumName, const OJoinTableView::OTableWindowMap& _rTabList, OTableFieldDescRef& _rInfo )
+ {
+ OJoinTableView::OTableWindowMap::const_iterator aIter = _rTabList.begin();
+ OJoinTableView::OTableWindowMap::const_iterator aEnd = _rTabList.end();
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ OQueryTableWindow* pTabWin = static_cast< OQueryTableWindow* >( aIter->second );
+ if ( pTabWin && pTabWin->ExistsField( _rColumName, _rInfo ) )
+ return pTabWin;
+ }
+ return NULL;
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void InsertColumnRef(const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode * pColumnRef,
+ ::rtl::OUString& aColumnName,
+ const ::rtl::OUString& aColumnAlias,
+ ::rtl::OUString& aTableRange,
+ OTableFieldDescRef& _raInfo,
+ OJoinTableView::OTableWindowMap* pTabList)
+ {
+
+ // Tabellennamen zusammen setzen
+ ::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator();
+ rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange );
+
+ sal_Bool bFound(sal_False);
+ OSL_ENSURE(aColumnName.getLength(),"Columnname darf nicht leer sein");
+ if (!aTableRange.getLength())
+ {
+ // SELECT column, ...
+ bFound = NULL != lcl_findColumnInTables( aColumnName, *pTabList, _raInfo );
+ if ( bFound && ( aColumnName.toChar() != '*' ) )
+ _raInfo->SetFieldAlias(aColumnAlias);
+ }
+ else
+ {
+ // SELECT range.column, ...
+ OQueryTableWindow* pTabWin = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable(aTableRange);
+
+ if (pTabWin && pTabWin->ExistsField(aColumnName, _raInfo))
+ {
+ if(aColumnName.toChar() != '*')
+ _raInfo->SetFieldAlias(aColumnAlias);
+ bFound = sal_True;
+ }
+ }
+ if (!bFound)
+ {
+ _raInfo->SetTable(::rtl::OUString());
+ _raInfo->SetAlias(::rtl::OUString());
+ _raInfo->SetField(aColumnName);
+ _raInfo->SetFieldAlias(aColumnAlias); // nyi : hier ein fortlaufendes Expr_1, Expr_2 ...
+ _raInfo->SetFunctionType(FKT_OTHER);
+ }
+ }
+ //-----------------------------------------------------------------------------
+ sal_Bool checkJoinConditions( const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode* _pNode )
+ {
+ const ::connectivity::OSQLParseNode* pJoinNode = NULL;
+ sal_Bool bRet = sal_True;
+ if (SQL_ISRULE(_pNode,qualified_join))
+ pJoinNode = _pNode;
+ else if (SQL_ISRULE(_pNode,table_ref)
+ && _pNode->count() == 3
+ && SQL_ISPUNCTUATION(_pNode->getChild(0),"(")
+ && SQL_ISPUNCTUATION(_pNode->getChild(2),")") ) // '(' joined_table ')'
+ pJoinNode = _pNode->getChild(1);
+ else if (! ( SQL_ISRULE(_pNode, table_ref) && _pNode->count() == 2) ) // table_node table_primary_as_range_column
+ bRet = sal_False;
+
+ if (pJoinNode && !InsertJoin(_pView,pJoinNode))
+ bRet = sal_False;
+ return bRet;
+ }
+ //-----------------------------------------------------------------------------
+ sal_Bool InsertJoin(const OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode *pNode)
+ {
+ OSL_ENSURE( SQL_ISRULE( pNode, qualified_join ) || SQL_ISRULE( pNode, joined_table ) || SQL_ISRULE( pNode, cross_union ),
+ "OQueryDesignView::InsertJoin: Fehler im Parse Tree");
+
+ if (SQL_ISRULE(pNode,joined_table))
+ return InsertJoin(_pView,pNode->getChild(1));
+
+ // first check the left and right side
+ const ::connectivity::OSQLParseNode* pRightTableRef = pNode->getChild(3); // table_ref
+ if ( SQL_ISRULE(pNode, qualified_join) && SQL_ISTOKEN(pNode->getChild(1),NATURAL) )
+ pRightTableRef = pNode->getChild(4); // table_ref
+
+ if ( !checkJoinConditions(_pView,pNode->getChild(0)) || !checkJoinConditions(_pView,pRightTableRef))
+ return sal_False;
+
+ // named column join wird später vieleicht noch implementiert
+ // SQL_ISRULE(pNode->getChild(4),named_columns_join)
+ EJoinType eJoinType = INNER_JOIN;
+ bool bNatural = false;
+ if ( SQL_ISRULE(pNode, qualified_join) )
+ {
+ ::connectivity::OSQLParseNode* pJoinType = pNode->getChild(1); // join_type
+ if ( SQL_ISTOKEN(pJoinType,NATURAL) )
+ {
+ bNatural = true;
+ pJoinType = pNode->getChild(2);
+ }
+
+ if (SQL_ISRULE(pJoinType,join_type) && (!pJoinType->count() || SQL_ISTOKEN(pJoinType->getChild(0),INNER)))
+ {
+ eJoinType = INNER_JOIN;
+ }
+ else
+ {
+ if (SQL_ISRULE(pJoinType,join_type)) // eine Ebene tiefer
+ pJoinType = pJoinType->getChild(0);
+
+ if (SQL_ISTOKEN(pJoinType->getChild(0),LEFT))
+ eJoinType = LEFT_JOIN;
+ else if(SQL_ISTOKEN(pJoinType->getChild(0),RIGHT))
+ eJoinType = RIGHT_JOIN;
+ else
+ eJoinType = FULL_JOIN;
+ }
+ if ( SQL_ISRULE(pNode->getChild(4),join_condition) )
+ {
+ if ( InsertJoinConnection(_pView,pNode->getChild(4)->getChild(1), eJoinType,pNode->getChild(0),pRightTableRef) != eOk )
+ return sal_False;
+ }
+ }
+ else if ( SQL_ISRULE(pNode, cross_union) )
+ {
+ eJoinType = CROSS_JOIN;
+ pRightTableRef = pNode->getChild(pNode->count() - 1);
+ }
+ else
+ return sal_False;
+
+ if ( eJoinType == CROSS_JOIN || bNatural )
+ {
+
+ OQueryTableWindow* pLeftWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pNode->getChild(0)) );
+ OQueryTableWindow* pRightWindow = static_cast<OQueryTableView*>(_pView->getTableView())->FindTable( getTableRange(_pView,pRightTableRef) );
+ OSL_ENSURE(pLeftWindow && pRightWindow,"Table Windows could not be found!");
+ if ( !pLeftWindow || !pRightWindow )
+ return sal_False;
+
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ aDragLeft->SetTabWindow(pLeftWindow);
+ aDragLeft->SetTable(pLeftWindow->GetTableName());
+ aDragLeft->SetAlias(pLeftWindow->GetAliasName());
+
+ OTableFieldDescRef aDragRight = new OTableFieldDesc();
+ aDragRight->SetTabWindow(pRightWindow);
+ aDragRight->SetTable(pRightWindow->GetTableName());
+ aDragRight->SetAlias(pRightWindow->GetAliasName());
+
+ insertConnection(_pView,eJoinType,aDragLeft,aDragRight,bNatural);
+ }
+
+
+ return sal_True;
+ }
+ //------------------------------------------------------------------------------
+ void insertUnUsedFields(OQueryDesignView* _pView,OSelectionBrowseBox* _pSelectionBrw)
+ {
+ // now we have to insert the fields which aren't in the statement
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ OTableFields& rUnUsedFields = rController.getUnUsedFields();
+ OTableFields::iterator aEnd = rUnUsedFields.end();
+ for(OTableFields::iterator aIter = rUnUsedFields.begin();aIter != aEnd;++aIter)
+ if(_pSelectionBrw->InsertField(*aIter,BROWSER_INVALIDID,sal_False,sal_False).is())
+ (*aIter) = NULL;
+ OTableFields().swap( rUnUsedFields );
+ }
+
+ //------------------------------------------------------------------------------
+ SqlParseError InitFromParseNodeImpl(OQueryDesignView* _pView,OSelectionBrowseBox* _pSelectionBrw)
+ {
+ SqlParseError eErrorCode = eOk;
+
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+
+ _pSelectionBrw->PreFill();
+ _pSelectionBrw->SetReadOnly(rController.isReadOnly());
+ _pSelectionBrw->Fill();
+
+
+ ::connectivity::OSQLParseTreeIterator& aIterator = rController.getParseIterator();
+ const ::connectivity::OSQLParseNode* pParseTree = aIterator.getParseTree();
+
+ do
+ {
+ if ( !pParseTree )
+ {
+ // now we have to insert the fields which aren't in the statement
+ insertUnUsedFields(_pView,_pSelectionBrw);
+ break;
+ }
+
+ if ( !rController.isEsacpeProcessing() ) // not allowed in this mode
+ {
+ eErrorCode = eNativeMode;
+ break;
+ }
+
+ if ( !( SQL_ISRULE( pParseTree, select_statement ) ) )
+ {
+ eErrorCode = eNoSelectStatement;
+ break;
+ }
+
+ Reference< XConnection> xConnection = rController.getConnection();
+ if ( !xConnection.is() )
+ {
+ OSL_FAIL( "InitFromParseNodeImpl: no connection? no connection!" );
+ break;
+ }
+
+ const OSQLTables& aMap = aIterator.getTables();
+ ::comphelper::UStringMixLess aTmp(aMap.key_comp());
+ ::comphelper::UStringMixEqual aKeyComp( aTmp.isCaseSensitive() );
+
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ try
+ {
+ sal_Int32 nMax = xMetaData->getMaxTablesInSelect();
+ if ( nMax && nMax < (sal_Int32)aMap.size() )
+ {
+ eErrorCode = eTooManyTables;
+ break;
+ }
+
+ ::rtl::OUString sComposedName;
+ ::rtl::OUString aQualifierName;
+ ::rtl::OUString sAlias;
+
+ OQueryTableView* pTableView = static_cast<OQueryTableView*>(_pView->getTableView());
+ pTableView->clearLayoutInformation();
+ OSQLTables::const_iterator aIter = aMap.begin();
+ OSQLTables::const_iterator aEnd = aMap.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSQLTable xTable = aIter->second;
+ Reference< XPropertySet > xTableProps( xTable, UNO_QUERY_THROW );
+
+ sAlias = aIter->first;
+
+ // check whether this is a query
+ Reference< XPropertySetInfo > xPSI = xTableProps->getPropertySetInfo();
+ bool bIsQuery = xPSI.is() && xPSI->hasPropertyByName( PROPERTY_COMMAND );
+
+ if ( bIsQuery )
+ OSL_VERIFY( xTableProps->getPropertyValue( PROPERTY_NAME ) >>= sComposedName );
+ else
+ {
+ sComposedName = ::dbtools::composeTableName( xMetaData, xTableProps, ::dbtools::eInDataManipulation, false, false, false );
+
+ // if the alias is the complete (composed) table, then shorten it
+ if ( aKeyComp( sComposedName, aIter->first ) )
+ {
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents( xMetaData, sComposedName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
+ sAlias = sTable;
+ }
+ }
+
+ // find the existent window for this alias
+ OQueryTableWindow* pExistentWin = pTableView->FindTable( sAlias );
+ if ( !pExistentWin )
+ {
+ pTableView->AddTabWin( sComposedName, sAlias, sal_False ); // don't create data here
+ }
+ else
+ {
+ // there already exists a window for this alias ....
+ if ( !aKeyComp( pExistentWin->GetData()->GetComposedName(), sComposedName ) )
+ // ... but for another complete table name -> new window
+ pTableView->AddTabWin(sComposedName, sAlias);
+ }
+ }
+
+ // now delete the data for which we haven't any tablewindow
+ OJoinTableView::OTableWindowMap aTableMap(*pTableView->GetTabWinMap());
+ OJoinTableView::OTableWindowMap::iterator aIterTableMap = aTableMap.begin();
+ OJoinTableView::OTableWindowMap::iterator aIterTableEnd = aTableMap.end();
+ for(;aIterTableMap != aIterTableEnd;++aIterTableMap)
+ {
+ if(aMap.find(aIterTableMap->second->GetComposedName()) == aMap.end() &&
+ aMap.find(aIterTableMap->first) == aMap.end())
+ pTableView->RemoveTabWin(aIterTableMap->second);
+ }
+
+ if ( eOk == (eErrorCode = FillOuterJoins(_pView,pParseTree->getChild(3)->getChild(0)->getChild(1))) )
+ {
+ // check if we have a distinct statement
+ if(SQL_ISTOKEN(pParseTree->getChild(1),DISTINCT))
+ {
+ rController.setDistinct(sal_True);
+ rController.InvalidateFeature(SID_QUERY_DISTINCT_VALUES);
+ }
+ if ( (eErrorCode = InstallFields(_pView,pParseTree, pTableView->GetTabWinMap())) == eOk )
+ {
+ // GetSelectionCriteria must be called before GetHavingCriteria
+ sal_uInt16 nLevel=0;
+
+ if ( eOk == (eErrorCode = GetSelectionCriteria(_pView,_pSelectionBrw,pParseTree,nLevel)) )
+ {
+ if ( eOk == (eErrorCode = GetGroupCriteria(_pView,_pSelectionBrw,pParseTree)) )
+ {
+ if ( eOk == (eErrorCode = GetHavingCriteria(_pView,_pSelectionBrw,pParseTree,nLevel)) )
+ {
+ if ( eOk == (eErrorCode = GetOrderCriteria(_pView,_pSelectionBrw,pParseTree)) )
+ insertUnUsedFields(_pView,_pSelectionBrw);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("getMaxTablesInSelect!");
+ }
+ }
+ while ( false );
+
+ // Durch das Neuerzeugen wurden wieder Undo-Actions in den Manager gestellt
+ rController.ClearUndoManager();
+ _pSelectionBrw->Invalidate();
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ /** fillSelectSubList
+ @return
+ <TRUE/> when columns could be inserted otherwise <FALSE/>
+ */
+ //------------------------------------------------------------------------------
+ SqlParseError fillSelectSubList( OQueryDesignView* _pView,
+ OJoinTableView::OTableWindowMap* _pTabList)
+ {
+ SqlParseError eErrorCode = eOk;
+ sal_Bool bFirstField = sal_True;
+ ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));
+ OJoinTableView::OTableWindowMap::iterator aIter = _pTabList->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = _pTabList->end();
+ for(;aIter != aEnd && eOk == eErrorCode ;++aIter)
+ {
+ OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
+ OTableFieldDescRef aInfo = new OTableFieldDesc();
+ if (pTabWin->ExistsField( sAsterix, aInfo ))
+ {
+ eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
+ bFirstField = sal_False;
+ }
+ }
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError InstallFields(OQueryDesignView* _pView,
+ const ::connectivity::OSQLParseNode* pNode,
+ OJoinTableView::OTableWindowMap* pTabList )
+ {
+ if( pNode==0 || !SQL_ISRULE(pNode,select_statement))
+ return eNoSelectStatement;
+
+ ::connectivity::OSQLParseNode* pParseTree = pNode->getChild(2); // selection
+ sal_Bool bFirstField = sal_True; // bei der Initialisierung muß auf alle Faelle das erste Feld neu aktiviert werden
+
+ SqlParseError eErrorCode = eOk;
+
+ if ( pParseTree->isRule() && SQL_ISPUNCTUATION(pParseTree->getChild(0),"*") )
+ {
+ // SELECT * ...
+ eErrorCode = fillSelectSubList(_pView,pTabList);
+ }
+ else if (SQL_ISRULE(pParseTree,scalar_exp_commalist) )
+ {
+ // SELECT column, ...
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ Reference< XConnection> xConnection = rController.getConnection();
+
+ ::rtl::OUString aColumnName,aTableRange;
+ for (sal_uInt32 i = 0; i < pParseTree->count() && eOk == eErrorCode ; ++i)
+ {
+ ::connectivity::OSQLParseNode * pColumnRef = pParseTree->getChild(i);
+
+ do {
+
+ if ( SQL_ISRULE(pColumnRef,select_sublist) )
+ {
+ eErrorCode = fillSelectSubList(_pView,pTabList);
+ break;
+ }
+
+ if ( SQL_ISRULE(pColumnRef,derived_column) )
+ {
+ ::rtl::OUString aColumnAlias(rController.getParseIterator().getColumnAlias(pColumnRef)); // kann leer sein
+ pColumnRef = pColumnRef->getChild(0);
+ OTableFieldDescRef aInfo = new OTableFieldDesc();
+
+ if ( pColumnRef->count() == 3 &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
+ )
+ pColumnRef = pColumnRef->getChild(1);
+
+ if (SQL_ISRULE(pColumnRef,column_ref))
+ {
+ InsertColumnRef(_pView,pColumnRef,aColumnName,aColumnAlias,aTableRange,aInfo,pTabList);
+ eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
+ bFirstField = sal_False;
+ }
+ else if(SQL_ISRULEOR2(pColumnRef,general_set_fct ,set_fct_spec) ||
+ SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) ||
+ SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) ||
+ SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct))
+ {
+ ::rtl::OUString aColumns;
+ pColumnRef->parseNodeToPredicateStr(aColumns,
+ xConnection,
+ rController.getNumberFormatter(),
+ _pView->getLocale(),
+ static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ &rController.getParser().getContext());
+
+ sal_Int32 nFunctionType = FKT_NONE;
+ ::connectivity::OSQLParseNode* pParamRef = NULL;
+ sal_Int32 nColumnRefPos = pColumnRef->count() - 2;
+ if ( nColumnRefPos >= 0 && static_cast<sal_uInt32>(nColumnRefPos) < pColumnRef->count() )
+ pParamRef = pColumnRef->getChild(nColumnRefPos);
+
+ if ( SQL_ISRULE(pColumnRef,general_set_fct)
+ && SQL_ISRULE(pParamRef,column_ref) )
+ {
+ // Parameter auf Columnref pr"ufen
+ InsertColumnRef(_pView,pParamRef,aColumnName,aColumnAlias,aTableRange,aInfo,pTabList);
+ }
+ else if ( SQL_ISRULE(pColumnRef,general_set_fct) )
+ {
+ if ( pParamRef && pParamRef->getTokenValue().toChar() == '*' )
+ {
+ OJoinTableView::OTableWindowMap::iterator aIter = pTabList->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = pTabList->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableWindow* pTabWin = static_cast<OQueryTableWindow*>(aIter->second);
+ if (pTabWin->ExistsField( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), aInfo ))
+ {
+ aInfo->SetAlias(String());
+ aInfo->SetTable(String());
+ break;
+ }
+ }
+ }
+ else
+ {
+ ::rtl::OUString sFieldName = aColumns;
+ if ( pParamRef )
+ { // we got an aggregate function but without column name inside
+ // so we set the whole argument of the function as field name
+ nFunctionType |= FKT_NUMERIC;
+ sFieldName = ::rtl::OUString();
+ pParamRef->parseNodeToStr( sFieldName,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True,
+ sal_True); // quote is to true because we need quoted elements inside the function
+ }
+ aInfo->SetDataType(DataType::DOUBLE);
+ aInfo->SetFieldType(TAB_NORMAL_FIELD);
+ aInfo->SetField(sFieldName);
+ }
+ aInfo->SetTabWindow(NULL);
+ aInfo->SetFieldAlias(aColumnAlias);
+ }
+ else
+ {
+ _pView->fillFunctionInfo(pColumnRef,aColumns,aInfo);
+ aInfo->SetFieldAlias(aColumnAlias);
+ }
+
+ if ( SQL_ISRULE(pColumnRef,general_set_fct) )
+ {
+ aInfo->SetFunctionType(nFunctionType|FKT_AGGREGATE);
+ String aCol(aColumns);
+ aInfo->SetFunction(aCol.GetToken(0,'(').EraseTrailingChars(' '));
+ }
+ else
+ aInfo->SetFunctionType(nFunctionType|FKT_OTHER);
+
+ eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
+ bFirstField = sal_False;
+ }
+ else
+ {
+ ::rtl::OUString aColumns;
+ pColumnRef->parseNodeToStr( aColumns,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True,
+ sal_True); // quote is to true because we need quoted elements inside the function
+
+ aInfo->SetTabWindow( NULL );
+
+ // since we support queries in queries, the thingie might belong to an existing "table"
+ OQueryTableWindow* pExistingTable = lcl_findColumnInTables( aColumns, *pTabList, aInfo );
+ if ( pExistingTable )
+ {
+ aInfo->SetTabWindow( pExistingTable );
+ aInfo->SetTable( pExistingTable->GetTableName() );
+ aInfo->SetAlias( pExistingTable->GetAliasName() );
+ }
+
+ aInfo->SetDataType(DataType::DOUBLE);
+ aInfo->SetFieldType(TAB_NORMAL_FIELD);
+ aInfo->SetField(aColumns);
+ aInfo->SetFieldAlias(aColumnAlias);
+ aInfo->SetFunctionType(FKT_NUMERIC | FKT_OTHER);
+
+ eErrorCode = _pView->InsertField(aInfo, sal_True, bFirstField);
+ bFirstField = sal_False;
+ }
+
+ break;
+ }
+
+ OSL_FAIL( "InstallFields: don't know how to interpret this parse node!" );
+
+ } while ( false );
+ }
+ }
+ else
+ eErrorCode = eStatementTooComplex;
+
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError GetOrderCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pParseRoot )
+ {
+ SqlParseError eErrorCode = eOk;
+ if (!pParseRoot->getChild(3)->getChild(4)->isLeaf())
+ {
+ ::connectivity::OSQLParseNode* pNode = pParseRoot->getChild(3)->getChild(4)->getChild(2);
+ ::connectivity::OSQLParseNode* pParamRef = NULL;
+
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ EOrderDir eOrderDir;
+ OTableFieldDescRef aDragLeft = new OTableFieldDesc();
+ for( sal_uInt32 i=0 ; i<pNode->count() ; i++ )
+ {
+ eOrderDir = ORDER_ASC;
+ ::connectivity::OSQLParseNode* pChild = pNode->getChild( i );
+
+ if (SQL_ISTOKEN( pChild->getChild(1), DESC ) )
+ eOrderDir = ORDER_DESC;
+
+ ::connectivity::OSQLParseNode* pArgument = pChild->getChild(0);
+
+ if(SQL_ISRULE(pArgument,column_ref))
+ {
+ if( eOk == FillDragInfo(_pView,pArgument,aDragLeft))
+ _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i);
+ else // it could be a alias name for a field
+ {
+ ::rtl::OUString aTableRange,aColumnName;
+ ::connectivity::OSQLParseTreeIterator& rParseIter = rController.getParseIterator();
+ rParseIter.getColumnRange( pArgument, aColumnName, aTableRange );
+
+ OTableFields& aList = rController.getTableFieldDesc();
+ OTableFields::iterator aIter = aList.begin();
+ OTableFields::iterator aEnd = aList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntry = *aIter;
+ if(pEntry.is() && pEntry->GetFieldAlias() == aColumnName)
+ pEntry->SetOrderDir( eOrderDir );
+ }
+ }
+ }
+ else if(SQL_ISRULE(pArgument, general_set_fct ) &&
+ SQL_ISRULE(pParamRef = pArgument->getChild(pArgument->count()-2),column_ref) &&
+ eOk == FillDragInfo(_pView,pParamRef,aDragLeft))
+ _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i );
+ else if( SQL_ISRULE(pArgument, set_fct_spec ) )
+ {
+
+ Reference< XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ ::rtl::OUString sCondition;
+ pArgument->parseNodeToPredicateStr(sCondition,
+ xConnection,
+ rController.getNumberFormatter(),
+ _pView->getLocale(),
+ static_cast<sal_Char>(_pView->getDecimalSeparator().toChar()),
+ &rController.getParser().getContext());
+ _pView->fillFunctionInfo(pArgument,sCondition,aDragLeft);
+ aDragLeft->SetFunctionType(FKT_OTHER);
+ aDragLeft->SetOrderDir(eOrderDir);
+ aDragLeft->SetVisible(sal_False);
+ _pSelectionBrw->AddOrder( aDragLeft, eOrderDir, i );
+ }
+ else
+ eErrorCode = eColumnNotFound;
+ }
+ else
+ eErrorCode = eColumnNotFound;
+ }
+ }
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError GetHavingCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pSelectRoot,
+ sal_uInt16& rLevel )
+ {
+ SqlParseError eErrorCode = eOk;
+ if (!pSelectRoot->getChild(3)->getChild(3)->isLeaf())
+ eErrorCode = GetORCriteria(_pView,_pSelectionBrw,pSelectRoot->getChild(3)->getChild(3)->getChild(1),rLevel, sal_True);
+ return eErrorCode;
+ }
+ //------------------------------------------------------------------------------
+ SqlParseError GetGroupCriteria( OQueryDesignView* _pView,
+ OSelectionBrowseBox* _pSelectionBrw,
+ const ::connectivity::OSQLParseNode* pSelectRoot )
+ {
+ SqlParseError eErrorCode = eOk;
+ if (!pSelectRoot->getChild(3)->getChild(2)->isLeaf()) // opt_group_by_clause
+ {
+ OQueryController& rController = static_cast<OQueryController&>(_pView->getController());
+ ::connectivity::OSQLParseNode* pGroupBy = pSelectRoot->getChild(3)->getChild(2)->getChild(2);
+ OTableFieldDescRef aDragInfo = new OTableFieldDesc();
+ for( sal_uInt32 i=0 ; i < pGroupBy->count() && eOk == eErrorCode; ++i )
+ {
+ ::connectivity::OSQLParseNode* pParamRef = NULL;
+ ::connectivity::OSQLParseNode* pArgument = pGroupBy->getChild( i );
+ if(SQL_ISRULE(pArgument,column_ref))
+ {
+ if ( eOk == (eErrorCode = FillDragInfo(_pView,pArgument,aDragInfo)) )
+ {
+ aDragInfo->SetGroupBy(sal_True);
+ _pSelectionBrw->AddGroupBy(aDragInfo,i);
+ }
+ }
+ else if(SQL_ISRULE(pArgument, general_set_fct ) &&
+ SQL_ISRULE(pParamRef = pArgument->getChild(pArgument->count()-2),column_ref) &&
+ eOk == FillDragInfo(_pView,pParamRef,aDragInfo))
+ {
+ aDragInfo->SetGroupBy(sal_True);
+ _pSelectionBrw->AddGroupBy( aDragInfo, i );
+ }
+ else if( SQL_ISRULE(pArgument, set_fct_spec ) )
+ {
+ Reference< XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ ::rtl::OUString sGroupByExpression;
+ pArgument->parseNodeToStr( sGroupByExpression,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True,
+ sal_True); // quote is to true because we need quoted elements inside the function
+ _pView->fillFunctionInfo(pArgument,sGroupByExpression,aDragInfo);
+ aDragInfo->SetFunctionType(FKT_OTHER);
+ aDragInfo->SetGroupBy(sal_True);
+ aDragInfo->SetVisible(sal_False);
+ _pSelectionBrw->AddGroupBy( aDragInfo, i );
+ }
+ else
+ eErrorCode = eColumnNotFound;
+ }
+ }
+ }
+ return eErrorCode;
+ }
+
+ //------------------------------------------------------------------------------
+ String getParseErrorMessage( SqlParseError _eErrorCode )
+ {
+ sal_uInt16 nResId;
+ switch(_eErrorCode)
+ {
+ case eIllegalJoin:
+ nResId = STR_QRY_ILLEGAL_JOIN;
+ break;
+ case eStatementTooLong:
+ nResId = STR_QRY_TOO_LONG_STATEMENT;
+ break;
+ case eNoConnection:
+ nResId = STR_QRY_SYNTAX;
+ break;
+ case eNoSelectStatement:
+ nResId = STR_QRY_NOSELECT;
+ break;
+ case eColumnInLikeNotFound:
+ nResId = STR_QRY_SYNTAX;
+ break;
+ case eNoColumnInLike:
+ nResId = STR_QRY_SYNTAX;
+ break;
+ case eColumnNotFound:
+ nResId = STR_QRY_SYNTAX;
+ break;
+ case eNativeMode:
+ nResId = STR_QRY_NATIVE;
+ break;
+ case eTooManyTables:
+ nResId = STR_QRY_TOO_MANY_TABLES;
+ break;
+ case eTooManyConditions:
+ nResId = STR_QRY_TOOMANYCOND;
+ break;
+ case eTooManyColumns:
+ nResId = STR_QRY_TOO_MANY_COLUMNS;
+ break;
+ case eStatementTooComplex:
+ nResId = STR_QRY_TOOCOMPLEX;
+ break;
+ default:
+ nResId = STR_QRY_SYNTAX;
+ break;
+ }
+ ;
+ return String( ModuleRes( nResId ) );
+ }
+
+ //------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------
+}
+// end of anonymouse namespace
+DBG_NAME(OQueryDesignView)
+
+OQueryDesignView::OQueryDesignView( OQueryContainerWindow* _pParent,
+ OQueryController& _rController,
+ const Reference< XMultiServiceFactory >& _rFactory)
+ :OQueryView( _pParent, _rController, _rFactory )
+ ,m_aSplitter( this )
+ ,m_eChildFocus(NONE)
+ ,m_bInKeyEvent(sal_False)
+ ,m_bInSplitHandler( sal_False )
+{
+ DBG_CTOR(OQueryDesignView,NULL);
+
+ try
+ {
+ SvtSysLocale aSysLocale;
+ m_aLocale = aSysLocale.GetLocaleData().getLocale();
+ m_sDecimalSep = aSysLocale.GetLocaleData().getNumDecimalSep();
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_pSelectionBox = new OSelectionBrowseBox(this);
+
+ setNoneVisbleRow(static_cast<OQueryController&>(getController()).getVisibleRows());
+ m_pSelectionBox->Show();
+ // Splitter einrichten
+ m_aSplitter.SetSplitHdl(LINK(this, OQueryDesignView,SplitHdl));
+ m_aSplitter.Show();
+
+}
+// -----------------------------------------------------------------------------
+OQueryDesignView::~OQueryDesignView()
+{
+ if ( m_pTableView )
+ ::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ ::std::auto_ptr<Window> aTemp(m_pSelectionBox);
+ m_pSelectionBox = NULL;
+
+ DBG_DTOR(OQueryDesignView,NULL);
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OQueryDesignView, SplitHdl, void*, /*p*/ )
+{
+ if (!getController().isReadOnly())
+ {
+ m_bInSplitHandler = sal_True;
+ m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),m_aSplitter.GetSplitPosPixel() ) );
+ static_cast<OQueryController&>(getController()).setSplitPos(m_aSplitter.GetSplitPosPixel());
+ static_cast<OQueryController&>(getController()).setModified( sal_True );
+ Resize();
+ m_bInSplitHandler = sal_True;
+ }
+ return 0L;
+}
+// -------------------------------------------------------------------------
+void OQueryDesignView::Construct()
+{
+ m_pTableView = new OQueryTableView(m_pScrollWindow,this);
+ ::dbaui::notifySystemWindow(this,m_pTableView,::comphelper::mem_fun(&TaskPaneList::AddWindow));
+ OQueryView::Construct();
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::initialize()
+{
+ if(static_cast<OQueryController&>(getController()).getSplitPos() != -1)
+ {
+ m_aSplitter.SetPosPixel( Point( m_aSplitter.GetPosPixel().X(),static_cast<OQueryController&>(getController()).getSplitPos() ) );
+ m_aSplitter.SetSplitPosPixel(static_cast<OQueryController&>(getController()).getSplitPos());
+ }
+ m_pSelectionBox->initialize();
+ reset();
+}
+// -------------------------------------------------------------------------
+void OQueryDesignView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ Point aPlaygroundPos( _rPlayground.TopLeft() );
+ Size aPlaygroundSize( _rPlayground.GetSize() );
+
+ // calc the split pos, and forward it to the controller
+ sal_Int32 nSplitPos = static_cast<OQueryController&>(getController()).getSplitPos();
+ if ( 0 != aPlaygroundSize.Height() )
+ {
+ if ( ( -1 == nSplitPos )
+ || ( nSplitPos >= aPlaygroundSize.Height() )
+ )
+ {
+ // let the selection browse box determine an optimal size
+ Size aSelectionBoxSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize );
+ nSplitPos = aPlaygroundSize.Height() - aSelectionBoxSize.Height() - m_aSplitter.GetSizePixel().Height();
+ // still an invalid size?
+ if ( nSplitPos == -1 || nSplitPos >= aPlaygroundSize.Height() )
+ nSplitPos = sal_Int32(aPlaygroundSize.Height()*0.6);
+
+ static_cast<OQueryController&>(getController()).setSplitPos(nSplitPos);
+ }
+
+ if ( !m_bInSplitHandler )
+ { // the resize is triggered by something else than the split handler
+ // our main focus is to try to preserve the size of the selectionbrowse box
+ Size aSelBoxSize = m_pSelectionBox->GetSizePixel();
+ if ( aSelBoxSize.Height() )
+ {
+ // keep the size of the sel box constant
+ nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxSize.Height();
+
+ // and if the box is smaller than the optimal size, try to do something about it
+ Size aSelBoxOptSize = m_pSelectionBox->CalcOptimalSize( aPlaygroundSize );
+ if ( aSelBoxOptSize.Height() > aSelBoxSize.Height() )
+ {
+ nSplitPos = aPlaygroundSize.Height() - m_aSplitter.GetSizePixel().Height() - aSelBoxOptSize.Height();
+ }
+
+ static_cast< OQueryController& >(getController()).setSplitPos( nSplitPos );
+ }
+ }
+ }
+
+ // normalize the split pos
+ Point aSplitPos = Point( _rPlayground.Left(), nSplitPos );
+ Size aSplitSize = Size( _rPlayground.GetSize().Width(), m_aSplitter.GetSizePixel().Height() );
+
+ if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
+ aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
+
+ if( aSplitPos.Y() <= aPlaygroundPos.Y() )
+ aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.2);
+
+ // position the table
+ Size aTableViewSize(aPlaygroundSize.Width(), aSplitPos.Y() - aPlaygroundPos.Y());
+ m_pScrollWindow->SetPosSizePixel(aPlaygroundPos, aTableViewSize);
+
+ // position the selection browse box
+ Point aPos( aPlaygroundPos.X(), aSplitPos.Y() + aSplitSize.Height() );
+ m_pSelectionBox->SetPosSizePixel( aPos, Size( aPlaygroundSize.Width(), aPlaygroundSize.Height() - aSplitSize.Height() - aTableViewSize.Height() ));
+
+ // set the size of the splitter
+ m_aSplitter.SetPosSizePixel( aSplitPos, aSplitSize );
+ m_aSplitter.SetDragRectPixel( _rPlayground );
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::setReadOnly(sal_Bool _bReadOnly)
+{
+ m_pSelectionBox->SetReadOnly(_bReadOnly);
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::clear()
+{
+ m_pSelectionBox->ClearAll(); // clear the whole selection
+ m_pTableView->ClearAll();
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::setStatement(const ::rtl::OUString& /*_rsStatement*/)
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::copy()
+{
+ if( m_eChildFocus == SELECTION)
+ m_pSelectionBox->copy();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryDesignView::isCutAllowed()
+{
+ sal_Bool bAllowed = sal_False;
+ if ( SELECTION == m_eChildFocus )
+ bAllowed = m_pSelectionBox->isCutAllowed();
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryDesignView::isPasteAllowed()
+{
+ sal_Bool bAllowed = sal_False;
+ if ( SELECTION == m_eChildFocus )
+ bAllowed = m_pSelectionBox->isPasteAllowed();
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryDesignView::isCopyAllowed()
+{
+ sal_Bool bAllowed = sal_False;
+ if ( SELECTION == m_eChildFocus )
+ bAllowed = m_pSelectionBox->isCopyAllowed();
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::stopTimer()
+{
+ m_pSelectionBox->stopTimer();
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::startTimer()
+{
+ m_pSelectionBox->startTimer();
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::cut()
+{
+ if( m_eChildFocus == SELECTION)
+ {
+ m_pSelectionBox->cut();
+ static_cast<OQueryController&>(getController()).setModified(sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::paste()
+{
+ if( m_eChildFocus == SELECTION)
+ {
+ m_pSelectionBox->paste();
+ static_cast<OQueryController&>(getController()).setModified(sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::TableDeleted(const ::rtl::OUString& rAliasName)
+{
+ // Nachricht, dass Tabelle aus dem Fenster gel"oscht wurde
+ DeleteFields(rAliasName);
+ static_cast<OQueryController&>(getController()).InvalidateFeature(ID_BROWSER_ADDTABLE); // view nochmal bescheid sagen
+}
+//------------------------------------------------------------------------------
+void OQueryDesignView::DeleteFields( const ::rtl::OUString& rAliasName )
+{
+ m_pSelectionBox->DeleteFields( rAliasName );
+}
+// -----------------------------------------------------------------------------
+bool OQueryDesignView::HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const
+{
+ return m_pSelectionBox->HasFieldByAliasName( rFieldName, rInfo);
+}
+// -----------------------------------------------------------------------------
+SqlParseError OQueryDesignView::InsertField( const OTableFieldDescRef& rInfo, sal_Bool bVis, sal_Bool bActivate)
+{
+ return m_pSelectionBox->InsertField( rInfo, BROWSER_INVALIDID,bVis, bActivate ).is() ? eOk : eTooManyColumns;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OQueryDesignView::getColWidth(sal_uInt16 _nColPos) const
+{
+ static sal_Int32 s_nDefaultWidth = GetTextWidth(String(RTL_CONSTASCII_USTRINGPARAM("0"))) * 15;
+ sal_Int32 nWidth = static_cast<OQueryController&>(getController()).getColWidth(_nColPos);
+ if ( !nWidth )
+ nWidth = s_nDefaultWidth;
+ return nWidth;
+}
+//------------------------------------------------------------------------------
+void OQueryDesignView::fillValidFields(const ::rtl::OUString& sAliasName, ComboBox* pFieldList)
+{
+ OSL_ENSURE(pFieldList != NULL, "OQueryDesignView::FillValidFields : What the hell do you think I can do with a NULL-ptr ? This will crash !");
+ pFieldList->Clear();
+
+ sal_Bool bAllTables = sAliasName.getLength() == 0;
+
+ OJoinTableView::OTableWindowMap* pTabWins = m_pTableView->GetTabWinMap();
+ ::rtl::OUString strCurrentPrefix;
+ ::std::vector< ::rtl::OUString> aFields;
+ OJoinTableView::OTableWindowMap::iterator aIter = pTabWins->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = pTabWins->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableWindow* pCurrentWin = static_cast<OQueryTableWindow*>(aIter->second);
+ if (bAllTables || (pCurrentWin->GetAliasName() == sAliasName))
+ {
+ strCurrentPrefix = pCurrentWin->GetAliasName();
+ strCurrentPrefix += ::rtl::OUString('.');
+
+ pCurrentWin->EnumValidFields(aFields);
+
+ ::std::vector< ::rtl::OUString>::iterator aStrIter = aFields.begin();
+ ::std::vector< ::rtl::OUString>::iterator aStrEnd = aFields.end();
+ for(;aStrIter != aStrEnd;++aStrIter)
+ {
+ if (bAllTables || aStrIter->toChar() == '*')
+ pFieldList->InsertEntry(::rtl::OUString(strCurrentPrefix) += *aStrIter);
+ else
+ pFieldList->InsertEntry(*aStrIter);
+ }
+
+ if (!bAllTables)
+ // das heisst, dass ich in diesen Block kam, weil der Tabellenname genau der gesuchte war, also bin ich fertig
+ // (dadurch verhindere ich auch das doppelte Einfuegen von Feldern, wenn eine Tabelle mehrmals als TabWin vorkommt)
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+long OQueryDesignView::PreNotify(NotifyEvent& rNEvt)
+{
+ switch (rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Window* pFocus = Application::GetFocusWindow();
+ (void)pFocus;
+ }
+#endif
+
+ if ( m_pSelectionBox && m_pSelectionBox->HasChildPathFocus() )
+ m_eChildFocus = SELECTION;
+ else
+ m_eChildFocus = TABLEVIEW;
+ break;
+ }
+
+ return OQueryView::PreNotify(rNEvt);
+}
+//------------------------------------------------------------------------------
+
+
+// -----------------------------------------------------------------------------
+// check if the statement is correct when not returning false
+sal_Bool OQueryDesignView::checkStatement()
+{
+ sal_Bool bRet = sal_True;
+ if ( m_pSelectionBox )
+ bRet = m_pSelectionBox->Save(); // an error occurred so we return no
+ return bRet;
+}
+//-------------------------------------------------------------------------------
+::rtl::OUString OQueryDesignView::getStatement()
+{
+ OQueryController& rController = static_cast<OQueryController&>(getController());
+ m_rController.clearError();
+ // used for fields which aren't any longer in the statement
+ OTableFields& rUnUsedFields = rController.getUnUsedFields();
+ OTableFields().swap( rUnUsedFields );
+
+ // create the select columns
+ sal_uInt32 nFieldcount = 0;
+ OTableFields& rFieldList = rController.getTableFieldDesc();
+ OTableFields::iterator aIter = rFieldList.begin();
+ OTableFields::iterator aEnd = rFieldList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntryField = *aIter;
+ if ( pEntryField->GetField().getLength() && pEntryField->IsVisible() )
+ ++nFieldcount;
+ else if (pEntryField->GetField().getLength() &&
+ !pEntryField->HasCriteria() &&
+ pEntryField->isNoneFunction() &&
+ pEntryField->GetOrderDir() == ORDER_NONE &&
+ !pEntryField->IsGroupBy() &&
+ !pEntryField->GetFunction().getLength() )
+ rUnUsedFields.push_back(pEntryField);
+ }
+ if ( !nFieldcount ) // keine Felder sichtbar also zur"uck
+ {
+ rUnUsedFields = rFieldList;
+ return ::rtl::OUString();
+ }
+
+ OQueryTableView::OTableWindowMap* pTabList = m_pTableView->GetTabWinMap();
+ sal_uInt32 nTabcount = pTabList->size();
+
+ ::rtl::OUString aFieldListStr(GenerateSelectList(this,rFieldList,nTabcount>1));
+ if( !aFieldListStr.getLength() )
+ return ::rtl::OUString();
+ // Ausnahmebehandlung, wenn keine Felder angegeben worden sind
+ // Dann darf die Tabpage nicht gewechselt werden
+ // Im TabBarSelectHdl wird der SQL-::rtl::OUString auf STATEMENT_NOFIELDS abgefragt
+ // und eine Errormeldung erzeugt
+ // ----------------- Tabellenliste aufbauen ----------------------
+
+ const ::std::vector<OTableConnection*>* pConnList = m_pTableView->getTableConnections();
+ Reference< XConnection> xConnection = rController.getConnection();
+ ::rtl::OUString aTableListStr(GenerateFromClause(xConnection,pTabList,pConnList));
+ OSL_ENSURE(aTableListStr.getLength(), "OQueryDesignView::getStatement() : unerwartet : habe Felder, aber keine Tabellen !");
+ // wenn es Felder gibt, koennen die nur durch Einfuegen aus einer schon existenten Tabelle entstanden sein; wenn andererseits
+ // eine Tabelle geloescht wird, verschwinden auch die zugehoerigen Felder -> ergo KANN es das nicht geben, dass Felder
+ // existieren, aber keine Tabellen (und aFieldListStr hat schon eine Laenge, das stelle ich oben sicher)
+ ::rtl::OUStringBuffer aHavingStr,aCriteriaListStr;
+ // ----------------- Kriterien aufbauen ----------------------
+ if (!GenerateCriterias(this,aCriteriaListStr,aHavingStr,rFieldList, nTabcount > 1))
+ return ::rtl::OUString();
+
+ ::rtl::OUString aJoinCrit;
+ GenerateInnerJoinCriterias(xConnection,aJoinCrit,pConnList);
+ if(aJoinCrit.getLength())
+ {
+ ::rtl::OUString aTmp(RTL_CONSTASCII_USTRINGPARAM("( "));
+ aTmp += aJoinCrit;
+ aTmp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" )"));
+ if(aCriteriaListStr.getLength())
+ {
+ aTmp += C_AND;
+ aTmp += aCriteriaListStr.makeStringAndClear();
+ }
+ aCriteriaListStr = aTmp;
+ }
+ // ----------------- Statement aufbauen ----------------------
+ ::rtl::OUStringBuffer aSqlCmd(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")));
+ if(static_cast<OQueryController&>(getController()).isDistinct())
+ aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DISTINCT ")));
+ aSqlCmd.append(aFieldListStr);
+ aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM ")));
+ aSqlCmd.append(aTableListStr);
+
+ if (aCriteriaListStr.getLength())
+ {
+ aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE ")));
+ aSqlCmd.append(aCriteriaListStr.makeStringAndClear());
+ }
+ // ----------------- GroupBy aufbauen und Anh"angen ------------
+ Reference<XDatabaseMetaData> xMeta;
+ if ( xConnection.is() )
+ xMeta = xConnection->getMetaData();
+ sal_Bool bUseAlias = nTabcount > 1;
+ if ( xMeta.is() )
+ bUseAlias = bUseAlias || !xMeta->supportsGroupByUnrelated();
+
+ aSqlCmd.append(GenerateGroupBy(this,rFieldList,bUseAlias));
+ // ----------------- having Anh"angen ------------
+ if(aHavingStr.getLength())
+ {
+ aSqlCmd.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" HAVING ")));
+ aSqlCmd.append(aHavingStr.makeStringAndClear());
+ }
+ // ----------------- Sortierung aufbauen und Anh"angen ------------
+ ::rtl::OUString sOrder;
+ SqlParseError eErrorCode = eOk;
+ if ( (eErrorCode = GenerateOrder(this,rFieldList,nTabcount > 1,sOrder)) == eOk)
+ aSqlCmd.append(sOrder);
+ else
+ {
+ if ( !m_rController.hasError() )
+ m_rController.appendError( getParseErrorMessage( eErrorCode ) );
+
+ m_rController.displayError();
+ }
+
+ ::rtl::OUString sSQL = aSqlCmd.makeStringAndClear();
+ if ( xConnection.is() )
+ {
+ ::connectivity::OSQLParser& rParser( rController.getParser() );
+ ::rtl::OUString sErrorMessage;
+ ::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( sErrorMessage, sSQL, sal_True ) );
+ if ( pParseNode.get() )
+ {
+ OSQLParseNode* pNode = pParseNode->getChild(3)->getChild(1);
+ if ( pNode->count() > 1 )
+ {
+ ::connectivity::OSQLParseNode * pCondition = pNode->getChild(1);
+ if ( pCondition ) // no where clause
+ {
+ OSQLParseNode::compress(pCondition);
+ ::rtl::OUString sTemp;
+ pParseNode->parseNodeToStr(sTemp,xConnection);
+ sSQL = sTemp;
+ }
+ }
+ }
+ }
+ return sSQL;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void OQueryDesignView::setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable)
+{
+ sal_uInt16 nRow;
+ switch (_nSlotId)
+ {
+ case SID_QUERY_VIEW_FUNCTIONS:
+ nRow = BROW_FUNCTION_ROW;
+ break;
+ case SID_QUERY_VIEW_TABLES:
+ nRow = BROW_TABLE_ROW;
+ break;
+ case SID_QUERY_VIEW_ALIASES:
+ nRow = BROW_COLUMNALIAS_ROW;
+ break;
+ default:
+ // ????????????
+ nRow = 0;
+ break;
+ }
+ m_pSelectionBox->SetRowVisible(nRow,_bEnable);
+ m_pSelectionBox->Invalidate();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryDesignView::isSlotEnabled(sal_Int32 _nSlotId)
+{
+ sal_uInt16 nRow;
+ switch (_nSlotId)
+ {
+ case SID_QUERY_VIEW_FUNCTIONS:
+ nRow = BROW_FUNCTION_ROW;
+ break;
+ case SID_QUERY_VIEW_TABLES:
+ nRow = BROW_TABLE_ROW;
+ break;
+ case SID_QUERY_VIEW_ALIASES:
+ nRow = BROW_COLUMNALIAS_ROW;
+ break;
+ default:
+ // ?????????
+ nRow = 0;
+ break;
+ }
+ return m_pSelectionBox->IsRowVisible(nRow);
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::SaveUIConfig()
+{
+ OQueryController& rCtrl = static_cast<OQueryController&>(getController());
+ rCtrl.SaveTabWinsPosSize( m_pTableView->GetTabWinMap(), m_pScrollWindow->GetHScrollBar()->GetThumbPos(), m_pScrollWindow->GetVScrollBar()->GetThumbPos() );
+ rCtrl.setVisibleRows( m_pSelectionBox->GetNoneVisibleRows() );
+ if ( m_aSplitter.GetSplitPosPixel() != 0 )
+ rCtrl.setSplitPos( m_aSplitter.GetSplitPosPixel() );
+}
+// -----------------------------------------------------------------------------
+OSQLParseNode* OQueryDesignView::getPredicateTreeFromEntry(OTableFieldDescRef pEntry,
+ const String& _sCriteria,
+ ::rtl::OUString& _rsErrorMessage,
+ Reference<XPropertySet>& _rxColumn) const
+{
+ OSL_ENSURE(pEntry.is(),"Entry is null!");
+ if(!pEntry.is())
+ return NULL;
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getController()).getConnection();
+ if(!xConnection.is())
+ return NULL;
+
+ ::connectivity::OSQLParser& rParser( static_cast<OQueryController&>(getController()).getParser() );
+ OQueryTableWindow* pWin = static_cast<OQueryTableWindow*>(pEntry->GetTabWindow());
+
+ String sTest(_sCriteria);
+ // special handling for functions
+ if ( pEntry->GetFunctionType() & (FKT_OTHER | FKT_AGGREGATE | FKT_NUMERIC) )
+ {
+ // we have a function here so we have to distinguish the type of return value
+ String sFunction;
+ if ( pEntry->isNumericOrAggreateFunction() )
+ sFunction = pEntry->GetFunction();
+
+ if ( !sFunction.Len() )
+ sFunction = pEntry->GetField();
+
+ if(sFunction.GetTokenCount('(') > 1)
+ sFunction = sFunction.GetToken(0,'('); // this should be the name of the function
+
+ sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType(sFunction,&rParser.getContext());
+ if ( nType == DataType::OTHER || (!sFunction.Len() && pEntry->isNumericOrAggreateFunction()) )
+ {
+ // first try the international version
+ ::rtl::OUString sSql;
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * "));
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x WHERE "));
+ sSql += pEntry->GetField();
+ sSql += _sCriteria;
+ ::std::auto_ptr<OSQLParseNode> pParseNode( rParser.parseTree( _rsErrorMessage, sSql, sal_True ) );
+ nType = DataType::DOUBLE;
+ if ( pParseNode.get() )
+ {
+ OSQLParseNode* pColumnRef = pParseNode->getByRule(OSQLParseNode::column_ref);
+ if ( pColumnRef )
+ {
+ OTableFieldDescRef aField = new OTableFieldDesc();
+ if ( eOk == FillDragInfo(this,pColumnRef,aField) )
+ {
+ nType = aField->GetDataType();
+ }
+ }
+ }
+ }
+
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ parse::OParseColumn* pColumn = new parse::OParseColumn( pEntry->GetField(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ColumnValue::NULLABLE_UNKNOWN,
+ 0,
+ 0,
+ nType,
+ sal_False,
+ sal_False,
+ xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+ _rxColumn = pColumn;
+ pColumn->setFunction(sal_True);
+ pColumn->setRealName(pEntry->GetField());
+ }
+ else
+ {
+ if (pWin)
+ {
+ Reference<XNameAccess> xColumns = pWin->GetOriginalColumns();
+ if (xColumns.is() && xColumns->hasByName(pEntry->GetField()))
+ xColumns->getByName(pEntry->GetField()) >>= _rxColumn;
+ }
+ }
+
+ OSQLParseNode* pParseNode = rParser.predicateTree( _rsErrorMessage,
+ sTest,
+ static_cast<OQueryController&>(getController()).getNumberFormatter(),
+ _rxColumn);
+ return pParseNode;
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::GetFocus()
+{
+ OQueryView::GetFocus();
+ if ( m_pSelectionBox && !m_pSelectionBox->HasChildPathFocus() )
+ {
+ // first we have to deactivate the current cell to refill when nescessary
+ m_pSelectionBox->DeactivateCell();
+ m_pSelectionBox->ActivateCell(m_pSelectionBox->GetCurRow(), m_pSelectionBox->GetCurColumnId());
+ m_pSelectionBox->GrabFocus();
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::reset()
+{
+ m_pTableView->ClearAll();
+ m_pTableView->ReSync();
+}
+// -----------------------------------------------------------------------------
+void OQueryDesignView::setNoneVisbleRow(sal_Int32 _nRows)
+{
+ m_pSelectionBox->SetNoneVisbleRow(_nRows);
+}
+
+// -----------------------------------------------------------------------------
+void OQueryDesignView::initByFieldDescriptions( const Sequence< PropertyValue >& i_rFieldDescriptions )
+{
+ OQueryController& rController = static_cast< OQueryController& >( getController() );
+
+ m_pSelectionBox->PreFill();
+ m_pSelectionBox->SetReadOnly( rController.isReadOnly() );
+ m_pSelectionBox->Fill();
+
+ for ( const PropertyValue* field = i_rFieldDescriptions.getConstArray();
+ field != i_rFieldDescriptions.getConstArray() + i_rFieldDescriptions.getLength();
+ ++field
+ )
+ {
+ ::rtl::Reference< OTableFieldDesc > pField( new OTableFieldDesc() );
+ pField->Load( *field, true );
+ InsertField( pField, sal_True, sal_False );
+ }
+
+ rController.ClearUndoManager();
+ m_pSelectionBox->Invalidate();
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ SqlParseError eErrorCode = eNativeMode;
+ m_rController.clearError();
+
+ try
+ {
+ eErrorCode = InitFromParseNodeImpl( this, m_pSelectionBox );
+
+ if ( eErrorCode != eOk )
+ {
+ if ( !m_rController.hasError() )
+ m_rController.appendError( getParseErrorMessage( eErrorCode ) );
+
+ if ( _pErrorInfo )
+ {
+ *_pErrorInfo = m_rController.getError();
+ }
+ else
+ {
+ m_rController.displayError();
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return eErrorCode == eOk;
+}
+//------------------------------------------------------------------------------
+void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* pNode
+ ,const ::rtl::OUString& sFunctionTerm
+ ,OTableFieldDescRef& aInfo)
+{
+ // get the type out of the funtion name
+ OQueryController& rController = static_cast<OQueryController&>(getController());
+ sal_Int32 nDataType = DataType::DOUBLE;
+ ::rtl::OUString sFieldName = sFunctionTerm;
+ OSQLParseNode* pFunctionName = pNode->getChild(0);
+ if ( !SQL_ISPUNCTUATION(pFunctionName,"{") )
+ {
+ if ( SQL_ISRULEOR2(pNode,length_exp,char_value_fct) )
+ pFunctionName = pFunctionName->getChild(0);
+
+ ::rtl::OUString sFunctionName = pFunctionName->getTokenValue();
+ if ( !sFunctionName.getLength() )
+ sFunctionName = ::rtl::OStringToOUString(OSQLParser::TokenIDToStr(pFunctionName->getTokenID()),RTL_TEXTENCODING_UTF8);
+
+ nDataType = OSQLParser::getFunctionReturnType(
+ sFunctionName
+ ,&rController.getParser().getContext());
+ }
+ aInfo->SetDataType(nDataType);
+ aInfo->SetFieldType(TAB_NORMAL_FIELD);
+ aInfo->SetField(sFieldName);
+ aInfo->SetTabWindow(NULL);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx
new file mode 100644
index 000000000000..fb662a8b7438
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryMoveTabWinUndoAct.hxx"
+#include "JoinTableView.hxx"
+#include "QTableWindow.hxx"
+using namespace dbaui;
+//------------------------------------------------------------------------------
+void OJoinMoveTabWinUndoAct::TogglePosition()
+{
+ Point ptFrameScrollPos(m_pOwner->GetHScrollBar()->GetThumbPos(), m_pOwner->GetVScrollBar()->GetThumbPos());
+ Point ptNext = m_pTabWin->GetPosPixel() + ptFrameScrollPos;
+
+ m_pTabWin->SetPosPixel(m_ptNextPosition - ptFrameScrollPos);
+ // sieht so aus, als wenn das ptFrameScrollPos sinnlos ist, da ich es hier abziehe und auf das ptNext aufaddiere, wo
+ // ich es das naechste Mal ja wieder abziehe ... Aber ptFrameScrollPos kann sich natuerlich beim naechsten Mal schon wieder
+ // geaendert haben ...
+ m_pOwner->EnsureVisible(m_pTabWin);
+
+ m_ptNextPosition = ptNext;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx
new file mode 100644
index 000000000000..692bd3946fda
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryMoveTabWinUndoAct.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_OQUERYMOVETABWINUNDOACT_HXX
+#define DBAUI_OQUERYMOVETABWINUNDOACT_HXX
+
+#include "QueryDesignUndoAction.hxx"
+#include "dbu_qry.hrc"
+#include <tools/gen.hxx>
+
+namespace dbaui
+{
+
+ // ================================================================================================
+ // OQueryMoveTabWinUndoAct - Undo-Klasse fuer Verschieben eines TabWins
+ class OQueryTableWindow;
+ class OTableWindow;
+ class OJoinMoveTabWinUndoAct : public OQueryDesignUndoAction
+ {
+ Point m_ptNextPosition;
+ OTableWindow* m_pTabWin;
+
+ protected:
+ void TogglePosition();
+
+ public:
+ OJoinMoveTabWinUndoAct(OJoinTableView* pOwner, const Point& ptOriginalPosition, OTableWindow* pTabWin);
+
+ virtual void Undo() { TogglePosition(); }
+ virtual void Redo() { TogglePosition(); }
+ };
+
+ // ------------------------------------------------------------------------------------------------
+ inline OJoinMoveTabWinUndoAct::OJoinMoveTabWinUndoAct(OJoinTableView* pOwner, const Point& ptOriginalPosition, OTableWindow* pTabWin)
+ :OQueryDesignUndoAction(pOwner, STR_QUERY_UNDO_MOVETABWIN)
+ ,m_ptNextPosition(ptOriginalPosition)
+ ,m_pTabWin(pTabWin)
+ {
+ }
+}
+#endif // DBAUI_OQUERYMOVETABWINUNDOACT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx
new file mode 100644
index 000000000000..11a2fc0412de
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QuerySizeTabWinUndoAct.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYSIZETABWINUNDOACT_HXX
+#define DBAUI_QUERYSIZETABWINUNDOACT_HXX
+
+#include "QueryDesignUndoAction.hxx"
+#include "dbu_qry.hrc"
+
+namespace dbaui
+{
+
+ // ================================================================================================
+ // OQuerySizeTabWinUndoAct - Undo-Klasse fuer Groessenveraenderung eines TabWins
+ class OTableWindow;
+ class OJoinSizeTabWinUndoAct : public OQueryDesignUndoAction
+ {
+ Point m_ptNextPosition;
+ Size m_szNextSize;
+ OTableWindow* m_pTabWin;
+
+ protected:
+ inline void ToggleSizePosition();
+
+ public:
+ OJoinSizeTabWinUndoAct(OJoinTableView* pOwner, const Point& ptOriginalPos, const Size& szOriginalSize, OTableWindow* pTabWin);
+ // Nebenbedingung : es darf nicht gescrollt worden sein, waehrend die neue Groesse/Position ermittelt wurde, das heisst, die Position
+ // hier sind physische, nicht logische Koordinaten
+ // (im Gegensatz zur QueryMoveTabWinUndoAct)
+
+ virtual void Undo() { ToggleSizePosition(); }
+ virtual void Redo() { ToggleSizePosition(); }
+ };
+
+ //------------------------------------------------------------------------------
+ inline OJoinSizeTabWinUndoAct::OJoinSizeTabWinUndoAct(OJoinTableView* pOwner, const Point& ptOriginalPos, const Size& szOriginalSize, OTableWindow* pTabWin)
+ :OQueryDesignUndoAction(pOwner, STR_QUERY_UNDO_SIZETABWIN)
+ ,m_ptNextPosition(ptOriginalPos)
+ ,m_szNextSize(szOriginalSize)
+ ,m_pTabWin(pTabWin)
+ {
+ }
+
+ //------------------------------------------------------------------------------
+ inline void OJoinSizeTabWinUndoAct::ToggleSizePosition()
+ {
+ Point ptNext = m_pTabWin->GetPosPixel();
+ Size szNext = m_pTabWin->GetSizePixel();
+
+ m_pOwner->Invalidate(INVALIDATE_NOCHILDREN);
+ m_pTabWin->SetPosSizePixel(m_ptNextPosition, m_szNextSize);
+ m_pOwner->Invalidate(INVALIDATE_NOCHILDREN);
+
+ m_ptNextPosition = ptNext;
+ m_szNextSize = szNext;
+ }
+}
+
+#endif //DBAUI_QUERYSIZETABWINUNDOACT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
new file mode 100644
index 000000000000..6f9a45d59228
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryTabConnUndoAction.hxx"
+#include "QTableConnection.hxx"
+#include <tools/debug.hxx>
+#include "QueryTableView.hxx"
+#include "QueryAddTabConnUndoAction.hxx"
+#include "QueryTabWinShowUndoAct.hxx"
+#include "dbu_qry.hrc"
+
+using namespace dbaui;
+
+DBG_NAME(OQueryTabConnUndoAction)
+// ------------------------------------------------------------------------------------------------
+OQueryTabConnUndoAction::~OQueryTabConnUndoAction()
+{
+ DBG_DTOR(OQueryTabConnUndoAction,NULL);
+ if (m_bOwnerOfConn)
+ { // ich besitze die Connection -> loeschen
+ m_pOwner->DeselectConn(m_pConnection);
+ delete m_pConnection;
+ }
+}
+
+// ------------------------------------------------------------------------------------------------
+OQueryTabConnUndoAction::OQueryTabConnUndoAction(OQueryTableView* pOwner, sal_uInt16 nCommentID)
+ :OQueryDesignUndoAction(pOwner, nCommentID)
+ ,m_pConnection(NULL)
+ ,m_bOwnerOfConn(sal_False)
+{
+ DBG_CTOR(OQueryTabConnUndoAction,NULL);
+}
+// -----------------------------------------------------------------------------
+OQueryAddTabConnUndoAction::OQueryAddTabConnUndoAction(OQueryTableView* pOwner)
+ : OQueryTabConnUndoAction(pOwner, STR_QUERY_UNDO_INSERTCONNECTION)
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryAddTabConnUndoAction::Undo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->DropConnection(m_pConnection);
+ SetOwnership(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OQueryAddTabConnUndoAction::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection);
+ SetOwnership(sal_False);
+}
+// -----------------------------------------------------------------------------
+OQueryDelTabConnUndoAction::OQueryDelTabConnUndoAction(OQueryTableView* pOwner)
+ : OQueryTabConnUndoAction(pOwner, STR_QUERY_UNDO_REMOVECONNECTION)
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryDelTabConnUndoAction::Undo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->GetConnection(m_pConnection);
+ SetOwnership(sal_False);
+}
+// -----------------------------------------------------------------------------
+void OQueryDelTabConnUndoAction::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->DropConnection(m_pConnection);
+ SetOwnership(sal_True);
+}
+// -----------------------------------------------------------------------------
+OQueryTabWinShowUndoAct::OQueryTabWinShowUndoAct(OQueryTableView* pOwner)
+ : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINSHOW)
+{
+}
+// -----------------------------------------------------------------------------
+OQueryTabWinShowUndoAct::~OQueryTabWinShowUndoAct()
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinShowUndoAct::Undo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->HideTabWin(m_pTabWin, this);
+ SetOwnership(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinShowUndoAct::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->ShowTabWin(m_pTabWin, this,sal_True);
+ SetOwnership(sal_False);
+}
+// -----------------------------------------------------------------------------
+OQueryTabWinDelUndoAct::OQueryTabWinDelUndoAct(OQueryTableView* pOwner)
+ : OQueryTabWinUndoAct(pOwner, STR_QUERY_UNDO_TABWINDELETE)
+{
+}
+// -----------------------------------------------------------------------------
+OQueryTabWinDelUndoAct::~OQueryTabWinDelUndoAct()
+{
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinDelUndoAct::Undo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->ShowTabWin( m_pTabWin, this,sal_True );
+ SetOwnership(sal_False);
+}
+// -----------------------------------------------------------------------------
+void OQueryTabWinDelUndoAct::Redo()
+{
+ static_cast<OQueryTableView*>(m_pOwner)->HideTabWin( m_pTabWin, this );
+ SetOwnership(sal_True);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx
new file mode 100644
index 000000000000..186c522279d5
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabConnUndoAction.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYTABCONNUNDOACTION_HXX
+#define DBAUI_QUERYTABCONNUNDOACTION_HXX
+
+#include "QueryDesignUndoAction.hxx"
+
+namespace dbaui
+{
+ class OQueryTableConnection;
+ class OQueryTableView;
+ class OQueryTabConnUndoAction : public OQueryDesignUndoAction
+ {
+ protected:
+ OQueryTableConnection* m_pConnection;
+ sal_Bool m_bOwnerOfConn;
+ // bin ich alleiniger Eigentuemer der Connection ? (aendert sich mit jedem Redo oder Undo)
+
+ public:
+ OQueryTabConnUndoAction(OQueryTableView* pOwner, sal_uInt16 nCommentID);
+ virtual ~OQueryTabConnUndoAction();
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+
+ void SetConnection(OQueryTableConnection* pConn) { m_pConnection = pConn; }
+ // anschliessend bitte SetOwnership
+ void SetOwnership(sal_Bool bTakeIt) { m_bOwnerOfConn = bTakeIt; }
+ };
+}
+#endif // DBAUI_QUERYTABCONNUNDOACTION_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx
new file mode 100644
index 000000000000..f5988bd65786
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinShowUndoAct.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYTABWINSHOWUNDOACT_HXX
+#define DBAUI_QUERYTABWINSHOWUNDOACT_HXX
+
+#include "QueryTabWinUndoAct.hxx"
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryTabWinShowUndoAct - Undo-Klasse fuer Anzeigen eines TabWins
+
+ class OQueryTabWinShowUndoAct : public OQueryTabWinUndoAct
+ {
+ public:
+ OQueryTabWinShowUndoAct(OQueryTableView* pOwner);
+ ~OQueryTabWinShowUndoAct();
+
+ virtual void Undo();
+ virtual void Redo();
+ };
+
+ // ================================================================================================
+ // OQueryTabWinDelUndoAct - Undo-Klasse fuer Loeschen eines TabWins
+
+ class OQueryTabWinDelUndoAct : public OQueryTabWinUndoAct
+ {
+ public:
+ OQueryTabWinDelUndoAct(OQueryTableView* pOwner);
+ ~OQueryTabWinDelUndoAct();
+
+ virtual void Undo();
+ virtual void Redo();
+ };
+}
+#endif // DBAUI_QUERYTABWINSHOWUNDOACT_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
new file mode 100644
index 000000000000..599afe015379
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryTabWinUndoAct.hxx"
+#include <osl/diagnose.h>
+#include "QTableWindow.hxx"
+#include "QTableWindowData.hxx"
+#include "TableConnection.hxx"
+#include "TableConnectionData.hxx"
+#include "QueryDesignFieldUndoAct.hxx"
+#include "QueryTableView.hxx"
+
+
+using namespace dbaui;
+DBG_NAME(OQueryDesignFieldUndoAct)
+OQueryDesignFieldUndoAct::OQueryDesignFieldUndoAct(OSelectionBrowseBox* pSelBrwBox, sal_uInt16 nCommentID)
+ : OCommentUndoAction(nCommentID)
+ , pOwner(pSelBrwBox)
+ , m_nColumnPostion(BROWSER_INVALIDID)
+{
+ DBG_CTOR(OQueryDesignFieldUndoAct,NULL);
+}
+// -----------------------------------------------------------------------------
+OQueryDesignFieldUndoAct::~OQueryDesignFieldUndoAct()
+{
+ DBG_DTOR(OQueryDesignFieldUndoAct,NULL);
+ pOwner = NULL;
+}
+// -----------------------------------------------------------------------------
+
+DBG_NAME(OQueryTabWinUndoAct )
+// ------------------------------------------------------------------------------------------------
+OQueryTabWinUndoAct::OQueryTabWinUndoAct(OQueryTableView* pOwner, sal_uInt16 nCommentID)
+ :OQueryDesignUndoAction(pOwner, nCommentID)
+ ,m_pTabWin(NULL)
+{
+ DBG_CTOR(OQueryTabWinUndoAct ,NULL);
+}
+//==============================================================================
+OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
+{
+ DBG_DTOR(OQueryTabWinUndoAct ,NULL);
+ if (m_bOwnerOfObjects)
+ { // wenn ich der alleinige Owner des Fenster bin, muss ich dafuer sorgen, dass es geloescht wird
+ OSL_ENSURE(m_pTabWin != NULL, "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : m_pTabWin sollte nicht NULL sein");
+ OSL_ENSURE(!m_pTabWin->IsVisible(), "OQueryTabWinUndoAct::~OQueryTabWinUndoAct() : *m_pTabWin sollte nicht sichtbar sein");
+
+ if ( m_pTabWin )
+ m_pTabWin->clearListBox();
+ delete m_pTabWin;
+
+ // und natuerlich auch die entsprechenden Connections
+ ::std::vector<OTableConnection*>::iterator aIter = m_vTableConnection.begin();
+ ::std::vector<OTableConnection*>::iterator aEnd = m_vTableConnection.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ m_pOwner->DeselectConn(*aIter);
+ delete (*aIter);
+ }
+ m_vTableConnection.clear();
+ }
+}
+//------------------------------------------------------------------------------
+void OTabFieldCellModifiedUndoAct::Undo()
+{
+ pOwner->EnterUndoMode();
+ OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
+ OSL_ENSURE(m_nColumnPostion < pOwner->GetColumnCount(),"Position outside the column count!");
+ if ( m_nColumnPostion != BROWSER_INVALIDID )
+ {
+ sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
+ String strNext = pOwner->GetCellContents(m_nCellIndex, nColumnId);
+ pOwner->SetCellContents(m_nCellIndex, nColumnId, m_strNextCellContents);
+ m_strNextCellContents = strNext;
+ }
+ pOwner->LeaveUndoMode();
+}
+
+//------------------------------------------------------------------------------
+void OTabFieldSizedUndoAct::Undo()
+{
+ pOwner->EnterUndoMode();
+ OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
+ if ( m_nColumnPostion != BROWSER_INVALIDID )
+ {
+ sal_uInt16 nColumnId = pOwner->GetColumnId(m_nColumnPostion);
+ long nNextWidth = pOwner->GetColumnWidth(nColumnId);
+ pOwner->SetColWidth(nColumnId, m_nNextWidth);
+ m_nNextWidth = nNextWidth;
+ }
+ pOwner->LeaveUndoMode();
+}
+// -----------------------------------------------------------------------------
+void OTabFieldMovedUndoAct::Undo()
+{
+ pOwner->EnterUndoMode();
+ OSL_ENSURE(m_nColumnPostion != BROWSER_INVALIDID,"Column position was not set add the undo action!");
+ if ( m_nColumnPostion != BROWSER_INVALIDID )
+ {
+ sal_uInt16 nId = pDescr->GetColumnId();
+ sal_uInt16 nOldPos = pOwner->GetColumnPos(nId);
+ pOwner->SetColumnPos(nId,m_nColumnPostion);
+ pOwner->ColumnMoved(nId,sal_False);
+ m_nColumnPostion = nOldPos;
+ }
+ pOwner->LeaveUndoMode();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx
new file mode 100644
index 000000000000..7afb6811e810
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYTABWINUNDOACT_HXX
+#define DBAUI_QUERYTABWINUNDOACT_HXX
+
+#include "QueryDesignUndoAction.hxx"
+#ifndef INCLUDED_VECTOR
+#define INCLUDED_VECTOR
+#include <vector>
+#endif // INCLUDED_VECTOR
+
+#include <algorithm>
+
+namespace dbaui
+{
+ // ================================================================================================
+ // OQueryTabWinUndoAct - Undo-Basisklasse fuer alles, was mit Einfuegen/Entfernen von TabWIns zu tun hat zu tun hat
+
+ class OQueryTableWindow;
+ class OTableConnection;
+ class OQueryTableView;
+ class OQueryTabWinUndoAct : public OQueryDesignUndoAction
+ {
+ protected:
+ ::std::vector<OTableConnection*> m_vTableConnection;
+ OQueryTableWindow* m_pTabWin;
+ sal_Bool m_bOwnerOfObjects;
+ // bin ich alleiniger Eigentuemer der verwalteten Objekte ? (aendert sich mit jedem Redo oder Undo)
+
+ public:
+ OQueryTabWinUndoAct(OQueryTableView* pOwner, sal_uInt16 nCommentID);
+ virtual ~OQueryTabWinUndoAct();
+
+ void SetOwnership(sal_Bool bTakeIt) { m_bOwnerOfObjects = bTakeIt; }
+
+
+ virtual void Undo() = 0;
+ virtual void Redo() = 0;
+
+ // Zugriff auf das TabWin
+ void SetTabWin(OQueryTableWindow* pTW) { m_pTabWin = pTW; }
+ // anschliessend sollte das SetOwnership aufgerufen werden
+
+ // Zugriff auf die verwalteten Connections
+ sal_uInt16 ConnCount() { return (sal_uInt16)m_vTableConnection.size(); }
+
+ ::std::vector<OTableConnection*>* GetTabConnList() { return &m_vTableConnection; }
+
+ void InsertConnection( OTableConnection* pConnection ) { m_vTableConnection.push_back(pConnection); }
+ void RemoveConnection( OTableConnection* pConnection )
+ {
+ m_vTableConnection.erase(::std::remove(m_vTableConnection.begin(),m_vTableConnection.end(),pConnection),m_vTableConnection.end());
+ }
+ };
+
+
+}
+#endif // DBAUI_QUERYTABWINUNDOACT_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx
new file mode 100644
index 000000000000..302b57cef86d
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx
@@ -0,0 +1,1035 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryTableView.hxx"
+#include "TableFieldInfo.hxx"
+#include "TableFieldDescription.hxx"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include "dbaccess_helpid.hrc"
+#include "QTableWindow.hxx"
+#include "QTableConnection.hxx"
+#include "QTableConnectionData.hxx"
+#include "QueryDesignView.hxx"
+#include "querycontroller.hxx"
+#include "QueryAddTabConnUndoAction.hxx"
+#include "QueryTabWinShowUndoAct.hxx"
+#include "browserids.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include "JAccess.hxx"
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <comphelper/sequence.hxx>
+#include "querydlg.hxx"
+#include "JoinExchange.hxx"
+#include <comphelper/extract.hxx>
+#include "QueryDesignView.hxx"
+#include "dbu_qry.hrc"
+#include <vcl/msgbox.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::accessibility;
+
+//------------------------------------------------------------------------------
+namespace
+{
+ // -----------------------------------------------------------------------------
+ sal_Bool isColumnInKeyType(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rColumnName,sal_Int32 _nKeyType)
+ {
+ sal_Bool bReturn = sal_False;
+ if(_rxKeys.is())
+ {
+ Reference<XColumnsSupplier> xColumnsSupplier;
+ // search the one and only primary key
+ const sal_Int32 nCount = _rxKeys->getCount();
+ for(sal_Int32 i=0;i< nCount;++i)
+ {
+ Reference<XPropertySet> xProp(_rxKeys->getByIndex(i),UNO_QUERY);
+ if(xProp.is())
+ {
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(_nKeyType == nKeyType)
+ {
+ xColumnsSupplier.set(xProp,UNO_QUERY);
+ if(xColumnsSupplier.is())
+ {
+ Reference<XNameAccess> xColumns = xColumnsSupplier->getColumns();
+ if(xColumns.is() && xColumns->hasByName(_rColumnName))
+ {
+ bReturn = sal_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return bReturn;
+ }
+ // -----------------------------------------------------------------------------
+ /** appends a new TabAdd Undo action at controller
+ @param _pView the view which we use
+ @param _pUndoAction the undo action which should be added
+ @param _pConnection the connection for which the undo action should be appended
+ @param _bOwner is the undo action the owner
+ */
+ // -----------------------------------------------------------------------------
+ void addUndoAction( OQueryTableView* _pView,
+ OQueryTabConnUndoAction* _pUndoAction,
+ OQueryTableConnection* _pConnection,
+ sal_Bool _bOwner = sal_False)
+ {
+ _pUndoAction->SetOwnership(_bOwner);
+ _pUndoAction->SetConnection(_pConnection);
+ _pView->getDesignView()->getController().addUndoActionAndInvalidate(_pUndoAction);
+ }
+ // -----------------------------------------------------------------------------
+ /** openJoinDialog opens the join dialog with this connection data
+ @param _pView the view which we use
+ @param _pConnectionData the connection data
+
+ @return true when OK was pressed otherwise false
+ */
+ sal_Bool openJoinDialog(OQueryTableView* _pView,const TTableConnectionData::value_type& _pConnectionData,sal_Bool _bSelectableTables)
+ {
+ OQueryTableConnectionData* pData = static_cast< OQueryTableConnectionData*>(_pConnectionData.get());
+
+ DlgQryJoin aDlg(_pView,_pConnectionData,_pView->GetTabWinMap(),_pView->getDesignView()->getController().getConnection(),_bSelectableTables);
+ sal_Bool bOk = aDlg.Execute() == RET_OK;
+ if( bOk )
+ {
+ pData->SetJoinType(aDlg.GetJoinType());
+ _pView->getDesignView()->getController().setModified(sal_True);
+ }
+
+ return bOk;
+ }
+ // -----------------------------------------------------------------------------
+ /** connectionModified adds an undo action for the modified connection and forces an redraw
+ @param _pView the view which we use
+ @param _pConnection the connection which was modified
+ @param _bAddUndo true when an undo action should be appended
+ */
+ void connectionModified(OQueryTableView* _pView,
+ OTableConnection* _pConnection,
+ sal_Bool _bAddUndo)
+ {
+ OSL_ENSURE(_pConnection,"Invalid connection!");
+ _pConnection->UpdateLineList();
+
+ // add an undo action
+ if ( _bAddUndo )
+ addUndoAction( _pView,
+ new OQueryAddTabConnUndoAction(_pView),
+ static_cast< OQueryTableConnection*>(_pConnection));
+ // redraw
+ _pConnection->RecalcLines();
+ // force an invalidation of the bounding rectangle
+ _pConnection->InvalidateConnection();
+
+ _pView->Invalidate(INVALIDATE_NOCHILDREN);
+ }
+ // -----------------------------------------------------------------------------
+ void addConnections(OQueryTableView* _pView,
+ const OQueryTableWindow& _rSource,
+ const OQueryTableWindow& _rDest,
+ const Reference<XNameAccess>& _rxSourceForeignKeyColumns)
+ {
+ if ( _rSource.GetData()->isQuery() || _rDest.GetData()->isQuery() )
+ // nothing to do if one of both denotes a query
+ return;
+
+ // we found a table in our view where we can insert some connections
+ // the key columns have a property called RelatedColumn
+ // OQueryTableConnectionData aufbauen
+ OQueryTableConnectionData* pNewConnData = new OQueryTableConnectionData( _rSource.GetData(), _rDest.GetData() );
+ TTableConnectionData::value_type aNewConnData(pNewConnData);
+
+ Reference<XIndexAccess> xReferencedKeys( _rDest.GetData()->getKeys());
+ ::rtl::OUString sRelatedColumn;
+
+ // iterate through all foreignkey columns to create the connections
+ Sequence< ::rtl::OUString> aElements(_rxSourceForeignKeyColumns->getElementNames());
+ const ::rtl::OUString* pIter = aElements.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aElements.getLength();
+ for(sal_Int32 i=0;pIter != pEnd;++pIter,++i)
+ {
+ Reference<XPropertySet> xColumn;
+ if ( !( _rxSourceForeignKeyColumns->getByName(*pIter) >>= xColumn ) )
+ {
+ OSL_FAIL( "addConnections: invalid foreign key column!" );
+ continue;
+ }
+
+ pNewConnData->SetFieldType(JTCS_FROM,TAB_NORMAL_FIELD);
+
+ xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn;
+ pNewConnData->SetFieldType(JTCS_TO,isColumnInKeyType(xReferencedKeys,sRelatedColumn,KeyType::PRIMARY) ? TAB_PRIMARY_FIELD : TAB_NORMAL_FIELD);
+
+ {
+ Sequence< sal_Int16> aFind(::comphelper::findValue(_rSource.GetOriginalColumns()->getElementNames(),*pIter,sal_True));
+ if(aFind.getLength())
+ pNewConnData->SetFieldIndex(JTCS_FROM,aFind[0]+1);
+ else
+ OSL_FAIL("Column not found!");
+ }
+ // get the position inside the tabe
+ Reference<XNameAccess> xRefColumns = _rDest.GetOriginalColumns();
+ if(xRefColumns.is())
+ {
+ Sequence< sal_Int16> aFind(::comphelper::findValue(xRefColumns->getElementNames(),sRelatedColumn,sal_True));
+ if(aFind.getLength())
+ pNewConnData->SetFieldIndex(JTCS_TO,aFind[0]+1);
+ else
+ OSL_FAIL("Column not found!");
+ }
+ pNewConnData->AppendConnLine(*pIter,sRelatedColumn);
+
+ // dann die Conn selber dazu
+ OQueryTableConnection aNewConn(_pView, aNewConnData);
+ // der Verweis auf die lokale Variable ist unkritisch, da NotifyQueryTabConn eine neue Kopie anlegt
+ // und mir hinzufuegen (wenn nicht schon existent)
+ _pView->NotifyTabConnection(aNewConn, sal_False);
+ // don't create an Undo-Action for the new connection : the connection is
+ // covered by the Undo-Action for the tabwin, as the "Undo the insert" will
+ // automatically remove all connections adjacent to the win.
+ // (Because of this automatism we would have an ownerhsip ambiguity for
+ // the connection data if we would insert the conn-Undo-Action)
+ }
+ }
+}
+//==================================================================
+// class OQueryTableView
+//==================================================================
+DBG_NAME(OQueryTableView)
+//------------------------------------------------------------------------
+OQueryTableView::OQueryTableView( Window* pParent,OQueryDesignView* pView)
+ : OJoinTableView( pParent,pView)
+{
+ DBG_CTOR(OQueryTableView,NULL);
+ SetHelpId(HID_CTL_QRYDGNTAB);
+}
+
+//------------------------------------------------------------------------
+OQueryTableView::~OQueryTableView()
+{
+ DBG_DTOR(OQueryTableView,NULL);
+}
+
+//------------------------------------------------------------------------
+sal_Int32 OQueryTableView::CountTableAlias(const String& rName, sal_Int32& rMax)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ sal_Int32 nRet = 0;
+
+ OTableWindowMapIterator aIter = GetTabWinMap()->find(rName);
+ while(aIter != GetTabWinMap()->end())
+ {
+ String aNewName;
+ aNewName = rName;
+ aNewName += '_';
+ aNewName += String::CreateFromInt32(++nRet);
+
+ aIter = GetTabWinMap()->find(aNewName);
+ }
+
+ rMax = nRet;
+
+ return nRet;
+}
+//------------------------------------------------------------------------
+void OQueryTableView::ReSync()
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ TTableWindowData* pTabWinDataList = m_pView->getController().getTableWindowData();
+ OSL_ENSURE((getTableConnections()->size()==0) && (GetTabWinMap()->size()==0),
+ "vor OQueryTableView::ReSync() bitte ClearAll aufrufen !");
+
+ // ich brauche eine Sammlung aller Fensternamen, deren Anlegen schief geht, damit ich die entsprechenden Connections
+ // gar nicht erst anlege
+ ::std::vector<String> arrInvalidTables;
+
+ TTableWindowData::reverse_iterator aIter = pTabWinDataList->rbegin();
+ // Fenster kreieren und einfuegen
+
+ for(;aIter != pTabWinDataList->rend();++aIter)
+ {
+ OQueryTableWindowData* pData = static_cast<OQueryTableWindowData*>(aIter->get());
+ OTableWindow* pTabWin = createWindow(*aIter);
+
+ // ich gehe jetzt NICHT ueber ShowTabWin, da dieses die Daten des Fensters in die Liste des Docs einfuegt, was
+ // schlecht waere, denn genau von dort hole ich sie ja gerade
+ // also Schritt fuer Schritt
+ if (!pTabWin->Init())
+ {
+ // das Initialisieren ging schief, dass heisst, dieses TabWin steht nicht zur Verfuegung, also muss ich es inklusive
+ // seiner Daten am Dokument aufraeumen
+ pTabWin->clearListBox();
+ delete pTabWin;
+ arrInvalidTables.push_back(pData->GetAliasName());
+
+ pTabWinDataList->erase( ::std::remove(pTabWinDataList->begin(),pTabWinDataList->end(),*aIter) ,pTabWinDataList->end());
+ continue;
+ }
+
+ (*GetTabWinMap())[pData->GetAliasName()] = pTabWin; // am Anfang einfuegen, da ich die DataList ja rueckwaerts durchlaufe
+ // wenn in den Daten keine Position oder Groesse steht -> Default
+ if (!pData->HasPosition() && !pData->HasSize())
+ SetDefaultTabWinPosSize(pTabWin);
+
+ pTabWin->Show();
+ }
+
+ // Verbindungen einfuegen
+ TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
+ TTableConnectionData::reverse_iterator aConIter = pTabConnDataList->rbegin();
+
+ for(;aConIter != pTabConnDataList->rend();++aConIter)
+ {
+ OQueryTableConnectionData* pTabConnData = static_cast<OQueryTableConnectionData*>(aConIter->get());
+
+ // gibt es die beiden Tabellen zur Connection ?
+ String strTabExistenceTest = pTabConnData->getReferencingTable()->GetWinName();
+ sal_Bool bInvalid = ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
+ strTabExistenceTest = pTabConnData->getReferencedTable()->GetWinName();
+ bInvalid = bInvalid && ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
+
+ if (bInvalid)
+ { // nein -> Pech gehabt, die Connection faellt weg
+ pTabConnDataList->erase( ::std::remove(pTabConnDataList->begin(),pTabConnDataList->end(),*aConIter) ,pTabConnDataList->end());
+ continue;
+ }
+
+ // adds a new connection to join view and notifies our accessible and invaldates the controller
+ addConnection(new OQueryTableConnection(this, *aConIter));
+ }
+}
+
+//------------------------------------------------------------------------
+void OQueryTableView::ClearAll()
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OJoinTableView::ClearAll();
+
+ SetUpdateMode(sal_True);
+ m_pView->getController().setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+OTableWindow* OQueryTableView::createWindow(const TTableWindowData::value_type& _pData)
+{
+ return new OQueryTableWindow(this,_pData);
+}
+
+//------------------------------------------------------------------------------
+void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn, sal_Bool _bCreateUndoAction)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ // erst mal schauen, ob ich diese Connection schon habe
+ OQueryTableConnection* pTabConn = NULL;
+ const ::std::vector<OTableConnection*>* pConnections = getTableConnections();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pConnections->end();
+ ::std::vector<OTableConnection*>::const_iterator aIter = ::std::find( pConnections->begin(),
+ aEnd,
+ static_cast<const OTableConnection*>(&rNewConn)
+ );
+ if(aIter == aEnd )
+ {
+ aIter = pConnections->begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ if(*static_cast<OQueryTableConnection*>(*aIter) == rNewConn)
+ {
+ pTabConn = static_cast<OQueryTableConnection*>(*aIter);
+ break;
+ }
+ }
+ }
+ else
+ pTabConn = static_cast<OQueryTableConnection*>(*aIter);
+ // nein -> einfuegen
+ if (pTabConn == NULL)
+ {
+ // die neuen Daten ...
+ OQueryTableConnectionData* pNewData = static_cast< OQueryTableConnectionData*>(rNewConn.GetData()->NewInstance());
+ pNewData->CopyFrom(*rNewConn.GetData());
+ TTableConnectionData::value_type aData(pNewData);
+ OQueryTableConnection* pNewConn = new OQueryTableConnection(this, aData);
+ GetConnection(pNewConn);
+
+ connectionModified(this,pNewConn,_bCreateUndoAction);
+ }
+}
+// -----------------------------------------------------------------------------
+OTableWindowData* OQueryTableView::CreateImpl(const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& _sTableName
+ ,const ::rtl::OUString& _rWinName)
+{
+ return new OQueryTableWindowData( _rComposedName, _sTableName,_rWinName );
+}
+//------------------------------------------------------------------------------
+void OQueryTableView::AddTabWin(const ::rtl::OUString& _rTableName, const ::rtl::OUString& _rAliasName, sal_Bool bNewTable)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ // das ist die aus der Basisklasse geerbte Methode, die fuehre ich auf die an meinem Parent zurueck, die mir eventuell einen
+ // Alias dazu bastelt und das an mein anderes AddTabWin weiterreicht
+
+ // leider ist _rTableName voll qualifiziert, das OQueryDesignView erwartet aber einen String, der
+ // nur aus Schema und Tabelle besteht und keinen Katalog enthaelt.
+ Reference< XConnection> xConnection = m_pView->getController().getConnection();
+ if(!xConnection.is())
+ return;
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ ::rtl::OUString sCatalog, sSchema, sTable;
+ ::dbtools::qualifiedNameComponents(xMetaData,
+ _rTableName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ ::rtl::OUString sRealName(sSchema);
+ if (sRealName.getLength())
+ sRealName+= ::rtl::OUString('.');
+ sRealName += sTable;
+
+ AddTabWin(_rTableName, sRealName, _rAliasName, bNewTable);
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("qualifiedNameComponents");
+ }
+}
+// -----------------------------------------------------------------------------
+// find the table which has a foreign key with this referencedTable name
+Reference<XPropertySet> getKeyReferencedTo(const Reference<XIndexAccess>& _rxKeys,const ::rtl::OUString& _rReferencedTable)
+{
+ if(!_rxKeys.is())
+ return Reference<XPropertySet>();
+
+ if ( !_rxKeys.is() )
+ return Reference<XPropertySet>();
+ // search the one and only primary key
+ const sal_Int32 nCount = _rxKeys->getCount();
+ for(sal_Int32 i=0;i<nCount ;++i)
+ {
+ Reference<XPropertySet> xKey(_rxKeys->getByIndex(i),UNO_QUERY);
+ if(xKey.is())
+ {
+ sal_Int32 nKeyType = 0;
+ xKey->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::FOREIGN == nKeyType)
+ {
+ ::rtl::OUString sReferencedTable;
+ xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
+ // TODO check case
+ if(sReferencedTable == _rReferencedTable)
+ return xKey;
+ }
+ }
+ }
+ return Reference<XPropertySet>();
+}
+//------------------------------------------------------------------------------
+void OQueryTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& _rTableName, const ::rtl::OUString& strAlias, sal_Bool bNewTable)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OSL_ENSURE(_rTableName.getLength() || strAlias.getLength(), "OQueryTableView::AddTabWin : kein Tabellen- und kein Aliasname !");
+ // wenn der Tabellenname nicht gesetzt ist, steht das fuer ein Dummy-Fenster, das braucht aber wenigstens einen Alias-Namen
+
+ // neue Datenstruktur erzeugen
+ // first check if this already hav it's data
+ sal_Bool bAppend = bNewTable;
+ TTableWindowData::value_type pNewTabWinData;
+ TTableWindowData* pWindowData = getDesignView()->getController().getTableWindowData();
+ TTableWindowData::iterator aWinIter = pWindowData->begin();
+ TTableWindowData::iterator aWinEnd = pWindowData->end();
+ for(;aWinIter != aWinEnd;++aWinIter)
+ {
+ pNewTabWinData = *aWinIter;
+ if (pNewTabWinData && pNewTabWinData->GetWinName() == strAlias && pNewTabWinData->GetComposedName() == _rComposedName && pNewTabWinData->GetTableName() == _rTableName)
+ break;
+ }
+ if ( !bAppend )
+ bAppend = ( aWinIter == aWinEnd );
+ if ( bAppend )
+ pNewTabWinData = createTableWindowData(_rComposedName, _rTableName, strAlias);
+ // die TabWinData brauche ich nicht in die entsprechende Liste der DocShell eintragen, das macht ShowTabWin
+
+ // neues Fenster erzeugen
+ OQueryTableWindow* pNewTabWin = static_cast<OQueryTableWindow*>(createWindow(pNewTabWinData));
+ // das Init kann ich hier weglassen, da das in ShowTabWin passiert
+
+ // Neue UndoAction
+ OQueryTabWinShowUndoAct* pUndoAction = new OQueryTabWinShowUndoAct(this);
+ pUndoAction->SetTabWin(pNewTabWin); // Fenster
+ sal_Bool bSuccess = ShowTabWin(pNewTabWin, pUndoAction,bAppend);
+ if(!bSuccess)
+ {
+ // reset table window
+ pUndoAction->SetTabWin(NULL);
+ pUndoAction->SetOwnership(sal_False);
+
+ delete pUndoAction;
+ return;
+ }
+
+ // Relationen zwischen den einzelnen Tabellen anzeigen
+ OTableWindowMap* pTabWins = GetTabWinMap();
+ if(bNewTable && !pTabWins->empty() && _rTableName.getLength())
+ {
+ modified();
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ Any(),
+ makeAny(pNewTabWin->GetAccessible())
+ );
+
+ do {
+
+ if ( pNewTabWin->GetData()->isQuery() )
+ break;
+
+ try
+ {
+ //////////////////////////////////////////////////////////////////////
+ // find relations between the table an the tables already inserted
+ Reference< XIndexAccess> xKeyIndex = pNewTabWin->GetData()->getKeys();
+ if ( !xKeyIndex.is() )
+ break;
+
+ Reference<XNameAccess> xFKeyColumns;
+ ::rtl::OUString aReferencedTable;
+ Reference<XColumnsSupplier> xColumnsSupplier;
+
+ const sal_Int32 nKeyCount = xKeyIndex->getCount();
+ for ( sal_Int32 i=0; i<nKeyCount ; ++i )
+ {
+ Reference< XPropertySet > xProp( xKeyIndex->getByIndex(i), UNO_QUERY_THROW );
+ xColumnsSupplier.set( xProp, UNO_QUERY_THROW );
+ xFKeyColumns.set( xColumnsSupplier->getColumns(), UNO_QUERY_THROW );
+
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+
+ switch ( nKeyType )
+ {
+ case KeyType::FOREIGN:
+ { // our new table has a foreign key
+ // so look if the referenced table is already in our list
+ xProp->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= aReferencedTable;
+ OSL_ENSURE(aReferencedTable.getLength(),"Foreign key without referencedTableName");
+
+ OTableWindowMap::const_iterator aIter = pTabWins->find(aReferencedTable);
+ OTableWindowMap::const_iterator aEnd = pTabWins->end();
+ if(aIter == aEnd)
+ {
+ for(aIter = pTabWins->begin();aIter != aEnd;++aIter)
+ {
+ OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second);
+ OSL_ENSURE( pTabWinTmp,"TableWindow is null!" );
+ if ( pTabWinTmp != pNewTabWin && pTabWinTmp->GetComposedName() == aReferencedTable )
+ break;
+ }
+ }
+ if ( aIter != aEnd && pNewTabWin != aIter->second )
+ addConnections( this, *pNewTabWin, *static_cast<OQueryTableWindow*>(aIter->second), xFKeyColumns );
+ }
+ break;
+
+ case KeyType::PRIMARY:
+ {
+ // we have a primary key so look in our list if there exsits a key which this is refered to
+ OTableWindowMap::const_iterator aIter = pTabWins->begin();
+ OTableWindowMap::const_iterator aEnd = pTabWins->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second);
+ if ( pTabWinTmp == pNewTabWin )
+ continue;
+
+ if ( pTabWinTmp->GetData()->isQuery() )
+ continue;
+
+ OSL_ENSURE(pTabWinTmp,"TableWindow is null!");
+ Reference< XPropertySet > xFKKey = getKeyReferencedTo( pTabWinTmp->GetData()->getKeys(), pNewTabWin->GetComposedName() );
+ if ( !xFKKey.is() )
+ continue;
+
+ Reference<XColumnsSupplier> xFKColumnsSupplier( xFKKey, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTColumns( xFKColumnsSupplier->getColumns(), UNO_QUERY_THROW );
+ addConnections( this, *pTabWinTmp, *pNewTabWin, xTColumns );
+ }
+ }
+ break;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ } while ( false );
+ }
+
+ // mein Parent brauche ich, da es vom Loeschen erfahren soll
+ m_pView->getController().addUndoActionAndInvalidate( pUndoAction );
+
+ if (bSuccess && m_lnkTabWinsChangeHandler.IsSet())
+ {
+ TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_ADDED_WIN, pNewTabWin->GetAliasName());
+ m_lnkTabWinsChangeHandler.Call(&aHint);
+ }
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void OQueryTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>(jxdSource.pListBox->GetTabWin());
+ OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>(jxdDest.pListBox->GetTabWin());
+
+ String aSourceFieldName, aDestFieldName;
+ aSourceFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry);
+ aDestFieldName = jxdDest.pListBox->GetEntryText(jxdDest.pEntry);
+
+ OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true);
+ if ( !pConn )
+ {
+ // neues Daten-Objekt
+ OQueryTableConnectionData* pNewConnectionData = new OQueryTableConnectionData(pSourceWin->GetData(), pDestWin->GetData());
+ TTableConnectionData::value_type aNewConnectionData(pNewConnectionData);
+
+ sal_uInt32 nSourceFieldIndex, nDestFieldIndex;
+ ETableFieldType eSourceFieldType, eDestFieldType;
+
+ // Namen/Position/Typ der beiden betroffenen Felder besorgen ...
+ // Source
+
+ nSourceFieldIndex = jxdSource.pListBox->GetModel()->GetAbsPos(jxdSource.pEntry);
+ eSourceFieldType = static_cast< OTableFieldInfo*>(jxdSource.pEntry->GetUserData())->GetKeyType();
+
+ // Dest
+
+ nDestFieldIndex = jxdDest.pListBox->GetModel()->GetAbsPos(jxdDest.pEntry);
+ eDestFieldType = static_cast< OTableFieldInfo*>(jxdDest.pEntry->GetUserData())->GetKeyType();
+
+ // ... und setzen
+
+ pNewConnectionData->SetFieldIndex(JTCS_FROM, nSourceFieldIndex);
+ pNewConnectionData->SetFieldIndex(JTCS_TO, nDestFieldIndex);
+
+ pNewConnectionData->SetFieldType(JTCS_FROM, eSourceFieldType);
+ pNewConnectionData->SetFieldType(JTCS_TO, eDestFieldType);
+
+ pNewConnectionData->AppendConnLine( aSourceFieldName,aDestFieldName );
+
+ OQueryTableConnection aNewConnection(this, aNewConnectionData);
+ NotifyTabConnection(aNewConnection);
+ // wie immer bei NotifyTabConnection ist das Verwenden lokaler Variablen unkritisch, da sowieso eine Kopie erzeugt wird
+ }
+ else
+ {
+ // the connection could point on the other side
+ if(pConn->GetSourceWin() == pDestWin)
+ {
+ String aTmp(aSourceFieldName);
+ aSourceFieldName = aDestFieldName;
+ aDestFieldName = aTmp;
+ }
+
+ pConn->GetData()->AppendConnLine( aSourceFieldName,aDestFieldName );
+
+ connectionModified(this,pConn,sal_False);
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryTableView::ConnDoubleClicked(OTableConnection* pConnection)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ if( openJoinDialog(this,pConnection->GetData(),sal_False) )
+ {
+ connectionModified(this,pConnection,sal_False);
+ SelectConn( pConnection );
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryTableView::createNewConnection()
+{
+ TTableConnectionData::value_type pData(new OQueryTableConnectionData());
+ if( openJoinDialog(this,pData,sal_True) )
+ {
+ OTableWindowMap* pMap = GetTabWinMap();
+ OQueryTableWindow* pSourceWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencingTable()->GetWinName()]);
+ OQueryTableWindow* pDestWin = static_cast< OQueryTableWindow*>((*pMap)[pData->getReferencedTable()->GetWinName()]);
+ // first we have to look if the this connection already exists
+ OTableConnection* pConn = GetTabConn(pSourceWin,pDestWin,true);
+ sal_Bool bNew = sal_True;
+ if ( pConn )
+ {
+ pConn->GetData()->CopyFrom( *pData );
+ bNew = sal_False;
+ }
+ else
+ {
+ // create a new conenction and append it
+ OQueryTableConnection* pQConn = new OQueryTableConnection(this, pData);
+ GetConnection(pQConn);
+ pConn = pQConn;
+ }
+ connectionModified(this,pConn,bNew);
+ if ( !bNew && pConn == GetSelectedConn() ) // our connection was selected before so we have to reselect it
+ SelectConn( pConn );
+ }
+}
+//------------------------------------------------------------------------------
+bool OQueryTableView::RemoveConnection( OTableConnection* _pConnection,sal_Bool /*_bDelete*/ )
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+
+ // we don't want that our connection will be deleted, we put it in the undo manager
+ bool bRet = OJoinTableView::RemoveConnection( _pConnection,sal_False);
+
+ // add undo action
+ addUndoAction( this,
+ new OQueryDelTabConnUndoAction(this),
+ static_cast< OQueryTableConnection*>(_pConnection),
+ sal_True);
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+void OQueryTableView::KeyInput( const KeyEvent& rEvt )
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OJoinTableView::KeyInput( rEvt );
+}
+
+//------------------------------------------------------------------------------
+OQueryTableWindow* OQueryTableView::FindTable(const String& rAliasName)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OSL_ENSURE(rAliasName.Len(), "OQueryTableView::FindTable : der AliasName sollte nicht leer sein !");
+ // (nicht dass es schadet, aber es ist sinnlos und weist vielleicht auf Fehler beim Aufrufer hin)
+ OTableWindowMap::const_iterator aIter = GetTabWinMap()->find(rAliasName);
+ if(aIter != GetTabWinMap()->end())
+ return static_cast<OQueryTableWindow*>(aIter->second);
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OQueryTableView::FindTableFromField(const String& rFieldName, OTableFieldDescRef& rInfo, sal_uInt16& rCnt)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ rCnt = 0;
+ OTableWindowMap::const_iterator aIter = GetTabWinMap()->begin();
+ OTableWindowMap::const_iterator aEnd = GetTabWinMap()->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if(static_cast<OQueryTableWindow*>(aIter->second)->ExistsField(rFieldName, rInfo))
+ ++rCnt;
+ }
+
+ return rCnt == 1;
+}
+
+//------------------------------------------------------------------------------
+void OQueryTableView::RemoveTabWin(OTableWindow* pTabWin)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OSL_ENSURE(pTabWin != NULL, "OQueryTableView::RemoveTabWin : Fenster sollte ungleich NULL sein !");
+
+ // mein Parent brauche ich, da es vom Loeschen erfahren soll
+ OQueryDesignView* pParent = static_cast<OQueryDesignView*>(getDesignView());
+
+ SfxUndoManager& rUndoMgr = m_pView->getController().GetUndoManager();
+ rUndoMgr.EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() );
+
+ // Undo-Action anlegen
+ OQueryTabWinDelUndoAct* pUndoAction = new OQueryTabWinDelUndoAct(this);
+ pUndoAction->SetTabWin(static_cast< OQueryTableWindow*>(pTabWin));
+
+ // und Fenster verstecken
+ HideTabWin(static_cast< OQueryTableWindow*>(pTabWin), pUndoAction);
+
+ // Undo Actions und Loeschen der Felder in SelectionBrowseBox
+ pParent->TableDeleted( static_cast< OQueryTableWindowData*>(pTabWin->GetData().get())->GetAliasName() );
+
+ m_pView->getController().addUndoActionAndInvalidate( pUndoAction );
+ rUndoMgr.LeaveListAction();
+
+ if (m_lnkTabWinsChangeHandler.IsSet())
+ {
+ TabWinsChangeNotification aHint(TabWinsChangeNotification::AT_REMOVED_WIN, static_cast< OQueryTableWindow*>(pTabWin)->GetAliasName());
+ m_lnkTabWinsChangeHandler.Call(&aHint);
+ }
+
+ modified();
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ makeAny(pTabWin->GetAccessible()),
+ Any()
+ );
+}
+
+//------------------------------------------------------------------------
+void OQueryTableView::EnsureVisible(const OTableWindow* pWin)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+
+ Invalidate(INVALIDATE_NOCHILDREN);
+ OJoinTableView::EnsureVisible(pWin);
+}
+
+//------------------------------------------------------------------------
+void OQueryTableView::GetConnection(OQueryTableConnection* pConn)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ // bei mir und dem Dokument einfuegen
+
+ addConnection( pConn );
+}
+
+//------------------------------------------------------------------------
+void OQueryTableView::DropConnection(OQueryTableConnection* pConn)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ // Selektion beachten
+ // bei mir und dem Dokument rausnehmen
+ RemoveConnection( pConn ,sal_False);
+}
+
+//------------------------------------------------------------------------
+void OQueryTableView::HideTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction )
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OTableWindowMap* pTabWins = GetTabWinMap();
+ OSL_ENSURE(pTabWins != NULL, "OQueryTableView::HideTabWin : habe keine TabWins !");
+
+ if (pTabWin)
+ {
+ // Fenster
+ // die Position in seinen Daten speichern
+ getDesignView()->SaveTabWinUIConfig(pTabWin);
+ // (ich muss ueber das Parent gehen, da nur das die Position der Scrollbars kennt)
+ // dann aus der Liste der TabWins raus und verstecken
+ OTableWindowMap::iterator aIter = pTabWins->begin();
+ OTableWindowMap::iterator aEnd = pTabWins->end();
+ for ( ;aIter != aEnd ; ++aIter )
+ if ( aIter->second == pTabWin )
+ {
+ pTabWins->erase( aIter );
+ break;
+ }
+
+ pTabWin->Hide(); // nicht zerstoeren, steht im Undo!!
+
+ // die Daten zum TabWin muessen auch aus meiner Verantwortung entlassen werden
+ TTableWindowData* pTabWinDataList = m_pView->getController().getTableWindowData();
+ pTabWinDataList->erase( ::std::remove(pTabWinDataList->begin(),pTabWinDataList->end(),pTabWin->GetData()),pTabWinDataList->end());
+ // NICHT loeschen, da ja das TabWin selber - das noch lebt - sie auch noch braucht
+ // Entweder geht es irgendwann wieder in meine Verantwortung ueber, (ueber ShowTabWin), dann fuege ich
+ // auch die Daten wieder ein, oder die Undo-Action, die im Augenblick die alleinige Verantwortung fuer das Fenster
+ // und dessen Daten hat, wird zestoert, dann loescht es beides
+
+ if (m_pLastFocusTabWin == pTabWin)
+ m_pLastFocusTabWin = NULL;
+
+ // Verbindungen, die zum Fenster gehoeren, einsammeln und der UndoAction uebergeben
+ sal_Int16 nCnt = 0;
+ const ::std::vector<OTableConnection*>* pTabConList = getTableConnections();
+ ::std::vector<OTableConnection*>::const_iterator aIter2 = pTabConList->begin();
+ for(;aIter2 != pTabConList->end();)// the end may change
+ {
+ OQueryTableConnection* pTmpEntry = static_cast<OQueryTableConnection*>(*aIter2);
+ OSL_ENSURE(pTmpEntry,"OQueryTableConnection is null!");
+ if( pTmpEntry->GetAliasName(JTCS_FROM) == pTabWin->GetAliasName() ||
+ pTmpEntry->GetAliasName(JTCS_TO) == pTabWin->GetAliasName() )
+ {
+ // add to undo list
+ pUndoAction->InsertConnection(pTmpEntry);
+
+ // call base class because we append an undo action
+ // but this time we are in a undo action list
+ OJoinTableView::RemoveConnection(pTmpEntry,sal_False);
+ aIter2 = pTabConList->begin();
+ ++nCnt;
+ }
+ else
+ ++aIter2;
+ }
+
+ if (nCnt)
+ InvalidateConnections();
+
+ m_pView->getController().InvalidateFeature(ID_BROWSER_ADDTABLE);
+
+ // der UndoAction sagen, dass das Fenster (inklusive der Connections) jetzt in seinem Besitzt ist
+ pUndoAction->SetOwnership(sal_True);
+
+ // damit habe ich das Doc natuerlich modifiziert
+ m_pView->getController().setModified( sal_True );
+ m_pView->getController().InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
+ }
+}
+
+//------------------------------------------------------------------------
+sal_Bool OQueryTableView::ShowTabWin( OQueryTableWindow* pTabWin, OQueryTabWinUndoAct* pUndoAction,sal_Bool _bAppend )
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+
+ sal_Bool bSuccess = sal_False;
+
+ if (pTabWin)
+ {
+ if (pTabWin->Init())
+ {
+ TTableWindowData::value_type pData = pTabWin->GetData();
+ OSL_ENSURE(pData != NULL, "OQueryTableView::ShowTabWin : TabWin hat keine Daten !");
+ // Wenn die Daten schon PosSize haben, diese benutzen
+ if (pData->HasPosition() && pData->HasSize())
+ {
+ Size aSize(CalcZoom(pData->GetSize().Width()),CalcZoom(pData->GetSize().Height()));
+ pTabWin->SetPosSizePixel(pData->GetPosition(), aSize);
+ }
+ else
+ // ansonsten selber eine Default-Position ermitteln
+ SetDefaultTabWinPosSize(pTabWin);
+
+ // Fenster zeigen und in Liste eintragen
+ ::rtl::OUString sName = static_cast< OQueryTableWindowData*>(pData.get())->GetAliasName();
+ OSL_ENSURE(GetTabWinMap()->find(sName) == GetTabWinMap()->end(),"Alias name already in list!");
+ GetTabWinMap()->insert(OTableWindowMap::value_type(sName,pTabWin));
+
+ pTabWin->Show();
+
+ pTabWin->Update();
+ // Das Update ist notwendig, damit die Connections an dem Fenster richtig gezeichnet werden. Klingt absurd,
+ // ich weiss. Aber die Listbox haelt sich intern ein Member, was bei ersten Zeichnen (nachdem die Listbox im Init
+ // gerade neu gefuellt wurde) initialisiert wird, und genau dieses Member wird irgendwann benoetigt fuer
+ // GetEntryPos, und dieses wiederum von der Connection, wenn sie ihren Ansatzpunkt am Fenster feststellen will.
+
+ // die Connections
+ ::std::vector<OTableConnection*>* pTableCon = pUndoAction->GetTabConnList();
+ ::std::vector<OTableConnection*>::iterator aIter = pTableCon->begin();
+ ::std::vector<OTableConnection*>::iterator aEnd = pTableCon->end();
+
+ for(;aIter != aEnd;++aIter)
+ addConnection(*aIter); // add all connections from the undo action
+
+ pTableCon->clear();
+
+ // und die Daten des Fensters ebenfalls in Liste (des Docs)
+ if(_bAppend)
+ m_pView->getController().getTableWindowData()->push_back(pTabWin->GetData());
+
+ m_pView->getController().InvalidateFeature(ID_BROWSER_ADDTABLE);
+
+ // und der UndoAction sagen, dass das Fenster jetzt meine ist ...
+ pUndoAction->SetOwnership(sal_False);
+
+ bSuccess = sal_True;
+ }
+ else
+ {
+ //////////////////////////////////////////////////////////////////
+ // Initialisierung fehlgeschlagen
+ // (z.B. wenn Verbindung zur Datenbank in diesem Augenblick unterbrochen worden ist)
+ pTabWin->clearListBox();
+ delete pTabWin;
+ }
+ }
+
+ // damit habe ich das Doc natuerlich modifiziert
+ if(!m_pView->getController().isReadOnly())
+ m_pView->getController().setModified( sal_True );
+
+ m_pView->getController().InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
+
+ return bSuccess;
+}
+//------------------------------------------------------------------------
+void OQueryTableView::InsertField(const OTableFieldDescRef& rInfo)
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ OSL_ENSURE(getDesignView() != NULL, "OQueryTableView::InsertField : habe kein Parent !");
+ static_cast<OQueryDesignView*>(getDesignView())->InsertField(rInfo);
+}
+//------------------------------------------------------------------------------
+sal_Bool OQueryTableView::ExistsAVisitedConn(const OQueryTableWindow* pFrom) const
+{
+ DBG_CHKTHIS(OQueryTableView,NULL);
+ const ::std::vector<OTableConnection*>* pList = getTableConnections();
+ if (pList)
+ {
+ ::std::vector<OTableConnection*>::const_iterator aIter = pList->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pList->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OQueryTableConnection* pTemp = static_cast<OQueryTableConnection*>(*aIter);
+ if (pTemp->IsVisited() &&
+ (pFrom == static_cast< OQueryTableWindow*>(pTemp->GetSourceWin()) || pFrom == static_cast< OQueryTableWindow*>(pTemp->GetDestWin())))
+ return pTemp != NULL;
+ }
+ }
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OQueryTableView::onNoColumns_throw()
+{
+ String sError( ModuleRes( STR_STATEMENT_WITHOUT_RESULT_SET ) );
+ ::dbtools::throwSQLException( sError, ::dbtools::SQL_GENERAL_ERROR, NULL );
+}
+//------------------------------------------------------------------------------
+bool OQueryTableView::supressCrossNaturalJoin(const TTableConnectionData::value_type& _pData) const
+{
+ OQueryTableConnectionData* pQueryData = static_cast<OQueryTableConnectionData*>(_pData.get());
+ return pQueryData && (pQueryData->GetJoinType() == CROSS_JOIN);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx
new file mode 100644
index 000000000000..3f403a4c4892
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryTextView.hxx"
+#include "querycontainerwindow.hxx"
+#include "QueryViewSwitch.hxx"
+#include "sqledit.hxx"
+#include "undosqledit.hxx"
+#include "browserids.hxx"
+#include "querycontroller.hxx"
+#include "dbu_qry.hrc"
+#include "dbustrings.hrc"
+#include <toolkit/unohlp.hxx>
+#include <vcl/split.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/types.hxx>
+#include "QueryDesignView.hxx"
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+// -----------------------------------------------------------------------------
+
+// end of temp classes
+// -------------------------------------------------------------------------
+DBG_NAME(OQueryTextView)
+OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
+ :Window(_pParent)
+{
+ DBG_CTOR(OQueryTextView,NULL);
+ m_pEdit = new OSqlEdit(this);
+ m_pEdit->SetRightToLeft(sal_False);
+ m_pEdit->ClearModifyFlag();
+ m_pEdit->SaveValue();
+ m_pEdit->SetPosPixel( Point( 0, 0 ) );
+ m_pEdit->Show();
+}
+// -----------------------------------------------------------------------------
+OQueryTextView::~OQueryTextView()
+{
+ DBG_DTOR(OQueryTextView,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pEdit);
+ m_pEdit = NULL;
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::GetFocus()
+{
+ if ( m_pEdit )
+ m_pEdit->GrabFocus();
+}
+// -------------------------------------------------------------------------
+void OQueryTextView::Resize()
+{
+ Window::Resize();
+ m_pEdit->SetSizePixel( GetOutputSizePixel() );
+}
+// -----------------------------------------------------------------------------
+// check if the statement is correct when not returning false
+sal_Bool OQueryTextView::checkStatement()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OQueryTextView::getStatement()
+{
+ return m_pEdit->GetText();
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::setReadOnly(sal_Bool _bReadOnly)
+{
+ m_pEdit->SetReadOnly(_bReadOnly);
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::clear()
+{
+ OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( m_pEdit );
+
+ pUndoAct->SetOriginalText( m_pEdit->GetText() );
+ getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( pUndoAct );
+
+ m_pEdit->SetText(String());
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::setStatement(const ::rtl::OUString& _rsStatement)
+{
+ m_pEdit->SetText(_rsStatement);
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::copy()
+{
+ if(!m_pEdit->IsInAccelAct() )
+ m_pEdit->Copy();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryTextView::isCutAllowed()
+{
+ return m_pEdit->GetSelected().Len() != 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryTextView::isPasteAllowed()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryTextView::isCopyAllowed()
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::cut()
+{
+ if(!m_pEdit->IsInAccelAct() )
+ m_pEdit->Cut();
+ getContainerWindow()->getDesignView()->getController().setModified(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OQueryTextView::paste()
+{
+ if(!m_pEdit->IsInAccelAct() )
+ m_pEdit->Paste();
+ getContainerWindow()->getDesignView()->getController().setModified(sal_True);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
new file mode 100644
index 000000000000..0ad058656489
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -0,0 +1,344 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "QueryViewSwitch.hxx"
+#include "QueryDesignView.hxx"
+#include "QueryTextView.hxx"
+#include "querycontainerwindow.hxx"
+#include "dbu_qry.hrc"
+#include "browserids.hxx"
+#include "adtabdlg.hxx"
+#include "querycontroller.hxx"
+#include "sqledit.hxx"
+#include "querycontainerwindow.hxx"
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+DBG_NAME(OQueryViewSwitch)
+OQueryViewSwitch::OQueryViewSwitch(OQueryContainerWindow* _pParent, OQueryController& _rController,const Reference< XMultiServiceFactory >& _rFactory)
+: m_bAddTableDialogWasVisible(sal_False)
+{
+ DBG_CTOR(OQueryViewSwitch,NULL);
+
+ m_pTextView = new OQueryTextView(_pParent);
+ m_pDesignView = new OQueryDesignView( _pParent, _rController, _rFactory );
+}
+// -----------------------------------------------------------------------------
+OQueryViewSwitch::~OQueryViewSwitch()
+{
+ DBG_DTOR(OQueryViewSwitch,NULL);
+ {
+ ::std::auto_ptr<Window> aTemp(m_pTextView);
+ m_pTextView = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pDesignView);
+ m_pDesignView = NULL;
+ }
+}
+// -------------------------------------------------------------------------
+void OQueryViewSwitch::Construct()
+{
+ m_pDesignView->Construct( );
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::initialize()
+{
+ // initially be in SQL mode
+ m_pTextView->Show();
+ m_pDesignView->initialize();
+}
+// -------------------------------------------------------------------------
+void OQueryViewSwitch::resizeDocumentView(Rectangle& _rPlayground)
+{
+ m_pTextView->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
+ m_pDesignView->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryViewSwitch::checkStatement()
+{
+ if(m_pTextView->IsVisible())
+ return m_pTextView->checkStatement();
+ return m_pDesignView->checkStatement();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OQueryViewSwitch::getStatement()
+{
+ if(m_pTextView->IsVisible())
+ return m_pTextView->getStatement();
+ return m_pDesignView->getStatement();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::setReadOnly(sal_Bool _bReadOnly)
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->setReadOnly(_bReadOnly);
+ else
+ m_pDesignView->setReadOnly(_bReadOnly);
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::clear()
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->clear();
+ else
+ m_pDesignView->clear();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::GrabFocus()
+{
+ if ( m_pTextView && m_pTextView->IsVisible() )
+ m_pTextView->GrabFocus();
+ else if ( m_pDesignView && m_pDesignView->IsVisible() )
+ m_pDesignView->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::setStatement(const ::rtl::OUString& _rsStatement)
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->setStatement(_rsStatement);
+ else
+ m_pDesignView->setStatement(_rsStatement);
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::copy()
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->copy();
+ else
+ m_pDesignView->copy();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryViewSwitch::isCutAllowed()
+{
+ if(m_pTextView->IsVisible())
+ return m_pTextView->isCutAllowed();
+ return m_pDesignView->isCutAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryViewSwitch::isCopyAllowed()
+{
+ if(m_pTextView->IsVisible())
+ return m_pTextView->isCopyAllowed();
+ return m_pDesignView->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryViewSwitch::isPasteAllowed()
+{
+ if(m_pTextView->IsVisible())
+ return m_pTextView->isPasteAllowed();
+ return m_pDesignView->isPasteAllowed();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::cut()
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->cut();
+ else
+ m_pDesignView->cut();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::paste()
+{
+ if(m_pTextView->IsVisible())
+ m_pTextView->paste();
+ else
+ m_pDesignView->paste();
+}
+// -----------------------------------------------------------------------------
+OQueryContainerWindow* OQueryViewSwitch::getContainer() const
+{
+ Window* pDesignParent = getDesignView() ? getDesignView()->GetParent() : NULL;
+ return static_cast< OQueryContainerWindow* >( pDesignParent );
+}
+
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::impl_forceSQLView()
+{
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+
+ // hide the "Add Table" dialog
+ m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false;
+ if ( m_bAddTableDialogWasVisible )
+ pAddTabDialog->Hide();
+
+ // tell the views they're in/active
+ m_pDesignView->stopTimer();
+ m_pTextView->getSqlEdit()->startTimer();
+
+ // set the most recent statement at the text view
+ m_pTextView->clear();
+ m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement());
+}
+
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::forceInitialView()
+{
+ OQueryController& rQueryController( static_cast< OQueryController& >( m_pDesignView->getController() ) );
+ const sal_Bool bGraphicalDesign = rQueryController.isGraphicalDesign();
+ if ( !bGraphicalDesign )
+ impl_forceSQLView();
+ else
+ {
+ // tell the text view it's inactive now
+ m_pTextView->getSqlEdit()->stopTimer();
+
+ // update the "Add Table" dialog
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+ if ( pAddTabDialog )
+ pAddTabDialog->Update();
+
+ // initialize the design view
+ m_pDesignView->initByFieldDescriptions( rQueryController.getFieldInformation() );
+
+ // tell the design view it's active now
+ m_pDesignView->startTimer();
+ }
+
+ impl_postViewSwitch( bGraphicalDesign, true );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ sal_Bool bRet = sal_True;
+ sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign();
+
+ if ( !bGraphicalDesign )
+ {
+ impl_forceSQLView();
+ }
+ else
+ {
+ // tell the text view it's inactive now
+ m_pTextView->getSqlEdit()->stopTimer();
+
+ // update the "Add Table" dialog
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+ if ( pAddTabDialog )
+ pAddTabDialog->Update();
+
+ // initialize the design view
+ bRet = m_pDesignView->initByParseIterator( _pErrorInfo );
+
+ // tell the design view it's active now
+ m_pDesignView->startTimer();
+ }
+
+ return impl_postViewSwitch( bGraphicalDesign, bRet );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess )
+{
+ if ( i_bSuccess )
+ {
+ m_pTextView->Show ( !i_bGraphicalDesign );
+ m_pDesignView->Show ( i_bGraphicalDesign );
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+ if ( pAddTabDialog )
+ if ( i_bGraphicalDesign && m_bAddTableDialogWasVisible )
+ pAddTabDialog->Show();
+
+ GrabFocus();
+ }
+
+ OQueryContainerWindow* pContainer = getContainer();
+ if ( pContainer )
+ pContainer->Resize();
+
+ m_pDesignView->getController().ClearUndoManager();
+ m_pDesignView->getController().InvalidateAll();
+
+ return i_bSuccess;
+}
+
+// -----------------------------------------------------------------------------
+OAddTableDlg* OQueryViewSwitch::getAddTableDialog()
+{
+ if ( !m_pDesignView )
+ return NULL;
+ return m_pDesignView->getController().getAddTableDialog();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryViewSwitch::isSlotEnabled(sal_Int32 _nSlotId)
+{
+ return m_pDesignView->isSlotEnabled(_nSlotId);
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable)
+{
+ m_pDesignView->setSlotEnabled(_nSlotId,_bEnable);
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::SaveUIConfig()
+{
+ if(m_pDesignView->IsVisible())
+ m_pDesignView->SaveUIConfig();
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::SetPosSizePixel( Point _rPt,Size _rSize)
+{
+ m_pDesignView->SetPosSizePixel( _rPt,_rSize);
+ m_pDesignView->Resize();
+ m_pTextView->SetPosSizePixel( _rPt,_rSize);
+}
+// -----------------------------------------------------------------------------
+Reference< XMultiServiceFactory > OQueryViewSwitch::getORB() const
+{
+ return m_pDesignView->getORB();
+}
+// -----------------------------------------------------------------------------
+bool OQueryViewSwitch::reset( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ m_pDesignView->reset();
+ if ( !m_pDesignView->initByParseIterator( _pErrorInfo ) )
+ return false;
+
+ if ( switchView( _pErrorInfo ) )
+ return false;
+
+ return true;
+}
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::setNoneVisbleRow(sal_Int32 _nRows)
+{
+ if(m_pDesignView)
+ m_pDesignView->setNoneVisbleRow(_nRows);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
new file mode 100644
index 000000000000..f48ff8767b50
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -0,0 +1,2834 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "SelectionBrowseBox.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "QueryDesignView.hxx"
+#include "querycontroller.hxx"
+#include "QueryTableView.hxx"
+#include "browserids.hxx"
+#include <comphelper/types.hxx>
+#include "TableFieldInfo.hxx"
+#include "dbu_qry.hrc"
+#include "dbaccess_helpid.hrc"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "dbustrings.hrc"
+#include "QTableWindow.hxx"
+#include "QueryTableView.hxx"
+#include <vcl/msgbox.hxx>
+#include "QueryDesignFieldUndoAct.hxx"
+#include <svx/dbexch.hrc>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/extract.hxx>
+#include "sqlmessage.hxx"
+#include "UITools.hxx"
+#include <osl/diagnose.h>
+
+using namespace ::svt;
+using namespace ::dbaui;
+using namespace ::connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::accessibility;
+
+const String g_strOne = String::CreateFromAscii("1");
+const String g_strZero = String::CreateFromAscii("0");
+
+#define DEFAULT_QUERY_COLS 20
+#define DEFAULT_SIZE GetTextWidth(g_strZero) * 30
+#define CHECKBOX_SIZE 10
+#define HANDLE_ID 0
+#define HANDLE_COLUMN_WITDH 70
+
+#define SQL_ISRULEOR2(pParseNode, e1,e2) ((pParseNode)->isRule() && (\
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e1) || \
+ (pParseNode)->getRuleID() == OSQLParser::RuleID(OSQLParseNode::e2)))
+
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ sal_Bool isFieldNameAsterix(const ::rtl::OUString& _sFieldName )
+ {
+ sal_Bool bAsterix = !(_sFieldName.getLength() && _sFieldName.toChar() != '*');
+ if ( !bAsterix )
+ {
+ String sName = _sFieldName;
+ xub_StrLen nTokenCount = sName.GetTokenCount('.');
+ if ( (nTokenCount == 2 && sName.GetToken(1,'.').GetChar(0) == '*' )
+ || (nTokenCount == 3 && sName.GetToken(2,'.').GetChar(0) == '*' ) )
+ {
+ bAsterix = sal_True;
+ }
+ }
+ return bAsterix;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool lcl_SupportsCoreSQLGrammar(const Reference< XConnection>& _xConnection)
+ {
+ sal_Bool bSupportsCoreGrammar = sal_False;
+ if ( _xConnection.is() )
+ {
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
+ bSupportsCoreGrammar = xMetaData.is() && xMetaData->supportsCoreSQLGrammar();
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return bSupportsCoreGrammar;
+ }
+}
+
+DBG_NAME(OSelectionBrowseBox)
+//------------------------------------------------------------------------------
+OSelectionBrowseBox::OSelectionBrowseBox( Window* pParent )
+ :EditBrowseBox( pParent,EBBF_NOROWPICTURE, WB_3DLOOK, BROWSER_COLUMNSELECTION | BROWSER_KEEPSELECTION | BROWSER_HIDESELECT |
+ BROWSER_HIDECURSOR | BROWSER_HLINESFULL | BROWSER_VLINESFULL )
+ ,m_aFunctionStrings(ModuleRes(STR_QUERY_FUNCTIONS))
+ ,m_nVisibleCount(0)
+ ,m_bOrderByUnRelated(sal_True)
+ ,m_bGroupByUnRelated(sal_True)
+ ,m_bStopTimer(sal_False)
+ ,m_bWasEditing(sal_False)
+ ,m_bDisableErrorBox(sal_False)
+ ,m_bInUndoMode(sal_False)
+{
+ DBG_CTOR(OSelectionBrowseBox,NULL);
+ SetHelpId(HID_CTL_QRYDGNCRIT);
+
+ m_nMode = BROWSER_COLUMNSELECTION | BROWSER_HIDESELECT
+ | BROWSER_KEEPSELECTION | BROWSER_HIDECURSOR
+ | BROWSER_HLINESFULL | BROWSER_VLINESFULL
+ | BROWSER_HEADERBAR_NEW ;
+
+ m_pTextCell = new Edit(&GetDataWindow(), 0);
+ m_pVisibleCell = new CheckBoxControl(&GetDataWindow());
+ m_pTableCell = new ListBoxControl(&GetDataWindow()); m_pTableCell->SetDropDownLineCount( 20 );
+ m_pFieldCell = new ComboBoxControl(&GetDataWindow()); m_pFieldCell->SetDropDownLineCount( 20 );
+ m_pOrderCell = new ListBoxControl(&GetDataWindow());
+ m_pFunctionCell = new ListBoxControl(&GetDataWindow()); m_pFunctionCell->SetDropDownLineCount( 20 );
+
+ m_pVisibleCell->SetHelpId(HID_QRYDGN_ROW_VISIBLE);
+ m_pTableCell->SetHelpId(HID_QRYDGN_ROW_TABLE);
+ m_pFieldCell->SetHelpId(HID_QRYDGN_ROW_FIELD);
+ m_pOrderCell->SetHelpId(HID_QRYDGN_ROW_ORDER);
+ m_pFunctionCell->SetHelpId(HID_QRYDGN_ROW_FUNCTION);
+
+ //////////////////////////////////////////////////////////////////////
+ // TriState der ::com::sun::star::form::CheckBox abschalten
+ m_pVisibleCell->GetBox().EnableTriState( sal_False );
+
+ Font aTitleFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE,Window::GetSettings().GetLanguage(),DEFAULTFONT_FLAGS_ONLYONE);
+ aTitleFont.SetSize(Size(0, 6));
+ SetTitleFont(aTitleFont);
+
+ String aTxt(ModuleRes(STR_QUERY_SORTTEXT));
+ xub_StrLen nCount = aTxt.GetTokenCount();
+ xub_StrLen nIdx = 0;
+ for (; nIdx < nCount; nIdx++)
+ m_pOrderCell->InsertEntry(aTxt.GetToken(nIdx));
+
+ for(long i=0;i < BROW_ROW_CNT;i++)
+ m_bVisibleRow.push_back(sal_True);
+
+ m_bVisibleRow[BROW_FUNCTION_ROW] = sal_False; // zuerst ausblenden
+
+ m_timerInvalidate.SetTimeout(200);
+ m_timerInvalidate.SetTimeoutHdl(LINK(this, OSelectionBrowseBox, OnInvalidateTimer));
+ m_timerInvalidate.Start();
+}
+
+//------------------------------------------------------------------------------
+OSelectionBrowseBox::~OSelectionBrowseBox()
+{
+ DBG_DTOR(OSelectionBrowseBox,NULL);
+
+ delete m_pTextCell;
+ delete m_pVisibleCell;
+ delete m_pFieldCell;
+ delete m_pTableCell;
+ delete m_pOrderCell;
+ delete m_pFunctionCell;
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::initialize()
+{
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(xConnection.is())
+ {
+ const IParseContext& rContext = static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext();
+ IParseContext::InternationalKeyCode eFunctions[] = { IParseContext::KEY_AVG,IParseContext::KEY_COUNT,IParseContext::KEY_MAX
+ ,IParseContext::KEY_MIN,IParseContext::KEY_SUM
+ ,IParseContext::KEY_EVERY
+ ,IParseContext::KEY_ANY
+ ,IParseContext::KEY_SOME
+ ,IParseContext::KEY_STDDEV_POP
+ ,IParseContext::KEY_STDDEV_SAMP
+ ,IParseContext::KEY_VAR_SAMP
+ ,IParseContext::KEY_VAR_POP
+ ,IParseContext::KEY_COLLECT
+ ,IParseContext::KEY_FUSION
+ ,IParseContext::KEY_INTERSECTION
+ };
+
+ String sGroup = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount() - 1);
+ m_aFunctionStrings = m_aFunctionStrings.GetToken(0);
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(eFunctions); ++i)
+ {
+ m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
+ m_aFunctionStrings += String(ByteString(rContext.getIntlKeywordAscii(eFunctions[i])),RTL_TEXTENCODING_UTF8);
+
+ }
+ m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
+ m_aFunctionStrings += sGroup;
+
+ // Diese Funktionen stehen nur unter CORE zur Verf�gung
+ if ( lcl_SupportsCoreSQLGrammar(xConnection) )
+ {
+ xub_StrLen nCount = m_aFunctionStrings.GetTokenCount();
+ for (xub_StrLen nIdx = 0; nIdx < nCount; nIdx++)
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(nIdx));
+ }
+ else // sonst nur COUNT(*)
+ {
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(0));
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
+ }
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ if ( xMetaData.is() )
+ {
+ m_bOrderByUnRelated = xMetaData->supportsOrderByUnrelated();
+ m_bGroupByUnRelated = xMetaData->supportsGroupByUnrelated();
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+
+ Init();
+}
+//==============================================================================
+OQueryDesignView* OSelectionBrowseBox::getDesignView()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(static_cast<const OQueryDesignView*>(GetParent()),"Parent isn't an OQueryDesignView!");
+ return static_cast<OQueryDesignView*>(GetParent());
+}
+// -----------------------------------------------------------------------------
+OQueryDesignView* OSelectionBrowseBox::getDesignView() const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(static_cast<const OQueryDesignView*>(GetParent()),"Parent isn't an OQueryDesignView!");
+ return static_cast<OQueryDesignView*>(GetParent());
+}
+namespace
+{
+ class OSelectionBrwBoxHeader : public ::svt::EditBrowserHeader
+ {
+ OSelectionBrowseBox* m_pBrowseBox;
+ protected:
+ virtual void Select();
+ public:
+ OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent);
+ };
+ OSelectionBrwBoxHeader::OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent)
+ : ::svt::EditBrowserHeader(pParent,WB_BUTTONSTYLE|WB_DRAG)
+ ,m_pBrowseBox(pParent)
+ {
+ }
+
+ void OSelectionBrwBoxHeader::Select()
+ {
+ EditBrowserHeader::Select();
+ m_pBrowseBox->GrabFocus();
+
+ BrowserMode nMode = m_pBrowseBox->GetMode();
+ if ( 0 == m_pBrowseBox->GetSelectColumnCount() )
+ {
+ m_pBrowseBox->DeactivateCell();
+ // wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
+ if ( BROWSER_HIDESELECT == ( nMode & BROWSER_HIDESELECT ) )
+ {
+ nMode &= ~BROWSER_HIDESELECT;
+ nMode |= BROWSER_MULTISELECTION;
+ m_pBrowseBox->SetMode( nMode );
+ }
+ }
+ m_pBrowseBox->SelectColumnId( GetCurItemId() );
+ m_pBrowseBox->DeactivateCell();
+ }
+}
+
+// -----------------------------------------------------------------------------
+BrowserHeader* OSelectionBrowseBox::imp_CreateHeaderBar(BrowseBox* /*pParent*/)
+{
+ return new OSelectionBrwBoxHeader(this);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::ColumnMoved( sal_uInt16 nColId,sal_Bool _bCreateUndo )
+{
+ EditBrowseBox::ColumnMoved( nColId );
+ // swap the two columns
+ sal_uInt16 nNewPos = GetColumnPos( nColId );
+ OTableFields& rFields = getFields();
+ if ( rFields.size() > sal_uInt16(nNewPos-1) )
+ {
+ sal_uInt16 nOldPos = 0;
+ OTableFields::iterator aEnd = rFields.end();
+ OTableFields::iterator aIter = rFields.begin();
+ for (; aIter != aEnd && ( (*aIter)->GetColumnId() != nColId ); ++aIter,++nOldPos)
+ ;
+
+ OSL_ENSURE( (nNewPos-1) != nOldPos && nOldPos < rFields.size(),"Old and new position are equal!");
+ if ( aIter != aEnd )
+ {
+ OTableFieldDescRef pOldEntry = rFields[nOldPos];
+ rFields.erase(rFields.begin() + nOldPos);
+ rFields.insert(rFields.begin() + nNewPos - 1,pOldEntry);
+
+ // create the undo action
+ if ( !m_bInUndoMode && _bCreateUndo )
+ {
+ OTabFieldMovedUndoAct* pUndoAct = new OTabFieldMovedUndoAct(this);
+ pUndoAct->SetColumnPosition( nOldPos + 1);
+ pUndoAct->SetTabFieldDescr(pOldEntry);
+
+ getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
+ }
+ }
+ }
+ else
+ OSL_FAIL("Invalid column id!");
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::Init()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+
+ EditBrowseBox::Init();
+
+ // set the header bar
+ BrowserHeader* pNewHeaderBar = CreateHeaderBar(this);
+ pNewHeaderBar->SetMouseTransparent(sal_False);
+
+ SetHeaderBar(pNewHeaderBar);
+ SetMode(m_nMode);
+
+ Font aFont( GetDataWindow().GetFont() );
+ aFont.SetWeight( WEIGHT_NORMAL );
+ GetDataWindow().SetFont( aFont );
+
+ Size aHeight;
+ const Control* pControls[] = { m_pTextCell,m_pVisibleCell,m_pTableCell,m_pFieldCell };
+ for(sal_Size i= 0; i < SAL_N_ELEMENTS(pControls);++i)
+ {
+ const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ }
+ SetDataRowHeight(aHeight.Height());
+ SetTitleLines(1);
+ // Anzahl der sichtbaren Zeilen ermitteln
+ for(long i=0;i<BROW_ROW_CNT;i++)
+ {
+ if(m_bVisibleRow[i])
+ m_nVisibleCount++;
+ }
+ RowInserted(0, m_nVisibleCount, sal_False);
+ try
+ {
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(xConnection.is())
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ m_nMaxColumns = xMetaData.is() ? xMetaData->getMaxColumnsInSelect() : 0;
+
+ }
+ else
+ m_nMaxColumns = 0;
+ }
+ catch(const SQLException&)
+ {
+ OSL_FAIL("Catched Exception when asking for database metadata options!");
+ m_nMaxColumns = 0;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::PreFill()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ SetUpdateMode(sal_False);
+
+ if (GetCurRow() != 0)
+ GoToRow(0);
+
+
+ static_cast< OQueryController& >( getDesignView()->getController() ).clearFields();
+
+ DeactivateCell();
+
+ RemoveColumns();
+ InsertHandleColumn( HANDLE_COLUMN_WITDH );
+ SetUpdateMode(sal_True);
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::ClearAll()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ SetUpdateMode(sal_False);
+
+ OTableFields::reverse_iterator aIter = getFields().rbegin();
+ for ( ;aIter != getFields().rend(); ++aIter )
+ {
+ if ( !(*aIter)->IsEmpty() )
+ {
+ RemoveField( (*aIter)->GetColumnId() );
+ aIter = getFields().rbegin();
+ }
+ }
+ SetUpdateMode(sal_True);
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::SetReadOnly(sal_Bool bRO)
+{
+ if (bRO)
+ {
+ DeactivateCell();
+ m_nMode &= ~BROWSER_HIDECURSOR;
+ SetMode(m_nMode);
+ }
+ else
+ {
+ m_nMode |= BROWSER_HIDECURSOR;
+ SetMode(m_nMode);
+ ActivateCell();
+ }
+}
+
+//------------------------------------------------------------------------------
+CellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if ( nColId > getFields().size() )
+ return NULL;
+ OTableFieldDescRef pEntry = getFields()[nColId-1];
+ OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::GetController : keine FieldDescription !");
+
+ if (!pEntry.is())
+ return NULL;
+
+ if (static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
+ return NULL;
+
+ long nCellIndex = GetRealRow(nRow);
+ switch (nCellIndex)
+ {
+ case BROW_FIELD_ROW:
+ return new ComboBoxCellController(m_pFieldCell);
+ case BROW_TABLE_ROW:
+ return new ListBoxCellController(m_pTableCell);
+ case BROW_VIS_ROW:
+ return new CheckBoxCellController(m_pVisibleCell);
+ case BROW_ORDER_ROW:
+ return new ListBoxCellController(m_pOrderCell);
+ case BROW_FUNCTION_ROW:
+ return new ListBoxCellController(m_pFunctionCell);
+ default:
+ return new EditCellController(m_pTextCell);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(nColId != BROWSER_INVALIDID,"An Invalid Id was set!");
+ if ( nColId == BROWSER_INVALIDID )
+ return;
+ sal_uInt16 nPos = GetColumnPos(nColId);
+ if ( nPos == 0 || nPos == BROWSER_INVALIDID || nPos > getFields().size() )
+ return;
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::InitController : keine FieldDescription !");
+ long nCellIndex = GetRealRow(nRow);
+
+ switch (nCellIndex)
+ {
+ case BROW_FIELD_ROW:
+ {
+ m_pFieldCell->Clear();
+ m_pFieldCell->SetText(String());
+
+ String aField(pEntry->GetField());
+ String aTable(pEntry->GetAlias());
+
+ getDesignView()->fillValidFields(aTable, m_pFieldCell);
+
+ // * durch alias.* ersetzen
+ if ((aField.GetChar(0) == '*') && aTable.Len())
+ {
+ aField = aTable;
+ aField.AppendAscii(".*");
+ }
+ m_pFieldCell->SetText(aField);
+ } break;
+ case BROW_TABLE_ROW:
+ {
+ m_pTableCell->Clear();
+ enableControl(pEntry,m_pTableCell);
+ if ( !pEntry->isCondition() )
+ {
+ OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
+ if (pTabWinList)
+ {
+ OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end();
+
+ for(;aIter != aEnd;++aIter)
+ m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second)->GetAliasName());
+
+ m_pTableCell->InsertEntry(String(ModuleRes(STR_QUERY_NOTABLE)), 0);
+ if (pEntry->GetAlias().getLength())
+ m_pTableCell->SelectEntry(pEntry->GetAlias());
+ else
+ m_pTableCell->SelectEntry(String(ModuleRes(STR_QUERY_NOTABLE)));
+ }
+ }
+ } break;
+ case BROW_VIS_ROW:
+ {
+ m_pVisibleCell->GetBox().Check(pEntry->IsVisible());
+ m_pVisibleCell->GetBox().SaveValue();
+
+ enableControl(pEntry,m_pTextCell);
+
+ if(!pEntry->IsVisible() && pEntry->GetOrderDir() != ORDER_NONE && !m_bOrderByUnRelated)
+ {
+ // Spalte muss sichtbar sein, um im ORDER BY aufzutauchen
+ pEntry->SetVisible(sal_True);
+ m_pVisibleCell->GetBox().Check(pEntry->IsVisible());
+ m_pVisibleCell->GetBox().SaveValue();
+ m_pVisibleCell->GetBox().Disable();
+ m_pVisibleCell->GetBox().EnableInput(sal_False);
+ String aMessage(ModuleRes(STR_QRY_ORDERBY_UNRELATED));
+ OQueryDesignView* paDView = getDesignView();
+ InfoBox(paDView, aMessage).Execute();
+ }
+ } break;
+ case BROW_ORDER_ROW:
+ m_pOrderCell->SelectEntryPos(
+ sal::static_int_cast< sal_uInt16 >(pEntry->GetOrderDir()));
+ enableControl(pEntry,m_pOrderCell);
+ break;
+ case BROW_COLUMNALIAS_ROW:
+ setTextCellContext(pEntry,pEntry->GetFieldAlias(),HID_QRYDGN_ROW_ALIAS);
+ break;
+ case BROW_FUNCTION_ROW:
+ setFunctionCell(pEntry);
+ break;
+ default:
+ {
+ sal_uInt16 nIdx = sal_uInt16(nCellIndex - BROW_CRIT1_ROW);
+ setTextCellContext(pEntry,pEntry->GetCriteria( nIdx ),HID_QRYDGN_ROW_CRIT);
+ }
+ }
+ Controller()->ClearModified();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::notifyTableFieldChanged(const String& _sOldAlias,const String& _sAlias,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
+{
+ appendUndoAction(_sOldAlias,_sAlias,BROW_TABLE_ROW,_bListAction);
+ if ( m_bVisibleRow[BROW_TABLE_ROW] )
+ RowModified(GetBrowseRow(BROW_TABLE_ROW), _nColumnId);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::notifyFunctionFieldChanged(const String& _sOldFunctionName,const String& _sFunctionName,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
+{
+ appendUndoAction(_sOldFunctionName,_sFunctionName,BROW_FUNCTION_ROW,_bListAction);
+ if ( !m_bVisibleRow[BROW_FUNCTION_ROW] )
+ SetRowVisible(BROW_FUNCTION_ROW, sal_True);
+ RowModified(GetBrowseRow(BROW_FUNCTION_ROW), _nColumnId);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::clearEntryFunctionField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
+{
+ if ( isFieldNameAsterix( _sFieldName ) && (!_pEntry->isNoneFunction() || _pEntry->IsGroupBy()) )
+ {
+ String sFunctionName;
+ GetFunctionName(SQL_TOKEN_COUNT,sFunctionName);
+ String sOldLocalizedFunctionName = _pEntry->GetFunction();
+ if ( !sOldLocalizedFunctionName.Equals(sFunctionName) || _pEntry->IsGroupBy() )
+ {
+ // append undo action for the function field
+ _pEntry->SetFunctionType(FKT_NONE);
+ _pEntry->SetFunction(::rtl::OUString());
+ _pEntry->SetGroupBy(sal_False);
+ notifyFunctionFieldChanged(sOldLocalizedFunctionName,_pEntry->GetFunction(),_bListAction,_nColumnId);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::fillColumnRef(const OSQLParseNode* _pColumnRef, const Reference< XConnection >& _rxConnection, OTableFieldDescRef& _pEntry, sal_Bool& _bListAction )
+{
+ OSL_ENSURE(_pColumnRef,"No valid parsenode!");
+ ::rtl::OUString sColumnName,sTableRange;
+ OSQLParseTreeIterator::getColumnRange(_pColumnRef,_rxConnection,sColumnName,sTableRange);
+ return fillColumnRef(sColumnName,sTableRange,_rxConnection->getMetaData(),_pEntry,_bListAction);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::fillColumnRef(const ::rtl::OUString& _sColumnName,const ::rtl::OUString& _sTableRange,const Reference<XDatabaseMetaData>& _xMetaData,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction)
+{
+ sal_Bool bError = sal_False;
+ ::comphelper::UStringMixEqual bCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
+ // check if the table name is the same
+ if ( _sTableRange.getLength() && (bCase(_pEntry->GetTable(),_sTableRange) || bCase(_pEntry->GetAlias(),_sTableRange)) )
+ { // a table was already inserted and the tables contains that column name
+
+ if ( !_pEntry->GetTabWindow() )
+ { // fill tab window
+ ::rtl::OUString sOldAlias = _pEntry->GetAlias();
+ if ( !fillEntryTable(_pEntry,_pEntry->GetTable()) )
+ fillEntryTable(_pEntry,_pEntry->GetAlias()); // only when the first failed
+ if ( !bCase(sOldAlias,_pEntry->GetAlias()) )
+ notifyTableFieldChanged(sOldAlias,_pEntry->GetAlias(),_bListAction,GetCurColumnId());
+ }
+ }
+ // check if the table window
+ OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(_pEntry->GetTabWindow());
+ if ( !pEntryTab ) // no table found with this name so we have to travel through all tables
+ {
+ OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
+ if ( pTabWinList )
+ {
+ sal_uInt16 nTabCount = 0;
+ if ( !static_cast<OQueryTableView*>(getDesignView()->getTableView())->FindTableFromField(_sColumnName,_pEntry,nTabCount) ) // error occurred: column not in table window
+ {
+ String sErrorMsg(ModuleRes(RID_STR_FIELD_DOESNT_EXIST));
+ sErrorMsg.SearchAndReplaceAscii("$name$",_sColumnName);
+ OSQLWarningBox( this, sErrorMsg ).Execute();
+ bError = sal_True;
+ }
+ else
+ {
+ pEntryTab = static_cast<OQueryTableWindow*>(_pEntry->GetTabWindow());
+ notifyTableFieldChanged(String(),_pEntry->GetAlias(),_bListAction,GetCurColumnId());
+ }
+ }
+ }
+ if ( pEntryTab ) // here we got a valid table
+ _pEntry->SetField(_sColumnName);
+
+ return bError;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction)
+{
+ sal_Bool bError = sal_False;
+
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+
+ // first look if the name can be found in our tables
+ sal_uInt16 nTabCount = 0;
+ String sOldAlias = _pEntry->GetAlias();
+ if ( static_cast<OQueryTableView*>(getDesignView()->getTableView())->FindTableFromField(_sFieldName,_pEntry,nTabCount) )
+ {
+ // append undo action for the alias name
+ _pEntry->SetField(_sFieldName);
+ notifyTableFieldChanged(sOldAlias,_pEntry->GetAlias(),_bListAction,GetCurColumnId());
+ clearEntryFunctionField(_sFieldName,_pEntry,_bListAction,_pEntry->GetColumnId());
+ return bError;
+ }
+
+ Reference<XConnection> xConnection( rController.getConnection() );
+ Reference< XDatabaseMetaData > xMetaData;
+ if ( xConnection.is() )
+ xMetaData = xConnection->getMetaData();
+ OSL_ENSURE( xMetaData.is(), "OSelectionBrowseBox::saveField: invalid connection/meta data!" );
+ if ( !xMetaData.is() )
+ return sal_True;
+
+ ::rtl::OUString sErrorMsg;
+ // second test if the name can be set as select columns in a pseudo statement
+ // we have to look which entries we should quote
+
+ const ::rtl::OUString sFieldAlias = _pEntry->GetFieldAlias();
+ size_t nPass = 4;
+ ::connectivity::OSQLParser& rParser( rController.getParser() );
+ OSQLParseNode* pParseNode = NULL;
+ // 4 passes in trying to interprete the field name
+ // - don't quote the field name, parse internationally
+ // - don't quote the field name, parse en-US
+ // - quote the field name, parse internationally
+ // - quote the field name, parse en-US
+ do
+ {
+ bool bQuote = ( nPass <= 2 );
+ bool bInternational = ( nPass % 2 ) == 0;
+
+ ::rtl::OUString sSql;
+ if ( bQuote )
+ sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), _sFieldName );
+ else
+ sSql += _sFieldName;
+
+ if ( _pEntry->isAggreateFunction() )
+ {
+ OSL_ENSURE(_pEntry->GetFunction().getLength(),"Functionname darf hier nicht leer sein! ;-(");
+ ::rtl::OUStringBuffer aTmpStr2( _pEntry->GetFunction());
+ aTmpStr2.appendAscii("(");
+ aTmpStr2.append(sSql);
+ aTmpStr2.appendAscii(")");
+ sSql = aTmpStr2.makeStringAndClear();
+ }
+
+ sSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")) + sSql;
+ if ( sFieldAlias.getLength() )
+ { // always quote the alias name there canbe no function in it
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), sFieldAlias );
+ }
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x"));
+
+ pParseNode = rParser.parseTree( sErrorMsg, sSql, bInternational );
+ }
+ while ( ( pParseNode == NULL ) && ( --nPass > 0 ) );
+
+ if ( pParseNode == NULL )
+ {
+ // something different which we have to check (may be a select statement)
+ String sErrorMessage( ModuleRes( STR_QRY_COLUMN_NOT_FOUND ) );
+ sErrorMessage.SearchAndReplaceAscii("$name$",_sFieldName);
+ OSQLWarningBox( this, sErrorMessage ).Execute();
+ return sal_True;
+ }
+
+ // we got a valid select column
+ // find what type of column has be inserted
+ ::connectivity::OSQLParseNode* pSelection = pParseNode->getChild(2);
+ if ( SQL_ISRULE(pSelection,selection) ) // we found the asterix
+ {
+ _pEntry->SetField(_sFieldName);
+ clearEntryFunctionField(_sFieldName,_pEntry,_bListAction,_pEntry->GetColumnId());
+ } // travel through the select column parse node
+ else
+ {
+ ::comphelper::UStringMixEqual bCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
+
+ OTableFieldDescRef aSelEntry = _pEntry;
+ sal_uInt16 nColumnId = aSelEntry->GetColumnId();
+
+ sal_uInt32 nCount = pSelection->count();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ if ( i > 0 ) // may we have to append more than one field
+ {
+ sal_uInt16 nColumnPostion;
+ aSelEntry = FindFirstFreeCol(nColumnPostion);
+ if ( !aSelEntry.is() )
+ {
+ AppendNewCol(1);
+ aSelEntry = FindFirstFreeCol(nColumnPostion);
+ }
+ ++nColumnPostion;
+ nColumnId = GetColumnId(nColumnPostion);
+ }
+
+ ::connectivity::OSQLParseNode* pChild = pSelection->getChild( i );
+ OSL_ENSURE(SQL_ISRULE(pChild,derived_column), "No derived column found!");
+ // get the column alias
+ ::rtl::OUString sColumnAlias = OSQLParseTreeIterator::getColumnAlias(pChild);
+ if ( sColumnAlias.getLength() ) // we found an as clause
+ {
+ String aSelectionAlias = aSelEntry->GetFieldAlias();
+ aSelEntry->SetFieldAlias( sColumnAlias );
+ // append undo
+ appendUndoAction(aSelectionAlias,aSelEntry->GetFieldAlias(),BROW_COLUMNALIAS_ROW,_bListAction);
+ if ( m_bVisibleRow[BROW_COLUMNALIAS_ROW] )
+ RowModified(GetBrowseRow(BROW_COLUMNALIAS_ROW), nColumnId);
+ }
+
+ ::connectivity::OSQLParseNode* pColumnRef = pChild->getChild(0);
+ if (
+ pColumnRef->count() == 3 &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
+ )
+ pColumnRef = pColumnRef->getChild(1);
+
+ if ( SQL_ISRULE(pColumnRef,column_ref) ) // we found a valid column name or more column names
+ {
+ // look if we can find the corresponding table
+ bError = fillColumnRef( pColumnRef, xConnection, aSelEntry, _bListAction );
+
+ // we found a simple column so we must clear the function fields but only when the column name is '*'
+ // and the function is different to count
+ clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId);
+ }
+ else
+ {
+ // first check if we have a aggregate function and only a function
+ if ( SQL_ISRULE(pColumnRef,general_set_fct) )
+ {
+ String sLocalizedFunctionName;
+ if ( GetFunctionName(pColumnRef->getChild(0)->getTokenID(),sLocalizedFunctionName) )
+ {
+ String sOldLocalizedFunctionName = aSelEntry->GetFunction();
+ aSelEntry->SetFunction(sLocalizedFunctionName);
+ sal_uInt32 nFunCount = pColumnRef->count() - 1;
+ sal_Int32 nFunctionType = FKT_AGGREGATE;
+ sal_Bool bQuote = sal_False;
+ // may be there exists only one parameter which is a column, fill all information into our fields
+ if ( nFunCount == 4 && SQL_ISRULE(pColumnRef->getChild(3),column_ref) )
+ bError = fillColumnRef( pColumnRef->getChild(3), xConnection, aSelEntry, _bListAction );
+ else if ( nFunCount == 3 ) // we have a COUNT(*) here, so take the first table
+ bError = fillColumnRef( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), ::rtl::OUString(), xMetaData, aSelEntry, _bListAction );
+ else
+ {
+ nFunctionType |= FKT_NUMERIC;
+ bQuote = sal_True;
+ aSelEntry->SetDataType(DataType::DOUBLE);
+ aSelEntry->SetFieldType(TAB_NORMAL_FIELD);
+ }
+
+ // now parse the parameters
+ ::rtl::OUString sParameters;
+ for(sal_uInt32 function = 2; function < nFunCount; ++function) // we only want to parse the parameters of the function
+ pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, bQuote );
+
+ aSelEntry->SetFunctionType(nFunctionType);
+ aSelEntry->SetField(sParameters);
+ if ( aSelEntry->IsGroupBy() )
+ {
+ sOldLocalizedFunctionName = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1);
+ aSelEntry->SetGroupBy(sal_False);
+ }
+
+ // append undo action
+ notifyFunctionFieldChanged(sOldLocalizedFunctionName,sLocalizedFunctionName,_bListAction, nColumnId);
+ }
+ else
+ OSL_FAIL("Unsupported function inserted!");
+
+ }
+ else
+ {
+ // so we first clear the function field
+ clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId);
+ ::rtl::OUString sFunction;
+ pColumnRef->parseNodeToStr( sFunction,
+ xConnection,
+ &rController.getParser().getContext(),
+ sal_True,
+ sal_True); // quote is to true because we need quoted elements inside the function
+
+ getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry);
+
+ if( SQL_ISRULEOR2(pColumnRef,position_exp,extract_exp) ||
+ SQL_ISRULEOR2(pColumnRef,fold,char_substring_fct) ||
+ SQL_ISRULEOR2(pColumnRef,length_exp,char_value_fct) )
+ // a calculation has been found ( can be calc and function )
+ {
+ // now parse the whole statement
+ sal_uInt32 nFunCount = pColumnRef->count();
+ ::rtl::OUString sParameters;
+ for(sal_uInt32 function = 0; function < nFunCount; ++function)
+ pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, sal_True );
+
+ sOldAlias = aSelEntry->GetAlias();
+ sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER;
+ aSelEntry->SetFunctionType(nNewFunctionType);
+ aSelEntry->SetField(sParameters);
+ }
+ else
+ {
+ aSelEntry->SetFieldAlias(sColumnAlias);
+ if ( SQL_ISRULE(pColumnRef,set_fct_spec) )
+ aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER);
+ else
+ {
+ if ( SQL_ISRULEOR2(pColumnRef,num_value_exp,term) || SQL_ISRULE(pColumnRef,factor) )
+ aSelEntry->SetDataType(DataType::DOUBLE);
+ else if ( SQL_ISRULE(pColumnRef,value_exp) )
+ aSelEntry->SetDataType(DataType::TIMESTAMP);
+ else
+ aSelEntry->SetDataType(DataType::VARCHAR);
+ aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER);
+ }
+ }
+
+ aSelEntry->SetAlias(::rtl::OUString());
+ notifyTableFieldChanged(sOldAlias,aSelEntry->GetAlias(),_bListAction, nColumnId);
+ }
+
+ }
+ if ( i > 0 && !InsertField(aSelEntry,BROWSER_INVALIDID,sal_True,sal_False).is() ) // may we have to append more than one field
+ { // the field could not be isnerted
+ String sErrorMessage( ModuleRes( RID_STR_FIELD_DOESNT_EXIST ) );
+ sErrorMessage.SearchAndReplaceAscii("$name$",aSelEntry->GetField());
+ OSQLWarningBox( this, sErrorMessage ).Execute();
+ bError = sal_True;
+ }
+ }
+ }
+ delete pParseNode;
+
+ return bError;
+}
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::SaveModified()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+ OTableFieldDescRef pEntry = NULL;
+ sal_uInt16 nCurrentColumnPos = GetColumnPos(GetCurColumnId());
+ if(getFields().size() > static_cast<sal_uInt16>(nCurrentColumnPos - 1))
+ pEntry = getEntry(nCurrentColumnPos - 1);
+
+ sal_Bool bWasEmpty = pEntry.is() ? pEntry->IsEmpty() : sal_False;
+ sal_Bool bError = sal_False;
+ sal_Bool bListAction = sal_False;
+
+ if (pEntry.is() && Controller().Is() && Controller()->IsModified())
+ {
+ // fuer die Undo-Action
+ String strOldCellContents,sNewValue;
+ long nRow = GetRealRow(GetCurRow());
+ sal_Bool bAppendRow = sal_False;
+ switch (nRow)
+ {
+ case BROW_VIS_ROW:
+ {
+ sal_Bool bOldValue = m_pVisibleCell->GetBox().GetSavedValue() != STATE_NOCHECK;
+ strOldCellContents = bOldValue ? g_strOne : g_strZero;
+ sNewValue = !bOldValue ? g_strOne : g_strZero;
+ }
+ if((m_bOrderByUnRelated || pEntry->GetOrderDir() == ORDER_NONE) &&
+ (m_bGroupByUnRelated || !pEntry->IsGroupBy()))
+ {
+ pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked());
+ }
+ else
+ {
+ pEntry->SetVisible(sal_True);
+ m_pVisibleCell->GetBox().Check();
+ }
+ break;
+
+ case BROW_FIELD_ROW:
+ {
+ String aFieldName(m_pFieldCell->GetText());
+ try
+ {
+ if (!aFieldName.Len())
+ {
+ OTableFieldDescRef pNewEntry = new OTableFieldDesc();
+ pNewEntry->SetColumnId( pEntry->GetColumnId() );
+ ::std::replace(getFields().begin(),getFields().end(),pEntry,pNewEntry);
+ sal_uInt16 nCol = GetCurColumnId();
+ for (int i = 0; i < m_nVisibleCount; i++) // Spalte neu zeichnen
+ RowModified(i,nCol);
+ }
+ else
+ {
+ strOldCellContents = pEntry->GetField();
+ bListAction = sal_True;
+ if ( !m_bInUndoMode )
+ rController.GetUndoManager().EnterListAction(String(),String());
+
+ sal_uInt16 nPos = m_pFieldCell->GetEntryPos(aFieldName);
+ String aAliasName = pEntry->GetAlias();
+ if ( nPos != COMBOBOX_ENTRY_NOTFOUND && !aAliasName.Len() && aFieldName.GetTokenCount('.') > 1 )
+ { // special case, we have a table field so we must cut the table name
+ String sTableAlias = aFieldName.GetToken(0,'.');
+ pEntry->SetAlias(sTableAlias);
+ String sColumnName = aFieldName.Copy(sTableAlias.Len()+1,aFieldName.Len() - sTableAlias.Len() -1);
+ Reference<XConnection> xConnection = rController.getConnection();
+ if ( !xConnection.is() )
+ return sal_False;
+ bError = fillColumnRef( sColumnName, sTableAlias, xConnection->getMetaData(), pEntry, bListAction );
+ }
+ else
+ bError = sal_True;
+
+ if ( bError )
+ bError = saveField(aFieldName,pEntry,bListAction);
+ }
+ }
+ catch(Exception&)
+ {
+ bError = sal_True;
+ }
+ if ( bError )
+ {
+ sNewValue = aFieldName;
+ if ( !m_bInUndoMode )
+ static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().LeaveListAction();
+ bListAction = sal_False;
+ }
+ else
+ sNewValue = pEntry->GetField();
+ rController.InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
+ }
+ break;
+
+ case BROW_TABLE_ROW:
+ {
+ String aAliasName = m_pTableCell->GetSelectEntry();
+ strOldCellContents = pEntry->GetAlias();
+ if ( m_pTableCell->GetSelectEntryPos() != 0 )
+ {
+ pEntry->SetAlias(aAliasName);
+ // we have to set the table name as well as the table window
+ OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
+ if (pTabWinList)
+ {
+ OJoinTableView::OTableWindowMapIterator aIter = pTabWinList->find(aAliasName);
+ if(aIter != pTabWinList->end())
+ {
+ OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second);
+ if (pEntryTab)
+ {
+ pEntry->SetTable(pEntryTab->GetTableName());
+ pEntry->SetTabWindow(pEntryTab);
+ }
+ }
+ }
+ }
+ else
+ {
+ pEntry->SetAlias(::rtl::OUString());
+ pEntry->SetTable(::rtl::OUString());
+ pEntry->SetTabWindow(NULL);
+ }
+ sNewValue = pEntry->GetAlias();
+
+ } break;
+
+ case BROW_ORDER_ROW:
+ {
+ strOldCellContents = String::CreateFromInt32((sal_uInt16)pEntry->GetOrderDir());
+ sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
+ if (nIdx == sal_uInt16(-1))
+ nIdx = 0;
+ pEntry->SetOrderDir(EOrderDir(nIdx));
+ if(!m_bOrderByUnRelated)
+ {
+ pEntry->SetVisible(sal_True);
+ m_pVisibleCell->GetBox().Check();
+ RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId());
+ }
+ sNewValue = String::CreateFromInt32((sal_uInt16)pEntry->GetOrderDir());
+ } break;
+
+ case BROW_COLUMNALIAS_ROW:
+ strOldCellContents = pEntry->GetFieldAlias();
+ pEntry->SetFieldAlias(m_pTextCell->GetText());
+ sNewValue = pEntry->GetFieldAlias();
+ break;
+ case BROW_FUNCTION_ROW:
+ {
+ strOldCellContents = pEntry->GetFunction();
+ sal_uInt16 nPos = m_pFunctionCell->GetSelectEntryPos();
+ // Diese Funktionen stehen nur unter CORE zur Verf�gung
+ String sFunctionName = m_pFunctionCell->GetEntry(nPos);
+ String sGroupFunctionName = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1);
+ sal_Bool bGroupBy = sal_False;
+ if ( sGroupFunctionName.Equals(sFunctionName) ) // check if the function name is GROUP
+ {
+ bGroupBy = sal_True;
+
+ if ( !m_bGroupByUnRelated && !pEntry->IsVisible() )
+ {
+ // we have to change the visblie flag, so we must append also an undo action
+ pEntry->SetVisible(sal_True);
+ m_pVisibleCell->GetBox().Check();
+ appendUndoAction(g_strZero,g_strOne,BROW_VIS_ROW,bListAction);
+ RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId());
+ }
+
+ pEntry->SetFunction(String());
+ pEntry->SetFunctionType(pEntry->GetFunctionType() & ~FKT_AGGREGATE );
+ }
+ else if ( nPos ) // we found an aggregate function
+ {
+ pEntry->SetFunctionType(pEntry->GetFunctionType() | FKT_AGGREGATE );
+ pEntry->SetFunction(sFunctionName);
+ }
+ else
+ {
+ sFunctionName = String();
+ pEntry->SetFunction(String());
+ pEntry->SetFunctionType(pEntry->GetFunctionType() & ~FKT_AGGREGATE );
+ }
+
+ pEntry->SetGroupBy(bGroupBy);
+
+ sNewValue = sFunctionName;
+ }
+ break;
+ default:
+ {
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(!xConnection.is())
+ break;
+
+ sal_uInt16 nIdx = sal_uInt16(nRow - BROW_CRIT1_ROW);
+ String aText = m_pTextCell->GetText();
+
+ aText.EraseLeadingChars();
+ ::rtl::OUString aCrit;
+ if(aText.Len())
+ {
+ ::rtl::OUString aErrorMsg;
+ Reference<XPropertySet> xColumn;
+ OSQLParseNode* pParseNode = getDesignView()->getPredicateTreeFromEntry(pEntry,aText,aErrorMsg,xColumn);
+
+ if (pParseNode)
+ {
+ pParseNode->parseNodeToPredicateStr(aCrit,
+ xConnection,
+ static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
+ xColumn,
+ getDesignView()->getLocale(),
+ static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()),
+ &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext()));
+ delete pParseNode;
+ }
+ else
+ {
+ if(xColumn.is())
+ {
+ sal_Int32 nType = 0;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ switch(nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ if(aText.GetChar(0) != '\'' || aText.GetChar(aText.Len() -1) != '\'')
+ {
+ aText.SearchAndReplaceAll(String::CreateFromAscii("'"),String::CreateFromAscii("''"));
+ String aTmp(String::CreateFromAscii("'"));
+ (aTmp += aText) += String::CreateFromAscii("'");
+ aText = aTmp;
+ }
+ break;
+ default:
+ ;
+ }
+ ::connectivity::OSQLParser& rParser = static_cast<OQueryController&>(getDesignView()->getController()).getParser();
+ pParseNode = rParser.predicateTree(aErrorMsg,
+ aText,
+ static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
+ xColumn);
+ if (pParseNode)
+ {
+ pParseNode->parseNodeToPredicateStr(aCrit,
+ xConnection,
+ static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
+ xColumn,
+ getDesignView()->getLocale(),
+ static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()),
+ &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext()));
+ delete pParseNode;
+ }
+ else
+ {
+ if ( !m_bDisableErrorBox )
+ {
+ OSQLWarningBox( this, aErrorMsg ).Execute();
+ }
+ bError = sal_True;
+ }
+ }
+ else
+ {
+ if ( !m_bDisableErrorBox )
+ {
+ OSQLWarningBox( this, aErrorMsg ).Execute();
+ }
+ bError = sal_True;
+ }
+ }
+ }
+ strOldCellContents = pEntry->GetCriteria(nIdx);
+ pEntry->SetCriteria(nIdx, aCrit);
+ sNewValue = pEntry->GetCriteria(nIdx);
+ if(aCrit.getLength() && nRow >= (GetRowCount()-1))
+ bAppendRow = sal_True;
+ }
+ }
+ if(!bError && Controller())
+ Controller()->ClearModified();
+
+ RowModified(GetCurRow(), GetCurColumnId());
+
+ if ( bAppendRow )
+ {
+ RowInserted( GetRowCount()-1, 1, sal_True );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+
+ if(!bError)
+ {
+ // und noch die Undo-Action fuer das Ganze
+ appendUndoAction(strOldCellContents,sNewValue,nRow);
+
+ }
+ }
+
+ // habe ich Daten in einer FieldDescription gespeichert, die vorher leer war und es nach den Aenderungen nicht mehr ist ?
+ if ( pEntry.is() && bWasEmpty && !pEntry->IsEmpty() && !bError )
+ {
+ // Default auf sichtbar
+ pEntry->SetVisible(sal_True);
+ appendUndoAction(g_strZero,g_strOne,BROW_VIS_ROW,bListAction);
+ RowModified(BROW_VIS_ROW, GetCurColumnId());
+
+ // wenn noetig neue freie Spalten anlegen
+ sal_uInt16 nDummy;
+ CheckFreeColumns(nDummy);
+ }
+
+ if ( bListAction && !m_bInUndoMode )
+ static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().LeaveListAction();
+
+ return pEntry != NULL && !bError;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::SeekRow(long nRow)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bRet = sal_False;
+
+ m_nSeekRow = nRow;
+ if (nRow < m_nVisibleCount )
+ bRet = sal_True;
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ rDev.SetClipRegion( rRect );
+
+ OTableFieldDescRef pEntry = NULL;
+ sal_uInt16 nPos = GetColumnPos(nColumnId);
+ if(getFields().size() > sal_uInt16(nPos - 1))
+ pEntry = getFields()[nPos - 1];
+
+ if (!pEntry.is())
+ return;
+
+ long nRow = GetRealRow(m_nSeekRow);
+ if (nRow == BROW_VIS_ROW)
+ PaintTristate(rDev, rRect, pEntry->IsVisible() ? STATE_CHECK : STATE_NOCHECK);
+ else
+ rDev.DrawText(rRect, GetCellText(nRow, nColumnId),TEXT_DRAW_VCENTER);
+
+ rDev.SetClipRegion( );
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ Rectangle aRect(rRect);
+ aRect.TopLeft().Y() -= 2;
+ String aLabel(ModuleRes(STR_QUERY_HANDLETEXT));
+
+ // ab BROW_CRIT2_ROW werden alle Zeilen mit "oder" angegeben
+ xub_StrLen nToken = (xub_StrLen) (m_nSeekRow >= GetBrowseRow(BROW_CRIT2_ROW))
+ ?
+ xub_StrLen(BROW_CRIT2_ROW) : xub_StrLen(GetRealRow(m_nSeekRow));
+ rDev.DrawText(aRect, aLabel.GetToken(nToken),TEXT_DRAW_VCENTER);
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::RemoveColumn(sal_uInt16 _nColumnId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+
+ sal_uInt16 nPos = GetColumnPos(_nColumnId);
+ // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
+ OSL_ENSURE((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::RemoveColumn : invalid parameter nColId");
+ // ColId ist bei mir gleichbedeutend mit Position, und da sollte die Bedingung natuerlich zutreffen
+
+ sal_uInt16 nCurCol = GetCurColumnId();
+ long nCurrentRow = GetCurRow();
+
+ DeactivateCell();
+
+ getFields().erase( getFields().begin() + (nPos - 1) );
+ OTableFieldDescRef pEntry = new OTableFieldDesc();
+ pEntry->SetColumnId(_nColumnId);
+ getFields().push_back(pEntry);
+
+ EditBrowseBox::RemoveColumn( _nColumnId );
+ InsertDataColumn( _nColumnId , String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND);
+
+ // Neuzeichnen
+ Rectangle aInvalidRect = GetInvalidRect( _nColumnId );
+ Invalidate( aInvalidRect );
+
+ ActivateCell( nCurrentRow, nCurCol );
+
+ rController.setModified( sal_True );
+
+ invalidateUndoRedo();
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::RemoveField(sal_uInt16 nColumnId )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+
+ sal_uInt16 nPos = GetColumnPos(nColumnId);
+ OSL_ENSURE(getFields().size() > sal_uInt16(nPos-1),"ID is to great!");
+
+ OTableFieldDescRef pDesc = getEntry((sal_uInt32)(nPos - 1)) ;
+ pDesc->SetColWidth( (sal_uInt16)GetColumnWidth(nColumnId) ); // hat er sich vorher leider nicht gemerkt
+
+ // UndoAction erzeugen
+ if ( !m_bInUndoMode )
+ {
+ OTabFieldDelUndoAct* pUndoAction = new OTabFieldDelUndoAct( this );
+ pUndoAction->SetTabFieldDescr(pDesc);
+ pUndoAction->SetColumnPosition(nPos);
+ rController.addUndoActionAndInvalidate( pUndoAction );
+ }
+
+ RemoveColumn(nColumnId);
+
+ invalidateUndoRedo();
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_Bool _bClickedOntoHandleCol )
+{
+ // wenn ein Header selectiert wird, mu� die selection angezeigt werden, sonst nicht)
+ if ( _bClickedOntoHeader )
+ {
+ if (0 == GetSelectColumnCount() )
+ // wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
+ if ( BROWSER_HIDESELECT == ( m_nMode & BROWSER_HIDESELECT ) )
+ {
+ m_nMode &= ~BROWSER_HIDESELECT;
+ m_nMode |= BROWSER_MULTISELECTION;
+ SetMode( m_nMode );
+ }
+ }
+ else if ( BROWSER_HIDESELECT != ( m_nMode & BROWSER_HIDESELECT ) )
+ {
+ if ( GetSelectColumnCount() != 0 )
+ SetNoSelection();
+
+ if ( _bClickedOntoHandleCol )
+ {
+ m_nMode |= BROWSER_HIDESELECT;
+ m_nMode &= ~BROWSER_MULTISELECTION;
+ SetMode( m_nMode );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if( rEvt.IsLeft() )
+ {
+ sal_Bool bOnHandle = HANDLE_ID == rEvt.GetColumnId();
+ sal_Bool bOnHeader = ( rEvt.GetRow() < 0 ) && !bOnHandle;
+ adjustSelectionMode( bOnHeader, bOnHandle );
+ }
+ EditBrowseBox::MouseButtonDown(rEvt);
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::MouseButtonUp(const BrowserMouseEvent& rEvt)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ EditBrowseBox::MouseButtonUp( rEvt );
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::KeyInput( const KeyEvent& rEvt )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if (IsColumnSelected(GetCurColumnId()))
+ {
+ if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
+ !rEvt.GetKeyCode().IsShift() &&
+ !rEvt.GetKeyCode().IsMod1())
+ {
+ RemoveField(GetCurColumnId());
+ return;
+ }
+ }
+ EditBrowseBox::KeyInput(rEvt);
+}
+
+
+//------------------------------------------------------------------------------
+sal_Int8 OSelectionBrowseBox::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Int8 nDropAction = DND_ACTION_NONE;
+ if ( rEvt.GetRow() >= -1 )
+ {
+ if ( IsEditing() )
+ {
+ // allow the asterix again
+ m_bDisableErrorBox = sal_True;
+ SaveModified();
+ m_bDisableErrorBox = sal_False;
+ DeactivateCell();
+ }
+ // check if the format is already supported, if not deactivate the current cell and try again
+ if ( OJoinExchObj::isFormatAvailable(GetDataFlavors()) )
+ nDropAction = DND_ACTION_LINK;
+ }
+
+ return nDropAction;
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 OSelectionBrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& _rEvt )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+
+ TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
+ if (!OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector()))
+ {
+ OSL_FAIL("OSelectionBrowseBox::ExecuteDrop: this should never have passed AcceptDrop!");
+ return DND_ACTION_NONE;
+ }
+
+ OTableFieldDesc aInfo;
+ // Einfuegen des Feldes an der gewuenschten Position
+ OJoinExchangeData jxdSource = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
+ InsertField(jxdSource);
+
+ return DND_ACTION_LINK;
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::AppendNewCol( sal_uInt16 nCnt)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ // es koennen mehrere angelegt werden, aber der Erste
+ // wird returnt
+ sal_uInt32 nCount = getFields().size();
+ for (sal_uInt16 i=0 ; i<nCnt ; i++)
+ {
+ OTableFieldDescRef pEmptyEntry = new OTableFieldDesc();
+ getFields().push_back(pEmptyEntry);
+ sal_uInt16 nColumnId = sal::static_int_cast< sal_uInt16 >(getFields().size());
+ pEmptyEntry->SetColumnId( nColumnId );
+
+ InsertDataColumn( nColumnId , String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND);
+ }
+
+ return getFields()[nCount];
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::DeleteFields(const String& rAliasName)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if (!getFields().empty())
+ {
+ sal_uInt16 nColId = GetCurColumnId();
+ sal_uInt32 nRow = GetCurRow();
+
+ sal_Bool bWasEditing = IsEditing();
+ if (bWasEditing)
+ DeactivateCell();
+
+ OTableFields::reverse_iterator aIter = getFields().rbegin();
+ OTableFieldDescRef pEntry = NULL;
+ for(sal_uInt16 nPos=sal::static_int_cast< sal_uInt16 >(getFields().size());aIter != getFields().rend();++aIter,--nPos)
+ {
+ pEntry = *aIter;
+ if ( pEntry->GetAlias().equals( rAliasName ) )
+ {
+ RemoveField( GetColumnId( nPos ) );
+ break;
+ }
+ }
+
+ if (bWasEditing)
+ ActivateCell(nRow , nColId);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::SetColWidth(sal_uInt16 nColId, long nNewWidth)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bWasEditing = IsEditing();
+ if (bWasEditing)
+ DeactivateCell();
+
+ // die Basisklasse machen lassen
+ SetColumnWidth(nColId, nNewWidth);
+
+ // der FieldDescription Bescheid sagen
+ OTableFieldDescRef pEntry = getEntry(GetColumnPos(nColId) - 1);
+ if (pEntry.is())
+ pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId)));
+
+ if (bWasEditing)
+ ActivateCell(GetCurRow(), GetCurColumnId());
+}
+
+//------------------------------------------------------------------------------
+Rectangle OSelectionBrowseBox::GetInvalidRect( sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Rechteck ist erst einmal der gesamte Outputbereich des Fensters
+ Rectangle aInvalidRect( Point(0,0), GetOutputSizePixel() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Dann wird die linke Seite angepasst
+ Rectangle aFieldRect(GetCellRect( 0, nColId )); // used instead of GetFieldRectPixel
+ aInvalidRect.Left() = aFieldRect.Left();
+
+ return aInvalidRect;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _nColumnPostion)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
+ OSL_ENSURE(_nColumnPostion == BROWSER_INVALIDID || (_nColumnPostion <= (long)getFields().size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId.");
+ // -1 heisst ganz hinten, Count heisst ganz hinten, der Rest bezeichnet eine richtige Position
+
+ sal_uInt16 nCurCol = GetCurColumnId();
+ long nCurrentRow = GetCurRow();
+
+ DeactivateCell();
+
+ // remember the column id of the current positon
+ sal_uInt16 nColumnId = GetColumnId(_nColumnPostion);
+ // Wenn zu klein oder zu gross, auf Ende der Liste setzen
+ if ((_nColumnPostion == BROWSER_INVALIDID) || (_nColumnPostion >= getFields().size())) // Anhaengen des Feldes
+ {
+ if (FindFirstFreeCol(_nColumnPostion) == NULL) // keine freie Column mehr
+ {
+ AppendNewCol(1);
+ _nColumnPostion = sal::static_int_cast< sal_uInt16 >(
+ getFields().size());
+ }
+ else
+ ++_nColumnPostion; // innerhalb der vorgegebenen Liste
+ nColumnId = GetColumnId(_nColumnPostion);
+ pEntry->SetColumnId( nColumnId );
+ getFields()[ _nColumnPostion - 1] = pEntry;
+ }
+
+ // check if the column ids are identical, if not we have to move
+ if ( pEntry->GetColumnId() != nColumnId )
+ {
+ sal_uInt16 nOldPosition = GetColumnPos(pEntry->GetColumnId());
+ OSL_ENSURE( nOldPosition != 0,"Old position was 0. Not possible!");
+ SetColumnPos(pEntry->GetColumnId(),_nColumnPostion);
+ // we have to delete an empty field for the fields list, because the columns must have equal length
+ if ( nOldPosition > 0 && nOldPosition <= getFields().size() )
+ getFields()[nOldPosition - 1] = pEntry;
+
+ ColumnMoved(pEntry->GetColumnId(),sal_False);
+ }
+
+ if ( pEntry->GetFunctionType() & (FKT_AGGREGATE) )
+ {
+ String sFunctionName = pEntry->GetFunction();
+ if ( GetFunctionName(sal_uInt32(-1),sFunctionName) )
+ pEntry->SetFunction(sFunctionName);
+ }
+
+ nColumnId = pEntry->GetColumnId();
+
+ SetColWidth(nColumnId,getDesignView()->getColWidth(GetColumnPos(nColumnId)-1));
+ // Neuzeichnen
+ Rectangle aInvalidRect = GetInvalidRect( nColumnId );
+ Invalidate( aInvalidRect );
+
+ ActivateCell( nCurrentRow, nCurCol );
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+
+ invalidateUndoRedo();
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPostion, sal_Bool bVis, sal_Bool bActivate)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(jxdSource.pListBox->GetTabWin());
+ if (!pSourceWin)
+ return NULL;
+
+ // Namen/Position des selektierten Feldes
+ String aFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry);
+ sal_uInt32 nFieldIndex = jxdSource.pListBox->GetModel()->GetAbsPos(jxdSource.pEntry);
+ OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(jxdSource.pEntry->GetUserData());
+
+ // eine DragInfo aufbauen, damit ich mich auf das andere InsertField zurueckziehen kann
+ OTableFieldDescRef aInfo = new OTableFieldDesc(pSourceWin->GetTableName(),aFieldName);
+ aInfo->SetTabWindow(pSourceWin);
+ aInfo->SetFieldIndex(nFieldIndex);
+ aInfo->SetFieldType(pInf->GetKeyType());
+ aInfo->SetAlias(pSourceWin->GetAliasName());
+
+ aInfo->SetDataType(pInf->GetDataType());
+ aInfo->SetVisible(bVis);
+
+ return InsertField(aInfo, _nColumnPostion, bVis, bActivate);
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _rInfo, sal_uInt16 _nColumnPostion, sal_Bool bVis, sal_Bool bActivate)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+
+ if(m_nMaxColumns && m_nMaxColumns <= FieldsCount())
+ return NULL;
+ if (bActivate)
+ SaveModified();
+
+ // Neue Spaltenbeschreibung
+ OTableFieldDescRef pEntry = _rInfo;
+ pEntry->SetVisible(bVis);
+
+ // Spalte einfuegen
+ InsertColumn( pEntry, _nColumnPostion );
+
+ if ( !m_bInUndoMode )
+ {
+ // UndoAction erzeugen
+ OTabFieldCreateUndoAct* pUndoAction = new OTabFieldCreateUndoAct( this );
+ pUndoAction->SetTabFieldDescr( pEntry );
+ pUndoAction->SetColumnPosition(_nColumnPostion);
+ getDesignView()->getController().addUndoActionAndInvalidate( pUndoAction );
+ }
+
+ return pEntry;
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 OSelectionBrowseBox::FieldsCount()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OTableFields::iterator aIter = getFields().begin();
+ sal_uInt16 nCount = 0;
+
+ while (aIter != getFields().end())
+ {
+ if ((*aIter).is() && !(*aIter)->IsEmpty())
+ ++nCount;
+ ++aIter;
+ }
+
+ return nCount;
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::FindFirstFreeCol(sal_uInt16& _rColumnPosition )
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OTableFields::iterator aIter = getFields().begin();
+ OTableFields::iterator aEnd = getFields().end();
+
+ _rColumnPosition = BROWSER_INVALIDID;
+
+ while ( aIter != aEnd )
+ {
+ ++_rColumnPosition;
+ OTableFieldDescRef pEntry = (*aIter);
+ if ( pEntry.is() && pEntry->IsEmpty() )
+ return pEntry;
+ ++aIter;
+ }
+
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::CheckFreeColumns(sal_uInt16& _rColumnPosition)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if (FindFirstFreeCol(_rColumnPosition) == NULL)
+ {
+ // es ist voll, also einen Packen Spalten anhaengen
+ AppendNewCol(DEFAULT_QUERY_COLS);
+ OSL_VERIFY(FindFirstFreeCol(_rColumnPosition).is());
+ }
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt32 /*_nCurrentPos*/)
+{
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(!xConnection.is())
+ return;
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(!rInfo->IsEmpty(),"AddGroupBy:: OTableFieldDescRef sollte nicht Empty sein!");
+ OTableFieldDescRef pEntry;
+ const Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ const ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+ //sal_Bool bAppend = sal_False;
+
+ OTableFields& rFields = getFields();
+ OTableFields::iterator aIter = rFields.begin();
+ OTableFields::iterator aEnd = rFields.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ pEntry = *aIter;
+ OSL_ENSURE(pEntry.is(),"OTableFieldDescRef was null!");
+
+ const ::rtl::OUString aField = pEntry->GetField();
+ const ::rtl::OUString aAlias = pEntry->GetAlias();
+
+ if (bCase(aField,rInfo->GetField()) &&
+ bCase(aAlias,rInfo->GetAlias()) &&
+ pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
+ pEntry->GetFunction() == rInfo->GetFunction())
+ {
+ if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
+ {
+ pEntry->SetGroupBy(sal_False);
+ aIter = rFields.end();
+ break;
+ }
+ else
+ {
+ if ( !pEntry->IsGroupBy() && !pEntry->HasCriteria() ) // here we have a where condition which is no having clause
+ {
+ pEntry->SetGroupBy(rInfo->IsGroupBy());
+ if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
+ pEntry->SetVisible(sal_True);
+ break;
+ }
+ }
+
+ }
+ }
+
+ if (aIter == rFields.end())
+ {
+ OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
+ if ( (pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy()) ) // das GroupBy wird bereits von rInfo "ubernommen
+ pTmp->SetGroupBy(sal_False);
+ }
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ const sal_uInt16 nNewLevel = nLevel +1;
+ OTableFields& rFields = getFields();
+ OTableFields::iterator aIter = rFields.begin();
+ OTableFields::iterator aEnd = rFields.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntry = *aIter;
+
+ ::rtl::OUString sValue = pEntry->GetCriteria(nLevel);
+ if ( sValue.getLength() )
+ {
+ pEntry->SetCriteria( nNewLevel, sValue);
+ if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) )
+ {
+ RowInserted( GetRowCount()-1, 1, sal_True );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True;
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const String& rValue, const sal_uInt16 nLevel,bool _bAddOrOnOneLine )
+{
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(!xConnection.is())
+ return;
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(rInfo.is() && !rInfo->IsEmpty(),"AddCondition:: OTableFieldDescRef sollte nicht Empty sein!");
+
+ OTableFieldDescRef pLastEntry;
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+
+ OTableFields& rFields = getFields();
+ OTableFields::iterator aIter = rFields.begin();
+ OTableFields::iterator aEnd = rFields.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableFieldDescRef pEntry = *aIter;
+ const ::rtl::OUString aField = pEntry->GetField();
+ const ::rtl::OUString aAlias = pEntry->GetAlias();
+
+ if (bCase(aField,rInfo->GetField()) &&
+ bCase(aAlias,rInfo->GetAlias()) &&
+ pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
+ pEntry->GetFunction() == rInfo->GetFunction() &&
+ pEntry->IsGroupBy() == rInfo->IsGroupBy() )
+ {
+ if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
+ pEntry->SetGroupBy(sal_False);
+ else
+ {
+ if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
+ pEntry->SetVisible(sal_True);
+ }
+ if (!pEntry->GetCriteria(nLevel).getLength() )
+ {
+ pEntry->SetCriteria( nLevel, rValue);
+ if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
+ {
+ RowInserted( GetRowCount()-1, 1, sal_True );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = sal_True;
+ break;
+ }
+ if ( _bAddOrOnOneLine )
+ {
+ pLastEntry = pEntry;
+ }
+ }
+ }
+ if ( pLastEntry.is() )
+ {
+ String sCriteria = rValue;
+ String sOldCriteria = pLastEntry->GetCriteria( nLevel );
+ if ( sOldCriteria.Len() )
+ {
+ sCriteria = String(RTL_CONSTASCII_USTRINGPARAM("( "));
+ sCriteria += sOldCriteria;
+ sCriteria += String(RTL_CONSTASCII_USTRINGPARAM(" OR "));
+ sCriteria += rValue;
+ sCriteria += String(RTL_CONSTASCII_USTRINGPARAM(" )"));
+ }
+ pLastEntry->SetCriteria( nLevel, sCriteria);
+ if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
+ {
+ RowInserted( GetRowCount()-1, 1, sal_True );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = sal_True;
+ }
+
+ else if (aIter == getFields().end())
+ {
+ OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
+ if ( pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) // das GroupBy wird bereits von rInfo "ubernommen
+ pTmp->SetGroupBy(sal_False);
+ if ( pTmp.is() )
+ {
+ pTmp->SetCriteria( nLevel, rValue);
+ if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
+ {
+ RowInserted( GetRowCount()-1, 1, sal_True );
+ m_bVisibleRow.push_back(sal_True);
+ ++m_nVisibleCount;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos)
+{
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if(!xConnection.is())
+ return;
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(!rInfo->IsEmpty(),"AddOrder:: OTableFieldDescRef sollte nicht Empty sein!");
+ OTableFieldDescRef pEntry;
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+
+ sal_Bool bAppend = sal_False;
+ OTableFields& rFields = getFields();
+ OTableFields::iterator aIter = rFields.begin();
+ OTableFields::iterator aEnd = rFields.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ pEntry = *aIter;
+ ::rtl::OUString aField = pEntry->GetField();
+ ::rtl::OUString aAlias = pEntry->GetAlias();
+
+ if (bCase(aField,rInfo->GetField()) &&
+ bCase(aAlias,rInfo->GetAlias()))
+ {
+ sal_uInt32 nPos = aIter - rFields.begin();
+ bAppend = _nCurrentPos > nPos;
+ if ( bAppend )
+ aIter = rFields.end();
+ else
+ {
+ if ( !m_bOrderByUnRelated )
+ pEntry->SetVisible(sal_True);
+ pEntry->SetOrderDir( eDir );
+ }
+ break;
+ }
+ }
+
+ if (aIter == rFields.end())
+ {
+ OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
+ if(pTmp.is())
+ {
+ if ( !m_bOrderByUnRelated && !bAppend )
+ pTmp->SetVisible(sal_True);
+ pTmp->SetOrderDir( eDir );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::ArrangeControls(sal_uInt16& nX, sal_uInt16 nY)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ EditBrowseBox::ArrangeControls(nX, nY);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::Save()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bRet = sal_True;
+ if (IsModified())
+ bRet = SaveModified();
+ return bRet;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::CellModified()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_VIS_ROW:
+ {
+ OTableFieldDescRef pEntry = getEntry(GetColumnPos(GetCurColumnId()) - 1);
+
+ sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
+ if(!m_bOrderByUnRelated && nIdx > 0 &&
+ nIdx != sal_uInt16(-1) &&
+ !pEntry->IsEmpty() &&
+ pEntry->GetOrderDir() != ORDER_NONE)
+ {
+ m_pVisibleCell->GetBox().Check();
+ pEntry->SetVisible(sal_True);
+ }
+ else
+ pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked());
+ }
+ break;
+ }
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::Fill()
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(ColCount() >= 1, "OSelectionBrowseBox::Fill : please call only after inserting the handle column !");
+
+ sal_uInt16 nColCount = ColCount() - 1;
+ if (nColCount < DEFAULT_QUERY_COLS)
+ AppendNewCol(DEFAULT_QUERY_COLS - nColCount);
+}
+
+//------------------------------------------------------------------------------
+Size OSelectionBrowseBox::CalcOptimalSize( const Size& _rAvailable )
+{
+ Size aReturn( _rAvailable.Width(), GetTitleHeight() );
+
+ aReturn.Height() += ( m_nVisibleCount ? m_nVisibleCount : 15 ) * GetDataRowHeight();
+ aReturn.Height() += 40; // just some space
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::Command(const CommandEvent& rEvt)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ Point aMenuPos( rEvt.GetMousePosPixel() );
+
+ if (!rEvt.IsMouseEvent())
+ {
+ if ( 1 == GetSelectColumnCount() )
+ {
+ sal_uInt16 nSelId = GetColumnId(
+ sal::static_int_cast< sal_uInt16 >(
+ FirstSelectedColumn() ) );
+ ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
+
+ aMenuPos = aColRect.TopCenter();
+ }
+ else
+ {
+ EditBrowseBox::Command(rEvt);
+ return;
+ }
+ }
+
+ sal_uInt16 nColId = GetColumnId(GetColumnAtXPosPixel( aMenuPos.X() ));
+ long nRow = GetRowAtYPosPixel( aMenuPos.Y() );
+
+ if (nRow < 0 && nColId > HANDLE_ID )
+ {
+ if ( !IsColumnSelected( nColId ) )
+ {
+ adjustSelectionMode( sal_True /* clicked onto a header */ , sal_False /* not onto the handle col */ );
+ SelectColumnId( nColId );
+ }
+
+ if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
+ {
+ PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
+ switch (aContextMenu.Execute(this, aMenuPos))
+ {
+ case SID_DELETE:
+ RemoveField(nColId);
+ break;
+
+ case ID_BROWSER_COLWIDTH:
+ adjustBrowseBoxColumnWidth( this, nColId );
+ break;
+ }
+ }
+ }
+ else if(nRow >= 0 && nColId <= HANDLE_ID)
+ {
+ if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
+ {
+ PopupMenu aContextMenu(ModuleRes(RID_QUERYFUNCTION_POPUPMENU));
+ aContextMenu.CheckItem( ID_QUERY_FUNCTION, m_bVisibleRow[BROW_FUNCTION_ROW]);
+ aContextMenu.CheckItem( ID_QUERY_TABLENAME, m_bVisibleRow[BROW_TABLE_ROW]);
+ aContextMenu.CheckItem( ID_QUERY_ALIASNAME, m_bVisibleRow[BROW_COLUMNALIAS_ROW]);
+ aContextMenu.CheckItem( ID_QUERY_DISTINCT, static_cast<OQueryController&>(getDesignView()->getController()).isDistinct());
+
+ switch (aContextMenu.Execute(this, aMenuPos))
+ {
+ case ID_QUERY_FUNCTION:
+ SetRowVisible(BROW_FUNCTION_ROW, !IsRowVisible(BROW_FUNCTION_ROW));
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_FUNCTIONS );
+ break;
+ case ID_QUERY_TABLENAME:
+ SetRowVisible(BROW_TABLE_ROW, !IsRowVisible(BROW_TABLE_ROW));
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_TABLES );
+ break;
+ case ID_QUERY_ALIASNAME:
+ SetRowVisible(BROW_COLUMNALIAS_ROW, !IsRowVisible(BROW_COLUMNALIAS_ROW));
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_ALIASES );
+ break;
+ case ID_QUERY_DISTINCT:
+ static_cast<OQueryController&>(getDesignView()->getController()).setDistinct(!static_cast<OQueryController&>(getDesignView()->getController()).isDistinct());
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_DISTINCT_VALUES );
+ break;
+ }
+
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+ }
+ }
+ else
+ {
+ EditBrowseBox::Command(rEvt);
+ return;
+ }
+ }
+ default:
+ EditBrowseBox::Command(rEvt);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::IsRowVisible(sal_uInt16 _nWhich) const
+{
+ OSL_ENSURE(_nWhich<(m_bVisibleRow.size()), "OSelectionBrowseBox::IsRowVisible : invalid parameter !");
+ return m_bVisibleRow[_nWhich];
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::SetRowVisible(sal_uInt16 _nWhich, sal_Bool _bVis)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ OSL_ENSURE(_nWhich<m_bVisibleRow.size(), "OSelectionBrowseBox::SetRowVisible : invalid parameter !");
+
+ sal_Bool bWasEditing = IsEditing();
+ if (bWasEditing)
+ DeactivateCell();
+
+ // do this before removing or inserting rows, as this triggers ActivateCell-calls, which rely on m_bVisibleRow
+ m_bVisibleRow[_nWhich] = !m_bVisibleRow[_nWhich];
+
+ long nId = GetBrowseRow(_nWhich);
+ if (_bVis)
+ {
+ RowInserted(nId,1);
+ ++m_nVisibleCount;
+ }
+ else
+ {
+ RowRemoved(nId,1);
+ --m_nVisibleCount;
+ }
+
+ if (bWasEditing)
+ ActivateCell();
+}
+
+//------------------------------------------------------------------------------
+long OSelectionBrowseBox::GetBrowseRow(long nRowId) const
+{
+ sal_uInt16 nCount(0);
+ for(sal_uInt16 i = 0 ; i < nRowId ; ++i)
+ {
+ if ( m_bVisibleRow[i] )
+ ++nCount;
+ }
+ return nCount;
+}
+//------------------------------------------------------------------------------
+long OSelectionBrowseBox::GetRealRow(long nRowId) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ long nErg=0,i;
+ const long nCount = m_bVisibleRow.size();
+ for(i=0;i < nCount; ++i)
+ {
+ if(m_bVisibleRow[i])
+ {
+ if(nErg++ == nRowId)
+ break;
+ }
+ }
+ OSL_ENSURE(nErg <= long(m_bVisibleRow.size()),"nErg kann nicht groesser als BROW_ROW_CNT sein!");
+ return i;
+}
+static long nVisibleRowMask[] =
+ {
+ 0x0001,
+ 0x0002,
+ 0x0004,
+ 0x0008,
+ 0x0010,
+ 0x0020,
+ 0x0040,
+ 0x0080,
+ 0x0100,
+ 0x0200,
+ 0x0400,
+ 0x0800
+ };
+//------------------------------------------------------------------------------
+sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const
+{
+ sal_Int32 nErg(0);
+ // only the first 11 row are interesting
+ sal_Int32 nSize = SAL_N_ELEMENTS(nVisibleRowMask);
+ for(sal_Int32 i=0;i<nSize;i++)
+ {
+ if(!m_bVisibleRow[i])
+ nErg |= nVisibleRowMask[i];
+ }
+ return nErg;
+}
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::SetNoneVisbleRow(long nRows)
+{
+ // only the first 11 row are interesting
+ sal_Int32 nSize = SAL_N_ELEMENTS(nVisibleRowMask);
+ for(sal_Int32 i=0;i< nSize;i++)
+ m_bVisibleRow[i] = !(nRows & nVisibleRowMask[i]);
+}
+//------------------------------------------------------------------------------
+String OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+
+ sal_uInt16 nPos = GetColumnPos(nColId);
+
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::GetCellText : invalid column id, prepare for GPF ... ");
+ if ( pEntry->IsEmpty() )
+ return String();
+
+ String aText;
+ switch (nRow)
+ {
+ case BROW_TABLE_ROW:
+ aText = pEntry->GetAlias();
+ break;
+ case BROW_FIELD_ROW:
+ {
+ String aField = pEntry->GetField();
+ if (aField.GetChar(0) == '*') // * durch alias.* ersetzen
+ {
+ aField = pEntry->GetAlias();
+ if(aField.Len())
+ aField += '.';
+ aField += '*';
+ }
+ aText = aField;
+ } break;
+ case BROW_ORDER_ROW:
+ if (pEntry->GetOrderDir() != ORDER_NONE)
+ aText = String(ModuleRes(STR_QUERY_SORTTEXT) ).GetToken(sal::static_int_cast< sal_uInt16 >(pEntry->GetOrderDir()));
+ break;
+ case BROW_VIS_ROW:
+ break;
+ case BROW_COLUMNALIAS_ROW:
+ aText = pEntry->GetFieldAlias();
+ break;
+ case BROW_FUNCTION_ROW:
+ // we always show the group function at first
+ if ( pEntry->IsGroupBy() )
+ aText = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1);
+ else if ( pEntry->isNumericOrAggreateFunction() )
+ aText = pEntry->GetFunction();
+ break;
+ default:
+ aText = pEntry->GetCriteria(sal_uInt16(nRow - BROW_CRIT1_ROW));
+ }
+ return aText;
+}
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId,String& rFkt)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bErg=sal_True;
+ String aText;
+ switch(_nFunctionTokenId)
+ {
+ case SQL_TOKEN_COUNT:
+ rFkt = (m_pFunctionCell->GetEntryCount() < 3) ? m_pFunctionCell->GetEntry(1) : m_pFunctionCell->GetEntry(2);
+ break;
+ case SQL_TOKEN_AVG:
+ rFkt = m_pFunctionCell->GetEntry(1);
+ break;
+ case SQL_TOKEN_MAX:
+ rFkt = m_pFunctionCell->GetEntry(3);
+ break;
+ case SQL_TOKEN_MIN:
+ rFkt = m_pFunctionCell->GetEntry(4);
+ break;
+ case SQL_TOKEN_SUM:
+ rFkt = m_pFunctionCell->GetEntry(5);
+ break;
+ case SQL_TOKEN_EVERY:
+ rFkt = m_pFunctionCell->GetEntry(6);
+ break;
+ case SQL_TOKEN_ANY:
+ rFkt = m_pFunctionCell->GetEntry(7);
+ break;
+ case SQL_TOKEN_SOME:
+ rFkt = m_pFunctionCell->GetEntry(8);
+ break;
+ case SQL_TOKEN_STDDEV_POP:
+ rFkt = m_pFunctionCell->GetEntry(9);
+ break;
+ case SQL_TOKEN_STDDEV_SAMP:
+ rFkt = m_pFunctionCell->GetEntry(10);
+ break;
+ case SQL_TOKEN_VAR_SAMP:
+ rFkt = m_pFunctionCell->GetEntry(11);
+ break;
+ case SQL_TOKEN_VAR_POP:
+ rFkt = m_pFunctionCell->GetEntry(12);
+ break;
+ case SQL_TOKEN_COLLECT:
+ rFkt = m_pFunctionCell->GetEntry(13);
+ break;
+ case SQL_TOKEN_FUSION:
+ rFkt = m_pFunctionCell->GetEntry(14);
+ break;
+ case SQL_TOKEN_INTERSECTION:
+ rFkt = m_pFunctionCell->GetEntry(15);
+ break;
+ default:
+ {
+ xub_StrLen nCount = m_aFunctionStrings.GetTokenCount();
+ xub_StrLen i;
+ for ( i = 0; i < nCount-1; i++) // Gruppierung wird nicht mit gez"ahlt
+ {
+ if(rFkt.EqualsIgnoreCaseAscii(m_aFunctionStrings.GetToken(i)))
+ {
+ rFkt = m_aFunctionStrings.GetToken(i);
+ break;
+ }
+ }
+ if(i == nCount-1)
+ bErg = sal_False;
+ }
+ }
+
+ return bErg;
+}
+//------------------------------------------------------------------------------
+String OSelectionBrowseBox::GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ if ( GetCurColumnId() == nColId && !m_bInUndoMode )
+ SaveModified();
+
+ sal_uInt16 nPos = GetColumnPos(nColId);
+ OTableFieldDescRef pEntry = getFields()[nPos - 1];
+ OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::GetCellContents : invalid column id, prepare for GPF ... ");
+
+ switch (nCellIndex)
+ {
+ case BROW_VIS_ROW :
+ return pEntry->IsVisible() ? g_strOne : g_strZero;
+ case BROW_ORDER_ROW:
+ {
+ sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
+ if (nIdx == sal_uInt16(-1))
+ nIdx = 0;
+ return String(nIdx);
+ }
+ default:
+ return GetCellText(nCellIndex, nColId);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::SetCellContents(sal_Int32 nRow, sal_uInt16 nColId, const String& strNewText)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_Bool bWasEditing = IsEditing() && (GetCurColumnId() == nColId) && IsRowVisible(static_cast<sal_uInt16>(nRow)) && (GetCurRow() == static_cast<sal_uInt16>(GetBrowseRow(nRow)));
+ if (bWasEditing)
+ DeactivateCell();
+
+ sal_uInt16 nPos = GetColumnPos(nColId);
+ OTableFieldDescRef pEntry = getEntry(nPos - 1);
+ OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::SetCellContents : invalid column id, prepare for GPF ... ");
+
+
+ switch (nRow)
+ {
+ case BROW_VIS_ROW:
+ pEntry->SetVisible(strNewText.Equals(g_strOne));
+ break;
+ case BROW_FIELD_ROW:
+ pEntry->SetField(strNewText);
+ break;
+ case BROW_TABLE_ROW:
+ pEntry->SetAlias(strNewText);
+ break;
+ case BROW_ORDER_ROW:
+ {
+ sal_uInt16 nIdx = (sal_uInt16)strNewText.ToInt32();
+ pEntry->SetOrderDir(EOrderDir(nIdx));
+ } break;
+ case BROW_COLUMNALIAS_ROW:
+ pEntry->SetFieldAlias(strNewText);
+ break;
+ case BROW_FUNCTION_ROW:
+ {
+ String sOldFunctionName = pEntry->GetFunction();
+ String sGroupFunctionName = m_aFunctionStrings.GetToken(m_aFunctionStrings.GetTokenCount()-1);
+ pEntry->SetFunction(strNewText);
+ // first reset this two member
+ sal_Int32 nFunctionType = pEntry->GetFunctionType();
+ nFunctionType &= ~FKT_AGGREGATE;
+ pEntry->SetFunctionType(nFunctionType);
+ if ( pEntry->IsGroupBy() && !sGroupFunctionName.EqualsIgnoreCaseAscii(strNewText) )
+ pEntry->SetGroupBy(sal_False);
+
+
+ if ( sGroupFunctionName.EqualsIgnoreCaseAscii(strNewText) )
+ pEntry->SetGroupBy(sal_True);
+ else if ( strNewText.Len() )
+ {
+ nFunctionType |= FKT_AGGREGATE;
+ pEntry->SetFunctionType(nFunctionType);
+ }
+ } break;
+ default:
+ pEntry->SetCriteria(sal_uInt16(nRow - BROW_CRIT1_ROW), strNewText);
+ }
+
+ long nCellIndex = GetRealRow(nRow);
+ if(IsRowVisible(static_cast<sal_uInt16>(nRow)))
+ RowModified(nCellIndex, nColId);
+
+ // die entsprechende Feld-Beschreibung ist jetzt leer -> Visible auf sal_False (damit das konsistent mit normalen leeren Spalten ist)
+ if (pEntry->IsEmpty())
+ pEntry->SetVisible(sal_False);
+
+ if (bWasEditing)
+ ActivateCell(nCellIndex, nColId);
+
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+}
+//------------------------------------------------------------------------------
+sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRow, sal_uInt16 nColId) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+
+ long nRowId = GetRealRow(nRow);
+ if (nRowId == BROW_VIS_ROW)
+ return CHECKBOX_SIZE;
+ else
+ return GetDataWindow().GetTextWidth(GetCellText(nRowId, nColId));
+}
+
+//------------------------------------------------------------------------------
+void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId)
+{
+ if (static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
+ return;
+ // The resizing of columns can't be suppressed (BrowseBox doesn't support that) so we have to do this
+ // fake. It's not _that_ bad : the user may change column widths while in read-only mode to see all details
+ // but the changes aren't permanent ...
+
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_uInt16 nPos = GetColumnPos(nColId);
+ OSL_ENSURE(nPos <= getFields().size(),"ColumnResized:: nColId sollte nicht groesser als List::count sein!");
+ OTableFieldDescRef pEntry = getEntry(nPos-1);
+ OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::ColumnResized : keine FieldDescription !");
+ static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
+ EditBrowseBox::ColumnResized(nColId);
+
+ if ( pEntry.is())
+ {
+ if ( !m_bInUndoMode )
+ {
+ // create the undo action
+ OTabFieldSizedUndoAct* pUndo = new OTabFieldSizedUndoAct(this);
+ pUndo->SetColumnPosition( nPos );
+ pUndo->SetOriginalWidth(pEntry->GetColWidth());
+ getDesignView()->getController().addUndoActionAndInvalidate(pUndo);
+ }
+ pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId)));
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ sal_uInt16 nPos = GetColumnPos(nColId);
+ OSL_ENSURE((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId");
+
+ OTableFieldDescRef pEntry = getFields()[nPos-1];
+ OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::GetTotalCellWidth : invalid FieldDescription !");
+
+ long nRow = GetRealRow(nRowId);
+ String strText(GetCellText(nRow, nColId));
+ return GetDataWindow().LogicToPixel(Size(GetDataWindow().GetTextWidth(strText),0)).Width();
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 OSelectionBrowseBox::GetDefaultColumnWidth(const String& /*rName*/) const
+{
+ DBG_CHKTHIS(OSelectionBrowseBox,NULL);
+ // die Baissklasse macht das von dem Text abhaengig, ich habe aber keine Spaltenueberschriften, daher haette ich
+ // hier gern einen anderen Default-Wert
+ return static_cast<sal_uInt16>(DEFAULT_SIZE);
+}
+//------------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::isCutAllowed()
+{
+ sal_Bool bCutAllowed = sal_False;
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_VIS_ROW:
+ case BROW_ORDER_ROW:
+ case BROW_TABLE_ROW:
+ case BROW_FUNCTION_ROW:
+ break;
+ case BROW_FIELD_ROW:
+ bCutAllowed = m_pFieldCell->GetSelected().Len() != 0;
+ break;
+ default:
+ bCutAllowed = m_pTextCell->GetSelected().Len() != 0;
+ break;
+ }
+ return bCutAllowed;
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::cut()
+{
+ String sOldValue = GetCellContents(GetRealRow(GetCurRow()),GetCurColumnId());
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_FIELD_ROW:
+ m_pFieldCell->Cut();
+ m_pFieldCell->SetModifyFlag();
+ break;
+ default:
+ m_pTextCell->Cut();
+ m_pTextCell->SetModifyFlag();
+ }
+ SaveModified();
+ RowModified(GetBrowseRow(nRow), GetCurColumnId());
+
+ invalidateUndoRedo();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::paste()
+{
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_FIELD_ROW:
+ m_pFieldCell->Paste();
+ m_pFieldCell->SetModifyFlag();
+ break;
+ default:
+ m_pTextCell->Paste();
+ m_pTextCell->SetModifyFlag();
+ }
+ RowModified(GetBrowseRow(nRow), GetCurColumnId());
+ invalidateUndoRedo();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::isPasteAllowed()
+{
+ sal_Bool bPasteAllowed = sal_True;
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_VIS_ROW:
+ case BROW_ORDER_ROW:
+ case BROW_TABLE_ROW:
+ case BROW_FUNCTION_ROW:
+ bPasteAllowed = sal_False;
+ break;
+ }
+ return bPasteAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::isCopyAllowed()
+{
+ return isCutAllowed();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::copy()
+{
+ long nRow = GetRealRow(GetCurRow());
+ switch (nRow)
+ {
+ case BROW_FIELD_ROW:
+ m_pFieldCell->Copy();
+ break;
+ default:
+ m_pTextCell->Copy();
+ }
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow,sal_Bool& _bListAction)
+{
+ if ( !m_bInUndoMode && !_rNewValue.Equals(_rOldValue) )
+ {
+ if ( !_bListAction )
+ {
+ _bListAction = sal_True;
+ static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().EnterListAction(String(),String());
+ }
+ appendUndoAction(_rOldValue,_rNewValue,_nRow);
+ }
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow)
+{
+ if ( !m_bInUndoMode && !_rNewValue.Equals(_rOldValue) )
+ {
+ OTabFieldCellModifiedUndoAct* pUndoAct = new OTabFieldCellModifiedUndoAct(this);
+ pUndoAct->SetCellIndex(_nRow);
+ OSL_ENSURE(GetColumnPos(GetCurColumnId()) != BROWSER_INVALIDID,"Current position isn't valid!");
+ pUndoAct->SetColumnPosition( GetColumnPos(GetCurColumnId()) );
+ pUndoAct->SetCellContents(_rOldValue);
+ getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK(OSelectionBrowseBox, OnInvalidateTimer, void*, EMPTYARG)
+{
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_CUT);
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_COPY);
+ static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_PASTE);
+ if(!m_bStopTimer)
+ m_timerInvalidate.Start();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::stopTimer()
+{
+ m_bStopTimer = sal_True;
+ if (m_timerInvalidate.IsActive())
+ m_timerInvalidate.Stop();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::startTimer()
+{
+ m_bStopTimer = sal_False;
+ if (!m_timerInvalidate.IsActive())
+ m_timerInvalidate.Start();
+}
+// -----------------------------------------------------------------------------
+OTableFields& OSelectionBrowseBox::getFields() const
+{
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+ return rController.getTableFieldDesc();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl)
+{
+ sal_Bool bEnable = !_rEntry->isCondition();
+ _pControl->Enable(bEnable);
+ _pControl->EnableInput(bEnable);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,const rtl::OString& _sHelpId)
+{
+ m_pTextCell->SetText(_sText);
+ m_pTextCell->ClearModifyFlag();
+ if (!m_pTextCell->HasFocus())
+ m_pTextCell->GrabFocus();
+
+ enableControl(_rEntry,m_pTextCell);
+
+ if (m_pTextCell->GetHelpId() != _sHelpId)
+ // da TextCell in verschiedenen Kontexten verwendet wird, muss ich den gecachten HelpText loeschen
+ m_pTextCell->SetHelpText(String());
+ m_pTextCell->SetHelpId(_sHelpId);
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::invalidateUndoRedo()
+{
+ OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
+ rController.InvalidateFeature( ID_BROWSER_UNDO );
+ rController.InvalidateFeature( ID_BROWSER_REDO );
+ rController.InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
+}
+// -----------------------------------------------------------------------------
+OTableFieldDescRef OSelectionBrowseBox::getEntry(OTableFields::size_type _nPos)
+{
+ // we have to check if we need a new entry at this position
+ OTableFields& aFields = getFields();
+ OSL_ENSURE(aFields.size() > _nPos,"ColID is to great!");
+
+ OTableFieldDescRef pEntry = aFields[_nPos];
+ OSL_ENSURE(pEntry.is(),"Invalid entry!");
+ if ( !pEntry.is() )
+ {
+ pEntry = new OTableFieldDesc();
+ pEntry->SetColumnId(
+ GetColumnId(sal::static_int_cast< sal_uInt16 >(_nPos+1)));
+ aFields[_nPos] = pEntry;
+ }
+ return pEntry;
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::GetFocus()
+{
+ if(!IsEditing() && !m_bWasEditing)
+ ActivateCell();
+ EditBrowseBox::GetFocus();
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::DeactivateCell(sal_Bool _bUpdate)
+{
+ m_bWasEditing = sal_True;
+ EditBrowseBox::DeactivateCell(_bUpdate);
+ m_bWasEditing = sal_False;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSelectionBrowseBox::GetRowDescription( sal_Int32 _nRow ) const
+{
+ String aLabel(ModuleRes(STR_QUERY_HANDLETEXT));
+
+ // ab BROW_CRIT2_ROW werden alle Zeilen mit "oder" angegeben
+ xub_StrLen nToken = (xub_StrLen) (_nRow >= GetBrowseRow(BROW_CRIT2_ROW))
+ ?
+ xub_StrLen(BROW_CRIT2_ROW) : xub_StrLen(GetRealRow(_nRow));
+ return ::rtl::OUString(aLabel.GetToken(nToken));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OSelectionBrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition) const
+{
+ ::rtl::OUString sRetText;
+ switch( _eObjType )
+ {
+ case ::svt::BBTYPE_ROWHEADERCELL:
+ sRetText = GetRowDescription(_nPosition);
+ break;
+ default:
+ sRetText = EditBrowseBox::GetAccessibleObjectDescription(_eObjType,_nPosition);
+ }
+ return sRetText;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OSelectionBrowseBox::fillEntryTable(OTableFieldDescRef& _pEntry,const ::rtl::OUString& _sTableName)
+{
+ sal_Bool bRet = sal_False;
+ OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
+ if (pTabWinList)
+ {
+ OJoinTableView::OTableWindowMapIterator aIter = pTabWinList->find(_sTableName);
+ if(aIter != pTabWinList->end())
+ {
+ OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second);
+ if (pEntryTab)
+ {
+ _pEntry->SetTable(pEntryTab->GetTableName());
+ _pEntry->SetTabWindow(pEntryTab);
+ bRet = sal_True;
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void OSelectionBrowseBox::setFunctionCell(OTableFieldDescRef& _pEntry)
+{
+ Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
+ if ( xConnection.is() )
+ {
+ // Diese Funktionen stehen nur unter CORE zur Verf�gung
+ if ( lcl_SupportsCoreSQLGrammar(xConnection) )
+ {
+ // if we have an asterix, no other function than count is allowed
+ m_pFunctionCell->Clear();
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(0));
+ if ( isFieldNameAsterix(_pEntry->GetField()) )
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
+ else
+ {
+ xub_StrLen nCount = m_aFunctionStrings.GetTokenCount();
+ if ( _pEntry->isNumeric() )
+ --nCount;
+ for (xub_StrLen nIdx = 1; nIdx < nCount; nIdx++)
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(nIdx));
+ }
+
+ if ( _pEntry->IsGroupBy() )
+ {
+ OSL_ENSURE(!_pEntry->isNumeric(),"Not allowed to combine group by and numeric values!");
+ m_pFunctionCell->SelectEntry(m_pFunctionCell->GetEntry(m_pFunctionCell->GetEntryCount() - 1));
+ }
+ else if ( m_pFunctionCell->GetEntryPos(String(_pEntry->GetFunction())) != COMBOBOX_ENTRY_NOTFOUND )
+ m_pFunctionCell->SelectEntry(String(_pEntry->GetFunction()));
+ else
+ m_pFunctionCell->SelectEntryPos(0);
+
+ enableControl(_pEntry,m_pFunctionCell);
+ }
+ else
+ {
+ // nur COUNT(*) erlaubt
+ sal_Bool bCountRemoved = !isFieldNameAsterix(_pEntry->GetField());
+ if ( bCountRemoved )
+ m_pFunctionCell->RemoveEntry(1);
+
+ if ( !bCountRemoved && m_pFunctionCell->GetEntryCount() < 2)
+ m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
+
+ if(m_pFunctionCell->GetEntryPos(String(_pEntry->GetFunction())) != COMBOBOX_ENTRY_NOTFOUND)
+ m_pFunctionCell->SelectEntry(_pEntry->GetFunction());
+ else
+ m_pFunctionCell->SelectEntryPos(0);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > OSelectionBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
+{
+ OTableFieldDescRef pEntry = NULL;
+ if(getFields().size() > sal_uInt16(_nColumnPos - 1))
+ pEntry = getFields()[_nColumnPos - 1];
+
+ if ( _nRow == BROW_VIS_ROW && pEntry.is() )
+ return EditBrowseBox::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,pEntry->IsVisible() ? STATE_CHECK : STATE_NOCHECK );
+
+ return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
+}
+// -----------------------------------------------------------------------------
+bool OSelectionBrowseBox::HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const
+{
+ OTableFields& aFields = getFields();
+ OTableFields::iterator aIter = aFields.begin();
+ OTableFields::iterator aEnd = aFields.end();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( (*aIter)->GetFieldAlias() == rFieldName )
+ {
+ *rInfo = *(*aIter);
+ break;
+ }
+ }
+ return aIter != aEnd;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
new file mode 100644
index 000000000000..fc361d5fc16f
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+#define DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+
+#include <svtools/editbrowsebox.hxx>
+#include "TableFieldDescription.hxx"
+#include "JoinExchange.hxx"
+#include "QEnumTypes.hxx"
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <tools/string.hxx>
+#include <svtools/transfer.hxx>
+
+namespace connectivity
+{
+ class OSQLParseNode;
+}
+
+namespace dbaui
+{
+ //==================================================================
+#define SIZ_NONE 0
+#define SIZ_TOP 1
+#define SIZ_BOTTOM 2
+#define SIZ_LEFT 4
+#define SIZ_RIGHT 8
+
+#define BROW_FIELD_ROW 0
+#define BROW_COLUMNALIAS_ROW 1
+#define BROW_TABLE_ROW 2
+#define BROW_ORDER_ROW 3
+#define BROW_VIS_ROW 4
+#define BROW_FUNCTION_ROW 5
+#define BROW_CRIT1_ROW 6
+#define BROW_CRIT2_ROW 7
+#define BROW_CRIT3_ROW 8
+#define BROW_CRIT4_ROW 9
+#define BROW_CRIT5_ROW 10
+#define BROW_CRIT6_ROW 11
+#define BROW_ROW_CNT 12
+
+ //==================================================================
+ class OQueryDesignView;
+ class OSelectionBrowseBox : public ::svt::EditBrowseBox
+ {
+ friend class OQueryDesignView;
+ ::std::vector<bool> m_bVisibleRow; // an Pos steht die RowId
+ Timer m_timerInvalidate;
+
+ long m_nSeekRow;
+ BrowserMode m_nMode; // Merken des BrowseModes
+ Edit* m_pTextCell;
+ ::svt::CheckBoxControl* m_pVisibleCell;
+ ::svt::ComboBoxControl* m_pFieldCell;
+ ::svt::ListBoxControl* m_pFunctionCell;
+ ::svt::ListBoxControl* m_pTableCell;
+ ::svt::ListBoxControl* m_pOrderCell;
+
+ OTableFieldDescRef m_pEmptyEntry; // default entry in the list may reference more than once
+
+ sal_Int32 m_nMaxColumns; // maximale Anzahl der Spalten in einem Select-Statement
+
+ String m_aFunctionStrings;
+ sal_uInt16 m_nVisibleCount; // Anzahl der max sichtbaren Zeilen
+ sal_Bool m_bOrderByUnRelated;
+ sal_Bool m_bGroupByUnRelated;
+ sal_Bool m_bStopTimer;
+ sal_Bool m_bWasEditing;
+ sal_Bool m_bDisableErrorBox;
+ sal_Bool m_bInUndoMode;
+
+ DECL_LINK(OnInvalidateTimer, void*);
+ public: OSelectionBrowseBox( Window* pParent );
+ ~OSelectionBrowseBox();
+
+ void initialize();
+ OTableFieldDescRef InsertField( const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+ OTableFieldDescRef InsertField( const OTableFieldDescRef& rInfo, sal_uInt16 _nColumnPostion = BROWSER_INVALIDID, sal_Bool bVis=sal_True, sal_Bool bActivate=sal_True );
+ void InsertColumn( OTableFieldDescRef pEntry, sal_uInt16& _nColumnPostion );
+ void RemoveColumn( sal_uInt16 _nColumnId );
+ void DeleteFields( const String& rAliasName );
+
+ bool HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const;
+ // AddGroupBy:: F"ugt ein Feld mit Funktion == Grupierung. Falls das Feld schon vorhanden ist und ein Aggregate Funktion
+ // benutzt, wird das Flag nicht gesetzt
+ void AddGroupBy( const OTableFieldDescRef& rInfo,sal_uInt32 _nCurrentPos);
+ void AddCondition( const OTableFieldDescRef& rInfo,
+ const String& rValue,
+ const sal_uInt16 nLevel,
+ bool _bAddOrOnOneLine );
+ void DuplicateConditionLevel( const sal_uInt16 nLevel);
+ void AddOrder(const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos);
+ void ClearAll();
+ OTableFieldDescRef AppendNewCol( sal_uInt16 nCnt=1 );
+ sal_Bool Save();
+ OQueryDesignView* getDesignView();
+ OQueryDesignView* getDesignView() const;
+ sal_uInt16 FieldsCount();
+
+ void SetColWidth(sal_uInt16 nColId, long lNewWidth);
+ // beachtet im Gegensatz zum SetColumnWidth der Basisklasse auch eine eventuell aktive Zelle in dieser Spalte
+
+ String GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId);
+ void SetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId, const String& strNewText);
+ // Zelleninhalt (als String formatiert) setzen/liefern
+ sal_Int32 GetNoneVisibleRows() const;
+ void SetNoneVisbleRow(long nRows);
+ sal_Bool IsRowVisible(sal_uInt16 _nWhich) const;
+ void SetRowVisible(sal_uInt16 _nWhich, sal_Bool _bVis);
+
+ void SetReadOnly(sal_Bool bRO);
+ // calculate an optimal size. Basically, this takes into account the number of visible rows.
+ Size CalcOptimalSize( const Size& _rAvailable );
+
+ // can the current content be cut
+ sal_Bool isPasteAllowed();
+ sal_Bool isCutAllowed();
+ sal_Bool isCopyAllowed();
+ void cut();
+ void paste();
+ void copy();
+
+ virtual void GetFocus();
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+ virtual void ColumnMoved( sal_uInt16 nColId ) { ColumnMoved(nColId,sal_True); }
+ void ColumnMoved( sal_uInt16 nColId,sal_Bool _bCreateUndo);
+
+ void Fill();
+ void PreFill();
+
+ /** Disables the generation of undo actions
+ */
+ inline void EnterUndoMode() { m_bInUndoMode = sal_True; }
+ /** Enables the generation of undo actions
+ */
+ inline void LeaveUndoMode() { m_bInUndoMode = sal_False; }
+
+ /** GetCellText returns the text at the given position
+ @param _nRow
+ the number of the row
+ @param _nColId
+ the ID of the column
+ @return
+ the text out of the cell
+ */
+ virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const;
+
+ /** returns the description of the row.
+ @param _nRow
+ The row number.
+ @return
+ The header text of the specified row.
+ */
+ virtual ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const;
+
+ /** return the name of the specified object.
+ @param eObjType
+ The type to ask for
+ @param _nPosition
+ The position of a tablecell (index position), header bar colum/row cell
+ @return
+ The name of the specified object.
+ */
+ virtual ::rtl::OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
+
+ // IAccessibleTableProvider
+ /** Creates the accessible object of a data table cell.
+ @param nRow The row index of the cell.
+ @param nColumnId The column ID of the cell.
+ @return The XAccessible interface of the specified cell. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId );
+
+
+ protected:
+ virtual sal_Bool SeekRow( long nRow );
+
+ virtual void PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const;
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ sal_uInt16 nColumnId ) const;
+
+ virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
+ virtual void MouseButtonDown( const BrowserMouseEvent& rEvt );
+ virtual void MouseButtonUp( const BrowserMouseEvent& rEvt );
+ virtual void KeyInput( const KeyEvent& rEvt );
+ virtual void Command(const CommandEvent& rEvt);
+ virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY);
+
+ virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
+ virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
+ virtual void CellModified();
+ virtual sal_Bool SaveModified();
+ virtual void Init();
+ virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId) const;
+ virtual void ColumnResized( sal_uInt16 nColId );
+
+ virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
+
+ virtual sal_uInt16 GetDefaultColumnWidth(const String& rName) const;
+ // if you want to have an own header ...
+ virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent);
+
+ void stopTimer();
+ void startTimer();
+
+ private:
+ OTableFieldDescRef FindFirstFreeCol(sal_uInt16& _rColumnPosition);
+ // rCol enthaelt die Nummer (in pOTableFieldDescList) der ersten Spalte, die von sich sagt, dass sie leer ist
+ // wenn es keine solche gibt, ist rCol undefiniert und der Rueckgabewert NULL
+ void CheckFreeColumns(sal_uInt16& _rColumnPosition);
+ // testet, ob es noch freie Spalten gibt, wenn nicht, wird ein neuer Packen angefuegt
+ // rCol enthaelt die Nummer der ersten freien Spalte (in pOTableFieldDescList)
+
+ void RemoveField( sal_uInt16 nId );
+ Rectangle GetInvalidRect( sal_uInt16 nColId );
+ long GetRealRow(long nRow) const;
+ long GetBrowseRow(long nRowId) const;
+ sal_Bool GetFunctionName(sal_uInt32 _nFunctionTokenId,String& rFkt);
+ void appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow,sal_Bool& _bListAction);
+ void appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow);
+ OTableFields& getFields() const;
+ void enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl);
+ void setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,const rtl::OString& _sHelpId);
+ void invalidateUndoRedo();
+ OTableFieldDescRef getEntry(OTableFields::size_type _nPos);
+
+ void adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_Bool _bClickedOntoHandleCol );
+
+ /** save the filed change in save modified
+ @param _sFieldName
+ The field name inserted by the user.
+ @param _pEntry
+ The entry which will contain the nescessary entries.
+ @param _bListAction
+ Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
+ @return
+ <TRUE/> if an error occurred otherwise <FALSE/>
+ */
+ sal_Bool saveField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction);
+
+ /** sets the table window at the _pEntry
+ @param _pEntry
+ The entry where the window should be set.
+ @param _sTableName
+ The table name to search for.
+ @return
+ <TRUE/> if the table name was set otherwise <FALSE/>
+ */
+ sal_Bool fillEntryTable(OTableFieldDescRef& _pEntry,const ::rtl::OUString& _sTableName);
+
+ /** uses the parse node to fill all information into the field
+ @param _pColumnRef
+ The parse node used to fill the info into the field.
+ @param _xMetaData
+ Use to parse the node to a string.
+ @param _pEntry
+ The entry which will contain the nescessary entries.
+ @param _bListAction
+ Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
+ @return
+ <TRUE/> if an error occurred otherwise <FALSE/>
+ */
+ sal_Bool fillColumnRef( const ::connectivity::OSQLParseNode* _pColumnRef,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ OTableFieldDescRef& _pEntry,
+ sal_Bool& _bListAction);
+ sal_Bool fillColumnRef( const ::rtl::OUString& _sColumnName,
+ const ::rtl::OUString& _sTableRange,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData,
+ OTableFieldDescRef& _pEntry,
+ sal_Bool& _bListAction);
+
+
+ /** append an undo action for the table field
+ @param _sOldAlias
+ The old table alias.
+ @param _sAlias
+ The new alias name.
+ @param _bListAction
+ Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
+ */
+ void notifyTableFieldChanged(const String& _sOldAlias,const String& _sAlias,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
+
+ /** append an undo action for the function field
+ @param _sOldFunctionName
+ The old value.
+ @param _sFunctionName
+ The new function name.
+ @param _bListAction
+ Will be set to <TRUE/> when we are in a list action otherwise <FALSE/>
+ */
+ void notifyFunctionFieldChanged(const String& _sOldFunctionName,const String& _sFunctionName,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
+
+ /** clears the function fields of the submitted entry if it doesn't match the SQL standard and append an undo action.
+ E.q. AGGREGATE functions are only valid when the field name isn't an asterix
+ @param _sFieldName
+ The field name.
+ @param _pEntry
+ The entry to be cleared
+ @param _bListAction
+ When <TRUE/> an list action will be created.
+ */
+ void clearEntryFunctionField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction,sal_uInt16 _nColumnId);
+
+ /** remove or insert the necessary function types
+ @param _pEntry
+ The currently edited entry.
+ */
+ void setFunctionCell(OTableFieldDescRef& _pEntry);
+
+ private:
+ using ::svt::EditBrowseBox::AcceptDrop;
+ using ::svt::EditBrowseBox::ExecuteDrop;
+ using ::svt::EditBrowseBox::MouseButtonDown;
+ using ::svt::EditBrowseBox::MouseButtonUp;
+ };
+}
+#endif // DBAUI_QUERYDESIGN_OSELECTIONBROWSEBOX_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx
new file mode 100644
index 000000000000..db6a8efd328c
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableConnection.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableConnection.hxx"
+#include "ConnectionLine.hxx"
+#include "TableConnectionData.hxx"
+#include "JoinTableView.hxx"
+#include <comphelper/stl_types.hxx>
+#include "ConnectionLineAccess.hxx"
+#include <algorithm>
+
+
+using namespace dbaui;
+using namespace comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+//========================================================================
+// class OTableConnection
+//========================================================================
+namespace dbaui
+{
+ DBG_NAME(OTableConnection)
+ //------------------------------------------------------------------------
+ OTableConnection::OTableConnection( OJoinTableView* _pContainer,const TTableConnectionData::value_type& _pTabConnData )
+ :Window(_pContainer)
+ ,m_pData( _pTabConnData )
+ ,m_pParent( _pContainer )
+ ,m_bSelected( sal_False )
+ {
+ DBG_CTOR(OTableConnection,NULL);
+ Init();
+ Show();
+ }
+
+ //------------------------------------------------------------------------
+ OTableConnection::OTableConnection( const OTableConnection& _rConn ) : Window(_rConn.m_pParent)
+ ,m_pData(_rConn.GetData()->NewInstance())
+ {
+ DBG_CTOR(OTableConnection,NULL);
+ *this = _rConn;
+ }
+
+ //------------------------------------------------------------------------
+ void OTableConnection::Init()
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Linienliste mit Defaults initialisieren
+ OConnectionLineDataVec* pLineData = GetData()->GetConnLineDataList();
+ OConnectionLineDataVec::const_iterator aIter = pLineData->begin();
+ OConnectionLineDataVec::const_iterator aEnd = pLineData->end();
+ m_vConnLine.reserve(pLineData->size());
+ for(;aIter != aEnd;++aIter)
+ m_vConnLine.push_back( new OConnectionLine(this, *aIter) );
+ }
+
+ //------------------------------------------------------------------------
+ OConnectionLine* OTableConnection::CreateConnLine( const OConnectionLine& rConnLine )
+ {
+ return new OConnectionLine( rConnLine );
+ }
+ // -----------------------------------------------------------------------------
+ void OTableConnection::clearLineData()
+ {
+ ::std::vector<OConnectionLine*>::iterator aLineEnd = m_vConnLine.end();
+ for(::std::vector<OConnectionLine*>::iterator aLineIter = m_vConnLine.begin();aLineIter != aLineEnd;++aLineIter)
+ delete *aLineIter;
+ m_vConnLine.clear();
+ }
+ //------------------------------------------------------------------------
+ void OTableConnection::UpdateLineList()
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Linienliste loeschen
+ clearLineData();
+
+ Init();
+ }
+
+ //------------------------------------------------------------------------
+ OTableConnection& OTableConnection::operator=( const OTableConnection& rConn )
+ {
+ if( &rConn == this )
+ return *this;
+
+ // Linienliste loeschen
+ clearLineData();
+
+ // Linienliste kopieren
+ if(! rConn.GetConnLineList()->empty() )
+ {
+ const ::std::vector<OConnectionLine*>* pLine = rConn.GetConnLineList();
+ ::std::vector<OConnectionLine*>::const_iterator aIter = pLine->begin();
+ ::std::vector<OConnectionLine*>::const_iterator aEnd = pLine->end();
+ m_vConnLine.reserve(pLine->size());
+ for(;aIter != aEnd;++aIter)
+ m_vConnLine.push_back( CreateConnLine( **aIter ));
+ }
+
+ // da mir die Daten nicht gehoeren, loesche ich die alten nicht
+ m_pData->CopyFrom(*rConn.GetData());
+ // CopyFrom ist virtuell, damit ist es kein Problem, wenn m_pData von einem von OTableConnectionData abgeleiteten Typ ist
+
+ m_bSelected = rConn.m_bSelected;
+ m_pParent = rConn.m_pParent;
+
+ return *this;
+ }
+
+
+ //------------------------------------------------------------------------
+ bool OTableConnection::RecalcLines()
+ {
+ // call RecalcLines on each line
+ ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),::std::mem_fun(&OConnectionLine::RecalcLine));
+ return true;
+ }
+ //------------------------------------------------------------------------
+ OTableWindow* OTableConnection::GetSourceWin() const
+ {
+ TTableWindowData::value_type pRef = GetData()->getReferencingTable();
+ OTableWindow* pRet = m_pParent->GetTabWindow( pRef->GetWinName() );
+ if ( !pRet )
+ {
+ pRet = m_pParent->GetTabWindow( pRef->GetComposedName() );
+ }
+ return pRet;
+ }
+ //------------------------------------------------------------------------
+ OTableWindow* OTableConnection::GetDestWin() const
+ {
+ TTableWindowData::value_type pRef = GetData()->getReferencedTable();
+ OTableWindow* pRet = m_pParent->GetTabWindow( pRef->GetWinName() );
+ if ( !pRet )
+ {
+ pRet = m_pParent->GetTabWindow( pRef->GetComposedName() );
+ }
+ return pRet;
+ }
+
+ //------------------------------------------------------------------------
+ void OTableConnection::Select()
+ {
+ m_bSelected = sal_True;
+ m_pParent->Invalidate( GetBoundingRect(), INVALIDATE_NOCHILDREN);
+ }
+
+ //------------------------------------------------------------------------
+ void OTableConnection::Deselect()
+ {
+ m_bSelected = sal_False;
+ InvalidateConnection();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OTableConnection::CheckHit( const Point& rMousePos ) const
+ {
+ //////////////////////////////////////////////////////////////////////
+ // check if the point hit our line
+ ::std::vector<OConnectionLine*>::const_iterator aIter = ::std::find_if(m_vConnLine.begin(),
+ m_vConnLine.end(),
+ ::std::bind2nd(TConnectionLineCheckHitFunctor(),rMousePos));
+ return aIter != m_vConnLine.end();
+ }
+
+ //------------------------------------------------------------------------
+ bool OTableConnection::InvalidateConnection()
+ {
+ Rectangle rcBounding = GetBoundingRect();
+ rcBounding.Bottom() += 1;
+ rcBounding.Right() += 1;
+ // ich glaube, dass sich Invalidate und Draw(Rectangle) nicht konsistent verhalten : jedenfalls waere dadurch zu
+ // erklaeren, warum ohne diesen Fake hier beim Loeschen einer Connection ein Strich an ihrem unteren Ende stehen bleibt :
+ // Invalidate erfasst dabei offensichtlich eine Pixelzeile weniger als Draw.
+ // Oder alles haengt ganz anders zusammen ... jedenfalls klappt es so ...
+ m_pParent->Invalidate( rcBounding, INVALIDATE_NOCHILDREN );
+
+ return true;
+ }
+
+ //------------------------------------------------------------------------
+ Rectangle OTableConnection::GetBoundingRect() const
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Aus allen Linien das umgebende Rechteck bestimmen
+ Rectangle aBoundingRect( Point(0,0), Point(0,0) );
+ Rectangle aTempRect;
+ ::std::vector<OConnectionLine*>::const_iterator aEnd = m_vConnLine.end();
+ for(::std::vector<OConnectionLine*>::const_iterator aIter = m_vConnLine.begin();aIter != aEnd;++aIter)
+ {
+ aTempRect = (*aIter)->GetBoundingRect();
+
+ //////////////////////////////////////////////////////////////////////
+ // Ist das BoundingRect dieser Linie gueltig?
+ if( (aTempRect.GetWidth()!=1) && (aTempRect.GetHeight()!=1) )
+ {
+ if( (aBoundingRect.GetWidth()==1) && (aBoundingRect.GetHeight()==1) )
+ aBoundingRect = aTempRect;
+ else
+ aBoundingRect.Union( aTempRect );
+ }
+ }
+
+ return aBoundingRect;
+ }
+
+ //------------------------------------------------------------------------
+ void OTableConnection::Draw( const Rectangle& /*rRect*/ )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Linien zeichnen
+ ::std::for_each(m_vConnLine.begin(),m_vConnLine.end(),TConnectionLineDrawFunctor(m_pParent));
+ }
+ // -----------------------------------------------------------------------------
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
new file mode 100644
index 000000000000..d820c5efa280
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableConnectionData.hxx"
+#include <tools/debug.hxx>
+#include <osl/diagnose.h>
+#include <comphelper/stl_types.hxx>
+
+using namespace dbaui;
+using namespace comphelper;
+//==================================================================
+// class OTableConnectionData
+//==================================================================
+DBG_NAME(OTableConnectionData)
+//------------------------------------------------------------------------
+OTableConnectionData::OTableConnectionData()
+{
+ DBG_CTOR(OTableConnectionData,NULL);
+ Init();
+}
+// -----------------------------------------------------------------------------
+OTableConnectionData::OTableConnectionData(const TTableWindowData::value_type& _pReferencingTable
+ ,const TTableWindowData::value_type& _pReferencedTable
+ ,const String& rConnName )
+ :m_pReferencingTable(_pReferencingTable)
+ ,m_pReferencedTable(_pReferencedTable)
+ ,m_aConnName( rConnName )
+{
+ DBG_CTOR(OTableConnectionData,NULL);
+ Init();
+}
+//------------------------------------------------------------------------
+void OTableConnectionData::Init()
+{
+ //////////////////////////////////////////////////////////////////////
+ // LineDataList mit Defaults initialisieren
+ OSL_ENSURE(m_vConnLineData.size() == 0, "OTableConnectionData::Init() : nur mit leere Linienliste aufzurufen !");
+ ResetConnLines(sal_True);
+ // das legt Defaults an
+}
+//------------------------------------------------------------------------
+OTableConnectionData::OTableConnectionData( const OTableConnectionData& rConnData )
+{
+ DBG_CTOR(OTableConnectionData,NULL);
+ *this = rConnData;
+}
+//------------------------------------------------------------------------
+void OTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
+{
+ *this = rSource;
+ // hier ziehe ich mich auf das (nicht-virtuelle) operator= zurueck, das nur meine Members kopiert
+}
+
+//------------------------------------------------------------------------
+OTableConnectionData::~OTableConnectionData()
+{
+ DBG_DTOR(OTableConnectionData,NULL);
+ // LineDataList loeschen
+ OConnectionLineDataVec().swap(m_vConnLineData);
+}
+
+//------------------------------------------------------------------------
+OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionData& rConnData )
+{
+ if (&rConnData == this)
+ return *this;
+
+ m_pReferencingTable = rConnData.m_pReferencingTable;
+ m_pReferencedTable = rConnData.m_pReferencedTable;
+ m_aConnName = rConnData.GetConnName();
+
+ // clear line list
+ ResetConnLines(sal_False);
+
+ // und kopieren
+ OConnectionLineDataVec* pLineData = const_cast<OTableConnectionData*>(&rConnData)->GetConnLineDataList();
+
+ OConnectionLineDataVec::const_iterator aIter = pLineData->begin();
+ OConnectionLineDataVec::const_iterator aEnd = pLineData->end();
+ for(;aIter != aEnd;++aIter)
+ m_vConnLineData.push_back(new OConnectionLineData(**aIter));
+
+ return *this;
+}
+
+//------------------------------------------------------------------------
+sal_Bool OTableConnectionData::SetConnLine( sal_uInt16 nIndex, const String& rSourceFieldName, const String& rDestFieldName )
+{
+ if (sal_uInt16(m_vConnLineData.size()) < nIndex)
+ return sal_False;
+ // == ist noch erlaubt, das entspricht einem Append
+
+ if (m_vConnLineData.size() == nIndex)
+ return AppendConnLine(rSourceFieldName, rDestFieldName);
+
+ OConnectionLineDataRef pConnLineData = m_vConnLineData[nIndex];
+ OSL_ENSURE(pConnLineData != NULL, "OTableConnectionData::SetConnLine : habe ungueltiges LineData-Objekt");
+
+ pConnLineData->SetSourceFieldName( rSourceFieldName );
+ pConnLineData->SetDestFieldName( rDestFieldName );
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+sal_Bool OTableConnectionData::AppendConnLine( const ::rtl::OUString& rSourceFieldName, const ::rtl::OUString& rDestFieldName )
+{
+ OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
+ OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName)
+ break;
+ }
+ if(aIter == aEnd)
+ {
+ OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
+ if (!pNew.is())
+ return sal_False;
+
+ m_vConnLineData.push_back(pNew);
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+void OTableConnectionData::ResetConnLines( sal_Bool /*bUseDefaults*/ )
+{
+ OConnectionLineDataVec().swap(m_vConnLineData);
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef OTableConnectionData::CreateLineDataObj()
+{
+ return new OConnectionLineData();
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef OTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
+{
+ return new OConnectionLineData( rConnLineData );
+}
+// -----------------------------------------------------------------------------
+OTableConnectionData* OTableConnectionData::NewInstance() const
+{
+ return new OTableConnectionData();
+}
+// -----------------------------------------------------------------------------
+void OTableConnectionData::normalizeLines()
+{
+ // noch ein wenig Normalisierung auf den LineDatas : leere Lines vom Anfang an das Ende verschieben
+ sal_Int32 nCount = m_vConnLineData.size();
+ for(sal_Int32 i=0;i<nCount;)
+ {
+ if(!m_vConnLineData[i]->GetSourceFieldName().getLength() || !m_vConnLineData[i]->GetDestFieldName().getLength())
+ {
+ OConnectionLineDataRef pData = m_vConnLineData[i];
+ m_vConnLineData.erase(m_vConnLineData.begin()+i);
+ m_vConnLineData.push_back(pData);
+ --nCount;
+ }
+ else
+ ++i;
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
new file mode 100644
index 000000000000..8edf83464b96
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
@@ -0,0 +1,242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableFieldDescription.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <comphelper/namedvaluecollection.hxx>
+
+#include <functional>
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace comphelper;
+using namespace dbaui;
+
+DBG_NAME(OTableFieldDesc)
+//==============================================================================
+OTableFieldDesc::OTableFieldDesc()
+ :m_pTabWindow(0)
+ ,m_eDataType(1000)
+ ,m_eFunctionType( FKT_NONE )
+ ,m_eFieldType(TAB_NORMAL_FIELD)
+ ,m_eOrderDir( ORDER_NONE )
+ ,m_nIndex(0)
+ ,m_nColWidth(0)
+ ,m_nColumnId((sal_uInt16)-1)
+ ,m_bGroupBy(sal_False)
+ ,m_bVisible(sal_False)
+{
+ DBG_CTOR(OTableFieldDesc,NULL);
+}
+//------------------------------------------------------------------------------
+OTableFieldDesc::OTableFieldDesc(const OTableFieldDesc& rRS)
+ : ::salhelper::SimpleReferenceObject()
+
+{
+ DBG_CTOR(OTableFieldDesc,NULL);
+ *this = rRS;
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDesc::OTableFieldDesc(const ::rtl::OUString& rT, const ::rtl::OUString& rF )
+ :m_pTabWindow(0)
+ ,m_eFunctionType( FKT_NONE )
+ ,m_eOrderDir( ORDER_NONE )
+ ,m_nColumnId((sal_uInt16)-1)
+ ,m_bGroupBy(sal_False)
+ ,m_bVisible(sal_False)
+{
+ DBG_CTOR(OTableFieldDesc,NULL);
+ SetField( rF ); SetTable( rT );
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDesc::~OTableFieldDesc()
+{
+ DBG_DTOR(OTableFieldDesc,NULL);
+}
+//------------------------------------------------------------------------------
+OTableFieldDesc& OTableFieldDesc::operator=( const OTableFieldDesc& rRS )
+{
+ if (&rRS == this)
+ return *this;
+
+ m_aCriteria = rRS.GetCriteria();
+ m_aTableName = rRS.GetTable();
+ m_aAliasName = rRS.GetAlias(); // table range
+ m_aFieldName = rRS.GetField(); // column
+ m_aFieldAlias = rRS.GetFieldAlias(); // column alias
+ m_aFunctionName = rRS.GetFunction(); // Funktionsname
+ m_pTabWindow = rRS.GetTabWindow();
+ m_eDataType = rRS.GetDataType();
+ m_eFunctionType = rRS.GetFunctionType();
+ m_eFieldType = rRS.GetFieldType();
+ m_eOrderDir = rRS.GetOrderDir();
+ m_nIndex = rRS.GetFieldIndex();
+ m_nColWidth = rRS.GetColWidth();
+ m_nColumnId = rRS.m_nColumnId;
+ m_bGroupBy = rRS.IsGroupBy();
+ m_bVisible = rRS.IsVisible();
+
+ return *this;
+}
+//------------------------------------------------------------------------------
+sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc )
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+
+ return ( m_eOrderDir != rDesc.GetOrderDir() ||
+ m_eDataType != rDesc.GetDataType() ||
+ m_aAliasName != rDesc.GetAlias() ||
+ m_aFunctionName != rDesc.GetFunction() ||
+ m_aFieldName != rDesc.GetField() ||
+ m_aTableName != rDesc.GetTable() ||
+ m_bGroupBy != rDesc.IsGroupBy() ||
+ m_aCriteria != rDesc.GetCriteria() ||
+ m_bVisible != rDesc.IsVisible() );
+
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDesc::SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit)
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+ if (nIdx < m_aCriteria.size())
+ m_aCriteria[nIdx] = rCrit;
+ else
+ {
+ for(sal_Int32 i=m_aCriteria.size();i<nIdx;++i)
+ m_aCriteria.push_back( ::rtl::OUString());
+ m_aCriteria.push_back(rCrit);
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OTableFieldDesc::GetCriteria( sal_uInt16 nIdx ) const
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+ ::rtl::OUString aRetStr;
+ if( nIdx < m_aCriteria.size())
+ aRetStr = m_aCriteria[nIdx];
+
+ return aRetStr;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ struct SelectPropertyValueAsString : public ::std::unary_function< PropertyValue, ::rtl::OUString >
+ {
+ ::rtl::OUString operator()( const PropertyValue& i_rPropValue ) const
+ {
+ ::rtl::OUString sValue;
+ OSL_VERIFY( i_rPropValue.Value >>= sValue );
+ return sValue;
+ }
+ };
+}
+
+// -----------------------------------------------------------------------------
+void OTableFieldDesc::Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria )
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+
+ ::comphelper::NamedValueCollection aFieldDesc( i_rSettings.Value );
+ m_aAliasName = aFieldDesc.getOrDefault( "AliasName", m_aAliasName );
+ m_aTableName = aFieldDesc.getOrDefault( "TableName", m_aTableName );
+ m_aFieldName = aFieldDesc.getOrDefault( "FieldName", m_aFieldName );
+ m_aFieldAlias = aFieldDesc.getOrDefault( "FieldAlias", m_aFieldAlias );
+ m_aFunctionName = aFieldDesc.getOrDefault( "FunctionName", m_aFunctionName );
+ m_eDataType = aFieldDesc.getOrDefault( "DataType", m_eDataType );
+ m_eFunctionType = aFieldDesc.getOrDefault( "FunctionType", m_eFunctionType );
+ m_nColWidth = aFieldDesc.getOrDefault( "ColWidth", m_nColWidth );
+ m_bGroupBy = aFieldDesc.getOrDefault( "GroupBy", m_bGroupBy );
+ m_bVisible = aFieldDesc.getOrDefault( "Visible", m_bVisible );
+
+ m_eFieldType = static_cast< ETableFieldType >( aFieldDesc.getOrDefault( "FieldType", static_cast< sal_Int32 >( m_eFieldType ) ) );
+ m_eOrderDir = static_cast< EOrderDir >( aFieldDesc.getOrDefault( "OrderDir", static_cast< sal_Int32 >( m_eOrderDir ) ) );
+
+ if ( i_bIncludingCriteria )
+ {
+ const Sequence< PropertyValue > aCriteria( aFieldDesc.getOrDefault( "Criteria", Sequence< PropertyValue >() ) );
+ m_aCriteria.resize( aCriteria.getLength() );
+ ::std::transform(
+ aCriteria.getConstArray(),
+ aCriteria.getConstArray() + aCriteria.getLength(),
+ m_aCriteria.begin(),
+ SelectPropertyValueAsString()
+ );
+ }
+}
+//------------------------------------------------------------------------------
+void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria )
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+
+ o_rSettings.put( "AliasName", m_aAliasName );
+ o_rSettings.put( "TableName", m_aTableName );
+ o_rSettings.put( "FieldName", m_aFieldName );
+ o_rSettings.put( "FieldAlias", m_aFieldAlias );
+ o_rSettings.put( "FunctionName", m_aFunctionName );
+ o_rSettings.put( "DataType", m_eDataType );
+ o_rSettings.put( "FunctionType", (sal_Int32)m_eFunctionType );
+ o_rSettings.put( "FieldType", (sal_Int32)m_eFieldType );
+ o_rSettings.put( "OrderDir", (sal_Int32)m_eOrderDir );
+ o_rSettings.put( "ColWidth", m_nColWidth );
+ o_rSettings.put( "GroupBy", m_bGroupBy );
+ o_rSettings.put( "Visible", m_bVisible );
+
+ if ( i_bIncludingCriteria )
+ {
+ if ( !m_aCriteria.empty() )
+ {
+ sal_Int32 c = 0;
+ Sequence< PropertyValue > aCriteria( m_aCriteria.size() );
+ for ( ::std::vector< ::rtl::OUString >::const_iterator crit = m_aCriteria.begin();
+ crit != m_aCriteria.end();
+ ++crit, ++c
+ )
+ {
+ aCriteria[c].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Criterion_" ) ) + ::rtl::OUString::valueOf( c );
+ aCriteria[c].Value <<= *crit;
+ }
+
+ o_rSettings.put( "Criteria", aCriteria );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx
new file mode 100644
index 000000000000..7ef432c32bd8
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableFieldInfo.hxx"
+#include <tools/debug.hxx>
+
+using namespace dbaui;
+//==================================================================
+// class OTableFieldInfo
+//==================================================================
+
+DBG_NAME(OTableFieldInfo)
+OTableFieldInfo::OTableFieldInfo() :
+ m_eDataType(1000)
+{
+ DBG_CTOR(OTableFieldInfo,NULL);
+ m_eFieldType = TAB_NORMAL_FIELD;
+}
+
+//------------------------------------------------------------------------------
+OTableFieldInfo::~OTableFieldInfo()
+{
+ DBG_DTOR(OTableFieldInfo,NULL);
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.hxx b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx
new file mode 100644
index 000000000000..090d71735665
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableFieldInfo.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDINFO_HXX
+#define DBAUI_TABLEFIELDINFO_HXX
+
+#include "QEnumTypes.hxx"
+#include <sal/types.h>
+
+namespace dbaui
+{
+ class OTableFieldInfo
+ {
+ private:
+ ETableFieldType m_eFieldType;
+ sal_Int32 m_eDataType;
+
+ public:
+ OTableFieldInfo();
+ ~OTableFieldInfo();
+
+ inline ETableFieldType GetKeyType() const { return m_eFieldType; }
+ inline void SetKey(ETableFieldType bKey=TAB_NORMAL_FIELD) { m_eFieldType = bKey; }
+ inline sal_Int32 GetDataType() const { return m_eDataType; }
+ inline void SetDataType(sal_Int32 eTyp) { m_eDataType = eTyp; }
+ };
+}
+#endif // DBAUI_TABLEFIELDINFO_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx
new file mode 100644
index 000000000000..57185506f84c
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindow.cxx
@@ -0,0 +1,803 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableWindow.hxx"
+#include "TableWindowListBox.hxx"
+#include "QueryTableView.hxx"
+#include "QueryDesignView.hxx"
+#include "TableWindowData.hxx"
+#include "imageprovider.hxx"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <vcl/svapp.hxx>
+#include <vcl/wall.hxx>
+
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include "querycontroller.hxx"
+#include "dbu_qry.hrc"
+#include "dbustrings.hrc"
+#include "Query.hrc"
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+#include "TableWindowAccess.hxx"
+#include "browserids.hxx"
+#include <connectivity/dbtools.hxx>
+
+
+using namespace dbaui;
+using namespace ::utl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::accessibility;
+
+#define TABWIN_SIZING_AREA 4
+#define LISTBOX_SCROLLING_AREA 6
+#define SCROLLING_TIMESPAN 500
+
+#define TABWIN_WIDTH_MIN 90
+#define TABWIN_HEIGHT_MIN 80
+
+//========================================================================
+// class OTableWindow
+//========================================================================
+DBG_NAME(OTableWindow)
+//------------------------------------------------------------------------------
+OTableWindow::OTableWindow( Window* pParent, const TTableWindowData::value_type& pTabWinData )
+ : ::comphelper::OContainerListener(m_aMutex)
+ ,Window( pParent, WB_3DLOOK|WB_MOVEABLE )
+ ,m_aTypeImage( this )
+ ,m_aTitle( this )
+ ,m_pListBox(NULL)
+ ,m_pAccessible(NULL)
+ ,m_pData( pTabWinData )
+ ,m_nMoveCount(0)
+ ,m_nMoveIncrement(1)
+ ,m_nSizingFlags( SIZING_NONE )
+ ,m_bActive( sal_False )
+{
+ DBG_CTOR(OTableWindow,NULL);
+
+ // Position und Groesse bestimmen
+ if( GetData()->HasPosition() )
+ SetPosPixel( GetData()->GetPosition() );
+
+ if( GetData()->HasSize() )
+ SetSizePixel( GetData()->GetSize() );
+
+ // Hintergrund setzen
+ const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
+ SetBackground(Wallpaper(aSystemStyle.GetFaceColor()));
+ // und Textfarbe (obwohl ich eigentlich keinen Text habe, aber wer weiss, was
+ // abgeleitete Klassen machen)
+ SetTextColor(aSystemStyle.GetButtonTextColor());
+
+ EnableClipSiblings();
+}
+
+//------------------------------------------------------------------------------
+OTableWindow::~OTableWindow()
+{
+ DBG_DTOR(OTableWindow,NULL);
+
+ if (m_pListBox)
+ {
+ OSL_ENSURE(m_pListBox->GetEntryCount()==0,"Forgot to call EmptyListbox()!");
+ ::std::auto_ptr<Window> aTemp(m_pListBox);
+ m_pListBox = NULL;
+ }
+ if ( m_pContainerListener.is() )
+ m_pContainerListener->dispose();
+
+ m_pAccessible = NULL;
+}
+// -----------------------------------------------------------------------------
+const OJoinTableView* OTableWindow::getTableView() const
+{
+ OSL_ENSURE(static_cast<OJoinTableView*>(GetParent()),"No OJoinTableView!");
+ return static_cast<OJoinTableView*>(GetParent());
+}
+// -----------------------------------------------------------------------------
+OJoinTableView* OTableWindow::getTableView()
+{
+ OSL_ENSURE(static_cast<OJoinTableView*>(GetParent()),"No OJoinTableView!");
+ return static_cast<OJoinTableView*>(GetParent());
+}
+// -----------------------------------------------------------------------------
+OJoinDesignView* OTableWindow::getDesignView()
+{
+ OSL_ENSURE(static_cast<OJoinDesignView*>(GetParent()->GetParent()->GetParent()),"No OJoinDesignView!");
+ return static_cast<OJoinDesignView*>(GetParent()->GetParent()->GetParent());
+}
+//------------------------------------------------------------------------------
+void OTableWindow::SetPosPixel( const Point& rNewPos )
+{
+ Point aNewPosData = rNewPos + getTableView()->GetScrollOffset();
+ GetData()->SetPosition( aNewPosData );
+ Window::SetPosPixel( rNewPos );
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::SetSizePixel( const Size& rNewSize )
+{
+ Size aOutSize(rNewSize);
+ if( aOutSize.Width() < TABWIN_WIDTH_MIN )
+ aOutSize.Width() = TABWIN_WIDTH_MIN;
+ if( aOutSize.Height() < TABWIN_HEIGHT_MIN )
+ aOutSize.Height() = TABWIN_HEIGHT_MIN;
+
+ GetData()->SetSize( aOutSize );
+ Window::SetSizePixel( aOutSize );
+}
+//------------------------------------------------------------------------------
+void OTableWindow::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
+{
+ SetPosPixel( rNewPos );
+ SetSizePixel( rNewSize );
+}
+//------------------------------------------------------------------------------
+OTableWindowListBox* OTableWindow::CreateListBox()
+{
+ return new OTableWindowListBox(this);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableWindow::FillListBox()
+{
+ m_pListBox->Clear();
+ if ( !m_pContainerListener.is() )
+ {
+ Reference< XContainer> xContainer(m_pData->getColumns(),UNO_QUERY);
+ if ( xContainer.is() )
+ m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
+ }
+ // mark all primary keys with special image
+ ModuleRes TmpRes(IMG_JOINS);
+ ImageList aImageList(TmpRes);
+ Image aPrimKeyImage = aImageList.GetImage(IMG_PRIMARY_KEY);
+
+ if (GetData()->IsShowAll())
+ {
+ SvLBoxEntry* pEntry = m_pListBox->InsertEntry( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")) );
+ pEntry->SetUserData( createUserData(NULL,false) );
+ }
+
+ Reference<XNameAccess> xPKeyColumns;
+ try
+ {
+ xPKeyColumns = dbtools::getPrimaryKeyColumns_throw(m_pData->getTable());
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("Exception occurred!");
+ }
+ try
+ {
+ Reference< XNameAccess > xColumns = m_pData->getColumns();
+ if( xColumns.is() )
+ {
+ Sequence< ::rtl::OUString> aColumns = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
+
+ SvLBoxEntry* pEntry = NULL;
+ for (; pIter != pEnd; ++pIter)
+ {
+ bool bPrimaryKeyColumn = xPKeyColumns.is() && xPKeyColumns->hasByName( *pIter );
+ // is this column in the primary key
+ if ( bPrimaryKeyColumn )
+ pEntry = m_pListBox->InsertEntry(*pIter, aPrimKeyImage, aPrimKeyImage);
+ else
+ pEntry = m_pListBox->InsertEntry(*pIter);
+
+ Reference<XPropertySet> xColumn(xColumns->getByName(*pIter),UNO_QUERY);
+ if ( xColumn.is() )
+ pEntry->SetUserData( createUserData(xColumn,bPrimaryKeyColumn) );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("Exception occurred!");
+ }
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void* OTableWindow::createUserData(const Reference< XPropertySet>& /*_xColumn*/,bool /*_bPrimaryKey*/)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::deleteUserData(void*& _pUserData)
+{
+ OSL_ENSURE(!_pUserData,"INVALID call. Need to delete the userclass!");
+ _pUserData = NULL;
+}
+//------------------------------------------------------------------------------
+void OTableWindow::clearListBox()
+{
+ if ( m_pListBox )
+ {
+ SvLBoxEntry* pEntry = m_pListBox->First();
+
+ while(pEntry)
+ {
+ void* pUserData = pEntry->GetUserData();
+ deleteUserData(pUserData);
+ SvLBoxEntry* pNextEntry = m_pListBox->Next(pEntry);
+ m_pListBox->GetModel()->Remove(pEntry);
+ pEntry = pNextEntry;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::impl_updateImage()
+{
+ ImageProvider aImageProvider( getDesignView()->getController().getConnection() );
+
+ Image aImage;
+ aImageProvider.getImages( GetComposedName(), m_pData->isQuery() ? DatabaseObject::QUERY : DatabaseObject::TABLE, aImage );
+
+ if ( !aImage )
+ {
+ OSL_FAIL( "OTableWindow::impl_updateImage: no images!" );
+ return;
+ }
+
+ m_aTypeImage.SetModeImage( aImage );
+ m_aTypeImage.Show();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableWindow::Init()
+{
+ // create list box if necessary
+ if ( !m_pListBox )
+ {
+ m_pListBox = CreateListBox();
+ OSL_ENSURE( m_pListBox != NULL, "OTableWindow::Init() : CreateListBox hat NULL geliefert !" );
+ m_pListBox->SetSelectionMode( MULTIPLE_SELECTION );
+ }
+
+ // Titel setzen
+ m_aTitle.SetText( m_pData->GetWinName() );
+ m_aTitle.Show();
+
+ m_pListBox->Show();
+
+ // die Felder in die ListBox eintragen
+ clearListBox();
+ sal_Bool bSuccess = FillListBox();
+ if ( bSuccess )
+ m_pListBox->SelectAll( sal_False );
+
+ impl_updateImage();
+
+ return bSuccess;
+}
+//------------------------------------------------------------------------------
+void OTableWindow::DataChanged(const DataChangedEvent& rDCEvt)
+{
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
+ {
+ // nehmen wir den worst-case an : die Farben haben sich geaendert, also
+ // mich anpassen
+ const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
+ SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
+ SetTextColor(aSystemStyle.GetButtonTextColor());
+ }
+}
+//------------------------------------------------------------------------------
+void OTableWindow::Paint( const Rectangle& rRect )
+{
+ Rectangle aRect( Point(0,0), GetOutputSizePixel() );
+ Window::Paint( rRect );
+ Draw3DBorder( aRect );
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::Draw3DBorder(const Rectangle& rRect)
+{
+ // die Style-Settings des Systems fuer meine Farben
+ const StyleSettings& aSystemStyle = Application::GetSettings().GetStyleSettings();
+
+ // Schwarze Linie unten und rechts
+ SetLineColor(aSystemStyle.GetDarkShadowColor());
+ DrawLine( rRect.BottomLeft(), rRect.BottomRight() );
+ DrawLine( rRect.BottomRight(), rRect.TopRight() );
+
+ // Dunkelgraue Linie ueber der schwarzen
+ SetLineColor(aSystemStyle.GetShadowColor());
+ Point aEHvector(1,1);
+ DrawLine( rRect.BottomLeft()+Point(1,-1), rRect.BottomRight() - aEHvector );
+ DrawLine( rRect.BottomRight() - aEHvector, rRect.TopRight()+Point(-1,1) );
+
+ // Hellgraue Linie links und oben
+ SetLineColor(aSystemStyle.GetLightColor());
+ DrawLine( rRect.BottomLeft()+Point(1,-2), rRect.TopLeft() + aEHvector );
+ DrawLine( rRect.TopLeft() + aEHvector, rRect.TopRight()+Point(-2,1) );
+}
+// -----------------------------------------------------------------------------
+Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSize) const
+{
+ Rectangle aSizingRect = Rectangle( GetPosPixel(), GetSizePixel() );
+ sal_uInt16 nSizingFlags = GetSizingFlags();
+
+ if( nSizingFlags & SIZING_TOP )
+ {
+ if( _rPos.Y() < 0 )
+ aSizingRect.Top() = 0;
+ else
+ aSizingRect.Top() = _rPos.Y();
+ }
+
+ if( nSizingFlags & SIZING_BOTTOM )
+ {
+ if( _rPos.Y() > _rOutputSize.Height() )
+ aSizingRect.Bottom() = _rOutputSize.Height();
+ else
+ aSizingRect.Bottom() = _rPos.Y();
+ }
+
+
+ if( nSizingFlags & SIZING_RIGHT )
+ {
+ if( _rPos.X() > _rOutputSize.Width() )
+ aSizingRect.Right() = _rOutputSize.Width();
+ else
+ aSizingRect.Right() = _rPos.X();
+ }
+
+ if( nSizingFlags & SIZING_LEFT )
+ {
+ if( _rPos.X() < 0 )
+ aSizingRect.Left() = 0;
+ else
+ aSizingRect.Left() = _rPos.X();
+ }
+ return aSizingRect;
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::setSizingFlag(const Point& _rPos)
+{
+ Size aOutSize = GetOutputSizePixel();
+ //////////////////////////////////////////////////////////////////////
+ // Flags anpassen, wenn Mauszeiger in sizingArea
+ m_nSizingFlags = SIZING_NONE;
+
+ if( _rPos.X() < TABWIN_SIZING_AREA )
+ m_nSizingFlags |= SIZING_LEFT;
+
+ if( _rPos.Y() < TABWIN_SIZING_AREA )
+ m_nSizingFlags |= SIZING_TOP;
+
+ if( _rPos.X() > aOutSize.Width()-TABWIN_SIZING_AREA )
+ m_nSizingFlags |= SIZING_RIGHT;
+
+ if( _rPos.Y() > aOutSize.Height()-TABWIN_SIZING_AREA )
+ m_nSizingFlags |= SIZING_BOTTOM;
+}
+//------------------------------------------------------------------------------
+void OTableWindow::MouseMove( const MouseEvent& rEvt )
+{
+ Window::MouseMove(rEvt);
+
+ OJoinTableView* pCont = getTableView();
+ if (pCont->getDesignView()->getController().isReadOnly())
+ return;
+
+ Point aPos = rEvt.GetPosPixel();
+ setSizingFlag(aPos);
+ Pointer aPointer;
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Mauszeiger anpassen, wenn Mauszeiger in sizingArea
+ switch( m_nSizingFlags )
+ {
+ case SIZING_TOP:
+ case SIZING_BOTTOM:
+ aPointer = Pointer( POINTER_SSIZE );
+ break;
+
+ case SIZING_LEFT:
+ case SIZING_RIGHT:
+ aPointer = Pointer( POINTER_ESIZE );
+ break;
+
+ case SIZING_LEFT+SIZING_TOP:
+ case SIZING_RIGHT+SIZING_BOTTOM:
+ aPointer = Pointer( POINTER_SESIZE );
+ break;
+
+ case SIZING_RIGHT+SIZING_TOP:
+ case SIZING_LEFT+SIZING_BOTTOM:
+ aPointer = Pointer( POINTER_NESIZE );
+ break;
+ }
+
+ SetPointer( aPointer );
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::MouseButtonDown( const MouseEvent& rEvt )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Wenn sizing, dann bekommt Parent die Nachricht,
+ // dass jetzt die Fenstergroesse seines Childs veraendert wird
+ if( m_nSizingFlags )
+ getTableView()->BeginChildSizing( this, GetPointer() );
+
+ Window::MouseButtonDown( rEvt );
+}
+
+
+
+//------------------------------------------------------------------------------
+void OTableWindow::Resize()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Das Fenster darf nicht verschwinden, deshalb min. Groesse setzen
+ Size aOutSize = GetOutputSizePixel();
+ aOutSize = Size(CalcZoom(aOutSize.Width()),CalcZoom(aOutSize.Height()));
+
+ long nTitleHeight = CalcZoom( GetTextHeight() )+ CalcZoom( 4 );
+
+ //////////////////////////////////////////////////////////////////////
+ // Titel und ListBox anpassen
+ long n5Pos = CalcZoom(5);
+ long nPositionX = n5Pos;
+ long nPositionY = n5Pos;
+
+ // position the image which indicates the type
+ m_aTypeImage.SetPosPixel( Point( nPositionX, nPositionY ) );
+ Size aImageSize( m_aTypeImage.GetImage().GetSizePixel() );
+ m_aTypeImage.SetSizePixel( aImageSize );
+
+ if ( nTitleHeight < aImageSize.Height() )
+ nTitleHeight = aImageSize.Height();
+
+ nPositionX += aImageSize.Width() + CalcZoom( 2 );
+ m_aTitle.SetPosSizePixel( Point( nPositionX, nPositionY ), Size( aOutSize.Width() - nPositionX - n5Pos, nTitleHeight ) );
+
+ long nTitleToList = CalcZoom( 3 );
+
+ m_pListBox->SetPosSizePixel(
+ Point( n5Pos, nPositionY + nTitleHeight + nTitleToList ),
+ Size( aOutSize.Width() - 2 * n5Pos, aOutSize.Height() - ( nPositionY + nTitleHeight + nTitleToList ) - n5Pos )
+ );
+
+ Window::Invalidate();
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::SetBoldTitle( sal_Bool bBold )
+{
+ Font aFont = m_aTitle.GetFont();
+ aFont.SetWeight( bBold?WEIGHT_BOLD:WEIGHT_NORMAL );
+ m_aTitle.SetFont( aFont );
+ m_aTitle.Invalidate();
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::GetFocus()
+{
+ Window::GetFocus();
+ // we have to forward the focus to our listbox to enable keystokes
+ if(m_pListBox)
+ m_pListBox->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::setActive(sal_Bool _bActive)
+{
+ SetBoldTitle( _bActive );
+ m_bActive = _bActive;
+ if (!_bActive && m_pListBox && m_pListBox->GetSelectionCount() != 0)
+ m_pListBox->SelectAll(sal_False);
+}
+
+//------------------------------------------------------------------------------
+void OTableWindow::Remove()
+{
+ //////////////////////////////////////////////////////////////////
+ // Fenster loeschen
+ OJoinTableView* pTabWinCont = getTableView();
+ pTabWinCont->RemoveTabWin( this );
+ pTabWinCont->Invalidate();
+}
+//------------------------------------------------------------------------------
+sal_Bool OTableWindow::HandleKeyInput( const KeyEvent& rEvt )
+{
+ const KeyCode& rCode = rEvt.GetKeyCode();
+ sal_uInt16 nCode = rCode.GetCode();
+ sal_Bool bShift = rCode.IsShift();
+ sal_Bool bCtrl = rCode.IsMod1();
+
+ sal_Bool bHandle = sal_False;
+
+ if( !bCtrl && !bShift && (nCode==KEY_DELETE) )
+ {
+ Remove();
+ bHandle = sal_True;
+ }
+ return bHandle;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableWindow::ExistsAConn() const
+{
+ return getTableView()->ExistsAConn(this);
+}
+//------------------------------------------------------------------------------
+void OTableWindow::EnumValidFields(::std::vector< ::rtl::OUString>& arrstrFields)
+{
+ arrstrFields.clear();
+ // diese Default-Implementierung zaehlt einfach alles auf, was es in der ListBox gibt ... fuer anderes Verhalten ueberschreiben
+ if ( m_pListBox )
+ {
+ arrstrFields.reserve(m_pListBox->GetEntryCount());
+ SvLBoxEntry* pEntryLoop = m_pListBox->First();
+ while (pEntryLoop)
+ {
+ arrstrFields.push_back(m_pListBox->GetEntryText(pEntryLoop));
+ pEntryLoop = m_pListBox->Next(pEntryLoop);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::StateChanged( StateChangedType nType )
+{
+ Window::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_ZOOM )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ Font aFont = rStyleSettings.GetGroupFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetZoomedPointFont( aFont );
+
+ m_aTitle.SetZoom(GetZoom());
+ m_pListBox->SetZoom(GetZoom());
+ Resize();
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > OTableWindow::CreateAccessible()
+{
+ OTableWindowAccess* pAccessible = new OTableWindowAccess(this);
+ m_pAccessible = pAccessible;
+ return pAccessible;
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::Command(const CommandEvent& rEvt)
+{
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ OJoinController& rController = getDesignView()->getController();
+ if(!rController.isReadOnly() && rController.isConnected())
+ {
+ Point ptWhere;
+ if ( rEvt.IsMouseEvent() )
+ ptWhere = rEvt.GetMousePosPixel();
+ else
+ {
+ SvLBoxEntry* pCurrent = m_pListBox->GetCurEntry();
+ if ( pCurrent )
+ ptWhere = m_pListBox->GetEntryPosition(pCurrent);
+ else
+ ptWhere = m_aTitle.GetPosPixel();
+ }
+
+ PopupMenu aContextMenu(ModuleRes(RID_MENU_JOINVIEW_TABLE));
+ switch (aContextMenu.Execute(this, ptWhere))
+ {
+ case SID_DELETE:
+ Remove();
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ Window::Command(rEvt);
+ }
+}
+// -----------------------------------------------------------------------------
+long OTableWindow::PreNotify(NotifyEvent& rNEvt)
+{
+ sal_Bool bHandled = sal_False;
+ switch (rNEvt.GetType())
+ {
+ case EVENT_KEYINPUT:
+ {
+ if ( getDesignView()->getController().isReadOnly() )
+ break;
+
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ const KeyCode& rCode = pKeyEvent->GetKeyCode();
+ if ( rCode.IsMod1() )
+ {
+ Point aStartPoint = GetPosPixel();
+ if ( rCode.IsShift() )
+ {
+ aStartPoint.X() = GetSizePixel().Width();
+ aStartPoint.Y() = GetSizePixel().Height();
+ }
+
+ switch( rCode.GetCode() )
+ {
+ case KEY_DOWN:
+ bHandled = sal_True;
+ aStartPoint.Y() += m_nMoveIncrement;
+ break;
+ case KEY_UP:
+ bHandled = sal_True;
+ aStartPoint.Y() += -m_nMoveIncrement;
+ break;
+ case KEY_LEFT:
+ bHandled = sal_True;
+ aStartPoint.X() += -m_nMoveIncrement;
+ break;
+ case KEY_RIGHT:
+ bHandled = sal_True;
+ aStartPoint.X() += m_nMoveIncrement;
+ break;
+ }
+ if ( bHandled )
+ {
+ if ( rCode.IsShift() )
+ {
+ OJoinTableView* pView = getTableView();
+ Point ptOld = GetPosPixel();
+ Size aSize = pView->getRealOutputSize();
+ Size aNewSize(aStartPoint.X(),aStartPoint.Y());
+ if ( ((ptOld.X() + aNewSize.Width()) <= aSize.Width())
+ && ((ptOld.Y() + aNewSize.Height()) <= aSize.Height()) )
+ {
+ if ( aNewSize.Width() < TABWIN_WIDTH_MIN )
+ aNewSize.Width() = TABWIN_WIDTH_MIN;
+ if ( aNewSize.Height() < TABWIN_HEIGHT_MIN )
+ aNewSize.Height() = TABWIN_HEIGHT_MIN;
+
+ Size szOld = GetSizePixel();
+
+ aNewSize = Size(pView->CalcZoom(aNewSize.Width()),pView->CalcZoom(aNewSize.Height()));
+ SetPosSizePixel( ptOld, aNewSize );
+ pView->TabWinSized(this, ptOld, szOld);
+ Invalidate( INVALIDATE_NOCHILDREN );
+ }
+ }
+ else
+ {
+ // remember how often the user moved our window
+ ++m_nMoveCount;
+ if( m_nMoveCount == 5 )
+ m_nMoveIncrement = 10;
+ else if( m_nMoveCount > 15 )
+ m_nMoveCount = m_nMoveIncrement = 20;
+
+ Point aOldDataPoint = GetData()->GetPosition();
+ Point aNewDataPoint = aStartPoint + getTableView()->GetScrollOffset();
+ if ( aNewDataPoint.X() > -1 && aNewDataPoint.Y() > -1 )
+ {
+ OJoinTableView* pView = getTableView();
+ if ( pView->isMovementAllowed(aNewDataPoint, GetData()->GetSize()) )
+ {
+ SetPosPixel(aStartPoint);
+
+ // aNewDataPoint can not be used here because SetPosPixel reset it
+ pView->EnsureVisible(GetData()->GetPosition(), GetData()->GetSize());
+ pView->TabWinMoved(this,aOldDataPoint);
+ Invalidate(INVALIDATE_NOCHILDREN);
+ getDesignView()->getController().setModified( sal_True );
+ }
+ else
+ {
+ m_nMoveCount = 0; // reset our movement count
+ m_nMoveIncrement = 1;
+ }
+ }
+ else
+ {
+ m_nMoveCount = 0; // reset our movement count
+ m_nMoveIncrement = 1;
+ }
+ }
+ resetSizingFlag();
+ }
+ else
+ {
+ m_nMoveCount = 0; // reset our movement count
+ m_nMoveIncrement = 1;
+ }
+ }
+ else
+ {
+ m_nMoveCount = 0; // reset our movement count
+ m_nMoveIncrement = 1;
+ }
+ }
+ break;
+ case EVENT_KEYUP:
+ {
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ const KeyCode& rCode = pKeyEvent->GetKeyCode();
+ sal_uInt16 nKeyCode = rCode.GetCode();
+ if ( rCode.IsMod2() && nKeyCode != KEY_UP && nKeyCode != KEY_DOWN && nKeyCode != KEY_LEFT && nKeyCode != KEY_RIGHT )
+ {
+ m_nMoveCount = 0; // reset our movement count
+ m_nMoveIncrement = 1;
+ }
+ }
+ break;
+ }
+ if (!bHandled)
+ return Window::PreNotify(rNEvt);
+ return 1L;
+}
+// -----------------------------------------------------------------------------
+String OTableWindow::getTitle() const
+{
+ return m_aTitle.GetText();
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ FillListBox();
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ FillListBox();
+}
+// -----------------------------------------------------------------------------
+void OTableWindow::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+ FillListBox();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
new file mode 100644
index 000000000000..44b3953b57e8
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
@@ -0,0 +1,294 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableWindowAccess.hxx"
+#include "JAccess.hxx"
+#include "TableWindow.hxx"
+#include "TableWindowListBox.hxx"
+#include "JoinDesignView.hxx"
+#include "JoinController.hxx"
+#include "JoinTableView.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <comphelper/sequence.hxx>
+#include "dbu_qry.hrc"
+
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::accessibility;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star;
+
+ OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable)
+ :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : NULL)
+ ,m_pTable(_pTable)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OTableWindowAccess::disposing()
+ {
+ m_pTable = NULL;
+ VCLXAccessibleComponent::disposing();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableWindowAccess::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+ {
+ if ( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_pTable = NULL;
+ }
+
+ VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
+ }
+ // -----------------------------------------------------------------------------
+ Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) throw (RuntimeException)
+ {
+ Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
+ return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType );
+ }
+ // -----------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OTableWindowAccess::getTypes( ) throw (RuntimeException)
+ {
+ return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes());
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OTableWindowAccess::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+ // -----------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ // -----------------------------------------------------------------------------
+ // XServiceInfo - static methods
+ Sequence< ::rtl::OUString > OTableWindowAccess::getSupportedServiceNames_Static(void) throw( RuntimeException )
+ {
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.Accessible"));
+ aSupported[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext"));
+ return aSupported;
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString OTableWindowAccess::getImplementationName_Static(void) throw( RuntimeException )
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.TableWindowAccessibility"));
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleContext
+ sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nCount = 0;
+ if(m_pTable)
+ {
+ if(m_pTable->GetTitleCtrl())
+ ++nCount;
+ if(m_pTable->GetListBox())
+ ++nCount;
+ }
+ return nCount;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XAccessible > aRet;
+ if(m_pTable)
+ {
+ switch(i)
+ {
+ case 0:
+ if(m_pTable->GetTitleCtrl())
+ {
+ aRet = m_pTable->GetTitleCtrl()->GetAccessible();
+ break;
+ } // fall through if title control does not exist
+ case 1:
+ if(m_pTable->GetListBox())
+ aRet = m_pTable->GetListBox()->GetAccessible();
+ break;
+ default:
+ throw IndexOutOfBoundsException();
+ }
+ }
+ return aRet;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nIndex = -1;
+ if( m_pTable )
+ {
+ // search the postion of our table window in the table window map
+ OJoinTableView::OTableWindowMap* pMap = m_pTable->getTableView()->GetTabWinMap();
+ OJoinTableView::OTableWindowMap::iterator aIter = pMap->begin();
+ OJoinTableView::OTableWindowMap::iterator aEnd = pMap->end();
+ for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
+ ;
+ nIndex = aIter != aEnd ? nIndex : -1;
+ }
+ return nIndex;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole( ) throw (RuntimeException)
+ {
+ return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return this;
+ }
+ // -----------------------------------------------------------------------------
+ // XAccessibleComponent
+ Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XAccessible > aRet;
+ if( m_pTable )
+ {
+ Point aPoint(_aPoint.X,_aPoint.Y);
+ Rectangle aRect(m_pTable->GetDesktopRectPixel());
+ if( aRect.IsInside(aPoint) )
+ aRet = this;
+ else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint))
+ aRet = m_pTable->GetListBox()->GetAccessible();
+ }
+ return aRet;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex)
+ {
+ Reference< XAccessible > xReturn;
+ Reference< XAccessible > xParent = getAccessibleParent();
+ if ( xParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
+ if ( xParentContext.is() )
+ {
+ xReturn = xParentContext->getAccessibleChild(_nIndex);
+ }
+ }
+ return xReturn;
+ }
+ // -----------------------------------------------------------------------------
+
+ sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
+ }
+ // -----------------------------------------------------------------------------
+ AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if( nIndex < 0 || nIndex >= getRelationCount() )
+ throw IndexOutOfBoundsException();
+
+ AccessibleRelation aRet;
+ if( m_pTable )
+ {
+ OJoinTableView* pView = m_pTable->getTableView();
+ ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable) + nIndex;
+ aRet.TargetSet.realloc(1);
+ aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections()->begin());
+ aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
+ }
+ return aRet;
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return AccessibleRelationType::CONTROLLER_FOR == aRelationType
+ && m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
+ }
+ // -----------------------------------------------------------------------------
+ AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
+ {
+ OJoinTableView* pView = m_pTable->getTableView();
+ const ::std::vector<OTableConnection*>* pConnectionList = pView->getTableConnections();
+
+ ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable);
+ ::std::vector<OTableConnection*>::const_iterator aEnd = pConnectionList->end();
+ ::std::vector< Reference<XInterface> > aRelations;
+ aRelations.reserve(5); // just guessing
+ for (; aIter != aEnd ; ++aIter )
+ aRelations.push_back(getParentChild(aIter - pConnectionList->begin()));
+
+ Reference<XInterface> *pRelations = aRelations.empty() ? 0 : &aRelations[0];
+ Sequence< Reference<XInterface> > aSeq(pRelations, aRelations.size());
+ return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
+ }
+ return AccessibleRelation();
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableWindowAccess::isEditable() const
+ {
+ return m_pTable && !m_pTable->getTableView()->getDesignView()->getController().isReadOnly();
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OTableWindowAccess::getTitledBorderText( ) throw (RuntimeException)
+ {
+ return getAccessibleName( );
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OTableWindowAccess::getAccessibleName( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::rtl::OUString sAccessibleName;
+ if ( m_pTable )
+ sAccessibleName = m_pTable->getTitle();
+ return sAccessibleName;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return this;
+ }
+ // -----------------------------------------------------------------------------
+
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableWindowData.cxx b/dbaccess/source/ui/querydesign/TableWindowData.cxx
new file mode 100644
index 000000000000..56cad8c62fff
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowData.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableWindowData.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+using namespace dbaui;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+//==================================================================
+// class OTableWindowData
+//==================================================================
+DBG_NAME(OTableWindowData)
+//------------------------------------------------------------------------------
+OTableWindowData::OTableWindowData( const Reference< XPropertySet>& _xTable
+ ,const ::rtl::OUString& _rComposedName
+ ,const ::rtl::OUString& rTableName
+ ,const ::rtl::OUString& rWinName )
+ :m_xTable(_xTable)
+ ,m_aTableName( rTableName )
+ ,m_aWinName( rWinName )
+ ,m_sComposedName(_rComposedName)
+ ,m_aPosition( Point(-1,-1) )
+ ,m_aSize( Size(-1,-1) )
+ ,m_bShowAll( sal_True )
+ ,m_bIsQuery(false)
+ ,m_bIsValid(true)
+{
+ DBG_CTOR(OTableWindowData,NULL);
+ if( !m_aWinName.getLength() )
+ m_aWinName = m_aTableName;
+
+ listen();
+}
+
+//------------------------------------------------------------------------------
+OTableWindowData::~OTableWindowData()
+{
+ DBG_DTOR(OTableWindowData,NULL);
+ Reference<XComponent> xComponent( m_xTable, UNO_QUERY );
+ if ( xComponent.is() )
+ stopComponentListening( xComponent );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableWindowData::HasPosition() const
+{
+ return ( (m_aPosition.X() != -1) && (m_aPosition.Y() != -1) );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableWindowData::HasSize() const
+{
+ return ( (m_aSize.Width() != -1) && (m_aSize.Height() !=-1) );
+}
+// -----------------------------------------------------------------------------
+void OTableWindowData::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // it doesn't matter which one was disposed
+ m_xColumns.clear();
+ m_xKeys.clear();
+ m_xTable.clear();
+}
+// -----------------------------------------------------------------------------
+bool OTableWindowData::init(const Reference< XConnection >& _xConnection,bool _bAllowQueries)
+{
+ OSL_ENSURE(!m_xTable.is(),"We are already connected to a table!");
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XQueriesSupplier > xSupQueries( _xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xQueries( xSupQueries->getQueries(), UNO_QUERY_THROW );
+ bool bIsKnownQuery = _bAllowQueries && xQueries->hasByName( m_sComposedName );
+
+ Reference< XTablesSupplier > xSupTables( _xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables( xSupTables->getTables(), UNO_QUERY_THROW );
+ bool bIsKnownTable = xTables->hasByName( m_sComposedName );
+
+ if ( bIsKnownQuery )
+ m_xTable.set( xQueries->getByName( m_sComposedName ), UNO_QUERY );
+ else if ( bIsKnownTable )
+ m_xTable.set( xTables->getByName( m_sComposedName ), UNO_QUERY );
+ else
+ m_bIsValid = false;
+
+ // if we survived so far, we know whether it's a query
+ m_bIsQuery = bIsKnownQuery;
+
+ listen();
+
+ Reference< XIndexAccess > xColumnsAsIndex( m_xColumns,UNO_QUERY );
+ return xColumnsAsIndex.is() && ( xColumnsAsIndex->getCount() > 0 );
+}
+// -----------------------------------------------------------------------------
+void OTableWindowData::listen()
+{
+ if ( m_xTable.is() )
+ {
+ // listen for the object being disposed
+ Reference<XComponent> xComponent( m_xTable, UNO_QUERY );
+ if ( xComponent.is() )
+ startComponentListening( xComponent );
+
+ // obtain the columns
+ Reference< XColumnsSupplier > xColumnsSups( m_xTable, UNO_QUERY);
+ if ( xColumnsSups.is() )
+ m_xColumns = xColumnsSups->getColumns();
+
+ Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
+ if ( xKeySup.is() )
+ m_xKeys = xKeySup->getKeys();
+ }
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableWindowListBox.cxx b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
new file mode 100644
index 000000000000..9d0f29701421
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowListBox.cxx
@@ -0,0 +1,402 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableWindowListBox.hxx"
+#include "TableWindow.hxx"
+#include "QueryDesignView.hxx"
+#include "QueryTableView.hxx"
+#include "querycontroller.hxx"
+#include "JoinExchange.hxx"
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <svx/dbexch.hrc>
+#include <vcl/svapp.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::datatransfer;
+
+OJoinExchangeData::OJoinExchangeData(OTableWindowListBox* pBox)
+ : pListBox(pBox)
+ , pEntry(pBox->FirstSelected())
+{ }
+
+const sal_uLong SCROLLING_TIMESPAN = 500;
+const long LISTBOX_SCROLLING_AREA = 6;
+//==================================================================
+// class OTableWindowListBox
+//==================================================================
+DBG_NAME(OTableWindowListBox)
+//------------------------------------------------------------------------------
+OTableWindowListBox::OTableWindowListBox( OTableWindow* pParent )
+ :SvTreeListBox( pParent, WB_HASBUTTONS | WB_BORDER)
+ ,m_aMousePos( Point(0,0) )
+ ,m_pTabWin( pParent )
+ ,m_nDropEvent(0)
+ ,m_nUiEvent(0)
+ ,m_bReallyScrolled( sal_False )
+{
+ DBG_CTOR(OTableWindowListBox,NULL);
+ m_aScrollTimer.SetTimeout( SCROLLING_TIMESPAN );
+ SetDoubleClickHdl( LINK(this, OTableWindowListBox, OnDoubleClick) );
+
+ SetSelectionMode(SINGLE_SELECTION);
+
+ SetHighlightRange( );
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::dragFinished( )
+{
+ // first show the error msg when existing
+ m_pTabWin->getDesignView()->getController().showError(m_pTabWin->getDesignView()->getController().clearOccurredError());
+ // second look for ui activities which should happen after d&d
+ if (m_nUiEvent)
+ Application::RemoveUserEvent(m_nUiEvent);
+ m_nUiEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, LookForUiHdl));
+}
+
+//------------------------------------------------------------------------------
+OTableWindowListBox::~OTableWindowListBox()
+{
+ DBG_DTOR(OTableWindowListBox,NULL);
+ if (m_nDropEvent)
+ Application::RemoveUserEvent(m_nDropEvent);
+ if (m_nUiEvent)
+ Application::RemoveUserEvent(m_nUiEvent);
+ if( m_aScrollTimer.IsActive() )
+ m_aScrollTimer.Stop();
+ m_pTabWin = NULL;
+}
+
+//------------------------------------------------------------------------------
+SvLBoxEntry* OTableWindowListBox::GetEntryFromText( const String& rEntryText )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Liste durchiterieren
+ SvTreeList* pTreeList = GetModel();
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pTreeList->First();
+ OJoinDesignView* pView = m_pTabWin->getDesignView();
+ OJoinController& rController = pView->getController();
+
+ sal_Bool bCase = sal_False;
+ try
+ {
+ Reference<XConnection> xConnection = rController.getConnection();
+ if(xConnection.is())
+ {
+ Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
+ if(xMeta.is())
+ bCase = xMeta->supportsMixedCaseQuotedIdentifiers();
+ }
+ while( pEntry )
+ {
+ if((bCase ? rEntryText == GetEntryText(pEntry) : rEntryText.EqualsIgnoreCaseAscii(GetEntryText(pEntry))))
+ {
+ return pEntry;
+ }
+ pEntry = (SvLBoxEntry*)pTreeList->Next( pEntry );
+ }
+ }
+ catch(SQLException&)
+ {
+ }
+
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::NotifyScrolled()
+{
+ m_bReallyScrolled = sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::NotifyEndScroll()
+{
+ if (m_bReallyScrolled)
+ // die Verbindungen, die diese Tabelle eventuell hat, muessen neu gezeichnet werden
+ m_pTabWin->getTableView()->Invalidate(INVALIDATE_NOCHILDREN);
+ // ohne das INVALIDATE_NOCHILDREN wuerden auch alle Tabellen neu gezeichnet werden,
+ // sprich : es flackert
+ m_bReallyScrolled = sal_False;
+}
+
+//------------------------------------------------------------------------------
+long OTableWindowListBox::PreNotify(NotifyEvent& rNEvt)
+{
+ sal_Bool bHandled = sal_False;
+ switch (rNEvt.GetType())
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ const KeyCode& rCode = pKeyEvent->GetKeyCode();
+
+ if (rCode.GetCode() != KEY_RETURN)
+ {
+ if(m_pTabWin)
+ {
+ bHandled = m_pTabWin->HandleKeyInput(*pKeyEvent);
+ }
+ break;
+ }
+
+ if (rCode.IsMod1() || rCode.IsMod2() || rCode.IsShift())
+ break;
+ if (FirstSelected())
+ static_cast<OTableWindow*>(Window::GetParent())->OnEntryDoubleClicked(FirstSelected());
+ }
+ break;
+ }
+
+ if (!bHandled)
+ return SvTreeListBox::PreNotify(rNEvt);
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, ScrollUpHdl, SvTreeListBox*, /*pBox*/ )
+{
+ SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
+ if( !pEntry )
+ return 0;
+
+ if( pEntry != Last() )
+ {
+ ScrollOutputArea( -1 );
+ pEntry = GetEntry( m_aMousePos );
+ Select( pEntry, sal_True );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, ScrollDownHdl, SvTreeListBox*, /*pBox*/ )
+{
+ SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
+ if( !pEntry )
+ return 0;
+
+ if( pEntry != Last() )
+ {
+ ScrollOutputArea( 1 );
+ pEntry = GetEntry( m_aMousePos );
+ Select( pEntry, sal_True );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ )
+{
+ OJoinTableView* pCont = m_pTabWin->getTableView();
+ if (!pCont->getDesignView()->getController().isReadOnly() && pCont->getDesignView()->getController().isConnected())
+ {
+ // asterix was not allowed to be copied to selection browsebox
+ sal_Bool bFirstNotAllowed = FirstSelected() == First() && m_pTabWin->GetData()->IsShowAll();
+ EndSelection();
+ // create a description of the source
+ OJoinExchangeData jxdSource(this);
+ // put it into a exchange object
+ OJoinExchObj* pJoin = new OJoinExchObj(jxdSource,bFirstNotAllowed);
+ Reference< XTransferable > xEnsureDelete(pJoin);
+ pJoin->StartDrag(this, DND_ACTION_LINK, this);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 OTableWindowListBox::AcceptDrop( const AcceptDropEvent& _rEvt )
+{
+ sal_Int8 nDND_Action = DND_ACTION_NONE;
+ // check the format
+ if ( !OJoinExchObj::isFormatAvailable(GetDataFlavorExVector(),SOT_FORMATSTR_ID_SBA_TABID) // this means that the first entry is to be draged
+ && OJoinExchObj::isFormatAvailable(GetDataFlavorExVector(),SOT_FORMATSTR_ID_SBA_JOIN) )
+ { // don't drop into the window if it's the drag source itself
+
+ // remove the selection if the dragging operation is leaving the window
+ if (_rEvt.mbLeaving)
+ SelectAll(sal_False);
+ else
+ {
+ // hit test
+ m_aMousePos = _rEvt.maPosPixel;
+ Size aOutputSize = GetOutputSizePixel();
+ SvLBoxEntry* pEntry = GetEntry( m_aMousePos );
+ if( !pEntry )
+ return DND_ACTION_NONE;
+
+ // Scrolling Areas
+ Rectangle aBottomScrollArea( Point(0, aOutputSize.Height()-LISTBOX_SCROLLING_AREA),
+ Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
+ Rectangle aTopScrollArea( Point(0,0), Size(aOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
+
+ // Wenn Zeiger auf der oberen ScrollingArea steht, nach oben scrollen
+ if( aBottomScrollArea.IsInside(m_aMousePos) )
+ {
+ if( !m_aScrollTimer.IsActive() )
+ {
+ m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollUpHdl) );
+ ScrollUpHdl( this );
+ }
+ }
+
+ // Wenn Zeiger auf der oberen ScrollingArea steht, nach unten scrollen
+ else if( aTopScrollArea.IsInside(m_aMousePos) )
+ {
+ if( !m_aScrollTimer.IsActive() )
+ {
+ m_aScrollTimer.SetTimeoutHdl( LINK(this, OTableWindowListBox, ScrollDownHdl) );
+ ScrollDownHdl( this );
+ }
+ }
+ else
+ {
+ if( m_aScrollTimer.IsActive() )
+ m_aScrollTimer.Stop();
+ }
+
+ // Beim Drag automatisch den richtigen Eintrag selektieren
+ if ((FirstSelected() != pEntry) || (FirstSelected() && NextSelected(FirstSelected())))
+ SelectAll(sal_False);
+ Select(pEntry, sal_True);
+
+ // Auf den ersten Eintrag (*) kann nicht gedroppt werden
+ if(!( m_pTabWin->GetData()->IsShowAll() && (pEntry==First()) ))
+ nDND_Action = DND_ACTION_LINK;
+ }
+ }
+ return nDND_Action;
+}
+// -----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, LookForUiHdl, void *, /*EMPTY_ARG*/)
+{
+ m_nUiEvent = 0;
+ m_pTabWin->getTableView()->lookForUiActivities();
+ return 0L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, DropHdl, void *, /*EMPTY_ARG*/)
+{
+ // create the connection
+ m_nDropEvent = 0;
+ OSL_ENSURE(m_pTabWin,"No TableWindow!");
+ try
+ {
+ OJoinTableView* pCont = m_pTabWin->getTableView();
+ OSL_ENSURE(pCont,"No QueryTableView!");
+ pCont->AddConnection(m_aDropInfo.aSource, m_aDropInfo.aDest);
+ }
+ catch(const SQLException& e)
+ {
+ // remember the exception so that we can show them later when d&d is finished
+ m_pTabWin->getDesignView()->getController().setErrorOccurred(::dbtools::SQLExceptionInfo(e));
+ }
+ return 0L;
+}
+//------------------------------------------------------------------------------
+sal_Int8 OTableWindowListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
+{
+ TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
+ if ( OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector()))
+ { // don't drop into the window if it's the drag source itself
+ m_aDropInfo.aSource = OJoinExchangeData(this);
+ m_aDropInfo.aDest = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
+
+ if (m_nDropEvent)
+ Application::RemoveUserEvent(m_nDropEvent);
+ m_nDropEvent = Application::PostUserEvent(LINK(this, OTableWindowListBox, DropHdl));
+
+ return DND_ACTION_LINK;
+ }
+ return DND_ACTION_NONE;
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::LoseFocus()
+{
+ if(m_pTabWin)
+ m_pTabWin->setActive(sal_False);
+ SvTreeListBox::LoseFocus();
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowListBox::GetFocus()
+{
+ if(m_pTabWin)
+ m_pTabWin->setActive();
+
+ if (GetCurEntry() != NULL)
+ {
+ if ( GetSelectionCount() == 0 || GetCurEntry() != FirstSelected() )
+ {
+ if ( FirstSelected() )
+ Select(FirstSelected(), sal_False);
+ Select(GetCurEntry(), sal_True);
+ }
+ else
+ ShowFocusRect(FirstSelected());
+ }
+ SvTreeListBox::GetFocus();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableWindowListBox, OnDoubleClick, SvTreeListBox *, /*pBox*/ )
+{
+ // meinem Elter Bescheid sagen
+ Window* pParent = Window::GetParent();
+ OSL_ENSURE(pParent != NULL, "OTableWindowListBox::OnDoubleClick : habe kein Parent !");
+
+ static_cast<OTableWindow*>(pParent)->OnEntryDoubleClicked(GetHdlEntry());
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OTableWindowListBox::Command(const CommandEvent& rEvt)
+{
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ static_cast<OTableWindow*>(Window::GetParent())->Command(rEvt);
+ break;
+ }
+ default:
+ SvTreeListBox::Command(rEvt);
+ }
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableWindowTitle.cxx b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
new file mode 100644
index 000000000000..6c740fb6c52d
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/TableWindowTitle.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableWindowTitle.hxx"
+#include "TableWindow.hxx"
+#include "QueryTableView.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/help.hxx>
+#include <vcl/menu.hxx>
+#include <tools/debug.hxx>
+#include "dbustrings.hrc"
+#include <sfx2/cntids.hrc>
+#include "TableWindowListBox.hxx"
+#include "TableConnection.hxx"
+#include "dbu_qry.hrc"
+#include "QueryDesignView.hxx"
+#include "JoinController.hxx"
+
+#include <algorithm>
+
+using namespace dbaui;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+//==================================================================
+// class OTableWindowTitle
+//==================================================================
+DBG_NAME(OTableWindowTitle)
+//------------------------------------------------------------------------------
+OTableWindowTitle::OTableWindowTitle( OTableWindow* pParent ) :
+ FixedText( pParent, WB_3DLOOK|WB_LEFT|WB_NOLABEL|WB_VCENTER )
+ ,m_pTabWin( pParent )
+{
+ DBG_CTOR(OTableWindowTitle,NULL);
+ // Hintergrund- und Textfarbe setzen
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
+ SetTextColor(aSystemStyle.GetButtonTextColor());
+
+ Font aFont( GetFont() );
+ aFont.SetTransparent( sal_True );
+ SetFont( aFont );
+}
+
+//------------------------------------------------------------------------------
+OTableWindowTitle::~OTableWindowTitle()
+{
+ DBG_DTOR(OTableWindowTitle,NULL);
+ m_pTabWin = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::GetFocus()
+{
+ if(m_pTabWin)
+ m_pTabWin->GetFocus();
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::LoseFocus()
+{
+ m_pTabWin->LoseFocus();
+}
+//------------------------------------------------------------------------------
+void OTableWindowTitle::RequestHelp( const HelpEvent& rHEvt )
+{
+ if(m_pTabWin)
+ {
+ String aHelpText = m_pTabWin->GetComposedName();
+ if( aHelpText.Len())
+ {
+ // Hilfe anzeigen
+ Rectangle aItemRect(Point(0,0),GetSizePixel());
+ aItemRect = LogicToPixel( aItemRect );
+ Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
+ aItemRect.Left() = aPt.X();
+ aItemRect.Top() = aPt.Y();
+ aPt = OutputToScreenPixel( aItemRect.BottomRight() );
+ aItemRect.Right() = aPt.X();
+ aItemRect.Bottom() = aPt.Y();
+ if( rHEvt.GetMode() == HELPMODE_BALLOON )
+ Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText);
+ else
+ Help::ShowQuickHelp( this, aItemRect, aHelpText );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::Command( const CommandEvent& rEvt )
+{
+ switch( rEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ GrabFocus();
+ if ( m_pTabWin )
+ m_pTabWin->Command( rEvt );
+ else
+ Control::Command(rEvt);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::KeyInput( const KeyEvent& rEvt )
+{
+ if ( m_pTabWin )
+ m_pTabWin->KeyInput( rEvt );
+}
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::MouseButtonDown( const MouseEvent& rEvt )
+{
+ if( rEvt.IsLeft() )
+ {
+ if( rEvt.GetClicks() == 2)
+ {
+ Size aSize(GetTextWidth(GetText()) + 20,
+ m_pTabWin->GetSizePixel().Height() - m_pTabWin->GetListBox()->GetSizePixel().Height());
+
+ aSize.Height() += (m_pTabWin->GetListBox()->GetEntryCount() + 2) * m_pTabWin->GetListBox()->GetEntryHeight();
+ if(m_pTabWin->GetSizePixel() != aSize)
+ {
+ m_pTabWin->SetSizePixel(aSize);
+
+ OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
+ OSL_ENSURE(pView,"No OJoinTableView!");
+ const ::std::vector<OTableConnection*>* pConns = pView->getTableConnections();
+ ::std::for_each(pConns->begin(),
+ pConns->end(),
+ ::std::mem_fun(&OTableConnection::RecalcLines));
+
+ pView->InvalidateConnections();
+ pView->getDesignView()->getController().setModified(sal_True);
+ pView->Invalidate(INVALIDATE_NOCHILDREN);
+ }
+ }
+ else
+ {
+ Point aPos = rEvt.GetPosPixel();
+ aPos = OutputToScreenPixel( aPos );
+ OJoinTableView* pView = static_cast<OJoinTableView*>(m_pTabWin->getTableView());
+ OSL_ENSURE(pView,"No OJoinTableView!");
+ pView->NotifyTitleClicked( static_cast<OTableWindow*>(GetParent()), aPos );
+ }
+ GrabFocus();
+ }
+ else
+ Control::MouseButtonDown( rEvt );
+}
+
+
+//------------------------------------------------------------------------------
+void OTableWindowTitle::DataChanged(const DataChangedEvent& rDCEvt)
+{
+ if (rDCEvt.GetType() == DATACHANGED_SETTINGS)
+ {
+ // nehmen wir den worst-case an : die Farben haben sich geaendert, also
+ // mich anpassen
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ SetBackground(Wallpaper(Color(aSystemStyle.GetFaceColor())));
+ SetTextColor(aSystemStyle.GetButtonTextColor());
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableWindowTitle::StateChanged( StateChangedType nType )
+{
+ Window::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_ZOOM )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ Font aFont = rStyleSettings.GetGroupFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetZoomedPointFont( aFont );
+
+ Resize();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/class.jpg b/dbaccess/source/ui/querydesign/class.jpg
new file mode 100644
index 000000000000..b1a3b6d272ad
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/class.jpg
Binary files differ
diff --git a/dbaccess/source/ui/querydesign/makefile.mk b/dbaccess/source/ui/querydesign/makefile.mk
new file mode 100644
index 000000000000..a4a39c36a79c
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=querydesign
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES =\
+ $(SLO)$/ConnectionLine.obj \
+ $(SLO)$/ConnectionLineAccess.obj \
+ $(SLO)$/JAccess.obj \
+ $(SLO)$/JoinController.obj \
+ $(SLO)$/JoinDesignView.obj \
+ $(SLO)$/JoinExchange.obj \
+ $(SLO)$/JoinTableView.obj \
+ $(SLO)$/QTableConnection.obj \
+ $(SLO)$/QTableConnectionData.obj \
+ $(SLO)$/QTableWindow.obj \
+ $(SLO)$/QTableWindowData.obj \
+ $(SLO)$/QueryDesignView.obj \
+ $(SLO)$/QueryMoveTabWinUndoAct.obj \
+ $(SLO)$/QueryTabConnUndoAction.obj \
+ $(SLO)$/QueryTabWinUndoAct.obj \
+ $(SLO)$/QueryTableView.obj \
+ $(SLO)$/QueryTextView.obj \
+ $(SLO)$/QueryViewSwitch.obj \
+ $(SLO)$/SelectionBrowseBox.obj \
+ $(SLO)$/TableConnection.obj \
+ $(SLO)$/TableConnectionData.obj \
+ $(SLO)$/TableFieldDescription.obj \
+ $(SLO)$/TableWindow.obj \
+ $(SLO)$/TableWindowAccess.obj \
+ $(SLO)$/TableWindowData.obj \
+ $(SLO)$/TableWindowListBox.obj \
+ $(SLO)$/TableWindowTitle.obj \
+ $(SLO)$/querycontainerwindow.obj \
+ $(SLO)$/querycontroller.obj \
+ $(SLO)$/querydlg.obj \
+ $(SLO)$/queryview.obj
+
+SLOFILES =\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/ConnectionLineData.obj \
+ $(SLO)$/TableFieldInfo.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = query.src \
+ querydlg.src \
+
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
+
diff --git a/dbaccess/source/ui/querydesign/query.src b/dbaccess/source/ui/querydesign/query.src
new file mode 100644
index 000000000000..aae5a07545ae
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/query.src
@@ -0,0 +1,426 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERY_HRC
+#include "Query.hrc"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef _CNTIDS_HRC
+#include <sfx2/cntids.hrc>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+
+#define MN_EDIT 20
+#define MN_VIEW 21
+#define MN_EXTRA 22
+#define MN_INSERT 23
+#define MN_WIN 30
+#define MN_HELP 31
+
+Menu RID_MENU_JOINVIEW_CONNECTION
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_DELETE
+ };
+ MenuItem
+ {
+ MID_DBUI_QUERY_EDIT_JOINCONNECTION
+ };
+ };
+};
+
+Menu RID_MENU_JOINVIEW_TABLE
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_DELETE
+ };
+ };
+};
+
+Menu RID_QUERYCOLPOPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ MID_COLUMN_WIDTH
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ ITEM_EDIT_DELETE
+ };
+ };
+};
+
+ImageList IMG_JOINS
+{
+ Prefix = "jo";
+ MaskColor = Color { Red = 0xffff; Green = 0x0000; Blue = 0xffff; };
+ IdList = {
+ IMG_PRIMARY_KEY; IMG_FOREIGN_KEY;
+ };
+ IdCount = { 2; };
+};
+
+String STR_QUERY_UNDO_TABWINSHOW
+{
+ Text [ en-US ] = "Add Table Window" ;
+};
+
+String STR_QUERY_UNDO_MOVETABWIN
+{
+ Text [ en-US ] = "Move table window" ;
+};
+String STR_QUERY_UNDO_INSERTCONNECTION
+{
+ Text [ en-US ] = "Insert Join" ;
+};
+
+String STR_QUERY_UNDO_REMOVECONNECTION
+{
+ Text [ en-US ] = "Delete Join" ;
+};
+
+String STR_QUERY_UNDO_SIZETABWIN
+{
+ Text [ en-US ] = "Resize table window" ;
+};
+String STR_QUERY_UNDO_TABFIELDDELETE
+{
+ Text [ en-US ] = "Delete Column" ;
+};
+
+String STR_QUERY_UNDO_TABFIELDMOVED
+{
+ Text [ en-US ] = "Move column";
+};
+
+String STR_QUERY_UNDO_TABFIELDCREATE
+{
+ Text [ en-US ] = "Add Column" ;
+};
+
+String RID_STR_TABLE_DOESNT_EXIST
+{
+ Text [ en-US ] = "Invalid expression, table '$name$' does not exist.";
+};
+
+String RID_STR_FIELD_DOESNT_EXIST
+{
+ Text [ en-US ] = "Invalid expression, field name '$name$' does not exist.";
+};
+
+String RID_STR_TOMUCHTABLES
+{
+ Text [ en-US ] = "The query covers #num# tables. The selected database type, however, can only process a maximum of #maxnum# table(s) per statement.";
+};
+
+String STR_QUERY_UNDO_TABWINDELETE
+{
+ Text [ en-US ] = "Delete Table Window" ;
+};
+
+String STR_QUERY_UNDO_MODIFY_CELL
+{
+ Text [ en-US ] = "Edit Column Description";
+};
+
+String STR_QUERY_UNDO_SIZE_COLUMN
+{
+ Text [ en-US ] = "Adjust column width";
+};
+
+String STR_QUERY_SORTTEXT
+{
+ Text [ en-US ] = "(not sorted);ascending;descending" ;
+};
+
+String STR_QUERY_FUNCTIONS
+{
+ Text [ en-US ] = "(no function);Group";
+};
+
+String STR_QUERY_NOTABLE
+{
+ Text [ en-US ] = "(no table)";
+};
+
+String STR_QRY_ORDERBY_UNRELATED
+{
+ Text [ en-US ] = "The database only supports sorting for visible fields.";
+};
+
+Menu RID_QUERYFUNCTION_POPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_QUERY_FUNCTION ;
+ HelpID = HID_QUERY_FUNCTION;
+ Text [ en-US ] = "Functions";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_QUERY_TABLENAME ;
+ HelpID = HID_QUERY_TABLENAME ;
+ Text [ en-US ] = "Table Name";
+ };
+ MenuItem
+ {
+ Identifier = ID_QUERY_ALIASNAME ;
+ HelpID = HID_QUERY_ALIASNAME ;
+ Text [ en-US ] = "Alias";
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = ID_QUERY_DISTINCT ;
+ HelpID = HID_QUERY_DISTINCT ;
+ Text [ en-US ] = "Distinct Values";
+ };
+ };
+};
+
+String STR_QUERY_HANDLETEXT
+{
+ Text [ en-US ] = "Field;Alias;Table;Sort;Visible;Function;Criterion;Or;Or";
+};
+
+String STR_QRY_TOO_MANY_COLUMNS
+{
+ Text [ en-US ] = "There are too many columns.";
+};
+
+ErrorBox ERR_QRY_CRITERIA_ON_ASTERISK
+{
+ Message [ en-US ] = "A condition cannot be applied to field [*]" ;
+};
+
+String STR_QRY_TOO_LONG_STATEMENT
+{
+ Text [ en-US ] = "The SQL statement created is too long.";
+};
+
+String STR_QRY_TOOCOMPLEX
+{
+ Text [ en-US ] = "Query is too complex" ;
+};
+
+String STR_QRY_NOSELECT
+{
+ Text [ en-US ] = "Nothing has been selected." ;
+};
+
+String STR_QRY_TOOMANYCOND
+{
+ Text [ en-US ] = "Too many search criteria" ;
+};
+
+String STR_QRY_SYNTAX
+{
+ Text [ en-US ] = "SQL syntax error" ;
+};
+
+ErrorBox ERR_QRY_ORDERBY_ON_ASTERISK
+{
+ Message [ en-US ] = "[*] cannot be used as a sort criterion.";
+};
+
+String STR_QUERY_TRUE
+{
+ Text [ en-US ] = "TRUE" ;
+};
+
+String STR_QUERY_FALSE
+{
+ Text [ en-US ] = "FALSE" ;
+};
+
+String STR_QRY_TOO_MANY_TABLES
+{
+ Text [ en-US ] = "There are too many tables.";
+};
+
+String STR_QRY_NATIVE
+{
+ Text [ en-US ] = "The statement will not be applied when querying in the SQL dialect of the database." ;
+};
+
+ErrorBox ERR_QRY_AMB_FIELD
+{
+ Message [ en-US ] = "Field name not found or not unique" ;
+};
+
+String STR_QRY_ILLEGAL_JOIN
+{
+ Text [ en-US ] = "Join could not be processed" ;
+};
+
+String STR_SVT_SQL_SYNTAX_ERROR
+{
+ Text [ en-US ] = "Syntax error in SQL statement" ;
+};
+
+String STR_QUERYDESIGN_NO_VIEW_SUPPORT
+{
+ Text [ en-US ] = "This database does not support table views.";
+};
+
+String STR_NO_ALTER_VIEW_SUPPORT
+{
+ Text [ en-US ] = "This database does not support altering of existing table views.";
+};
+
+String STR_QUERYDESIGN_NO_VIEW_ASK
+{
+ Text [ en-US ] = "Do you want to create a query instead?";
+};
+
+ErrorBox ERR_QRY_NOSTATEMENT
+{
+ Message [ en-US ] = "No query could be created.";
+};
+
+ErrorBox ERR_QRY_NOCRITERIA
+{
+ Message [ en-US ] = "No query could be created because no fields were selected.";
+};
+
+/*
+ The menubar resource has become obsolete - you can now find the menubar definition at: <project>/uiconfig/dbquery/menubar/menubar.xml
+ */
+
+String STR_DATASOURCE_DELETED
+{
+ Text [ en-US ] = "The corresponding data source has been deleted. Therefore, data relevant to that data source cannot be saved.";
+};
+
+String STR_QRY_COLUMN_NOT_FOUND
+{
+ Text [ en-US ] = "The column '$name$' is unknown.";
+};
+
+String STR_QRY_JOIN_COLUMN_COMPARE
+{
+ Text [ en-US ] = "Columns can only be compared using '='.";
+};
+
+String STR_QRY_LIKE_LEFT_NO_COLUMN
+{
+ Text [ en-US ] = "You must use a column name before 'LIKE'.";
+};
+
+String STR_QRY_CHECK_CASESENSITIVE
+{
+ Text [ en-US ] = "The column could not be found. Please note that the database is case-sensitive.";
+};
+
+String STR_QUERYDESIGN
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base: Query Design";
+};
+
+String STR_VIEWDESIGN
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base: View Design";
+};
+
+String STR_QUERY_SAVEMODIFIED
+{
+ Text [ en-US ] = "$object$ has been changed.\nDo you want to save the changes?" ;
+ Text [ x-comment ] = "For $object$, one of the values of the RSC_QUERY_OBJECT_TYPE resource will be inserted.";
+};
+
+String STR_ERROR_PARSING_STATEMENT
+{
+ Text [ en-US ] = "$object$ is based on an SQL command which could not be parsed.";
+ Text [ x-comment ] = "For $object$, one of the values of the RSC_QUERY_OBJECT_TYPE resource "
+ "(except \"SQL command\", which doesn't make sense here) will be inserted.";
+};
+
+String STR_INFO_OPENING_IN_SQL_VIEW
+{
+ Text [ en-US ] = "$object$ will be opened in SQL view.";
+ Text [ x-comment ] = "For $object$, one of the values of the RSC_QUERY_OBJECT_TYPE resource "
+ "(except \"SQL command\", which doesn't make sense here) will be inserted.";
+};
+
+Resource RSC_QUERY_OBJECT_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "The table view";
+ };
+ String 2
+ {
+ Text [ en-US ] = "The query";
+ };
+ String 3
+ {
+ Text [ en-US ] = "The SQL statement";
+ };
+};
+
+String STR_STATEMENT_WITHOUT_RESULT_SET
+{
+ Text [ en-US ] = "The query does not create a result set, and thus cannot be part of another query.";
+};
+
+String STR_NO_DATASOURCE_OR_CONNECTION
+{
+ Text [ en-US ] = "Both the ActiveConnection and the DataSourceName parameter are missing or wrong - cannot initialize the query designer.";
+};
diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
new file mode 100644
index 000000000000..15fbc7611c75
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "querycontainerwindow.hxx"
+#include "QueryDesignView.hxx"
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include "JoinController.hxx"
+#include <toolkit/unohlp.hxx>
+#include "dbustrings.hrc"
+#include <sfx2/sfxsids.hrc>
+#include <vcl/fixed.hxx>
+#include "UITools.hxx"
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+
+ //=====================================================================
+ //= OQueryContainerWindow
+ //=====================================================================
+ DBG_NAME(OQueryContainerWindow)
+ OQueryContainerWindow::OQueryContainerWindow(Window* pParent, OQueryController& _rController,const Reference< XMultiServiceFactory >& _rFactory)
+ :ODataView( pParent, _rController, _rFactory )
+ ,m_pViewSwitch(NULL)
+ ,m_pBeamer(NULL)
+ {
+ DBG_CTOR(OQueryContainerWindow,NULL);
+ m_pViewSwitch = new OQueryViewSwitch( this, _rController, _rFactory );
+
+ m_pSplitter = new Splitter(this,WB_VSCROLL);
+ m_pSplitter->Hide();
+ m_pSplitter->SetSplitHdl( LINK( this, OQueryContainerWindow, SplitHdl ) );
+ m_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
+ }
+ // -----------------------------------------------------------------------------
+ OQueryContainerWindow::~OQueryContainerWindow()
+ {
+ DBG_DTOR(OQueryContainerWindow,NULL);
+ {
+ ::std::auto_ptr<OQueryViewSwitch> aTemp(m_pViewSwitch);
+ m_pViewSwitch = NULL;
+ }
+ if ( m_pBeamer )
+ ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_pBeamer = NULL;
+ if ( m_xBeamer.is() )
+ {
+ Reference< ::com::sun::star::util::XCloseable > xCloseable(m_xBeamer,UNO_QUERY);
+ m_xBeamer = NULL;
+ if(xCloseable.is())
+ xCloseable->close(sal_False); // false - holds the owner ship of this frame
+ }
+
+ ::std::auto_ptr<Window> aTemp(m_pSplitter);
+ m_pSplitter = NULL;
+
+ }
+ // -----------------------------------------------------------------------------
+ bool OQueryContainerWindow::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+ {
+ return m_pViewSwitch->switchView( _pErrorInfo );
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::forceInitialView()
+ {
+ return m_pViewSwitch->forceInitialView();
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::resizeAll( const Rectangle& _rPlayground )
+ {
+ Rectangle aPlayground( _rPlayground );
+
+ if ( m_pBeamer && m_pBeamer->IsVisible() )
+ {
+ // calc pos and size of the splitter
+ Point aSplitPos = m_pSplitter->GetPosPixel();
+ Size aSplitSize = m_pSplitter->GetOutputSizePixel();
+ aSplitSize.Width() = aPlayground.GetWidth();
+
+ if ( aSplitPos.Y() <= aPlayground.Top() )
+ aSplitPos.Y() = aPlayground.Top() + sal_Int32( aPlayground.GetHeight() * 0.2 );
+
+ if ( aSplitPos.Y() + aSplitSize.Height() > aPlayground.GetHeight() )
+ aSplitPos.Y() = aPlayground.GetHeight() - aSplitSize.Height();
+
+ // set pos and size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, aSplitSize );
+ m_pSplitter->SetDragRectPixel( aPlayground );
+
+ // set pos and size of the beamer
+ Size aBeamerSize( aPlayground.GetWidth(), aSplitPos.Y() );
+ m_pBeamer->SetPosSizePixel( aPlayground.TopLeft(), aBeamerSize );
+
+ // shrink the playground by the size which is occupied by the beamer
+ aPlayground.Top() = aSplitPos.Y() + aSplitSize.Height();
+ }
+
+ ODataView::resizeAll( aPlayground );
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::resizeDocumentView( Rectangle& _rPlayground )
+ {
+ m_pViewSwitch->SetPosSizePixel( _rPlayground.TopLeft(), Size( _rPlayground.GetWidth(), _rPlayground.GetHeight() ) );
+
+ ODataView::resizeDocumentView( _rPlayground );
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::GetFocus()
+ {
+ ODataView::GetFocus();
+ if(m_pViewSwitch)
+ m_pViewSwitch->GrabFocus();
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( OQueryContainerWindow, SplitHdl, void*, /*p*/ )
+ {
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
+ Resize();
+
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::Construct()
+ {
+ m_pViewSwitch->Construct();
+ }
+
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::disposingPreview()
+ {
+ if ( m_pBeamer )
+ {
+ // here I know that we will be destroyed from the frame
+ ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_pBeamer = NULL;
+ m_xBeamer = NULL;
+ m_pSplitter->Hide();
+ Resize();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ long OQueryContainerWindow::PreNotify( NotifyEvent& rNEvt )
+ {
+ sal_Bool bHandled = sal_False;
+ switch (rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if ( m_pViewSwitch )
+ {
+ OJoinController& rController = m_pViewSwitch->getDesignView()->getController();
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+ rController.InvalidateFeature(SID_PASTE);
+ }
+ }
+ return bHandled ? 1L : ODataView::PreNotify(rNEvt);
+ }
+ // -----------------------------------------------------------------------------
+ void OQueryContainerWindow::showPreview(const Reference<XFrame>& _xFrame)
+ {
+ if(!m_pBeamer)
+ {
+ m_pBeamer = new OBeamer(this);
+
+ ::dbaui::notifySystemWindow(this,m_pBeamer,::comphelper::mem_fun(&TaskPaneList::AddWindow));
+
+ Reference < XFrame > xBeamerFrame( m_pViewSwitch->getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame"))),UNO_QUERY );
+ m_xBeamer.set( xBeamerFrame );
+ OSL_ENSURE(m_xBeamer.is(),"No frame created!");
+ m_xBeamer->initialize( VCLUnoHelper::GetInterface ( m_pBeamer ) );
+
+ // notify layout manager to not create internal toolbars
+ Reference < XPropertySet > xPropSet( xBeamerFrame, UNO_QUERY );
+ try
+ {
+ const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ));
+ Reference < XPropertySet > xLMPropSet(xPropSet->getPropertyValue( aLayoutManager ),UNO_QUERY);
+
+ if ( xLMPropSet.is() )
+ {
+ const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" ));
+ xLMPropSet->setPropertyValue( aAutomaticToolbars, Any( sal_False ));
+ }
+ }
+ catch( Exception& )
+ {
+ }
+
+ m_xBeamer->setName(FRAME_NAME_QUERY_PREVIEW);
+
+ // append our frame
+ Reference < XFramesSupplier > xSup(_xFrame,UNO_QUERY);
+ Reference < XFrames > xFrames = xSup->getFrames();
+ xFrames->append( m_xBeamer );
+
+ Size aSize = GetOutputSizePixel();
+ Size aBeamer(aSize.Width(),sal_Int32(aSize.Height()*0.33));
+
+ const long nFrameHeight = LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height();
+ Point aPos(0,aBeamer.Height()+nFrameHeight);
+
+ m_pBeamer->SetPosSizePixel(Point(0,0),aBeamer);
+ m_pBeamer->Show();
+
+ m_pSplitter->SetPosSizePixel( Point(0,aBeamer.Height()), Size(aSize.Width(),nFrameHeight) );
+ // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide
+ m_pSplitter->SetSplitPosPixel( aBeamer.Height() );
+ m_pViewSwitch->SetPosSizePixel(aPos,Size(aBeamer.Width(),aSize.Height() - aBeamer.Height()-nFrameHeight));
+
+ m_pSplitter->Show();
+
+ Resize();
+ }
+ }
+ // -----------------------------------------------------------------------------
+
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
new file mode 100644
index 000000000000..054c854e846a
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -0,0 +1,1868 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "adtabdlg.hxx"
+#include "browserids.hxx"
+#include "dbu_qry.hrc"
+#include "dbu_reghelper.hxx"
+#include "dbustrings.hrc"
+#include "defaultobjectnamecheck.hxx"
+#include "dlgsave.hxx"
+#include "localresaccess.hxx"
+#include "QTableWindow.hxx"
+#include "QTableWindowData.hxx"
+#include "querycontainerwindow.hxx"
+#include "querycontroller.hxx"
+#include "QueryDesignView.hxx"
+#include "QueryTableView.hxx"
+#include "QueryTextView.hxx"
+#include "queryview.hxx"
+#include "QueryViewSwitch.hxx"
+#include "sqlmessage.hxx"
+#include "TableConnectionData.hxx"
+#include "TableFieldDescription.hxx"
+#include "UITools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XLoadEventListener.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/VetoException.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/basicio.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/streamsection.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <svtools/localresaccess.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+extern "C" void SAL_CALL createRegistryInfo_OQueryControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OQueryController > aAutoRegistration;
+}
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+
+ class OViewController : public OQueryController
+ {
+ //------------------------------------------------------------------------------
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( RuntimeException )
+ {
+ return getImplementationName_Static();
+ }
+ //-------------------------------------------------------------------------
+ virtual Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ public:
+ OViewController(const Reference< XMultiServiceFactory >& _rM) : OQueryController(_rM){}
+
+ // need by registration
+ static ::rtl::OUString getImplementationName_Static() throw( RuntimeException )
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OViewDesign"));
+ }
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException )
+ {
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ViewDesign"));
+ return aSupported;
+ }
+ static Reference< XInterface > SAL_CALL Create(const Reference< XMultiServiceFactory >& _rM)
+ {
+ return *(new OViewController(_rM));
+ }
+ };
+}
+extern "C" void SAL_CALL createRegistryInfo_OViewControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OViewController > aAutoRegistration;
+}
+
+namespace dbaui
+{
+ using namespace ::connectivity;
+#if OSL_DEBUG_LEVEL > 1
+ namespace
+ {
+ // -----------------------------------------------------------------------------
+ void insertParseTree(SvTreeListBox* _pBox,::connectivity::OSQLParseNode* _pNode,SvLBoxEntry* _pParent = NULL)
+ {
+ ::rtl::OUString rString;
+ if (!_pNode->isToken())
+ {
+ // Regelnamen als rule: ...
+ rString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RULE_ID: "));
+ rString += ::rtl::OUString::valueOf( (sal_Int32)_pNode->getRuleID());
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("));
+ rString += OSQLParser::RuleIDToStr(_pNode->getRuleID());
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+
+
+ _pParent = _pBox->InsertEntry(rString,_pParent);
+
+ // einmal auswerten wieviel Subtrees dieser Knoten besitzt
+ sal_uInt32 nStop = _pNode->count();
+ // hol dir den ersten Subtree
+ for(sal_uInt32 i=0;i<nStop;++i)
+ insertParseTree(_pBox,_pNode->getChild(i),_pParent);
+ }
+ else
+ {
+ // ein Token gefunden
+ // tabs fuer das Einruecken entsprechend nLevel
+
+ switch (_pNode->getNodeType())
+ {
+
+ case SQL_NODE_KEYWORD:
+ {
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_KEYWORD:"));
+ ::rtl::OString sT = OSQLParser::TokenIDToStr(_pNode->getTokenID());
+ rString += ::rtl::OUString(sT,sT.getLength(),RTL_TEXTENCODING_UTF8);
+ break;}
+
+ case SQL_NODE_COMPARISON:
+ {
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_COMPARISON:"));
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+ // und beginne neu Zeile
+ break;}
+
+ case SQL_NODE_NAME:
+ {
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_NAME:"));
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
+ rString += _pNode->getTokenValue();
+ rString+= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\""));
+ break;}
+
+ case SQL_NODE_STRING:
+ {
+ rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_STRING:'"));
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_INTNUM:
+ {
+ rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_INTNUM:"));
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_APPROXNUM:
+ {
+ rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_APPROXNUM:"));
+ rString += _pNode->getTokenValue();
+ break;}
+
+ case SQL_NODE_PUNCTUATION:
+ {
+ rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_PUNCTUATION:"));
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+ break;}
+
+ case SQL_NODE_AMMSC:
+ {
+ rString += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQL_AMMSC:"));
+ rString += _pNode->getTokenValue(); // haenge Nodevalue an
+ break;}
+
+ default:
+ OSL_FAIL("OSQLParser::ShowParseTree: unzulaessiger NodeType");
+ rString += _pNode->getTokenValue();
+ }
+ _pBox->InsertEntry(rString,_pParent);
+ }
+ }
+ }
+#endif // OSL_DEBUG_LEVEL
+
+ namespace
+ {
+ // -----------------------------------------------------------------------------
+ String lcl_getObjectResourceString( sal_uInt16 _nResId, sal_Int32 _nCommandType )
+ {
+ String sMessageText = String( ModuleRes( _nResId ) );
+ String sObjectType;
+ {
+ LocalResourceAccess aLocalRes( RSC_QUERY_OBJECT_TYPE, RSC_RESOURCE );
+ sObjectType = String( ModuleRes( (sal_uInt16)( _nCommandType + 1 ) ) );
+ }
+ sMessageText.SearchAndReplace( String::CreateFromAscii( "$object$" ), sObjectType );
+ return sMessageText;
+ }
+ }
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::awt;
+using namespace ::dbtools;
+
+using namespace ::comphelper;
+
+namespace
+{
+ void ensureToolbars( OQueryController& _rController, sal_Bool _bDesign )
+ {
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = _rController.getLayoutManager( _rController.getFrame() );
+ if ( xLayoutManager.is() )
+ {
+ xLayoutManager->lock();
+ static ::rtl::OUString s_sDesignToolbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/designobjectbar"));
+ static ::rtl::OUString s_sSqlToolbar(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sqlobjectbar"));
+ if ( _bDesign )
+ {
+ xLayoutManager->destroyElement( s_sSqlToolbar );
+ xLayoutManager->createElement( s_sDesignToolbar );
+ }
+ else
+ {
+ xLayoutManager->destroyElement( s_sDesignToolbar );
+ xLayoutManager->createElement( s_sSqlToolbar );
+ }
+ xLayoutManager->unlock();
+ xLayoutManager->doLayout();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OQueryController::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OQueryController::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OQueryDesign"));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OQueryController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.QueryDesign"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL OQueryController::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OQueryController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OQueryController(_rxFactory));
+}
+DBG_NAME(OQueryController);
+// -----------------------------------------------------------------------------
+OQueryController::OQueryController(const Reference< XMultiServiceFactory >& _rM)
+ :OJoinController(_rM)
+ ,OQueryController_PBase( getBroadcastHelper() )
+ ,m_pParseContext( new svxform::OSystemParseContext )
+ ,m_aSqlParser( _rM, m_pParseContext )
+ ,m_pSqlIterator(NULL)
+ ,m_nVisibleRows(0x400)
+ ,m_nSplitPos(-1)
+ ,m_nCommandType( CommandType::QUERY )
+ ,m_bGraphicalDesign(sal_False)
+ ,m_bDistinct(sal_False)
+ ,m_bViewAlias(sal_False)
+ ,m_bViewTable(sal_False)
+ ,m_bViewFunction(sal_False)
+ ,m_bEscapeProcessing(sal_True)
+{
+ DBG_CTOR(OQueryController,NULL);
+ InvalidateAll();
+
+ registerProperty( PROPERTY_ACTIVECOMMAND, PROPERTY_ID_ACTIVECOMMAND, PropertyAttribute::READONLY | PropertyAttribute::BOUND,
+ &m_sStatement, ::getCppuType( &m_sStatement ) );
+ registerProperty( PROPERTY_ESCAPE_PROCESSING, PROPERTY_ID_ESCAPE_PROCESSING, PropertyAttribute::READONLY | PropertyAttribute::BOUND,
+ &m_bEscapeProcessing, ::getCppuType( &m_bEscapeProcessing ) );
+}
+
+// -----------------------------------------------------------------------------
+OQueryController::~OQueryController()
+{
+ DBG_DTOR(OQueryController,NULL);
+ if ( !getBroadcastHelper().bDisposed && !getBroadcastHelper().bInDispose )
+ {
+ OSL_FAIL("Please check who doesn't dispose this component!");
+ // increment ref count to prevent double call of Dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( OQueryController, OJoinController, OQueryController_PBase )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OQueryController, OJoinController, OQueryController_PBase )
+
+//-------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL OQueryController::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+sal_Bool SAL_CALL OQueryController::convertFastPropertyValue( Any& o_rConvertedValue, Any& o_rOldValue, sal_Int32 i_nHandle, const Any& i_rValue ) throw (IllegalArgumentException)
+{
+ return OPropertyContainer::convertFastPropertyValue( o_rConvertedValue, o_rOldValue, i_nHandle, i_rValue );
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL OQueryController::setFastPropertyValue_NoBroadcast( sal_Int32 i_nHandle, const Any& i_rValue ) throw ( Exception )
+{
+ OPropertyContainer::setFastPropertyValue_NoBroadcast( i_nHandle, i_rValue );
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i_nHandle ) const
+{
+ switch ( i_nHandle )
+ {
+ case PROPERTY_ID_CURRENT_QUERY_DESIGN:
+ {
+ ::comphelper::NamedValueCollection aCurrentDesign;
+ aCurrentDesign.put( "GraphicalDesign", isGraphicalDesign() );
+ aCurrentDesign.put( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing );
+
+ if ( isGraphicalDesign() )
+ {
+ getContainer()->SaveUIConfig();
+ saveViewSettings( aCurrentDesign, true );
+ aCurrentDesign.put( "Statement", m_sStatement );
+ }
+ else
+ {
+ aCurrentDesign.put( "Statement", getContainer()->getStatement() );
+ }
+
+ o_rValue <<= aCurrentDesign.getPropertyValues();
+ }
+ break;
+
+ default:
+ OPropertyContainer::getFastPropertyValue( o_rValue, i_nHandle );
+ break;
+ }
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OQueryController::getInfoHelper()
+{
+ return *const_cast< OQueryController* >( this )->getArrayHelper();
+}
+
+//--------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OQueryController::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+
+ // one additional property:
+ const sal_Int32 nLength = aProps.getLength();
+ aProps.realloc( nLength + 1 );
+ aProps[ nLength ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrentQueryDesign" ) ),
+ PROPERTY_ID_CURRENT_QUERY_DESIGN,
+ ::cppu::UnoType< Sequence< PropertyValue > >::get(),
+ PropertyAttribute::READONLY
+ );
+
+ ::std::sort(
+ aProps.getArray(),
+ aProps.getArray() + aProps.getLength(),
+ ::comphelper::PropertyCompareByName()
+ );
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::deleteIterator()
+{
+ if(m_pSqlIterator)
+ {
+ delete m_pSqlIterator->getParseTree();
+ m_pSqlIterator->dispose();
+ delete m_pSqlIterator;
+ m_pSqlIterator = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void OQueryController::disposing()
+{
+ OQueryController_PBase::disposing();
+
+ deleteIterator();
+
+ delete m_pParseContext;
+
+ clearFields();
+ OTableFields().swap(m_vUnUsedFieldsDesc);
+
+ ::comphelper::disposeComponent(m_xComposer);
+ OJoinController::disposing();
+ OQueryController_PBase::disposing();
+}
+// -----------------------------------------------------------------------------
+void OQueryController::clearFields()
+{
+ OTableFields().swap(m_vTableFieldDesc);
+}
+// -----------------------------------------------------------------------------
+FeatureState OQueryController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ aReturn.bEnabled = sal_True;
+ // (disabled automatically)
+
+ switch (_nId)
+ {
+ case ID_BROWSER_EDITDOC:
+ if ( editingCommand() )
+ aReturn.bEnabled = sal_False;
+ else if ( editingView() && !m_xAlterView.is() )
+ aReturn.bEnabled = sal_False;
+ else
+ aReturn = OJoinController::GetState( _nId );
+ break;
+
+ case ID_BROWSER_ESACPEPROCESSING:
+ aReturn.bChecked = !m_bEscapeProcessing;
+ aReturn.bEnabled = ( m_pSqlIterator != NULL ) && !m_bGraphicalDesign;
+ break;
+ case SID_RELATION_ADD_RELATION:
+ aReturn.bEnabled = isEditable() && m_bGraphicalDesign && m_vTableData.size() > 1;
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ aReturn.bEnabled = !editingCommand() && !editingView() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty()));
+ break;
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = impl_isModified() && (!m_bGraphicalDesign || !(m_vTableFieldDesc.empty() || m_vTableData.empty()));
+ break;
+ case SID_PRINTDOCDIRECT:
+ break;
+ case ID_BROWSER_CUT:
+ aReturn.bEnabled = isEditable() && getContainer() && getContainer()->isCutAllowed();
+ break;
+ case ID_BROWSER_COPY:
+ aReturn.bEnabled = getContainer() && getContainer()->isCopyAllowed();
+ break;
+ case ID_BROWSER_PASTE:
+ aReturn.bEnabled = isEditable() && getContainer() && getContainer()->isPasteAllowed();
+ break;
+ case ID_BROWSER_SQL:
+ aReturn.bEnabled = m_bEscapeProcessing && m_pSqlIterator;
+ aReturn.bChecked = m_bGraphicalDesign;
+ break;
+ case SID_BROWSER_CLEAR_QUERY:
+ aReturn.bEnabled = isEditable() && (m_sStatement.getLength() || !m_vTableData.empty());
+ break;
+ case SID_QUERY_VIEW_FUNCTIONS:
+ case SID_QUERY_VIEW_TABLES:
+ case SID_QUERY_VIEW_ALIASES:
+ aReturn.bChecked = getContainer() && getContainer()->isSlotEnabled(_nId);
+ aReturn.bEnabled = m_bGraphicalDesign;
+ break;
+ case SID_QUERY_DISTINCT_VALUES:
+ aReturn.bEnabled = m_bGraphicalDesign && isEditable();
+ aReturn.bChecked = m_bDistinct;
+ break;
+ case ID_BROWSER_QUERY_EXECUTE:
+ aReturn.bEnabled = sal_True;
+ break;
+ case SID_DB_QUERY_PREVIEW:
+ aReturn.bEnabled = sal_True;
+ aReturn.bChecked = getContainer() && getContainer()->getPreviewFrame().is();
+ break;
+#if OSL_DEBUG_LEVEL > 1
+ case ID_EDIT_QUERY_SQL:
+ break;
+ case ID_EDIT_QUERY_DESIGN:
+ break;
+#endif
+ case ID_BROWSER_ADDTABLE:
+ if ( !m_bGraphicalDesign )
+ {
+ aReturn.bEnabled = sal_False;
+ break;
+ }
+ // run through
+ default:
+ aReturn = OJoinController::GetState(_nId);
+ break;
+ }
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch(_nId)
+ {
+ case ID_BROWSER_ESACPEPROCESSING:
+ setEscapeProcessing_fireEvent( !m_bEscapeProcessing );
+ if ( !editingView() )
+ setModified(sal_True);
+ InvalidateFeature(ID_BROWSER_SQL);
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ case ID_BROWSER_SAVEDOC:
+ doSaveAsDoc(ID_BROWSER_SAVEASDOC == _nId);
+ break;
+ case SID_RELATION_ADD_RELATION:
+ {
+ OJoinDesignView* pView = getJoinView();
+ if( pView )
+ static_cast<OQueryTableView*>(pView->getTableView())->createNewConnection();
+ }
+ break;
+ case SID_PRINTDOCDIRECT:
+ break;
+ case ID_BROWSER_CUT:
+ getContainer()->cut();
+ break;
+ case ID_BROWSER_COPY:
+ getContainer()->copy();
+ break;
+ case ID_BROWSER_PASTE:
+ getContainer()->paste();
+ break;
+ case ID_BROWSER_SQL:
+ {
+ if ( !getContainer()->checkStatement() )
+ break;
+ SQLExceptionInfo aError;
+ try
+ {
+ ::rtl::OUString aErrorMsg;
+ setStatement_fireEvent( getContainer()->getStatement() );
+ if(!m_sStatement.getLength() && m_pSqlIterator)
+ {
+ // change the view of the data
+ delete m_pSqlIterator->getParseTree();
+ m_pSqlIterator->setParseTree(NULL);
+ m_bGraphicalDesign = !m_bGraphicalDesign;
+ impl_setViewMode( &aError );
+ }
+ else
+ {
+ ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree(aErrorMsg,m_sStatement,m_bGraphicalDesign);
+ if ( pNode )
+ {
+ delete m_pSqlIterator->getParseTree();
+ m_pSqlIterator->setParseTree(pNode);
+ m_pSqlIterator->traverseAll();
+
+ if ( m_pSqlIterator->hasErrors() )
+ {
+ aError = m_pSqlIterator->getErrors();
+ }
+ else
+ {
+ const OSQLTables& xTabs = m_pSqlIterator->getTables();
+ if ( m_pSqlIterator->getStatementType() != SQL_STATEMENT_SELECT || xTabs.begin() == xTabs.end() )
+ {
+ aError = SQLException(
+ String( ModuleRes( STR_QRY_NOSELECT ) ),
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
+ 1000,
+ Any()
+ );
+ }
+ else
+ {
+ // change the view of the data
+ m_bGraphicalDesign = !m_bGraphicalDesign;
+ ::rtl::OUString sNewStatement;
+ pNode->parseNodeToStr( sNewStatement, getConnection() );
+ setStatement_fireEvent( sNewStatement );
+ getContainer()->SaveUIConfig();
+ m_vTableConnectionData.clear();
+ impl_setViewMode( &aError );
+ }
+ }
+ }
+ else
+ {
+ aError = SQLException(
+ String( ModuleRes( STR_QRY_SYNTAX ) ),
+ NULL,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) ),
+ 1000,
+ Any()
+ );
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ aError = ::cppu::getCaughtException();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( aError.isValid() )
+ showError( aError );
+
+ if(m_bGraphicalDesign)
+ {
+ InvalidateFeature(ID_BROWSER_ADDTABLE);
+ InvalidateFeature(SID_RELATION_ADD_RELATION);
+ }
+ }
+ break;
+ case SID_BROWSER_CLEAR_QUERY:
+ {
+ GetUndoManager().EnterListAction( String( ModuleRes(STR_QUERY_UNDO_TABWINDELETE) ), String() );
+ getContainer()->clear();
+ GetUndoManager().LeaveListAction();
+
+ setStatement_fireEvent( ::rtl::OUString() );
+ if(m_bGraphicalDesign)
+ InvalidateFeature(ID_BROWSER_ADDTABLE);
+ }
+ break;
+ case SID_QUERY_VIEW_FUNCTIONS:
+ case SID_QUERY_VIEW_TABLES:
+ case SID_QUERY_VIEW_ALIASES:
+ getContainer()->setSlotEnabled(_nId,!getContainer()->isSlotEnabled(_nId));
+ setModified(sal_True);
+ break;
+ case SID_QUERY_DISTINCT_VALUES:
+ m_bDistinct = !m_bDistinct;
+ setModified(sal_True);
+ break;
+ case ID_BROWSER_QUERY_EXECUTE:
+ if ( getContainer()->checkStatement() )
+ executeQuery();
+ break;
+ case SID_DB_QUERY_PREVIEW:
+ try
+ {
+ Reference< ::com::sun::star::util::XCloseable > xCloseFrame( getContainer()->getPreviewFrame(), UNO_QUERY );
+ if ( xCloseFrame.is() )
+ {
+ try
+ {
+ xCloseFrame->close( sal_True );
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL( "OQueryController::Execute(SID_DB_QUERY_PREVIEW): *nobody* is expected to veto closing the preview frame!" );
+ }
+ }
+ else
+ Execute(ID_BROWSER_QUERY_EXECUTE,Sequence< PropertyValue >());
+ }
+ catch(const Exception&)
+ {
+ }
+ break;
+ case ID_QUERY_ZOOM_IN:
+ {
+ }
+ break;
+ case ID_QUERY_ZOOM_OUT:
+ {
+ }
+ break;
+#if OSL_DEBUG_LEVEL > 1
+ case ID_EDIT_QUERY_DESIGN:
+ case ID_EDIT_QUERY_SQL:
+ {
+ ::rtl::OUString aErrorMsg;
+ setStatement_fireEvent( getContainer()->getStatement() );
+ ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign );
+ if ( pNode )
+ {
+ Window* pView = getView();
+ ModalDialog* pWindow = new ModalDialog( pView, WB_STDMODAL | WB_SIZEMOVE | WB_CENTER );
+ pWindow->SetSizePixel( ::Size( pView->GetSizePixel().Width() / 2, pView->GetSizePixel().Height() / 2 ) );
+ SvTreeListBox* pTreeBox = new SvTreeListBox( pWindow, WB_BORDER | WB_HASLINES | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HASLINESATROOT | WB_VSCROLL );
+ pTreeBox->SetPosSizePixel( ::Point( 6, 6 ), ::Size( pWindow->GetSizePixel().Width() - 12, pWindow->GetSizePixel().Height() - 12 ));
+ pTreeBox->SetNodeDefaultImages();
+
+ if ( _nId == ID_EDIT_QUERY_DESIGN )
+ {
+ ::connectivity::OSQLParseNode* pTemp = pNode ? pNode->getChild(3)->getChild(1) : NULL;
+ // no where clause found
+ if ( pTemp && !pTemp->isLeaf() )
+ {
+ ::connectivity::OSQLParseNode * pCondition = pTemp->getChild(1);
+ if ( pCondition ) // no where clause
+ {
+ ::connectivity::OSQLParseNode::negateSearchCondition(pCondition);
+ ::connectivity::OSQLParseNode *pNodeTmp = pTemp->getChild(1);
+
+ ::connectivity::OSQLParseNode::disjunctiveNormalForm(pNodeTmp);
+ pNodeTmp = pTemp->getChild(1);
+ ::connectivity::OSQLParseNode::absorptions(pNodeTmp);
+ pNodeTmp = pTemp->getChild(1);
+ OSQLParseNode::compress(pNodeTmp);
+ pNodeTmp = pTemp->getChild(1);
+ }
+ ::rtl::OUString sTemp;
+ pNode->parseNodeToStr(sTemp,getConnection());
+ getContainer()->setStatement(sTemp);
+ }
+ }
+
+ insertParseTree(pTreeBox,pNode);
+
+ pTreeBox->Show();
+ pWindow->Execute();
+
+ delete pTreeBox;
+ delete pWindow;
+ delete pNode;
+ }
+ break;
+ }
+#endif
+ default:
+ OJoinController::Execute(_nId,aArgs);
+ return; // else we would invalidate twice
+ }
+ InvalidateFeature(_nId);
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails )
+{
+ SQLContext aErrorContext;
+ aErrorContext.Message = lcl_getObjectResourceString( STR_ERROR_PARSING_STATEMENT, m_nCommandType );
+ aErrorContext.Context = *this;
+ aErrorContext.Details = lcl_getObjectResourceString( STR_INFO_OPENING_IN_SQL_VIEW, m_nCommandType );
+ aErrorContext.NextException = _rErrorDetails;
+ showError( aErrorContext );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryController::impl_setViewMode( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ OSL_PRECOND( getContainer(), "OQueryController::impl_setViewMode: illegal call!" );
+
+ bool wasModified = isModified();
+
+ SQLExceptionInfo aError;
+ bool bSuccess = getContainer()->switchView( &aError );
+ if ( !bSuccess )
+ {
+ m_bGraphicalDesign = !m_bGraphicalDesign;
+ // restore old state
+ getContainer()->switchView( NULL );
+ // don't pass &aError here, this would overwrite the error which the first switchView call
+ // returned in this location.
+ if ( _pErrorInfo )
+ *_pErrorInfo = aError;
+ else
+ showError( aError );
+ }
+ else
+ {
+ ensureToolbars( *this, m_bGraphicalDesign );
+ }
+
+ setModified( wasModified );
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::impl_initialize()
+{
+ OJoinController::impl_initialize();
+
+ const NamedValueCollection& rArguments( getInitParams() );
+
+ ::rtl::OUString sCommand;
+ m_nCommandType = CommandType::QUERY;
+
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+ // ° reading parameters
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+ // legacy parameters first (later overwritten by regular parameters)
+ ::rtl::OUString sIndependentSQLCommand;
+ if ( rArguments.get_ensureType( "IndependentSQLCommand", sIndependentSQLCommand ) )
+ {
+ OSL_FAIL( "OQueryController::impl_initialize: IndependentSQLCommand is regognized for compatibility only!" );
+ sCommand = sIndependentSQLCommand;
+ m_nCommandType = CommandType::COMMAND;
+ }
+
+ ::rtl::OUString sCurrentQuery;
+ if ( rArguments.get_ensureType( "CurrentQuery", sCurrentQuery ) )
+ {
+ OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" );
+ sCommand = sCurrentQuery;
+ m_nCommandType = CommandType::QUERY;
+ }
+
+ sal_Bool bCreateView( sal_False );
+ if ( rArguments.get_ensureType( "CreateView", bCreateView ) && bCreateView )
+ {
+ OSL_FAIL( "OQueryController::impl_initialize: CurrentQuery is regognized for compatibility only!" );
+ m_nCommandType = CommandType::TABLE;
+ }
+
+ // non-legacy parameters which overwrite the legacy parameters
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND, sCommand );
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_COMMAND_TYPE, m_nCommandType );
+
+ // translate Command/Type into proper members
+ // TODO/Later: all this (including those members) should be hidden behind some abstact interface,
+ // which is implemented for all the three commands
+ switch ( m_nCommandType )
+ {
+ case CommandType::QUERY:
+ m_sName = sCommand;
+ break;
+ case CommandType::TABLE:
+ m_sName = sCommand;
+ break;
+ case CommandType::COMMAND:
+ setStatement_fireEvent( sCommand );
+ m_sName = ::rtl::OUString();
+ break;
+ default:
+ OSL_FAIL( "OQueryController::impl_initialize: logic error in code!" );
+ throw RuntimeException();
+ }
+
+ // more legacy parameters
+ sal_Bool bGraphicalDesign( sal_True );
+ if ( rArguments.get_ensureType( (::rtl::OUString)PROPERTY_QUERYDESIGNVIEW, bGraphicalDesign ) )
+ {
+ OSL_FAIL( "OQueryController::impl_initialize: QueryDesignView is regognized for compatibility only!" );
+ m_bGraphicalDesign = bGraphicalDesign;
+ }
+
+ // more non-legacy
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign );
+
+ bool bEscapeProcessing( sal_True );
+ if ( rArguments.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, bEscapeProcessing ) )
+ {
+ setEscapeProcessing_fireEvent( bEscapeProcessing );
+
+ OSL_ENSURE( m_bEscapeProcessing || !m_bGraphicalDesign, "OQueryController::impl_initialize: can't do the graphical design without escape processing!" );
+ if ( !m_bEscapeProcessing )
+ m_bGraphicalDesign = false;
+ }
+
+ // .................................................................................................................
+ // . initial design
+ bool bForceInitialDesign = false;
+ Sequence< PropertyValue > aCurrentQueryDesignProps;
+ aCurrentQueryDesignProps = rArguments.getOrDefault( "CurrentQueryDesign", aCurrentQueryDesignProps );
+
+ if ( aCurrentQueryDesignProps.getLength() )
+ {
+ ::comphelper::NamedValueCollection aCurrentQueryDesign( aCurrentQueryDesignProps );
+ if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN ) )
+ {
+ aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign );
+ }
+ if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING ) )
+ {
+ aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing );
+ }
+ if ( aCurrentQueryDesign.has( "Statement" ) )
+ {
+ ::rtl::OUString sStatement;
+ aCurrentQueryDesign.get_ensureType( "Statement", sStatement );
+ aCurrentQueryDesign.remove( "Statement" );
+ setStatement_fireEvent( sStatement );
+ }
+
+ loadViewSettings( aCurrentQueryDesign );
+
+ bForceInitialDesign = true;
+ }
+
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+ if ( !ensureConnected( sal_False ) )
+ { // we have no connection so what else should we do
+ m_bGraphicalDesign = sal_False;
+ if ( editingView() )
+ {
+ connectionLostMessage();
+ throw SQLException();
+ }
+ }
+
+ // check the view capabilities
+ if ( isConnected() && editingView() )
+ {
+ Reference< XViewsSupplier > xViewsSup( getConnection(), UNO_QUERY );
+ Reference< XNameAccess > xViews;
+ if ( xViewsSup.is() )
+ xViews = xViewsSup->getViews();
+
+ if ( !xViews.is() )
+ { // we can't create views so we ask if the user wants to create a query instead
+ m_nCommandType = CommandType::QUERY;
+ sal_Bool bClose = sal_False;
+ {
+ String aTitle( ModuleRes( STR_QUERYDESIGN_NO_VIEW_SUPPORT ) );
+ String aMessage( ModuleRes( STR_QUERYDESIGN_NO_VIEW_ASK ) );
+ ODataView* pWindow = getView();
+ OSQLMessageBox aDlg( pWindow, aTitle, aMessage, WB_YES_NO | WB_DEF_YES, OSQLMessageBox::Query );
+ bClose = aDlg.Execute() == RET_NO;
+ }
+ if ( bClose )
+ throw VetoException();
+ }
+
+ // now if we are to edit an existing view, check whether this is possible
+ if ( m_sName.getLength() )
+ {
+ Any aView( xViews->getByName( m_sName ) );
+ // will throw if there is no such view
+ if ( !( aView >>= m_xAlterView ) )
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( String( ModuleRes( STR_NO_ALTER_VIEW_SUPPORT ) ) ),
+ *this,
+ 1
+ );
+ }
+ }
+ }
+
+ OSL_ENSURE(getDataSource().is(),"OQueryController::impl_initialize: need a datasource!");
+
+ try
+ {
+ getContainer()->initialize();
+ impl_reset( bForceInitialDesign );
+
+ SQLExceptionInfo aError;
+ const bool bAttemptedGraphicalDesign = m_bGraphicalDesign;
+
+ if ( bForceInitialDesign )
+ {
+ getContainer()->forceInitialView();
+ }
+ else
+ {
+ impl_setViewMode( &aError );
+ }
+
+ if ( aError.isValid() && bAttemptedGraphicalDesign && !m_bGraphicalDesign )
+ {
+ // we tried initializing the graphical view, this failed, and we were automatically switched to SQL
+ // view => tell this to the user
+ if ( !editingView() )
+ {
+ impl_showAutoSQLViewError( aError.get() );
+ }
+ }
+
+ ClearUndoManager();
+
+ if ( ( m_bGraphicalDesign )
+ && ( ( !m_sName.getLength() && !editingCommand() )
+ || ( !m_sStatement.getLength() && editingCommand() )
+ )
+ )
+ {
+ Application::PostUserEvent( LINK( this, OQueryController, OnExecuteAddTable ) );
+ }
+
+ setModified(sal_False);
+ }
+ catch(const SQLException& e)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ // we caught an exception so we switch to text only mode
+ {
+ m_bGraphicalDesign = sal_False;
+ getContainer()->initialize();
+ ODataView* pWindow = getView();
+ OSQLMessageBox(pWindow,e).Execute();
+ }
+ throw;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::onLoadedMenu(const Reference< ::com::sun::star::frame::XLayoutManager >& /*_xLayoutManager*/)
+{
+ ensureToolbars( *this, m_bGraphicalDesign );
+}
+
+// -----------------------------------------------------------------------------
+::rtl::OUString OQueryController::getPrivateTitle( ) const
+{
+ ::rtl::OUString sName = m_sName;
+ if ( !sName.getLength() )
+ {
+ if ( !editingCommand() )
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ String aDefaultName = String( ModuleRes( editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE ) );
+ sName = aDefaultName.GetToken(0,' ');
+ sName += ::rtl::OUString::valueOf(getCurrentStartNumber());
+ }
+ }
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OQueryController::setQueryComposer()
+{
+ if(isConnected())
+ {
+ Reference< XSQLQueryComposerFactory > xFactory(getConnection(), UNO_QUERY);
+ OSL_ENSURE(xFactory.is(),"Connection doesn't support a querycomposer");
+ if ( xFactory.is() && getContainer() )
+ {
+ try
+ {
+ m_xComposer = xFactory->createQueryComposer();
+ getContainer()->setStatement(m_sStatement);
+ }
+ catch(const Exception&)
+ {
+ m_xComposer = NULL;
+ }
+ OSL_ENSURE(m_xComposer.is(),"No querycomposer available!");
+ Reference<XTablesSupplier> xTablesSup(getConnection(), UNO_QUERY);
+ deleteIterator();
+ m_pSqlIterator = new ::connectivity::OSQLParseTreeIterator( getConnection(), xTablesSup->getTables(), m_aSqlParser, NULL );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryController::Construct(Window* pParent)
+{
+ // TODO: we have to check if we should create the text- or the design- view
+
+ setView( * new OQueryContainerWindow( pParent, *this, getORB() ) );
+
+ return OJoinController::Construct(pParent);
+}
+
+// -----------------------------------------------------------------------------
+OJoinDesignView* OQueryController::getJoinView()
+{
+ return getContainer()->getDesignView();
+}
+// -----------------------------------------------------------------------------
+void OQueryController::describeSupportedFeatures()
+{
+ OJoinController::describeSupportedFeatures();
+ implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SbaNativeSql", ID_BROWSER_ESACPEPROCESSING,CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:DBViewFunctions", SID_QUERY_VIEW_FUNCTIONS, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBViewTableNames", SID_QUERY_VIEW_TABLES, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBViewAliases", SID_QUERY_VIEW_ALIASES, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBDistinctValues", SID_QUERY_DISTINCT_VALUES, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:DBChangeDesignMode",ID_BROWSER_SQL, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBClearQuery", SID_BROWSER_CLEAR_QUERY, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:SbaExecuteSql", ID_BROWSER_QUERY_EXECUTE, CommandGroup::VIEW );
+ implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:DBQueryPreview", SID_DB_QUERY_PREVIEW, CommandGroup::VIEW );
+
+#if OSL_DEBUG_LEVEL > 1
+ implDescribeSupportedFeature( ".uno:DBShowParseTree", ID_EDIT_QUERY_SQL );
+ implDescribeSupportedFeature( ".uno:DBMakeDisjunct", ID_EDIT_QUERY_DESIGN );
+#endif
+}
+// -----------------------------------------------------------------------------
+void OQueryController::impl_onModifyChanged()
+{
+ OJoinController::impl_onModifyChanged();
+ InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
+ InvalidateFeature(ID_BROWSER_SAVEASDOC);
+ InvalidateFeature(ID_BROWSER_QUERY_EXECUTE);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryController::disposing( const EventObject& Source ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( getContainer() && Source.Source.is() )
+ {
+ if ( Source.Source == m_aCurrentFrame.getFrame() )
+ { // our frame is being disposed -> close the preview window (if we have one)
+ Reference< XFrame > xPreviewFrame( getContainer()->getPreviewFrame() );
+ ::comphelper::disposeComponent( xPreviewFrame );
+ }
+ else if ( Source.Source == getContainer()->getPreviewFrame() )
+ {
+ getContainer()->disposingPreview();
+ }
+ }
+
+ OJoinController::disposing(Source);
+}
+// -----------------------------------------------------------------------------
+void OQueryController::reconnect(sal_Bool _bUI)
+{
+ deleteIterator();
+ ::comphelper::disposeComponent(m_xComposer);
+
+ OJoinController::reconnect( _bUI );
+
+ if (isConnected())
+ {
+ setQueryComposer();
+ }
+ else
+ {
+ if(m_bGraphicalDesign)
+ {
+ m_bGraphicalDesign = sal_False;
+ // don't call Execute(SQL) because this changes the sql statement
+ impl_setViewMode( NULL );
+ }
+ InvalidateAll();
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const
+{
+ saveTableWindows( o_rViewSettings );
+
+ OTableFields::const_iterator field = m_vTableFieldDesc.begin();
+ OTableFields::const_iterator fieldEnd = m_vTableFieldDesc.end();
+
+ ::comphelper::NamedValueCollection aAllFieldsData;
+ ::comphelper::NamedValueCollection aFieldData;
+ for ( sal_Int32 i = 1; field != fieldEnd; ++field, ++i )
+ {
+ if ( !(*field)->IsEmpty() )
+ {
+ aFieldData.clear();
+ (*field)->Save( aFieldData, i_includingCriteria );
+
+ const ::rtl::OUString sFieldSettingName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Field" ) ) + ::rtl::OUString::valueOf( i );
+ aAllFieldsData.put( sFieldSettingName, aFieldData.getPropertyValues() );
+ }
+ }
+
+ o_rViewSettings.put( "Fields", aAllFieldsData.getPropertyValues() );
+ o_rViewSettings.put( "SplitterPosition", m_nSplitPos );
+ o_rViewSettings.put( "VisibleRows", m_nVisibleRows );
+}
+// -----------------------------------------------------------------------------
+void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings )
+{
+ loadTableWindows( o_rViewSettings );
+
+ m_nSplitPos = o_rViewSettings.getOrDefault( "SplitterPosition", m_nSplitPos );
+ m_nVisibleRows = o_rViewSettings.getOrDefault( "VisibleRows", m_nVisibleRows );
+ m_aFieldInformation = o_rViewSettings.getOrDefault( "Fields", m_aFieldInformation );
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos) const
+{
+ if ( _nColPos < m_aFieldInformation.getLength() )
+ {
+ ::std::auto_ptr<OTableFieldDesc> pField( new OTableFieldDesc());
+ pField->Load( m_aFieldInformation[ _nColPos ], false );
+ return pField->GetColWidth();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+Reference<XNameAccess> OQueryController::getObjectContainer() const
+{
+ Reference< XNameAccess > xElements;
+ if ( editingView() )
+ {
+ Reference< XViewsSupplier > xViewsSupp( getConnection(), UNO_QUERY );
+ if ( xViewsSupp.is() )
+ xElements = xViewsSupp->getViews();
+ }
+ else
+ {
+ Reference< XQueriesSupplier > xQueriesSupp( getConnection(), UNO_QUERY );
+ if ( xQueriesSupp.is() )
+ xElements = xQueriesSupp->getQueries();
+ else
+ {
+ Reference< XQueryDefinitionsSupplier > xQueryDefsSupp( getDataSource(), UNO_QUERY );
+ if ( xQueryDefsSupp.is() )
+ xElements = xQueryDefsSupp->getQueryDefinitions();
+ }
+ }
+
+ OSL_ENSURE( xElements.is(), "OQueryController::getObjectContainer: unable to obtain the container!" );
+ return xElements;
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::executeQuery()
+{
+ // we don't need to check the connection here because we already check the composer
+ // which can't live without his connection
+ ::rtl::OUString sTranslatedStmt = translateStatement( false );
+
+ ::rtl::OUString sDataSourceName = getDataSourceName();
+ if ( sDataSourceName.getLength() && sTranslatedStmt.getLength() )
+ {
+ try
+ {
+ getContainer()->showPreview( getFrame() );
+ InvalidateFeature(SID_DB_QUERY_PREVIEW);
+
+ URL aWantToDispatch;
+ aWantToDispatch.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".component:DB/DataSourceBrowser"));
+
+ ::rtl::OUString sFrameName( FRAME_NAME_QUERY_PREVIEW );
+ sal_Int32 nSearchFlags = FrameSearchFlag::CHILDREN;
+
+ Reference< XDispatch> xDisp;
+ Reference< XDispatchProvider> xProv( getFrame()->findFrame( sFrameName, nSearchFlags ), UNO_QUERY );
+ if(!xProv.is())
+ {
+ xProv.set( getFrame(), UNO_QUERY );
+ if (xProv.is())
+ xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, nSearchFlags);
+ }
+ else
+ {
+ xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, FrameSearchFlag::SELF);
+ }
+ if (xDisp.is())
+ {
+ Sequence< PropertyValue> aProps(9);
+ aProps[0].Name = PROPERTY_DATASOURCENAME;
+ aProps[0].Value <<= sDataSourceName;
+
+ aProps[1].Name = PROPERTY_COMMAND_TYPE;
+ aProps[1].Value <<= CommandType::COMMAND;
+
+ aProps[2].Name = PROPERTY_COMMAND;
+ aProps[2].Value <<= sTranslatedStmt;
+
+ aProps[3].Name = PROPERTY_ENABLE_BROWSER;
+ aProps[3].Value = ::cppu::bool2any(sal_False);
+
+ aProps[4].Name = PROPERTY_ACTIVE_CONNECTION;
+ aProps[4].Value <<= getConnection();
+
+ aProps[5].Name = PROPERTY_UPDATE_CATALOGNAME;
+ aProps[5].Value <<= m_sUpdateCatalogName;
+
+ aProps[6].Name = PROPERTY_UPDATE_SCHEMANAME;
+ aProps[6].Value <<= m_sUpdateSchemaName;
+
+ aProps[7].Name = PROPERTY_UPDATE_TABLENAME;
+ aProps[7].Value <<= m_sUpdateTableName;
+
+ aProps[8].Name = PROPERTY_ESCAPE_PROCESSING;
+ aProps[8].Value = ::cppu::bool2any(m_bEscapeProcessing);
+
+ xDisp->dispatch(aWantToDispatch, aProps);
+ // check the state of the beamer
+ // be notified when the beamer frame is closed
+ Reference< XComponent > xComponent( getFrame()->findFrame( sFrameName, nSearchFlags ), UNO_QUERY );
+ if (xComponent.is())
+ {
+ OSL_ENSURE(Reference< XFrame >(xComponent, UNO_QUERY).get() == getContainer()->getPreviewFrame().get(),
+ "OQueryController::executeQuery: oops ... which window do I have here?");
+ Reference< XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->addEventListener(xEvtL);
+ }
+ }
+ else
+ {
+ OSL_FAIL("Couldn't create a beamer window!");
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("Couldn't create a beamer window!");
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OQueryController::askForNewName(const Reference<XNameAccess>& _xElements,sal_Bool _bSaveAs)
+{
+ OSL_ENSURE( !editingCommand(), "OQueryController::askForNewName: not to be called when designing an independent statement!" );
+ if ( editingCommand() )
+ return sal_False;
+
+ OSL_PRECOND( _xElements.is(), "OQueryController::askForNewName: invalid container!" );
+ if ( !_xElements.is() )
+ return sal_False;
+
+ sal_Bool bRet = sal_True;
+ sal_Bool bNew = _bSaveAs || !_xElements->hasByName( m_sName );
+ if(bNew)
+ {
+ String aDefaultName;
+ if ( ( _bSaveAs && !bNew ) || ( bNew && m_sName.getLength() ) )
+ aDefaultName = String( m_sName );
+ else
+ {
+ String sName = String( ModuleRes( editingView() ? STR_VIEW_TITLE : STR_QRY_TITLE ) );
+ aDefaultName = sName.GetToken(0,' ');
+ aDefaultName = ::dbtools::createUniqueName(_xElements,aDefaultName);
+ }
+
+ DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::QUERY );
+ OSaveAsDlg aDlg(
+ getView(),
+ m_nCommandType,
+ getORB(),
+ getConnection(),
+ aDefaultName,
+ aNameChecker,
+ SAD_DEFAULT );
+
+ bRet = ( aDlg.Execute() == RET_OK );
+ if ( bRet )
+ {
+ m_sName = aDlg.getName();
+ if ( editingView() )
+ {
+ m_sUpdateCatalogName = aDlg.getCatalog();
+ m_sUpdateSchemaName = aDlg.getSchema();
+ }
+ }
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+bool OQueryController::doSaveAsDoc(sal_Bool _bSaveAs)
+{
+ OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!");
+ if ( !editingCommand() && !haveDataSource() )
+ {
+ String aMessage(ModuleRes(STR_DATASOURCE_DELETED));
+ OSQLWarningBox( getView(), aMessage ).Execute();
+ return false;
+ }
+
+ Reference< XNameAccess > xElements = getObjectContainer();
+ if ( !xElements.is() )
+ return false;
+
+ if ( !getContainer()->checkStatement() )
+ return false;
+
+ ::rtl::OUString sTranslatedStmt = translateStatement();
+ if ( editingCommand() )
+ {
+ setModified( sal_False );
+ // this is all we need to do here. translateStatement implicitly set our m_sStatement, and
+ // notified it, and that's all
+ return true;
+ }
+
+ if ( !sTranslatedStmt.getLength() )
+ return false;
+
+ // first we need a name for our query so ask the user
+ // did we get a name
+ ::rtl::OUString sOriginalName( m_sName );
+ if ( !askForNewName( xElements, _bSaveAs ) || !m_sName.getLength() )
+ return false;
+
+ SQLExceptionInfo aInfo;
+ bool bSuccess = false;
+ bool bNew = false;
+ try
+ {
+ bNew = ( _bSaveAs )
+ || ( !xElements->hasByName( m_sName ) );
+
+ Reference<XPropertySet> xQuery;
+ if ( bNew ) // just to make sure the query already exists
+ {
+ // drop the query, in case it already exists
+ if ( xElements->hasByName( m_sName ) )
+ {
+ Reference< XDrop > xNameCont( xElements, UNO_QUERY );
+ if ( xNameCont.is() )
+ xNameCont->dropByName( m_sName );
+ else
+ {
+ Reference< XNameContainer > xCont( xElements, UNO_QUERY );
+ if ( xCont.is() )
+ xCont->removeByName( m_sName );
+ }
+ }
+
+ // create a new (empty, uninitialized) query resp. view
+ Reference< XDataDescriptorFactory > xFact( xElements, UNO_QUERY );
+ if ( xFact.is() )
+ {
+ xQuery = xFact->createDataDescriptor();
+ // to set the name is only allowed when the query is new
+ xQuery->setPropertyValue( PROPERTY_NAME, makeAny( m_sName ) );
+ }
+ else
+ {
+ Reference< XSingleServiceFactory > xSingleFac( xElements, UNO_QUERY );
+ if ( xSingleFac.is() )
+ xQuery = xQuery.query( xSingleFac->createInstance() );
+ }
+ }
+ else
+ {
+ xElements->getByName( m_sName ) >>= xQuery;
+ }
+ if ( !xQuery.is() )
+ throw RuntimeException();
+
+ // the new commands
+ if ( editingView() && !bNew )
+ {
+ OSL_ENSURE( xQuery == m_xAlterView, "OQueryController::doSaveAsDoc: already have another alterable view ...!?" );
+ m_xAlterView.set( xQuery, UNO_QUERY_THROW );
+ m_xAlterView->alterCommand( sTranslatedStmt );
+ }
+ else
+ { // we're creating a query, or a *new* view
+ xQuery->setPropertyValue( PROPERTY_COMMAND, makeAny( sTranslatedStmt ) );
+
+ if ( editingView() )
+ {
+ xQuery->setPropertyValue( PROPERTY_CATALOGNAME, makeAny( m_sUpdateCatalogName ) );
+ xQuery->setPropertyValue( PROPERTY_SCHEMANAME, makeAny( m_sUpdateSchemaName ) );
+ }
+
+ if ( editingQuery() )
+ {
+ xQuery->setPropertyValue( PROPERTY_UPDATE_TABLENAME, makeAny( m_sUpdateTableName ) );
+ xQuery->setPropertyValue( PROPERTY_ESCAPE_PROCESSING,::cppu::bool2any( m_bEscapeProcessing ) );
+
+ xQuery->setPropertyValue( PROPERTY_LAYOUTINFORMATION, getViewData() );
+ }
+ }
+
+ if ( bNew )
+ {
+ Reference< XAppend > xAppend( xElements, UNO_QUERY );
+ if ( xAppend.is() )
+ {
+ xAppend->appendByDescriptor( xQuery );
+ }
+ else
+ {
+ Reference< XNameContainer > xCont( xElements, UNO_QUERY );
+ if ( xCont.is() )
+ xCont->insertByName( m_sName, makeAny( xQuery ) );
+ }
+
+ if ( editingView() )
+ {
+ Reference< XPropertySet > xViewProps;
+ if ( xElements->hasByName( m_sName ) )
+ xViewProps.set( xElements->getByName( m_sName ), UNO_QUERY );
+
+ if ( !xViewProps.is() ) // correct name and try again
+ m_sName = ::dbtools::composeTableName( getMetaData(), xQuery, ::dbtools::eInDataManipulation, false, false, false );
+
+ OSL_ENSURE( xElements->hasByName( m_sName ), "OQueryController::doSaveAsDoc: newly creaed view does not exist!" );
+
+ if ( xElements->hasByName( m_sName ) )
+ m_xAlterView.set( xElements->getByName( m_sName ), UNO_QUERY );
+
+ // now check if our datasource has set a tablefilter and if so, append the new table name to it
+ ::dbaui::appendToFilter( getConnection(), m_sName, getORB(), getView() );
+ }
+ Reference< XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
+ if ( xEventListener.is() )
+ {
+ TitleChangedEvent aEvent;
+ xEventListener->titleChanged(aEvent);
+ }
+ releaseNumberForComponent();
+ }
+
+ setModified( sal_False );
+ bSuccess = true;
+
+ }
+ catch(const SQLException&)
+ {
+ if ( !bNew )
+ m_sName = sOriginalName;
+ aInfo = SQLExceptionInfo( ::cppu::getCaughtException() );
+ }
+ catch(const Exception&)
+ {
+ if ( !bNew )
+ m_sName = sOriginalName;
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ showError( aInfo );
+
+ // update the title of our window
+ //updateTitle();
+
+ // if we successfully saved a view we were creating, then close the designer
+ if ( bSuccess && editingView() && !m_xAlterView.is() )
+ {
+ closeTask();
+ }
+
+ if ( bSuccess && editingView() )
+ InvalidateFeature( ID_BROWSER_EDITDOC );
+
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OQueryController::translateStatement( bool _bFireStatementChange )
+{
+ // now set the properties
+ setStatement_fireEvent( getContainer()->getStatement(), _bFireStatementChange );
+ ::rtl::OUString sTranslatedStmt;
+ if(m_sStatement.getLength() && m_xComposer.is() && m_bEscapeProcessing)
+ {
+ try
+ {
+ ::rtl::OUString aErrorMsg;
+
+ ::connectivity::OSQLParseNode* pNode = m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign );
+ if(pNode)
+ {
+ pNode->parseNodeToStr( sTranslatedStmt, getConnection() );
+ delete pNode;
+ }
+
+ m_xComposer->setQuery(sTranslatedStmt);
+ sTranslatedStmt = m_xComposer->getComposedQuery();
+ }
+ catch(const SQLException& e)
+ {
+ ::dbtools::SQLExceptionInfo aInfo(e);
+ showError(aInfo);
+ // an error occurred so we clear the statement
+ sTranslatedStmt = ::rtl::OUString();
+ }
+ }
+ else if(!m_sStatement.getLength())
+ {
+ ModuleRes aModuleRes(STR_QRY_NOSELECT);
+ String sTmpStr(aModuleRes);
+ ::rtl::OUString sError(sTmpStr);
+ showError(SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000") ),1000,Any()));
+ }
+ else
+ sTranslatedStmt = m_sStatement;
+
+ return sTranslatedStmt;
+}
+// -----------------------------------------------------------------------------
+short OQueryController::saveModified()
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ short nRet = RET_YES;
+ if ( !isConnected() || !isModified() )
+ return nRet;
+
+ if ( !m_bGraphicalDesign
+ || ( !m_vTableFieldDesc.empty()
+ && !m_vTableData.empty()
+ )
+ )
+ {
+ String sMessageText( lcl_getObjectResourceString( STR_QUERY_SAVEMODIFIED, m_nCommandType ) );
+ QueryBox aQry( getView(), WB_YES_NO_CANCEL | WB_DEF_YES, sMessageText );
+
+ nRet = aQry.Execute();
+ if ( ( nRet == RET_YES )
+ && !doSaveAsDoc( sal_False )
+ )
+ {
+ nRet = RET_CANCEL;
+ }
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+void OQueryController::impl_reset( const bool i_bForceCurrentControllerSettings )
+{
+ bool bValid = false;
+
+ Sequence< PropertyValue > aLayoutInformation;
+ // get command from the query if a query name was supplied
+ if ( !i_bForceCurrentControllerSettings && !editingCommand() )
+ {
+ if ( m_sName.getLength() )
+ {
+ Reference< XNameAccess > xQueries = getObjectContainer();
+ if ( xQueries.is() )
+ {
+ Reference< XPropertySet > xProp;
+ if( xQueries->hasByName( m_sName ) && ( xQueries->getByName( m_sName ) >>= xProp ) && xProp.is() )
+ {
+ ::rtl::OUString sNewStatement;
+ xProp->getPropertyValue( PROPERTY_COMMAND ) >>= sNewStatement;
+ setStatement_fireEvent( sNewStatement );
+
+ sal_Bool bNewEscapeProcessing( sal_True );
+ if ( editingQuery() )
+ {
+ xProp->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bNewEscapeProcessing;
+ setEscapeProcessing_fireEvent( bNewEscapeProcessing );
+ }
+
+ m_bGraphicalDesign = m_bGraphicalDesign && m_bEscapeProcessing;
+ bValid = true;
+
+ try
+ {
+ if ( editingQuery() )
+ xProp->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) >>= aLayoutInformation;
+ }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "OQueryController::impl_reset: could not retrieve the layout information from the query!" );
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ bValid = true;
+ // assume that we got all necessary information during initialization
+ }
+
+ if ( bValid )
+ {
+ // load the layoutInformation
+ if ( aLayoutInformation.getLength() )
+ {
+ try
+ {
+ loadViewSettings( aLayoutInformation );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( m_sStatement.getLength() )
+ {
+ setQueryComposer();
+
+ bool bError( false );
+
+ if ( !m_pSqlIterator )
+ {
+ bError = true;
+ }
+ else if ( m_bEscapeProcessing )
+ {
+ ::rtl::OUString aErrorMsg;
+ ::std::auto_ptr< ::connectivity::OSQLParseNode > pNode(
+ m_aSqlParser.parseTree( aErrorMsg, m_sStatement, m_bGraphicalDesign ) );
+
+ if ( pNode.get() )
+ {
+ delete m_pSqlIterator->getParseTree();
+ m_pSqlIterator->setParseTree( pNode.release() );
+ m_pSqlIterator->traverseAll();
+ if ( m_pSqlIterator->hasErrors() )
+ {
+ if ( !i_bForceCurrentControllerSettings && m_bGraphicalDesign && !editingView() )
+ {
+ impl_showAutoSQLViewError( makeAny( m_pSqlIterator->getErrors() ) );
+ }
+ bError = true;
+ }
+ }
+ else
+ {
+ if ( !i_bForceCurrentControllerSettings && !editingView() )
+ {
+ String aTitle(ModuleRes(STR_SVT_SQL_SYNTAX_ERROR));
+ OSQLMessageBox aDlg(getView(),aTitle,aErrorMsg);
+ aDlg.Execute();
+ }
+ bError = true;
+ }
+ }
+
+ if ( bError )
+ {
+ m_bGraphicalDesign = sal_False;
+ if ( editingView() )
+ // if we're editing a view whose statement could not be parsed, default to "no escape processing"
+ setEscapeProcessing_fireEvent( sal_False );
+ }
+ }
+ }
+
+ if(!m_pSqlIterator)
+ setQueryComposer();
+ OSL_ENSURE(m_pSqlIterator,"No SQLIterator set!");
+
+ getContainer()->setNoneVisbleRow(m_nVisibleRows);
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::reset()
+{
+ impl_reset();
+ getContainer()->reset( NULL );
+ ClearUndoManager();
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::setStatement_fireEvent( const ::rtl::OUString& _rNewStatement, bool _bFireStatementChange )
+{
+ Any aOldValue = makeAny( m_sStatement );
+ m_sStatement = _rNewStatement;
+ Any aNewValue = makeAny( m_sStatement );
+
+ sal_Int32 nHandle = PROPERTY_ID_ACTIVECOMMAND;
+ if ( _bFireStatementChange )
+ fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False );
+}
+
+// -----------------------------------------------------------------------------
+void OQueryController::setEscapeProcessing_fireEvent( const sal_Bool _bEscapeProcessing )
+{
+ if ( _bEscapeProcessing == m_bEscapeProcessing )
+ return;
+
+ Any aOldValue = makeAny( m_bEscapeProcessing );
+ m_bEscapeProcessing = _bEscapeProcessing;
+ Any aNewValue = makeAny( m_bEscapeProcessing );
+
+ sal_Int32 nHandle = PROPERTY_ID_ESCAPE_PROCESSING;
+ fire( &nHandle, &aNewValue, &aOldValue, 1, sal_False );
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK( OQueryController, OnExecuteAddTable, void*, /*pNotInterestedIn*/ )
+{
+ Execute( ID_BROWSER_ADDTABLE,Sequence<PropertyValue>() );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryController::allowViews() const
+{
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryController::allowQueries() const
+{
+ OSL_ENSURE( getSdbMetaData().isConnected(), "OQueryController::allowQueries: illegal call!" );
+ if ( !getSdbMetaData().supportsSubqueriesInFrom() )
+ return false;
+
+ const NamedValueCollection& rArguments( getInitParams() );
+ sal_Int32 nCommandType = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_COMMAND_TYPE, (sal_Int32)CommandType::QUERY );
+ sal_Bool bCreatingView = ( nCommandType == CommandType::TABLE );
+ return !bCreatingView;
+}
+
+// -----------------------------------------------------------------------------
+Any SAL_CALL OQueryController::getViewData() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ getContainer()->SaveUIConfig();
+
+ ::comphelper::NamedValueCollection aViewSettings;
+ saveViewSettings( aViewSettings, false );
+
+ return makeAny( aViewSettings.getPropertyValues() );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OQueryController::restoreViewData(const Any& /*Data*/) throw( RuntimeException )
+{
+ // TODO
+}
+
+// -----------------------------------------------------------------------------
+} // namespace dbaui
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/querydlg.cxx b/dbaccess/source/ui/querydesign/querydlg.cxx
new file mode 100644
index 000000000000..2b9e70e8d07b
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "querydlg.hxx"
+#include "dbu_qry.hrc"
+#include "querydlg.hrc"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "QTableConnectionData.hxx"
+#include "querycontroller.hxx"
+#include "QueryTableView.hxx"
+#include "QueryDesignView.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "RelationControl.hxx"
+#include <vcl/msgbox.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbc;
+
+namespace dbaui
+{
+class OJoinControl : public Window
+{
+public:
+ FixedLine aFL_Join;
+ FixedText aFT_Title;
+ ListBox aLB_JoinType;
+ CheckBox m_aCBNatural;
+
+ OJoinControl(Window* _pParent,const ResId& _rResId);
+};
+OJoinControl::OJoinControl(Window* _pParent,const ResId& _rResId)
+ : Window(_pParent,_rResId)
+ ,aFL_Join( this, ResId( FL_JOIN,*_rResId.GetResMgr() ) )
+ ,aFT_Title( this, ResId(FT_LISTBOXTITLE,*_rResId.GetResMgr()) )
+ ,aLB_JoinType( this, ResId(LB_JOINTYPE,*_rResId.GetResMgr()) )
+ ,m_aCBNatural( this, ResId(CB_NATURAL,*_rResId.GetResMgr()) )
+{
+ FreeResource();
+}
+// -----------------------------------------------------------------------------
+} // dbaui
+// -----------------------------------------------------------------------------
+DBG_NAME(DlgQryJoin)
+DlgQryJoin::DlgQryJoin( OQueryTableView * pParent,
+ const TTableConnectionData::value_type& _pData,
+ OJoinTableView::OTableWindowMap* _pTableMap,
+ const Reference< XConnection >& _xConnection,
+ sal_Bool _bAllowTableSelect)
+ :ModalDialog( pParent, ModuleRes(DLG_QRY_JOIN) )
+ ,aML_HelpText( this, ModuleRes(ML_HELPTEXT) )
+ ,aPB_OK( this, ModuleRes( PB_OK ) )
+ ,aPB_CANCEL( this, ModuleRes( PB_CANCEL ) )
+ ,aPB_HELP( this, ModuleRes( PB_HELP ) )
+ ,m_pJoinControl( NULL )
+ ,m_pTableControl( NULL )
+ ,m_pTableMap(_pTableMap)
+ ,m_pTableView(pParent)
+ ,eJoinType(static_cast<OQueryTableConnectionData*>(_pData.get())->GetJoinType())
+ ,m_pOrigConnData(_pData)
+ ,m_xConnection(_xConnection)
+{
+ DBG_CTOR(DlgQryJoin,NULL);
+
+ aML_HelpText.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
+ //////////////////////////////////////////////////////////////////////
+ // Connection kopieren
+ m_pConnData.reset(_pData->NewInstance());
+ m_pConnData->CopyFrom(*_pData);
+
+ m_pTableControl = new OTableListBoxControl(this,ModuleRes(WND_CONTROL),m_pTableMap,this);
+
+ m_pJoinControl = new OJoinControl(m_pTableControl,ModuleRes(WND_JOIN_CONTROL));
+
+ m_pJoinControl->Show();
+ m_pJoinControl->m_aCBNatural.Check(static_cast<OQueryTableConnectionData*>(m_pConnData.get())->isNatural());
+ m_pTableControl->Show();
+
+ if( _bAllowTableSelect )
+ {
+ m_pTableControl->Init( m_pConnData );
+ m_pTableControl->fillListBoxes();
+ }
+ else
+ {
+ m_pTableControl->fillAndDisable(m_pConnData);
+ m_pTableControl->Init( m_pConnData );
+ }
+
+ m_pTableControl->lateUIInit(m_pJoinControl);
+
+ sal_Bool bSupportFullJoin = sal_False;
+ Reference<XDatabaseMetaData> xMeta;
+ try
+ {
+ xMeta = m_xConnection->getMetaData();
+ if ( xMeta.is() )
+ bSupportFullJoin = xMeta->supportsFullOuterJoins();
+ }
+ catch(SQLException&)
+ {
+ }
+ sal_Bool bSupportOuterJoin = sal_False;
+ try
+ {
+ if ( xMeta.is() )
+ bSupportOuterJoin= xMeta->supportsOuterJoins();
+ }
+ catch(SQLException&)
+ {
+ }
+
+ setJoinType(eJoinType);
+
+ aPB_OK.SetClickHdl( LINK(this, DlgQryJoin, OKClickHdl) );
+
+ m_pJoinControl->aLB_JoinType.SetSelectHdl(LINK(this,DlgQryJoin,LBChangeHdl));
+ m_pJoinControl->m_aCBNatural.SetToggleHdl(LINK(this,DlgQryJoin,NaturalToggleHdl));
+
+ if ( static_cast<OQueryTableView*>(pParent)->getDesignView()->getController().isReadOnly() )
+ {
+ m_pJoinControl->aLB_JoinType.Disable();
+ m_pJoinControl->m_aCBNatural.Disable();
+ m_pTableControl->Disable();
+ }
+ else
+ {
+ const sal_uInt16 nCount = m_pJoinControl->aLB_JoinType.GetEntryCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ const long nJoinTyp = reinterpret_cast<long>(m_pJoinControl->aLB_JoinType.GetEntryData(i));
+ if ( !bSupportFullJoin && nJoinTyp == ID_FULL_JOIN )
+ m_pJoinControl->aLB_JoinType.RemoveEntry(i);
+ else if ( !bSupportOuterJoin && (nJoinTyp == ID_LEFT_JOIN || nJoinTyp == ID_RIGHT_JOIN) )
+ m_pJoinControl->aLB_JoinType.RemoveEntry(i);
+ }
+
+ m_pTableControl->NotifyCellChange();
+ m_pTableControl->enableRelation(!static_cast<OQueryTableConnectionData*>(m_pConnData.get())->isNatural() && eJoinType != CROSS_JOIN );
+ }
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+DlgQryJoin::~DlgQryJoin()
+{
+ DBG_DTOR(DlgQryJoin,NULL);
+ delete m_pJoinControl;
+ delete m_pTableControl;
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( DlgQryJoin, LBChangeHdl, ListBox*, /*pListBox*/ )
+{
+ DBG_CHKTHIS(DlgQryJoin,NULL);
+ if (m_pJoinControl->aLB_JoinType.GetSelectEntryPos() == m_pJoinControl->aLB_JoinType.GetSavedValue() )
+ return 1;
+
+ m_pJoinControl->aLB_JoinType.SaveValue();
+ aML_HelpText.SetText(String());
+
+ m_pTableControl->enableRelation(true);
+
+ String sFirstWinName = m_pConnData->getReferencingTable()->GetWinName();
+ String sSecondWinName = m_pConnData->getReferencedTable()->GetWinName();
+ const EJoinType eOldJoinType = eJoinType;
+ sal_uInt16 nResId = 0;
+ const sal_uInt16 nPos = m_pJoinControl->aLB_JoinType.GetSelectEntryPos();
+ const long nJoinType = reinterpret_cast<long>(m_pJoinControl->aLB_JoinType.GetEntryData(nPos));
+ sal_Bool bAddHint = sal_True;
+ switch ( nJoinType )
+ {
+ default:
+ case ID_INNER_JOIN:
+ nResId = STR_QUERY_INNER_JOIN;
+ bAddHint = sal_False;
+ eJoinType = INNER_JOIN;
+ break;
+ case ID_LEFT_JOIN:
+ nResId = STR_QUERY_LEFTRIGHT_JOIN;
+ eJoinType = LEFT_JOIN;
+ break;
+ case ID_RIGHT_JOIN:
+ {
+ nResId = STR_QUERY_LEFTRIGHT_JOIN;
+ eJoinType = RIGHT_JOIN;
+ String sTemp = sFirstWinName;
+ sFirstWinName = sSecondWinName;
+ sSecondWinName = sTemp;
+ }
+ break;
+ case ID_FULL_JOIN:
+ nResId = STR_QUERY_FULL_JOIN;
+ eJoinType = FULL_JOIN;
+ break;
+ case ID_CROSS_JOIN:
+ {
+ nResId = STR_QUERY_CROSS_JOIN;
+ eJoinType = CROSS_JOIN;
+
+ m_pConnData->ResetConnLines();
+ m_pTableControl->lateInit();
+ m_pJoinControl->m_aCBNatural.Check(sal_False);
+ m_pTableControl->enableRelation(false);
+ ::rtl::OUString sEmpty;
+ m_pConnData->AppendConnLine(sEmpty,sEmpty);
+ aPB_OK.Enable(sal_True);
+ }
+ break;
+ }
+
+ m_pJoinControl->m_aCBNatural.Enable(eJoinType != CROSS_JOIN);
+
+ if ( eJoinType != eOldJoinType && eOldJoinType == CROSS_JOIN )
+ {
+ m_pConnData->ResetConnLines();
+ }
+ if ( eJoinType != CROSS_JOIN )
+ {
+ m_pTableControl->NotifyCellChange();
+ NaturalToggleHdl(&m_pJoinControl->m_aCBNatural);
+ }
+
+ m_pTableControl->Invalidate();
+
+ String sHelpText = String( ModuleRes( nResId ) );
+ if( nPos )
+ {
+ sHelpText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%1" ) ), sFirstWinName );
+ sHelpText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%2" ) ), sSecondWinName );
+ }
+ if ( bAddHint )
+ {
+ sHelpText += String( RTL_CONSTASCII_USTRINGPARAM( "\n" ) );
+ sHelpText += String( ModuleRes( STR_JOIN_TYPE_HINT ) );
+ }
+
+ aML_HelpText.SetText( sHelpText );
+ return 1;
+}
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( DlgQryJoin, OKClickHdl, Button*, /*pButton*/ )
+{
+ DBG_CHKTHIS(DlgQryJoin,NULL);
+
+ m_pConnData->Update();
+ m_pOrigConnData->CopyFrom( *m_pConnData );
+
+ EndDialog(RET_OK);
+ return 1;
+}
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( DlgQryJoin, NaturalToggleHdl, CheckBox*, /*pButton*/ )
+{
+ DBG_CHKTHIS(DlgQryJoin,NULL);
+ sal_Bool bChecked = m_pJoinControl->m_aCBNatural.IsChecked();
+ static_cast<OQueryTableConnectionData*>(m_pConnData.get())->setNatural(bChecked);
+ m_pTableControl->enableRelation(!bChecked);
+ if ( bChecked )
+ {
+ m_pConnData->ResetConnLines();
+ try
+ {
+ Reference<XNameAccess> xReferencedTableColumns(m_pConnData->getReferencedTable()->getColumns());
+ Sequence< ::rtl::OUString> aSeq = m_pConnData->getReferencingTable()->getColumns()->getElementNames();
+ const ::rtl::OUString* pIter = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( xReferencedTableColumns->hasByName(*pIter) )
+ m_pConnData->AppendConnLine(*pIter,*pIter);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pTableControl->NotifyCellChange();
+ m_pTableControl->Invalidate();
+ }
+
+ return 1;
+}
+// -----------------------------------------------------------------------------
+TTableConnectionData::value_type DlgQryJoin::getConnectionData() const
+{
+ return m_pConnData;
+}
+// -----------------------------------------------------------------------------
+void DlgQryJoin::setValid(sal_Bool _bValid)
+{
+ aPB_OK.Enable(_bValid || eJoinType == CROSS_JOIN );
+}
+// -----------------------------------------------------------------------------
+void DlgQryJoin::notifyConnectionChange( )
+{
+ setJoinType( static_cast<OQueryTableConnectionData*>(m_pConnData.get())->GetJoinType() );
+ m_pJoinControl->m_aCBNatural.Check(static_cast<OQueryTableConnectionData*>(m_pConnData.get())->isNatural());
+ NaturalToggleHdl(&m_pJoinControl->m_aCBNatural);
+}
+// -----------------------------------------------------------------------------
+void DlgQryJoin::setJoinType(EJoinType _eNewJoinType)
+{
+ eJoinType = _eNewJoinType;
+ m_pJoinControl->m_aCBNatural.Enable(eJoinType != CROSS_JOIN);
+
+ long nJoinType = 0;
+ switch ( eJoinType )
+ {
+ default:
+ case INNER_JOIN:
+ nJoinType = ID_INNER_JOIN;
+ break;
+ case LEFT_JOIN:
+ nJoinType = ID_LEFT_JOIN;
+ break;
+ case RIGHT_JOIN:
+ nJoinType = ID_RIGHT_JOIN;
+ break;
+ case FULL_JOIN:
+ nJoinType = ID_FULL_JOIN;
+ break;
+ case CROSS_JOIN:
+ nJoinType = ID_CROSS_JOIN;
+ break;
+ }
+
+ const sal_uInt16 nCount = m_pJoinControl->aLB_JoinType.GetEntryCount();
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ if ( nJoinType == reinterpret_cast<long>(m_pJoinControl->aLB_JoinType.GetEntryData(i)) )
+ {
+ m_pJoinControl->aLB_JoinType.SelectEntryPos(i);
+ break;
+ }
+ }
+
+ LBChangeHdl(&m_pJoinControl->aLB_JoinType);
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/querydlg.hrc b/dbaccess/source/ui/querydesign/querydlg.hrc
new file mode 100644
index 000000000000..0112fe1ffa56
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_QUERYDLG_HRC
+#define DBAUI_QUERYDLG_HRC
+
+#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+#include "RelationControl.hrc"
+#endif
+
+#define FL_JOIN 1
+#define FT_LISTBOXTITLE 2
+
+#define LB_JOINTYPE 1
+
+#define GB_FIELDS 1
+
+#define CB_NATURAL 1
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+#define ML_HELPTEXT 4
+
+#define WND_JOIN_CONTROL 1
+#define WND_CONTROL 2
+
+#define ID_INNER_JOIN 1
+#define ID_LEFT_JOIN 2
+#define ID_RIGHT_JOIN 3
+#define ID_FULL_JOIN 4
+#define ID_CROSS_JOIN 5
+
+#endif // DBAUI_QUERYDLG_HRC
+
+
+
diff --git a/dbaccess/source/ui/querydesign/querydlg.hxx b/dbaccess/source/ui/querydesign/querydlg.hxx
new file mode 100644
index 000000000000..21f4aea129ef
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_QUERYDLG_HXX
+#define DBAUI_QUERYDLG_HXX
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+#include "QEnumTypes.hxx"
+
+#include "RelControliFace.hxx"
+#include "JoinTableView.hxx"
+
+
+namespace dbaui
+{
+ class OQueryTableConnectionData;
+ class OTableListBoxControl;
+ class OQueryTableView;
+ class OJoinControl;
+ class DlgQryJoin : public ModalDialog
+ ,public IRelationControlInterface
+ {
+ protected:
+ FixedText aML_HelpText;
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+ OJoinControl* m_pJoinControl;
+ OTableListBoxControl* m_pTableControl;
+ OJoinTableView::OTableWindowMap* m_pTableMap;
+ OQueryTableView* m_pTableView;
+
+ EJoinType eJoinType;
+ TTableConnectionData::value_type m_pConnData; // enth"alt linke und rechte Tabelle
+ TTableConnectionData::value_type m_pOrigConnData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
+
+
+ DECL_LINK( OKClickHdl, Button* );
+ DECL_LINK( LBChangeHdl, ListBox* );
+ DECL_LINK( NaturalToggleHdl, CheckBox* );
+
+ /** setJoinType enables and set the new join type
+ @param _eNewJoinType the new jointype
+ */
+ void setJoinType(EJoinType _eNewJoinType);
+ public:
+ DlgQryJoin( OQueryTableView * pParent,
+ const TTableConnectionData::value_type& pData,
+ OJoinTableView::OTableWindowMap* _pTableMap,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ sal_Bool _bAllowTableSelect);
+ virtual ~DlgQryJoin();
+ EJoinType GetJoinType() const { return eJoinType; };
+
+ /** getConnectionData returns the current connection data
+ @return the current connectiondata
+ */
+ virtual TTableConnectionData::value_type getConnectionData() const;
+
+ /** setValid set the valid inside, can be used for OK buttons
+ @param _bValid true when the using control allows an update
+ */
+ virtual void setValid(sal_Bool _bValid);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() { return m_xConnection; }
+
+ /** notifyConnectionChange is callback which is called when the table selection has changed and a new connection exists
+ @param _pConnectionData the connection which exists between the new tables
+ */
+ virtual void notifyConnectionChange();
+ };
+}
+#endif // DBAUI_QUERYDLG_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/querydlg.src b/dbaccess/source/ui/querydesign/querydlg.src
new file mode 100644
index 000000000000..e0aec2c49d84
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/querydlg.src
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_QRY_HRC_
+#include "dbu_qry.hrc"
+#endif
+#ifndef DBAUI_QUERYDLG_HRC
+#include "querydlg.hrc"
+#endif
+#include "dbaccess_helpid.hrc"
+
+ModalDialog DLG_QRY_JOIN
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_DLG_QRY_JOIN ;
+ Size = MAP_APPFONT ( 265, 219 ) ;
+
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ Window WND_JOIN_CONTROL
+ {
+ Pos = MAP_APPFONT( 0, 0 );
+ Size = MAP_APPFONT( 203, 44 );
+ DialogControl = TRUE;
+ HelpId = HID_DLG_QRY_JOIN_CONTROL ;
+ FixedLine FL_JOIN
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 191 , 8 ) ;
+ Text [ en-US ] = "Options";
+ };
+
+ FixedText FT_LISTBOXTITLE
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 89 , 8 ) ;
+
+ Text [ en-US ] = "~Type";
+ };
+
+ ListBox LB_JOINTYPE
+ {
+ Pos = MAP_APPFONT ( 101 , 15 ) ;
+ Size = MAP_APPFONT ( 90 , 60 ) ;
+ HelpId = HID_DLG_QRY_JOINTYPE ;
+
+ DropDown = TRUE;
+ DDExtraWidth = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Inner join" ; ID_INNER_JOIN; > ;
+ < "Left join" ; ID_LEFT_JOIN; > ;
+ < "Right join" ; ID_RIGHT_JOIN; > ;
+ < "Full (outer) join" ; ID_FULL_JOIN; > ;
+ < "Cross join" ; ID_CROSS_JOIN; > ;
+ };
+ };
+ CheckBox CB_NATURAL
+ {
+ HelpID = "dbaccess:CheckBox:DLG_QRY_JOIN:CB_NATURAL";
+ Pos = MAP_APPFONT ( 101 , 31 ) ;
+ Size = MAP_APPFONT ( 89 , 8 ) ;
+
+ Text [ en-US ] = "Natural";
+ };
+ };
+
+ Window WND_CONTROL
+ {
+ Pos = MAP_APPFONT( 0, 0 );
+ Size = MAP_APPFONT( 203, 153 );
+ DialogControl = TRUE;
+ HelpId = HID_DLG_QRY_WINDOW_CONTROL ;
+
+ FixedLine FL_INVOLVED_TABLES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 191 , 8 ) ;
+ Text [ en-US ] = "Tables involved";
+ };
+
+ ListBox LB_LEFT_TABLE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 12, 14 );
+ Size = MAP_APPFONT( 87, 60 );
+ HelpId = HID_DLG_QRY_LEFT_TABLE ;
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+
+ ListBox LB_RIGHT_TABLE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 104, 14 );
+ Size = MAP_APPFONT( 87, 60 );
+ HelpId = HID_DLG_QRY_RIGHT_TABLE ;
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+
+ FixedLine FL_INVOLVED_FIELDS
+ {
+ Pos = MAP_APPFONT ( 6 , 29 ) ;
+ Size = MAP_APPFONT ( 191 , 8 ) ;
+ Text [ en-US ] = "Fields involved";
+ };
+ };
+
+ FixedText ML_HELPTEXT
+ {
+ Pos = MAP_APPFONT ( 12 , 159 ) ;
+ Size = MAP_APPFONT ( 179 , 49 ) ;
+ UniqueId = HID_DLG_QRY_HELPTEXT ;
+ SVLook = TRUE;
+ WordBreak = TRUE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 206 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 206 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 206 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ Text [ en-US ] = "Join Properties";
+};
+
+String STR_JOIN_TYPE_HINT
+{
+ Text [ en-US ] = "Please note that some databases may not support this join type.";
+};
+
+String STR_QUERY_INNER_JOIN
+{
+ Text [ en-US ] = "Includes only records for which the contents of the related fields of both tables are identical.";
+};
+
+String STR_QUERY_LEFTRIGHT_JOIN
+{
+ Text [ en-US ] = "Contains ALL records from table '%1' but only records from table '%2' where the values in the related fields are matching.";
+};
+
+String STR_QUERY_FULL_JOIN
+{
+ Text [ en-US ] = "Contains ALL records from '%1' and from '%2'.";
+};
+
+String STR_QUERY_CROSS_JOIN
+{
+ Text [ en-US ] = "Contains the cartesian product of ALL records from '%1' and from '%2'.";
+};
+
+String STR_QUERY_NATURAL_JOIN
+{
+ Text [ en-US ] = "Contains only one column for each pair of equally-named columns from '%1' and from '%2'.";
+};
diff --git a/dbaccess/source/ui/querydesign/queryview.cxx b/dbaccess/source/ui/querydesign/queryview.cxx
new file mode 100644
index 000000000000..dea455795484
--- /dev/null
+++ b/dbaccess/source/ui/querydesign/queryview.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "queryview.hxx"
+#include "dbu_qry.hrc"
+#include "querycontroller.hxx"
+
+
+using namespace dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+DBG_NAME(OQueryView)
+// -------------------------------------------------------------------------
+OQueryView::OQueryView(Window* _pParent, OQueryController& _rController,const Reference< XMultiServiceFactory >& _rFactory)
+ :OJoinDesignView( _pParent, _rController, _rFactory )
+{
+ DBG_CTOR(OQueryView,NULL);
+
+}
+// -----------------------------------------------------------------------------
+OQueryView::~OQueryView()
+{
+
+ DBG_DTOR(OQueryView,NULL);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.cxx b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
new file mode 100644
index 000000000000..9cc6a42b4fe8
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RTableConnection.hxx"
+#include <tools/debug.hxx>
+#include "RelationTableView.hxx"
+#include <vcl/svapp.hxx>
+#include "ConnectionLine.hxx"
+
+using namespace dbaui;
+//========================================================================
+// class ORelationTableConnection
+//========================================================================
+DBG_NAME(ORelationTableConnection)
+//------------------------------------------------------------------------
+ORelationTableConnection::ORelationTableConnection( ORelationTableView* pContainer,
+ const TTableConnectionData::value_type& pTabConnData )
+ :OTableConnection( pContainer, pTabConnData )
+{
+ DBG_CTOR(ORelationTableConnection,NULL);
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnection::ORelationTableConnection( const ORelationTableConnection& rConn )
+ : OTableConnection( rConn )
+{
+ DBG_CTOR(ORelationTableConnection,NULL);
+ // keine eigenen Members, also reicht die Basisklassenfunktionalitaet
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnection::~ORelationTableConnection()
+{
+ DBG_DTOR(ORelationTableConnection,NULL);
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnection& ORelationTableConnection::operator=( const ORelationTableConnection& rConn )
+{
+ DBG_CHKTHIS(ORelationTableConnection,NULL);
+ // nicht dass es was aendern wuerde, da die Basisklasse das auch testet und ich keine eigenen Members zu kopieren habe
+ if (&rConn == this)
+ return *this;
+
+ OTableConnection::operator=( rConn );
+ return *this;
+}
+
+
+//------------------------------------------------------------------------
+void ORelationTableConnection::Draw( const Rectangle& rRect )
+{
+ DBG_CHKTHIS(ORelationTableConnection,NULL);
+ OTableConnection::Draw( rRect );
+ ORelationTableConnectionData* pData = static_cast< ORelationTableConnectionData* >(GetData().get());
+ if ( pData && (pData->GetCardinality() == CARDINAL_UNDEFINED) )
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Linien nach oberster Linie durchsuchen
+ Rectangle aBoundingRect;
+ long nTop = GetBoundingRect().Bottom();
+ long nTemp;
+
+ const OConnectionLine* pTopLine = NULL;
+ const ::std::vector<OConnectionLine*>* pConnLineList = GetConnLineList();
+ ::std::vector<OConnectionLine*>::const_iterator aIter = pConnLineList->begin();
+ ::std::vector<OConnectionLine*>::const_iterator aEnd = pConnLineList->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if( (*aIter)->IsValid() )
+ {
+ aBoundingRect = (*aIter)->GetBoundingRect();
+ nTemp = aBoundingRect.Top();
+ if( nTemp<nTop )
+ {
+ nTop = nTemp;
+ pTopLine = (*aIter);
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Kardinalitaet antragen
+ if( !pTopLine )
+ return;
+
+ Rectangle aSourcePos = pTopLine->GetSourceTextPos();
+ Rectangle aDestPos = pTopLine->GetDestTextPos();
+
+ String aSourceText;
+ String aDestText;
+
+ switch( pData->GetCardinality() )
+ {
+ case CARDINAL_ONE_MANY:
+ aSourceText ='1';
+ aDestText ='n';
+ break;
+
+ case CARDINAL_MANY_ONE:
+ aSourceText ='n';
+ aDestText ='1';
+ break;
+
+ case CARDINAL_ONE_ONE:
+ aSourceText ='1';
+ aDestText ='1';
+ break;
+ }
+
+ if (IsSelected())
+ GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
+ else
+ GetParent()->SetTextColor(Application::GetSettings().GetStyleSettings().GetWindowTextColor());
+
+
+ GetParent()->DrawText( aSourcePos, aSourceText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
+ GetParent()->DrawText( aDestPos, aDestText, TEXT_DRAW_CLIP | TEXT_DRAW_CENTER | TEXT_DRAW_BOTTOM);
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RTableConnection.hxx b/dbaccess/source/ui/relationdesign/RTableConnection.hxx
new file mode 100644
index 000000000000..c9be2d46cc9e
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnection.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RTABLECONNECTION_HXX
+#define DBAUI_RTABLECONNECTION_HXX
+
+#include "TableConnection.hxx"
+#include "RTableConnectionData.hxx"
+
+namespace dbaui
+{
+ class ORelationTableView;
+ //==================================================================
+ class ORelationTableConnection : public OTableConnection
+ {
+ public:
+ ORelationTableConnection( ORelationTableView* pContainer, const TTableConnectionData::value_type& pTabConnData );
+ ORelationTableConnection( const ORelationTableConnection& rConn );
+ // wichtiger Kommentar zum CopyConstructor siehe OTableConnection(const OTableConnection&)
+ virtual ~ORelationTableConnection();
+
+ ORelationTableConnection& operator=( const ORelationTableConnection& rConn );
+
+ virtual void Draw( const Rectangle& rRect );
+ using OTableConnection::Draw;
+ };
+}
+#endif // DBAUI_RTABLECONNECTION_HXX
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
new file mode 100644
index 000000000000..713f2677b255
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -0,0 +1,466 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RTableConnectionData.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "dbustrings.hrc"
+#include "dbu_rel.hrc"
+#include "UITools.hxx"
+#include "moduledbu.hxx"
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+DBG_NAME(ORelationTableConnectionData)
+//========================================================================
+// class ORelationTableConnectionData
+//========================================================================
+//------------------------------------------------------------------------
+ORelationTableConnectionData::ORelationTableConnectionData()
+ :OTableConnectionData()
+ ,m_nUpdateRules(KeyRule::NO_ACTION)
+ ,m_nDeleteRules(KeyRule::NO_ACTION)
+ ,m_nCardinality(CARDINAL_UNDEFINED)
+{
+ DBG_CTOR(ORelationTableConnectionData,NULL);
+}
+//------------------------------------------------------------------------
+ORelationTableConnectionData::ORelationTableConnectionData( const TTableWindowData::value_type& _pReferencingTable,
+ const TTableWindowData::value_type& _pReferencedTable,
+ const ::rtl::OUString& rConnName )
+ :OTableConnectionData( _pReferencingTable, _pReferencedTable )
+ ,m_nUpdateRules(KeyRule::NO_ACTION)
+ ,m_nDeleteRules(KeyRule::NO_ACTION)
+ ,m_nCardinality(CARDINAL_UNDEFINED)
+{
+ DBG_CTOR(ORelationTableConnectionData,NULL);
+ m_aConnName = rConnName;
+
+ if ( m_aConnName.Len() )
+ SetCardinality();
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnectionData::ORelationTableConnectionData( const ORelationTableConnectionData& rConnData )
+ :OTableConnectionData( rConnData )
+{
+ DBG_CTOR(ORelationTableConnectionData,NULL);
+ *this = rConnData;
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnectionData::~ORelationTableConnectionData()
+{
+ DBG_DTOR(ORelationTableConnectionData,NULL);
+}
+
+//------------------------------------------------------------------------
+sal_Bool ORelationTableConnectionData::DropRelation()
+{
+ DBG_CHKTHIS(ORelationTableConnectionData,NULL);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ////////////////////////////////////////////////////////////
+ // Relation loeschen
+ Reference< XIndexAccess> xKeys = getReferencingTable()->getKeys();
+ if( m_aConnName.Len() && xKeys.is() )
+ {
+ const sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i = 0;i < nCount;++i)
+ {
+ Reference< XPropertySet> xKey(xKeys->getByIndex(i),UNO_QUERY);
+ OSL_ENSURE(xKey.is(),"Key is not valid!");
+ if(xKey.is())
+ {
+ ::rtl::OUString sName;
+ xKey->getPropertyValue(PROPERTY_NAME) >>= sName;
+ if(String(sName) == m_aConnName)
+ {
+ Reference< XDrop> xDrop(xKeys,UNO_QUERY);
+ OSL_ENSURE(xDrop.is(),"can't drop key because we haven't a drop interface!");
+ if(xDrop.is())
+ xDrop->dropByIndex(i);
+ break;
+ }
+ }
+ }
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+void ORelationTableConnectionData::ChangeOrientation()
+{
+ DBG_CHKTHIS(ORelationTableConnectionData,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Source- und DestFieldName der Linien austauschen
+ ::rtl::OUString sTempString;
+ OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
+ OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ sTempString = (*aIter)->GetSourceFieldName();
+ (*aIter)->SetSourceFieldName( (*aIter)->GetDestFieldName() );
+ (*aIter)->SetDestFieldName( sTempString );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Member anpassen
+ TTableWindowData::value_type pTemp = m_pReferencingTable;
+ m_pReferencingTable = m_pReferencedTable;
+ m_pReferencedTable = pTemp;
+}
+
+//------------------------------------------------------------------------
+void ORelationTableConnectionData::SetCardinality()
+{
+ DBG_CHKTHIS(ORelationTableConnectionData,NULL);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nCardinality = CARDINAL_UNDEFINED;
+
+ if( IsSourcePrimKey() )
+ {
+ if( IsDestPrimKey() )
+ m_nCardinality = CARDINAL_ONE_ONE;
+ else
+ m_nCardinality = CARDINAL_ONE_MANY;
+ }
+
+ if( IsDestPrimKey() )
+ {
+ if( !IsSourcePrimKey() )
+ m_nCardinality = CARDINAL_MANY_ONE;
+ }
+
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORelationTableConnectionData::checkPrimaryKey(const Reference< XPropertySet>& i_xTable,EConnectionSide _eEConnectionSide) const
+{
+ // check if Table has the primary key column dependig on _eEConnectionSide
+ sal_uInt16 nPrimKeysCount = 0,
+ nValidLinesCount = 0;
+ const Reference< XNameAccess> xKeyColumns = dbtools::getPrimaryKeyColumns_throw(i_xTable);
+ if ( xKeyColumns.is() )
+ {
+ Sequence< ::rtl::OUString> aKeyColumns = xKeyColumns->getElementNames();
+ const ::rtl::OUString* pKeyIter = aKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength();
+
+ for(;pKeyIter != pKeyEnd;++pKeyIter)
+ {
+ OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin();
+ OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ ++nValidLinesCount;
+ if ( (*aIter)->GetFieldName(_eEConnectionSide) == *pKeyIter )
+ {
+ ++nPrimKeysCount;
+ break;
+ }
+ }
+ }
+ if ( nPrimKeysCount != aKeyColumns.getLength() )
+ return sal_False;
+ }
+ if ( !nPrimKeysCount || nPrimKeysCount != nValidLinesCount )
+ return sal_False;
+
+ return sal_True;
+}
+//------------------------------------------------------------------------
+sal_Bool ORelationTableConnectionData::IsConnectionPossible()
+{
+ DBG_CHKTHIS(ORelationTableConnectionData,NULL);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn die SourceFelder ein PrimKey sind, ist nur die Orientierung falsch
+ if ( IsSourcePrimKey() && !IsDestPrimKey() )
+ ChangeOrientation();
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef ORelationTableConnectionData::CreateLineDataObj()
+{
+ return new OConnectionLineData();
+}
+
+//------------------------------------------------------------------------
+OConnectionLineDataRef ORelationTableConnectionData::CreateLineDataObj( const OConnectionLineData& rConnLineData )
+{
+ return new OConnectionLineData( rConnLineData );
+}
+
+//------------------------------------------------------------------------
+void ORelationTableConnectionData::CopyFrom(const OTableConnectionData& rSource)
+{
+ // wie in der Basisklasse zurueckziehen auf das (nicht-virtuelle) operator=
+ *this = *static_cast<const ORelationTableConnectionData*>(&rSource);
+}
+
+//------------------------------------------------------------------------
+ORelationTableConnectionData& ORelationTableConnectionData::operator=( const ORelationTableConnectionData& rConnData )
+{
+ if (&rConnData == this)
+ return *this;
+
+ OTableConnectionData::operator=( rConnData );
+ m_nUpdateRules = rConnData.GetUpdateRules();
+ m_nDeleteRules = rConnData.GetDeleteRules();
+ m_nCardinality = rConnData.GetCardinality();
+
+ return *this;
+}
+namespace dbaui
+{
+//-------------------------------------------------------------------------
+bool operator==(const ORelationTableConnectionData& lhs, const ORelationTableConnectionData& rhs)
+{
+ bool bEqual = (lhs.m_nUpdateRules == rhs.m_nUpdateRules)
+ && (lhs.m_nDeleteRules == rhs.m_nDeleteRules)
+ && (lhs.m_nCardinality == rhs.m_nCardinality)
+ && (lhs.getReferencingTable() == rhs.getReferencingTable())
+ && (lhs.getReferencedTable() == rhs.getReferencedTable())
+ && (lhs.m_aConnName == rhs.m_aConnName)
+ && (lhs.m_vConnLineData.size() == rhs.m_vConnLineData.size());
+
+ if ( bEqual )
+ {
+ std::vector< OConnectionLineDataRef >::const_iterator aIter = lhs.m_vConnLineData.begin();
+ std::vector< OConnectionLineDataRef >::const_iterator aEnd = lhs.m_vConnLineData.end();
+ for (sal_Int32 i = 0; aIter != aEnd; ++aIter,++i)
+ {
+ if ( *(rhs.m_vConnLineData[i]) != **aIter )
+ break;
+ }
+ bEqual = aIter == aEnd;
+ }
+ return bEqual;
+}
+}
+//------------------------------------------------------------------------
+sal_Bool ORelationTableConnectionData::Update()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ////////////////////////////////////////////////////////////
+ // Alte Relation loeschen
+ {
+ DropRelation();
+ if( !IsConnectionPossible() )
+ return sal_False;
+ }
+
+ // reassign the keys because the orientaion could be changed
+ Reference<XPropertySet> xTableProp(getReferencingTable()->getTable());
+ Reference< XIndexAccess> xKeys ( getReferencingTable()->getKeys());
+
+ if ( !xKeys.is() )
+ return sal_False;
+ ////////////////////////////////////////////////////////////
+ // Neue Relation erzeugen
+ Reference<XDataDescriptorFactory> xKeyFactory(xKeys,UNO_QUERY);
+ OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
+ Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
+ OSL_ENSURE(xKey.is(),"Key is null!");
+ if ( xKey.is() && xTableProp.is() )
+ {
+ // build a foreign key name
+ ::rtl::OUString sSourceName;
+ xTableProp->getPropertyValue(PROPERTY_NAME) >>= sSourceName;
+ ::rtl::OUString sKeyName = sSourceName;
+ sKeyName += getReferencedTable()->GetTableName();
+
+ xKey->setPropertyValue(PROPERTY_NAME,makeAny(sKeyName));
+ xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::FOREIGN));
+ xKey->setPropertyValue(PROPERTY_REFERENCEDTABLE,makeAny(::rtl::OUString(getReferencedTable()->GetTableName())));
+ xKey->setPropertyValue(PROPERTY_UPDATERULE, makeAny(GetUpdateRules()));
+ xKey->setPropertyValue(PROPERTY_DELETERULE, makeAny(GetDeleteRules()));
+ }
+
+ Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
+ if ( xColSup.is() )
+ {
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+ Reference<XAppend> xColumnAppend(xColumns,UNO_QUERY);
+ if ( xColumnFactory.is() )
+ {
+ OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
+ OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if((*aIter)->GetSourceFieldName().getLength() && (*aIter)->GetDestFieldName().getLength())
+ {
+ Reference<XPropertySet> xColumn;
+ xColumn = xColumnFactory->createDataDescriptor();
+ if ( xColumn.is() )
+ {
+ xColumn->setPropertyValue(PROPERTY_NAME,makeAny((*aIter)->GetSourceFieldName()));
+ xColumn->setPropertyValue(PROPERTY_RELATEDCOLUMN,makeAny((*aIter)->GetDestFieldName()));
+ xColumnAppend->appendByDescriptor(xColumn);
+ }
+ }
+ }
+
+ if ( xColumns->hasElements() )
+ xAppend->appendByDescriptor(xKey);
+ }
+ // to get the key we have to reget it because after append it is no longer valid
+ }
+
+ // get the name of foreign key // search for columns
+ m_aConnName = ::rtl::OUString();
+xKey.clear();
+ bool bDropRelation = false;
+ for(sal_Int32 i=0;i<xKeys->getCount();++i)
+ {
+ xKeys->getByIndex(i) >>= xKey;
+ OSL_ENSURE(xKey.is(),"Key is not valid!");
+ if ( xKey.is() )
+ {
+ sal_Int32 nType = 0;
+ xKey->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ ::rtl::OUString sReferencedTable;
+ xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
+ if ( sReferencedTable == ::rtl::OUString(getReferencedTable()->GetTableName()) )
+ {
+ xColSup.set(xKey,UNO_QUERY_THROW);
+ try
+ {
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+
+ Reference<XPropertySet> xColumn;
+ ::rtl::OUString sName,sRelatedColumn;
+ for ( ; pIter != pEnd ; ++pIter )
+ {
+ xColumn.set(xColumns->getByName(*pIter),UNO_QUERY_THROW);
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn;
+
+ OConnectionLineDataVec::iterator aIter = m_vConnLineData.begin();
+ OConnectionLineDataVec::iterator aEnd = m_vConnLineData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if( (*aIter)->GetSourceFieldName() == sName
+ && (*aIter)->GetDestFieldName() == sRelatedColumn )
+ {
+ break;
+ }
+ }
+ if ( aIter == m_vConnLineData.end() )
+ break;
+ }
+ if ( pIter == pEnd )
+ {
+ xKey->getPropertyValue(PROPERTY_NAME) >>= sName;
+ m_aConnName = sName;
+ bDropRelation = aNames.getLength() == 0; // the key contains no column, so it isn't valid and we have to drop it
+ //here we already know our column structure so we don't have to recreate the table connection data
+ xColSup.clear();
+ break;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ xKey.clear();
+ }
+ if ( bDropRelation )
+ {
+ DropRelation();
+ String sError(ModuleRes(STR_QUERY_REL_COULD_NOT_CREATE));
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+
+ // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated
+ if ( xColSup.is() )
+ {
+ OConnectionLineDataVec().swap(m_vConnLineData);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+
+ m_vConnLineData.reserve( aNames.getLength() );
+ Reference<XPropertySet> xColumn;
+ ::rtl::OUString sName,sRelatedColumn;
+
+ for(;pIter != pEnd;++pIter)
+ {
+ xColumns->getByName(*pIter) >>= xColumn;
+ if ( xColumn.is() )
+ {
+ OConnectionLineDataRef pNewData = CreateLineDataObj();
+
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedColumn;
+
+ pNewData->SetSourceFieldName(sName);
+ pNewData->SetDestFieldName(sRelatedColumn);
+ m_vConnLineData.push_back(pNewData);
+ }
+ }
+ }
+ // NOTE : the caller is responsible for updating any other objects referencing the old LineDatas (for instance a ConnLine)
+
+ ////////////////////////////////////////////////////////////
+ // Kardinalitaet bestimmen
+ SetCardinality();
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RTableWindow.hxx b/dbaccess/source/ui/relationdesign/RTableWindow.hxx
new file mode 100644
index 000000000000..12c7b51e5b42
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RTableWindow.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_RELTABLEWINDOW_HXX
+#define DBAUI_RELTABLEWINDOW_HXX
+
+#include "TableWindow.hxx"
+
+namespace dbaui
+{
+ class ORelationTableWindow : public OTableWindow
+ {
+ public:
+ ORelationTableWindow( Window* pParent,const TTableWindowData::value_type& pTabWinData)
+ : OTableWindow(pParent, pTabWinData) {}
+
+ /** returns the name which should be used when displaying join or relations
+ @return
+ The composed name or the window name.
+ */
+ virtual ::rtl::OUString GetName() const { return GetComposedName(); }
+ };
+}
+#endif //DBAUI_RELTABLEWINDOW_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RelationController.cxx b/dbaccess/source/ui/relationdesign/RelationController.cxx
new file mode 100644
index 000000000000..9af062981e78
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationController.cxx
@@ -0,0 +1,612 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include <sfx2/sfxsids.hrc>
+#include "dbu_rel.hrc"
+#include <vcl/svapp.hxx>
+#include "browserids.hxx"
+#include <comphelper/types.hxx>
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <comphelper/streamsection.hxx>
+#include <comphelper/basicio.hxx>
+#include <comphelper/seqstream.hxx>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include "sqlmessage.hxx"
+#include "RelationController.hxx"
+#include <vcl/msgbox.hxx>
+#include "TableWindowData.hxx"
+#include "dbustrings.hrc"
+#include "UITools.hxx"
+#include "RTableConnectionData.hxx"
+#include "RelationTableView.hxx"
+#include "RelationDesignView.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/waitobj.hxx>
+#include <osl/thread.hxx>
+#include <osl/mutex.hxx>
+
+
+#define MAX_THREADS 10
+
+extern "C" void SAL_CALL createRegistryInfo_ORelationControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ORelationController > aAutoRegistration;
+}
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::util;
+using namespace ::dbtools;
+using namespace ::dbaui;
+using namespace ::comphelper;
+using namespace ::osl;
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ORelationController::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString ORelationController::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ORelationDesign"));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> ORelationController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RelationDesign"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL ORelationController::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ORelationController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new ORelationController(_rxFactory));
+}
+DBG_NAME(ORelationController);
+// -----------------------------------------------------------------------------
+ORelationController::ORelationController(const Reference< XMultiServiceFactory >& _rM)
+ : OJoinController(_rM)
+ ,m_nThreadEvent(0)
+ ,m_bRelationsPossible(sal_True)
+{
+ DBG_CTOR(ORelationController,NULL);
+ InvalidateAll();
+}
+// -----------------------------------------------------------------------------
+ORelationController::~ORelationController()
+{
+ DBG_DTOR(ORelationController,NULL);
+}
+// -----------------------------------------------------------------------------
+FeatureState ORelationController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ aReturn.bEnabled = m_bRelationsPossible;
+ switch (_nId)
+ {
+ case SID_RELATION_ADD_RELATION:
+ aReturn.bEnabled = !m_vTableData.empty() && isConnected() && isEditable();
+ aReturn.bChecked = false;
+ break;
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = haveDataSource() && impl_isModified();
+ break;
+ default:
+ aReturn = OJoinController::GetState(_nId);
+ break;
+ }
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+void ORelationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch(_nId)
+ {
+ case ID_BROWSER_SAVEDOC:
+ {
+ OSL_ENSURE(isEditable(),"Slot ID_BROWSER_SAVEDOC should not be enabled!");
+ if(!::dbaui::checkDataSourceAvailable(::comphelper::getString(getDataSource()->getPropertyValue(PROPERTY_NAME)),getORB()))
+ {
+ String aMessage(ModuleRes(STR_DATASOURCE_DELETED));
+ OSQLWarningBox( getView(), aMessage ).Execute();
+ }
+ else
+ {
+ // now we save the layout information
+ // create the output stream
+ try
+ {
+ if ( haveDataSource() && getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION) )
+ {
+ ::comphelper::NamedValueCollection aWindowsData;
+ saveTableWindows( aWindowsData );
+ getDataSource()->setPropertyValue( PROPERTY_LAYOUTINFORMATION, makeAny( aWindowsData.getPropertyValues() ) );
+ setModified(sal_False);
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ break;
+ case SID_RELATION_ADD_RELATION:
+ static_cast<ORelationTableView*>(static_cast<ORelationDesignView*>( getView() )->getTableView())->AddNewRelation();
+ break;
+ default:
+ OJoinController::Execute(_nId,aArgs);
+ return;
+ }
+ InvalidateFeature(_nId);
+}
+// -----------------------------------------------------------------------------
+void ORelationController::impl_initialize()
+{
+ OJoinController::impl_initialize();
+
+ if( !getSdbMetaData().supportsRelations() )
+ {// check if this database supports relations
+
+ setEditable(sal_False);
+ m_bRelationsPossible = sal_False;
+ {
+ String sTitle(ModuleRes(STR_RELATIONDESIGN));
+ sTitle.Erase(0,3);
+ OSQLMessageBox aDlg(NULL,sTitle,ModuleRes(STR_RELATIONDESIGN_NOT_AVAILABLE));
+ aDlg.Execute();
+ }
+ disconnect();
+ throw SQLException();
+ }
+
+ if(!m_bRelationsPossible)
+ InvalidateAll();
+
+ // we need a datasource
+ OSL_ENSURE(haveDataSource(),"ORelationController::initialize: need a datasource!");
+
+ Reference<XTablesSupplier> xSup(getConnection(),UNO_QUERY);
+ OSL_ENSURE(xSup.is(),"Connection isn't a XTablesSupplier!");
+ if(xSup.is())
+ m_xTables = xSup->getTables();
+ // load the layoutInformation
+ loadLayoutInformation();
+ try
+ {
+ loadData();
+ if ( !m_nThreadEvent )
+ Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished));
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ORelationController::getPrivateTitle( ) const
+{
+ ::rtl::OUString sName = getDataSourceName();
+ return ::dbaui::getStrippedDatabaseName(getDataSource(),sName);
+}
+// -----------------------------------------------------------------------------
+sal_Bool ORelationController::Construct(Window* pParent)
+{
+ setView( * new ORelationDesignView( pParent, *this, getORB() ) );
+ OJoinController::Construct(pParent);
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+short ORelationController::saveModified()
+{
+ short nSaved = RET_YES;
+ if(haveDataSource() && isModified())
+ {
+ QueryBox aQry(getView(), ModuleRes(RELATION_DESIGN_SAVEMODIFIED));
+ nSaved = aQry.Execute();
+ if(nSaved == RET_YES)
+ Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
+ }
+ return nSaved;
+}
+// -----------------------------------------------------------------------------
+void ORelationController::describeSupportedFeatures()
+{
+ OJoinController::describeSupportedFeatures();
+ implDescribeSupportedFeature( ".uno:DBAddRelation", SID_RELATION_ADD_RELATION, CommandGroup::EDIT );
+}
+namespace
+{
+ class RelationLoader : public ::osl::Thread
+ {
+ DECLARE_STL_MAP(::rtl::OUString,::boost::shared_ptr<OTableWindowData>,::comphelper::UStringMixLess,TTableDataHelper);
+ TTableDataHelper m_aTableData;
+ TTableConnectionData m_vTableConnectionData;
+ const Sequence< ::rtl::OUString> m_aTableList;
+ ORelationController* m_pParent;
+ const Reference< XDatabaseMetaData> m_xMetaData;
+ const Reference< XNameAccess > m_xTables;
+ const sal_Int32 m_nStartIndex;
+ const sal_Int32 m_nEndIndex;
+
+ public:
+ RelationLoader(ORelationController* _pParent
+ ,const Reference< XDatabaseMetaData>& _xMetaData
+ ,const Reference< XNameAccess >& _xTables
+ ,const Sequence< ::rtl::OUString>& _aTableList
+ ,const sal_Int32 _nStartIndex
+ ,const sal_Int32 _nEndIndex)
+ :m_aTableData(_xMetaData.is() && _xMetaData->supportsMixedCaseQuotedIdentifiers())
+ ,m_aTableList(_aTableList)
+ ,m_pParent(_pParent)
+ ,m_xMetaData(_xMetaData)
+ ,m_xTables(_xTables)
+ ,m_nStartIndex(_nStartIndex)
+ ,m_nEndIndex(_nEndIndex)
+ {
+ }
+
+ /// Working method which should be overridden.
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+ protected:
+ virtual ~RelationLoader(){}
+
+ void loadTableData(const Any& _aTable);
+ };
+
+ void SAL_CALL RelationLoader::run()
+ {
+ const ::rtl::OUString* pIter = m_aTableList.getConstArray() + m_nStartIndex;
+ for(sal_Int32 i = m_nStartIndex; i < m_nEndIndex;++i,++pIter)
+ {
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ *pIter,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+
+ try
+ {
+ Reference< XResultSet > xResult = m_xMetaData->getImportedKeys(aCatalog, sSchema,sTable);
+ if ( xResult.is() && xResult->next() )
+ {
+ ::comphelper::disposeComponent(xResult);
+ loadTableData(m_xTables->getByName(*pIter));
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ void SAL_CALL RelationLoader::onTerminated()
+ {
+ m_pParent->mergeData(m_vTableConnectionData);
+ delete this;
+ }
+
+ void RelationLoader::loadTableData(const Any& _aTable)
+ {
+ Reference<XPropertySet> xTableProp(_aTable,UNO_QUERY);
+ const ::rtl::OUString sSourceName = ::dbtools::composeTableName( m_xMetaData, xTableProp, ::dbtools::eInTableDefinitions, false, false, false );
+ TTableDataHelper::iterator aFind = m_aTableData.find(sSourceName);
+ if ( aFind == m_aTableData.end() )
+ {
+ aFind = m_aTableData.insert(TTableDataHelper::value_type(sSourceName,::boost::shared_ptr<OTableWindowData>(new OTableWindowData(xTableProp,sSourceName, sSourceName)))).first;
+ aFind->second->ShowAll(sal_False);
+ }
+ TTableWindowData::value_type pReferencingTable = aFind->second;
+ Reference<XIndexAccess> xKeys = pReferencingTable->getKeys();
+ const Reference<XKeysSupplier> xKeySup(xTableProp,UNO_QUERY);
+
+ if ( !xKeys.is() && xKeySup.is() )
+ {
+ xKeys = xKeySup->getKeys();
+ }
+
+ if ( xKeys.is() )
+ {
+ Reference<XPropertySet> xKey;
+ const sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i = 0 ; i < nCount ; ++i)
+ {
+ xKeys->getByIndex(i) >>= xKey;
+ sal_Int32 nKeyType = 0;
+ xKey->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if ( KeyType::FOREIGN == nKeyType )
+ {
+ ::rtl::OUString sReferencedTable;
+ xKey->getPropertyValue(PROPERTY_REFERENCEDTABLE) >>= sReferencedTable;
+ //////////////////////////////////////////////////////////////////////
+ // insert windows
+ TTableDataHelper::iterator aRefFind = m_aTableData.find(sReferencedTable);
+ if ( aRefFind == m_aTableData.end() )
+ {
+ if ( m_xTables->hasByName(sReferencedTable) )
+ {
+ Reference<XPropertySet> xReferencedTable(m_xTables->getByName(sReferencedTable),UNO_QUERY);
+ aRefFind = m_aTableData.insert(TTableDataHelper::value_type(sReferencedTable,::boost::shared_ptr<OTableWindowData>(new OTableWindowData(xReferencedTable,sReferencedTable, sReferencedTable)))).first;
+ aRefFind->second->ShowAll(sal_False);
+ }
+ else
+ continue; // table name could not be found so we do not show this table releation
+ }
+ TTableWindowData::value_type pReferencedTable = aRefFind->second;
+
+ ::rtl::OUString sKeyName;
+ xKey->getPropertyValue(PROPERTY_NAME) >>= sKeyName;
+ //////////////////////////////////////////////////////////////////////
+ // insert connection
+ ORelationTableConnectionData* pTabConnData = new ORelationTableConnectionData( pReferencingTable, pReferencedTable, sKeyName );
+ m_vTableConnectionData.push_back(TTableConnectionData::value_type(pTabConnData));
+ //////////////////////////////////////////////////////////////////////
+ // insert columns
+ const Reference<XColumnsSupplier> xColsSup(xKey,UNO_QUERY);
+ OSL_ENSURE(xColsSup.is(),"Key is no XColumnsSupplier!");
+ const Reference<XNameAccess> xColumns = xColsSup->getColumns();
+ const Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ ::rtl::OUString sColumnName,sRelatedName;
+ for(sal_uInt16 j=0;pIter != pEnd;++pIter,++j)
+ {
+ const Reference<XPropertySet> xPropSet(xColumns->getByName(*pIter),UNO_QUERY);
+ OSL_ENSURE(xPropSet.is(),"Invalid column found in KeyColumns!");
+ if ( xPropSet.is() )
+ {
+ xPropSet->getPropertyValue(PROPERTY_NAME) >>= sColumnName;
+ xPropSet->getPropertyValue(PROPERTY_RELATEDCOLUMN) >>= sRelatedName;
+ }
+ pTabConnData->SetConnLine( j, sColumnName, sRelatedName );
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Update/Del-Flags setzen
+ sal_Int32 nUpdateRule = 0;
+ sal_Int32 nDeleteRule = 0;
+ xKey->getPropertyValue(PROPERTY_UPDATERULE) >>= nUpdateRule;
+ xKey->getPropertyValue(PROPERTY_DELETERULE) >>= nDeleteRule;
+
+ pTabConnData->SetUpdateRules( nUpdateRule );
+ pTabConnData->SetDeleteRules( nDeleteRule );
+
+ //////////////////////////////////////////////////////////////////////
+ // Kardinalitaet setzen
+ pTabConnData->SetCardinality();
+ }
+ }
+ }
+ }
+}
+
+void ORelationController::mergeData(const TTableConnectionData& _aConnectionData)
+{
+ ::osl::MutexGuard aGuard( getMutex() );
+
+ ::std::copy( _aConnectionData.begin(), _aConnectionData.end(), ::std::back_inserter( m_vTableConnectionData ));
+ //const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData();
+ const sal_Bool bCase = sal_True;//xMetaData.is() && xMetaData->supportsMixedCaseQuotedIdentifiers();
+ // here we are finished, so we can collect the table from connection data
+ TTableConnectionData::iterator aConnDataIter = m_vTableConnectionData.begin();
+ TTableConnectionData::iterator aConnDataEnd = m_vTableConnectionData.end();
+ for(;aConnDataIter != aConnDataEnd;++aConnDataIter)
+ {
+ if ( !existsTable((*aConnDataIter)->getReferencingTable()->GetComposedName(),bCase) )
+ {
+ m_vTableData.push_back((*aConnDataIter)->getReferencingTable());
+ }
+ if ( !existsTable((*aConnDataIter)->getReferencedTable()->GetComposedName(),bCase) )
+ {
+ m_vTableData.push_back((*aConnDataIter)->getReferencedTable());
+ }
+ }
+ if ( m_nThreadEvent )
+ {
+ --m_nThreadEvent;
+ if ( !m_nThreadEvent )
+ Application::PostUserEvent(LINK(this, ORelationController, OnThreadFinished));
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( ORelationController, OnThreadFinished, void*, /*NOTINTERESTEDIN*/ )
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ try
+ {
+ getView()->initialize(); // show the windows and fill with our informations
+ getView()->Invalidate(INVALIDATE_NOERASE);
+ ClearUndoManager();
+ setModified(sal_False); // and we are not modified yet
+
+ if(m_vTableData.empty())
+ Execute(ID_BROWSER_ADDTABLE,Sequence<PropertyValue>());
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pWaitObject.reset();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void ORelationController::loadData()
+{
+ m_pWaitObject.reset( new WaitObject(getView()) );
+ try
+ {
+ if ( !m_xTables.is() )
+ return;
+ DatabaseMetaData aMeta(getConnection());
+ // this may take some time
+ const Reference< XDatabaseMetaData> xMetaData = getConnection()->getMetaData();
+ const Sequence< ::rtl::OUString> aNames = m_xTables->getElementNames();
+ const sal_Int32 nCount = aNames.getLength();
+ if ( aMeta.supportsThreads() )
+ {
+ const sal_Int32 nMaxElements = (nCount / MAX_THREADS) +1;
+ sal_Int32 nStart = 0,nEnd = ::std::min(nMaxElements,nCount);
+ while(nStart != nEnd)
+ {
+ ++m_nThreadEvent;
+ RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,nStart,nEnd);
+ pThread->createSuspended();
+ pThread->setPriority(osl_Thread_PriorityBelowNormal);
+ pThread->resume();
+ nStart = nEnd;
+ nEnd += nMaxElements;
+ nEnd = ::std::min(nEnd,nCount);
+ }
+ }
+ else
+ {
+ RelationLoader* pThread = new RelationLoader(this,xMetaData,m_xTables,aNames,0,nCount);
+ pThread->run();
+ pThread->onTerminated();
+ }
+ }
+ catch(SQLException& e)
+ {
+ showError(SQLExceptionInfo(e));
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+TTableWindowData::value_type ORelationController::existsTable(const ::rtl::OUString& _rComposedTableName,sal_Bool _bCase) const
+{
+ ::comphelper::UStringMixEqual bCase(_bCase);
+ TTableWindowData::const_iterator aIter = m_vTableData.begin();
+ TTableWindowData::const_iterator aEnd = m_vTableData.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if(bCase((*aIter)->GetComposedName(),_rComposedTableName))
+ break;
+ }
+ return ( aIter != aEnd) ? *aIter : TTableWindowData::value_type();
+}
+// -----------------------------------------------------------------------------
+void ORelationController::loadLayoutInformation()
+{
+ try
+ {
+ OSL_ENSURE(haveDataSource(),"We need a datasource from our connection!");
+ if ( haveDataSource() )
+ {
+ if ( getDataSource()->getPropertySetInfo()->hasPropertyByName(PROPERTY_LAYOUTINFORMATION) )
+ {
+ Sequence<PropertyValue> aWindows;
+ getDataSource()->getPropertyValue(PROPERTY_LAYOUTINFORMATION) >>= aWindows;
+ loadTableWindows(aWindows);
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void ORelationController::reset()
+{
+ loadLayoutInformation();
+ ODataView* pView = getView();
+ OSL_ENSURE(pView,"No current view!");
+ if(pView)
+ {
+ pView->initialize();
+ pView->Invalidate(INVALIDATE_NOERASE);
+ }
+}
+
+// -----------------------------------------------------------------------------
+bool ORelationController::allowViews() const
+{
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+bool ORelationController::allowQueries() const
+{
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RelationDesignView.cxx b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
new file mode 100644
index 000000000000..4030abfb46a2
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationDesignView.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RelationDesignView.hxx"
+#include "RelationTableView.hxx"
+#include "RelationController.hxx"
+#include <svl/undo.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include "browserids.hxx"
+#include "dbu_rel.hrc"
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "RTableConnection.hxx"
+#include "ConnectionLine.hxx"
+#include "ConnectionLineData.hxx"
+#include "RTableConnectionData.hxx"
+#include "dbustrings.hrc"
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+#include <tools/debug.hxx>
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+DBG_NAME(ORelationDesignView)
+ORelationDesignView::ORelationDesignView(Window* _pParent, ORelationController& _rController,const Reference< XMultiServiceFactory >& _rFactory)
+ :OJoinDesignView( _pParent, _rController, _rFactory )
+{
+ DBG_CTOR(ORelationDesignView,NULL);
+}
+// -----------------------------------------------------------------------------
+ORelationDesignView::~ORelationDesignView()
+{
+ DBG_DTOR(ORelationDesignView,NULL);
+}
+// -------------------------------------------------------------------------
+void ORelationDesignView::Construct()
+{
+ m_pTableView = new ORelationTableView(m_pScrollWindow,this);
+ OJoinDesignView::Construct();
+}
+// -----------------------------------------------------------------------------
+void ORelationDesignView::initialize()
+{
+ m_pTableView->clearLayoutInformation();
+ m_pTableView->ReSync();
+
+ OJoinDesignView::initialize();
+}
+// -----------------------------------------------------------------------------
+long ORelationDesignView::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0L;
+ if(rNEvt.GetType() == EVENT_GETFOCUS)
+ {
+ if(!m_pTableView->HasChildPathFocus())
+ {
+ m_pTableView->GrabTabWinFocus();
+ nDone = 1L;
+ }
+ }
+ if(!nDone)
+ nDone = OJoinDesignView::PreNotify(rNEvt);
+ return nDone;
+}
+// -----------------------------------------------------------------------------
+void ORelationDesignView::GetFocus()
+{
+ OJoinDesignView::GetFocus();
+ if ( m_pTableView && m_pTableView->IsVisible() && !m_pTableView->GetTabWinMap()->empty() )
+ m_pTableView->GrabTabWinFocus();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/RelationTableView.cxx b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
new file mode 100644
index 000000000000..d334aa93b133
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/RelationTableView.cxx
@@ -0,0 +1,446 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "RelationTableView.hxx"
+#include "JoinExchange.hxx"
+#include <comphelper/extract.hxx>
+#include "browserids.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "dbustrings.hrc"
+#include <connectivity/dbtools.hxx>
+#include <comphelper/sequence.hxx>
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "RelationDesignView.hxx"
+#include "JoinController.hxx"
+#include "TableWindow.hxx"
+#include "TableWindowData.hxx"
+#include "RTableConnection.hxx"
+#include "RTableConnectionData.hxx"
+#include "RelationDlg.hxx"
+#include "sqlmessage.hxx"
+#include "dbu_rel.hrc"
+#include "UITools.hxx"
+#include <connectivity/dbexception.hxx>
+#include "RTableWindow.hxx"
+#include "JAccess.hxx"
+#include <svl/undo.hxx>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+
+using namespace dbaui;
+using namespace ::dbtools;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::accessibility;
+
+//==================================================================
+// class ORelationTableView
+//==================================================================
+DBG_NAME(ORelationTableView)
+//------------------------------------------------------------------------
+ORelationTableView::ORelationTableView( Window* pParent, ORelationDesignView* pView )
+ :OJoinTableView( pParent, pView )
+ , ::comphelper::OContainerListener(m_aMutex)
+ ,m_pExistingConnection(NULL)
+ ,m_bInRemove(false)
+
+{
+ DBG_CTOR(ORelationTableView,NULL);
+ SetHelpId(HID_CTL_RELATIONTAB);
+}
+
+//------------------------------------------------------------------------
+ORelationTableView::~ORelationTableView()
+{
+ DBG_DTOR(ORelationTableView,NULL);
+ if ( m_pContainerListener.is() )
+ m_pContainerListener->dispose();
+}
+
+//------------------------------------------------------------------------
+void ORelationTableView::ReSync()
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+ if ( !m_pContainerListener.is() )
+ {
+ Reference< XConnection> xConnection = m_pView->getController().getConnection();
+ Reference< XTablesSupplier > xTableSupp( xConnection, UNO_QUERY_THROW );
+ Reference< XNameAccess > xTables = xTableSupp->getTables();
+ Reference< XContainer> xContainer(xTables,uno::UNO_QUERY);
+ if ( xContainer.is() )
+ m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
+ }
+ // Es kann sein, dass in der DB Tabellen ausgeblendet wurden, die eigentlich Bestandteil einer Relation sind. Oder eine Tabelle
+ // befand sich im Layout (durchaus ohne Relation), existiert aber nicht mehr. In beiden Faellen wird das Anlegen des TabWins schief
+ // gehen, und alle solchen TabWinDatas oder darauf bezogenen ConnDatas muss ich dann loeschen.
+ ::std::vector< ::rtl::OUString> arrInvalidTables;
+
+ //////////////////////////////////////////////////////////////////////
+ // create and insert windows
+ TTableWindowData* pTabWinDataList = m_pView->getController().getTableWindowData();
+ TTableWindowData::reverse_iterator aIter = pTabWinDataList->rbegin();
+ for(;aIter != pTabWinDataList->rend();++aIter)
+ {
+ TTableWindowData::value_type pData = *aIter;
+ OTableWindow* pTabWin = createWindow(pData);
+
+ if (!pTabWin->Init())
+ {
+ // das Initialisieren ging schief, dass heisst, dieses TabWin steht nicht zur Verfuegung, also muss ich es inklusive
+ // seiner Daten am Dokument aufraeumen
+ pTabWin->clearListBox();
+ delete pTabWin;
+ arrInvalidTables.push_back(pData->GetTableName());
+
+ pTabWinDataList->erase( ::std::remove(pTabWinDataList->begin(),pTabWinDataList->end(),*aIter) ,pTabWinDataList->end());
+ continue;
+ }
+
+ (*GetTabWinMap())[pData->GetComposedName()] = pTabWin; // am Anfang einfuegen, da ich die DataList ja rueckwaerts durchlaufe
+ // wenn in den Daten keine Position oder Groesse steht -> Default
+ if (!pData->HasPosition() && !pData->HasSize())
+ SetDefaultTabWinPosSize(pTabWin);
+
+ pTabWin->Show();
+ }
+
+ // Verbindungen einfuegen
+ TTableConnectionData* pTabConnDataList = m_pView->getController().getTableConnectionData();
+ TTableConnectionData::reverse_iterator aConIter = pTabConnDataList->rbegin();
+
+ for(;aConIter != pTabConnDataList->rend();++aConIter)
+ {
+ ORelationTableConnectionData* pTabConnData = static_cast<ORelationTableConnectionData*>(aConIter->get());
+ if ( !arrInvalidTables.empty() )
+ {
+ // gibt es die beiden Tabellen zur Connection ?
+ ::rtl::OUString strTabExistenceTest = pTabConnData->getReferencingTable()->GetTableName();
+ sal_Bool bInvalid = ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
+ strTabExistenceTest = pTabConnData->getReferencedTable()->GetTableName();
+ bInvalid = bInvalid || ::std::find(arrInvalidTables.begin(),arrInvalidTables.end(),strTabExistenceTest) != arrInvalidTables.end();
+
+ if (bInvalid)
+ { // nein -> Pech gehabt, die Connection faellt weg
+ pTabConnDataList->erase( ::std::remove(pTabConnDataList->begin(),pTabConnDataList->end(),*aConIter),pTabConnDataList->end() );
+ continue;
+ }
+ }
+
+ addConnection( new ORelationTableConnection(this, *aConIter), sal_False ); // don't add the data again
+ }
+
+ if ( !GetTabWinMap()->empty() )
+ GetTabWinMap()->begin()->second->GrabFocus();
+}
+//------------------------------------------------------------------------------
+sal_Bool ORelationTableView::IsAddAllowed()
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+
+ return !m_pView->getController().isReadOnly();
+}
+//------------------------------------------------------------------------
+void ORelationTableView::AddConnection(const OJoinExchangeData& jxdSource, const OJoinExchangeData& jxdDest)
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+ // Aus selektierten Feldnamen LineDataObject setzen
+ // check if relation already exists
+ OTableWindow* pSourceWin = jxdSource.pListBox->GetTabWin();
+ OTableWindow* pDestWin = jxdDest.pListBox->GetTabWin();
+
+ ::std::vector<OTableConnection*>::const_iterator aIter = getTableConnections()->begin();
+ ::std::vector<OTableConnection*>::const_iterator aEnd = getTableConnections()->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OTableConnection* pFirst = *aIter;
+ if((pFirst->GetSourceWin() == pSourceWin && pFirst->GetDestWin() == pDestWin) ||
+ (pFirst->GetSourceWin() == pDestWin && pFirst->GetDestWin() == pSourceWin))
+ {
+ m_pExistingConnection = pFirst;
+ break;
+ }
+ }
+ // insert table connection into view
+
+ TTableConnectionData::value_type pTabConnData(new ORelationTableConnectionData(pSourceWin->GetData(),
+ pDestWin->GetData()));
+
+ // die Namen der betroffenen Felder
+ ::rtl::OUString sSourceFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry);
+ ::rtl::OUString sDestFieldName = jxdDest.pListBox->GetEntryText(jxdDest.pEntry);
+
+ // die Anzahl der PKey-Felder in der Quelle
+ const Reference< XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(pSourceWin->GetData()->getTable());
+ bool bAskUser = xPrimaryKeyColumns.is() && Reference< XIndexAccess>(xPrimaryKeyColumns,UNO_QUERY)->getCount() > 1;
+
+ pTabConnData->SetConnLine( 0, sSourceFieldName, sDestFieldName );
+
+ if ( bAskUser || m_pExistingConnection )
+ m_pCurrentlyTabConnData = pTabConnData; // this implies that we ask the user what to do
+ else
+ {
+ try
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Daten der Datenbank uebergeben
+ if( pTabConnData->Update() )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // UI-Object in ConnListe eintragen
+ addConnection( new ORelationTableConnection( this, pTabConnData ) );
+ }
+ }
+ catch(const SQLException&)
+ {
+ throw;
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("ORelationTableView::AddConnection: Exception oocured!");
+ }
+ }
+}
+
+
+//------------------------------------------------------------------------
+void ORelationTableView::ConnDoubleClicked( OTableConnection* pConnection )
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+ ORelationDialog aRelDlg( this, pConnection->GetData() );
+ switch (aRelDlg.Execute())
+ {
+ case RET_OK:
+ // successfully updated
+ pConnection->UpdateLineList();
+ // The connection references 1 ConnData and n ConnLines, each ConnData references n LineDatas, each Line exactly 1 LineData
+ // As the Dialog and the ConnData->Update may have changed the LineDatas we have to restore the consistent state
+ break;
+
+ case RET_NO:
+ // tried at least one update, but did not succeed -> the original connection is lost
+ RemoveConnection( pConnection ,sal_True);
+ break;
+
+ case RET_CANCEL:
+ // no break, as nothing happened and we don't need the code below
+ return;
+
+ }
+
+ Invalidate(INVALIDATE_NOCHILDREN);
+}
+
+//------------------------------------------------------------------------------
+void ORelationTableView::AddNewRelation()
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+
+ TTableConnectionData::value_type pNewConnData( new ORelationTableConnectionData() );
+ ORelationDialog aRelDlg(this, pNewConnData, sal_True);
+
+ sal_Bool bSuccess = (aRelDlg.Execute() == RET_OK);
+ if (bSuccess)
+ {
+ // already updated by the dialog
+ // dem Dokument bekanntgeben
+ addConnection( new ORelationTableConnection(this, pNewConnData) );
+ }
+}
+
+//------------------------------------------------------------------------------
+bool ORelationTableView::RemoveConnection( OTableConnection* pConn ,sal_Bool /*_bDelete*/)
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+ ORelationTableConnectionData* pTabConnData = (ORelationTableConnectionData*)pConn->GetData().get();
+ try
+ {
+ if ( m_bInRemove || pTabConnData->DropRelation())
+ return OJoinTableView::RemoveConnection( pConn ,sal_True);
+ }
+ catch(SQLException& e)
+ {
+ getDesignView()->getController().showError(SQLExceptionInfo(e));
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("ORelationTableView::RemoveConnection: Something other than SQLException occurred!");
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+void ORelationTableView::AddTabWin(const ::rtl::OUString& _rComposedName, const ::rtl::OUString& rWinName, sal_Bool /*bNewTable*/)
+{
+ DBG_CHKTHIS(ORelationTableView,NULL);
+ OSL_ENSURE(_rComposedName.getLength(),"There must be a table name supplied!");
+ OJoinTableView::OTableWindowMap::iterator aIter = GetTabWinMap()->find(_rComposedName);
+
+ if(aIter != GetTabWinMap()->end())
+ {
+ aIter->second->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+ aIter->second->GrabFocus();
+ EnsureVisible(aIter->second);
+ // no new one
+ return;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Neue Datenstruktur in DocShell eintragen
+ TTableWindowData::value_type pNewTabWinData(createTableWindowData( _rComposedName, rWinName,rWinName ));
+ pNewTabWinData->ShowAll(sal_False);
+
+ //////////////////////////////////////////////////////////////////
+ // Neues Fenster in Fensterliste eintragen
+ OTableWindow* pNewTabWin = createWindow( pNewTabWinData );
+ if(pNewTabWin->Init())
+ {
+ m_pView->getController().getTableWindowData()->push_back( pNewTabWinData);
+ // when we already have a table with this name insert the full qualified one instead
+ (*GetTabWinMap())[_rComposedName] = pNewTabWin;
+
+ SetDefaultTabWinPosSize( pNewTabWin );
+ pNewTabWin->Show();
+
+ modified();
+
+ if ( m_pAccessible )
+ m_pAccessible->notifyAccessibleEvent( AccessibleEventId::CHILD,
+ Any(),
+ makeAny(pNewTabWin->GetAccessible()));
+ }
+ else
+ {
+ pNewTabWin->clearListBox();
+ delete pNewTabWin;
+ }
+}
+// -----------------------------------------------------------------------------
+void ORelationTableView::RemoveTabWin( OTableWindow* pTabWin )
+{
+ OSQLWarningBox aDlg( this, ModuleRes( STR_QUERY_REL_DELETE_WINDOW ), WB_YES_NO | WB_DEF_YES );
+ if ( m_bInRemove || aDlg.Execute() == RET_YES )
+ {
+ m_pView->getController().ClearUndoManager();
+ OJoinTableView::RemoveTabWin( pTabWin );
+
+ m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
+ m_pView->getController().InvalidateFeature(ID_BROWSER_UNDO);
+ m_pView->getController().InvalidateFeature(ID_BROWSER_REDO);
+ }
+}
+
+void ORelationTableView::lookForUiActivities()
+{
+ if(m_pExistingConnection)
+ {
+ String sTitle(ModuleRes(STR_RELATIONDESIGN));
+ sTitle.Erase(0,3);
+ OSQLMessageBox aDlg(this,ModuleRes(STR_QUERY_REL_EDIT_RELATION),String(),0);
+ aDlg.SetText(sTitle);
+ aDlg.RemoveButton(aDlg.GetButtonId(0));
+ aDlg.AddButton( ModuleRes(STR_QUERY_REL_EDIT), BUTTONID_OK, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON);
+ aDlg.AddButton( ModuleRes(STR_QUERY_REL_CREATE), BUTTONID_YES, 0);
+ aDlg.AddButton(BUTTON_CANCEL,BUTTONID_CANCEL,0);
+ sal_uInt16 nRet = aDlg.Execute();
+ if( nRet == RET_CANCEL)
+ {
+ m_pCurrentlyTabConnData.reset();
+ }
+ else if ( nRet == RET_OK ) // EDIT
+ {
+ ConnDoubleClicked(m_pExistingConnection);
+ m_pCurrentlyTabConnData.reset();
+ }
+ m_pExistingConnection = NULL;
+ }
+ if(m_pCurrentlyTabConnData)
+ {
+ ORelationDialog aRelDlg( this, m_pCurrentlyTabConnData );
+ if (aRelDlg.Execute() == RET_OK)
+ {
+ // already updated by the dialog
+ addConnection( new ORelationTableConnection( this, m_pCurrentlyTabConnData ) );
+ }
+ m_pCurrentlyTabConnData.reset();
+ }
+}
+
+// -----------------------------------------------------------------------------
+OTableWindow* ORelationTableView::createWindow(const TTableWindowData::value_type& _pData)
+{
+ return new ORelationTableWindow(this,_pData);
+}
+// -----------------------------------------------------------------------------
+bool ORelationTableView::allowQueries() const
+{
+ return false;
+}
+// -----------------------------------------------------------------------------
+void ORelationTableView::_elementInserted( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+
+}
+// -----------------------------------------------------------------------------
+void ORelationTableView::_elementRemoved( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
+{
+ m_bInRemove = true;
+ ::rtl::OUString sName;
+ if ( _rEvent.Accessor >>= sName )
+ {
+ OTableWindow* pTableWindow = GetTabWindow(sName);
+ if ( pTableWindow )
+ {
+ m_pView->getController().ClearUndoManager();
+ OJoinTableView::RemoveTabWin( pTableWindow );
+
+ m_pView->getController().InvalidateFeature(SID_RELATION_ADD_RELATION);
+ m_pView->getController().InvalidateFeature(ID_BROWSER_UNDO);
+ m_pView->getController().InvalidateFeature(ID_BROWSER_REDO);
+ }
+ }
+ m_bInRemove = false;
+}
+// -----------------------------------------------------------------------------
+void ORelationTableView::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/relationdesign/makefile.mk b/dbaccess/source/ui/relationdesign/makefile.mk
new file mode 100644
index 000000000000..cdaaa8722013
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=relationdesign
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES =\
+ $(SLO)$/RTableConnection.obj \
+ $(SLO)$/RTableConnectionData.obj \
+ $(SLO)$/RelationTableView.obj \
+ $(SLO)$/RelationDesignView.obj \
+ $(SLO)$/RelationController.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = relation.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
+
diff --git a/dbaccess/source/ui/relationdesign/relation.src b/dbaccess/source/ui/relationdesign/relation.src
new file mode 100644
index 000000000000..4420ade06100
--- /dev/null
+++ b/dbaccess/source/ui/relationdesign/relation.src
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef _DBU_REL_HRC_
+#include "dbu_rel.hrc"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef _CNTIDS_HRC
+#include <sfx2/cntids.hrc>
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+
+String STR_QUERY_REL_EDIT_RELATION
+{
+ Text [ en-US ] = "This relation already exists. Do you want to edit it or create a new one?" ;
+};
+
+String STR_QUERY_REL_EDIT
+{
+ Text [ en-US ] = "Edit..." ;
+};
+
+String STR_QUERY_REL_CREATE
+{
+ Text [ en-US ] = "Create..." ;
+};
+
+String STR_RELATIONDESIGN
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base: Relation design" ;
+};
+
+String STR_RELATIONDESIGN_NOT_AVAILABLE
+{
+ Text [ en-US ] = "The database does not support relations." ;
+};
+
+QueryBox RELATION_DESIGN_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The relation design has been changed.\nDo you want to save the changes?" ;
+};
+
+String STR_QUERY_REL_DELETE_WINDOW
+{
+ Text [ en-US ] = "When you delete this table all corresponding relations will be deleted as well. Continue?";
+};
+
+String STR_QUERY_REL_COULD_NOT_CREATE
+{
+ Text [ en-US ] = "The database could not create the relation. May be foreign keys for this kind of table aren't supported.\nPlease check your documentation of the database.";
+};
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
new file mode 100644
index 000000000000..45165c16605f
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "FieldDescGenWin.hxx"
+#include <osl/diagnose.h>
+#include "dbaccess_helpid.hrc"
+#include "TableDesignHelpBar.hxx"
+#include "TableFieldControl.hxx"
+#include "TableDesignView.hxx"
+#include "TEditControl.hxx"
+using namespace dbaui;
+
+//==================================================================
+// class OFieldDescGenWin
+//==================================================================
+
+DBG_NAME(OFieldDescGenWin)
+//==================================================================
+//------------------------------------------------------------------------------
+OFieldDescGenWin::OFieldDescGenWin( Window* pParent, OTableDesignHelpBar* pHelp ) :
+ TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL )
+{
+ DBG_CTOR(OFieldDescGenWin,NULL);
+ m_pFieldControl = new OTableFieldControl(this,pHelp);
+ m_pFieldControl->SetHelpId(HID_TAB_DESIGN_FIELDCONTROL);
+ m_pFieldControl->Show();
+}
+//------------------------------------------------------------------------------
+OFieldDescGenWin::~OFieldDescGenWin()
+{
+ DBG_DTOR(OFieldDescGenWin,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pFieldControl);
+ m_pFieldControl = NULL;
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::Init()
+{
+ OSL_ENSURE(GetEditorCtrl() != NULL, "OFieldDescGenWin::Init : have no editor control !");
+
+ m_pFieldControl->Init();
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::Resize()
+{
+ m_pFieldControl->SetPosSizePixel(Point(0,0),GetSizePixel());
+ m_pFieldControl->Resize();
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SetReadOnly( sal_Bool bReadOnly )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+
+ m_pFieldControl->SetReadOnly(bReadOnly);
+}
+//------------------------------------------------------------------------------
+String OFieldDescGenWin::GetControlText( sal_uInt16 nControlId )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ return m_pFieldControl->GetControlText(nControlId);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SetControlText( sal_uInt16 nControlId, const String& rText )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls setzen
+ m_pFieldControl->SetControlText(nControlId,rText);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::DisplayData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+
+ m_pFieldControl->DisplayData(pFieldDescr);
+}
+//------------------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 0
+OTableEditorCtrl* OFieldDescGenWin::GetEditorCtrl()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent());
+ return pDesignWin->GetEditorCtrl();
+}
+#endif
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ m_pFieldControl->SaveData(pFieldDescr);
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::GetFocus()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Setzt den Focus auf das zuletzt aktive Control
+ TabPage::GetFocus();
+ if(m_pFieldControl)
+ m_pFieldControl->GetFocus();
+
+}
+//------------------------------------------------------------------------------
+void OFieldDescGenWin::LoseFocus()
+{
+ DBG_CHKTHIS(OFieldDescGenWin,NULL);
+ m_pFieldControl->LoseFocus();
+ TabPage::LoseFocus();
+}
+//------------------------------------------------------------------
+String OFieldDescGenWin::BoolStringPersistent(const String& rUIString) const
+{
+ return m_pFieldControl->BoolStringPersistent(rUIString);
+}
+
+//------------------------------------------------------------------
+String OFieldDescGenWin::BoolStringUI(const String& rPersistentString) const
+{
+ return m_pFieldControl->BoolStringUI(rPersistentString);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isCopyAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isCutAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescGenWin::isPasteAllowed()
+{
+ return (m_pFieldControl && m_pFieldControl->isPasteAllowed());
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::cut()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->cut();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::copy()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->copy();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescGenWin::paste()
+{
+ if(m_pFieldControl)
+ m_pFieldControl->paste();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
new file mode 100644
index 000000000000..d95ddefbebf6
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescGenWin.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESCGENPAGE_HXX
+#define DBAUI_TABLEFIELDDESCGENPAGE_HXX
+
+#include <vcl/tabpage.hxx>
+#include "IClipBoardTest.hxx"
+
+namespace dbaui
+{
+ class OTableDesignHelpBar;
+ class OFieldDescription;
+ class OTableFieldControl;
+ class OTableEditorCtrl;
+ //==================================================================
+ class OFieldDescGenWin : public TabPage
+ ,public IClipboardTest
+ {
+
+ OTableFieldControl *m_pFieldControl;
+ protected:
+ virtual void Resize();
+
+ public:
+ OFieldDescGenWin( Window* pParent, OTableDesignHelpBar* pHelpBar );
+ virtual ~OFieldDescGenWin();
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual void Init();
+
+ void DisplayData( OFieldDescription* pFieldDescr );
+ void SaveData( OFieldDescription* pFieldDescr );
+ void SetControlText( sal_uInt16 nControlId, const String& rText );
+ String GetControlText( sal_uInt16 nControlId );
+ void SetReadOnly( sal_Bool bReadOnly );
+#if OSL_DEBUG_LEVEL > 0
+ OTableEditorCtrl* GetEditorCtrl();
+#endif
+ // short GetFormatCategory(OFieldDescription* pFieldDescr);
+ // liefert zum am Feld eingestellten Format einen der CAT_xxx-Werte (CAT_NUMBER, CAT_DATE ...)
+
+ String BoolStringPersistent(const String& rUIString) const;
+ String BoolStringUI(const String& rPersistentString) const;
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ inline OTableFieldControl* getFieldControl() const { return m_pFieldControl; }
+ };
+}
+#endif // DBAUI_TABLEFIELDDESCGENPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
new file mode 100644
index 000000000000..914d33c3d7a5
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx
@@ -0,0 +1,682 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "FieldDescriptions.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "dbu_tbl.hrc"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "dbustrings.hrc"
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include "UITools.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+
+#define DEFAULT_VARCHAR_PRECSION 100
+#define DEFAULT_OTHER_PRECSION 16
+#define DEFAULT_NUMERIC_PRECSION 5
+#define DEFAULT_NUMERIC_SCALE 0
+
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+
+//========================================================================
+// class OFieldDescription
+//========================================================================
+DBG_NAME(OFieldDescription)
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription()
+ :m_pType()
+ ,m_nType(DataType::VARCHAR)
+ ,m_nPrecision(0)
+ ,m_nScale(0)
+ ,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nFormatKey(0)
+ ,m_eHorJustify(SVX_HOR_JUSTIFY_STANDARD)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bIsPrimaryKey(sal_False)
+ ,m_bIsCurrency(sal_False)
+ ,m_bHidden(sal_False)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+}
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription( const OFieldDescription& rDescr )
+ :m_aDefaultValue(rDescr.m_aDefaultValue)
+ ,m_aControlDefault(rDescr.m_aControlDefault)
+ ,m_aWidth(rDescr.m_aWidth)
+ ,m_aRelativePosition(rDescr.m_aRelativePosition)
+ ,m_pType(rDescr.m_pType)
+ ,m_xDest(rDescr.m_xDest)
+ ,m_xDestInfo(rDescr.m_xDestInfo)
+ ,m_sName(rDescr.m_sName)
+ ,m_sTypeName(rDescr.m_sTypeName)
+ ,m_sDescription(rDescr.m_sDescription)
+ ,m_sAutoIncrementValue(rDescr.m_sAutoIncrementValue)
+ ,m_nType(rDescr.m_nType)
+ ,m_nPrecision(rDescr.m_nPrecision)
+ ,m_nScale(rDescr.m_nScale)
+ ,m_nIsNullable(rDescr.m_nIsNullable)
+ ,m_nFormatKey(rDescr.m_nFormatKey)
+ ,m_eHorJustify(rDescr.m_eHorJustify)
+ ,m_bIsAutoIncrement(rDescr.m_bIsAutoIncrement)
+ ,m_bIsPrimaryKey(rDescr.m_bIsPrimaryKey)
+ ,m_bIsCurrency(rDescr.m_bIsCurrency)
+ ,m_bHidden(rDescr.m_bHidden)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+}
+
+//------------------------------------------------------------------------------
+OFieldDescription::~OFieldDescription()
+{
+ DBG_DTOR(OFieldDescription,NULL);
+}
+//------------------------------------------------------------------------------
+OFieldDescription::OFieldDescription(const Reference< XPropertySet >& xAffectedCol,sal_Bool _bUseAsDest)
+ :m_pType()
+ ,m_nType(DataType::VARCHAR)
+ ,m_nPrecision(0)
+ ,m_nScale(0)
+ ,m_nIsNullable(ColumnValue::NULLABLE)
+ ,m_nFormatKey(0)
+ ,m_eHorJustify(SVX_HOR_JUSTIFY_STANDARD)
+ ,m_bIsAutoIncrement(sal_False)
+ ,m_bIsPrimaryKey(sal_False)
+ ,m_bIsCurrency(sal_False)
+ ,m_bHidden(sal_False)
+{
+ DBG_CTOR(OFieldDescription,NULL);
+ OSL_ENSURE(xAffectedCol.is(),"PropetySet can notbe null!");
+ if ( xAffectedCol.is() )
+ {
+ if ( _bUseAsDest )
+ {
+ m_xDest = xAffectedCol;
+ m_xDestInfo = xAffectedCol->getPropertySetInfo();;
+ }
+ else
+ {
+ try
+ {
+ Reference<XPropertySetInfo> xPropSetInfo = xAffectedCol->getPropertySetInfo();
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_NAME))
+ SetName(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_NAME)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_DESCRIPTION))
+ SetDescription(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_DESCRIPTION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_HELPTEXT))
+ {
+ ::rtl::OUString sHelpText;
+ xAffectedCol->getPropertyValue(PROPERTY_HELPTEXT) >>= sHelpText;
+ SetHelpText(sHelpText);
+ }
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE))
+ SetDefaultValue( xAffectedCol->getPropertyValue(PROPERTY_DEFAULTVALUE) );
+
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ SetControlDefault( xAffectedCol->getPropertyValue(PROPERTY_CONTROLDEFAULT) );
+
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION))
+ SetAutoIncrementValue(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_AUTOINCREMENTCREATION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_TYPE))
+ SetTypeValue(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_TYPE)));
+ if (xPropSetInfo->hasPropertyByName(PROPERTY_TYPENAME))
+ SetTypeName(::comphelper::getString(xAffectedCol->getPropertyValue(PROPERTY_TYPENAME)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_PRECISION))
+ SetPrecision(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_PRECISION)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_SCALE))
+ SetScale(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_SCALE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ISNULLABLE))
+ SetIsNullable(::comphelper::getINT32(xAffectedCol->getPropertyValue(PROPERTY_ISNULLABLE)));
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_FORMATKEY))
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_FORMATKEY);
+ if ( aValue.hasValue() )
+ SetFormatKey(::comphelper::getINT32(aValue));
+ }
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
+ m_aRelativePosition = xAffectedCol->getPropertyValue(PROPERTY_RELATIVEPOSITION);
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_WIDTH))
+ m_aWidth = xAffectedCol->getPropertyValue(PROPERTY_WIDTH);
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_HIDDEN))
+ xAffectedCol->getPropertyValue(PROPERTY_HIDDEN) >>= m_bHidden;
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ALIGN))
+ {
+ const Any aValue = xAffectedCol->getPropertyValue(PROPERTY_ALIGN);
+ if ( aValue.hasValue() )
+ SetHorJustify( ::dbaui::mapTextJustify(::comphelper::getINT32(aValue)));
+ }
+ if(xPropSetInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT))
+ SetAutoIncrement(::cppu::any2bool(xAffectedCol->getPropertyValue(PROPERTY_ISAUTOINCREMENT)));
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bForce,sal_Bool _bReset)
+{
+ TOTypeInfoSP pOldType = getTypeInfo();
+ if ( _pType != pOldType )
+ {
+ // reset type depending information
+ if ( _bReset )
+ {
+ SetFormatKey(0);
+ SetControlDefault(Any());
+ }
+
+ sal_Bool bForce = _bForce || pOldType.get() == NULL || pOldType->nType != _pType->nType;
+ switch ( _pType->nType )
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ if ( bForce )
+ {
+ sal_Int32 nPrec = DEFAULT_VARCHAR_PRECSION;
+ if ( GetPrecision() )
+ nPrec = GetPrecision();
+ SetPrecision(::std::min<sal_Int32>(nPrec,_pType->nPrecision));
+ }
+ break;
+ case DataType::TIMESTAMP:
+ if ( bForce && _pType->nMaximumScale)
+ {
+ SetScale(::std::min<sal_Int32>(GetScale() ? GetScale() : DEFAULT_NUMERIC_SCALE,_pType->nMaximumScale));
+ }
+ break;
+ default:
+ if ( bForce )
+ {
+ sal_Int32 nPrec = DEFAULT_OTHER_PRECSION;
+ switch ( _pType->nType )
+ {
+ case DataType::BIT:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ nPrec = _pType->nPrecision;
+ break;
+ default:
+ if ( GetPrecision() )
+ nPrec = GetPrecision();
+ break;
+ }
+
+ if ( _pType->nPrecision )
+ SetPrecision(::std::min<sal_Int32>(nPrec ? nPrec : DEFAULT_NUMERIC_PRECSION,_pType->nPrecision));
+ if ( _pType->nMaximumScale )
+ SetScale(::std::min<sal_Int32>(GetScale() ? GetScale() : DEFAULT_NUMERIC_SCALE,_pType->nMaximumScale));
+ }
+ }
+ if ( !_pType->aCreateParams.getLength() )
+ {
+ SetPrecision(_pType->nPrecision);
+ SetScale(_pType->nMinimumScale);
+ }
+ if ( !_pType->bNullable && IsNullable() )
+ SetIsNullable(ColumnValue::NO_NULLS);
+ if ( !_pType->bAutoIncrement && IsAutoIncrement() )
+ SetAutoIncrement(sal_False);
+ SetCurrency( _pType->bCurrency );
+ SetType(_pType);
+ SetTypeName(_pType->aTypeName);
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetName(const ::rtl::OUString& _rName)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_NAME) )
+ m_xDest->setPropertyValue(PROPERTY_NAME,makeAny(_rName));
+ else
+ m_sName = _rName;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetHelpText(const ::rtl::OUString& _sHelpText)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ m_xDest->setPropertyValue(PROPERTY_HELPTEXT,makeAny(_sHelpText));
+ else
+ m_sHelpText = _sHelpText;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetDescription(const ::rtl::OUString& _rDescription)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DESCRIPTION) )
+ m_xDest->setPropertyValue(PROPERTY_DESCRIPTION,makeAny(_rDescription));
+ else
+ m_sDescription = _rDescription;
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetDefaultValue(const Any& _rDefaultValue)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DEFAULTVALUE) )
+ m_xDest->setPropertyValue(PROPERTY_DEFAULTVALUE,makeAny(_rDefaultValue));
+ else
+ m_aDefaultValue = _rDefaultValue;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetControlDefault(const Any& _rControlDefault)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ m_xDest->setPropertyValue(PROPERTY_CONTROLDEFAULT,makeAny(_rControlDefault));
+ else
+ m_aControlDefault = _rControlDefault;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetAutoIncrementValue(const ::rtl::OUString& _sAutoIncValue)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ m_xDest->setPropertyValue(PROPERTY_AUTOINCREMENTCREATION,makeAny(_sAutoIncValue));
+ else
+ m_sAutoIncrementValue = _sAutoIncValue;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetType(TOTypeInfoSP _pType)
+{
+ m_pType = _pType;
+ if ( m_pType.get() )
+ {
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ m_xDest->setPropertyValue(PROPERTY_TYPE,makeAny(m_pType->nType));
+ else
+ m_nType = m_pType->nType;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetTypeValue(sal_Int32 _nType)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ m_xDest->setPropertyValue(PROPERTY_TYPE,makeAny(_nType));
+ else
+ {
+ m_nType = _nType;
+ OSL_ENSURE(!m_pType.get(),"Invalid call here!");
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetPrecision(const sal_Int32& _rPrecision)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_PRECISION) )
+ m_xDest->setPropertyValue(PROPERTY_PRECISION,makeAny(_rPrecision));
+ else
+ m_nPrecision = _rPrecision;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetScale(const sal_Int32& _rScale)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_SCALE) )
+ m_xDest->setPropertyValue(PROPERTY_SCALE,makeAny(_rScale));
+ else
+ m_nScale = _rScale;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetIsNullable(const sal_Int32& _rIsNullable)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ m_xDest->setPropertyValue(PROPERTY_ISNULLABLE,makeAny(_rIsNullable));
+ else
+ m_nIsNullable = _rIsNullable;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetFormatKey(const sal_Int32& _rFormatKey)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ m_xDest->setPropertyValue(PROPERTY_FORMATKEY,makeAny(_rFormatKey));
+ else
+ m_nFormatKey = _rFormatKey;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetHorJustify(const SvxCellHorJustify& _rHorJustify)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ m_xDest->setPropertyValue(PROPERTY_ALIGN,makeAny( dbaui::mapTextAllign(_rHorJustify)));
+ else
+ m_eHorJustify = _rHorJustify;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetAutoIncrement(sal_Bool _bAuto)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) )
+ m_xDest->setPropertyValue(PROPERTY_ISAUTOINCREMENT,makeAny(_bAuto));
+ else
+ m_bIsAutoIncrement = _bAuto;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetPrimaryKey(sal_Bool _bPKey)
+{
+ m_bIsPrimaryKey = _bPKey;
+ if ( _bPKey )
+ SetIsNullable(::com::sun::star::sdbc::ColumnValue::NO_NULLS);
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetCurrency(sal_Bool _bIsCurrency)
+{
+ m_bIsCurrency = _bIsCurrency;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString OFieldDescription::GetName() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_NAME) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_NAME));
+ else
+ return m_sName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetDescription() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_DESCRIPTION) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_DESCRIPTION));
+ else
+ return m_sDescription;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetHelpText() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_HELPTEXT));
+ else
+ return m_sHelpText;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Any OFieldDescription::GetControlDefault() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ return m_xDest->getPropertyValue(PROPERTY_CONTROLDEFAULT);
+ else
+ return m_aControlDefault;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetAutoIncrementValue() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_AUTOINCREMENTCREATION) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_AUTOINCREMENTCREATION));
+ else
+ return m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetType() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_TYPE));
+ else
+ return m_pType.get() ? m_pType->nType : m_nType;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFieldDescription::GetTypeName() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPENAME) )
+ return ::comphelper::getString(m_xDest->getPropertyValue(PROPERTY_TYPENAME));
+ else
+ return m_pType.get() ? m_pType->aTypeName : m_sTypeName;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetPrecision() const
+{
+ sal_Int32 nPrec = m_nPrecision;
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_PRECISION) )
+ nPrec = ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_PRECISION));
+
+ TOTypeInfoSP pTypeInfo = getTypeInfo();
+ if ( pTypeInfo )
+ {
+ switch ( pTypeInfo->nType )
+ {
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ if ( !nPrec )
+ nPrec = pTypeInfo->nPrecision;
+ break;
+ }
+ }
+
+ return nPrec;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetScale() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_SCALE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_SCALE));
+ else
+ return m_nScale;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetIsNullable() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ISNULLABLE));
+ else
+ return m_nIsNullable;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OFieldDescription::GetFormatKey() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_FORMATKEY));
+ else
+ return m_nFormatKey;
+}
+// -----------------------------------------------------------------------------
+SvxCellHorJustify OFieldDescription::GetHorJustify() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ return ::dbaui::mapTextJustify(::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ALIGN)));
+ else
+ return m_eHorJustify;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OFieldDescription::getTypeInfo() const
+{
+ return m_pType;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OFieldDescription::getSpecialTypeInfo() const
+{
+ TOTypeInfoSP pSpecialType( new OTypeInfo() );
+ *pSpecialType = *m_pType;
+ pSpecialType->nPrecision = GetPrecision();
+ pSpecialType->nMaximumScale = static_cast<sal_Int16>(GetScale());
+ return pSpecialType;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsAutoIncrement() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) )
+ return ::cppu::any2bool(m_xDest->getPropertyValue(PROPERTY_ISAUTOINCREMENT));
+ else
+ return m_bIsAutoIncrement;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsPrimaryKey() const
+{
+ return m_bIsPrimaryKey;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsCurrency() const
+{
+ return m_bIsCurrency;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescription::IsNullable() const
+{
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISNULLABLE) )
+ return ::comphelper::getINT32(m_xDest->getPropertyValue(PROPERTY_ISNULLABLE)) == ::com::sun::star::sdbc::ColumnValue::NULLABLE;
+ else
+ return m_nIsNullable == ::com::sun::star::sdbc::ColumnValue::NULLABLE;
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::SetTypeName(const ::rtl::OUString& _sTypeName)
+{
+ try
+ {
+ if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_TYPENAME) )
+ m_xDest->setPropertyValue(PROPERTY_TYPENAME,makeAny(_sTypeName));
+ else
+ m_sTypeName = _sTypeName;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescription::copyColumnSettingsTo(const Reference< XPropertySet >& _rxColumn)
+{
+ if ( _rxColumn.is() )
+ {
+ Reference<XPropertySetInfo> xInfo = _rxColumn->getPropertySetInfo();
+
+ if ( GetFormatKey() != NumberFormat::ALL && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
+ _rxColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(GetFormatKey()));
+ if ( GetHorJustify() != SVX_HOR_JUSTIFY_STANDARD && xInfo->hasPropertyByName(PROPERTY_ALIGN) )
+ _rxColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(GetHorJustify())));
+ if ( GetHelpText().getLength() && xInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ _rxColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(GetHelpText()));
+ if ( GetControlDefault().hasValue() && xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT) )
+ _rxColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,GetControlDefault());
+
+ if(xInfo->hasPropertyByName(PROPERTY_RELATIVEPOSITION))
+ _rxColumn->setPropertyValue(PROPERTY_RELATIVEPOSITION,m_aRelativePosition);
+ if(xInfo->hasPropertyByName(PROPERTY_WIDTH))
+ _rxColumn->setPropertyValue(PROPERTY_WIDTH,m_aWidth);
+ if(xInfo->hasPropertyByName(PROPERTY_HIDDEN))
+ _rxColumn->setPropertyValue(PROPERTY_HIDDEN,makeAny(m_bHidden));
+ }
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx
new file mode 100644
index 000000000000..6884feaf2ef4
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx
@@ -0,0 +1,1944 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TEditControl.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include "dbu_tbl.hrc"
+#include "dbustrings.hrc"
+#include "browserids.hxx"
+#include "dbaccess_helpid.hrc"
+#include <comphelper/types.hxx>
+#include "FieldDescControl.hxx"
+#include "FieldDescriptions.hxx"
+#include <vcl/msgbox.hxx>
+#include "TableUndo.hxx"
+#include "TableController.hxx"
+#include <connectivity/dbtools.hxx>
+#include "SqlNameEdit.hxx"
+#include "TableRowExchange.hxx"
+#include <sot/storage.hxx>
+#include "UITools.hxx"
+#include "FieldDescControl.hxx"
+#include "TableFieldControl.hxx"
+#include "dsntypes.hxx"
+
+#include "dbaccess_slotid.hrc"
+
+using namespace ::dbaui;
+using namespace ::comphelper;
+using namespace ::svt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+
+namespace dbaui
+{
+ extern String GetTypeString( sal_uInt16 nType );
+}
+//==============================================================================
+
+// TYPEINIT1(OTableEditorCtrl, DBView);
+DBG_NAME(OTableEditorCtrl)
+
+//==============================================================================
+
+#define HANDLE_ID 0
+
+// default Spaltenbreiten
+#define FIELDNAME_WIDTH 100
+#define FIELDTYPE_WIDTH 150
+#define FIELDDESCR_WIDTH 300
+
+// Maximale Eingabelaenge im Beschreibungsfeld
+#define MAX_DESCR_LEN 256
+
+
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 5
+#define CONTROL_HEIGHT 20
+#define CONTROL_WIDTH_1 140 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
+
+
+//==================================================================
+DBG_NAME(ClipboardInvalidator)
+//------------------------------------------------------------------
+OTableEditorCtrl::ClipboardInvalidator::ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl* _pOwner)
+: m_pOwner(_pOwner)
+{
+ DBG_CTOR(ClipboardInvalidator,NULL);
+
+ m_aInvalidateTimer.SetTimeout(nTimeout);
+ m_aInvalidateTimer.SetTimeoutHdl(LINK(this, OTableEditorCtrl::ClipboardInvalidator, OnInvalidate));
+ m_aInvalidateTimer.Start();
+}
+
+//------------------------------------------------------------------
+OTableEditorCtrl::ClipboardInvalidator::~ClipboardInvalidator()
+{
+ m_aInvalidateTimer.Stop();
+
+ DBG_DTOR(ClipboardInvalidator,NULL);
+}
+
+//------------------------------------------------------------------
+IMPL_LINK(OTableEditorCtrl::ClipboardInvalidator, OnInvalidate, void*, EMPTYARG)
+{
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_CUT);
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_COPY);
+ m_pOwner->GetView()->getController().InvalidateFeature(SID_PASTE);
+ return 0L;
+}
+
+//==================================================================
+void OTableEditorCtrl::Init()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OTableRowView::Init();
+
+ //////////////////////////////////////////////////////////////////////
+ // Soll der Entwurf ReadOnly geoeffnet werden ?
+ sal_Bool bRead(GetView()->getController().isReadOnly());
+
+ SetReadOnly( bRead );
+
+ //////////////////////////////////////////////////////////////////////
+ // Spalten einfuegen
+ String aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) );
+ InsertDataColumn( FIELD_NAME, aColumnName, FIELDNAME_WIDTH );
+
+ aColumnName = String( ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE) );
+ InsertDataColumn( FIELD_TYPE, aColumnName, FIELDTYPE_WIDTH );
+
+ ::dbaccess::ODsnTypeCollection aDsnTypes(GetView()->getController().getORB());
+ sal_Bool bShowColumnDescription = aDsnTypes.supportsColumnDescription(::comphelper::getString(GetView()->getController().getDataSource()->getPropertyValue(PROPERTY_URL)));
+ aColumnName = String( ModuleRes(STR_TAB_HELP_TEXT) );
+ InsertDataColumn( HELP_TEXT, aColumnName, bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH );
+
+ if ( bShowColumnDescription )
+ {
+ aColumnName = String( ModuleRes(STR_COLUMN_DESCRIPTION) );
+ InsertDataColumn( COLUMN_DESCRIPTION, aColumnName, FIELDTYPE_WIDTH );
+ }
+
+ InitCellController();
+
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen einfuegen
+ RowInserted(0, m_pRowList->size(), sal_True);
+}
+
+//==================================================================
+void OTableEditorCtrl::UpdateAll()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ RowRemoved(0, GetRowCount(), sal_False);
+ m_nDataPos = 0;
+
+ InvalidateFeatures();
+ Invalidate();
+}
+//==================================================================
+OTableEditorCtrl::OTableEditorCtrl(Window* pWindow)
+ :OTableRowView(pWindow)
+ ,pNameCell(NULL)
+ ,pTypeCell(NULL)
+ ,pHelpTextCell(NULL)
+ ,pDescrCell(NULL)
+ ,pDescrWin(NULL)
+ ,nIndexEvent(0)
+ ,nCutEvent(0)
+ ,nPasteEvent(0)
+ ,nDeleteEvent(0)
+ ,nInsNewRowsEvent(0)
+ ,nInvalidateTypeEvent(0)
+ ,nEntryNotFoundEvent(0)
+ ,m_eChildFocus(NONE)
+ ,nOldDataPos(-1)
+ ,bSaveOnMove(sal_True)
+ ,bReadOnly(sal_True)
+ ,m_aInvalidate(500,this)
+{
+ DBG_CTOR(OTableEditorCtrl,NULL);
+
+ SetHelpId(HID_TABDESIGN_BACKGROUND);
+ GetDataWindow().SetHelpId(HID_CTL_TABLEEDIT);
+
+ m_pRowList = GetView()->getController().getRows();
+ m_nDataPos = 0;
+}
+
+//------------------------------------------------------------------------------
+SfxUndoManager& OTableEditorCtrl::GetUndoManager() const
+{
+ return GetView()->getController().GetUndoManager();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsReadOnly()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ return bReadOnly;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetReadOnly( sal_Bool bRead )
+{
+ // nix zu tun ?
+ if (bRead == IsReadOnly())
+ // diese Abfrage ist wichtig, da die zugrundeliegende Def sonst im folgenden gelockt oder ge-unlocked wird, obwohl es
+ // nicht notwendig waere (und was schlimmer ist, das wuerde dann auch nicht wieder rueckgaengig gemacht)
+ return;
+
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ bReadOnly = bRead;
+
+ //////////////////////////////////////////////////////////////////////
+ // Aktive Zelle disablen
+ long nRow(GetCurRow());
+ sal_uInt16 nCol(GetCurColumnId());
+ DeactivateCell();
+
+ //////////////////////////////////////////////////////////////////////
+ // Cursor des Browsers anpassen
+ BrowserMode nMode(BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
+ BROWSER_HLINESFULL | BROWSER_VLINESFULL|BROWSER_AUTOSIZE_LASTCOL);
+ if( !bReadOnly )
+ nMode |= BROWSER_HIDECURSOR;
+ SetMode(nMode);
+
+ if( !bReadOnly )
+ ActivateCell( nRow, nCol );
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InitCellController()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Feldname
+ xub_StrLen nMaxTextLen = EDIT_NOLIMIT;
+ ::rtl::OUString sExtraNameChars;
+ Reference<XConnection> xCon;
+ try
+ {
+ xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ nMaxTextLen = ((xub_StrLen)xMetaData.is() ? static_cast<xub_StrLen>(xMetaData->getMaxColumnNameLength()) : 0);
+
+ if( nMaxTextLen == 0 )
+ nMaxTextLen = EDIT_NOLIMIT;
+ sExtraNameChars = xMetaData.is() ? xMetaData->getExtraNameCharacters() : ::rtl::OUString();
+
+ }
+ catch(SQLException&)
+ {
+ OSL_FAIL("getMaxColumnNameLength");
+ }
+
+ pNameCell = new OSQLNameEdit( &GetDataWindow(), sExtraNameChars,WB_LEFT );
+ pNameCell->SetMaxTextLen( nMaxTextLen );
+ pNameCell->setCheck( isSQL92CheckEnabled(xCon) );
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Typ
+ pTypeCell = new ListBoxControl( &GetDataWindow() );
+ pTypeCell->SetDropDownLineCount( 15 );
+
+ //////////////////////////////////////////////////////////////////////
+ // Zelle Beschreibung
+ pDescrCell = new Edit( &GetDataWindow(), WB_LEFT );
+ pDescrCell->SetMaxTextLen( MAX_DESCR_LEN );
+
+ pHelpTextCell = new Edit( &GetDataWindow(), WB_LEFT );
+ pHelpTextCell->SetMaxTextLen( MAX_DESCR_LEN );
+
+ pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL);
+ pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL);
+ pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL);
+ pHelpTextCell->SetHelpId(HID_TABDESIGN_HELPTEXT);
+
+ Size aHeight;
+ const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell,pHelpTextCell};
+ for(sal_Size i= 0; i < SAL_N_ELEMENTS(pControls);++i)
+ {
+ const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ }
+ SetDataRowHeight(aHeight.Height());
+
+ ClearModified();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::ClearModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ pNameCell->ClearModifyFlag();
+ pDescrCell->ClearModifyFlag();
+ pHelpTextCell->ClearModifyFlag();
+ pTypeCell->SaveValue();
+}
+
+//------------------------------------------------------------------------------
+OTableEditorCtrl::~OTableEditorCtrl()
+{
+ DBG_DTOR(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Manager zuruecksetzen
+ GetUndoManager().Clear();
+
+ //////////////////////////////////////////////////////////////////////
+ // Moegliche Events aus Queue entfernen
+ if( nCutEvent )
+ Application::RemoveUserEvent( nCutEvent );
+ if( nPasteEvent )
+ Application::RemoveUserEvent( nPasteEvent );
+ if( nDeleteEvent )
+ Application::RemoveUserEvent( nDeleteEvent );
+ if( nInsNewRowsEvent )
+ Application::RemoveUserEvent( nInsNewRowsEvent );
+ if( nInvalidateTypeEvent )
+ Application::RemoveUserEvent( nInvalidateTypeEvent );
+ if( nEntryNotFoundEvent )
+ Application::RemoveUserEvent( nEntryNotFoundEvent );
+
+ //////////////////////////////////////////////////////////////////////
+ // Controltypen zerstoeren
+ delete pNameCell;
+ delete pTypeCell;
+ delete pDescrCell;
+ delete pHelpTextCell;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SetDataPtr( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if(nRow == -1)
+ return sal_False;
+
+ OSL_ENSURE((xub_StrLen)nRow < m_pRowList->size(),"Row is greater than size!");
+ if(nRow >= (long)m_pRowList->size())
+ return sal_False;
+ pActRow = (*m_pRowList)[nRow];
+ return pActRow != NULL;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SeekRow(long _nRow)
+{
+ // die Basisklasse braucht den Aufruf, da sie sich dort merkt, welche Zeile gepainted wird
+ EditBrowseBox::SeekRow(_nRow);
+
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ m_nCurrentPos = _nRow;
+ return SetDataPtr(_nRow);
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ sal_uInt16 nColumnId ) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ String aText( GetCellText( m_nCurrentPos, nColumnId ));
+ Point aPos(rRect.TopLeft());
+ Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight());
+
+ if (aPos.X() < rRect.Right() || aPos.X() + TxtSize.Width() > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + TxtSize.Height() > rRect.Bottom())
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText(aPos, aText);
+
+ if (rDev.IsClipRegion())
+ rDev.SetClipRegion();
+}
+
+//------------------------------------------------------------------------------
+CellController* OTableEditorCtrl::GetController(long nRow, sal_uInt16 nColumnId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Wenn EditorCtrl ReadOnly ist, darf nicht editiert werden
+ Reference<XPropertySet> xTable = GetView()->getController().getTable();
+ if (IsReadOnly() || ( xTable.is() &&
+ xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE) &&
+ ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"))))
+ return NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Zeile ReadOnly ist, darf sie nicht editiert werden
+ SetDataPtr( nRow );
+ if( pActRow->IsReadOnly() )
+ return NULL;
+
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+ switch (nColumnId)
+ {
+ case FIELD_NAME:
+ return new EditCellController( pNameCell );
+ case FIELD_TYPE:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new ListBoxCellController( pTypeCell );
+ else return NULL;
+ case HELP_TEXT:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new EditCellController( pHelpTextCell );
+ else
+ return NULL;
+ case COLUMN_DESCRIPTION:
+ if (pActFieldDescr && (pActFieldDescr->GetName().getLength() != 0))
+ return new EditCellController( pDescrCell );
+ else
+ return NULL;
+ default:
+ return NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16 nColumnId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ SeekRow( nRow == -1 ? GetCurRow() : nRow);
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+ String aInitString;
+
+ switch (nColumnId)
+ {
+ case FIELD_NAME:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetName();
+ pNameCell->SetText( aInitString );
+ pNameCell->SaveValue();
+ break;
+ case FIELD_TYPE:
+ {
+ if ( pActFieldDescr && pActFieldDescr->getTypeInfo() )
+ aInitString = pActFieldDescr->getTypeInfo()->aUIName;
+
+ //////////////////////////////////////////////////////////////
+ // Anpassen des ComboBoxInhalts
+ pTypeCell->Clear();
+ if( !pActFieldDescr )
+ break;
+
+ const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter)
+ pTypeCell->InsertEntry( aIter->second->aUIName );
+ pTypeCell->SelectEntry( aInitString );
+ }
+
+ break;
+ case HELP_TEXT:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetHelpText();
+ pHelpTextCell->SetText( aInitString );
+ pHelpTextCell->SaveValue();
+ break;
+ case COLUMN_DESCRIPTION:
+ if( pActFieldDescr )
+ aInitString = pActFieldDescr->GetDescription();
+ pDescrCell->SetText( aInitString );
+ pDescrCell->SaveValue();
+ break;
+
+ }
+}
+
+//------------------------------------------------------------------------------
+EditBrowseBox::RowStatus OTableEditorCtrl::GetRowStatus(long nRow) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ ( (OTableEditorCtrl*)this )->SetDataPtr( nRow );
+ if( !pActRow )
+ return EditBrowseBox::CLEAN;
+ if (nRow >= 0 && nRow == m_nDataPos)
+ {
+ if( pActRow->IsPrimaryKey() )
+ return EditBrowseBox::CURRENT_PRIMARYKEY;
+ return EditBrowseBox::CURRENT;
+ }
+ else
+ {
+ if( pActRow->IsPrimaryKey() )
+ return EditBrowseBox::PRIMARYKEY;
+ return EditBrowseBox::CLEAN;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveCurRow()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if (GetFieldDescr(GetCurRow()) == NULL)
+ // in der Zeile, in der ich mich i.A. befinde, stehen keine Daten
+ return sal_True;
+ if (!SaveModified())
+ return sal_False;
+
+ SetDataPtr(GetCurRow());
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::DisplayData(long nRow, sal_Bool bGrabFocus)
+{
+ // zur richtigen Zelle fahren
+ SetDataPtr(nRow);
+
+ // Editier-Modus temporaer aus
+ sal_Bool bWasEditing = IsEditing();
+ if (bWasEditing)
+ DeactivateCell();
+
+ CellControllerRef aTemp;
+ InitController(aTemp, nRow, FIELD_NAME);
+ InitController(aTemp, nRow, FIELD_TYPE);
+ InitController(aTemp, nRow, COLUMN_DESCRIPTION);
+ InitController(aTemp, nRow, HELP_TEXT);
+
+ GoToRow(nRow);
+ // das Description-Window aktualisieren
+ GetView()->GetDescWin()->DisplayData(GetFieldDescr(nRow));
+ // neu zeichnen
+ RowModified(nRow);
+
+ // wieder an
+ if (bWasEditing || bGrabFocus)
+ ActivateCell(nRow, GetCurColumnId(), bGrabFocus);
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CursorMoved()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Zeilenwechsel ?
+ m_nDataPos = GetCurRow();
+ if( m_nDataPos != nOldDataPos && m_nDataPos != -1)
+ {
+ CellControllerRef aTemp;
+ InitController(aTemp,m_nDataPos,FIELD_NAME);
+ InitController(aTemp,m_nDataPos,FIELD_TYPE);
+ InitController(aTemp,m_nDataPos,COLUMN_DESCRIPTION);
+ InitController(aTemp,m_nDataPos,HELP_TEXT);
+ }
+
+ OTableRowView::CursorMoved();
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 OTableEditorCtrl::HasFieldName( const String& rFieldName )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ Reference<XConnection> xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_pRowList->end();
+ OFieldDescription* pFieldDescr;
+ sal_Int32 nCount(0);
+ for(;aIter != aEnd;++aIter)
+ {
+ pFieldDescr = (*aIter)->GetActFieldDescr();
+ if( pFieldDescr && bCase(rFieldName,pFieldDescr->GetName()))
+ nCount++;
+ }
+ return nCount;
+}
+// --------------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////
+ // Zellinhalte in Datenstruktur speichern
+ SetDataPtr( nRow == -1 ? GetCurRow() : nRow);
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+
+ switch( nColId)
+ {
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt NameCell
+ case FIELD_NAME:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn kein Name, nichts machen
+ String aName(pNameCell->GetText());
+
+ if( !aName.Len() )
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn FieldDescr existiert, wurde Feld geloescht und alter Inhalt wird wiederhergestellt
+ if (pActFieldDescr)
+ {
+ GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, nRow, FIELD_TYPE, pActFieldDescr->getTypeInfo()));
+ SwitchType(TOTypeInfoSP());
+ pActFieldDescr = pActRow->GetActFieldDescr();
+ }
+ else
+ return sal_True;
+ }
+ if(pActFieldDescr)
+ pActFieldDescr->SetName( aName );
+ pNameCell->ClearModifyFlag();
+
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt TypeCell
+ case FIELD_TYPE:
+ break;
+
+ //////////////////////////////////////////////////////////////
+ // Speichern Inhalt DescrCell
+ case HELP_TEXT:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if( !pActFieldDescr )
+ {
+ pHelpTextCell->SetText(String());
+ pHelpTextCell->ClearModifyFlag();
+ }
+ else
+ pActFieldDescr->SetHelpText( pHelpTextCell->GetText() );
+ break;
+ }
+ case COLUMN_DESCRIPTION:
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if( !pActFieldDescr )
+ {
+ pDescrCell->SetText(String());
+ pDescrCell->ClearModifyFlag();
+ }
+ else
+ pActFieldDescr->SetDescription( pDescrCell->GetText() );
+ break;
+ }
+ case FIELD_PROPERTY_DEFAULT:
+ case FIELD_PROPERTY_REQUIRED:
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_NUMTYPE:
+ case FIELD_PROPERTY_AUTOINC:
+ case FIELD_PROPERTY_LENGTH:
+ case FIELD_PROPERTY_SCALE:
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ pDescrWin->SaveData(pActFieldDescr);
+
+ if ( FIELD_PROPERTY_AUTOINC == nColId && pActFieldDescr->IsAutoIncrement() )
+ {
+ OTableController& rController = GetView()->getController();
+ if ( rController.isAutoIncrementPrimaryKey() )
+ {
+ pActFieldDescr->SetPrimaryKey( true );
+ InvalidateHandleColumn();
+ Invalidate();
+ }
+ }
+ break;
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::SaveModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_uInt16 nColId = GetCurColumnId();
+
+ switch( nColId )
+ {
+ //////////////////////////////////////////////////////////////
+ // TypeCell
+ case FIELD_TYPE:
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Type umstellen
+ resetType();
+ } break;
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ if (!EditBrowseBox::CursorMoving(nNewRow, nNewCol))
+ return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wird nach SaveModified() gerufen, aktuelle Zeile ist noch die alte
+ m_nDataPos = nNewRow;
+ nOldDataPos = GetCurRow();
+
+ //////////////////////////////////////////////////////////////////////
+ // Marker umsetzen
+ InvalidateStatusCell( nOldDataPos );
+ InvalidateStatusCell( m_nDataPos );
+
+ //////////////////////////////////////////////////////////////////////
+ // Daten des Propertyfensters speichern
+ if( SetDataPtr(nOldDataPos) && pDescrWin)
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Daten im Propertyfenster anzeigen
+ if( SetDataPtr(m_nDataPos) && pDescrWin)
+ pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, InvalidateFieldType, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nInvalidateTypeEvent = 0;
+ Invalidate( GetFieldRectPixel(nOldDataPos, FIELD_TYPE) );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, EntryNotFound, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nEntryNotFoundEvent = 0;
+ ErrorBox( this, ModuleRes(ERR_INVALID_LISTBOX_ENTRY) ).Execute();
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ //////////////////////////////////////////////////////////////
+ // Wenn aktuelle Feldbeschreibung NULL, Default setzen
+ if(nRow == -1)
+ nRow = GetCurRow();
+ SetDataPtr( nRow );
+ OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
+
+ String sActionDescription;
+ switch ( nColId )
+ {
+ case FIELD_NAME: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_NAME ) ); break;
+ case FIELD_TYPE: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_TYPE ) ); break;
+ case HELP_TEXT:
+ case COLUMN_DESCRIPTION: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break;
+ default: sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_ATTRIBUTE ) ); break;
+ }
+
+ GetUndoManager().EnterListAction( sActionDescription, String() );
+ if (!pActFieldDescr)
+ {
+ const OTypeInfoMap* pTypeInfoMap = GetView()->getController().getTypeInfo();
+ if ( !pTypeInfoMap->empty() )
+ {
+ OTypeInfoMap::const_iterator aTypeIter = pTypeInfoMap->find(DataType::VARCHAR);
+ if ( aTypeIter == pTypeInfoMap->end() )
+ aTypeIter = pTypeInfoMap->begin();
+ pActRow->SetFieldType( aTypeIter->second );
+ }
+ else
+ pActRow->SetFieldType( GetView()->getController().getTypeInfoFallBack() );
+
+ nInvalidateTypeEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, InvalidateFieldType) );
+ pActFieldDescr = pActRow->GetActFieldDescr();
+ pDescrWin->DisplayData( pActFieldDescr );
+ GetUndoManager().AddUndoAction( new OTableEditorTypeSelUndoAct(this, nRow, nColId+1, TOTypeInfoSP()) );
+ }
+
+ if( nColId != FIELD_TYPE )
+ GetUndoManager().AddUndoAction( new OTableDesignCellUndoAct(this, nRow, nColId) );
+ else
+ {
+ GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, GetCurRow(), nColId, GetFieldDescr(GetCurRow())->getTypeInfo()));
+ resetType();
+ }
+
+ SaveData(nRow,nColId);
+ // SaveData could create a undo action as well
+ GetUndoManager().LeaveListAction();
+ RowModified(nRow);
+ CellControllerRef xController(Controller());
+ if(xController.Is())
+ xController->SetModified();
+
+ //////////////////////////////////////////////////////////////////////
+ // Das ModifyFlag setzen
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::resetType()
+{
+ sal_uInt16 nPos = pTypeCell->GetSelectEntryPos();
+ if(nPos != LISTBOX_ENTRY_NOTFOUND)
+ SwitchType( GetView()->getController().getTypeInfo(nPos) );
+ else
+ SwitchType(TOTypeInfoSP());
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CellModified()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ CellModified( GetCurRow(), GetCurColumnId() );
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::InvalidateFeatures()
+{
+ GetView()->getController().InvalidateFeature(SID_UNDO);
+ GetView()->getController().InvalidateFeature(SID_REDO);
+ GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Undo()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ InvalidateFeatures();
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Redo()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::CopyRows()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // set to the right row and save it
+ if( SetDataPtr(m_nDataPos) )
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////////////
+ // Selektierte Zeilen in die ClipboardListe kopieren
+ ::boost::shared_ptr<OTableRow> pClipboardRow;
+ ::boost::shared_ptr<OTableRow> pRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> > vClipboardList;
+ vClipboardList.reserve(GetSelectRowCount());
+
+ for( long nIndex=FirstSelectedRow(); nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()); nIndex=NextSelectedRow() )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ OSL_ENSURE(pRow,"OTableEditorCtrl::CopyRows: Row is NULL!");
+ if ( pRow && pRow->GetActFieldDescr() )
+ {
+ pClipboardRow.reset(new OTableRow( *pRow ));
+ vClipboardList.push_back( pClipboardRow);
+ }
+ }
+ if(!vClipboardList.empty())
+ {
+ OTableRowExchange* pData = new OTableRowExchange(vClipboardList);
+ Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
+ pData->CopyToClipboard(GetParent());
+ }
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GenerateName( const String& rName )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Basisnamen zum Anhaengen einer Numerierung erstellen
+ String aBaseName;
+ Reference<XConnection> xCon = GetView()->getController().getConnection();
+ Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
+
+ xub_StrLen nMaxTextLen((xub_StrLen)( xMetaData.is() ? xMetaData->getMaxColumnNameLength() : 0));
+
+ if( (rName.Len()+2) >nMaxTextLen )
+ aBaseName = rName.Copy( 0, nMaxTextLen-2 );
+ else
+ aBaseName = rName;
+
+ //////////////////////////////////////////////////////////////////////
+ // Namen durchnumerieren (bis 99)
+ String aFieldName( rName);
+ sal_Int32 i=1;
+ while( HasFieldName(aFieldName) )
+ {
+ aFieldName = aBaseName;
+ aFieldName += String::CreateFromInt32(i);
+ i++;
+ }
+
+ return aFieldName;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InsertRows( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> > vInsertedUndoRedoRows; // need for undo/redo handling
+ //////////////////////////////////////////////////////////////////////
+ // get rows from clipboard
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
+ {
+ SotStorageStreamRef aStreamRef;
+ aTransferData.GetSotStorageStream(SOT_FORMATSTR_ID_SBA_TABED,aStreamRef);
+ if(aStreamRef.Is())
+ {
+ aStreamRef->Seek(STREAM_SEEK_TO_BEGIN);
+ aStreamRef->ResetError();
+ long nInsertRow = nRow;
+ String aFieldName;
+ ::boost::shared_ptr<OTableRow> pRow;
+ sal_Int32 nSize = 0;
+ (*aStreamRef) >> nSize;
+ vInsertedUndoRedoRows.reserve(nSize);
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ pRow.reset(new OTableRow());
+ (*aStreamRef) >> *pRow;
+ pRow->SetReadOnly( sal_False );
+ sal_Int32 nType = pRow->GetActFieldDescr()->GetType();
+ if ( pRow->GetActFieldDescr() )
+ pRow->GetActFieldDescr()->SetType(GetView()->getController().getTypeInfoByType(nType));
+ //////////////////////////////////////////////////////////////////////
+ // Anpassen des Feldnamens
+ aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() );
+ pRow->GetActFieldDescr()->SetName( aFieldName );
+ pRow->SetPos(nInsertRow);
+ m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow );
+ vInsertedUndoRedoRows.push_back(::boost::shared_ptr<OTableRow>(new OTableRow(*pRow)));
+ nInsertRow++;
+ }
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Beim RowInserted wird CursorMoved gerufen.
+ // Die UI-Daten duerfen hier beim CursorMoved nicht gespeichert werden.
+ bSaveOnMove = sal_False;
+ RowInserted( nRow,vInsertedUndoRedoRows.size(),sal_True );
+ bSaveOnMove = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Action erzeugen
+ GetUndoManager().AddUndoAction( new OTableEditorInsUndoAct(this, nRow,vInsertedUndoRedoRows) );
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::DeleteRows()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OSL_ENSURE(GetView()->getController().isDropAllowed(),"Call of DeleteRows not valid here. Please check isDropAllowed!");
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Action erzeugen
+ GetUndoManager().AddUndoAction( new OTableEditorDelUndoAct(this) );
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Alle markierten Zeilen loeschen
+ long nIndex = FirstSelectedRow();
+ nOldDataPos = nIndex;
+ bSaveOnMove = sal_False;
+
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Zeile entfernen
+ m_pRowList->erase( m_pRowList->begin()+nIndex );
+ RowRemoved( nIndex, 1, sal_True );
+
+ //////////////////////////////////////////////////////////////////////
+ // Leerzeile am Ende wieder einfuegen
+ m_pRowList->push_back( ::boost::shared_ptr<OTableRow>(new OTableRow()));
+ RowInserted( GetRowCount()-1, 1, sal_True );
+
+ nIndex = FirstSelectedRow();
+ }
+
+ bSaveOnMove = sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // Erzwingen, dass der aktuelle Datensatz angezeigt wird
+ m_nDataPos = GetCurRow();
+ InvalidateStatusCell( nOldDataPos );
+ InvalidateStatusCell( m_nDataPos );
+ SetDataPtr( m_nDataPos );
+ ActivateCell();
+ pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::InsertNewRows( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OSL_ENSURE(GetView()->getController().isAddAllowed(),"Call of InsertNewRows not valid here. Please check isAppendAllowed!");
+ //////////////////////////////////////////////////////////////////////
+ // Undo-Action erzeugen
+ long nInsertRows = GetSelectRowCount();
+ if( !nInsertRows )
+ nInsertRows = 1;
+ GetUndoManager().AddUndoAction( new OTableEditorInsNewUndoAct(this, nRow, nInsertRows) );
+ //////////////////////////////////////////////////////////////////////
+ // Zahl der selektierten Zeilen werden neu eingefuegt
+ for( long i=nRow; i<(nRow+nInsertRows); i++ )
+ m_pRowList->insert( m_pRowList->begin()+i ,::boost::shared_ptr<OTableRow>(new OTableRow()));
+ RowInserted( nRow, nInsertRows, sal_True );
+
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GetControlText( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls des Browsers auslesen
+ if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
+ {
+ GoToRow( nRow );
+ GoToColumnId( nColId );
+ CellControllerRef xController = Controller();
+ if(xController.Is())
+ return xController->GetWindow().GetText();
+ else
+ return GetCellText(nRow,nColId);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls der Tabpage Auslesen
+ else
+ return pDescrWin->GetControlText( nColId );
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetControlText( long nRow, sal_uInt16 nColId, const String& rText )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls des Browsers setzen
+ if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
+ {
+ GoToRow( nRow );
+ GoToColumnId( nColId );
+ CellControllerRef xController = Controller();
+ if(xController.Is())
+ xController->GetWindow().SetText( rText );
+ else
+ RowModified(nRow,nColId);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls der Tabpage setzen
+ else
+ {
+ pDescrWin->SetControlText( nColId, rText );
+ }
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow == -1 )
+ nRow = GetCurRow();
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr && nColId != FIELD_TYPE)
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder setzen
+ switch( nColId )
+ {
+ case FIELD_TYPE:
+ SwitchType( _pTypeInfo );
+ break;
+ default:
+ OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
+ }
+ SetControlText(nRow,nColId,_pTypeInfo.get() ? _pTypeInfo->aUIName : ::rtl::OUString());
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rNewData )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow == -1 )
+ nRow = GetCurRow();
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr && nColId != FIELD_TYPE)
+ return;
+
+ String sValue;
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder setzen
+ switch( nColId )
+ {
+ case FIELD_NAME:
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetName( sValue );
+ break;
+
+ case FIELD_TYPE:
+ OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
+ break;
+
+ case COLUMN_DESCRIPTION:
+ pFieldDescr->SetDescription( sValue = ::comphelper::getString(_rNewData) );
+ break;
+
+ case FIELD_PROPERTY_DEFAULT:
+ pFieldDescr->SetControlDefault( _rNewData );
+ sValue = GetView()->GetDescWin()->getGenPage()->getFieldControl()->getControlDefault(pFieldDescr);
+ break;
+
+ case FIELD_PROPERTY_REQUIRED:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetIsNullable( sValue.ToInt32() );
+ }
+ break;
+
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_LENGTH:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetPrecision( sValue.ToInt32() );
+ }
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
+ break;
+
+ case FIELD_PROPERTY_AUTOINC:
+ {
+ String strYes(ModuleRes(STR_VALUE_YES));
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetAutoIncrement(sValue.Equals(strYes));
+ }
+ break;
+ case FIELD_PROPERTY_SCALE:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetScale(sValue.ToInt32());
+ }
+ break;
+
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ sValue = GetView()->GetDescWin()->BoolStringPersistent(::comphelper::getString(_rNewData));
+ pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(sValue)));
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ {
+ sValue = ::comphelper::getString(_rNewData);
+ pFieldDescr->SetFormatKey(sValue.ToInt32());
+ }
+ break;
+ }
+
+ SetControlText(nRow,nColId,sValue);
+}
+
+//------------------------------------------------------------------------------
+Any OTableEditorCtrl::GetCellData( long nRow, sal_uInt16 nColId )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
+ if( !pFieldDescr )
+ return Any();
+
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Datenzeiger umsetzen
+ if( nRow==-1 )
+ nRow = GetCurRow();
+ SetDataPtr( nRow );
+
+ static const String strYes(ModuleRes(STR_VALUE_YES));
+ static const String strNo(ModuleRes(STR_VALUE_NO));
+ ::rtl::OUString sValue;
+ //////////////////////////////////////////////////////////////////////
+ // Einzelne Felder auslesen
+ switch( nColId )
+ {
+ case FIELD_NAME:
+ sValue = pFieldDescr->GetName();
+ break;
+
+ case FIELD_TYPE:
+ if ( pFieldDescr->getTypeInfo() )
+ sValue = pFieldDescr->getTypeInfo()->aUIName;
+ break;
+
+ case COLUMN_DESCRIPTION:
+ sValue = pFieldDescr->GetDescription();
+ break;
+ case HELP_TEXT:
+ sValue = pFieldDescr->GetHelpText();
+ break;
+
+ case FIELD_PROPERTY_DEFAULT:
+ return pFieldDescr->GetControlDefault();
+
+ case FIELD_PROPERTY_REQUIRED:
+ sValue = pFieldDescr->GetIsNullable() == ColumnValue::NULLABLE ? strYes : strNo;
+ break;
+
+ case FIELD_PROPERTY_TEXTLEN:
+ case FIELD_PROPERTY_LENGTH:
+ sValue = String::CreateFromInt32(pFieldDescr->GetPrecision());
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ OSL_FAIL("OTableEditorCtrl::GetCellData: invalid column!");
+ break;
+
+ case FIELD_PROPERTY_AUTOINC:
+ sValue = pFieldDescr->IsAutoIncrement() ? strYes : strNo;
+ break;
+
+ case FIELD_PROPERTY_SCALE:
+ sValue = String::CreateFromInt32(pFieldDescr->GetScale());
+ break;
+
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ sValue = GetView()->GetDescWin()->BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault()));
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ sValue = String::CreateFromInt32(pFieldDescr->GetFormatKey());
+ break;
+ }
+
+ return makeAny(sValue);
+}
+
+//------------------------------------------------------------------------------
+String OTableEditorCtrl::GetCellText( long nRow, sal_uInt16 nColId ) const
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ ::rtl::OUString sCellText;
+ const_cast< OTableEditorCtrl* >( this )->GetCellData( nRow, nColId ) >>= sCellText;
+ return sCellText;
+}
+
+//------------------------------------------------------------------------------
+sal_uInt32 OTableEditorCtrl::GetTotalCellWidth(long nRow, sal_uInt16 nColId)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ return GetTextWidth(GetCellText(nRow, nColId)) + 2 * GetTextWidth('0');
+}
+
+//------------------------------------------------------------------------------
+OFieldDescription* OTableEditorCtrl::GetFieldDescr( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ std::vector< ::boost::shared_ptr<OTableRow> >::size_type nListCount(
+ m_pRowList->size());
+ if( (nRow<0) || (sal::static_int_cast< unsigned long >(nRow)>=nListCount) )
+ {
+ OSL_FAIL("(nRow<0) || (nRow>=nListCount)");
+ return NULL;
+ }
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[ nRow ];
+ if( !pRow )
+ return NULL;
+ return pRow->GetActFieldDescr();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bIsCutAllowed = (GetView()->getController().isAddAllowed() && GetView()->getController().isDropAllowed()) ||
+ GetView()->getController().isAlterAllowed();
+
+ if(bIsCutAllowed)
+ {
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ bIsCutAllowed = pDescrCell->GetSelected().Len() != 0;
+ break;
+ case HELPTEXT:
+ bIsCutAllowed = pHelpTextCell->GetSelected().Len() != 0;
+ break;
+ case NAME:
+ bIsCutAllowed = pNameCell->GetSelected().Len() != 0;
+ break;
+ case ROW:
+ bIsCutAllowed = IsCopyAllowed(nRow);
+ break;
+ default:
+ bIsCutAllowed = sal_False;
+ break;
+ }
+ }
+
+ return bIsCutAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsCopyAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bIsCopyAllowed = sal_False;
+ if(m_eChildFocus == DESCRIPTION )
+ bIsCopyAllowed = pDescrCell->GetSelected().Len() != 0;
+ else if(HELPTEXT == m_eChildFocus )
+ bIsCopyAllowed = pHelpTextCell->GetSelected().Len() != 0;
+ else if(m_eChildFocus == NAME)
+ bIsCopyAllowed = pNameCell->GetSelected().Len() != 0;
+ else if(m_eChildFocus == ROW)
+ {
+ Reference<XPropertySet> xTable = GetView()->getController().getTable();
+ if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"))))
+ return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn eine der markierten Zeilen leer ist, kein Copy moeglich
+ ::boost::shared_ptr<OTableRow> pRow;
+ long nIndex = FirstSelectedRow();
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ if( !pRow->GetActFieldDescr() )
+ return sal_False;
+
+ nIndex = NextSelectedRow();
+ }
+
+ bIsCopyAllowed = sal_True;
+ }
+
+ return bIsCopyAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPasteAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ sal_Bool bAllowed = GetView()->getController().isAddAllowed();
+ if ( bAllowed )
+ {
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ sal_Bool bRowFormat = aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED);
+ if ( m_eChildFocus == ROW )
+ bAllowed = bRowFormat;
+ else
+ bAllowed = !bRowFormat && aTransferData.HasFormat(SOT_FORMAT_STRING);
+ }
+
+ return bAllowed;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::cut()
+{
+ if(m_eChildFocus == NAME)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,FIELD_NAME);
+ pNameCell->Cut();
+ CellModified(-1,FIELD_NAME);
+ }
+ }
+ else if(m_eChildFocus == DESCRIPTION)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,COLUMN_DESCRIPTION);
+ pDescrCell->Cut();
+ CellModified(-1,COLUMN_DESCRIPTION);
+ }
+ }
+ else if(HELPTEXT == m_eChildFocus )
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ SaveData(-1,HELP_TEXT);
+ pHelpTextCell->Cut();
+ CellModified(-1,HELP_TEXT);
+ }
+ }
+ else if(m_eChildFocus == ROW)
+ {
+ if (nCutEvent)
+ Application::RemoveUserEvent(nCutEvent);
+ nCutEvent = Application::PostUserEvent(LINK(this, OTableEditorCtrl, DelayedCut));
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::copy()
+{
+ if(GetSelectRowCount())
+ OTableRowView::copy();
+ else if(m_eChildFocus == NAME)
+ pNameCell->Copy();
+ else if(HELPTEXT == m_eChildFocus )
+ pHelpTextCell->Copy();
+ else if(m_eChildFocus == DESCRIPTION )
+ pDescrCell->Copy();
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::paste()
+{
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
+ {
+ if( nPasteEvent )
+ Application::RemoveUserEvent( nPasteEvent );
+ nPasteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedPaste) );
+ }
+ else if(m_eChildFocus == NAME)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pNameCell->Paste();
+ CellModified();
+ }
+ }
+ else if(HELPTEXT == m_eChildFocus )
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pHelpTextCell->Paste();
+ CellModified();
+ }
+ }
+ else if(m_eChildFocus == DESCRIPTION)
+ {
+ if(GetView()->getController().isAlterAllowed())
+ {
+ pDescrCell->Paste();
+ CellModified();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsDeleteAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ return GetSelectRowCount() != 0 && GetView()->getController().isDropAllowed();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsInsertNewAllowed( long nRow )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+
+ sal_Bool bInsertNewAllowed = GetView()->getController().isAddAllowed();
+ //////////////////////////////////////////////////////////////
+ // Wenn nur Felder hinzugefuegt werden duerfen, Paste nur in neue Felder
+ if (bInsertNewAllowed && !GetView()->getController().isDropAllowed())
+ {
+ SetDataPtr(nRow);
+ if( GetActRow()->IsReadOnly() )
+ return sal_False;
+ }
+
+ return bInsertNewAllowed;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ if( !GetSelectRowCount() )
+ return sal_False;
+
+ OTableController& rController = GetView()->getController();
+ if ( !rController.getSdbMetaData().supportsPrimaryKeys() )
+ return sal_False;
+
+ Reference<XPropertySet> xTable = rController.getTable();
+ //////////////////////////////////////////////////////////////
+ // Key darf nicht veraendert werden
+ // Dies gilt jedoch nur, wenn die Tabelle nicht neu ist und keine ::com::sun::star::sdbcx::View. Ansonsten wird kein DROP ausgeführt
+
+ if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")))
+ return sal_False;
+ //////////////////////////////////////////////////////////////
+ // Wenn leeres Feld, kein PrimKey
+ // Eintrag wird nur erlaubt, wenn
+ // - kein leerer Eintrag in der Selection ist
+ // - kein Eintrag vom Typ Memo oder Image ist
+ // - kein DROP erlaubt ist (s.o.) und die Spalte noch kein Required (not null) gesetzt hatte.
+ long nIndex = FirstSelectedRow();
+ ::boost::shared_ptr<OTableRow> pRow;
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ pRow = (*m_pRowList)[nIndex];
+ OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
+ if(!pFieldDescr)
+ return sal_False;
+ else
+ {
+ //////////////////////////////////////////////////////////////
+ // Wenn Feldtyp Memo oder Image, kein PrimKey
+ // oder wenn Spalten nicht gedroped werden können und das Required Flag ist nicht gesetzt
+ // oder wenn eine ::com::sun::star::sdbcx::View vorhanden ist und das Required Flag nicht gesetzt ist
+ TOTypeInfoSP pTypeInfo = pFieldDescr->getTypeInfo();
+ if( pTypeInfo->nSearchType == ColumnSearch::NONE
+ || (pFieldDescr->IsNullable() && pRow->IsReadOnly())
+ )
+ return sal_False;
+ }
+
+ nIndex = NextSelectedRow();
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::Command(const CommandEvent& rEvt)
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ Point aMenuPos( rEvt.GetMousePosPixel() );
+ if (!rEvt.IsMouseEvent())
+ {
+ if ( 1 == GetSelectColumnCount() )
+ {
+ sal_uInt16 nSelId = GetColumnId(
+ sal::static_int_cast< sal_uInt16 >(
+ FirstSelectedColumn() ) );
+ ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
+
+ aMenuPos = aColRect.TopCenter();
+ }
+ else if ( GetSelectRowCount() > 0 )
+ {
+ ::Rectangle aColRect( GetFieldRectPixel( FirstSelectedRow(), HANDLE_ID, sal_True ) );
+
+ aMenuPos = aColRect.TopCenter();
+ }
+ else
+ {
+ OTableRowView::Command(rEvt);
+ return;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Kontextmenu einblenden
+ if( !IsReadOnly() )
+ {
+ sal_uInt16 nColId = GetColumnAtXPosPixel(aMenuPos.X());
+ long nRow = GetRowAtYPosPixel(aMenuPos.Y());
+
+ if ( HANDLE_ID != nColId )
+ {
+ if ( nRow < 0 && nColId != BROWSER_INVALIDID )
+ { // hit the header
+ if ( 3 != nColId )
+ { // 3 would mean the last column, and this last column is auto-sized
+ if ( !IsColumnSelected( nColId ) )
+ SelectColumnId( nColId );
+
+ PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
+ aContextMenu.EnableItem( SID_DELETE, sal_False );
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+ switch ( aContextMenu.Execute( this, aMenuPos ) )
+ {
+ case ID_BROWSER_COLWIDTH:
+ adjustBrowseBoxColumnWidth( this, nColId );
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
+
+ aContextMenu.EnableItem( SID_CUT, IsCutAllowed(nRow) );
+ aContextMenu.EnableItem( SID_COPY, IsCopyAllowed(nRow) );
+ aContextMenu.EnableItem( SID_PASTE, IsPasteAllowed(nRow) );
+ aContextMenu.EnableItem( SID_DELETE, IsDeleteAllowed(nRow) );
+ aContextMenu.EnableItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsPrimaryKeyAllowed(nRow) );
+ aContextMenu.EnableItem( SID_TABLEDESIGN_INSERTROWS, IsInsertNewAllowed(nRow) );
+ aContextMenu.CheckItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsRowSelected(GetCurRow()) && IsPrimaryKey() );
+
+ // jetzt alles, was disabled wurde, wech
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+
+ if( SetDataPtr(m_nDataPos) )
+ pDescrWin->SaveData( pActRow->GetActFieldDescr() );
+
+ //////////////////////////////////////////////////////////////
+ // Alle Aktionen, die die Zeilenzahl veraendern, muessen asynchron
+ // ausgefuehrt werden->sonst Probleme zwischen Kontextmenu u. Browser
+ m_nDataPos = GetCurRow();
+ switch (aContextMenu.Execute(this, aMenuPos))
+ {
+ case SID_CUT:
+ cut();
+ break;
+ case SID_COPY:
+ copy();
+ break;
+ case SID_PASTE:
+ paste();
+ break;
+ case SID_DELETE:
+ if( nDeleteEvent )
+ Application::RemoveUserEvent( nDeleteEvent );
+ nDeleteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedDelete) );
+ break;
+ case SID_TABLEDESIGN_INSERTROWS:
+ if( nInsNewRowsEvent )
+ Application::RemoveUserEvent( nInsNewRowsEvent );
+ nInsNewRowsEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedInsNewRows) );
+ break;
+ case SID_TABLEDESIGN_TABED_PRIMARYKEY:
+ SetPrimaryKey( !IsPrimaryKey() );
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ break;
+ default:
+ OTableRowView::Command(rEvt);
+ }
+
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedCut, void*, /*EMPTYTAG*/ )
+{
+ nCutEvent = 0;
+ OTableRowView::cut();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedPaste, void*, /*EMPTYTAG*/ )
+{
+ nPasteEvent = 0;
+
+ sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
+ if ( !GetView()->getController().getTable().is() )
+ nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : GetCurRow();
+
+ if (!IsInsertNewAllowed(nPastePosition))
+ { // kein Einfuegen erlaubt, sondern nur anhaengen, also testen, ob hinter der PastePosition noch
+ // belegte Zeilen erscheinen
+
+ sal_Int32 nFreeFromPos; // ab da nur freie Zeilen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::reverse_iterator aIter = m_pRowList->rbegin();
+ for(nFreeFromPos = m_pRowList->size();
+ aIter != m_pRowList->rend() && (!(*aIter) || !(*aIter)->GetActFieldDescr() || !(*aIter)->GetActFieldDescr()->GetName().getLength());
+ --nFreeFromPos, ++aIter)
+ ;
+ if (nPastePosition < nFreeFromPos) // es gibt mindestens eine belegte hinter PastePosition -> ganz nach hinten
+ nPastePosition = nFreeFromPos;
+ }
+
+ OTableRowView::Paste( nPastePosition );
+ SetNoSelection();
+ GoToRow( nPastePosition );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedDelete, void*, /*EMPTYTAG*/ )
+{
+ nDeleteEvent = 0;
+ DeleteRows();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableEditorCtrl, DelayedInsNewRows, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ nInsNewRowsEvent = 0;
+ sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
+ if ( !GetView()->getController().getTable().is() )
+ nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : m_nDataPos;
+
+ InsertNewRows( nPastePosition );
+ SetNoSelection();
+ GoToRow( nPastePosition );
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::AdjustFieldDescription(OFieldDescription* _pFieldDesc,
+ MultiSelection& _rMultiSel,
+ sal_Int32 _nPos,
+ sal_Bool _bSet,
+ sal_Bool _bPrimaryKey)
+{
+ _pFieldDesc->SetPrimaryKey( _bPrimaryKey );
+ if(!_bSet && _pFieldDesc->getTypeInfo()->bNullable)
+ {
+ _pFieldDesc->SetIsNullable(ColumnValue::NO_NULLS);
+ _pFieldDesc->SetControlDefault(Any());
+ }
+ if ( _pFieldDesc->IsAutoIncrement() && !_bPrimaryKey )
+ {
+ OTableController& rController = GetView()->getController();
+ if ( rController.isAutoIncrementPrimaryKey() )
+ {
+ _pFieldDesc->SetAutoIncrement(false);
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // update field description
+ pDescrWin->DisplayData(_pFieldDesc);
+
+ _rMultiSel.Insert( _nPos );
+ _rMultiSel.Select( _nPos );
+}
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Evtl. vorhandene Primary Keys loeschen
+ MultiSelection aDeletedPrimKeys;
+ aDeletedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
+ for(sal_Int32 nRow = 0;aIter != aEnd;++aIter,++nRow)
+ {
+ OFieldDescription* pFieldDescr = (*aIter)->GetActFieldDescr();
+ if( pFieldDescr && (*aIter)->IsPrimaryKey() && (!bSet || !IsRowSelected(nRow)) )
+ {
+ AdjustFieldDescription(pFieldDescr,aDeletedPrimKeys,nRow,bSet,sal_False);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Die Primary Keys der markierten Zeilen setzen
+ MultiSelection aInsertedPrimKeys;
+ aInsertedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
+ if( bSet )
+ {
+ long nIndex = FirstSelectedRow();
+ while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Key setzen
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[nIndex];
+ OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
+ if(pFieldDescr)
+ AdjustFieldDescription(pFieldDescr,aInsertedPrimKeys,nIndex,sal_False,sal_True);
+
+ nIndex = NextSelectedRow();
+ }
+ }
+
+ GetUndoManager().AddUndoAction( new OPrimKeyUndoAct(this, aDeletedPrimKeys, aInsertedPrimKeys) );
+
+ //////////////////////////////////////////////////////////////////////
+ // Handle-Spalte invalidieren
+ InvalidateHandleColumn();
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Das ModifyFlag der TableDocSh setzen
+ GetView()->getController().setModified( sal_True );
+ InvalidateFeatures();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OTableEditorCtrl::IsPrimaryKey()
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Gehoeren alle markierten Felder zu einem Primary Key ?
+ long nPrimaryKeys = 0;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
+ for(sal_Int32 nRow=0;aIter != aEnd;++aIter,++nRow)
+ {
+ if( IsRowSelected(nRow) && !(*aIter)->IsPrimaryKey() )
+ return sal_False;
+ if( (*aIter)->IsPrimaryKey() )
+ ++nPrimaryKeys;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Gibt es unselektierte Felder, die noch zu dem Key gehoeren ?
+ return GetSelectRowCount() == nPrimaryKeys;
+}
+
+//------------------------------------------------------------------------------
+void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType )
+{
+ DBG_CHKTHIS(OTableEditorCtrl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Wenn noch kein Feldname vergeben wurde
+ long nRow(GetCurRow());
+ OFieldDescription* pActFieldDescr = GetFieldDescr( nRow );
+ if( pActFieldDescr )
+ //////////////////////////////////////////////////////////////////////
+ // Alte Beschreibung speichern
+ pDescrWin->SaveData( pActFieldDescr );
+
+ if ( nRow < 0 || nRow > static_cast<long>(m_pRowList->size()) )
+ return;
+ //////////////////////////////////////////////////////////////////////
+ // Neue Beschreibung darstellen
+ ::boost::shared_ptr<OTableRow> pRow = (*m_pRowList)[nRow];
+ pRow->SetFieldType( _pType, sal_True );
+ if ( _pType.get() )
+ {
+ const sal_uInt16 nCurrentlySelected = pTypeCell->GetSelectEntryPos();
+
+ if ( ( LISTBOX_ENTRY_NOTFOUND == nCurrentlySelected )
+ || ( GetView()->getController().getTypeInfo( nCurrentlySelected ) != _pType )
+ )
+ {
+ sal_uInt16 nEntryPos = 0;
+ const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter,++nEntryPos)
+ {
+ if(aIter->second == _pType)
+ break;
+ }
+ if (nEntryPos < pTypeCell->GetEntryCount())
+ pTypeCell->SelectEntryPos( nEntryPos );
+ }
+ }
+
+ pActFieldDescr = pRow->GetActFieldDescr();
+ if (pActFieldDescr != NULL && !pActFieldDescr->GetFormatKey())
+ {
+ sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( pActFieldDescr->GetType(),
+ pActFieldDescr->GetScale(),
+ pActFieldDescr->IsCurrency(),
+ Reference< XNumberFormatTypes>(GetView()->getController().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY),
+ GetView()->getLocale());
+
+ pActFieldDescr->SetFormatKey(nFormatKey);
+ }
+
+ pDescrWin->DisplayData( pActFieldDescr );
+}
+// -----------------------------------------------------------------------------
+OTableDesignView* OTableEditorCtrl::GetView() const
+{
+ return static_cast<OTableDesignView*>(GetParent()->GetParent());
+}
+// -----------------------------------------------------------------------------
+void OTableEditorCtrl::DeactivateCell(sal_Bool bUpdate)
+{
+ OTableRowView::DeactivateCell(bUpdate);
+ // now we have to deactivate the field description
+ long nRow(GetCurRow());
+ if (pDescrWin)
+ pDescrWin->SetReadOnly(bReadOnly || !SetDataPtr(nRow) || GetActRow()->IsReadOnly());
+}
+//------------------------------------------------------------------------------
+long OTableEditorCtrl::PreNotify( NotifyEvent& rNEvt )
+{
+ if (rNEvt.GetType() == EVENT_GETFOCUS)
+ {
+ if( pHelpTextCell && pHelpTextCell->HasChildPathFocus() )
+ m_eChildFocus = HELPTEXT;
+ else if( pDescrCell && pDescrCell->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else if(pNameCell && pNameCell->HasChildPathFocus() )
+ m_eChildFocus = NAME;
+ else
+ m_eChildFocus = ROW;
+ }
+
+ return OTableRowView::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TEditControl.hxx b/dbaccess/source/ui/tabledesign/TEditControl.hxx
new file mode 100644
index 000000000000..3128d979b681
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TEditControl.hxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEEDITORCONTROL_HXX
+#define DBAUI_TABLEEDITORCONTROL_HXX
+
+#include "TableDesignControl.hxx"
+#include "TableDesignView.hxx"
+#include "TableFieldDescWin.hxx"
+#include "TableRow.hxx"
+#include "QEnumTypes.hxx"
+#include "TypeInfo.hxx"
+
+class Edit;
+class SfxUndoManager;
+namespace dbaui
+{
+ class OSQLNameEdit;
+
+ class OTableEditorCtrl : public OTableRowView
+ {
+ enum ChildFocusState
+ {
+ HELPTEXT,
+ DESCRIPTION,
+ NAME,
+ ROW,
+ NONE
+ };
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_aUndoList;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* m_pRowList;
+
+ OSQLNameEdit* pNameCell;
+ ::svt::ListBoxControl* pTypeCell;
+ Edit* pHelpTextCell;
+ Edit* pDescrCell;
+ OTableFieldDescWin* pDescrWin; // properties of one column
+
+ ::boost::shared_ptr<OTableRow> pActRow;
+
+ sal_uLong nIndexEvent;
+ sal_uLong nCutEvent;
+ sal_uLong nPasteEvent;
+ sal_uLong nDeleteEvent;
+ sal_uLong nInsNewRowsEvent;
+ sal_uLong nInvalidateTypeEvent;
+ sal_uLong nEntryNotFoundEvent;
+ ChildFocusState m_eChildFocus;
+
+ long nOldDataPos;
+
+ sal_Bool bSaveOnMove;
+ sal_Bool bReadOnly;
+ //------------------------------------------------------------------
+ // Hilfsklasse
+ class ClipboardInvalidator
+ {
+ private:
+ AutoTimer m_aInvalidateTimer;
+ OTableEditorCtrl* m_pOwner;
+
+ public:
+ ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl*);
+ ~ClipboardInvalidator();
+
+ protected:
+ DECL_LINK(OnInvalidate, void*);
+ };
+ friend class OTableEditorCtrl::ClipboardInvalidator;
+
+ ClipboardInvalidator m_aInvalidate;
+
+ protected:
+ virtual void Command( const CommandEvent& rEvt );
+ virtual sal_Bool SeekRow(long nRow);
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect,
+ sal_uInt16 nColumnId ) const;
+
+ virtual void CursorMoved();
+ virtual RowStatus GetRowStatus(long nRow) const;
+
+ virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
+ virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
+
+ virtual void CellModified();
+ virtual sal_Bool SaveModified(); // wird aufgerufen vor einem Zellenwechsel
+ // return sal_False, verhindert Zellenwechsel
+ virtual void Undo();
+ virtual void Redo();
+ virtual String GetCellText(long nRow, sal_uInt16 nColId) const;
+ virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
+
+ virtual void CopyRows();
+ virtual void InsertRows( long nRow );
+ virtual void DeleteRows();
+ virtual void InsertNewRows( long nRow );
+
+ virtual sal_Bool IsPrimaryKeyAllowed( long nRow );
+ virtual sal_Bool IsInsertNewAllowed( long nRow );
+ virtual sal_Bool IsDeleteAllowed( long nRow );
+
+ void ClearModified();
+
+ void SetPrimaryKey( sal_Bool bSet );
+ sal_Bool IsPrimaryKey();
+
+ DECL_LINK(ControlPreNotifyHdl, NotifyEvent*);
+
+ public:
+ // TYPEINFO();
+ OTableEditorCtrl(Window* pParentWin);
+ virtual ~OTableEditorCtrl();
+ virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol);
+ virtual void UpdateAll();
+ SfxUndoManager& GetUndoManager() const;
+
+ void SetDescrWin( OTableFieldDescWin* pWin ){ pDescrWin = pWin; if (pDescrWin && pActRow) pDescrWin->DisplayData(pActRow->GetActFieldDescr()); }
+ sal_Bool SaveCurRow();
+ void SwitchType( const TOTypeInfoSP& _pType );
+
+ void DisplayData( long nRow, sal_Bool bGrabFocus = sal_True );
+ // erzwingt das Anzeigen der genannten Zeile (selbst wenn es eigentlich schon die aktuelle ist)
+
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo );
+ virtual void SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rSaveData );
+ virtual ::com::sun::star::uno::Any GetCellData( long nRow, sal_uInt16 nColId );
+ virtual void SetControlText( long nRow, sal_uInt16 nColId, const String& rText );
+ virtual String GetControlText( long nRow, sal_uInt16 nColId );
+
+ virtual OTableDesignView* GetView() const;
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* GetRowList(){ return m_pRowList; }
+
+ ::boost::shared_ptr<OTableRow> GetActRow(){ return pActRow; }
+ void CellModified( long nRow, sal_uInt16 nColId );
+ void SetReadOnly( sal_Bool bRead=sal_True );
+
+ virtual void Init();
+ virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
+
+ sal_Bool IsCutAllowed( long nRow = -1 );
+ sal_Bool IsCopyAllowed( long nRow = -1 );
+ sal_Bool IsPasteAllowed( long nRow = -1 );
+ sal_Bool IsReadOnly();
+ OFieldDescription* GetFieldDescr( long nRow );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed() { return IsCutAllowed(); }
+ virtual sal_Bool isCopyAllowed() { return IsCopyAllowed(); }
+ virtual sal_Bool isPasteAllowed() { return IsPasteAllowed(); }
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void cut();
+ virtual void copy();
+ virtual void paste();
+ private:
+ DECL_LINK( StartIndexing, void* );
+ DECL_LINK( DelayedCut, void* );
+ DECL_LINK( DelayedPaste, void* );
+ DECL_LINK( DelayedDelete, void* );
+ DECL_LINK( DelayedInsNewRows, void* );
+ DECL_LINK( InvalidateFieldType, void* );
+ DECL_LINK( EntryNotFound, void* );
+
+ void InitCellController();
+ sal_Int32 HasFieldName( const String& rFieldName );
+ String GenerateName( const String& rName );
+ sal_Bool SetDataPtr( long nRow );
+
+ sal_Bool SaveData(long nRow, sal_uInt16 nColumnId);
+ /** AdjustFieldDescription set the needed values for the description
+ @param _pFieldDesc the field description where to set the values
+ @param _rMultiSel contains the postions which changed for undo/redo
+ @param _nPos the current position
+ @param _bSet should a key be set
+ @param _bPrimaryKey which value should the pkey have
+ */
+ void AdjustFieldDescription( OFieldDescription* _pFieldDesc,
+ MultiSelection& _rMultiSel,
+ sal_Int32 _nPos,
+ sal_Bool _bSet,
+ sal_Bool _bPrimaryKey);
+ /** InvalidateFeatures invalidates the slots SID_UNDO | SID_REDO | SID_SAVEDOC
+ */
+ void InvalidateFeatures();
+
+ void resetType();
+ };
+}
+#endif // DBAUI_TABLEEDITORCONTROL_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
new file mode 100644
index 000000000000..b79eba4f8378
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -0,0 +1,1600 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "FieldDescriptions.hxx"
+#include "TEditControl.hxx"
+#include "TableController.hxx"
+#include "TableDesignView.hxx"
+#include "TableRow.hxx"
+#include "TypeInfo.hxx"
+#include "UITools.hxx"
+#include "browserids.hxx"
+#include "dbu_reghelper.hxx"
+#include "dbu_tbl.hrc"
+#include "dbustrings.hrc"
+#include "defaultobjectnamecheck.hxx"
+#include "dlgsave.hxx"
+#include "dsmeta.hxx"
+#include "indexdialog.hxx"
+#include "sqlmessage.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XTitleChangeListener.hpp>
+#include <com/sun/star/frame/XUntitledNumbers.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XAlterTable.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XDrop.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/streamsection.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbmetadata.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <tools/diagnose_ex.h>
+#include <tools/string.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <boost/mem_fn.hpp>
+#include <boost/bind.hpp>
+
+#include <algorithm>
+#include <functional>
+
+extern "C" void SAL_CALL createRegistryInfo_OTableControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTableController > aAutoRegistration;
+}
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::util;
+using namespace ::dbtools;
+using namespace ::dbaui;
+using namespace ::comphelper;
+
+// Anzahl Spalten beim Neuanlegen
+#define NEWCOLS 128
+
+namespace
+{
+ void dropTable(const Reference<XNameAccess>& _rxTable,const ::rtl::OUString& _sTableName)
+ {
+ if ( _rxTable->hasByName(_sTableName) )
+ {
+ Reference<XDrop> xNameCont(_rxTable,UNO_QUERY);
+ OSL_ENSURE(xNameCont.is(),"No drop interface for tables!");
+ if ( xNameCont.is() )
+ xNameCont->dropByName(_sTableName);
+ }
+ }
+ //------------------------------------------------------------------------------
+ struct OTableRowCompare : public ::std::binary_function< ::boost::shared_ptr<OTableRow> , ::rtl::OUString, bool>
+ {
+ bool operator() (const ::boost::shared_ptr<OTableRow> lhs, const ::rtl::OUString& rhs) const
+ {
+ OFieldDescription* pField = lhs->GetActFieldDescr();
+ return pField && pField->GetName() == rhs;
+ }
+ };
+
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTableController::getImplementationName() throw( RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString OTableController::getImplementationName_Static() throw( RuntimeException )
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OTableDesign"));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> OTableController::getSupportedServiceNames_Static(void) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.TableDesign"));
+ return aSupported;
+}
+//-------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL OTableController::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OTableController::Create(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OTableController(_rxFactory));
+}
+
+DBG_NAME(OTableController)
+// -----------------------------------------------------------------------------
+OTableController::OTableController(const Reference< XMultiServiceFactory >& _rM) : OTableController_BASE(_rM)
+ ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ ,m_pTypeInfo()
+ ,m_bAllowAutoIncrementValue(sal_False)
+ ,m_bNew(sal_True)
+{
+ DBG_CTOR(OTableController,NULL);
+
+ InvalidateAll();
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+}
+// -----------------------------------------------------------------------------
+OTableController::~OTableController()
+{
+ m_aTypeInfoIndex.clear();
+ m_aTypeInfo.clear();
+
+ DBG_DTOR(OTableController,NULL);
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::startTableListening()
+{
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(static_cast<XModifyListener*>(this));
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::stopTableListening()
+{
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener(static_cast<XModifyListener*>(this));
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::disposing()
+{
+ OTableController_BASE::disposing();
+ clearView();
+
+ m_vRowList.clear();
+}
+// -----------------------------------------------------------------------------
+FeatureState OTableController::GetState(sal_uInt16 _nId) const
+{
+ FeatureState aReturn;
+ // (disabled automatically)
+
+ switch (_nId)
+ {
+ case ID_BROWSER_CLOSE:
+ aReturn.bEnabled = sal_True;
+ break;
+ case ID_BROWSER_EDITDOC:
+ aReturn.bChecked = isEditable();
+ aReturn.bEnabled = m_bNew || isEditable();// the editable flag is set through this one -> || isAddAllowed() || isDropAllowed() || isAlterAllowed();
+ break;
+ case ID_BROWSER_SAVEDOC:
+ aReturn.bEnabled = impl_isModified();
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ aReturn.bEnabled = isConnected() && isEditable();
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+
+ case ID_BROWSER_CUT:
+ aReturn.bEnabled = isEditable() && m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isCutAllowed();
+ break;
+ case ID_BROWSER_COPY:
+ aReturn.bEnabled = m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isCopyAllowed();
+ break;
+ case ID_BROWSER_PASTE:
+ aReturn.bEnabled = isEditable() && m_aCurrentFrame.isActive() && getView() && static_cast<OTableDesignView*>(getView())->isPasteAllowed();
+ break;
+ case SID_INDEXDESIGN:
+ aReturn.bEnabled =
+ ( ( ((!m_bNew && impl_isModified()) || impl_isModified())
+ || Reference< XIndexesSupplier >(m_xTable, UNO_QUERY).is()
+ )
+ && isConnected()
+ );
+ if ( aReturn.bEnabled )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ aReturn.bEnabled = aIter != m_vRowList.end();
+ }
+ break;
+ default:
+ aReturn = OTableController_BASE::GetState(_nId);
+ }
+ return aReturn;
+}
+// -----------------------------------------------------------------------------
+void OTableController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
+{
+ switch(_nId)
+ {
+ case ID_BROWSER_EDITDOC:
+ setEditable(!isEditable());
+ static_cast<OTableDesignView*>(getView())->setReadOnly(!isEditable());
+ InvalidateFeature(ID_BROWSER_PASTE);
+ InvalidateFeature(SID_BROWSER_CLEAR_QUERY);
+ break;
+ case ID_BROWSER_SAVEASDOC:
+ doSaveDoc(sal_True);
+ break;
+ case ID_BROWSER_SAVEDOC:
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->SaveCurRow();
+ doSaveDoc(sal_False);
+ break;
+ case ID_BROWSER_CUT:
+ static_cast<OTableDesignView*>(getView())->cut();
+ break;
+ case ID_BROWSER_COPY:
+ static_cast<OTableDesignView*>(getView())->copy();
+ break;
+ case ID_BROWSER_PASTE:
+ static_cast<OTableDesignView*>(getView())->paste();
+ break;
+ case SID_INDEXDESIGN:
+ doEditIndexes();
+ break;
+ default:
+ OTableController_BASE::Execute(_nId,aArgs);
+ }
+ InvalidateFeature(_nId);
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::doSaveDoc(sal_Bool _bSaveAs)
+{
+ if (!isConnected())
+ reconnect(sal_True); // ask the user for a new connection
+ Reference<XTablesSupplier> xTablesSup(getConnection(),UNO_QUERY);
+
+ if (!xTablesSup.is())
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_CONNECTION_MISSING));
+ OSQLWarningBox( getView(), aMessage ).Execute();
+ return sal_False;
+ }
+
+ // check if a column exists
+ // TODO
+
+ Reference<XNameAccess> xTables;
+ ::rtl::OUString sCatalog, sSchema;
+
+ sal_Bool bNew = (0 == m_sName.getLength());
+ bNew = bNew || m_bNew || _bSaveAs;
+
+ try
+ {
+ xTables = xTablesSup->getTables();
+ OSL_ENSURE(xTables.is(),"The tables can't be null!");
+ bNew = bNew || (xTables.is() && !xTables->hasByName(m_sName));
+
+ // first we need a name for our query so ask the user
+ if(bNew)
+ {
+ String aDefaultName;
+ if (_bSaveAs && !bNew)
+ aDefaultName = String(m_sName);
+ else
+ {
+ String aName = String(ModuleRes(STR_TBL_TITLE));
+ aDefaultName = aName.GetToken(0,' ');
+ aDefaultName = ::dbtools::createUniqueName(xTables,aDefaultName);
+ }
+
+ DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::TABLE );
+ OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), getConnection(), aDefaultName, aNameChecker );
+ if ( aDlg.Execute() != RET_OK )
+ return sal_False;
+
+ m_sName = aDlg.getName();
+ sCatalog = aDlg.getCatalog();
+ sSchema = aDlg.getSchema();
+ }
+
+ // did we get a name
+ if(!m_sName.getLength())
+ return sal_False;
+ }
+ catch(Exception&)
+ {
+ OSL_FAIL("OTableController::doSaveDoc: nothing is expected to happen here!");
+ }
+
+ sal_Bool bAlter = sal_False;
+ sal_Bool bError = sal_False;
+ SQLExceptionInfo aInfo;
+ try
+ {
+ // check the columns for double names
+ if(!checkColumns(bNew || !xTables->hasByName(m_sName)))
+ {
+ return sal_False;
+ }
+
+ Reference<XPropertySet> xTable;
+ if(bNew || !xTables->hasByName(m_sName)) // just to make sure the table already exists
+ {
+ dropTable(xTables,m_sName);
+
+ Reference<XDataDescriptorFactory> xFact(xTables,UNO_QUERY);
+ OSL_ENSURE(xFact.is(),"OTableController::doSaveDoc: No XDataDescriptorFactory available!");
+ xTable = xFact->createDataDescriptor();
+ OSL_ENSURE(xTable.is(),"OTableController::doSaveDoc: Create query failed!");
+ // to set the name is only allowed when the wuery is new
+ xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));
+ xTable->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(sSchema));
+ xTable->setPropertyValue(PROPERTY_NAME,makeAny(m_sName));
+
+ // now append the columns
+ Reference<XColumnsSupplier> xColSup(xTable,UNO_QUERY);
+ appendColumns(xColSup,bNew);
+ // now append the primary key
+ Reference<XKeysSupplier> xKeySup(xTable,UNO_QUERY);
+ appendPrimaryKey(xKeySup,bNew);
+ }
+ // now set the properties
+ if(bNew)
+ {
+ Reference<XAppend> xAppend(xTables,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"OTableController::doSaveDoc: No XAppend Interface!");
+ xAppend->appendByDescriptor(xTable);
+
+ assignTable();
+ if(!m_xTable.is()) // correct name and try again
+ {
+ // it can be that someone inserted new data for us
+ m_sName = ::dbtools::composeTableName( getConnection()->getMetaData(), xTable, ::dbtools::eInDataManipulation, false, false, false );
+ assignTable();
+ }
+ // now check if our datasource has set a tablefilter and if append the new table name to it
+ ::dbaui::appendToFilter(getConnection(),m_sName,getORB(),getView()); // we are not interessted in the return value
+ Reference< frame::XTitleChangeListener> xEventListener(impl_getTitleHelper_throw(),UNO_QUERY);
+ if ( xEventListener.is() )
+ {
+ frame::TitleChangedEvent aEvent;
+ xEventListener->titleChanged(aEvent);
+ }
+ releaseNumberForComponent();
+ }
+ else if(m_xTable.is())
+ {
+ bAlter = sal_True;
+ alterColumns();
+ }
+ reSyncRows();
+ }
+ catch(const SQLContext& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLWarning& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLException& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const ElementExistException& )
+ {
+ String sText( ModuleRes( STR_NAME_ALREADY_EXISTS ) );
+ sText.SearchAndReplaceAscii( "#" , m_sName);
+ OSQLMessageBox aDlg( getView(), String( ModuleRes( STR_ERROR_DURING_CREATION ) ), sText, WB_OK, OSQLMessageBox::Error );
+
+ aDlg.Execute();
+ bError = sal_True;
+ }
+ catch( const Exception& )
+ {
+ bError = sal_True;
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( aInfo.isValid() )
+ aInfo.prepend( String( ModuleRes( STR_TABLEDESIGN_SAVE_ERROR ) ) );
+ showError(aInfo);
+
+ if (aInfo.isValid() || bError)
+ {
+ if(!bAlter || bNew)
+ {
+ m_sName = ::rtl::OUString();
+ stopTableListening();
+ m_xTable = NULL;
+ }
+ }
+ return ! (aInfo.isValid() || bError);
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::doEditIndexes()
+{
+ // table needs to be saved before editing indexes
+ if (m_bNew || isModified())
+ {
+ QueryBox aAsk(getView(), ModuleRes(QUERY_SAVE_TABLE_EDIT_INDEXES));
+ if (RET_YES != aAsk.Execute())
+ return;
+
+ if (!doSaveDoc(sal_False))
+ return;
+
+ OSL_ENSURE(!m_bNew && !isModified(), "OTableController::doEditIndexes: what the hell did doSaveDoc do?");
+ }
+
+ Reference< XNameAccess > xIndexes; // will be the keys of the table
+ Sequence< ::rtl::OUString > aFieldNames; // will be the column names of the table
+ try
+ {
+ // get the keys
+ Reference< XIndexesSupplier > xIndexesSupp(m_xTable, UNO_QUERY);
+ if (xIndexesSupp.is())
+ {
+ xIndexes = xIndexesSupp->getIndexes();
+ OSL_ENSURE(xIndexes.is(), "OTableController::doEditIndexes: no keys got from the indexes supplier!");
+ }
+ else
+ OSL_FAIL("OTableController::doEditIndexes: should never have reached this (no indexes supplier)!");
+
+ // get the field names
+ Reference< XColumnsSupplier > xColSupp(m_xTable, UNO_QUERY);
+ OSL_ENSURE(xColSupp.is(), "OTableController::doEditIndexes: no columns supplier!");
+ if (xColSupp.is())
+ {
+ Reference< XNameAccess > xCols = xColSupp->getColumns();
+ OSL_ENSURE(xCols.is(), "OTableController::doEditIndexes: no columns!");
+ if (xCols.is())
+ aFieldNames = xCols->getElementNames();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if (!xIndexes.is())
+ return;
+
+ DbaIndexDialog aDialog(getView(), aFieldNames, xIndexes, getConnection(),getORB(),isConnected() ? getConnection()->getMetaData().is() && getConnection()->getMetaData()->getMaxColumnsInIndex() : sal_Int32(0));
+ if (RET_OK != aDialog.Execute())
+ return;
+
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::impl_initialize()
+{
+ try
+ {
+ OTableController_BASE::impl_initialize();
+
+ const NamedValueCollection& rArguments( getInitParams() );
+
+ rArguments.get_ensureType( (::rtl::OUString)PROPERTY_CURRENTTABLE, m_sName );
+
+ // read autoincrement value set in the datasource
+ ::dbaui::fillAutoIncrementValue(getDataSource(),m_bAllowAutoIncrementValue,m_sAutoIncrementValue);
+
+ assignTable();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ try
+ {
+ ::dbaui::fillTypeInfo(getConnection(),m_sTypeNames,m_aTypeInfo,m_aTypeInfoIndex); // fill the needed type information
+ }
+ catch(const SQLException&)
+ {
+ OSQLWarningBox( getView(), ModuleRes( STR_NO_TYPE_INFO_AVAILABLE ) ).Execute();
+ throw;
+ }
+ try
+ {
+ loadData(); // fill the column information form the table
+ getView()->initialize(); // show the windows and fill with our informations
+ ClearUndoManager();
+ setModified(sal_False); // and we are not modified yet
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::Construct(Window* pParent)
+{
+ setView( * new OTableDesignView( pParent, getORB(), *this ) );
+ OTableController_BASE::Construct(pParent);
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException )
+{
+ if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
+ return sal_True;
+
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( getView() && getView()->IsInModalMode() )
+ return sal_False;
+ if ( getView() )
+ static_cast<OTableDesignView*>(getView())->GrabFocus();
+ sal_Bool bCheck = sal_True;
+ if ( isModified() )
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = ::std::find_if(m_vRowList.begin(),m_vRowList.end(),
+ ::boost::mem_fn(&OTableRow::isValid));
+ if ( aIter != m_vRowList.end() )
+ {
+ QueryBox aQry(getView(), ModuleRes(TABLE_DESIGN_SAVEMODIFIED));
+ switch (aQry.Execute())
+ {
+ case RET_YES:
+ Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>());
+ if ( isModified() )
+ bCheck = sal_False; // when we save the table this must be false else some press cancel
+ break;
+ case RET_CANCEL:
+ bCheck = sal_False;
+ default:
+ break;
+ }
+ }
+ else if ( !m_bNew )
+ {
+ QueryBox aQry(getView(), ModuleRes(TABLE_DESIGN_ALL_ROWS_DELETED));
+ switch (aQry.Execute())
+ {
+ case RET_YES:
+ {
+ try
+ {
+ Reference<XTablesSupplier> xTablesSup(getConnection(),UNO_QUERY);
+ Reference<XNameAccess> xTables = xTablesSup->getTables();
+ dropTable(xTables,m_sName);
+ }
+ catch(const Exception&)
+ {
+ OSL_FAIL("OTableController::suspend: nothing is expected to happen here!");
+ }
+
+ }
+ break;
+ case RET_CANCEL:
+ bCheck = sal_False;
+ default:
+ break;
+ }
+ }
+ }
+
+ return bCheck;
+}
+// -----------------------------------------------------------------------------
+void OTableController::describeSupportedFeatures()
+{
+ OSingleDocumentController::describeSupportedFeatures();
+
+ implDescribeSupportedFeature( ".uno:Redo", ID_BROWSER_REDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:HelpMenu", SID_HELPMENU, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:DBIndexDesign", SID_INDEXDESIGN, CommandGroup::APPLICATION );
+ implDescribeSupportedFeature( ".uno:EditDoc", ID_BROWSER_EDITDOC, CommandGroup::EDIT );
+}
+// -----------------------------------------------------------------------------
+void OTableController::impl_onModifyChanged()
+{
+ OSingleDocumentController::impl_onModifyChanged();
+ InvalidateFeature( SID_INDEXDESIGN );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OTableController::disposing( const EventObject& _rSource ) throw(RuntimeException)
+{
+ if ( _rSource.Source == m_xTable )
+ { // some deleted our table so we have a new one
+ stopTableListening();
+ m_xTable = NULL;
+ m_bNew = sal_True;
+ setModified(sal_True);
+ }
+ else
+ OTableController_BASE::disposing( _rSource );
+}
+// -----------------------------------------------------------------------------
+void OTableController::Save(const Reference< XObjectOutputStream>& _rxOut)
+{
+ OStreamSection aSection(_rxOut.get());
+
+}
+// -----------------------------------------------------------------------------
+void OTableController::Load(const Reference< XObjectInputStream>& _rxIn)
+{
+ OStreamSection aSection(_rxIn.get());
+}
+
+// -----------------------------------------------------------------------------
+void OTableController::losingConnection( )
+{
+ // let the base class do it's reconnect
+ OTableController_BASE::losingConnection( );
+
+ // remove from the table
+ Reference< XComponent > xComponent(m_xTable, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference<XEventListener> xEvtL( static_cast< ::cppu::OWeakObject*>(this), UNO_QUERY);
+ xComponent->removeEventListener(xEvtL);
+ }
+ stopTableListening();
+ m_xTable = NULL;
+ assignTable();
+ if(!m_xTable.is())
+ {
+ m_bNew = sal_True;
+ setModified(sal_True);
+ }
+ InvalidateAll();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OTableController::getTypeInfoByType(sal_Int32 _nDataType) const
+{
+ return queryTypeInfoByType(_nDataType,m_aTypeInfo);
+}
+// -----------------------------------------------------------------------------
+void OTableController::appendColumns(Reference<XColumnsSupplier>& _rxColSup,sal_Bool _bNew,sal_Bool _bKeyColumns)
+{
+ try
+ {
+ // now append the columns
+ OSL_ENSURE(_rxColSup.is(),"No columns supplier");
+ if(!_rxColSup.is())
+ return;
+ Reference<XNameAccess> xColumns = _rxColSup->getColumns();
+ OSL_ENSURE(xColumns.is(),"No columns");
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY);
+
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField || (!_bNew && (*aIter)->IsReadOnly() && !_bKeyColumns) )
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(pField->IsPrimaryKey() || !_bKeyColumns)
+ xColumn = xColumnFactory->createDataDescriptor();
+ if(xColumn.is())
+ {
+ if(!_bKeyColumns)
+ ::dbaui::setColumnProperties(xColumn,pField);
+ else
+ xColumn->setPropertyValue(PROPERTY_NAME,makeAny(pField->GetName()));
+
+ xAppend->appendByDescriptor(xColumn);
+ xColumn = NULL;
+ // now only the settings are missing
+ if(xColumns->hasByName(pField->GetName()))
+ {
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ if(xColumn.is())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_FAIL("OTableController::appendColumns: invalid field name!");
+ }
+
+ }
+ }
+ }
+ catch(const SQLException& )
+ {
+ showError( SQLExceptionInfo( ::cppu::getCaughtException() ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableController::appendPrimaryKey(Reference<XKeysSupplier>& _rxSup,sal_Bool _bNew)
+{
+ if(!_rxSup.is())
+ return; // the database doesn't support keys
+
+ OSL_ENSURE(_rxSup.is(),"No XKeysSupplier!");
+ Reference<XIndexAccess> xKeys(_rxSup->getKeys(),UNO_QUERY);
+ Reference<XPropertySet> xProp;
+ const sal_Int32 nCount = xKeys->getCount();
+ for(sal_Int32 i=0;i< nCount ;++i)
+ {
+ xKeys->getByIndex(i) >>= xProp;
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ return; // primary key already exists after appending a column
+ }
+ }
+ Reference<XDataDescriptorFactory> xKeyFactory(xKeys,UNO_QUERY);
+ OSL_ENSURE(xKeyFactory.is(),"No XDataDescriptorFactory Interface!");
+ if ( !xKeyFactory.is() )
+ return;
+ Reference<XAppend> xAppend(xKeyFactory,UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
+
+ Reference<XPropertySet> xKey = xKeyFactory->createDataDescriptor();
+ OSL_ENSURE(xKey.is(),"Key is null!");
+ xKey->setPropertyValue(PROPERTY_TYPE,makeAny(KeyType::PRIMARY));
+
+ Reference<XColumnsSupplier> xColSup(xKey,UNO_QUERY);
+ if(xColSup.is())
+ {
+ appendColumns(xColSup,_bNew,sal_True);
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ if(xColumns->hasElements())
+ xAppend->appendByDescriptor(xKey);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableController::loadData()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Datenstruktur bereits vorhanden, Struktur leeren
+ m_vRowList.clear();
+
+ ::boost::shared_ptr<OTableRow> pTabEdRow;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+ //////////////////////////////////////////////////////////////////////
+ // Datenstruktur mit Daten aus DatenDefinitionsObjekt fuellen
+ if(m_xTable.is() && xMetaData.is())
+ {
+ Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY);
+ OSL_ENSURE(xColSup.is(),"No XColumnsSupplier!");
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ OFieldDescription* pActFieldDescr = NULL;
+ String aType;
+ //////////////////////////////////////////////////////////////////////
+ // ReadOnly-Flag
+ // Bei Drop darf keine Zeile editierbar sein.
+ // Bei Add duerfen nur die leeren Zeilen editierbar sein.
+ // Bei Add und Drop koennen alle Zeilen editiert werden.
+ // sal_Bool bReadOldRow = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn();
+ sal_Bool bIsAlterAllowed = isAlterAllowed();
+ Sequence< ::rtl::OUString> aColumns = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumns.getLength();
+
+ for(;pIter != pEnd;++pIter)
+ {
+ Reference<XPropertySet> xColumn;
+ xColumns->getByName(*pIter) >>= xColumn;
+ sal_Int32 nType = 0;
+ sal_Int32 nScale = 0;
+ sal_Int32 nPrecision = 0;
+ sal_Int32 nNullable = 0;
+ sal_Int32 nFormatKey = 0;
+ sal_Int32 nAlign = 0;
+
+ sal_Bool bIsAutoIncrement = false, bIsCurrency = false;
+ ::rtl::OUString sName,sDescription,sTypeName,sHelpText;
+ Any aControlDefault;
+
+ // get the properties from the column
+ xColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName;
+ xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
+ xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bIsAutoIncrement;
+ xColumn->getPropertyValue(PROPERTY_ISCURRENCY) >>= bIsCurrency;
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
+ xColumn->getPropertyValue(PROPERTY_DESCRIPTION) >>= sDescription;
+
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_HELPTEXT))
+ xColumn->getPropertyValue(PROPERTY_HELPTEXT) >>= sHelpText;
+
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ aControlDefault = xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT);
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_FORMATKEY))
+ xColumn->getPropertyValue(PROPERTY_FORMATKEY) >>= nFormatKey;
+ if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_ALIGN))
+ xColumn->getPropertyValue(PROPERTY_ALIGN) >>= nAlign;
+
+ pTabEdRow.reset(new OTableRow());
+ pTabEdRow->SetReadOnly(!bIsAlterAllowed);
+ // search for type
+ sal_Bool bForce;
+ ::rtl::OUString sCreate(RTL_CONSTASCII_USTRINGPARAM("x"));
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(m_aTypeInfo,nType,sTypeName,sCreate,nPrecision,nScale,bIsAutoIncrement,bForce);
+ if ( !pTypeInfo.get() )
+ pTypeInfo = m_pTypeInfo;
+ pTabEdRow->SetFieldType( pTypeInfo, bForce );
+
+ pActFieldDescr = pTabEdRow->GetActFieldDescr();
+ OSL_ENSURE(pActFieldDescr, "OTableController::loadData: invalid field description generated by the table row!");
+ if ( pActFieldDescr )
+ {
+ pActFieldDescr->SetName(sName);
+ pActFieldDescr->SetFormatKey(nFormatKey);
+ pActFieldDescr->SetDescription(sDescription);
+ pActFieldDescr->SetHelpText(sHelpText);
+ pActFieldDescr->SetAutoIncrement(bIsAutoIncrement);
+ pActFieldDescr->SetHorJustify(dbaui::mapTextJustify(nAlign));
+ pActFieldDescr->SetCurrency(bIsCurrency);
+
+ //////////////////////////////////////////////////////////////////////
+ // Spezielle Daten
+ pActFieldDescr->SetIsNullable(nNullable);
+ pActFieldDescr->SetControlDefault(aControlDefault);
+ pActFieldDescr->SetPrecision(nPrecision);
+ pActFieldDescr->SetScale(nScale);
+ }
+ m_vRowList.push_back( pTabEdRow);
+ }
+ // fill the primary key information
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ if(xKeyColumns.is())
+ {
+ Sequence< ::rtl::OUString> aKeyColumns = xKeyColumns->getElementNames();
+ const ::rtl::OUString* pKeyBegin = aKeyColumns.getConstArray();
+ const ::rtl::OUString* pKeyEnd = pKeyBegin + aKeyColumns.getLength();
+
+ for(;pKeyBegin != pKeyEnd;++pKeyBegin)
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowEnd = m_vRowList.end();
+ for(;rowIter != rowEnd;++rowIter)
+ {
+ if((*rowIter)->GetActFieldDescr()->GetName() == *pKeyBegin)
+ {
+ (*rowIter)->SetPrimaryKey(sal_True);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Leere Zeilen fuellen
+
+ OTypeInfoMap::iterator aTypeIter = m_aTypeInfo.find(DataType::VARCHAR);
+ if(aTypeIter == m_aTypeInfo.end())
+ aTypeIter = m_aTypeInfo.begin();
+
+ OSL_ENSURE(aTypeIter != m_aTypeInfo.end(),"We have no type infomation!");
+
+ bool bReadRow = !isAddAllowed();
+ for(sal_Int32 i=m_vRowList.size(); i < NEWCOLS; i++ )
+ {
+ pTabEdRow.reset(new OTableRow());
+ pTabEdRow->SetReadOnly(bReadRow);
+ m_vRowList.push_back( pTabEdRow);
+ }
+}
+// -----------------------------------------------------------------------------
+Reference<XNameAccess> OTableController::getKeyColumns() const
+{
+ return getPrimaryKeyColumns_throw(m_xTable);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::checkColumns(sal_Bool _bNew) throw(::com::sun::star::sdbc::SQLException)
+{
+ sal_Bool bOk = sal_True;
+ sal_Bool bFoundPKey = sal_False;
+ Reference< XDatabaseMetaData > xMetaData = getMetaData( );
+ DatabaseMetaData aMetaData( getConnection() );
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pFieldDesc = (*aIter)->GetActFieldDescr();
+ if (pFieldDesc && pFieldDesc->GetName().getLength())
+ {
+ bFoundPKey |= (*aIter)->IsPrimaryKey();
+ // first check for duplicate names
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter2 = aIter+1;
+ for(;aIter2 != aEnd;++aIter2)
+ {
+ OFieldDescription* pCompareDesc = (*aIter2)->GetActFieldDescr();
+ if (pCompareDesc && bCase(pCompareDesc->GetName(),pFieldDesc->GetName()))
+ {
+ String strMessage = String(ModuleRes(STR_TABLEDESIGN_DUPLICATE_NAME));
+ strMessage.SearchAndReplaceAscii("$column$", pFieldDesc->GetName());
+ OSQLWarningBox( getView(), strMessage ).Execute();
+ return sal_False;
+ }
+ }
+ }
+ }
+ if ( _bNew && !bFoundPKey && aMetaData.supportsPrimaryKeys() )
+ {
+ String sTitle(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY_HEAD));
+ String sMsg(ModuleRes(STR_TABLEDESIGN_NO_PRIM_KEY));
+ OSQLMessageBox aBox(getView(), sTitle,sMsg, WB_YES_NO_CANCEL | WB_DEF_YES);
+
+ switch ( aBox.Execute() )
+ {
+ case RET_YES:
+ {
+ ::boost::shared_ptr<OTableRow> pNewRow(new OTableRow());
+ TOTypeInfoSP pTypeInfo = ::dbaui::queryPrimaryKeyType(m_aTypeInfo);
+ if ( !pTypeInfo.get() )
+ break;
+
+ pNewRow->SetFieldType( pTypeInfo );
+ OFieldDescription* pActFieldDescr = pNewRow->GetActFieldDescr();
+
+ pActFieldDescr->SetAutoIncrement(sal_False);
+ pActFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
+
+ pActFieldDescr->SetName( createUniqueName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ID")) ));
+ pActFieldDescr->SetPrimaryKey( sal_True );
+ m_vRowList.insert(m_vRowList.begin(),pNewRow);
+
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->Invalidate();
+ static_cast<OTableDesignView*>(getView())->GetEditorCtrl()->RowInserted(0);
+ }
+ break;
+ case RET_CANCEL:
+ bOk = sal_False;
+ break;
+ }
+ }
+ return bOk;
+}
+// -----------------------------------------------------------------------------
+void OTableController::alterColumns()
+{
+ Reference<XColumnsSupplier> xColSup(m_xTable,UNO_QUERY_THROW);
+ OSL_ENSURE(xColSup.is(),"What happen here?!");
+
+ Reference<XNameAccess> xColumns = xColSup->getColumns();
+ Reference<XIndexAccess> xIdxColumns(xColumns,UNO_QUERY_THROW);
+ OSL_ENSURE(xColumns.is(),"No columns");
+ if ( !xColumns.is() )
+ return;
+ Reference<XAlterTable> xAlter(m_xTable,UNO_QUERY); // can be null
+
+ sal_Int32 nColumnCount = xIdxColumns->getCount();
+ Reference<XDrop> xDrop(xColumns,UNO_QUERY); // can be null
+ Reference<XAppend> xAppend(xColumns,UNO_QUERY); // can be null
+ Reference<XDataDescriptorFactory> xColumnFactory(xColumns,UNO_QUERY); // can be null
+
+ sal_Bool bReload = sal_False; // refresh the data
+
+ // contains all columns names which are already handled those which are not in the list will be deleted
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+
+ ::std::map< ::rtl::OUString,sal_Bool,::comphelper::UStringMixLess> aColumns(xMetaData.is() ? (xMetaData->supportsMixedCaseQuotedIdentifiers() ? true : false): sal_True);
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ // first look for columns where something other than the name changed
+ sal_Int32 nPos = 0;
+ for(;aIter != aEnd;++aIter,++nPos)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+ if ( (*aIter)->IsReadOnly() )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+
+ Reference<XPropertySet> xColumn;
+ if ( xColumns->hasByName(pField->GetName()) )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ OSL_ENSURE(xColumn.is(),"Column is null!");
+
+ sal_Int32 nType=0,nPrecision=0,nScale=0,nNullable=0;
+ sal_Bool bAutoIncrement = false;
+ ::rtl::OUString sTypeName,sDescription;
+
+ xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
+ xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ xColumn->getPropertyValue(PROPERTY_ISNULLABLE) >>= nNullable;
+ xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement;
+ xColumn->getPropertyValue(PROPERTY_DESCRIPTION) >>= sDescription;
+
+ try { xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName; }
+ catch( const Exception& )
+ {
+ OSL_FAIL( "no TypeName property?!" );
+ // since this is a last minute fix for #i41785#, I want to be on the safe side,
+ // and catch errors here as early as possible (instead of the whole process of altering
+ // the columns failing)
+ // Normally, sdbcx::Column objects are expected to have a TypeName property
+ }
+
+ // check if something changed
+ if((nType != pField->GetType() ||
+ sTypeName != pField->GetTypeName() ||
+ (nPrecision != pField->GetPrecision() && nPrecision ) ||
+ nScale != pField->GetScale() ||
+ nNullable != pField->GetIsNullable() ||
+ sDescription != pField->GetDescription() ||
+ bAutoIncrement != pField->IsAutoIncrement())&&
+ xColumnFactory.is())
+ {
+ Reference<XPropertySet> xNewColumn;
+ xNewColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::setColumnProperties(xNewColumn,pField);
+ // first try to alter the column
+ sal_Bool bNotOk = sal_False;
+ try
+ {
+ // first try if we can alter the column
+ if(xAlter.is())
+ xAlter->alterColumnByName(pField->GetName(),xNewColumn);
+ }
+ catch(const SQLException&)
+ {
+ if(xDrop.is() && xAppend.is())
+ {
+ String aMessage( ModuleRes( STR_TABLEDESIGN_ALTER_ERROR ) );
+ aMessage.SearchAndReplaceAscii( "$column$", pField->GetName() );
+
+ SQLExceptionInfo aError( ::cppu::getCaughtException() );
+ OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES , &aError );
+ bNotOk = aMsg.Execute() == RET_YES;
+ }
+ else
+ throw;
+ }
+ // if something went wrong or we can't alter columns
+ // drop and append a new one
+ if((!xAlter.is() || bNotOk) && xDrop.is() && xAppend.is())
+ {
+ xDrop->dropByName(pField->GetName());
+ try
+ {
+ xAppend->appendByDescriptor(xNewColumn);
+ }
+ catch(const SQLException&)
+ { // an error occurred so we try to reactivate the old one
+ xAppend->appendByDescriptor(xColumn);
+ throw;
+ }
+ }
+ // exceptions are caught outside
+ xNewColumn = NULL;
+ if(xColumns->hasByName(pField->GetName()))
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ bReload = sal_True;
+ }
+
+
+ }
+ else if(xColumnFactory.is() && xAlter.is() && nPos < nColumnCount)
+ { // we can't find the column so we could try it with the index before we drop and append a new column
+ try
+ {
+ Reference<XPropertySet> xNewColumn;
+ xNewColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::setColumnProperties(xNewColumn,pField);
+ xAlter->alterColumnByIndex(nPos,xNewColumn);
+ if(xColumns->hasByName(pField->GetName()))
+ { // ask for the append by name
+ aColumns[pField->GetName()] = sal_True;
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ if(xColumn.is())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_FAIL("OTableController::alterColumns: invalid column (2)!");
+ }
+ }
+ catch(const SQLException&)
+ { // we couldn't alter the column so we have to add new columns
+ bReload = sal_True;
+ if(xDrop.is() && xAppend.is())
+ {
+ String aMessage(ModuleRes(STR_TABLEDESIGN_ALTER_ERROR));
+ aMessage.SearchAndReplaceAscii("$column$",pField->GetName());
+ OSQLWarningBox aMsg( getView(), aMessage, WB_YES_NO | WB_DEF_YES );
+ if ( aMsg.Execute() != RET_YES )
+ {
+ Reference<XPropertySet> xNewColumn(xIdxColumns->getByIndex(nPos),UNO_QUERY_THROW);
+ ::rtl::OUString sName;
+ xNewColumn->getPropertyValue(PROPERTY_NAME) >>= sName;
+ aColumns[sName] = sal_True;
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+ }
+ else
+ throw;
+ }
+ }
+ else
+ bReload = sal_True;
+ }
+ // alter column settings
+ aIter = m_vRowList.begin();
+
+ // first look for columns where something other than the name changed
+ for(nPos = 0;aIter != aEnd;++aIter,++nPos)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+ if ( (*aIter)->IsReadOnly() )
+ {
+ aColumns[pField->GetName()] = sal_True;
+ continue;
+ }
+
+ Reference<XPropertySet> xColumn;
+ if ( xColumns->hasByName(pField->GetName()) )
+ {
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ Reference<XPropertySetInfo> xInfo = xColumn->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName(PROPERTY_HELPTEXT) )
+ xColumn->setPropertyValue(PROPERTY_HELPTEXT,makeAny(pField->GetHelpText()));
+
+ if(xInfo->hasPropertyByName(PROPERTY_CONTROLDEFAULT))
+ xColumn->setPropertyValue(PROPERTY_CONTROLDEFAULT,pField->GetControlDefault());
+ if(xInfo->hasPropertyByName(PROPERTY_FORMATKEY))
+ xColumn->setPropertyValue(PROPERTY_FORMATKEY,makeAny(pField->GetFormatKey()));
+ if(xInfo->hasPropertyByName(PROPERTY_ALIGN))
+ xColumn->setPropertyValue(PROPERTY_ALIGN,makeAny(dbaui::mapTextAllign(pField->GetHorJustify())));
+ }
+ }
+ // second drop all columns which could be found by name
+ Reference<XNameAccess> xKeyColumns = getKeyColumns();
+ // now we have to look for the columns who could be deleted
+ if ( xDrop.is() )
+ {
+ Sequence< ::rtl::OUString> aColumnNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aColumnNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aColumnNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(aColumns.find(*pIter) == aColumns.end()) // found a column to delete
+ {
+ if(xKeyColumns.is() && xKeyColumns->hasByName(*pIter)) // check if this column is a member of the primary key
+ {
+ String aMsgT(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN));
+ aMsgT.SearchAndReplaceAscii("$column$",*pIter);
+ String aTitle(ModuleRes(STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE));
+ OSQLMessageBox aMsg(getView(),aTitle,aMsgT,WB_YES_NO| WB_DEF_YES);
+ if(aMsg.Execute() == RET_YES)
+ {
+ xKeyColumns = NULL;
+ dropPrimaryKey();
+ }
+ else
+ {
+ bReload = sal_True;
+ continue;
+ }
+ }
+ try
+ {
+ xDrop->dropByName(*pIter);
+ }
+ catch (const SQLException&)
+ {
+ String sError( ModuleRes( STR_TABLEDESIGN_COULD_NOT_DROP_COL ) );
+ sError.SearchAndReplaceAscii( "$column$", *pIter );
+
+ SQLException aNewException;
+ aNewException.Message = sError;
+ aNewException.SQLState = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
+ aNewException.NextException = ::cppu::getCaughtException();
+
+ throw aNewException;
+ }
+ }
+ }
+ }
+
+ // third append the new columns
+ aIter = m_vRowList.begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField || (*aIter)->IsReadOnly() || aColumns.find(pField->GetName()) != aColumns.end() )
+ continue;
+
+ Reference<XPropertySet> xColumn;
+ if(!xColumns->hasByName(pField->GetName()))
+ {
+ if(xColumnFactory.is() && xAppend.is())
+ {// column not found by its name so we assume it is new
+ // Column is new
+ xColumn = xColumnFactory->createDataDescriptor();
+ ::dbaui::setColumnProperties(xColumn,pField);
+ xAppend->appendByDescriptor(xColumn);
+ if(xColumns->hasByName(pField->GetName()))
+ { // ask for the append by name
+ aColumns[pField->GetName()] = sal_True;
+ xColumns->getByName(pField->GetName()) >>= xColumn;
+ if(xColumn.is())
+ pField->copyColumnSettingsTo(xColumn);
+ }
+ else
+ {
+ OSL_FAIL("OTableController::alterColumns: invalid column!");
+ }
+ }
+ }
+ }
+
+
+ // check if we have to do something with the primary key
+ sal_Bool bNeedDropKey = sal_False;
+ sal_Bool bNeedAppendKey = sal_False;
+ if ( xKeyColumns.is() )
+ {
+ aIter = m_vRowList.begin();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( !pField )
+ continue;
+
+ if ( pField->IsPrimaryKey()
+ && !xKeyColumns->hasByName( pField->GetName() )
+ )
+ { // new primary key column inserted which isn't already in the columns selection
+ bNeedDropKey = bNeedAppendKey = sal_True;
+ break;
+ }
+ else if ( !pField->IsPrimaryKey()
+ && xKeyColumns->hasByName( pField->GetName() )
+ )
+ { // found a column which currently is in the primary key, but is marked not to be anymore
+ bNeedDropKey = bNeedAppendKey = sal_True;
+ break;
+ }
+ }
+ }
+ else
+ { // no primary key available so we check if we should create one
+ bNeedAppendKey = sal_True;
+ }
+
+ if ( bNeedDropKey && xKeyColumns.is() && xKeyColumns->getElementNames().getLength() )
+ dropPrimaryKey();
+
+ if ( bNeedAppendKey )
+ {
+ Reference< XKeysSupplier > xKeySup( m_xTable, UNO_QUERY );
+ appendPrimaryKey( xKeySup ,sal_False);
+ }
+
+ reSyncRows();
+
+ if ( bReload )
+ reload();
+}
+// -----------------------------------------------------------------------------
+void OTableController::dropPrimaryKey()
+{
+ SQLExceptionInfo aInfo;
+ try
+ {
+ Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
+ Reference<XIndexAccess> xKeys;
+ if(xKeySup.is())
+ xKeys = xKeySup->getKeys();
+
+ if(xKeys.is())
+ {
+ Reference<XPropertySet> xProp;
+ for(sal_Int32 i=0;i< xKeys->getCount();++i)
+ {
+ xProp.set(xKeys->getByIndex(i),UNO_QUERY);
+ sal_Int32 nKeyType = 0;
+ xProp->getPropertyValue(PROPERTY_TYPE) >>= nKeyType;
+ if(KeyType::PRIMARY == nKeyType)
+ {
+ Reference<XDrop> xDrop(xKeys,UNO_QUERY);
+ xDrop->dropByIndex(i); // delete the key
+ break;
+ }
+ }
+ }
+ }
+ catch(const SQLContext& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLWarning& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch(const SQLException& e)
+ {
+ aInfo = SQLExceptionInfo(e);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ showError(aInfo);
+}
+// -----------------------------------------------------------------------------
+void OTableController::assignTable()
+{
+ ::rtl::OUString sComposedName;
+ // get the table
+ if(m_sName.getLength())
+ {
+ Reference<XNameAccess> xNameAccess;
+ Reference<XTablesSupplier> xSup(getConnection(),UNO_QUERY);
+ if(xSup.is())
+ {
+ xNameAccess = xSup->getTables();
+ OSL_ENSURE(xNameAccess.is(),"no nameaccess for the queries!");
+
+ Reference<XPropertySet> xProp;
+ if(xNameAccess->hasByName(m_sName) && ::cppu::extractInterface(xProp,xNameAccess->getByName(m_sName)) && xProp.is())
+ {
+ m_xTable = xProp;
+ startTableListening();
+
+ // check if we set the table editable
+ Reference<XDatabaseMetaData> xMeta = getConnection()->getMetaData();
+ setEditable( xMeta.is() && !xMeta->isReadOnly() && (isAlterAllowed() || isDropAllowed() || isAddAllowed()) );
+ if(!isEditable())
+ {
+ ::std::for_each(m_vRowList.begin(),m_vRowList.end(),boost::bind( &OTableRow::SetReadOnly, _1, boost::cref( sal_True )));
+ }
+ m_bNew = sal_False;
+ // be notified when the table is in disposing
+ InvalidateAll();
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isAddAllowed() const
+{
+ Reference<XColumnsSupplier> xColsSup(m_xTable,UNO_QUERY);
+ sal_Bool bAddAllowed = !m_xTable.is();
+ if(xColsSup.is())
+ bAddAllowed = Reference<XAppend>(xColsSup->getColumns(),UNO_QUERY).is();
+
+ try
+ {
+ Reference< XDatabaseMetaData > xMetaData = getMetaData( );
+ bAddAllowed = bAddAllowed || ( xMetaData.is() && xMetaData->supportsAlterTableWithAddColumn());
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bAddAllowed = sal_False;
+ }
+
+ return bAddAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isDropAllowed() const
+{
+ Reference<XColumnsSupplier> xColsSup(m_xTable,UNO_QUERY);
+ sal_Bool bDropAllowed = !m_xTable.is();
+ if(xColsSup.is())
+ {
+ Reference<XNameAccess> xNameAccess = xColsSup->getColumns();
+ bDropAllowed = Reference<XDrop>(xNameAccess,UNO_QUERY).is() && xNameAccess->hasElements();
+ }
+
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+ bDropAllowed = bDropAllowed || ( xMetaData.is() && xMetaData->supportsAlterTableWithDropColumn());
+
+ return bDropAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableController::isAlterAllowed() const
+{
+ sal_Bool bAllowed(!m_xTable.is() || Reference<XAlterTable>(m_xTable,UNO_QUERY).is());
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OTableController::reSyncRows()
+{
+ sal_Bool bAlterAllowed = isAlterAllowed();
+ sal_Bool bAddAllowed = isAddAllowed();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ OSL_ENSURE(*aIter,"OTableRow is null!");
+ OFieldDescription* pField = (*aIter)->GetActFieldDescr();
+ if ( pField )
+ (*aIter)->SetReadOnly(!bAlterAllowed);
+ else
+ (*aIter)->SetReadOnly(!bAddAllowed);
+
+ }
+ static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
+
+ ClearUndoManager();
+ setModified(sal_False); // and we are not modified yet
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableController::createUniqueName(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sName = _rName;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData( );
+
+ ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
+
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(sal_Int32 i=0;aIter != aEnd;++aIter)
+ {
+ OFieldDescription* pFieldDesc = (*aIter)->GetActFieldDescr();
+ if (pFieldDesc && pFieldDesc->GetName().getLength() && bCase(sName,pFieldDesc->GetName()))
+ { // found a second name of _rName so we need another
+ sName = _rName + ::rtl::OUString::valueOf(++i);
+ aIter = m_vRowList.begin(); // and retry
+ }
+ }
+ return sName;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableController::getPrivateTitle() const
+{
+ ::rtl::OUString sTitle;
+ try
+ {
+ // get the table
+ if ( m_sName.getLength() && getConnection().is() )
+ {
+ if ( m_xTable.is() )
+ sTitle = ::dbtools::composeTableName( getConnection()->getMetaData(), m_xTable, ::dbtools::eInDataManipulation, false, false, false );
+ else
+ sTitle = m_sName;
+ }
+ if ( !sTitle.getLength() )
+ {
+ String aName = String(ModuleRes(STR_TBL_TITLE));
+ sTitle = aName.GetToken(0,' ');
+ sTitle += ::rtl::OUString::valueOf(getCurrentStartNumber());
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sTitle;
+}
+// -----------------------------------------------------------------------------
+void OTableController::reload()
+{
+ loadData(); // fill the column information form the table
+ static_cast<OTableDesignView*>(getView())->reSync(); // show the windows and fill with our informations
+ ClearUndoManager();
+ setModified(sal_False); // and we are not modified yet
+ static_cast<OTableDesignView*>(getView())->Invalidate();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OTableController::getFirstEmptyRowPosition()
+{
+ sal_Int32 nRet = -1;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
+ for(;aIter != aEnd;++aIter)
+ {
+ if ( !*aIter || !(*aIter)->GetActFieldDescr() || !(*aIter)->GetActFieldDescr()->GetName().getLength() )
+ {
+ nRet = aIter - m_vRowList.begin();
+ break;
+ }
+ }
+ if ( nRet == -1 )
+ {
+ bool bReadRow = !isAddAllowed();
+ ::boost::shared_ptr<OTableRow> pTabEdRow(new OTableRow());
+ pTabEdRow->SetReadOnly(bReadRow);
+ nRet = m_vRowList.size();
+ m_vRowList.push_back( pTabEdRow);
+ }
+ return nRet;
+}
+// -----------------------------------------------------------------------------
+bool OTableController::isAutoIncrementPrimaryKey() const
+{
+ return getSdbMetaData().isAutoIncrementPrimaryKey();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableDesignControl.cxx b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
new file mode 100644
index 000000000000..0867deb7a4b7
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignControl.cxx
@@ -0,0 +1,224 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableDesignControl.hxx"
+#include "dbu_tbl.hrc"
+#include "TableDesignView.hxx"
+#include "TableController.hxx"
+#include "browserids.hxx"
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "dbaccess_helpid.hrc"
+
+using namespace ::dbaui;
+using namespace ::svt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+//--- Defines
+#define HANDLE_ID 0
+
+DBG_NAME(OTableRowView)
+//------------------------------------------------------------------------
+OTableRowView::OTableRowView(Window* pParent)
+ :EditBrowseBox(pParent, ModuleRes(RID_DB_TAB_EDITOR),EBBF_NONE,
+ BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
+ BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
+ ,m_nDataPos(-1)
+ ,m_nCurrentPos(-1)
+ ,m_nCurUndoActId(0)
+ ,m_bCurrentModified(sal_False)
+ ,m_bUpdatable(sal_False)
+ ,m_bClipboardFilled(sal_False)
+{
+ DBG_CTOR(OTableRowView,NULL);
+
+}
+
+//------------------------------------------------------------------------
+OTableRowView::~OTableRowView()
+{
+
+ DBG_DTOR(OTableRowView,NULL);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Init()
+{
+ EditBrowseBox::Init();
+
+ Font aFont( GetDataWindow().GetFont() );
+ aFont.SetWeight( WEIGHT_NORMAL );
+ GetDataWindow().SetFont( aFont );
+
+ // Font fuer die Ueberschriften auf Light setzen
+ aFont = GetFont();
+ aFont.SetWeight( WEIGHT_LIGHT );
+ SetFont(aFont);
+
+ // HandleColumn, fuer maximal fuenf Ziffern einrichten
+ InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth('0') * 4)/*, sal_True */);
+
+ BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
+ BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTOSIZE_LASTCOL;
+ if (IsUpdatable())
+ nMode |= BROWSER_HIDECURSOR;
+
+ SetMode(nMode);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::KeyInput( const KeyEvent& rEvt )
+{
+ if (IsDeleteAllowed(0))
+ {
+ if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
+ !rEvt.GetKeyCode().IsShift() &&
+ !rEvt.GetKeyCode().IsMod1())
+ {
+ DeleteRows();
+ return;
+ }
+ if( rEvt.GetKeyCode().GetCode() == KEY_F2 )
+ {
+ ::com::sun::star::util::URL aUrl;
+ aUrl.Complete =::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DSBEditDoc"));
+ GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
+ }
+ }
+ EditBrowseBox::KeyInput(rEvt);
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::SetUpdatable( sal_Bool bUpdate )
+{
+ m_bUpdatable = bUpdate;
+
+}
+
+//------------------------------------------------------------------------
+void OTableRowView::Command(const CommandEvent& rEvt)
+{
+
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if (!rEvt.IsMouseEvent())
+ {
+ EditBrowseBox::Command(rEvt);
+ return;
+ }
+
+ sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
+ long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
+
+ if ( nColId == HANDLE_ID )
+ {
+ PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
+ long nSelectRowCount = GetSelectRowCount();
+ aContextMenu.EnableItem( SID_CUT, nSelectRowCount != 0);
+ aContextMenu.EnableItem( SID_COPY, nSelectRowCount != 0);
+ aContextMenu.EnableItem( SID_PASTE, m_bClipboardFilled );
+ aContextMenu.EnableItem( SID_DELETE, IsUpdatable() && nSelectRowCount != 0 );
+ switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
+ {
+ case SID_CUT:
+ cut();
+ break;
+ case SID_COPY:
+ copy();
+ break;
+ case SID_PASTE:
+ Paste( nRow );
+ SetNoSelection();
+ GoToRow( nRow );
+ SeekRow( nRow );
+ break;
+
+ case SID_DELETE:
+ DeleteRows();
+ break;
+ case SID_TABLEDESIGN_INSERTROWS:
+ InsertNewRows( nRow );
+ SetNoSelection();
+ GoToRow( nRow );
+ SeekRow( nRow );
+ break;
+ default:
+ break;
+ }
+ }
+
+ }
+ default:
+ EditBrowseBox::Command(rEvt);
+ }
+
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::cut()
+{
+ CopyRows();
+ DeleteRows();
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::copy()
+{
+ CopyRows();
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::paste()
+{
+ OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
+}
+
+//------------------------------------------------------------------------------
+void OTableRowView::Paste( long nRow )
+{
+ InsertRows( nRow );
+}
+
+//------------------------------------------------------------------------------
+EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
+{
+ if (nRow >= 0 && m_nDataPos == nRow)
+ return CURRENT;
+ else
+ return CLEAN;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
new file mode 100644
index 000000000000..7279c1ec1fca
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignHelpBar.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableDesignHelpBar.hxx"
+#include <tools/debug.hxx>
+#include <svtools/svmedit.hxx>
+#include "dbaccess_helpid.hrc"
+#include <memory>
+using namespace dbaui;
+#define STANDARD_MARGIN 6
+//==================================================================
+// class OTableDesignHelpBar
+//==================================================================
+DBG_NAME(OTableDesignHelpBar)
+//------------------------------------------------------------------------------
+OTableDesignHelpBar::OTableDesignHelpBar( Window* pParent ) :
+ TabPage( pParent, WB_3DLOOK )
+{
+ DBG_CTOR(OTableDesignHelpBar,NULL);
+ m_pTextWin = new MultiLineEdit( this, WB_VSCROLL | WB_LEFT | WB_BORDER | WB_NOTABSTOP | WB_READONLY);
+ m_pTextWin->SetHelpId(HID_TABLE_DESIGN_HELP_WINDOW);
+ m_pTextWin->SetReadOnly();
+ m_pTextWin->SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
+ m_pTextWin->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableDesignHelpBar::~OTableDesignHelpBar()
+{
+ DBG_DTOR(OTableDesignHelpBar,NULL);
+ ::std::auto_ptr<Window> aTemp(m_pTextWin);
+ m_pTextWin = NULL;
+}
+
+//------------------------------------------------------------------------------
+void OTableDesignHelpBar::SetHelpText( const String& rText )
+{
+ DBG_CHKTHIS(OTableDesignHelpBar,NULL);
+ if(m_pTextWin)
+ m_pTextWin->SetText( rText );
+ Invalidate();
+}
+
+//------------------------------------------------------------------------------
+void OTableDesignHelpBar::Resize()
+{
+ DBG_CHKTHIS(OTableDesignHelpBar,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSizePixel() );
+
+ //////////////////////////////////////////////////////////////////////
+ // TextWin anpassen
+ if(m_pTextWin)
+ m_pTextWin->SetPosSizePixel( Point(STANDARD_MARGIN+1, STANDARD_MARGIN+1),
+ Size(aOutputSize.Width()-(2*STANDARD_MARGIN)-2,
+ aOutputSize.Height()-(2*STANDARD_MARGIN)-2) );
+
+}
+
+//------------------------------------------------------------------------------
+long OTableDesignHelpBar::PreNotify( NotifyEvent& rNEvt )
+{
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS)
+ SetHelpText(String());
+ return TabPage::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isCopyAllowed()
+{
+ return m_pTextWin && m_pTextWin->GetSelected().Len();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isCutAllowed()
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignHelpBar::isPasteAllowed()
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::cut()
+{
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::copy()
+{
+ if ( m_pTextWin )
+ m_pTextWin->Copy();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignHelpBar::paste()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableDesignView.cxx b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
new file mode 100644
index 000000000000..4c5882c7ef9e
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableDesignView.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableDesignView.hxx"
+#include <tools/debug.hxx>
+#include "TableController.hxx"
+#include "dbaccess_helpid.hrc"
+#include "FieldDescriptions.hxx"
+#include "TEditControl.hxx"
+#include "TableFieldDescWin.hxx"
+#include "TableRow.hxx"
+#include <unotools/configmgr.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <unotools/syslocale.hxx>
+#include "UITools.hxx"
+
+
+using namespace ::dbaui;
+using namespace ::utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::datatransfer::clipboard;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+//==================================================================
+// class OTableBorderWindow
+DBG_NAME(OTableBorderWindow)
+//==================================================================
+OTableBorderWindow::OTableBorderWindow(Window* pParent) : Window(pParent,WB_BORDER)
+ ,m_aHorzSplitter( this )
+{
+ DBG_CTOR(OTableBorderWindow,NULL);
+
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ //////////////////////////////////////////////////////////////////////
+ // Childs erzeugen
+ m_pEditorCtrl = new OTableEditorCtrl( this);
+ m_pFieldDescWin = new OTableFieldDescWin( this );
+
+ m_pFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN);
+
+ // set depending windows and controls
+ m_pEditorCtrl->SetDescrWin(m_pFieldDescWin);
+
+ //////////////////////////////////////////////////////////////////////
+ // Splitter einrichten
+ m_aHorzSplitter.SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) );
+ m_aHorzSplitter.Show();
+}
+// -----------------------------------------------------------------------------
+OTableBorderWindow::~OTableBorderWindow()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ // ::dbaui::notifySystemWindow(this,m_pFieldDescWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_pEditorCtrl->Hide();
+ m_pFieldDescWin->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pEditorCtrl);
+ m_pEditorCtrl = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pFieldDescWin);
+ m_pFieldDescWin = NULL;
+ }
+
+ DBG_DTOR(OTableBorderWindow,NULL);
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::Resize()
+{
+ const long nSplitterHeight(3);
+
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSize() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+ long nSplitPos = m_aHorzSplitter.GetSplitPosPixel();
+
+ //////////////////////////////////////////////////////////////////////
+ // Verschiebebereich Splitter mittleres Drittel des Outputs
+ long nDragPosY = nOutputHeight/3;
+ long nDragSizeHeight = nOutputHeight/3;
+ m_aHorzSplitter.SetDragRectPixel( Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this );
+ if( (nSplitPos < nDragPosY) || (nSplitPos > (nDragPosY+nDragSizeHeight)) )
+ nSplitPos = nDragPosY+nDragSizeHeight-5;
+
+ //////////////////////////////////////////////////////////////////////
+ // Splitter setzen
+ m_aHorzSplitter.SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight));
+ m_aHorzSplitter.SetSplitPosPixel( nSplitPos );
+
+ //////////////////////////////////////////////////////////////////////
+ // Fenster setzen
+ m_pEditorCtrl->SetPosSizePixel( Point(0, 0), Size(nOutputWidth , nSplitPos) );
+
+ m_pFieldDescWin->SetPosSizePixel( Point(0, nSplitPos+nSplitterHeight),
+ Size(nOutputWidth, nOutputHeight-nSplitPos-nSplitterHeight) );
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableBorderWindow, SplitHdl, Splitter*, pSplit )
+{
+ if(pSplit == &m_aHorzSplitter)
+ {
+ m_aHorzSplitter.SetPosPixel( Point( m_aHorzSplitter.GetPosPixel().X(),m_aHorzSplitter.GetSplitPosPixel() ) );
+ Resize();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetPointFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetFaceColor() );
+ }
+}
+// -----------------------------------------------------------------------
+void OTableBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableBorderWindow::GetFocus()
+{
+ Window::GetFocus();
+
+ // forward the focus to the current cell of the editor control
+ if (m_pEditorCtrl)
+ m_pEditorCtrl->GrabFocus();
+}
+
+//==================================================================
+// class OTableDesignView
+//==================================================================
+DBG_NAME(OTableDesignView);
+//------------------------------------------------------------------------------
+OTableDesignView::OTableDesignView( Window* pParent,
+ const Reference< XMultiServiceFactory >& _rxOrb,
+ OTableController& _rController
+ ) :
+ ODataView( pParent, _rController,_rxOrb )
+ ,m_rController( _rController )
+ ,m_eChildFocus(NONE)
+{
+ DBG_CTOR(OTableDesignView,NULL);
+
+ try
+ {
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_pWin = new OTableBorderWindow(this);
+ m_pWin->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableDesignView::~OTableDesignView()
+{
+ DBG_DTOR(OTableDesignView,NULL);
+ m_pWin->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pWin);
+ m_pWin = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OTableDesignView::initialize()
+{
+ GetEditorCtrl()->Init();
+ GetDescWin()->Init();
+ // first call after the editctrl has been set
+
+ GetEditorCtrl()->Show();
+ GetDescWin()->Show();
+
+ GetEditorCtrl()->DisplayData(0);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void OTableDesignView::resizeDocumentView(Rectangle& _rPlayground)
+{
+ m_pWin->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
+
+ // just for completeness: there is no space left, we occupied it all ...
+ _rPlayground.SetPos( _rPlayground.BottomRight() );
+ _rPlayground.SetSize( Size( 0, 0 ) );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( OTableDesignView, SwitchHdl, Accelerator*, /*pAcc*/ )
+{
+ if( getController().isReadOnly() )
+ return 0;
+
+ if( GetDescWin()->HasChildPathFocus() )
+ {
+ GetDescWin()->LoseFocus();
+ GetEditorCtrl()->GrabFocus();
+ }
+ else
+ {
+ ::boost::shared_ptr<OTableRow> pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
+ OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : NULL;
+ if ( pFieldDescr )
+ GetDescWin()->GrabFocus();
+ else
+ GetEditorCtrl()->GrabFocus();
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+long OTableDesignView::PreNotify( NotifyEvent& rNEvt )
+{
+ sal_Bool bHandled = sal_False;
+ switch(rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if( GetDescWin() && GetDescWin()->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else if ( GetEditorCtrl() && GetEditorCtrl()->HasChildPathFocus() )
+ m_eChildFocus = EDITOR;
+ else
+ m_eChildFocus = NONE;
+ break;
+ }
+
+ return bHandled ? 1L : ODataView::PreNotify(rNEvt);
+}
+// -----------------------------------------------------------------------------
+IClipboardTest* OTableDesignView::getActiveChild() const
+{
+ IClipboardTest* pTest = NULL;
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ pTest = GetDescWin();
+ break;
+ case EDITOR:
+ pTest = GetEditorCtrl();
+ break;
+ case NONE:
+ break;
+ }
+ return pTest;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isCopyAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isCutAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isCutAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableDesignView::isPasteAllowed()
+{
+ IClipboardTest* pTest = getActiveChild();
+ return pTest && pTest->isPasteAllowed();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::copy()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->copy();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::cut()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->cut();
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::paste()
+{
+ IClipboardTest* pTest = getActiveChild();
+ if ( pTest )
+ pTest->paste();
+}
+// -----------------------------------------------------------------------------
+// set the view readonly or not
+void OTableDesignView::setReadOnly(sal_Bool _bReadOnly)
+{
+ GetDescWin()->SetReadOnly(_bReadOnly);
+ GetEditorCtrl()->SetReadOnly(_bReadOnly);
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::reSync()
+{
+ GetEditorCtrl()->DeactivateCell();
+ ::boost::shared_ptr<OTableRow> pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
+ OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : NULL;
+ if ( pFieldDescr )
+ GetDescWin()->DisplayData(pFieldDescr);
+}
+// -----------------------------------------------------------------------------
+void OTableDesignView::GetFocus()
+{
+ if ( GetEditorCtrl() )
+ GetEditorCtrl()->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.cxx b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
new file mode 100644
index 000000000000..97484d519948
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableFieldControl.hxx"
+#include "TableController.hxx"
+#include "TableDesignView.hxx"
+#include "TEditControl.hxx"
+#include "dbustrings.hrc"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <comphelper/types.hxx>
+#include "TypeInfo.hxx"
+#include "UITools.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace dbaui;
+OTableFieldControl::OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar) :OFieldDescControl(pParent,pHelpBar)
+{
+}
+//------------------------------------------------------------------
+void OTableFieldControl::CellModified(long nRow, sal_uInt16 nColId )
+{
+ GetCtrl()->CellModified(nRow,nColId);
+}
+//------------------------------------------------------------------
+OTableEditorCtrl* OTableFieldControl::GetCtrl() const
+{
+ OTableDesignView* pDesignWin = static_cast<OTableDesignView*>(GetParent()->GetParent()->GetParent()->GetParent());
+ OSL_ENSURE(pDesignWin,"no view!");
+ return pDesignWin->GetEditorCtrl();
+}
+//------------------------------------------------------------------
+sal_Bool OTableFieldControl::IsReadOnly()
+{
+ sal_Bool bRead(GetCtrl()->IsReadOnly());
+ if( !bRead )
+ {
+ // Die Spalten einer ::com::sun::star::sdbcx::View können nicht verändert werden
+ Reference<XPropertySet> xTable = GetCtrl()->GetView()->getController().getTable();
+ if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")))
+ bRead = sal_True;
+ else
+ {
+ ::boost::shared_ptr<OTableRow> pCurRow = GetCtrl()->GetActRow();
+ if( pCurRow )
+ bRead = pCurRow->IsReadOnly();
+ }
+ }
+ return bRead;
+}
+//------------------------------------------------------------------
+void OTableFieldControl::ActivateAggregate( EControlType eType )
+{
+ switch(eType)
+ {
+ case tpColumnName:
+ case tpType:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate(eType);
+ }
+}
+//------------------------------------------------------------------
+void OTableFieldControl::DeactivateAggregate( EControlType eType )
+{
+ switch(eType)
+ {
+ case tpColumnName:
+ case tpType:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate(eType);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableFieldControl::SetModified(sal_Bool bModified)
+{
+ GetCtrl()->GetView()->getController().setModified(bModified);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> OTableFieldControl::getConnection()
+{
+ return GetCtrl()->GetView()->getController().getConnection();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> OTableFieldControl::getMetaData()
+{
+ Reference<XConnection> xCon = GetCtrl()->GetView()->getController().getConnection();
+ if(!xCon.is())
+ return NULL;
+ return xCon->getMetaData();
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OTableFieldControl::GetFormatter() const
+{
+ return GetCtrl()->GetView()->getController().getNumberFormatter();
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OTableFieldControl::getTypeInfo(sal_Int32 _nPos)
+{
+ return GetCtrl()->GetView()->getController().getTypeInfo(_nPos);
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OTableFieldControl::getTypeInfo() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getTypeInfo();
+}
+// -----------------------------------------------------------------------------
+Locale OTableFieldControl::GetLocale() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getLocale();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldControl::isAutoIncrementValueEnabled() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().isAutoIncrementValueEnabled();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTableFieldControl::getAutoIncrementValue() const
+{
+ return const_cast<OTableFieldControl*>(this)->GetCtrl()->GetView()->getController().getAutoIncrementValue();
+}
+// -----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableFieldControl.hxx b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
new file mode 100644
index 000000000000..22a77811b51c
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldControl.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDCONTROL_HXX
+#define DBAUI_TABLEFIELDCONTROL_HXX
+
+#include "FieldDescControl.hxx"
+
+namespace dbaui
+{
+ class OTableEditorCtrl;
+ class OTableDesignHelpBar;
+ //==================================================================
+ // OTableFieldControl
+ //==================================================================
+ class OTableFieldControl : public OFieldDescControl
+ {
+ OTableEditorCtrl* GetCtrl() const;
+ protected:
+ virtual void ActivateAggregate( EControlType eType );
+ virtual void DeactivateAggregate( EControlType eType );
+ // Sind von den abgeleiteten Klassen zu impl.
+ virtual void CellModified(long nRow, sal_uInt16 nColId );
+ virtual sal_Bool IsReadOnly();
+ virtual void SetModified(sal_Bool bModified);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const;
+
+ virtual ::com::sun::star::lang::Locale GetLocale() const;
+
+ virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos);
+ virtual const OTypeInfoMap* getTypeInfo() const;
+ virtual sal_Bool isAutoIncrementValueEnabled() const;
+ virtual ::rtl::OUString getAutoIncrementValue() const;
+
+ public:
+ OTableFieldControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
+
+ String BoolStringPersistent(const String& rUIString) const { return OFieldDescControl::BoolStringPersistent(rUIString); }
+ String BoolStringUI(const String& rPersistentString) const { return OFieldDescControl::BoolStringUI(rPersistentString); }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection();
+ };
+}
+#endif // DBAUI_TABLEFIELDCONTROL_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
new file mode 100644
index 000000000000..ca2680fc09a8
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.cxx
@@ -0,0 +1,320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableFieldDescWin.hxx"
+#include <osl/diagnose.h>
+#include "FieldDescriptions.hxx"
+#include "dbu_tbl.hrc"
+#include "FieldDescriptions.hxx"
+#include "TableDesignHelpBar.hxx"
+#include <vcl/fixed.hxx>
+#include "dbaccess_helpid.hrc"
+#include "moduledbu.hxx"
+#include <memory>
+
+#define STANDARD_MARGIN 6
+#define DETAILS_HEADER_HEIGHT 25
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 5
+#define CONTROL_HEIGHT 20
+#define CONTROL_WIDTH_1 140 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
+#define DETAILS_OPT_PAGE_WIDTH (CONTROL_WIDTH_1 + CONTROL_SPACING_X + CONTROL_WIDTH_4 + 50)
+#define DETAILS_OPT_PAGE_HEIGHT ((CONTROL_HEIGHT + CONTROL_SPACING_Y) * 5)
+#define DETAILS_MIN_HELP_WIDTH 100
+#define DETAILS_OPT_HELP_WIDTH 200
+#define DETAILS_MIN_HELP_HEIGHT 50
+#define DETAILS_OPT_HELP_HEIGHT 100
+
+
+using namespace dbaui;
+//==================================================================
+// class OTableFieldDescWin
+//==================================================================
+DBG_NAME(OTableFieldDescWin)
+//------------------------------------------------------------------------------
+OTableFieldDescWin::OTableFieldDescWin( Window* pParent)
+ :TabPage(pParent, WB_3DLOOK)
+{
+ DBG_CTOR(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Header
+ m_pHeader = new FixedText( this, WB_CENTER | WB_INFO ); // | WB_3DLOOK
+ m_pHeader->SetText( String(ModuleRes(STR_TAB_PROPERTIES)) );
+ m_pHeader->Show();
+
+ //////////////////////////////////////////////////////////////////////
+ // HelpBar
+ m_pHelpBar = new OTableDesignHelpBar( this );
+ m_pHelpBar->SetHelpId(HID_TAB_DESIGN_HELP_TEXT_FRAME);
+ m_pHelpBar->Show();
+
+ m_pGenPage = new OFieldDescGenWin( this, m_pHelpBar );
+ getGenPage()->SetHelpId( HID_TABLE_DESIGN_TABPAGE_GENERAL );
+ getGenPage()->Show();
+}
+
+//------------------------------------------------------------------------------
+OTableFieldDescWin::~OTableFieldDescWin()
+{
+ DBG_DTOR(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ m_pHelpBar->Hide();
+ getGenPage()->Hide();
+ m_pHeader->Hide();
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pGenPage);
+ m_pGenPage = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHeader);
+ m_pHeader = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHelpBar);
+ m_pHelpBar = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Init()
+{
+ OSL_ENSURE(getGenPage() != NULL, "OTableFieldDescWin::Init : ups ... no GenericPage ... this will crash ...");
+ getGenPage()->Init();
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::SetReadOnly( sal_Bool bRead )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->SetReadOnly( bRead );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::DisplayData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->DisplayData( pFieldDescr );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ getGenPage()->SaveData( pFieldDescr );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Paint( const Rectangle& /*rRect*/ )
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // 3D-Linie am oberen Fensterrand
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ SetLineColor( rStyleSettings.GetLightColor() );
+ DrawLine( Point(0,0), Point(GetSizePixel().Width(),0) );
+
+ //////////////////////////////////////////////////////////////////////
+ // 3D-Linie zum Abtrennen des Headers
+ DrawLine( Point(3, DETAILS_HEADER_HEIGHT), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT) );
+ SetLineColor( rStyleSettings.GetShadowColor() );
+ DrawLine( Point(3, DETAILS_HEADER_HEIGHT-1), Point(GetSizePixel().Width()-6, DETAILS_HEADER_HEIGHT-1) );
+}
+
+//------------------------------------------------------------------------------
+void OTableFieldDescWin::Resize()
+{
+ DBG_CHKTHIS(OTableFieldDescWin,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Abmessungen parent window
+ Size aOutputSize( GetOutputSizePixel() );
+ long nOutputWidth = aOutputSize.Width();
+ long nOutputHeight = aOutputSize.Height();
+
+ // da die GenPage scrollen kann, ich selber aber nicht, positioniere ich das HelpFenster, wenn ich zu schmal werde,
+ // _unter_ der Genpage, nicht rechts daneben. Zuvor versuche ich aber noch, es etwas schmaler zu machen
+
+ long nHelpX, nHelpY;
+ long nHelpWidth, nHelpHeight;
+ long nPageWidth, nPageHeight;
+
+ // passen beide nebeneinander (Rand + Page + Rand + Help) ?
+ if (STANDARD_MARGIN + DETAILS_OPT_PAGE_WIDTH + STANDARD_MARGIN + DETAILS_MIN_HELP_WIDTH <= nOutputWidth)
+ { // ja -> dann ist die Frage, ob man der Hilfe ihre Optimal-Breite geben kann
+ nHelpWidth = DETAILS_OPT_HELP_WIDTH;
+ nPageWidth = nOutputWidth - nHelpWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ if (nPageWidth < DETAILS_OPT_PAGE_WIDTH)
+ { // dann doch lieber die Hilfe von ihrer optimalen in Richtung auf die minimale Groesse
+ long nTransfer = DETAILS_OPT_PAGE_WIDTH - nPageWidth;
+ nPageWidth += nTransfer;
+ nHelpWidth -= nTransfer;
+ }
+ nHelpX = nOutputWidth - nHelpWidth;
+ // die Hoehen sind dann einfach ...
+ nHelpY = DETAILS_HEADER_HEIGHT + 1;
+ nHelpHeight = nOutputHeight - nHelpY;
+ nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ }
+ else
+ { // nebeneinander geht nicht, also untereinander (Rand + Header + Page + Help)
+ if (STANDARD_MARGIN + DETAILS_HEADER_HEIGHT + DETAILS_OPT_PAGE_HEIGHT + DETAILS_MIN_HELP_HEIGHT <= nOutputHeight)
+ { // es reicht zumindest, um beide untereinander (Page optimal, Help minimal) unterzubringen
+ nHelpHeight = DETAILS_OPT_HELP_HEIGHT;
+ nPageHeight = nOutputHeight - nHelpHeight - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ if (nPageHeight < DETAILS_OPT_PAGE_HEIGHT)
+ { // wie oben : Page optimal, Hilfe soviel wie eben bleibt (das ist groesser/gleich ihrem Minimum)
+ long nTransfer = DETAILS_OPT_PAGE_HEIGHT - nPageHeight;
+ nPageHeight += nTransfer;
+ nHelpHeight -= nTransfer;
+ }
+ nHelpY = nOutputHeight - nHelpHeight;
+ // und ueber die ganze Breite
+ nHelpX = 0; // ohne Margin, da das HelpCtrl einen eigenen hat
+ nHelpWidth = nOutputWidth; // dito
+ nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ }
+ else
+ { // dummerweise reicht es nicht mal, um Page optimal und Help minimal zu zeigen
+ nHelpX = nHelpY = nHelpWidth = nHelpHeight = 0; // -> kein Help-Fenster
+ nPageWidth = nOutputWidth - STANDARD_MARGIN - STANDARD_MARGIN;
+ nPageHeight = nOutputHeight - STANDARD_MARGIN - DETAILS_HEADER_HEIGHT - STANDARD_MARGIN;
+ }
+ }
+
+ m_pHeader->SetPosSizePixel( Point(0, STANDARD_MARGIN), Size(nOutputWidth, 15) );
+
+ getGenPage()->SetPosSizePixel(Point ( STANDARD_MARGIN,
+ STANDARD_MARGIN + DETAILS_HEADER_HEIGHT
+ ),
+ Size ( nPageWidth,
+ nPageHeight
+ )
+ );
+ if (nHelpHeight)
+ {
+ m_pHelpBar->Show();
+ m_pHelpBar->SetPosSizePixel(Point ( nHelpX,
+ nHelpY
+ ),
+ Size ( nHelpWidth,
+ nHelpHeight
+ )
+ );
+ }
+ else
+ {
+ m_pHelpBar->Hide();
+ }
+ Invalidate();
+}
+// -----------------------------------------------------------------------------
+IClipboardTest* OTableFieldDescWin::getActiveChild() const
+{
+ IClipboardTest* pTest = NULL;
+ switch(m_eChildFocus)
+ {
+ case DESCRIPTION:
+ pTest = getGenPage();
+ break;
+ default:
+ pTest = getHelpBar();
+ break;
+ }
+ return pTest;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isCopyAllowed()
+{
+ return getActiveChild() && getActiveChild()->isCopyAllowed();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isCutAllowed()
+{
+ return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isCutAllowed());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableFieldDescWin::isPasteAllowed()
+{
+ return (getGenPage() && getGenPage()->HasChildPathFocus() && getGenPage()->isPasteAllowed());
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::cut()
+{
+ if ( getGenPage() && getGenPage()->HasChildPathFocus() )
+ getGenPage()->cut();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::copy()
+{
+ if ( getActiveChild() )
+ getActiveChild()->copy();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::paste()
+{
+ if ( getGenPage() && getGenPage()->HasChildPathFocus() )
+ getGenPage()->paste();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::GetFocus()
+{
+ if ( getGenPage() )
+ getGenPage()->GetFocus();
+}
+// -----------------------------------------------------------------------------
+void OTableFieldDescWin::LoseFocus()
+{
+ if ( getGenPage() )
+ getGenPage()->LoseFocus();
+}
+// -----------------------------------------------------------------------------
+long OTableFieldDescWin::PreNotify( NotifyEvent& rNEvt )
+{
+ sal_Bool bHandled = sal_False;
+ switch(rNEvt.GetType())
+ {
+ case EVENT_GETFOCUS:
+ if( getGenPage() && getGenPage()->HasChildPathFocus() )
+ m_eChildFocus = DESCRIPTION;
+ else
+ m_eChildFocus = HELP;
+ break;
+ }
+
+ return bHandled ? 1L : TabPage::PreNotify(rNEvt);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
new file mode 100644
index 000000000000..5bfb03283cfc
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableFieldDescWin.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEFIELDDESCRIPTION_HXX
+#define DBAUI_TABLEFIELDDESCRIPTION_HXX
+
+#include <vcl/tabpage.hxx>
+#include "FieldDescGenWin.hxx"
+#include "IClipBoardTest.hxx"
+
+class FixedText;
+namespace dbaui
+{
+ class OFieldDescGenWin;
+ class OTableDesignHelpBar;
+ class OFieldDescription;
+ //==================================================================
+ // Ableitung von TabPage ist ein Trick von TH,
+ // um Aenderungen der Systemfarben zu bemerken
+ class OTableFieldDescWin : public TabPage
+ ,public IClipboardTest
+ {
+ enum ChildFocusState
+ {
+ DESCRIPTION,
+ HELP,
+ NONE
+ };
+ private:
+ OTableDesignHelpBar* m_pHelpBar;
+ OFieldDescGenWin* m_pGenPage;
+ FixedText* m_pHeader;
+ ChildFocusState m_eChildFocus;
+
+ IClipboardTest* getActiveChild() const;
+
+ protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRect );
+
+ public:
+ OTableFieldDescWin( Window* pParent);
+ virtual ~OTableFieldDescWin();
+
+ virtual void Init();
+
+ void DisplayData( OFieldDescription* pFieldDescr );
+ void SaveData( OFieldDescription* pFieldDescr );
+ void SetReadOnly( sal_Bool bReadOnly );
+
+ // window overloads
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ void SetControlText( sal_uInt16 nControlId, const String& rText )
+ { m_pGenPage->SetControlText(nControlId,rText); }
+ String GetControlText( sal_uInt16 nControlId )
+ { return m_pGenPage->GetControlText(nControlId); }
+
+ // short GetFormatCategory(OFieldDescription* pFieldDescr) { return m_pGenPage ? m_pGenPage->GetFormatCategory(pFieldDescr) : -1; }
+ // liefert zum am Feld eingestellten Format einen der CAT_xxx-Werte (CAT_NUMBER, CAT_DATE ...)
+
+ String BoolStringPersistent(const String& rUIString) const { return m_pGenPage->BoolStringPersistent(rUIString); }
+ String BoolStringUI(const String& rPersistentString) const { return m_pGenPage->BoolStringUI(rPersistentString); }
+
+ // IClipboardTest
+ virtual sal_Bool isCutAllowed();
+ virtual sal_Bool isCopyAllowed();
+ virtual sal_Bool isPasteAllowed();
+ virtual sal_Bool hasChildPathFocus() { return HasChildPathFocus(); }
+
+ virtual void copy();
+ virtual void cut();
+ virtual void paste();
+
+ inline OFieldDescGenWin* getGenPage() const { return m_pGenPage; }
+ inline OTableDesignHelpBar* getHelpBar() const { return m_pHelpBar; }
+
+ };
+}
+#endif // DBAUI_TABLEFIELDDESCRIPTION_HXX
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableRow.cxx b/dbaccess/source/ui/tabledesign/TableRow.cxx
new file mode 100644
index 000000000000..b9891730c1e5
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRow.cxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableRow.hxx"
+#include <tools/debug.hxx>
+#include "FieldDescriptions.hxx"
+#include <algorithm>
+#include <comphelper/types.hxx>
+
+using namespace dbaui;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+//========================================================================
+// class OTableRow
+//========================================================================
+DBG_NAME(OTableRow)
+//------------------------------------------------------------------------------
+OTableRow::OTableRow()
+ :m_pActFieldDescr( NULL )
+ ,m_nPos( -1 )
+ ,m_bReadOnly( false )
+ ,m_bOwnsDescriptions(false)
+{
+ DBG_CTOR(OTableRow,NULL);
+}
+//------------------------------------------------------------------------------
+OTableRow::OTableRow(const Reference< XPropertySet >& xAffectedCol)
+ :m_pActFieldDescr( NULL )
+ ,m_nPos( -1 )
+ ,m_bReadOnly( false )
+ ,m_bOwnsDescriptions(true)
+{
+ DBG_CTOR(OTableRow,NULL);
+ m_pActFieldDescr = new OFieldDescription(xAffectedCol);
+}
+//------------------------------------------------------------------------------
+OTableRow::OTableRow( const OTableRow& rRow, long nPosition )
+ :m_pActFieldDescr(NULL)
+ ,m_nPos( nPosition )
+ ,m_bReadOnly(rRow.IsReadOnly())
+ ,m_bOwnsDescriptions(false)
+{
+ DBG_CTOR(OTableRow,NULL);
+
+ OFieldDescription* pSrcField = rRow.GetActFieldDescr();
+ if(pSrcField)
+ {
+ m_pActFieldDescr = new OFieldDescription(*pSrcField);
+ m_bOwnsDescriptions = true;
+ }
+}
+
+//------------------------------------------------------------------------------
+OTableRow::~OTableRow()
+{
+ DBG_DTOR(OTableRow,NULL);
+ if(m_bOwnsDescriptions)
+ delete m_pActFieldDescr;
+}
+
+//------------------------------------------------------------------------------
+void OTableRow::SetPrimaryKey( sal_Bool bSet )
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ if(m_pActFieldDescr)
+ m_pActFieldDescr->SetPrimaryKey(bSet);
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableRow::IsPrimaryKey() const
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ return m_pActFieldDescr && m_pActFieldDescr->IsPrimaryKey();
+}
+// -----------------------------------------------------------------------------
+void OTableRow::SetFieldType( const TOTypeInfoSP& _pType, sal_Bool _bForce )
+{
+ DBG_CHKTHIS(OTableRow,NULL);
+ if ( _pType.get() )
+ {
+ if( !m_pActFieldDescr )
+ {
+ m_pActFieldDescr = new OFieldDescription();
+ m_bOwnsDescriptions = true;
+ }
+ m_pActFieldDescr->FillFromTypeInfo(_pType,_bForce,sal_True);
+ }
+ else
+ {
+ delete m_pActFieldDescr;
+ m_pActFieldDescr = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+namespace dbaui
+{
+ // -----------------------------------------------------------------------------
+ SvStream& operator<<( SvStream& _rStr, const OTableRow& _rRow )
+ {
+ _rStr << _rRow.m_nPos;
+ OFieldDescription* pFieldDesc = _rRow.GetActFieldDescr();
+ if(pFieldDesc)
+ {
+ _rStr << (sal_Int32)1;
+ _rStr.WriteByteString(pFieldDesc->GetName());
+ _rStr.WriteByteString(pFieldDesc->GetDescription());
+ _rStr.WriteByteString(pFieldDesc->GetHelpText());
+ double nValue = 0.0;
+ Any aValue = pFieldDesc->GetControlDefault();
+ if ( aValue >>= nValue )
+ {
+ _rStr << sal_Int32(1);
+ _rStr << nValue;
+ }
+ else
+ {
+ _rStr << sal_Int32(2);
+ _rStr.WriteByteString(::comphelper::getString(aValue));
+ }
+
+ _rStr << pFieldDesc->GetType();
+
+ _rStr << pFieldDesc->GetPrecision();
+ _rStr << pFieldDesc->GetScale();
+ _rStr << pFieldDesc->GetIsNullable();
+ _rStr << pFieldDesc->GetFormatKey();
+ _rStr << (sal_Int32)pFieldDesc->GetHorJustify();
+ _rStr << sal_Int32(pFieldDesc->IsAutoIncrement() ? 1 : 0);
+ _rStr << sal_Int32(pFieldDesc->IsPrimaryKey() ? 1 : 0);
+ _rStr << sal_Int32(pFieldDesc->IsCurrency() ? 1 : 0);
+ }
+ else
+ _rStr << (sal_Int32)0;
+ return _rStr;
+ }
+ // -----------------------------------------------------------------------------
+ SvStream& operator>>( SvStream& _rStr, OTableRow& _rRow )
+ {
+ _rStr >> _rRow.m_nPos;
+ sal_Int32 nValue = 0;
+ _rStr >> nValue;
+ if ( nValue )
+ {
+ OFieldDescription* pFieldDesc = new OFieldDescription();
+ _rRow.m_pActFieldDescr = pFieldDesc;
+ String sValue;
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetName(sValue);
+
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetDescription(sValue);
+ _rStr.ReadByteString(sValue);
+ pFieldDesc->SetHelpText(sValue);
+
+ _rStr >> nValue;
+ Any aControlDefault;
+ switch ( nValue )
+ {
+ case 1:
+ {
+ double nControlDefault;
+ _rStr >> nControlDefault;
+ aControlDefault <<= nControlDefault;
+ break;
+ }
+ case 2:
+ _rStr.ReadByteString(sValue);
+ aControlDefault <<= ::rtl::OUString(sValue);
+ break;
+ }
+
+ pFieldDesc->SetControlDefault(aControlDefault);
+
+
+ _rStr >> nValue;
+ pFieldDesc->SetTypeValue(nValue);
+
+ _rStr >> nValue;
+ pFieldDesc->SetPrecision(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetScale(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetIsNullable(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetFormatKey(nValue);
+ _rStr >> nValue;
+ pFieldDesc->SetHorJustify((SvxCellHorJustify)nValue);
+
+ _rStr >> nValue;
+ pFieldDesc->SetAutoIncrement(nValue != 0);
+ _rStr >> nValue;
+ pFieldDesc->SetPrimaryKey(nValue != 0);
+ _rStr >> nValue;
+ pFieldDesc->SetCurrency(nValue != 0);
+ }
+ return _rStr;
+ }
+ // -----------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableRowExchange.cxx b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
new file mode 100644
index 000000000000..97a6f2d649f1
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableRowExchange.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableRowExchange.hxx"
+#include <sot/formats.hxx>
+#include <sot/storage.hxx>
+#include "TableRow.hxx"
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ OTableRowExchange::OTableRowExchange(const ::std::vector< ::boost::shared_ptr<OTableRow> >& _rvTableRow)
+ : m_vTableRow(_rvTableRow)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableRowExchange::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& /*rFlavor*/ )
+ {
+ if(nUserObjectId == SOT_FORMATSTR_ID_SBA_TABED)
+ {
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRows = reinterpret_cast< ::std::vector< ::boost::shared_ptr<OTableRow> >* >(pUserObject);
+ if(pRows)
+ {
+ (*rxOStm) << (sal_Int32)pRows->size(); // first stream the size
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = pRows->begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = pRows->end();
+ for(;aIter != aEnd;++aIter)
+ (*rxOStm) << *(*aIter);
+ return sal_True;
+ }
+ }
+ return sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableRowExchange::AddSupportedFormats()
+ {
+ if ( !m_vTableRow.empty() )
+ AddFormat(SOT_FORMATSTR_ID_SBA_TABED);
+ }
+ // -----------------------------------------------------------------------------
+ sal_Bool OTableRowExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+ {
+ sal_uLong nFormat = SotExchange::GetFormat(rFlavor);
+ if(nFormat == SOT_FORMATSTR_ID_SBA_TABED)
+ return SetObject(&m_vTableRow,SOT_FORMATSTR_ID_SBA_TABED,rFlavor);
+ return sal_False;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableRowExchange::ObjectReleased()
+ {
+ m_vTableRow.clear();
+ }
+ // -----------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.cxx b/dbaccess/source/ui/tabledesign/TableUndo.cxx
new file mode 100644
index 000000000000..36262c5a0ac1
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.cxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "TableUndo.hxx"
+#include "dbu_tbl.hrc"
+#include "TEditControl.hxx"
+#include "TableRow.hxx"
+#include "browserids.hxx"
+#include "TableController.hxx"
+#include "TableDesignView.hxx"
+#include "FieldDescriptions.hxx"
+#include <tools/debug.hxx>
+
+using namespace dbaui;
+using namespace ::svt;
+
+TYPEINIT1( OCommentUndoAction, SfxUndoAction );
+TYPEINIT1( OTableDesignUndoAct, OCommentUndoAction );
+TYPEINIT1( OTableEditorUndoAct, OTableDesignUndoAct );
+TYPEINIT1( OTableDesignCellUndoAct, OTableDesignUndoAct );
+TYPEINIT1( OTableEditorTypeSelUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorDelUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorInsUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OTableEditorInsNewUndoAct, OTableEditorUndoAct );
+TYPEINIT1( OPrimKeyUndoAct, OTableEditorUndoAct );
+
+//==============================================================================
+// class OTableDesignUndoAct
+//==============================================================================
+DBG_NAME(OTableDesignUndoAct);
+OTableDesignUndoAct::OTableDesignUndoAct( OTableRowView* pOwner,sal_uInt16 nCommentID ) : OCommentUndoAction(nCommentID)
+ ,m_pTabDgnCtrl( pOwner )
+{
+ DBG_CTOR(OTableDesignUndoAct,NULL);
+ m_pTabDgnCtrl->m_nCurUndoActId++;
+}
+
+//-------------------------------------------------------------------------
+OTableDesignUndoAct::~OTableDesignUndoAct()
+{
+ DBG_DTOR(OTableDesignUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignUndoAct::Undo()
+{
+ m_pTabDgnCtrl->m_nCurUndoActId--;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn erstes Undo zurueckgenommen wurde, ist Doc nicht modifiziert worden
+ if( m_pTabDgnCtrl->m_nCurUndoActId == 0 )
+ {
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
+ m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+ }
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignUndoAct::Redo()
+{
+ m_pTabDgnCtrl->m_nCurUndoActId++;
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Redo fuer erste Undo-Action, muss Modified-Flag wieder gesetzt werden
+ if( m_pTabDgnCtrl->m_nCurUndoActId > 0 )
+ {
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_True);
+ m_pTabDgnCtrl->GetView()->getController().InvalidateFeature(SID_SAVEDOC);
+ }
+}
+//==============================================================================
+// class OTableDesignCellUndoAct
+//==============================================================================
+DBG_NAME(OTableDesignCellUndoAct);
+OTableDesignCellUndoAct::OTableDesignCellUndoAct( OTableRowView* pOwner, long nRowID, sal_uInt16 nColumn ) :
+ OTableDesignUndoAct( pOwner ,STR_TABED_UNDO_CELLMODIFIED)
+ ,m_nCol( nColumn )
+ ,m_nRow( nRowID )
+{
+ DBG_CTOR(OTableDesignCellUndoAct,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Text an der Position (m_nRow, m_nCol) auslesen
+ m_sOldText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
+}
+
+//-------------------------------------------------------------------------
+OTableDesignCellUndoAct::~OTableDesignCellUndoAct()
+{
+ DBG_DTOR(OTableDesignCellUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignCellUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Text der alten Zelle speichern und alten wieder einsetzen
+ m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
+ m_sNewText = m_pTabDgnCtrl->GetCellData( m_nRow, m_nCol );
+ m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sOldText );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn erstes Undo zurueckgenommen wurde, ist Zelle nicht mehr modifiziert
+ if (m_pTabDgnCtrl->GetCurUndoActId() == 1)
+ {
+ CellControllerRef xController = m_pTabDgnCtrl->Controller();
+ if ( xController.Is() )
+ xController->ClearModified();
+ m_pTabDgnCtrl->GetView()->getController().setModified(sal_False);
+
+ }
+
+ OTableDesignUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableDesignCellUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Text wieder einseten
+ m_pTabDgnCtrl->ActivateCell( m_nRow, m_nCol );
+ m_pTabDgnCtrl->SetCellData( m_nRow, m_nCol, m_sNewText );
+
+ OTableDesignUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorUndoAct);
+OTableEditorUndoAct::OTableEditorUndoAct( OTableEditorCtrl* pOwner,sal_uInt16 _nCommentID ) :
+ OTableDesignUndoAct( pOwner ,_nCommentID)
+ ,pTabEdCtrl(pOwner)
+{
+ DBG_CTOR(OTableEditorUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorUndoAct::~OTableEditorUndoAct()
+{
+ DBG_DTOR(OTableEditorUndoAct,NULL);
+}
+
+//==============================================================================
+// class OTableEditorTypeSelUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorTypeSelUndoAct);
+OTableEditorTypeSelUndoAct::OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, sal_uInt16 nColumn, const TOTypeInfoSP& _pOldType )
+ :OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_TYPE_CHANGED)
+ ,m_nCol( nColumn )
+ ,m_nRow( nRowID )
+ ,m_pOldType( _pOldType )
+{
+ DBG_CTOR(OTableEditorTypeSelUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorTypeSelUndoAct::~OTableEditorTypeSelUndoAct()
+{
+ DBG_DTOR(OTableEditorTypeSelUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorTypeSelUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Typ zuruecksetzen
+ OFieldDescription* pFieldDesc = pTabEdCtrl->GetFieldDescr(m_nRow);
+ if(pFieldDesc)
+ m_pNewType = pFieldDesc->getTypeInfo();
+ else
+ m_pNewType = TOTypeInfoSP();
+ pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pOldType);
+ pTabEdCtrl->SwitchType( m_pOldType );
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorTypeSelUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Typ
+ pTabEdCtrl->GoToRowColumnId( m_nRow ,m_nCol);
+ pTabEdCtrl->SetCellData(m_nRow,m_nCol,m_pNewType);
+
+ OTableEditorUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorDelUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorDelUndoAct);
+OTableEditorDelUndoAct::OTableEditorDelUndoAct( OTableEditorCtrl* pOwner) :
+ OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_ROWDELETED)
+{
+ DBG_CTOR(OTableEditorDelUndoAct,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // DeletedRowList fuellen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pOwner->GetRowList();
+ long nIndex = pOwner->FirstSelectedRow();
+ ::boost::shared_ptr<OTableRow> pOriginalRow;
+ ::boost::shared_ptr<OTableRow> pNewRow;
+
+ while( nIndex >= 0 )
+ {
+ pOriginalRow = (*pOriginalRows)[nIndex];
+ pNewRow.reset(new OTableRow( *pOriginalRow, nIndex ));
+ m_aDeletedRows.push_back( pNewRow);
+
+ nIndex = pOwner->NextSelectedRow();
+ }
+}
+
+//-------------------------------------------------------------------------
+OTableEditorDelUndoAct::~OTableEditorDelUndoAct()
+{
+ DBG_DTOR(OTableEditorDelUndoAct,NULL);
+ m_aDeletedRows.clear();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorDelUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Geloeschte Zeilen wieder einfuegen
+ sal_uLong nPos;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
+
+ ::boost::shared_ptr<OTableRow> pNewOrigRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ pNewOrigRow.reset(new OTableRow( **aIter ));
+ nPos = (*aIter)->GetPos();
+ pOriginalRows->insert( pOriginalRows->begin()+nPos,pNewOrigRow);
+ }
+
+ pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
+ pTabEdCtrl->Invalidate();
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorDelUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder loeschen
+ sal_uLong nPos;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_aDeletedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_aDeletedRows.end();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for(;aIter != aEnd;++aIter)
+ {
+ nPos = (*aIter)->GetPos();
+ pOriginalRows->erase( pOriginalRows->begin()+nPos );
+ }
+
+ pTabEdCtrl->DisplayData(pTabEdCtrl->GetCurRow());
+ pTabEdCtrl->Invalidate();
+ OTableEditorUndoAct::Redo();
+}
+
+//-------------------------------------------------------------------------
+//==============================================================================
+// class OTableEditorInsUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorInsUndoAct);
+OTableEditorInsUndoAct::OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
+ long nInsertPosition ,
+ const ::std::vector< ::boost::shared_ptr<OTableRow> >& _vInsertedRows)
+ :OTableEditorUndoAct( pOwner,STR_TABED_UNDO_ROWINSERTED )
+ ,m_vInsertedRows(_vInsertedRows)
+ ,m_nInsPos( nInsertPosition )
+{
+ DBG_CTOR(OTableEditorInsUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorInsUndoAct::~OTableEditorInsUndoAct()
+{
+ DBG_DTOR(OTableEditorInsUndoAct,NULL);
+ m_vInsertedRows.clear();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Eingefuegte Zeilen wieder loeschen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+ for( long i=(m_nInsPos+m_vInsertedRows.size()-1); i>(m_nInsPos-1); i-- )
+ {
+ pOriginalRows->erase(pOriginalRows->begin()+i);
+ }
+
+ pTabEdCtrl->RowRemoved( m_nInsPos, m_vInsertedRows.size(), sal_True );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder einfuegen
+ long nInsertRow = m_nInsPos;
+ ::boost::shared_ptr<OTableRow> pRow;
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vInsertedRows.begin();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_vInsertedRows.end();
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ for(;aIter != aEnd;++aIter)
+ {
+ pRow.reset(new OTableRow( **aIter ));
+ pRowList->insert( pRowList->begin()+nInsertRow ,pRow );
+ nInsertRow++;
+ }
+
+ pTabEdCtrl->RowInserted( m_nInsPos, m_vInsertedRows.size(), sal_True );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Redo();
+}
+
+//==============================================================================
+// class OTableEditorInsNewUndoAct
+//==============================================================================
+DBG_NAME(OTableEditorInsNewUndoAct);
+OTableEditorInsNewUndoAct::OTableEditorInsNewUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition, long nInsertedRows ) :
+ OTableEditorUndoAct( pOwner ,STR_TABED_UNDO_NEWROWINSERTED)
+ ,m_nInsPos( nInsertPosition )
+ ,m_nInsRows( nInsertedRows )
+{
+ DBG_CTOR(OTableEditorInsNewUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OTableEditorInsNewUndoAct::~OTableEditorInsNewUndoAct()
+{
+ DBG_DTOR(OTableEditorInsNewUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsNewUndoAct::Undo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Eingefuegte Zeilen wieder loeschen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pOriginalRows = pTabEdCtrl->GetRowList();
+
+ for( long i=(m_nInsPos+m_nInsRows-1); i>(m_nInsPos-1); i-- )
+ {
+ pOriginalRows->erase(pOriginalRows->begin()+i);
+ }
+
+ pTabEdCtrl->RowRemoved( m_nInsPos, m_nInsRows, sal_True );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OTableEditorInsNewUndoAct::Redo()
+{
+ //////////////////////////////////////////////////////////////////////
+ // Zeilen wieder einfuegen
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+
+ for( long i=m_nInsPos; i<(m_nInsPos+m_nInsRows); i++ )
+ pRowList->insert( pRowList->begin()+i,::boost::shared_ptr<OTableRow>(new OTableRow()) );
+
+ pTabEdCtrl->RowInserted( m_nInsPos, m_nInsRows, sal_True );
+ pTabEdCtrl->InvalidateHandleColumn();
+
+ OTableEditorUndoAct::Redo();
+}
+
+//-------------------------------------------------------------------------
+//========================================================================
+// class OPrimKeyUndoAct
+//========================================================================
+DBG_NAME(OPrimKeyUndoAct);
+//-------------------------------------------------------------------------
+OPrimKeyUndoAct::OPrimKeyUndoAct( OTableEditorCtrl* pOwner, MultiSelection aDeletedKeys, MultiSelection aInsertedKeys) :
+ OTableEditorUndoAct( pOwner ,STR_TABLEDESIGN_UNDO_PRIMKEY)
+ ,m_aDelKeys( aDeletedKeys )
+ ,m_aInsKeys( aInsertedKeys )
+ ,m_pEditorCtrl( pOwner )
+{
+ DBG_CTOR(OPrimKeyUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+OPrimKeyUndoAct::~OPrimKeyUndoAct()
+{
+ DBG_DTOR(OPrimKeyUndoAct,NULL);
+}
+
+//-------------------------------------------------------------------------
+void OPrimKeyUndoAct::Undo()
+{
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ ::boost::shared_ptr<OTableRow> pRow;
+ long nIndex;
+
+ //////////////////////////////////////////////////////////////////////
+ // Die eingefuegten Keys loeschen
+ for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
+ {
+ OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
+ pRow = (*pRowList)[nIndex];
+ pRow->SetPrimaryKey( sal_False );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Die geloeschten Keys herstellen
+ for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
+ {
+ OSL_ENSURE(nIndex <= static_cast<long>(pRowList->size()),"Index for undo isn't valid!");
+ pRow = (*pRowList)[nIndex];
+ pRow->SetPrimaryKey( sal_True );
+ }
+
+ m_pEditorCtrl->InvalidateHandleColumn();
+ OTableEditorUndoAct::Undo();
+}
+
+//-------------------------------------------------------------------------
+void OPrimKeyUndoAct::Redo()
+{
+ ::std::vector< ::boost::shared_ptr<OTableRow> >* pRowList = pTabEdCtrl->GetRowList();
+ long nIndex;
+
+ //////////////////////////////////////////////////////////////////////
+ // Die geloeschten Keys loeschen
+ for( nIndex = m_aDelKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aDelKeys.NextSelected() )
+ (*pRowList)[nIndex]->SetPrimaryKey( sal_False );
+
+ //////////////////////////////////////////////////////////////////////
+ // Die eingefuegten Keys herstellen
+ for( nIndex = m_aInsKeys.FirstSelected(); nIndex != (long)SFX_ENDOFSELECTION; nIndex=m_aInsKeys.NextSelected() )
+ (*pRowList)[nIndex]->SetPrimaryKey( sal_True );
+
+ m_pEditorCtrl->InvalidateHandleColumn();
+ OTableEditorUndoAct::Redo();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/TableUndo.hxx b/dbaccess/source/ui/tabledesign/TableUndo.hxx
new file mode 100644
index 000000000000..23ecf12b8e61
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/TableUndo.hxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_TABLEUNDO_HXX
+#define DBAUI_TABLEUNDO_HXX
+
+#include "GeneralUndo.hxx"
+#include <tools/multisel.hxx>
+
+#include <vector>
+
+#include <com/sun/star/uno/Any.h>
+#include "TypeInfo.hxx"
+
+namespace dbaui
+{
+ //========================================================================
+ class OTableRowView;
+ class OTableRow;
+ class OTableDesignUndoAct : public OCommentUndoAction
+ {
+ protected:
+ OTableRowView* m_pTabDgnCtrl;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableDesignUndoAct( OTableRowView* pOwner ,sal_uInt16 nCommentID);
+ virtual ~OTableDesignUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorCtrl;
+ class OTableEditorUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ OTableEditorCtrl* pTabEdCtrl;
+
+ public:
+ TYPEINFO();
+ OTableEditorUndoAct( OTableEditorCtrl* pOwner,sal_uInt16 nCommentID );
+ virtual ~OTableEditorUndoAct();
+ };
+
+
+ //========================================================================
+ class OTableDesignCellUndoAct : public OTableDesignUndoAct
+ {
+ protected:
+ sal_uInt16 m_nCol;
+ long m_nRow;
+ ::com::sun::star::uno::Any m_sOldText;
+ ::com::sun::star::uno::Any m_sNewText;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableDesignCellUndoAct( OTableRowView* pOwner, long nRowID, sal_uInt16 nColumn );
+ virtual ~OTableDesignCellUndoAct();
+ };
+
+ class OTypeInfo;
+ //========================================================================
+ class OTableEditorTypeSelUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ sal_uInt16 m_nCol;
+ long m_nRow;
+ TOTypeInfoSP m_pOldType;
+ TOTypeInfoSP m_pNewType;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorTypeSelUndoAct( OTableEditorCtrl* pOwner, long nRowID, sal_uInt16 nColumn, const TOTypeInfoSP& _pOldType );
+ virtual ~OTableEditorTypeSelUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorDelUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_aDeletedRows;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorDelUndoAct( OTableEditorCtrl* pOwner );
+ virtual ~OTableEditorDelUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorInsUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ ::std::vector< ::boost::shared_ptr<OTableRow> > m_vInsertedRows;
+ long m_nInsPos;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorInsUndoAct( OTableEditorCtrl* pOwner,
+ long nInsertPosition,
+ const ::std::vector< ::boost::shared_ptr<OTableRow> >& _vInsertedRows);
+ virtual ~OTableEditorInsUndoAct();
+ };
+
+ //========================================================================
+ class OTableEditorInsNewUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ long m_nInsPos;
+ long m_nInsRows;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OTableEditorInsNewUndoAct( OTableEditorCtrl* pOwner, long nInsertPosition, long nInsertedRows );
+ virtual ~OTableEditorInsNewUndoAct();
+ };
+
+ //========================================================================
+ class OPrimKeyUndoAct : public OTableEditorUndoAct
+ {
+ protected:
+ MultiSelection m_aDelKeys,
+ m_aInsKeys;
+ sal_Bool m_bActPrimKeySet;
+ OTableEditorCtrl* m_pEditorCtrl;
+
+ virtual void Undo();
+ virtual void Redo();
+ public:
+ TYPEINFO();
+ OPrimKeyUndoAct( OTableEditorCtrl* pOwner, MultiSelection aDeletedKeys, MultiSelection aInsertedKeys );
+ virtual ~OPrimKeyUndoAct();
+ };
+}
+#endif // DBAUI_TABLEUNDO_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/tabledesign/makefile.mk b/dbaccess/source/ui/tabledesign/makefile.mk
new file mode 100644
index 000000000000..5e52041ecd29
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=tabledesign
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES =\
+ $(SLO)$/TableDesignControl.obj \
+ $(SLO)$/TableFieldDescWin.obj \
+ $(SLO)$/TableController.obj \
+ $(SLO)$/TableDesignView.obj \
+ $(SLO)$/TEditControl.obj \
+ $(SLO)$/TableFieldControl.obj \
+ $(SLO)$/TableDesignHelpBar.obj \
+ $(SLO)$/FieldDescGenWin.obj \
+ $(SLO)$/FieldDescriptions.obj \
+ $(SLO)$/TableRow.obj \
+ $(SLO)$/TableRowExchange.obj \
+ $(SLO)$/TableUndo.obj
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES = table.src
+
+# --- Targets -------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src
new file mode 100644
index 000000000000..8ae961bcbb80
--- /dev/null
+++ b/dbaccess/source/ui/tabledesign/table.src
@@ -0,0 +1,466 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_TBL_HRC_
+#include "dbu_tbl.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _DBACCESS_SLOTID_HRC_
+#include "dbaccess_slotid.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef DBAUI_TOOLBOX_HXX
+#include "toolbox.hrc"
+#endif
+
+#define MN_EDIT 20
+#define MN_VIEW 21
+#define MN_EXTRA 22
+#define MN_INDEX 23
+#define MN_WIN 30
+#define MN_HELP 31
+
+String STR_TABLEDESIGN_DBFIELDTYPES
+{
+ Text [ en-US ] = "Unknown;Text;Number;Date/Time;Date;Time;Yes/No;Currency;Memo;Counter;Image;Text (fix);Decimal;Binary (fix);Binary;BigInt;Double;Float;Real;Integer;Small Integer;Tiny Integer;SQL Null;Object;Distinct;Structure;Field;BLOB;CLOB;REF;OTHER;Bit (fix)";
+};
+
+String STR_TABLEDESIGN_UNDO_PRIMKEY
+{
+ Text [ en-US ] = "Insert/remove primary key" ;
+};
+
+String STR_VALUE_YES
+{
+ Text [ en-US ] = "Yes" ;
+};
+
+String STR_VALUE_NO
+{
+ Text [ en-US ] = "No" ;
+};
+
+String STR_VALUE_ASC
+{
+ Text [ en-US ] = "Ascending" ;
+};
+
+String STR_VALUE_DESC
+{
+ Text [ en-US ] = "Descending" ;
+};
+
+String STR_VALUE_NONE
+{
+ // Bemerkung : sollte auch in anderen Sprachen irgendwie zum Wort 'Wert' passen : Wert - keiner ....
+ Text [ en-US ] = "<none>";
+};
+
+String STR_TAB_FIELD_NAME
+{
+ Text [ en-US ] = "Field name" ;
+};
+
+String STR_TAB_FIELD_COLUMN_NAME
+{
+ Text [ en-US ] = "Field Name" ;
+};
+
+String STR_TAB_FIELD_DATATYPE
+{
+ Text [ en-US ] = "Field ~type" ;
+};
+
+String STR_TAB_FIELD_COLUMN_DATATYPE
+{
+ Text [ en-US ] = "Field Type" ;
+};
+
+String STR_TAB_FIELD_LENGTH
+{
+ Text [ en-US ] = "Field length" ;
+};
+
+String STR_TAB_HELP_TEXT
+{
+ Text [ en-US ] = "Description" ;
+};
+
+String STR_COLUMN_DESCRIPTION
+{
+ Text [ en-US ] = "Column Description" ;
+};
+
+String STR_TAB_FIELD_NULLABLE
+{
+ Text [ en-US ] = "Input required" ;
+};
+
+String STR_FIELD_AUTOINCREMENT
+{
+ Text [ en-US ] = "~AutoValue";
+};
+
+String STR_TAB_PROPERTIES
+{
+ Text [ en-US ] = "Field Properties" ;
+};
+
+String STR_TABPAGE_GENERAL
+{
+ Text [ en-US ] = "General" ;
+};
+
+String STR_TAB_TABLE_DESCRIPTION
+{
+ Text [ en-US ] = "Description:";
+};
+
+String STR_TAB_TABLE_PROPERTIES
+{
+ Text [ en-US ] = "Table properties";
+};
+
+Control RID_DB_TAB_EDITOR
+{
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ SvLook = TRUE ;
+ Hide = TRUE ;
+ HelpId = HID_TABDESIGN_BACKGROUND ;
+};
+
+ErrorBox ERR_INVALID_LISTBOX_ENTRY
+{
+ Message [ en-US ] = "The text you entered is not a list element. " ;
+};
+
+Menu RID_TABLEDESIGNROWPOPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_CUT
+ };
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
+ MenuItem
+ {
+ ITEM_EDIT_PASTE
+ };
+ MenuItem
+ {
+ ITEM_EDIT_DELETE
+ };
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_INSERTROWS ;
+ HelpID = HID_TABLEDESIGN_INSERTROWS ;
+ Text [ en-US ] = "Insert Rows" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ HelpID = HID_TABLEDESIGN_TABED_PRIMARYKEY ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Primary Key" ;
+ };
+ };
+};
+
+String STR_TABED_UNDO_CELLMODIFIED
+{
+ Text [ en-US ] = "Modify cell" ;
+};
+
+String STR_TABED_UNDO_ROWDELETED
+{
+ Text [ en-US ] = "Delete row" ;
+};
+
+String STR_TABED_UNDO_TYPE_CHANGED
+{
+ Text [ en-US ] = "Modify field type";
+};
+
+String STR_TABED_UNDO_ROWINSERTED
+{
+ Text [ en-US ] = "Insert row" ;
+};
+
+String STR_TABED_UNDO_NEWROWINSERTED
+{
+ Text [ en-US ] = "Insert new row" ;
+};
+
+String STR_TABED_UNDO_PRIMKEY
+{
+ Text [ en-US ] = "Insert/remove primary key" ;
+};
+
+String STR_DEFAULT_VALUE
+{
+ Text [ en-US ] = "~Default value" ;
+};
+
+String STR_FIELD_REQUIRED
+{
+ Text [ en-US ] = "~Entry required" ;
+};
+
+String STR_TEXT_LENGTH
+{
+ Text [ en-US ] = "~Length" ;
+};
+
+String STR_NUMERIC_TYPE
+{
+ Text [ en-US ] = "~Type" ;
+};
+
+String STR_LENGTH
+{
+ Text [ en-US ] = "~Length" ;
+};
+
+String STR_SCALE
+{
+ Text [ en-US ] = "Decimal ~places" ;
+};
+
+String STR_FORMAT
+{
+ Text [ en-US ] = "Format example";
+};
+
+String STR_HELP_BOOL_DEFAULT
+{
+ Text [ en-US ] = "Select a value that is to appear in all new records as default.\nIf the field is not to have a default value, select the empty string.";
+};
+
+String STR_HELP_DEFAULT_VALUE
+{
+ Text [ en-US ] = "Enter a default value for this field.\n\nWhen you later enter data in the table, this string will be used in each new record for the field selected. It should, therefore, correspond to the cell format that needs to be entered below." ;
+};
+
+String STR_HELP_FIELD_REQUIRED
+{
+ Text [ en-US ] = "Activate this option if this field cannot contain NULL values, i.e. the user must always enter data." ;
+};
+
+String STR_HELP_TEXT_LENGTH
+{
+ Text [ en-US ] = "Enter the maximum text length permitted." ;
+};
+
+String STR_HELP_NUMERIC_TYPE
+{
+ Text [ en-US ] = "Enter the number format." ;
+};
+
+String STR_HELP_LENGTH
+{
+ Text [ en-US ] = "Determine the length data can have in this field.\n\nIf decimal fields, then the maximum length of the number to be entered, if binary fields, then the length of the data block.\nThe value will be corrected accordingly when it exceeds the maximum for this database." ;
+};
+
+String STR_HELP_SCALE
+{
+ Text [ en-US ] = "Specify the number of decimal places permitted in this field." ;
+};
+
+String STR_HELP_FORMAT_CODE
+{
+ Text [ en-US ] = "This is where you see how the data would be displayed in the current format (use the button on the right to modify the format).";
+};
+
+String STR_HELP_FORMAT_BUTTON
+{
+ Text [ en-US ] = "This is where you determine the output format of the data.";
+};
+
+String STR_HELP_AUTOINCREMENT
+{
+ Text [ en-US ] = "Choose if this field should contain AutoIncrement values.\n\nYou can not enter data in fields of this type. An intrinsic value will be assigned to each new record automatically (resulting from the increment of the previous record)." ;
+};
+
+PushButton PB_FORMAT
+{
+ TabStop = TRUE ;
+ Text [ en-US ] = "~...";
+};
+
+String STR_TABLEDESIGN_DUPLICATE_NAME
+{
+ Text [ en-US ] = "The table cannot be saved because column name \"$column$\" was assigned twice.";
+};
+
+String STR_TBL_COLUMN_IS_KEYCOLUMN
+{
+ Text [ en-US ] = "The column \"$column$\" belongs to the primary key. If the column is deleted, the primary key will also be deleted. Do you really want to continue?";
+};
+
+String STR_TBL_COLUMN_IS_KEYCOLUMN_TITLE
+{
+ Text [ en-US ] = "Primary Key Affected";
+};
+
+String STR_COLUMN_NAME
+{
+ Text [ en-US ] = "Column";
+};
+
+String STR_QRY_CONTINUE
+{
+ Text [ en-US ] = "Continue anyway?" ;
+};
+
+String STR_STAT_WARNING
+{
+ Text [ en-US ] = "Warning!" ;
+};
+
+QueryBox TABLE_DESIGN_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The table has been changed.\nDo you want to save the changes?" ;
+};
+
+QueryBox TABLE_QUERY_CONNECTION_LOST
+{
+ Buttons = WB_YES_NO ;
+ Message [ en-US ] = "The connection to the database was lost! The table design can only be used with limited functionality without a connection.\nReconnect?" ;
+};
+
+String STR_TABLEDESIGN_CONNECTION_MISSING
+{
+ Text [ en-US ] = "The table could not be saved due to problems connecting to the database.";
+};
+
+String STR_TABLEDESIGN_DATASOURCE_DELETED
+{
+ Text [ en-US ] = "The table filter could not be adjusted because the data source has been deleted.";
+};
+
+QueryBox QUERY_SAVE_TABLE_EDIT_INDEXES
+{
+ Message [ en-US ] = "Before you can edit the indexes of a table, you have to save it.\nDo you want to save the changes now?";
+
+ Buttons = WB_YES_NO ;
+};
+
+String STR_TABLEDESIGN_NO_PRIM_KEY_HEAD
+{
+ Text [ en-US ] = "No primary key" ;
+};
+
+String STR_TABLEDESIGN_NO_PRIM_KEY
+{
+ Text [ en-US ] = "A unique index or primary key is required for data record identification in this database.\nYou can only enter data into this table when one of these two structural conditions has been met.\n\nShould a primary key be created now?" ;
+};
+
+
+String STR_TABLEDESIGN_TITLE
+{
+ Text [ en-US ] = " - %PRODUCTNAME Base: Table Design";
+};
+
+/*
+ The menubar resource has become obsolete - you can now find the menubar definition at: <project>/uiconfig/dbtable/menubar/menubar.xml
+*/
+
+String STR_TABLEDESIGN_ALTER_ERROR
+{
+ Text [ en-US ] = "The column \"$column$\" could not be changed. Should the column instead be deleted and the new format appended?" ;
+};
+
+String STR_TABLEDESIGN_SAVE_ERROR
+{
+ Text [ en-US ] = "Error while saving the table design";
+};
+
+String STR_TABLEDESIGN_COULD_NOT_DROP_COL
+{
+ Text [ en-US ] = "The column $column$ could not be deleted.";
+};
+
+QueryBox TABLE_DESIGN_ALL_ROWS_DELETED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "You are trying to delete all the columns in the table. A table cannot exist without columns. Should the table be deleted from the database? If not, the table will remain unchanged.";
+};
+
+String STR_AUTOINCREMENT_VALUE
+{
+ Text [ en-US ] = "A~uto-increment statement";
+};
+
+String STR_HELP_AUTOINCREMENT_VALUE
+{
+ Text [ en-US ] = "Enter an SQL statement for the auto-increment field.\n\nThis statement will be directly transferred to the database when the table is created.";
+};
+
+String STR_NO_TYPE_INFO_AVAILABLE
+{
+ Text [ en-US ] = "No type information could be retrieved from the database.\nThe table design mode is not available for this data source.";
+};
+
+String STR_CHANGE_COLUMN_NAME
+{
+ Text [ en-US ] = "change field name";
+};
+
+String STR_CHANGE_COLUMN_TYPE
+{
+ Text [ en-US ] = "change field type";
+};
+
+String STR_CHANGE_COLUMN_DESCRIPTION
+{
+ Text [ en-US ] = "change field description";
+};
+
+String STR_CHANGE_COLUMN_ATTRIBUTE
+{
+ Text [ en-US ] = "change field attribute";
+};
diff --git a/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx b/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx
new file mode 100644
index 000000000000..d138782392da
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "AdabasSettingsDlg.hxx"
+#include "AdabasStatDlg.hxx"
+
+
+using namespace dbaui;
+
+extern "C" void SAL_CALL createRegistryInfo_OAdabasSettingsDialog()
+{
+ static OMultiInstanceAutoRegistration< OAdabasSettingsDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+OAdabasSettingsDialog::OAdabasSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+{
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL OAdabasSettingsDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OAdabasSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OAdabasSettingsDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OAdabasSettingsDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString OAdabasSettingsDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OAdabasSettingsDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL OAdabasSettingsDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence OAdabasSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdabasAdministrationDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL OAdabasSettingsDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OAdabasSettingsDialog::getInfoHelper()
+{
+ return *const_cast<OAdabasSettingsDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OAdabasSettingsDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* OAdabasSettingsDialog::createDialog(Window* _pParent)
+{
+ OAdabasStatPageDlg* pDlg = new OAdabasStatPageDlg(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection);
+ return pDlg;
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx
new file mode 100644
index 000000000000..f102ba02c39d
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdabasSettingsDlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_ADABASSETTINGSDLG_HXX
+#define _DBAUI_ADABASSETTINGSDLG_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= OAdabasSettingsDialog
+//=========================================================================
+class OAdabasSettingsDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< OAdabasSettingsDialog >
+{
+
+protected:
+ OAdabasSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_ADABASSETTINGSDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
new file mode 100644
index 000000000000..ce30b85d57cc
--- /dev/null
+++ b/dbaccess/source/ui/uno/AdvancedSettingsDlg.cxx
@@ -0,0 +1,162 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "unoadmin.hxx"
+#include "dbu_reghelper.hxx"
+#include "advancedsettingsdlg.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //=========================================================================
+ //= OAdvancedSettingsDialog
+ //=========================================================================
+ class OAdvancedSettingsDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< OAdvancedSettingsDialog >
+ {
+
+ protected:
+ OAdvancedSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ };
+
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ OAdvancedSettingsDialog::OAdvancedSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+ {
+ }
+ //-------------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OAdvancedSettingsDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //-------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OAdvancedSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+ {
+ return *(new OAdvancedSettingsDialog(_rxFactory));
+ }
+
+ //-------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OAdvancedSettingsDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+
+ //-------------------------------------------------------------------------
+ ::rtl::OUString OAdvancedSettingsDialog::getImplementationName_Static() throw(RuntimeException)
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OAdvancedSettingsDialog"));
+ }
+
+ //-------------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OAdvancedSettingsDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ //-------------------------------------------------------------------------
+ ::comphelper::StringSequence OAdvancedSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.AdvancedDatabaseSettingsDialog"));
+ return aSupported;
+ }
+
+ //-------------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OAdvancedSettingsDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //-------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OAdvancedSettingsDialog::getInfoHelper()
+ {
+ return *const_cast<OAdvancedSettingsDialog*>(this)->getArrayHelper();
+ }
+
+ //------------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OAdvancedSettingsDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+ //------------------------------------------------------------------------------
+ Dialog* OAdvancedSettingsDialog::createDialog(Window* _pParent)
+ {
+ AdvancedSettingsDialog* pDlg = new AdvancedSettingsDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection);
+ return pDlg;
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+extern "C" void SAL_CALL createRegistryInfo_OAdvancedSettingsDialog()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OAdvancedSettingsDialog > aAutoRegistration;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnControl.cxx b/dbaccess/source/ui/uno/ColumnControl.cxx
new file mode 100644
index 000000000000..beac49e1513f
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnControl.cxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ColumnControl.hxx"
+#include "ColumnPeer.hxx"
+#include "dbustrings.hrc"
+#include "apitools.hxx"
+#include <com/sun/star/awt/PosSize.hpp>
+#include "dbu_reghelper.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OColumnControl()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControl> aAutoRegistration;
+}
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+
+OColumnControl::OColumnControl(const Reference<XMultiServiceFactory>& _rxFactory)
+ :UnoControl( _rxFactory )
+{
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControl,SERVICE_CONTROLDEFAULT,"com.sun.star.awt.UnoControl","com.sun.star.sdb.ColumnDescriptorControl")
+// -----------------------------------------------------------------------------
+::rtl::OUString OColumnControl::GetComponentServiceName()
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ColumnDescriptorControl"));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OColumnControl::createPeer(const Reference< XToolkit >& /*rToolkit*/, const Reference< XWindowPeer >& rParentPeer) throw( RuntimeException )
+{
+ ::osl::ClearableMutexGuard aGuard( GetMutex() );
+ if ( !getPeer().is() )
+ {
+ mbCreatingPeer = sal_True;
+
+ Window* pParentWin = NULL;
+ if (rParentPeer.is())
+ {
+ VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
+ if (pParent)
+ pParentWin = pParent->GetWindow();
+ }
+
+ OColumnPeer* pPeer = new OColumnPeer( pParentWin, maContext.getLegacyServiceFactory() );
+ OSL_ENSURE(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
+ setPeer( pPeer );
+
+ UnoControlComponentInfos aComponentInfos(maComponentInfos);
+ Reference< XGraphics > xGraphics( mxGraphics );
+ Reference< XView > xV(getPeer(), UNO_QUERY);
+ Reference< XWindow > xW(getPeer(), UNO_QUERY);
+
+ aGuard.clear();
+
+ updateFromModel();
+
+ xV->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
+ setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
+
+ Reference<XPropertySet> xProp(getModel(), UNO_QUERY);
+ if ( xProp.is() )
+ {
+ Reference<XConnection> xCon(xProp->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+ pPeer->setConnection(xCon);
+ Reference<XPropertySet> xColumn(xProp->getPropertyValue(PROPERTY_COLUMN),UNO_QUERY);
+ pPeer->setColumn(xColumn);
+ sal_Int32 nWidth = 50;
+ xProp->getPropertyValue(PROPERTY_EDIT_WIDTH) >>= nWidth;
+ pPeer->setEditWidth(nWidth);
+ }
+
+ if (aComponentInfos.bVisible)
+ xW->setVisible(sal_True);
+
+ if (!aComponentInfos.bEnable)
+ xW->setEnable(sal_False);
+
+ if (maWindowListeners.getLength())
+ xW->addWindowListener( &maWindowListeners );
+
+ if (maFocusListeners.getLength())
+ xW->addFocusListener( &maFocusListeners );
+
+ if (maKeyListeners.getLength())
+ xW->addKeyListener( &maKeyListeners );
+
+ if (maMouseListeners.getLength())
+ xW->addMouseListener( &maMouseListeners );
+
+ if (maMouseMotionListeners.getLength())
+ xW->addMouseMotionListener( &maMouseMotionListeners );
+
+ if (maPaintListeners.getLength())
+ xW->addPaintListener( &maPaintListeners );
+
+ Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
+ xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
+ xPeerView->setGraphics( xGraphics );
+
+ mbCreatingPeer = sal_False;
+ }
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnControl.hxx b/dbaccess/source/ui/uno/ColumnControl.hxx
new file mode 100644
index 000000000000..7971357106d3
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnControl.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_COLUMNCONTROL_HXX
+#define DBAUI_COLUMNCONTROL_HXX
+
+#include <toolkit/controls/unocontrol.hxx>
+#include "apitools.hxx"
+
+namespace dbaui
+{
+ class OColumnControl : public UnoControl
+ {
+ public:
+ OColumnControl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ // UnoControl
+ virtual ::rtl::OUString GetComponentServiceName();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+ // ::com::sun::star::awt::XControl
+ virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& _rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent) throw(::com::sun::star::uno::RuntimeException);
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_COLUMNCONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnModel.cxx b/dbaccess/source/ui/uno/ColumnModel.cxx
new file mode 100644
index 000000000000..ec48a29409a0
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnModel.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ColumnModel.hxx"
+#include <com/sun/star/awt/FontRelief.hpp>
+#include <com/sun/star/awt/FontEmphasisMark.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include <cppuhelper/queryinterface.hxx>
+#include <comphelper/extract.hxx>
+#include "dbustrings.hrc"
+#include "dbu_reghelper.hxx"
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/property.hxx>
+
+extern "C" void SAL_CALL createRegistryInfo_OColumnControlModel()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OColumnControlModel> aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+
+
+DBG_NAME(OColumnControlModel)
+//------------------------------------------------------------------
+OColumnControlModel::OColumnControlModel(const Reference<XMultiServiceFactory>& _rxFactory)
+ :OPropertyContainer(m_aBHelper)
+ ,OColumnControlModel_BASE(m_aMutex)
+ ,m_xORB(_rxFactory)
+ ,m_sDefaultControl(SERVICE_CONTROLDEFAULT)
+ ,m_bEnable(sal_True)
+ ,m_nBorder(0)
+ ,m_nWidth(50)
+{
+ DBG_CTOR(OColumnControlModel,NULL);
+ registerProperties();
+}
+// -----------------------------------------------------------------------------
+OColumnControlModel::OColumnControlModel(const OColumnControlModel* _pSource,const Reference<XMultiServiceFactory>& _rxFactory)
+ :OPropertyContainer(m_aBHelper)
+ ,OColumnControlModel_BASE(m_aMutex)
+ ,m_xORB(_rxFactory)
+ ,m_sDefaultControl(_pSource->m_sDefaultControl)
+ ,m_aTabStop(_pSource->m_aTabStop)
+ ,m_bEnable(_pSource->m_bEnable)
+ ,m_nBorder(_pSource->m_nBorder)
+ ,m_nWidth(50)
+{
+ DBG_CTOR(OColumnControlModel,NULL);
+ registerProperties();
+}
+// -----------------------------------------------------------------------------
+OColumnControlModel::~OColumnControlModel()
+{
+ DBG_DTOR(OColumnControlModel,NULL);
+ if ( !OColumnControlModel_BASE::rBHelper.bDisposed && !OColumnControlModel_BASE::rBHelper.bInDispose )
+ {
+ acquire();
+ dispose();
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnControlModel::registerProperties()
+{
+ registerProperty( PROPERTY_ACTIVE_CONNECTION, PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND,
+ &m_xConnection, ::getCppuType( &m_xConnection ) );
+ Any a;
+ a <<= m_xColumn;
+ registerProperty( PROPERTY_COLUMN, PROPERTY_ID_COLUMN, PropertyAttribute::TRANSIENT | PropertyAttribute::BOUND,
+ &m_xColumn, ::getCppuType( &m_xColumn ) );
+
+ registerMayBeVoidProperty( PROPERTY_TABSTOP, PROPERTY_ID_TABSTOP, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
+ &m_aTabStop, ::getCppuType( static_cast<sal_Int16*>(NULL) ) );
+ registerProperty( PROPERTY_DEFAULTCONTROL, PROPERTY_ID_DEFAULTCONTROL, PropertyAttribute::BOUND,
+ &m_sDefaultControl, ::getCppuType( &m_sDefaultControl ) );
+ registerProperty( PROPERTY_ENABLED, PROPERTY_ID_ENABLED, PropertyAttribute::BOUND,
+ &m_bEnable, ::getCppuType( &m_bEnable ) );
+ registerProperty( PROPERTY_BORDER, PROPERTY_ID_BORDER, PropertyAttribute::BOUND,
+ &m_nBorder, ::getCppuType( &m_nBorder ) );
+ registerProperty( PROPERTY_EDIT_WIDTH, PROPERTY_ID_EDIT_WIDTH, PropertyAttribute::BOUND,
+ &m_nWidth, ::getCppuType( &m_nWidth ) );
+}
+// XCloneable
+//------------------------------------------------------------------------------
+Reference< XCloneable > SAL_CALL OColumnControlModel::createClone( ) throw (RuntimeException)
+{
+ return new OColumnControlModel( this, getORB() );
+}
+//------------------------------------------------------------------------------
+IMPLEMENT_TYPEPROVIDER2(OColumnControlModel,OColumnControlModel_BASE,comphelper::OPropertyContainer)
+IMPLEMENT_PROPERTYCONTAINER_DEFAULTS(OColumnControlModel)
+IMPLEMENT_SERVICE_INFO2_STATIC(OColumnControlModel,"com.sun.star.comp.dbu.OColumnControlModel","com.sun.star.awt.UnoControlModel","com.sun.star.sdb.ColumnDescriptorControlModel")
+IMPLEMENT_FORWARD_REFCOUNT( OColumnControlModel, OColumnControlModel_BASE )
+//------------------------------------------------------------------------------
+Any SAL_CALL OColumnControlModel::queryInterface( const Type& _rType ) throw (RuntimeException)
+{
+ return OColumnControlModel_BASE::queryInterface( _rType );
+}
+// -----------------------------------------------------------------------------
+// com::sun::star::XAggregation
+Any SAL_CALL OColumnControlModel::queryAggregation( const Type& rType ) throw(RuntimeException)
+{
+ Any aRet(OColumnControlModel_BASE::queryAggregation(rType));
+ if (!aRet.hasValue())
+ aRet = comphelper::OPropertyContainer::queryInterface(rType);
+ return aRet;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OColumnControlModel::getServiceName() throw ( RuntimeException)
+{
+ return ::rtl::OUString();
+}
+//------------------------------------------------------------------------------
+void OColumnControlModel::write(const Reference<XObjectOutputStream>& /*_rxOutStream*/) throw ( ::com::sun::star::io::IOException, RuntimeException)
+{
+ // TODO
+}
+
+//------------------------------------------------------------------------------
+void OColumnControlModel::read(const Reference<XObjectInputStream>& /*_rxInStream*/) throw ( ::com::sun::star::io::IOException, RuntimeException)
+{
+ // TODO
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnModel.hxx b/dbaccess/source/ui/uno/ColumnModel.hxx
new file mode 100644
index 000000000000..734933a35dc0
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnModel.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_COLUMNMODEL_HXX
+#define DBAUI_COLUMNMODEL_HXX
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include "apitools.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+//==================================================================
+// OColumnControlModel
+//==================================================================
+typedef ::cppu::WeakAggComponentImplHelper4 < ::com::sun::star::awt::XControlModel
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::util::XCloneable
+ , ::com::sun::star::io::XPersistObject
+ > OColumnControlModel_BASE;
+
+class OColumnControlModel;
+
+class OColumnControlModel : public ::comphelper::OMutexAndBroadcastHelper
+ ,public ::comphelper::OPropertyContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper< OColumnControlModel >
+ ,public OColumnControlModel_BASE
+{
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
+// [properties]
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xColumn;
+ ::rtl::OUString m_sDefaultControl;
+ ::com::sun::star::uno::Any m_aTabStop;
+ sal_Bool m_bEnable;
+ sal_Int16 m_nBorder;
+ sal_Int32 m_nWidth;
+// [properties]
+
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> getORB() const { return m_xORB; }
+ void registerProperties();
+protected:
+
+ virtual ~OColumnControlModel();
+ OColumnControlModel(const OColumnControlModel* _pSource
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+public:
+ OColumnControlModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+// UNO Anbindung
+ DECLARE_XINTERFACE( )
+
+// ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+// XTypeProvider
+ DECLARE_TYPEPROVIDER( );
+
+// com::sun::star::uno::XAggregation
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::io::XPersistObject
+ virtual ::rtl::OUString SAL_CALL getServiceName() throw ( ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& _rxOutStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& _rxInStream) throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+
+// OPropertyArrayUsageHelper
+ DECLARE_PROPERTYCONTAINER_DEFAULTS( );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+#endif // DBAUI_COLUMNMODEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnPeer.cxx b/dbaccess/source/ui/uno/ColumnPeer.cxx
new file mode 100644
index 000000000000..faf090402297
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnPeer.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "ColumnPeer.hxx"
+#include "ColumnControlWindow.hxx"
+#include <vcl/svapp.hxx>
+#include "dbustrings.hrc"
+#include "FieldDescriptions.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+
+OColumnPeer::OColumnPeer(Window* _pParent,const Reference<XMultiServiceFactory>& _rxFactory)
+ :m_xORB(_rxFactory)
+ ,m_pActFieldDescr(NULL)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ OColumnControlWindow* pFieldControl = new OColumnControlWindow(_pParent,m_xORB);
+ pFieldControl->SetComponentInterface(this);
+ pFieldControl->Show();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+void OColumnPeer::setEditWidth(sal_Int32 _nWidth)
+{
+ SolarMutexGuard aGuard;
+
+ OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+ if ( pFieldControl )
+ {
+ pFieldControl->setEditWidth(_nWidth);
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
+{
+ SolarMutexGuard aGuard;
+
+ OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+ if ( pFieldControl )
+ {
+ if ( m_pActFieldDescr )
+ {
+ delete m_pActFieldDescr;
+ m_pActFieldDescr = NULL;
+ }
+ if ( _xColumn.is() )
+ {
+ sal_Int32 nType = 0;
+ sal_Int32 nScale = 0;
+ sal_Int32 nPrecision = 0;
+ sal_Bool bAutoIncrement = sal_False;
+ ::rtl::OUString sTypeName;
+
+ try
+ {
+ // get the properties from the column
+ _xColumn->getPropertyValue(PROPERTY_TYPENAME) >>= sTypeName;
+ _xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
+ _xColumn->getPropertyValue(PROPERTY_SCALE) >>= nScale;
+ _xColumn->getPropertyValue(PROPERTY_PRECISION) >>= nPrecision;
+ _xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT) >>= bAutoIncrement;
+ }
+ catch(Exception)
+ {
+ }
+
+ m_pActFieldDescr = new OFieldDescription(_xColumn,sal_True);
+ // search for type
+ ::rtl::OUString sCreateParam(RTL_CONSTASCII_USTRINGPARAM("x"));
+ sal_Bool bForce;
+ TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(*pFieldControl->getTypeInfo(),nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
+ if ( !pTypeInfo.get() )
+ pTypeInfo = pFieldControl->getDefaultTyp();
+
+ m_pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False);
+ m_xColumn = _xColumn;
+ }
+ pFieldControl->DisplayData(m_pActFieldDescr);
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnPeer::setConnection(const Reference< XConnection>& _xCon)
+{
+ SolarMutexGuard aGuard;
+ OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
+ if ( pFieldControl )
+ pFieldControl->setConnection(_xCon);
+}
+//------------------------------------------------------------------------------
+void OColumnPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& Value) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if ( 0 == _rPropertyName.compareToAscii( PROPERTY_COLUMN ) )
+ {
+ Reference<XPropertySet> xProp(Value,UNO_QUERY);
+ setColumn(xProp);
+ }
+ else if ( 0 == _rPropertyName.compareToAscii( PROPERTY_ACTIVE_CONNECTION ) )
+ {
+ Reference<XConnection> xCon(Value,UNO_QUERY);
+ setConnection(xCon);
+ }
+ else
+ VCLXWindow::setProperty(_rPropertyName,Value);
+}
+// -----------------------------------------------------------------------------
+Any OColumnPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException )
+{
+ Any aProp;
+ OFieldDescControl* pFieldControl = static_cast<OFieldDescControl*>( GetWindow() );
+ if ( pFieldControl && 0 == _rPropertyName.compareToAscii( PROPERTY_COLUMN ) )
+ {
+ aProp <<= m_xColumn;
+ }
+ else if ( pFieldControl && 0 == _rPropertyName.compareToAscii( PROPERTY_ACTIVE_CONNECTION ) )
+ {
+ aProp <<= pFieldControl->getConnection();
+ }
+ else
+ aProp = VCLXWindow::getProperty(_rPropertyName);
+ return aProp;
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/ColumnPeer.hxx b/dbaccess/source/ui/uno/ColumnPeer.hxx
new file mode 100644
index 000000000000..e469e4997083
--- /dev/null
+++ b/dbaccess/source/ui/uno/ColumnPeer.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+#ifndef DBAUI_COLUMNPEER_HXX
+#define DBAUI_COLUMNPEER_HXX
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ class OFieldDescription;
+ class OColumnPeer : public VCLXWindow
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB;
+ OFieldDescription* m_pActFieldDescr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xColumn;
+ public:
+
+ OColumnPeer(Window* _pParent
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+
+ void setColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xColumn);
+ void setConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xCon);
+ void setEditWidth(sal_Int32 _nWidth);
+ // VCLXWindow
+ virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException);
+ };
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+#endif //DBAUI_COLUMNPEER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.cxx b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
new file mode 100644
index 000000000000..ef214bf1a8d0
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlg.cxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "DBTypeWizDlg.hxx"
+#include "dbwiz.hxx"
+
+using namespace dbaui;
+
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialog()
+{
+ static OMultiInstanceAutoRegistration< ODBTypeWizDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+ODBTypeWizDialog::ODBTypeWizDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+{
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL ODBTypeWizDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODBTypeWizDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new ODBTypeWizDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODBTypeWizDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString ODBTypeWizDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODBTypeWizDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL ODBTypeWizDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence ODBTypeWizDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODBTypeWizDialog::getInfoHelper()
+{
+ return *const_cast<ODBTypeWizDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODBTypeWizDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* ODBTypeWizDialog::createDialog(Window* _pParent)
+{
+ ODbTypeWizDialog* pDlg = new ODbTypeWizDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection);
+ return pDlg;
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlg.hxx b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx
new file mode 100644
index 000000000000..d34ed1b61c9b
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBTYPEWIZDLG_HXX
+#define DBAUI_DBTYPEWIZDLG_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= ODBTypeWizDialog
+//=========================================================================
+class ODBTypeWizDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< ODBTypeWizDialog >
+{
+
+protected:
+ ODBTypeWizDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBTYPEWIZDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
new file mode 100644
index 000000000000..6d5a2fb5ecd9
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.cxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include "DBTypeWizDlgSetup.hxx"
+#include "dbwizsetup.hxx"
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <vcl/msgbox.hxx>
+
+using namespace dbaui;
+namespace css = ::com::sun::star;
+
+extern "C" void SAL_CALL createRegistryInfo_ODBTypeWizDialogSetup()
+{
+ static OMultiInstanceAutoRegistration< ODBTypeWizDialogSetup > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+ODBTypeWizDialogSetup::ODBTypeWizDialogSetup(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+ ,m_bOpenDatabase(sal_True)
+ ,m_bStartTableWizard(sal_False)
+{
+ registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenDatabase")), 3, PropertyAttribute::TRANSIENT,
+ &m_bOpenDatabase, getBooleanCppuType());
+
+ registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StartTableWizard")), 4, PropertyAttribute::TRANSIENT,
+ &m_bStartTableWizard, getBooleanCppuType());
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL ODBTypeWizDialogSetup::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODBTypeWizDialogSetup::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ Reference < XInterface > xDBWizard = *(new ODBTypeWizDialogSetup(_rxFactory));
+ return xDBWizard;
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODBTypeWizDialogSetup::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString ODBTypeWizDialogSetup::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODBTypeWizDialogSetup"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL ODBTypeWizDialogSetup::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence ODBTypeWizDialogSetup::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseWizardDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL ODBTypeWizDialogSetup::getPropertySetInfo() throw(RuntimeException)
+{
+ return createPropertySetInfo( getInfoHelper() );
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODBTypeWizDialogSetup::getInfoHelper()
+{
+ return *const_cast<ODBTypeWizDialogSetup*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODBTypeWizDialogSetup::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* ODBTypeWizDialogSetup::createDialog(Window* _pParent)
+{
+ return new ODbTypeWizDialogSetup(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(), m_aInitialSelection);
+}
+// -----------------------------------------------------------------------------
+void ODBTypeWizDialogSetup::executedDialog(sal_Int16 _nExecutionResult)
+{
+ if ( _nExecutionResult == RET_OK )
+ {
+ const ODbTypeWizDialogSetup* pDialog = static_cast< ODbTypeWizDialogSetup* >( m_pDialog );
+ m_bOpenDatabase = pDialog->IsDatabaseDocumentToBeOpened();
+ m_bStartTableWizard = pDialog->IsTableWizardToBeStarted();
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx
new file mode 100644
index 000000000000..2b91f9566992
--- /dev/null
+++ b/dbaccess/source/ui/uno/DBTypeWizDlgSetup.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_DBTYPEWIZDLGSETUP_HXX
+#define DBAUI_DBTYPEWIZDLGSETUP_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= ODBTypeWizDialogSetup
+//=========================================================================
+class ODBTypeWizDialogSetup
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< ODBTypeWizDialogSetup >
+{
+ ::rtl::OUString m_sExistingDocToOpen;
+ sal_Bool m_bOpenDatabase;
+ sal_Bool m_bStartTableWizard;
+
+protected:
+ ODBTypeWizDialogSetup(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void executedDialog(sal_Int16 _nExecutionResult);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_DBTYPEWIZDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/TableFilterDlg.cxx b/dbaccess/source/ui/uno/TableFilterDlg.cxx
new file mode 100644
index 000000000000..4f0cc4d0196d
--- /dev/null
+++ b/dbaccess/source/ui/uno/TableFilterDlg.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "TableFilterDlg.hxx"
+#include "TablesSingleDlg.hxx"
+
+
+using namespace dbaui;
+
+extern "C" void SAL_CALL createRegistryInfo_OTableFilterDialog()
+{
+ static OMultiInstanceAutoRegistration< OTableFilterDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+OTableFilterDialog::OTableFilterDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+{
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL OTableFilterDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OTableFilterDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OTableFilterDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OTableFilterDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString OTableFilterDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OTableFilterDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL OTableFilterDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence OTableFilterDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.TableFilterDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL OTableFilterDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OTableFilterDialog::getInfoHelper()
+{
+ return *const_cast<OTableFilterDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OTableFilterDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* OTableFilterDialog::createDialog(Window* _pParent)
+{
+ OTableSubscriptionDialog* pDlg = new OTableSubscriptionDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection);
+ return pDlg;
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/TableFilterDlg.hxx b/dbaccess/source/ui/uno/TableFilterDlg.hxx
new file mode 100644
index 000000000000..3168c4d98751
--- /dev/null
+++ b/dbaccess/source/ui/uno/TableFilterDlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLEFILTERDLG_HXX
+#define _DBAUI_TABLEFILTERDLG_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= OTableFilterDialog
+//=========================================================================
+class OTableFilterDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< OTableFilterDialog >
+{
+
+protected:
+ OTableFilterDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_TABLEFILTERDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.cxx b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
new file mode 100644
index 000000000000..e30a06037b50
--- /dev/null
+++ b/dbaccess/source/ui/uno/UserSettingsDlg.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "UserSettingsDlg.hxx"
+#include "UserAdminDlg.hxx"
+
+
+using namespace dbaui;
+
+extern "C" void SAL_CALL createRegistryInfo_OUserSettingsDialog()
+{
+ static OMultiInstanceAutoRegistration< OUserSettingsDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+OUserSettingsDialog::OUserSettingsDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+{
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL OUserSettingsDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OUserSettingsDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OUserSettingsDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OUserSettingsDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString OUserSettingsDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OUserSettingsDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL OUserSettingsDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence OUserSettingsDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.UserAdministrationDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL OUserSettingsDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OUserSettingsDialog::getInfoHelper()
+{
+ return *const_cast<OUserSettingsDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OUserSettingsDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* OUserSettingsDialog::createDialog(Window* _pParent)
+{
+ OUserAdminDlg* pDlg = new OUserAdminDlg(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory(),m_aInitialSelection,m_xActiveConnection);
+ return pDlg;
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/UserSettingsDlg.hxx b/dbaccess/source/ui/uno/UserSettingsDlg.hxx
new file mode 100644
index 000000000000..e46d1505ac6c
--- /dev/null
+++ b/dbaccess/source/ui/uno/UserSettingsDlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_USERSETTINGSDLG_HXX
+#define _DBAUI_USERSETTINGSDLG_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= OUserSettingsDialog
+//=========================================================================
+class OUserSettingsDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< OUserSettingsDialog >
+{
+
+protected:
+ OUserSettingsDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_USERSETTINGSDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/admindlg.cxx b/dbaccess/source/ui/uno/admindlg.cxx
new file mode 100644
index 000000000000..fd751e807c40
--- /dev/null
+++ b/dbaccess/source/ui/uno/admindlg.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbu_reghelper.hxx"
+#include "admindlg.hxx"
+#include "dbadmin.hxx"
+
+
+using namespace dbaui;
+
+extern "C" void SAL_CALL createRegistryInfo_ODataSourcePropertyDialog()
+{
+ static OMultiInstanceAutoRegistration< ODataSourcePropertyDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+ODataSourcePropertyDialog::ODataSourcePropertyDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialog(_rxORB)
+{
+}
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL ODataSourcePropertyDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODataSourcePropertyDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new ODataSourcePropertyDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODataSourcePropertyDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString ODataSourcePropertyDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.ODatasourceAdministrationDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL ODataSourcePropertyDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence ODataSourcePropertyDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatasourceAdministrationDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL ODataSourcePropertyDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& ODataSourcePropertyDialog::getInfoHelper()
+{
+ return *const_cast<ODataSourcePropertyDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODataSourcePropertyDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+//------------------------------------------------------------------------------
+Dialog* ODataSourcePropertyDialog::createDialog(Window* _pParent)
+{
+
+ ODbAdminDialog* pDialog = new ODbAdminDialog(_pParent, m_pDatasourceItems, m_aContext.getLegacyServiceFactory());
+
+ // the initial selection
+ if ( m_aInitialSelection.hasValue() )
+ pDialog->selectDataSource(m_aInitialSelection);
+
+ return pDialog;
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/admindlg.hxx b/dbaccess/source/ui/uno/admindlg.hxx
new file mode 100644
index 000000000000..3b0fc5d8c367
--- /dev/null
+++ b/dbaccess/source/ui/uno/admindlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_ADMINDLG_HXX
+#define _DBAUI_ADMINDLG_HXX
+
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+//=========================================================================
+//= ODataSourcePropertyDialog
+//=========================================================================
+class ODataSourcePropertyDialog
+ :public ODatabaseAdministrationDialog
+ ,public ::comphelper::OPropertyArrayUsageHelper< ODataSourcePropertyDialog >
+{
+
+protected:
+ ODataSourcePropertyDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+protected:
+// OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+};
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_ADMINDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx
new file mode 100644
index 000000000000..647251deed6b
--- /dev/null
+++ b/dbaccess/source/ui/uno/composerdialogs.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "composerdialogs.hxx"
+
+/** === begin UNO includes === **/
+#include "dbu_reghelper.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+/** === end UNO includes === **/
+#include "dbustrings.hrc"
+#include "queryfilter.hxx"
+#include "queryorder.hxx"
+#include <connectivity/dbtools.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+
+extern "C" void SAL_CALL createRegistryInfo_ComposerDialogs()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetOrderDialog > aOrderDialogRegistration;
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::RowsetFilterDialog > aFilterDialogRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+#define PROPERTY_ID_QUERYCOMPOSER 100
+#define PROPERTY_ID_ROWSET 101
+
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_QUERYCOMPOSER, "QueryComposer" );
+ IMPLEMENT_CONSTASCII_USTRING( PROPERTY_ROWSET, "RowSet" );
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+
+ //=====================================================================
+ //= ComposerDialog
+ //=====================================================================
+ DBG_NAME(ComposerDialog)
+ //---------------------------------------------------------------------
+ ComposerDialog::ComposerDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ComposerDialog_BASE( _rxORB )
+ {
+ DBG_CTOR(ComposerDialog,NULL);
+
+ registerProperty( PROPERTY_QUERYCOMPOSER, PROPERTY_ID_QUERYCOMPOSER, PropertyAttribute::TRANSIENT,
+ &m_xComposer, ::getCppuType( &m_xComposer ) );
+ registerProperty( PROPERTY_ROWSET, PROPERTY_ID_ROWSET, PropertyAttribute::TRANSIENT,
+ &m_xRowSet, ::getCppuType( &m_xRowSet ) );
+ }
+
+ //---------------------------------------------------------------------
+ ComposerDialog::~ComposerDialog()
+ {
+
+ DBG_DTOR(ComposerDialog,NULL);
+ }
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_IMPLEMENTATION_ID( ComposerDialog )
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ComposerDialog )
+
+ //---------------------------------------------------------------------
+ Dialog* ComposerDialog::createDialog(Window* _pParent)
+ {
+ // obtain all the objects needed for the dialog
+ Reference< XConnection > xConnection;
+ Reference< XNameAccess > xColumns;
+ try
+ {
+ // the connection the row set is working with
+ if ( !::dbtools::isEmbeddedInDatabase( m_xRowSet, xConnection ) )
+ {
+ Reference< XPropertySet > xRowsetProps( m_xRowSet, UNO_QUERY );
+ if ( xRowsetProps.is() )
+ xRowsetProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
+ }
+
+ // fallback: if there is a connection and thus a row set, but no composer, create one
+ if ( xConnection.is() && !m_xComposer.is() )
+ m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext.getLegacyServiceFactory() );
+
+ // the columns of the row set
+ Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY );
+ if ( xSuppColumns.is() )
+ xColumns = xSuppColumns->getColumns();
+
+ if ( !xColumns.is() || !xColumns->hasElements() )
+ { // perhaps the composer can supply us with columns? This is necessary for cases
+ // where the dialog is invoked for a rowset which is not yet loaded
+ // #i22878#
+ xSuppColumns = xSuppColumns.query( m_xComposer );
+ if ( xSuppColumns.is() )
+ xColumns = xSuppColumns->getColumns();
+ }
+
+ OSL_ENSURE( xColumns.is() && xColumns->hasElements(), "ComposerDialog::createDialog: not much fun without any columns!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !xConnection.is() || !xColumns.is() || !m_xComposer.is() )
+ // can't create the dialog if I have improper settings
+ return NULL;
+
+ return createComposerDialog( _pParent, xConnection, xColumns );
+ }
+
+ //=====================================================================
+ //= RowsetFilterDialog
+ //=====================================================================
+ //---------------------------------------------------------------------
+ RowsetFilterDialog::RowsetFilterDialog( const Reference< XMultiServiceFactory >& _rxORB )
+ :ComposerDialog( _rxORB )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC( RowsetFilterDialog, "com.sun.star.uno.comp.sdb.RowsetFilterDialog", "com.sun.star.sdb.FilterDialog" )
+
+ //---------------------------------------------------------------------
+ Dialog* RowsetFilterDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
+ {
+ return new DlgFilterCrit( _pParent, m_aContext.getLegacyServiceFactory(), _rxConnection, m_xComposer, _rxColumns );
+ }
+
+ //---------------------------------------------------------------------
+ void RowsetFilterDialog::executedDialog( sal_Int16 _nExecutionResult )
+ {
+ ComposerDialog::executedDialog( _nExecutionResult );
+
+ if ( _nExecutionResult && m_pDialog )
+ static_cast< DlgFilterCrit* >( m_pDialog )->BuildWherePart();
+ }
+
+ //=====================================================================
+ //= RowsetOrderDialog
+ //=====================================================================
+ //---------------------------------------------------------------------
+ RowsetOrderDialog::RowsetOrderDialog( const Reference< XMultiServiceFactory >& _rxORB )
+ :ComposerDialog( _rxORB )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC( RowsetOrderDialog, "com.sun.star.uno.comp.sdb.RowsetOrderDialog", "com.sun.star.sdb.OrderDialog" )
+
+ //---------------------------------------------------------------------
+ Dialog* RowsetOrderDialog::createComposerDialog( Window* _pParent, const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxColumns )
+ {
+ return new DlgOrderCrit( _pParent, _rxConnection, m_xComposer, _rxColumns );
+ }
+
+ //---------------------------------------------------------------------
+ void RowsetOrderDialog::executedDialog( sal_Int16 _nExecutionResult )
+ {
+ ComposerDialog::executedDialog( _nExecutionResult );
+
+ if ( !m_pDialog )
+ return;
+
+ if ( _nExecutionResult )
+ static_cast< DlgOrderCrit* >( m_pDialog )->BuildOrderPart();
+ else if ( m_xComposer.is() )
+ m_xComposer->setOrder( static_cast< DlgOrderCrit* >( m_pDialog )->GetOrignalOrder() );
+ }
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/composerdialogs.hxx b/dbaccess/source/ui/uno/composerdialogs.hxx
new file mode 100644
index 000000000000..acc82ae93cf2
--- /dev/null
+++ b/dbaccess/source/ui/uno/composerdialogs.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX
+#define DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+/** === end UNO includes === **/
+
+#include <svtools/genericunodialog.hxx>
+#include "moduledbu.hxx"
+#include "apitools.hxx"
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=====================================================================
+ //= ComposerDialog
+ //=====================================================================
+ class ComposerDialog;
+ typedef ::svt::OGenericUnoDialog ComposerDialog_BASE;
+ typedef ::comphelper::OPropertyArrayUsageHelper< ComposerDialog > ComposerDialog_PBASE;
+
+ class ComposerDialog
+ :public ComposerDialog_BASE
+ ,public ComposerDialog_PBASE
+ {
+ OModuleClient m_aModuleClient;
+ protected:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >
+ m_xComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
+ m_xRowSet;
+ // </properties>
+
+ protected:
+ ComposerDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ ~ComposerDialog();
+
+ public:
+ DECLARE_IMPLEMENTATION_ID( );
+
+ DECLARE_PROPERTYCONTAINER_DEFAULTS( );
+
+ protected:
+ // own overridables
+ virtual Dialog* createComposerDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns
+ ) = 0;
+
+ private:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ };
+
+ //=====================================================================
+ //= RowsetFilterDialog
+ //=====================================================================
+ class RowsetFilterDialog : public ComposerDialog
+ {
+ public:
+ RowsetFilterDialog(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ protected:
+ // own overridables
+ virtual Dialog* createComposerDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns
+ );
+
+ // OGenericUnoDialog overridables
+ virtual void executedDialog( sal_Int16 _nExecutionResult );
+ };
+
+ //=====================================================================
+ //= RowsetOrderDialog
+ //=====================================================================
+ class RowsetOrderDialog : public ComposerDialog
+ {
+ public:
+ RowsetOrderDialog(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ protected:
+ // own overridables
+ virtual Dialog* createComposerDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxColumns
+ );
+
+ // OGenericUnoDialog overridables
+ virtual void executedDialog( sal_Int16 _nExecutionResult );
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBACCESS_SOURCE_UI_UNO_COMPOSERDIALOGS_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
new file mode 100644
index 000000000000..3fb4b032e3bc
--- /dev/null
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -0,0 +1,1643 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dbu_reghelper.hxx"
+#include "dbu_resource.hrc"
+#include "dbu_uno.hrc"
+#include "dbustrings.hrc"
+#include "moduledbu.hxx"
+#include "sqlmessage.hxx"
+#include "WCopyTable.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdb/application/XCopyTableWizard.hpp>
+#include <com/sun/star/sdb/application/CopyTableContinuation.hpp>
+#include <com/sun/star/sdb/application/CopyTableOperation.hpp>
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/NotInitializedException.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XBlob.hpp>
+#include <com/sun/star/sdbc/XClob.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/string.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/logfile.hxx>
+#include <svtools/genericunodialog.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/sharedunocomponent.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::sdb::application::XCopyTableWizard;
+ using ::com::sun::star::sdb::application::XCopyTableListener;
+ using ::com::sun::star::sdb::application::CopyTableRowEvent;
+ using ::com::sun::star::beans::Optional;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::lang::NotInitializedException;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XDataSource;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::task::XInteractionHandler;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::sdb::XDocumentDataSource;
+ using ::com::sun::star::sdb::XCompletedConnection;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::sdbcx::XTablesSupplier;
+ using ::com::sun::star::sdb::XQueriesSupplier;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::sdbc::XPreparedStatement;
+ using ::com::sun::star::sdb::XSingleSelectQueryComposer;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdbcx::XColumnsSupplier;
+ using ::com::sun::star::sdbc::XParameters;
+ using ::com::sun::star::sdbc::XResultSet;
+ using ::com::sun::star::sdbc::XRow;
+ using ::com::sun::star::sdbc::XBlob;
+ using ::com::sun::star::sdbc::XClob;
+ using ::com::sun::star::sdbcx::XRowLocate;
+ using ::com::sun::star::sdbc::XResultSetMetaDataSupplier;
+ using ::com::sun::star::sdbc::XResultSetMetaData;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdb::SQLContext;
+ using ::com::sun::star::sdbc::XDriverManager;
+ using ::com::sun::star::beans::PropertyValue;
+ /** === end UNO using === **/
+ namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
+ namespace CopyTableContinuation = ::com::sun::star::sdb::application::CopyTableContinuation;
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+
+ typedef ::utl::SharedUNOComponent< XConnection > SharedConnection;
+ typedef Reference< XInteractionHandler > InteractionHandler;
+
+ //=========================================================================
+ //= CopyTableWizard
+ //=========================================================================
+ typedef ::svt::OGenericUnoDialog CopyTableWizard_DialogBase;
+ typedef ::cppu::ImplInheritanceHelper1 < CopyTableWizard_DialogBase
+ , XCopyTableWizard
+ > CopyTableWizard_Base;
+ class CopyTableWizard
+ :public CopyTableWizard_Base
+ ,public ::comphelper::OPropertyArrayUsageHelper< CopyTableWizard >
+ {
+ public:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // XServiceInfo - static methods
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( RuntimeException );
+ static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& );
+
+ // XCopyTableWizard
+ virtual ::sal_Int16 SAL_CALL getOperation() throw (RuntimeException);
+ virtual void SAL_CALL setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDestinationTableName() throw (RuntimeException);
+ virtual void SAL_CALL setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException);
+ virtual Optional< ::rtl::OUString > SAL_CALL getCreatePrimaryKey() throw (RuntimeException);
+ virtual void SAL_CALL setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException);
+ virtual sal_Bool SAL_CALL getUseHeaderLineAsColumnNames() throw (RuntimeException);
+ virtual void SAL_CALL setUseHeaderLineAsColumnNames( sal_Bool _bUseHeaderLineAsColumnNames ) throw (RuntimeException);
+ virtual void SAL_CALL addCopyTableListener( const Reference< XCopyTableListener >& Listener ) throw (RuntimeException);
+ virtual void SAL_CALL removeCopyTableListener( const Reference< XCopyTableListener >& Listener ) throw (RuntimeException);
+
+ // XCopyTableWizard::XExecutableDialog
+ virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) throw (RuntimeException);
+ virtual ::sal_Int16 SAL_CALL execute( ) throw (RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
+
+ // XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ public:
+ ::osl::Mutex& getMutex() { return m_aMutex; }
+ bool isInitialized() const { return m_xSourceConnection.is() && m_pSourceObject.get() && m_xDestConnection.is(); }
+
+ protected:
+ CopyTableWizard( const Reference< XMultiServiceFactory >& _rxORB );
+ ~CopyTableWizard();
+
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog( Window* _pParent );
+ virtual void executedDialog( sal_Int16 _nExecutionResult );
+
+ private:
+ /// ensures our current attribute values are reflected in the dialog
+ void impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const;
+
+ /// ensures the current dialog settings are reflected in our attributes
+ void impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog );
+
+ /** returns our typed dialog
+
+ @throws ::com::sun::star::uno::RuntimeException
+ if we don't have a dialog at the moment the method is called
+ */
+ OCopyTableWizard&
+ impl_getDialog_throw();
+
+ /** returns our typed dialog
+
+ @throws ::com::sun::star::uno::RuntimeException
+ if we don't have a dialog at the moment the method is called
+ */
+ const OCopyTableWizard&
+ impl_getDialog_throw() const;
+
+ /** ensures the given argument sequence contains a valid data access descriptor at the given position
+ @param _rAllArgs
+ the arguments as passed to ->initialize
+ @param _nArgPos
+ the position within ->_rAllArgs which contains the data access descriptor
+ @param _out_rxConnection
+ will, upon successful return, contain the connection for the data source
+ @param _out_rxDocInteractionHandler
+ will, upon successful return, contain the interaction handler which could
+ be deduced from database document described by the descriptor, if any.
+ (It is possible that the descriptor does not allow to deduce a database document,
+ in which case <code>_out_rxDocInteractionHandler</code> will be <NULL/>.)
+ @return the data access descriptor
+ */
+ Reference< XPropertySet >
+ impl_ensureDataAccessDescriptor_throw(
+ const Sequence< Any >& _rAllArgs,
+ const sal_Int16 _nArgPos,
+ SharedConnection& _out_rxConnection,
+ InteractionHandler& _out_rxDocInteractionHandler
+ ) const;
+
+ /** extracts the source object (table or query) described by the given descriptor,
+ relative to m_xSourceConnection
+ */
+ ::std::auto_ptr< ICopyTableSourceObject >
+ impl_extractSourceObject_throw(
+ const Reference< XPropertySet >& _rxDescriptor,
+ sal_Int32& _out_rCommandType
+ ) const;
+
+ /** extracts the result set to copy records from, and the selection-related aspects, if any.
+
+ Effectively, this method extracts m_xSourceResultSet, m_aSourceSelection, and m_bSourceSelectionBookmarks.
+
+ If an inconsistent/insufficent sub set of those properties is present in the descriptor, and exception
+ is thrown.
+ */
+ void impl_extractSourceResultSet_throw(
+ const Reference< XPropertySet >& i_rDescriptor
+ );
+
+ /** checks whether the given copy source descriptor contains settings which are not
+ supported (yet)
+
+ Throws an IllegalArgumentException if the descriptor contains a valid setting, which is
+ not yet supported.
+ */
+ void impl_checkForUnsupportedSettings_throw(
+ const Reference< XPropertySet >& _rxSourceDescriptor ) const;
+
+ /** obtaines the connection described by the given data access descriptor
+
+ If needed and possible, the method will ask the user, using the interaction
+ handler associated with the database described by the descriptor.
+
+ All errors are handled with the InteractionHandler associated with the data source,
+ if there is one. Else, they will be silenced (but asserted in non-product builds).
+
+ @param _rxDataSourceDescriptor
+ the data access descriptor describing the data source whose connection
+ should be obtained. Must not be <NULL/>.
+ @param _out_rxDocInteractionHandler
+ the interaction handler which could be deduced from the descriptor
+
+ @throws RuntimeException
+ if anything goes seriously wrong.
+ */
+ SharedConnection
+ impl_extractConnection_throw(
+ const Reference< XPropertySet >& _rxDataSourceDescriptor,
+ InteractionHandler& _out_rxDocInteractionHandler
+ ) const;
+
+ /** actually copies the table
+
+ This method is called after the dialog has been successfully executed.
+ */
+ void impl_doCopy_nothrow();
+
+ /** creates the INSERT INTO statement
+ @param _xTable The destination table.
+ */
+ ::rtl::OUString impl_getServerSideCopyStatement_throw( const Reference< XPropertySet >& _xTable );
+
+ /** creates the statement which, when executed, will produce the source data to copy
+
+ If the source object refers to a query which contains parameters, those parameters
+ are filled in, using an interaction handler.
+ */
+ ::utl::SharedUNOComponent< XPreparedStatement >
+ impl_createSourceStatement_throw() const;
+
+ /** copies the data rows from the given source result set to the given destination table
+ */
+ void impl_copyRows_throw(
+ const Reference< XResultSet >& _rxSourceResultSet,
+ const Reference< XPropertySet >& _rxDestTable
+ );
+
+ /** processes an error which occurred during copying
+
+ First, all listeners are ask. If a listener tells to cancel or continue copying, this is reported to the
+ method's caller. If a listener tells to ask the user, this is done, and the user's decision is
+ reported to the method's caller.
+
+ @return
+ <TRUE/> if and only if copying should be continued.
+ */
+ bool impl_processCopyError_nothrow(
+ const CopyTableRowEvent& _rEvent );
+
+private:
+ ::comphelper::ComponentContext m_aContext;
+
+ // attributes
+ sal_Int16 m_nOperation;
+ ::rtl::OUString m_sDestinationTable;
+ Optional< ::rtl::OUString > m_aPrimaryKeyName;
+ sal_Bool m_bUseHeaderLineAsColumnNames;
+
+ // source
+ SharedConnection m_xSourceConnection;
+ sal_Int32 m_nCommandType;
+ ::std::auto_ptr< ICopyTableSourceObject >
+ m_pSourceObject;
+ Reference< XResultSet > m_xSourceResultSet;
+ Sequence< Any > m_aSourceSelection;
+ sal_Bool m_bSourceSelectionBookmarks;
+
+ // destination
+ SharedConnection m_xDestConnection;
+
+ // other
+ InteractionHandler m_xInteractionHandler;
+ ::cppu::OInterfaceContainerHelper
+ m_aCopyTableListeners;
+ sal_Int16 m_nOverrideExecutionResult;
+ };
+
+//=========================================================================
+//= MethodGuard
+//=========================================================================
+class CopyTableAccessGuard
+{
+public:
+ CopyTableAccessGuard( CopyTableWizard& _rWizard )
+ :m_rWizard( _rWizard )
+ {
+ m_rWizard.getMutex().acquire();
+ if ( !m_rWizard.isInitialized() )
+ throw NotInitializedException();
+ }
+
+ ~CopyTableAccessGuard()
+ {
+ m_rWizard.getMutex().release();
+ }
+
+private:
+ CopyTableWizard& m_rWizard;
+};
+
+//=========================================================================
+//-------------------------------------------------------------------------
+CopyTableWizard::CopyTableWizard( const Reference< XMultiServiceFactory >& _rxORB )
+ :CopyTableWizard_Base( _rxORB )
+ ,m_aContext( _rxORB )
+ ,m_nOperation( CopyTableOperation::CopyDefinitionAndData )
+ ,m_sDestinationTable()
+ ,m_aPrimaryKeyName( sal_False, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) ))
+ ,m_bUseHeaderLineAsColumnNames( sal_True )
+ ,m_xSourceConnection()
+ ,m_nCommandType( CommandType::COMMAND )
+ ,m_pSourceObject()
+ ,m_xSourceResultSet()
+ ,m_aSourceSelection()
+ ,m_bSourceSelectionBookmarks( sal_True )
+ ,m_xDestConnection()
+ ,m_aCopyTableListeners( m_aMutex )
+ ,m_nOverrideExecutionResult( -1 )
+{
+}
+
+//-------------------------------------------------------------------------
+CopyTableWizard::~CopyTableWizard()
+{
+ acquire();
+
+ // protect some members whose dtor might potentially throw
+ try { m_xSourceConnection.clear(); }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ try { m_xDestConnection.clear(); }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ // TODO: shouldn't we have explicit disposal support? If a listener is registered
+ // at our instance, and perhaps holds this our instance by a hard ref, then we'll never
+ // be destroyed.
+ // However, adding XComponent support to the GenericUNODialog probably requires
+ // some thinking - would it break existing clients which do not call a dispose, then?
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > CopyTableWizard::Create( const Reference< XMultiServiceFactory >& _rxFactory )
+{
+ return *( new CopyTableWizard( _rxFactory ) );
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL CopyTableWizard::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString CopyTableWizard::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.dbu.CopyTableWizard" ) );
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL CopyTableWizard::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence CopyTableWizard::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.application.CopyTableWizard" ) );
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL CopyTableWizard::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//--------------------------------------------------------------------
+::sal_Int16 SAL_CALL CopyTableWizard::getOperation() throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ return m_nOperation;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::setOperation( ::sal_Int16 _operation ) throw (IllegalArgumentException, RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+
+ if ( ( _operation != CopyTableOperation::CopyDefinitionAndData )
+ && ( _operation != CopyTableOperation::CopyDefinitionOnly )
+ && ( _operation != CopyTableOperation::CreateAsView )
+ && ( _operation != CopyTableOperation::AppendData )
+ )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ if ( ( _operation == CopyTableOperation::CreateAsView )
+ && !OCopyTableWizard::supportsViews( m_xDestConnection )
+ )
+ throw IllegalArgumentException(
+ String( ModuleRes( STR_CTW_NO_VIEWS_SUPPORT ) ),
+ *this,
+ 1
+ );
+
+ m_nOperation = _operation;
+}
+
+//--------------------------------------------------------------------
+::rtl::OUString SAL_CALL CopyTableWizard::getDestinationTableName() throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ return m_sDestinationTable;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::setDestinationTableName( const ::rtl::OUString& _destinationTableName ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ m_sDestinationTable = _destinationTableName;
+}
+
+//--------------------------------------------------------------------
+Optional< ::rtl::OUString > SAL_CALL CopyTableWizard::getCreatePrimaryKey() throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ return m_aPrimaryKeyName;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::setCreatePrimaryKey( const Optional< ::rtl::OUString >& _newPrimaryKey ) throw (IllegalArgumentException, RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+
+ if ( _newPrimaryKey.IsPresent && !OCopyTableWizard::supportsPrimaryKey( m_xDestConnection ) )
+ throw IllegalArgumentException(
+ String( ModuleRes( STR_CTW_NO_PRIMARY_KEY_SUPPORT ) ),
+ *this,
+ 1
+ );
+
+ m_aPrimaryKeyName = _newPrimaryKey;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL CopyTableWizard::getUseHeaderLineAsColumnNames() throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ return m_bUseHeaderLineAsColumnNames;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::setUseHeaderLineAsColumnNames( sal_Bool _bUseHeaderLineAsColumnNames ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ m_bUseHeaderLineAsColumnNames = _bUseHeaderLineAsColumnNames;
+}
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::addCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ if ( _rxListener.is() )
+ m_aCopyTableListeners.addInterface( _rxListener );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::removeCopyTableListener( const Reference< XCopyTableListener >& _rxListener ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ if ( _rxListener.is() )
+ m_aCopyTableListeners.removeInterface( _rxListener );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::setTitle( const ::rtl::OUString& _rTitle ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+ CopyTableWizard_DialogBase::setTitle( _rTitle );
+}
+
+//--------------------------------------------------------------------
+::sal_Int16 SAL_CALL CopyTableWizard::execute( ) throw (RuntimeException)
+{
+ CopyTableAccessGuard aGuard( *this );
+
+ m_nOverrideExecutionResult = -1;
+ sal_Int16 nExecutionResult = CopyTableWizard_DialogBase::execute();
+ if ( m_nOverrideExecutionResult )
+ nExecutionResult = m_nOverrideExecutionResult;
+
+ return nExecutionResult;
+}
+
+//-------------------------------------------------------------------------
+OCopyTableWizard& CopyTableWizard::impl_getDialog_throw()
+{
+ OCopyTableWizard* pWizard = dynamic_cast< OCopyTableWizard* >( m_pDialog );
+ if ( !pWizard )
+ throw DisposedException( ::rtl::OUString(), *this );
+ return *pWizard;
+}
+
+//-------------------------------------------------------------------------
+const OCopyTableWizard& CopyTableWizard::impl_getDialog_throw() const
+{
+ const OCopyTableWizard* pWizard = dynamic_cast< const OCopyTableWizard* >( m_pDialog );
+ if ( !pWizard )
+ throw DisposedException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
+ return *pWizard;
+}
+
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_attributesToDialog_nothrow( OCopyTableWizard& _rDialog ) const
+{
+ // primary key column
+ _rDialog.setCreatePrimaryKey( m_aPrimaryKeyName.IsPresent, m_aPrimaryKeyName.Value );
+ _rDialog.setUseHeaderLine(m_bUseHeaderLineAsColumnNames);
+
+ // everything else was passed at construction time already
+}
+
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_dialogToAttributes_nothrow( const OCopyTableWizard& _rDialog )
+{
+ m_aPrimaryKeyName.IsPresent = _rDialog.shouldCreatePrimaryKey();
+ if ( m_aPrimaryKeyName.IsPresent )
+ m_aPrimaryKeyName.Value = _rDialog.getPrimaryKeyName();
+ else
+ m_aPrimaryKeyName.Value = ::rtl::OUString();
+
+ m_sDestinationTable = _rDialog.getName();
+
+ m_nOperation = _rDialog.getOperation();
+ m_bUseHeaderLineAsColumnNames = _rDialog.UseHeaderLine();
+}
+
+//-------------------------------------------------------------------------
+namespace
+{
+ //.....................................................................
+ /** tries to obtain the InteractionHandler associated with a given data source
+
+ If the data source is a sdb-level data source, it will have a DatabaseDocument associated
+ with it. This doocument may have an InteractionHandler used while loading it.
+
+ @throws RuntimeException
+ if it occures during invoking any of the data source's methods, or if any of the involved
+ components violates its contract by not providing the required interfaces
+ */
+ InteractionHandler lcl_getInteractionHandler_throw( const Reference< XDataSource >& _rxDataSource, const InteractionHandler& _rFallback )
+ {
+ InteractionHandler xHandler( _rFallback );
+
+ // try to obtain the document model
+ Reference< XModel > xDocumentModel;
+ Reference< XDocumentDataSource > xDocDataSource( _rxDataSource, UNO_QUERY );
+ if ( xDocDataSource.is() )
+ xDocumentModel.set( xDocDataSource->getDatabaseDocument(), UNO_QUERY_THROW );
+
+ // see whether the document model can provide a handler
+ if ( xDocumentModel.is() )
+ {
+ ::comphelper::NamedValueCollection aModelArgs( xDocumentModel->getArgs() );
+ xHandler = aModelArgs.getOrDefault( "InteractionHandler", xHandler );
+ }
+
+ return xHandler;
+ }
+ //.....................................................................
+ /** tries to obtain the InteractionHandler associated with a given connection
+
+ If the connection belongs to a sdb-level data source, then this data source
+ is examined for an interaction handler. Else, <NULL/> is returned.
+
+ @throws RuntimeException
+ if it occures during invoking any of the data source's methods, or if any of the involved
+ components violates its contract by not providing the required interfaces
+ */
+ InteractionHandler lcl_getInteractionHandler_throw( const Reference< XConnection >& _rxConnection, const InteractionHandler& _rFallback )
+ {
+ // try whether there is a data source which the connection belongs to
+ Reference< XDataSource > xDataSource;
+ Reference< XChild > xAsChild( _rxConnection, UNO_QUERY );
+ if ( xAsChild.is() )
+ xDataSource = xDataSource.query( xAsChild->getParent() );
+
+ if ( xDataSource.is() )
+ return lcl_getInteractionHandler_throw( xDataSource, _rFallback );
+
+ return _rFallback;
+ }
+}
+
+//-------------------------------------------------------------------------
+Reference< XPropertySet > CopyTableWizard::impl_ensureDataAccessDescriptor_throw(
+ const Sequence< Any >& _rAllArgs, const sal_Int16 _nArgPos, SharedConnection& _out_rxConnection,
+ InteractionHandler& _out_rxDocInteractionHandler ) const
+{
+ Reference< XPropertySet > xDescriptor;
+ _rAllArgs[ _nArgPos ] >>= xDescriptor;
+
+ // the descriptor must be non-NULL, of course
+ bool bIsValid = xDescriptor.is();
+
+ // it must support the proper service
+ if ( bIsValid )
+ {
+ Reference< XServiceInfo > xSI( xDescriptor, UNO_QUERY );
+ bIsValid = ( xSI.is()
+ && xSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.DataAccessDescriptor" ) ) )
+ );
+ }
+
+ // it must be able to provide a connection
+ if ( bIsValid )
+ {
+ _out_rxConnection = impl_extractConnection_throw( xDescriptor, _out_rxDocInteractionHandler );
+ bIsValid = _out_rxConnection.is();
+ }
+
+ if ( !bIsValid )
+ {
+ throw IllegalArgumentException(
+ String( ModuleRes( STR_CTW_INVALID_DATA_ACCESS_DESCRIPTOR ) ),
+ *const_cast< CopyTableWizard* >( this ),
+ _nArgPos + 1
+ );
+ }
+
+ return xDescriptor;
+}
+
+//-------------------------------------------------------------------------
+namespace
+{
+ bool lcl_hasNonEmptyStringValue_throw( const Reference< XPropertySet >& _rxDescriptor,
+ const Reference< XPropertySetInfo > _rxPSI, const ::rtl::OUString& _rPropertyName )
+ {
+ ::rtl::OUString sValue;
+ if ( _rxPSI->hasPropertyByName( _rPropertyName ) )
+ {
+ OSL_VERIFY( _rxDescriptor->getPropertyValue( _rPropertyName ) >>= sValue );
+ }
+ return sValue.getLength() > 0;
+ }
+}
+
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_checkForUnsupportedSettings_throw( const Reference< XPropertySet >& _rxSourceDescriptor ) const
+{
+ OSL_PRECOND( _rxSourceDescriptor.is(), "CopyTableWizard::impl_checkForUnsupportedSettings_throw: illegal argument!" );
+ Reference< XPropertySetInfo > xPSI( _rxSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+ ::rtl::OUString sUnsupportedSetting;
+
+ const ::rtl::OUString aSettings[] = {
+ PROPERTY_FILTER, PROPERTY_ORDER, PROPERTY_HAVING_CLAUSE, PROPERTY_GROUP_BY
+ };
+ for ( size_t i=0; i < SAL_N_ELEMENTS( aSettings ); ++i )
+ {
+ if ( lcl_hasNonEmptyStringValue_throw( _rxSourceDescriptor, xPSI, aSettings[i] ) )
+ {
+ sUnsupportedSetting = aSettings[i];
+ break;
+ }
+ }
+
+ if ( sUnsupportedSetting.getLength() != 0 )
+ {
+ ::rtl::OUString sMessage( String(ModuleRes( STR_CTW_ERROR_UNSUPPORTED_SETTING )) );
+ ::comphelper::string::searchAndReplaceAsciiI( sMessage, "$name$", sUnsupportedSetting );
+ throw IllegalArgumentException(
+ sMessage,
+ *const_cast< CopyTableWizard* >( this ),
+ 1
+ );
+ }
+
+}
+
+//-------------------------------------------------------------------------
+::std::auto_ptr< ICopyTableSourceObject > CopyTableWizard::impl_extractSourceObject_throw( const Reference< XPropertySet >& _rxDescriptor, sal_Int32& _out_rCommandType ) const
+{
+ OSL_PRECOND( _rxDescriptor.is() && m_xSourceConnection.is(), "CopyTableWizard::impl_extractSourceObject_throw: illegal arguments!" );
+
+ Reference< XPropertySetInfo > xPSI( _rxDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+ if ( !xPSI->hasPropertyByName( PROPERTY_COMMAND )
+ || !xPSI->hasPropertyByName( PROPERTY_COMMAND_TYPE )
+ )
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expecting a table or query specification." ) ),
+ // TODO: resource
+ *const_cast< CopyTableWizard* >( this ),
+ 1
+ );
+
+ ::rtl::OUString sCommand;
+ _out_rCommandType = CommandType::COMMAND;
+ OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
+ OSL_VERIFY( _rxDescriptor->getPropertyValue( PROPERTY_COMMAND_TYPE ) >>= _out_rCommandType );
+
+ ::std::auto_ptr< ICopyTableSourceObject > pSourceObject;
+ Reference< XNameAccess > xContainer;
+ switch ( _out_rCommandType )
+ {
+ case CommandType::TABLE:
+ {
+ Reference< XTablesSupplier > xSuppTables( m_xSourceConnection.getTyped(), UNO_QUERY );
+ if ( xSuppTables.is() )
+ xContainer.set( xSuppTables->getTables(), UNO_SET_THROW );
+ }
+ break;
+ case CommandType::QUERY:
+ {
+ Reference< XQueriesSupplier > xSuppQueries( m_xSourceConnection.getTyped(), UNO_QUERY );
+ if ( xSuppQueries.is() )
+ xContainer.set( xSuppQueries->getQueries(), UNO_SET_THROW );
+ }
+ break;
+ default:
+ throw IllegalArgumentException(
+ String( ModuleRes( STR_CTW_ONLY_TABLES_AND_QUERIES_SUPPORT ) ),
+ *const_cast< CopyTableWizard* >( this ),
+ 1
+ );
+ }
+
+ if ( xContainer.is() )
+ {
+ pSourceObject.reset( new ObjectCopySource( m_xSourceConnection,
+ Reference< XPropertySet >( xContainer->getByName( sCommand ), UNO_QUERY_THROW ) ) );
+ }
+ else
+ {
+ // our source connection is an SDBC level connection only, not a SDBCX level one
+ // Which means it cannot provide the to-be-copied object as component.
+
+ if ( _out_rCommandType == CommandType::QUERY )
+ // we cannot copy a query if the connection cannot provide it ...
+ throw IllegalArgumentException(
+ String(ModuleRes( STR_CTW_ERROR_NO_QUERY )),
+ *const_cast< CopyTableWizard* >( this ),
+ 1
+ );
+ pSourceObject.reset( new NamedTableCopySource( m_xSourceConnection, sCommand ) );
+ }
+
+ return pSourceObject;
+}
+
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_extractSourceResultSet_throw( const Reference< XPropertySet >& i_rDescriptor )
+{
+ Reference< XPropertySetInfo > xPSI( i_rDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+
+ // extract relevant settings
+ if ( xPSI->hasPropertyByName( PROPERTY_RESULT_SET ) )
+ m_xSourceResultSet.set( i_rDescriptor->getPropertyValue( PROPERTY_RESULT_SET ), UNO_QUERY );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_SELECTION ) >>= m_aSourceSelection );
+
+ if ( xPSI->hasPropertyByName( PROPERTY_BOOKMARK_SELECTION ) )
+ OSL_VERIFY( i_rDescriptor->getPropertyValue( PROPERTY_BOOKMARK_SELECTION ) >>= m_bSourceSelectionBookmarks );
+
+ // sanity checks
+ const bool bHasResultSet = m_xSourceResultSet.is();
+ const bool bHasSelection = ( m_aSourceSelection.getLength() != 0 );
+ if ( bHasSelection && !bHasResultSet )
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "A result set is needed when specifying a selection to copy." ) ),
+ // TODO: resource
+ *this,
+ 1
+ );
+
+ if ( bHasSelection && m_bSourceSelectionBookmarks )
+ {
+ Reference< XRowLocate > xRowLocate( m_xSourceResultSet, UNO_QUERY );
+ if ( !xRowLocate.is() )
+ {
+ ::dbtools::throwGenericSQLException(
+ String( ModuleRes( STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS ) ),
+ *this
+ );
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
+SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference< XPropertySet >& _rxDataSourceDescriptor,
+ InteractionHandler& _out_rxDocInteractionHandler ) const
+{
+ SharedConnection xConnection;
+
+ OSL_PRECOND( _rxDataSourceDescriptor.is(), "CopyTableWizard::impl_extractConnection_throw: no descriptor!" );
+ if ( !_rxDataSourceDescriptor.is() )
+ return xConnection;
+
+ InteractionHandler xInteractionHandler;
+
+ do
+ {
+ Reference< XPropertySetInfo > xPSI( _rxDataSourceDescriptor->getPropertySetInfo(), UNO_SET_THROW );
+
+ // if there's an ActiveConnection, use it
+ if ( xPSI->hasPropertyByName( PROPERTY_ACTIVE_CONNECTION ) )
+ {
+ Reference< XConnection > xPure;
+ OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xPure );
+ xConnection.reset( xPure, SharedConnection::NoTakeOwnership );
+ }
+ if ( xConnection.is() )
+ {
+ xInteractionHandler = lcl_getInteractionHandler_throw( xConnection.getTyped(), m_xInteractionHandler );
+ OSL_POSTCOND( xInteractionHandler.is(), "CopyTableWizard::impl_extractConnection_throw: lcl_getInteractionHandler_throw returned nonsense!" );
+ break;
+ }
+
+ // there could be a DataSourceName or a DatabaseLocation, describing the css.sdb.DataSource
+ ::rtl::OUString sDataSource, sDatabaseLocation;
+ if ( xPSI->hasPropertyByName( PROPERTY_DATASOURCENAME ) )
+ OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sDataSource );
+ if ( xPSI->hasPropertyByName( PROPERTY_DATABASE_LOCATION ) )
+ OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_DATABASE_LOCATION ) >>= sDatabaseLocation );
+
+ // need a DatabaseContext for loading the data source
+ Reference< XNameAccess > xDatabaseContext( m_aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+ Reference< XDataSource > xDataSource;
+ if ( sDataSource.getLength() )
+ xDataSource.set( xDatabaseContext->getByName( sDataSource ), UNO_QUERY_THROW );
+ if ( !xDataSource.is() && sDatabaseLocation.getLength() )
+ xDataSource.set( xDatabaseContext->getByName( sDatabaseLocation ), UNO_QUERY_THROW );
+
+ if ( xDataSource.is() )
+ {
+ // first, try connecting with completion
+ xInteractionHandler = lcl_getInteractionHandler_throw( xDataSource, m_xInteractionHandler );
+ OSL_POSTCOND( xInteractionHandler.is(), "CopyTableWizard::impl_extractConnection_throw: lcl_getInteractionHandler_throw returned nonsense!" );
+ if ( xInteractionHandler.is() )
+ {
+ Reference< XCompletedConnection > xInteractiveConnection( xDataSource, UNO_QUERY );
+ if ( xInteractiveConnection.is() )
+ xConnection.reset( xInteractiveConnection->connectWithCompletion( xInteractionHandler ), SharedConnection::TakeOwnership );
+ }
+
+ // interactively connecting was not successful or possible -> connect without interaction
+ if ( !xConnection.is() )
+ {
+ xConnection.reset( xDataSource->getConnection( ::rtl::OUString(), ::rtl::OUString() ), SharedConnection::TakeOwnership );
+ }
+ }
+
+ if ( xConnection.is() )
+ break;
+
+ // finally, there could be a ConnectionResource/ConnectionInfo
+ ::rtl::OUString sConnectionResource;
+ Sequence< PropertyValue > aConnectionInfo;
+ if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_RESOURCE ) )
+ OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_RESOURCE ) >>= sConnectionResource );
+ if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_INFO ) )
+ OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_INFO ) >>= aConnectionInfo );
+
+ Reference< XDriverManager > xDriverManager;
+ xDriverManager.set( m_aContext.createComponent( "com.sun.star.sdbc.ConnectionPool" ), UNO_QUERY );
+ if ( !xDriverManager.is() )
+ // no connection pool installed
+ xDriverManager.set( m_aContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+
+ if ( aConnectionInfo.getLength() )
+ xConnection.set( xDriverManager->getConnectionWithInfo( sConnectionResource, aConnectionInfo ), UNO_SET_THROW );
+ else
+ xConnection.set( xDriverManager->getConnection( sConnectionResource ), UNO_SET_THROW );
+ }
+ while ( false );
+
+ if ( xInteractionHandler != m_xInteractionHandler )
+ _out_rxDocInteractionHandler = xInteractionHandler;
+
+ return xConnection;
+}
+
+//-------------------------------------------------------------------------
+::utl::SharedUNOComponent< XPreparedStatement > CopyTableWizard::impl_createSourceStatement_throw() const
+{
+ OSL_PRECOND( m_xSourceConnection.is(), "CopyTableWizard::impl_createSourceStatement_throw: illegal call!" );
+ if ( !m_xSourceConnection.is() )
+ throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
+
+ ::utl::SharedUNOComponent< XPreparedStatement > xStatement;
+ switch ( m_nCommandType )
+ {
+ case CommandType::TABLE:
+ xStatement.set( m_pSourceObject->getPreparedSelectStatement(), UNO_SET_THROW );
+ break;
+
+ case CommandType::QUERY:
+ {
+ ::rtl::OUString sQueryCommand( m_pSourceObject->getSelectStatement() );
+ xStatement.set( m_pSourceObject->getPreparedSelectStatement(), UNO_SET_THROW );
+
+ // check whether we have to fill in parameter values
+ // create and fill a composer
+
+ Reference< XMultiServiceFactory > xFactory( m_xSourceConnection, UNO_QUERY );
+ ::utl::SharedUNOComponent< XSingleSelectQueryComposer > xComposer;
+ if ( xFactory.is() )
+ // note: connections below the sdb-level are allowed to not support the XMultiServiceFactory interface
+ xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY );
+
+ if ( xComposer.is() )
+ {
+ xComposer->setQuery( sQueryCommand );
+
+ Reference< XParameters > xStatementParams( xStatement, UNO_QUERY );
+ OSL_ENSURE( xStatementParams.is(), "CopyTableWizard::impl_createSourceStatement_throw: no access to the statement's parameters!" );
+ // the statement should be a css.sdbc.PreparedStatement (this is what
+ // we created), and a prepared statement is required to support XParameters
+ if ( xStatementParams.is() )
+ {
+ OSL_ENSURE( m_xInteractionHandler.is(),
+ "CopyTableWizard::impl_createSourceStatement_throw: no interaction handler for the parameters request!" );
+ // we should always have an interaction handler - as last fallback, we create an own one in ::initialize
+
+ if ( m_xInteractionHandler.is() )
+ ::dbtools::askForParameters( xComposer, xStatementParams, m_xSourceConnection, m_xInteractionHandler );
+ }
+ }
+ }
+ break;
+
+ default:
+ // this should not have survived initialization phase
+ throw RuntimeException( ::rtl::OUString(), *const_cast< CopyTableWizard* >( this ) );
+ }
+
+ return xStatement;
+}
+
+//-------------------------------------------------------------------------
+namespace
+{
+ class ValueTransfer
+ {
+ public:
+ ValueTransfer( const sal_Int32& _rSourcePos, const sal_Int32& _rDestPos, const ::std::vector< sal_Int32 >& _rColTypes,
+ const Reference< XRow >& _rxSource, const Reference< XParameters >& _rxDest )
+ :m_rSourcePos( _rSourcePos )
+ ,m_rDestPos( _rDestPos )
+ ,m_rColTypes( _rColTypes )
+ ,m_xSource( _rxSource )
+ ,m_xDest( _rxDest )
+ {
+ }
+
+ template< typename VALUE_TYPE >
+ void transferValue( VALUE_TYPE ( SAL_CALL XRow::*_pGetter )( sal_Int32 ),
+ void (SAL_CALL XParameters::*_pSetter)( sal_Int32, VALUE_TYPE ) )
+ {
+ VALUE_TYPE value( (m_xSource.get()->*_pGetter)( m_rSourcePos ) );
+ if ( m_xSource->wasNull() )
+ m_xDest->setNull( m_rDestPos, m_rColTypes[ m_rSourcePos ] );
+ else
+ (m_xDest.get()->*_pSetter)( m_rDestPos, value );
+ }
+ template< typename VALUE_TYPE >
+ void transferComplexValue( VALUE_TYPE ( SAL_CALL XRow::*_pGetter )( sal_Int32 ),
+ void (SAL_CALL XParameters::*_pSetter)( sal_Int32, const VALUE_TYPE& ) )
+ {
+ const VALUE_TYPE value( (m_xSource.get()->*_pGetter)( m_rSourcePos ) );
+ {
+ if ( m_xSource->wasNull() )
+ m_xDest->setNull( m_rDestPos, m_rColTypes[ m_rSourcePos ] );
+ else
+ (m_xDest.get()->*_pSetter)( m_rDestPos, value );
+ }
+ }
+ private:
+ const sal_Int32& m_rSourcePos;
+ const sal_Int32& m_rDestPos;
+ const ::std::vector< sal_Int32 > m_rColTypes;
+ const Reference< XRow > m_xSource;
+ const Reference< XParameters > m_xDest;
+ };
+}
+
+//-------------------------------------------------------------------------
+bool CopyTableWizard::impl_processCopyError_nothrow( const CopyTableRowEvent& _rEvent )
+{
+ Reference< XCopyTableListener > xListener;
+ try
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( m_aCopyTableListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ xListener.set( aIter.next(), UNO_QUERY_THROW );
+ sal_Int16 nListenerChoice = xListener->copyRowError( _rEvent );
+ switch ( nListenerChoice )
+ {
+ case CopyTableContinuation::Proceed: return true; // continue copying
+ case CopyTableContinuation::CallNextHandler: continue; // continue the loop, ask next listener
+ case CopyTableContinuation::Cancel: return false; // cancel copying
+ case CopyTableContinuation::AskUser: break; // stop asking the listeners, ask the user
+
+ default:
+ OSL_FAIL( "CopyTableWizard::impl_processCopyError_nothrow: invalid listener response!" );
+ // ask next listener
+ continue;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // no listener felt responsible for the error, or a listener told to ask the user
+
+ try
+ {
+ SQLContext aError;
+ aError.Context = *this;
+ aError.Message = String( ModuleRes( STR_ERROR_OCCURRED_WHILE_COPYING ) );
+
+ ::dbtools::SQLExceptionInfo aInfo( _rEvent.Error );
+ if ( aInfo.isValid() )
+ aError.NextException = _rEvent.Error;
+ else
+ {
+ // a non-SQL exception happend
+ Exception aException;
+ OSL_VERIFY( _rEvent.Error >>= aException );
+ SQLContext aContext;
+ aContext.Context = aException.Context;
+ aContext.Message = aException.Message;
+ aContext.Details = _rEvent.Error.getValueTypeName();
+ aError.NextException <<= aContext;
+ }
+
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( makeAny( aError ) ) );
+
+ ::rtl::Reference< ::comphelper::OInteractionApprove > xYes = new ::comphelper::OInteractionApprove;
+ xRequest->addContinuation( xYes.get() );
+ xRequest->addContinuation( new ::comphelper::OInteractionDisapprove );
+
+ OSL_ENSURE( m_xInteractionHandler.is(),
+ "CopyTableWizard::impl_processCopyError_nothrow: we always should have an interaction handler!" );
+ if ( m_xInteractionHandler.is() )
+ m_xInteractionHandler->handle( xRequest.get() );
+
+ if ( xYes->wasSelected() )
+ // continue copying
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // cancel copying
+ return false;
+}
+
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_copyRows_throw( const Reference< XResultSet >& _rxSourceResultSet,
+ const Reference< XPropertySet >& _rxDestTable )
+{
+ OSL_PRECOND( m_xDestConnection.is(), "CopyTableWizard::impl_copyRows_throw: illegal call!" );
+ if ( !m_xDestConnection.is() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_QUERY_THROW );
+
+ const OCopyTableWizard& rWizard = impl_getDialog_throw();
+ ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions();
+ bool bAutoIncrement = rWizard.shouldCreatePrimaryKey();
+
+ Reference< XRow > xRow ( _rxSourceResultSet, UNO_QUERY_THROW );
+ Reference< XRowLocate > xRowLocate ( _rxSourceResultSet, UNO_QUERY_THROW );
+
+ Reference< XResultSetMetaDataSupplier > xSuppResMeta( _rxSourceResultSet, UNO_QUERY_THROW );
+ Reference< XResultSetMetaData> xMeta( xSuppResMeta->getMetaData() );
+
+ // we need a vector which all types
+ sal_Int32 nCount = xMeta->getColumnCount();
+ ::std::vector< sal_Int32 > aSourceColTypes;
+ aSourceColTypes.reserve( nCount + 1 );
+ aSourceColTypes.push_back( -1 ); // just to avoid a everytime i-1 call
+
+ ::std::vector< sal_Int32 > aSourcePrec;
+ aSourcePrec.reserve( nCount + 1 );
+ aSourcePrec.push_back( -1 ); // just to avoid a everytime i-1 call
+
+ for ( sal_Int32 k=1; k <= nCount; ++k )
+ {
+ aSourceColTypes.push_back( xMeta->getColumnType( k ) );
+ aSourcePrec.push_back( xMeta->getPrecision( k ) );
+ }
+
+ // now create, fill and execute the prepared statement
+ Reference< XPreparedStatement > xStatement( ODatabaseExport::createPreparedStatment( xDestMetaData, _rxDestTable, aColumnMapping ), UNO_SET_THROW );
+ Reference< XParameters > xStatementParams( xStatement, UNO_QUERY_THROW );
+
+ const bool bSelectedRecordsOnly = m_aSourceSelection.getLength() != 0;
+ const Any* pSelectedRow = m_aSourceSelection.getConstArray();
+ const Any* pSelEnd = pSelectedRow + m_aSourceSelection.getLength();
+
+ sal_Int32 nRowCount = 0;
+ bool bContinue = false;
+
+ CopyTableRowEvent aCopyEvent;
+ aCopyEvent.Source = *this;
+ aCopyEvent.SourceData = _rxSourceResultSet;
+
+ do // loop as long as there are more rows or the selection ends
+ {
+ bContinue = false;
+ if ( bSelectedRecordsOnly )
+ {
+ if ( pSelectedRow != pSelEnd )
+ {
+ if ( m_bSourceSelectionBookmarks )
+ {
+ bContinue = xRowLocate->moveToBookmark( *pSelectedRow );
+ }
+ else
+ {
+ sal_Int32 nPos = 0;
+ OSL_VERIFY( *pSelectedRow >>= nPos );
+ bContinue = _rxSourceResultSet->absolute( nPos );
+ }
+ ++pSelectedRow;
+ }
+ }
+ else
+ bContinue = _rxSourceResultSet->next();
+
+ if ( !bContinue )
+ {
+ break;
+ }
+
+ ++nRowCount;
+ sal_Bool bInsertAutoIncrement = sal_True;
+ ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin();
+ ODatabaseExport::TPositions::const_iterator aPosEnd = aColumnMapping.end();
+
+ aCopyEvent.Error.clear();
+ try
+ {
+ // notify listeners
+ m_aCopyTableListeners.notifyEach( &XCopyTableListener::copyingRow, aCopyEvent );
+
+ sal_Int32 nDestColumn( 0 );
+ sal_Int32 nSourceColumn( 1 );
+ ValueTransfer aTransfer( nSourceColumn, nDestColumn, aSourceColTypes, xRow, xStatementParams );
+
+ for ( ; aPosIter != aPosEnd; ++aPosIter )
+ {
+ nDestColumn = aPosIter->first;
+ if ( nDestColumn == COLUMN_POSITION_NOT_FOUND )
+ {
+ ++nSourceColumn;
+ // otherwise we don't get the correct value when only the 2nd source column was selected
+ continue;
+ }
+
+ if ( bAutoIncrement && bInsertAutoIncrement )
+ {
+ xStatementParams->setInt( 1, nRowCount );
+ bInsertAutoIncrement = sal_False;
+ continue;
+ }
+
+ if ( ( nSourceColumn < 1 ) || ( nSourceColumn >= (sal_Int32)aSourceColTypes.size() ) )
+ { // ( we have to check here against 1 because the parameters are 1 based)
+ ::dbtools::throwSQLException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: invalid column type index." ) ),
+ ::dbtools::SQL_INVALID_DESCRIPTOR_INDEX,
+ *this
+ );
+ }
+
+ switch ( aSourceColTypes[ nSourceColumn ] )
+ {
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ aTransfer.transferValue( &XRow::getDouble, &XParameters::setDouble );
+ break;
+
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aTransfer.transferComplexValue( &XRow::getString, &XParameters::setString );
+ break;
+
+ case DataType::BIGINT:
+ aTransfer.transferValue( &XRow::getLong, &XParameters::setLong );
+ break;
+
+ case DataType::FLOAT:
+ aTransfer.transferValue( &XRow::getFloat, &XParameters::setFloat );
+ break;
+
+ case DataType::LONGVARBINARY:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes );
+ break;
+
+ case DataType::DATE:
+ aTransfer.transferComplexValue( &XRow::getDate, &XParameters::setDate );
+ break;
+
+ case DataType::TIME:
+ aTransfer.transferComplexValue( &XRow::getTime, &XParameters::setTime );
+ break;
+
+ case DataType::TIMESTAMP:
+ aTransfer.transferComplexValue( &XRow::getTimestamp, &XParameters::setTimestamp );
+ break;
+
+ case DataType::BIT:
+ if ( aSourcePrec[nSourceColumn] > 1 )
+ {
+ aTransfer.transferComplexValue( &XRow::getBytes, &XParameters::setBytes );
+ break;
+ }
+ // run through
+ case DataType::BOOLEAN:
+ aTransfer.transferValue( &XRow::getBoolean, &XParameters::setBoolean );
+ break;
+
+ case DataType::TINYINT:
+ aTransfer.transferValue( &XRow::getByte, &XParameters::setByte );
+ break;
+
+ case DataType::SMALLINT:
+ aTransfer.transferValue( &XRow::getShort, &XParameters::setShort );
+ break;
+
+ case DataType::INTEGER:
+ aTransfer.transferValue( &XRow::getInt, &XParameters::setInt );
+ break;
+
+ case DataType::BLOB:
+ aTransfer.transferComplexValue( &XRow::getBlob, &XParameters::setBlob );
+ break;
+
+ case DataType::CLOB:
+ aTransfer.transferComplexValue( &XRow::getClob, &XParameters::setClob );
+ break;
+
+ default:
+ {
+ ::rtl::OUString aMessage( String( ModuleRes( STR_CTW_UNSUPPORTED_COLUMN_TYPE ) ) );
+
+ aMessage.replaceAt( aMessage.indexOfAsciiL( "$type$", 6 ), 6, ::rtl::OUString::valueOf( aSourceColTypes[ nSourceColumn ] ) );
+ aMessage.replaceAt( aMessage.indexOfAsciiL( "$pos$", 5 ), 5, ::rtl::OUString::valueOf( nSourceColumn ) );
+
+ ::dbtools::throwSQLException(
+ aMessage,
+ ::dbtools::SQL_INVALID_SQL_DATA_TYPE,
+ *this
+ );
+ }
+ }
+ ++nSourceColumn;
+ }
+ xStatement->executeUpdate();
+
+ // notify listeners
+ m_aCopyTableListeners.notifyEach( &XCopyTableListener::copiedRow, aCopyEvent );
+ }
+ catch( const Exception& )
+ {
+ aCopyEvent.Error = ::cppu::getCaughtException();
+ }
+
+ if ( aCopyEvent.Error.hasValue() )
+ bContinue = impl_processCopyError_nothrow( aCopyEvent );
+ }
+ while( bContinue );
+}
+//-------------------------------------------------------------------------
+void CopyTableWizard::impl_doCopy_nothrow()
+{
+ Any aError;
+
+ try
+ {
+ OCopyTableWizard& rWizard( impl_getDialog_throw() );
+
+ WaitObject aWO( rWizard.GetParent() );
+ Reference< XPropertySet > xTable;
+
+ switch ( rWizard.getOperation() )
+ {
+ case CopyTableOperation::CopyDefinitionOnly:
+ case CopyTableOperation::CopyDefinitionAndData:
+ {
+ xTable = rWizard.createTable();
+
+ if( !xTable.is() )
+ {
+ OSL_FAIL( "CopyTableWizard::impl_doCopy_nothrow: createTable should throw here, shouldn't it?" );
+ break;
+ }
+
+ if( CopyTableOperation::CopyDefinitionOnly == rWizard.getOperation() )
+ break;
+ }
+ // run through
+
+ case CopyTableOperation::AppendData:
+ {
+
+ if ( !xTable.is() )
+ {
+ xTable = rWizard.createTable();
+ if ( !xTable.is() )
+ {
+ OSL_FAIL( "CopyTableWizard::impl_doCopy_nothrow: createTable should throw here, shouldn't it?" );
+ break;
+ }
+ }
+
+ ::utl::SharedUNOComponent< XPreparedStatement > xSourceStatement;
+ ::utl::SharedUNOComponent< XResultSet > xSourceResultSet;
+
+ if ( m_xSourceResultSet.is() )
+ {
+ xSourceResultSet.reset( m_xSourceResultSet, ::utl::SharedUNOComponent< XResultSet >::NoTakeOwnership );
+ }
+ else
+ {
+ const bool bIsSameConnection = ( m_xSourceConnection.getTyped() == m_xDestConnection.getTyped() );
+ const bool bIsTable = ( CommandType::TABLE == m_nCommandType );
+ bool bDone = false;
+ if ( bIsSameConnection && bIsTable )
+ {
+ // try whether the server supports copying via SQL
+ try
+ {
+ m_xDestConnection->createStatement()->executeUpdate( impl_getServerSideCopyStatement_throw(xTable) );
+ bDone = true;
+ }
+ catch( const Exception& )
+ {
+ // this is allowed.
+ }
+ }
+
+ if ( !bDone )
+ {
+ xSourceStatement.set( impl_createSourceStatement_throw(), UNO_SET_THROW );
+ xSourceResultSet.set( xSourceStatement->executeQuery(), UNO_SET_THROW );
+ }
+ }
+
+ if ( xSourceResultSet.is() )
+ impl_copyRows_throw( xSourceResultSet, xTable );
+ }
+ break;
+
+ case CopyTableOperation::CreateAsView:
+ rWizard.createView();
+ break;
+
+ default:
+ OSL_FAIL( "CopyTableWizard::impl_doCopy_nothrow: What operation, please?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ aError = ::cppu::getCaughtException();
+
+ // silence the error of the user cancelling the parameter's dialog
+ SQLException aSQLError;
+ if ( ( aError >>= aSQLError ) && ( aSQLError.ErrorCode == ::dbtools::ParameterInteractionCancelled ) )
+ {
+ aError.clear();
+ m_nOverrideExecutionResult = RET_CANCEL;
+ }
+ }
+
+ if ( aError.hasValue() && m_xInteractionHandler.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ::comphelper::OInteractionRequest > xRequest( new ::comphelper::OInteractionRequest( aError ) );
+ m_xInteractionHandler->handle( xRequest.get() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString CopyTableWizard::impl_getServerSideCopyStatement_throw(const Reference< XPropertySet >& _xTable)
+{
+ const Reference<XColumnsSupplier> xDestColsSup(_xTable,UNO_QUERY_THROW);
+ const Sequence< ::rtl::OUString> aDestColumnNames = xDestColsSup->getColumns()->getElementNames();
+ const Sequence< ::rtl::OUString > aColumnNames = m_pSourceObject->getColumnNames();
+ const Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_QUERY_THROW );
+ const ::rtl::OUString sQuote = xDestMetaData->getIdentifierQuoteString();
+ ::rtl::OUStringBuffer sColumns;
+ // 1st check if the columns matching
+ const OCopyTableWizard& rWizard = impl_getDialog_throw();
+ ODatabaseExport::TPositions aColumnMapping = rWizard.GetColumnPositions();
+ ODatabaseExport::TPositions::const_iterator aPosIter = aColumnMapping.begin();
+ for ( sal_Int32 i = 0; aPosIter != aColumnMapping.end() ; ++aPosIter,++i )
+ {
+ if ( COLUMN_POSITION_NOT_FOUND != aPosIter->second )
+ {
+ if ( sColumns.getLength() )
+ sColumns.appendAscii(",");
+ sColumns.append(sQuote);
+ sColumns.append(aDestColumnNames[aPosIter->second - 1]);
+ sColumns.append(sQuote);
+ }
+ }
+ ::rtl::OUStringBuffer sSql;
+ sSql.appendAscii("INSERT INTO ");
+ const ::rtl::OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, _xTable, ::dbtools::eInDataManipulation, false, false, true );
+ sSql.append( sComposedTableName );
+ sSql.appendAscii(" ( ");
+ sSql.append( sColumns );
+ sSql.appendAscii(" ) ( ");
+ sSql.append( m_pSourceObject->getSelectStatement());
+ sSql.appendAscii(" )");
+
+ return sSql.makeStringAndClear();
+}
+//-------------------------------------------------------------------------
+void SAL_CALL CopyTableWizard::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( isInitialized() )
+ throw AlreadyInitializedException( ::rtl::OUString(), *this );
+
+ sal_Int32 nArgCount( _rArguments.getLength() );
+ if ( ( nArgCount != 2 ) && ( nArgCount != 3 ) )
+ throw IllegalArgumentException(
+ String( ModuleRes( STR_CTW_ILLEGAL_PARAMETER_COUNT ) ),
+ *this,
+ 1
+ );
+
+ try
+ {
+ if ( nArgCount == 3 )
+ { // ->createWithInteractionHandler
+ if ( !( _rArguments[2] >>= m_xInteractionHandler ) )
+ throw IllegalArgumentException(
+ String(ModuleRes( STR_CTW_ERROR_INVALID_INTERACTIONHANDLER )),
+ *this,
+ 3
+ );
+ }
+ if ( !m_xInteractionHandler.is() )
+ m_xInteractionHandler.set( m_aContext.createComponent( "com.sun.star.task.InteractionHandler" ), UNO_QUERY_THROW );
+
+ InteractionHandler xSourceDocHandler;
+ Reference< XPropertySet > xSourceDescriptor( impl_ensureDataAccessDescriptor_throw( _rArguments, 0, m_xSourceConnection, xSourceDocHandler ) );
+ impl_checkForUnsupportedSettings_throw( xSourceDescriptor );
+ m_pSourceObject = impl_extractSourceObject_throw( xSourceDescriptor, m_nCommandType );
+ impl_extractSourceResultSet_throw( xSourceDescriptor );
+
+ InteractionHandler xDestDocHandler;
+ impl_ensureDataAccessDescriptor_throw( _rArguments, 1, m_xDestConnection, xDestDocHandler );
+
+ if ( xDestDocHandler.is() && !m_xInteractionHandler.is() )
+ m_xInteractionHandler = xDestDocHandler;
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const IllegalArgumentException& ) { throw; }
+ catch( const SQLException& ) { throw; }
+ catch( const Exception& )
+ {
+ throw WrappedTargetException(
+ String( ModuleRes( STR_CTW_ERROR_DURING_INITIALIZATION ) ),
+ *this,
+ ::cppu::getCaughtException()
+ );
+ }
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& CopyTableWizard::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* CopyTableWizard::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+
+//------------------------------------------------------------------------------
+Dialog* CopyTableWizard::createDialog( Window* _pParent )
+{
+ OSL_PRECOND( isInitialized(), "CopyTableWizard::createDialog: not initialized!" );
+ // this should have been prevented in ::execute already
+
+ OCopyTableWizard* pWizard = new OCopyTableWizard(
+ _pParent,
+ m_sDestinationTable,
+ m_nOperation,
+ *m_pSourceObject,
+ m_xSourceConnection.getTyped(),
+ m_xDestConnection.getTyped(),
+ m_aContext.getLegacyServiceFactory(),
+ m_xInteractionHandler
+ );
+
+ impl_attributesToDialog_nothrow( *pWizard );
+
+ return pWizard;
+}
+
+//------------------------------------------------------------------------------
+void CopyTableWizard::executedDialog( sal_Int16 _nExecutionResult )
+{
+ CopyTableWizard_DialogBase::executedDialog( _nExecutionResult );
+
+ if ( _nExecutionResult == RET_OK )
+ impl_doCopy_nothrow();
+
+ // do this after impl_doCopy_nothrow: The attributes may change during copying, for instance
+ // if the user entered an unqualified table name
+ impl_dialogToAttributes_nothrow( impl_getDialog_throw() );
+}
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+extern "C" void SAL_CALL createRegistryInfo_CopyTableWizard()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::CopyTableWizard > aAutoRegistration;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/copytablewizard.src b/dbaccess/source/ui/uno/copytablewizard.src
new file mode 100644
index 000000000000..a0dd16eabf4e
--- /dev/null
+++ b/dbaccess/source/ui/uno/copytablewizard.src
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "dbu_uno.hrc"
+
+String STR_CTW_NO_VIEWS_SUPPORT
+{
+ Text [ en-US ] = "The destination database does not support views.";
+};
+
+String STR_CTW_NO_PRIMARY_KEY_SUPPORT
+{
+ Text [ en-US ] = "The destination database does not support primary keys.";
+};
+
+String STR_CTW_INVALID_DATA_ACCESS_DESCRIPTOR
+{
+ Text [ en-US ] = "no data access descriptor found, or no data access descriptor able to provide all necessary information";
+};
+
+String STR_CTW_ONLY_TABLES_AND_QUERIES_SUPPORT
+{
+ Text [ en-US ] = "Only tables and queries are supported at the moment.";
+};
+
+String STR_CTW_COPY_SOURCE_NEEDS_BOOKMARKS
+{
+ Text [ en-US ] = "The copy source's result set must support bookmarks.";
+};
+
+String STR_CTW_UNSUPPORTED_COLUMN_TYPE
+{
+ Text [ en-US ] = "Unsupported source column type ($type$) at column position $pos$.";
+};
+
+String STR_CTW_ILLEGAL_PARAMETER_COUNT
+{
+ Text [ en-US ] = "Illegal number of initialization parameters.";
+};
+
+String STR_CTW_ERROR_DURING_INITIALIZATION
+{
+ Text [ en-US ] = "An error occurred during initialization.";
+};
+
+String STR_CTW_ERROR_UNSUPPORTED_SETTING
+{
+ Text [ en-US ] = "Unsupported setting in the copy source descriptor: $name$.";
+};
+
+String STR_CTW_ERROR_NO_QUERY
+{
+ Text [ en-US ] = "To copy a query, your connection must be able to provide queries.";
+};
+
+String STR_CTW_ERROR_INVALID_INTERACTIONHANDLER
+{
+ Text [ en-US ] = "The given interaction handler is invalid.";
+};
diff --git a/dbaccess/source/ui/uno/dbinteraction.cxx b/dbaccess/source/ui/uno/dbinteraction.cxx
new file mode 100644
index 000000000000..8e029adfdbde
--- /dev/null
+++ b/dbaccess/source/ui/uno/dbinteraction.cxx
@@ -0,0 +1,379 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbinteraction.hxx"
+#include "dbu_reghelper.hxx"
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+#include <connectivity/dbexception.hxx>
+#include "sqlmessage.hxx"
+#include <com/sun/star/task/XInteractionApprove.hpp>
+#include <com/sun/star/task/XInteractionDisapprove.hpp>
+#include <com/sun/star/task/XInteractionRetry.hpp>
+#include <com/sun/star/task/XInteractionAbort.hpp>
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <com/sun/star/sdb/XInteractionDocumentSave.hpp>
+#include <sfx2/QuerySaveDocument.hxx>
+#include "dbu_uno.hrc"
+#include "paramdialog.hxx"
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include "CollectionView.hxx"
+#include "UITools.hxx"
+
+
+//==========================================================================
+
+extern "C" void SAL_CALL createRegistryInfo_OInteractionHandler()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::SQLExceptionInteractionHandler > aSQLExceptionInteractionHandler_AutoRegistration;
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::LegacyInteractionHandler > aLegacyInteractionHandler_AutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::beans;
+ using namespace ::dbtools;
+
+ //=========================================================================
+ //= BasicInteractionHandler
+ //=========================================================================
+ //-------------------------------------------------------------------------
+ BasicInteractionHandler::BasicInteractionHandler( const Reference< XMultiServiceFactory >& _rxORB, const bool i_bFallbackToGeneric )
+ :m_xORB( _rxORB )
+ ,m_bFallbackToGeneric( i_bFallbackToGeneric )
+ {
+ OSL_ENSURE( !m_bFallbackToGeneric,
+ "BasicInteractionHandler::BasicInteractionHandler: enabling legacy behavior, there should be no clients of this anymore!" );
+ }
+
+ //-------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL BasicInteractionHandler::handleInteractionRequest( const Reference< XInteractionRequest >& i_rRequest ) throw (RuntimeException)
+ {
+ return impl_handle_throw( i_rRequest );
+ }
+
+ //-------------------------------------------------------------------------
+ void SAL_CALL BasicInteractionHandler::handle( const Reference< XInteractionRequest >& i_rRequest ) throw(RuntimeException)
+ {
+ impl_handle_throw( i_rRequest );
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Bool BasicInteractionHandler::impl_handle_throw( const Reference< XInteractionRequest >& i_Request )
+ {
+ Any aRequest( i_Request->getRequest() );
+ OSL_ENSURE(aRequest.hasValue(), "BasicInteractionHandler::handle: invalid request!");
+ if ( !aRequest.hasValue() )
+ // no request -> no handling
+ return sal_False;
+
+ Sequence< Reference< XInteractionContinuation > > aContinuations( i_Request->getContinuations() );
+
+ // try to extract an SQLException (or one of it's derived members
+ SQLExceptionInfo aInfo( aRequest );
+ if ( aInfo.isValid() )
+ {
+ implHandle( aInfo, aContinuations );
+ return sal_True;
+ }
+
+ ParametersRequest aParamRequest;
+ if ( aRequest >>= aParamRequest )
+ {
+ implHandle( aParamRequest, aContinuations );
+ return sal_True;
+ }
+
+ DocumentSaveRequest aDocuRequest;
+ if ( aRequest >>= aDocuRequest )
+ {
+ implHandle( aDocuRequest, aContinuations );
+ return sal_True;
+ }
+
+ if ( m_bFallbackToGeneric )
+ return implHandleUnknown( i_Request );
+
+ return sal_False;
+ }
+
+ //-------------------------------------------------------------------------
+ void BasicInteractionHandler::implHandle(const ParametersRequest& _rParamRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
+ {
+ SolarMutexGuard aGuard;
+ // want to open a dialog ....
+
+ sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations);
+ sal_Int32 nParamPos = getContinuation(SUPPLY_PARAMETERS, _rContinuations);
+
+ Reference< XInteractionSupplyParameters > xParamCallback;
+ if (-1 != nParamPos)
+ xParamCallback = Reference< XInteractionSupplyParameters >(_rContinuations[nParamPos], UNO_QUERY);
+ OSL_ENSURE(xParamCallback.is(), "BasicInteractionHandler::implHandle(ParametersRequest): can't set the parameters without an appropriate interaction handler!s");
+
+ OParameterDialog aDlg(NULL, _rParamRequest.Parameters, _rParamRequest.Connection, m_xORB);
+ sal_Int16 nResult = aDlg.Execute();
+ try
+ {
+ switch (nResult)
+ {
+ case RET_OK:
+ if (xParamCallback.is())
+ {
+ xParamCallback->setParameters(aDlg.getValues());
+ xParamCallback->select();
+ }
+ break;
+ default:
+ if (-1 != nAbortPos)
+ _rContinuations[nAbortPos]->select();
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ void BasicInteractionHandler::implHandle(const SQLExceptionInfo& _rSqlInfo, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
+ {
+ SolarMutexGuard aGuard;
+ // want to open a dialog ....
+
+ sal_Int32 nApprovePos = getContinuation(APPROVE, _rContinuations);
+ sal_Int32 nDisapprovePos = getContinuation(DISAPPROVE, _rContinuations);
+ sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations);
+ sal_Int32 nRetryPos = getContinuation(RETRY, _rContinuations);
+
+ // determine the style of the dialog, dependent on the present continuation types
+ WinBits nDialogStyle = 0;
+ bool bHaveCancel = nAbortPos != -1;
+ // "approve" means "Yes", "disapprove" means "No"
+ // VCL only supports having both (which makes sense ...)
+ if ( ( nApprovePos != -1 ) || ( nDisapprovePos != -1 ) )
+ nDialogStyle = ( bHaveCancel ? WB_YES_NO_CANCEL : WB_YES_NO ) | WB_DEF_YES;
+ else
+ {
+ // if there's no yes/no, then use a default OK button
+ nDialogStyle = ( bHaveCancel ? WB_OK_CANCEL : WB_OK ) | WB_DEF_OK;
+ }
+
+ // If there's a "Retry" continuation, have a "Retry" button
+ if ( nRetryPos != -1 )
+ {
+ nDialogStyle = WB_RETRY_CANCEL | WB_DEF_RETRY;
+ }
+
+ // execute the dialog
+ OSQLMessageBox aDialog(NULL, _rSqlInfo, nDialogStyle);
+ // TODO: need a way to specify the parent window
+ sal_Int16 nResult = aDialog.Execute();
+ try
+ {
+ switch (nResult)
+ {
+ case RET_YES:
+ case RET_OK:
+ if ( nApprovePos != -1 )
+ _rContinuations[ nApprovePos ]->select();
+ else
+ OSL_ENSURE( nResult != RET_YES, "BasicInteractionHandler::implHandle: no handler for YES!" );
+ break;
+
+ case RET_NO:
+ if ( nDisapprovePos != -1 )
+ _rContinuations[ nDisapprovePos ]->select();
+ else
+ OSL_FAIL( "BasicInteractionHandler::implHandle: no handler for NO!" );
+ break;
+
+ case RET_CANCEL:
+ if ( nAbortPos != -1 )
+ _rContinuations[ nAbortPos ]->select();
+ else if ( nDisapprovePos != -1 )
+ _rContinuations[ nDisapprovePos ]->select();
+ else
+ OSL_FAIL( "BasicInteractionHandler::implHandle: no handler for CANCEL!" );
+ break;
+ case RET_RETRY:
+ if ( nRetryPos != -1 )
+ _rContinuations[ nRetryPos ]->select();
+ else
+ OSL_FAIL( "BasicInteractionHandler::implHandle: where does the RETRY come from?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ //-------------------------------------------------------------------------
+ void BasicInteractionHandler::implHandle(const DocumentSaveRequest& _rDocuRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
+ {
+ SolarMutexGuard aGuard;
+ // want to open a dialog ....
+
+ sal_Int32 nApprovePos = getContinuation(APPROVE, _rContinuations);
+ sal_Int32 nDisApprovePos = getContinuation(DISAPPROVE, _rContinuations);
+ sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations);
+
+ short nRet = RET_YES;
+ if ( -1 != nApprovePos )
+ {
+ // fragen, ob gespeichert werden soll
+ nRet = ExecuteQuerySaveDocument(NULL,_rDocuRequest.Name);
+ }
+
+ if ( RET_CANCEL == nRet )
+ {
+ if (-1 != nAbortPos)
+ _rContinuations[nAbortPos]->select();
+ return;
+ }
+ else if ( RET_YES == nRet )
+ {
+ sal_Int32 nDocuPos = getContinuation(SUPPLY_DOCUMENTSAVE, _rContinuations);
+
+ if (-1 != nDocuPos)
+ {
+ Reference< XInteractionDocumentSave > xCallback(_rContinuations[nDocuPos], UNO_QUERY);
+ OSL_ENSURE(xCallback.is(), "BasicInteractionHandler::implHandle(DocumentSaveRequest): can't save document without an appropriate interaction handler!s");
+
+ OCollectionView aDlg(NULL,_rDocuRequest.Content,_rDocuRequest.Name,m_xORB);
+ sal_Int16 nResult = aDlg.Execute();
+ try
+ {
+ switch (nResult)
+ {
+ case RET_OK:
+ if (xCallback.is())
+ {
+ xCallback->setName(aDlg.getName(),aDlg.getSelectedFolder());
+ xCallback->select();
+ }
+ break;
+ default:
+ if (-1 != nAbortPos)
+ _rContinuations[nAbortPos]->select();
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else if ( -1 != nApprovePos )
+ _rContinuations[nApprovePos]->select();
+ }
+ else if ( -1 != nDisApprovePos )
+ _rContinuations[nDisApprovePos]->select();
+ }
+
+ //-------------------------------------------------------------------------
+ bool BasicInteractionHandler::implHandleUnknown( const Reference< XInteractionRequest >& _rxRequest )
+ {
+ Reference< XInteractionHandler > xFallbackHandler;
+ if ( m_xORB.is() )
+ xFallbackHandler = xFallbackHandler.query( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) ) );
+ if ( xFallbackHandler.is() )
+ {
+ xFallbackHandler->handle( _rxRequest );
+ return true;
+ }
+ return false;
+ }
+
+ //-------------------------------------------------------------------------
+ sal_Int32 BasicInteractionHandler::getContinuation(Continuation _eCont, const Sequence< Reference< XInteractionContinuation > >& _rContinuations)
+ {
+ const Reference< XInteractionContinuation >* pContinuations = _rContinuations.getConstArray();
+ for (sal_Int32 i=0; i<_rContinuations.getLength(); ++i, ++pContinuations)
+ {
+ switch (_eCont)
+ {
+ case APPROVE:
+ if (Reference< XInteractionApprove >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ case DISAPPROVE:
+ if (Reference< XInteractionDisapprove >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ case RETRY:
+ if (Reference< XInteractionRetry >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ case ABORT:
+ if (Reference< XInteractionAbort >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ case SUPPLY_PARAMETERS:
+ if (Reference< XInteractionSupplyParameters >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ case SUPPLY_DOCUMENTSAVE:
+ if (Reference< XInteractionDocumentSave >(*pContinuations, UNO_QUERY).is())
+ return i;
+ break;
+ }
+ }
+
+ return -1;
+ }
+
+ //==========================================================================
+ //= SQLExceptionInteractionHandler
+ //==========================================================================
+ IMPLEMENT_SERVICE_INFO1_STATIC( SQLExceptionInteractionHandler, "com.sun.star.comp.dbaccess.DatabaseInteractionHandler", "com.sun.star.sdb.DatabaseInteractionHandler" );
+
+ //==========================================================================
+ //= LegacyInteractionHandler
+ //==========================================================================
+ IMPLEMENT_SERVICE_INFO1_STATIC( LegacyInteractionHandler, "com.sun.star.comp.dbaccess.LegacyInteractionHandler", "com.sun.star.sdb.InteractionHandler" );
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/dbinteraction.hxx b/dbaccess/source/ui/uno/dbinteraction.hxx
new file mode 100644
index 000000000000..90beac1b797e
--- /dev/null
+++ b/dbaccess/source/ui/uno/dbinteraction.hxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_INTERACTION_HXX_
+#define _DBAUI_INTERACTION_HXX_
+
+#include <cppuhelper/implbase2.hxx>
+
+#include "moduledbu.hxx"
+#include "apitools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/task/XInteractionHandler2.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/AuthenticationRequest.hpp>
+#include <com/sun/star/sdb/ParametersRequest.hpp>
+#include <com/sun/star/sdb/DocumentSaveRequest.hpp>
+/** === end UNO includes === **/
+
+namespace dbtools
+{
+ class SQLExceptionInfo;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=========================================================================
+ //= BasicInteractionHandler
+ //=========================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::task::XInteractionHandler2
+ > BasicInteractionHandler_Base;
+ /** implements an <type scope="com.sun.star.task">XInteractionHandler</type> for
+ database related interaction requests.
+ <p/>
+ Supported interaction requests by now (specified by an exception: The appropriate exception
+ has to be returned by the getRequest method of the object implementing the
+ <type scope="com.sun.star.task">XInteractionRequest</type> interface.
+ <ul>
+ <li><b><type scope="com.sun.star.sdbc">SQLException</type></b>: requests to display a
+ standard error dialog for the (maybe chained) exception given</li>
+ </ul>
+ */
+ class BasicInteractionHandler
+ :public BasicInteractionHandler_Base
+ {
+ const OModuleClient m_aModuleClient;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ const bool m_bFallbackToGeneric;
+
+ public:
+ BasicInteractionHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB,
+ const bool i_bFallbackToGeneric
+ );
+
+ // XInteractionHandler2
+ virtual ::sal_Bool SAL_CALL handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw(::com::sun::star::uno::RuntimeException);
+
+ protected:
+ sal_Bool
+ impl_handle_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_Request );
+
+ /// handle SQLExceptions (and derived classes)
+ void implHandle(
+ const ::dbtools::SQLExceptionInfo& _rSqlInfo,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
+
+ /// handle parameter requests
+ void implHandle(
+ const ::com::sun::star::sdb::ParametersRequest& _rParamRequest,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
+
+ /// handle document save requests
+ void implHandle(
+ const ::com::sun::star::sdb::DocumentSaveRequest& _rParamRequest,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
+
+ /// handles requests which are not SDB-specific
+ bool implHandleUnknown(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& _rxRequest );
+
+ /// known continuation types
+ enum Continuation
+ {
+ APPROVE,
+ DISAPPROVE,
+ RETRY,
+ ABORT,
+ SUPPLY_PARAMETERS,
+ SUPPLY_DOCUMENTSAVE
+ };
+ /** check if a given continuation sequence contains a given continuation type<p/>
+ @return the index within <arg>_rContinuations</arg> of the first occurrence of a continuation
+ of the requested type, -1 of no such continuation exists
+ */
+ sal_Int32 getContinuation(
+ Continuation _eCont,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations);
+ };
+
+ //=========================================================================
+ //= SQLExceptionInteractionHandler
+ //=========================================================================
+ class SQLExceptionInteractionHandler : public BasicInteractionHandler
+ {
+ public:
+ SQLExceptionInteractionHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
+ )
+ :BasicInteractionHandler( i_rORB, false )
+ {
+ }
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+ };
+
+ //=========================================================================
+ //= SQLExceptionInteractionHandler
+ //=========================================================================
+ /** an implementation for the legacy css.sdb.InteractionHandler
+
+ css.sdb.InteractionHandler is deprecated, as it does not only handle database related interactions,
+ but also delegates all kind of unknown requests to a css.task.InteractionHandler.
+
+ In today's architecture, there's only one central css.task.InteractionHandler, which is to be used
+ for all requests. Depending on configuration information, it decides which handler implementation
+ to delegate a request to.
+
+ SQLExceptionInteractionHandler is the delegatee which handles only database related interactions.
+ LegacyInteractionHandler is the version which first checks for a database related interaction, and
+ forwards everything else to the css.task.InteractionHandler.
+ */
+ class LegacyInteractionHandler : public BasicInteractionHandler
+ {
+ public:
+ LegacyInteractionHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_rORB
+ )
+ :BasicInteractionHandler( i_rORB, true )
+ {
+ }
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // _DBAUI_INTERACTION_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/dbinteraction.src b/dbaccess/source/ui/uno/dbinteraction.src
new file mode 100644
index 000000000000..3d4c33d8a06d
--- /dev/null
+++ b/dbaccess/source/ui/uno/dbinteraction.src
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_UNO_HRC_
+#include "dbu_uno.hrc"
+#endif
+
+String STR_REMEMBERPASSWORD_SESSION
+{
+ Text [ en-US ] = "~Remember password until end of session";
+};
+
+String STR_REMEMBERPASSWORD_PERSISTENT
+{
+ Text [ en-US ] = "~Remember password";
+};
+
diff --git a/dbaccess/source/ui/uno/makefile.mk b/dbaccess/source/ui/uno/makefile.mk
new file mode 100644
index 000000000000..987e67241d43
--- /dev/null
+++ b/dbaccess/source/ui/uno/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=uiuno
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dbinteraction.src \
+ copytablewizard.src
+
+# ... object files ............................
+# workaround for issue http://qa.openoffice.org/issues/show_bug.cgi?id=102305 Linux specific
+.IF "$(COM)" == "GCC"
+NOOPTFILES=\
+ $(SLO)$/copytablewizard.obj
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/copytablewizard.obj \
+ $(SLO)$/composerdialogs.obj \
+ $(SLO)$/unosqlmessage.obj \
+ $(SLO)$/unoadmin.obj \
+ $(SLO)$/admindlg.obj \
+ $(SLO)$/TableFilterDlg.obj \
+ $(SLO)$/AdvancedSettingsDlg.obj \
+ $(SLO)$/unoDirectSql.obj \
+ $(SLO)$/DBTypeWizDlg.obj \
+ $(SLO)$/DBTypeWizDlgSetup.obj \
+ $(SLO)$/UserSettingsDlg.obj \
+ $(SLO)$/ColumnModel.obj \
+ $(SLO)$/ColumnControl.obj \
+ $(SLO)$/ColumnPeer.obj \
+ $(SLO)$/dbinteraction.obj \
+ $(SLO)$/textconnectionsettings_uno.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx
new file mode 100644
index 000000000000..23658530be71
--- /dev/null
+++ b/dbaccess/source/ui/uno/textconnectionsettings_uno.cxx
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "textconnectionsettings.hxx"
+#include "dbu_reghelper.hxx"
+#include "moduledbu.hxx"
+#include "apitools.hxx"
+#include "unoadmin.hxx"
+#include "dbustrings.hrc"
+#include "propertystorage.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <svtools/genericunodialog.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ /** === end UNO using === **/
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //====================================================================
+ //= OTextConnectionSettingsDialog
+ //====================================================================
+
+ class OTextConnectionSettingsDialog;
+ typedef ODatabaseAdministrationDialog OTextConnectionSettingsDialog_BASE;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog > OTextConnectionSettingsDialog_PBASE;
+
+ class OTextConnectionSettingsDialog
+ :public OTextConnectionSettingsDialog_BASE
+ ,public OTextConnectionSettingsDialog_PBASE
+ {
+ OModuleClient m_aModuleClient;
+ PropertyValues m_aPropertyValues;
+
+ protected:
+ OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext );
+ virtual ~OTextConnectionSettingsDialog();
+
+ public:
+ DECLARE_IMPLEMENTATION_ID( );
+ DECLARE_SERVICE_INFO_STATIC( );
+ DECLARE_PROPERTYCONTAINER_DEFAULTS( );
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception);
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException);
+ virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog( Window* _pParent );
+ virtual void implInitialize( const com::sun::star::uno::Any& _rValue );
+ protected:
+ using OTextConnectionSettingsDialog_BASE::getFastPropertyValue;
+ };
+
+ //====================================================================
+ //= OTextConnectionSettingsDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const ::comphelper::ComponentContext& _rContext )
+ :OTextConnectionSettingsDialog_BASE( _rContext.getLegacyServiceFactory() )
+ {
+ TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues );
+ }
+
+ //---------------------------------------------------------------------
+ OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog()
+ {
+ }
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_IMPLEMENTATION_ID( OTextConnectionSettingsDialog )
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC( OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog", "com.sun.star.sdb.TextConnectionSettings" )
+
+ //---------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ return createPropertySetInfo( getInfoHelper() );
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper()
+ {
+ return *getArrayHelper();
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+
+ // in addition to the properties registered by the base class, we have
+ // more properties which are not even handled by the PropertyContainer implementation,
+ // but whose values are stored in our item set
+ sal_Int32 nProp = aProps.getLength();
+ aProps.realloc( nProp + 6 );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HeaderLine" ) ),
+ PROPERTY_ID_HEADER_LINE,
+ ::cppu::UnoType< sal_Bool >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldDelimiter" ) ),
+ PROPERTY_ID_FIELD_DELIMITER,
+ ::cppu::UnoType< ::rtl::OUString >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringDelimiter" ) ),
+ PROPERTY_ID_STRING_DELIMITER,
+ ::cppu::UnoType< ::rtl::OUString >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalDelimiter" ) ),
+ PROPERTY_ID_DECIMAL_DELIMITER,
+ ::cppu::UnoType< ::rtl::OUString >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThousandDelimiter" ) ),
+ PROPERTY_ID_THOUSAND_DELIMITER,
+ ::cppu::UnoType< ::rtl::OUString >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ aProps[ nProp++ ] = Property(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSet" ) ),
+ PROPERTY_ID_ENCODING,
+ ::cppu::UnoType< ::rtl::OUString >::get(),
+ PropertyAttribute::TRANSIENT
+ );
+
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //---------------------------------------------------------------------
+ Dialog* OTextConnectionSettingsDialog::createDialog(Window* _pParent)
+ {
+ return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems );
+ }
+
+ //---------------------------------------------------------------------
+ void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue)
+ {
+ OTextConnectionSettingsDialog_BASE::implInitialize( _rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception)
+ {
+ PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
+ if ( pos != m_aPropertyValues.end() )
+ {
+ pos->second->setPropertyValue( _rValue );
+ }
+ else
+ {
+ OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
+ {
+ sal_Bool bModified = sal_False;
+
+ PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
+ if ( pos != m_aPropertyValues.end() )
+ {
+ // we're lazy here ...
+ _rConvertedValue = _rValue;
+ pos->second->getPropertyValue( _rOldValue );
+ bModified = sal_True;
+ }
+ else
+ {
+ bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
+ }
+
+ return bModified;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+ {
+ PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
+ if ( pos != m_aPropertyValues.end() )
+ {
+ pos->second->getPropertyValue( _rValue );
+ }
+ else
+ {
+ OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle );
+ }
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
+extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx
new file mode 100644
index 000000000000..998b79a136ad
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoDirectSql.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "unoDirectSql.hxx"
+#include "dbu_reghelper.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/connection/XConnection.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include "directsql.hxx"
+#include "dbustrings.hrc"
+#include "datasourceconnector.hxx"
+#include <tools/diagnose_ex.h>
+
+
+extern "C" void SAL_CALL createRegistryInfo_ODirectSQLDialog()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::ODirectSQLDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdb;
+
+ //=====================================================================
+ //= ODirectSQLDialog
+ //=====================================================================
+DBG_NAME(ODirectSQLDialog)
+//---------------------------------------------------------------------
+ ODirectSQLDialog::ODirectSQLDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODirectSQLDialog_BASE( _rxORB )
+ {
+ DBG_CTOR(ODirectSQLDialog,NULL);
+
+ }
+
+ //---------------------------------------------------------------------
+ ODirectSQLDialog::~ODirectSQLDialog()
+ {
+
+ DBG_DTOR(ODirectSQLDialog,NULL);
+ }
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_IMPLEMENTATION_ID( ODirectSQLDialog )
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC( ODirectSQLDialog, "com.sun.star.comp.sdb.DirectSQLDialog", SERVICE_SDB_DIRECTSQLDIALOG )
+
+ //---------------------------------------------------------------------
+ IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( ODirectSQLDialog )
+
+ //---------------------------------------------------------------------
+ Dialog* ODirectSQLDialog::createDialog(Window* _pParent)
+ {
+ // obtain all the objects needed for the dialog
+ Reference< XConnection > xConnection = m_xActiveConnection;
+ if ( !xConnection.is() )
+ {
+ try
+ {
+ // the connection the row set is working with
+ ODatasourceConnector aDSConnector(m_aContext.getLegacyServiceFactory(),_pParent);
+ xConnection = aDSConnector.connect( m_sInitialSelection, NULL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ if ( !xConnection.is() )
+ // can't create the dialog if I have improper settings
+ return NULL;
+
+ return new DirectSQLDialog( _pParent, xConnection);
+ }
+ //---------------------------------------------------------------------
+ void ODirectSQLDialog::implInitialize(const Any& _rValue)
+ {
+ PropertyValue aProperty;
+ if (_rValue >>= aProperty)
+ {
+ if (0 == aProperty.Name.compareToAscii("InitialSelection"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sInitialSelection );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("ActiveConnection"))
+ {
+ m_xActiveConnection.set( aProperty.Value, UNO_QUERY );
+ OSL_ENSURE( m_xActiveConnection.is(), "ODirectSQLDialog::implInitialize: invalid connection!" );
+ return;
+ }
+ }
+ ODirectSQLDialog_BASE::implInitialize(_rValue);
+ }
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/unoDirectSql.hxx b/dbaccess/source/ui/uno/unoDirectSql.hxx
new file mode 100644
index 000000000000..1f7dde873282
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoDirectSql.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef DBAUI_UNODIRECTSQL_HXX
+#define DBAUI_UNODIRECTSQL_HXX
+
+#include <svtools/genericunodialog.hxx>
+#include "apitools.hxx"
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include "moduledbu.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ //=====================================================================
+ //= ODirectSQLDialog
+ //=====================================================================
+ class ODirectSQLDialog;
+ typedef ::svt::OGenericUnoDialog ODirectSQLDialog_BASE;
+ typedef ::comphelper::OPropertyArrayUsageHelper< ODirectSQLDialog > ODirectSQLDialog_PBASE;
+
+ class ODirectSQLDialog
+ :public ODirectSQLDialog_BASE
+ ,public ODirectSQLDialog_PBASE
+ {
+ OModuleClient m_aModuleClient;
+ ::rtl::OUString m_sInitialSelection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection;
+ protected:
+ ODirectSQLDialog(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ virtual ~ODirectSQLDialog();
+
+ public:
+ DECLARE_IMPLEMENTATION_ID( );
+
+ DECLARE_SERVICE_INFO_STATIC( );
+
+ DECLARE_PROPERTYCONTAINER_DEFAULTS( );
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+ };
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+#endif // DBAUI_UNODIRECTSQL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/unoadmin.cxx b/dbaccess/source/ui/uno/unoadmin.cxx
new file mode 100644
index 000000000000..c48a2e54a250
--- /dev/null
+++ b/dbaccess/source/ui/uno/unoadmin.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "dbustrings.hrc"
+#include <toolkit/awt/vclxwindow.hxx>
+#include "dbu_reghelper.hxx"
+#ifndef _DBAUI_UNOADMIN_
+#include "unoadmin.hxx"
+#endif
+#include "dbadmin.hxx"
+#include <comphelper/extract.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/property.hxx>
+#include <osl/diagnose.h>
+#include <vcl/msgbox.hxx>
+
+// --- needed because of the solar mutex
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+// ---
+
+#define THISREF() static_cast< XServiceInfo* >(this)
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+DBG_NAME(ODatabaseAdministrationDialog)
+//-------------------------------------------------------------------------
+ODatabaseAdministrationDialog::ODatabaseAdministrationDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :ODatabaseAdministrationDialogBase(_rxORB)
+ ,m_pDatasourceItems(NULL)
+ ,m_pItemPool(NULL)
+ ,m_pItemPoolDefaults(NULL)
+ ,m_pCollection(NULL)
+{
+ DBG_CTOR(ODatabaseAdministrationDialog,NULL);
+
+ m_pCollection = new ::dbaccess::ODsnTypeCollection(_rxORB);
+ ODbAdminDialog::createItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults, m_pCollection);
+}
+
+//-------------------------------------------------------------------------
+ODatabaseAdministrationDialog::~ODatabaseAdministrationDialog()
+{
+ // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor,
+ // so this virtual-method-call the base class does does not work, we're already dead then ...
+ if (m_pDialog)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (m_pDialog)
+ destroyDialog();
+ }
+
+ delete m_pCollection;
+ m_pCollection = NULL;
+
+ DBG_DTOR(ODatabaseAdministrationDialog,NULL);
+}
+//-------------------------------------------------------------------------
+void ODatabaseAdministrationDialog::destroyDialog()
+{
+ ODatabaseAdministrationDialogBase::destroyDialog();
+ ODbAdminDialog::destroyItemSet(m_pDatasourceItems, m_pItemPool, m_pItemPoolDefaults);
+}
+//------------------------------------------------------------------------------
+void ODatabaseAdministrationDialog::implInitialize(const Any& _rValue)
+{
+ PropertyValue aProperty;
+ if (_rValue >>= aProperty)
+ {
+ if (0 == aProperty.Name.compareToAscii("InitialSelection"))
+ {
+ m_aInitialSelection = aProperty.Value;
+ }
+ else if (0 == aProperty.Name.compareToAscii("ActiveConnection"))
+ {
+ m_xActiveConnection.set(aProperty.Value,UNO_QUERY);
+ }
+ else
+ ODatabaseAdministrationDialogBase::implInitialize(_rValue);
+ }
+ else
+ ODatabaseAdministrationDialogBase::implInitialize(_rValue);
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/uno/unosqlmessage.cxx b/dbaccess/source/ui/uno/unosqlmessage.cxx
new file mode 100644
index 000000000000..66d65552b264
--- /dev/null
+++ b/dbaccess/source/ui/uno/unosqlmessage.cxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 "sqlmessage.hxx"
+#include "unosqlmessage.hxx"
+#include "dbu_reghelper.hxx"
+#include "dbustrings.hrc"
+#include <cppuhelper/typeprovider.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace dbaui;
+using namespace dbtools;
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+
+extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog()
+{
+ static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+//=========================================================================
+//-------------------------------------------------------------------------
+OSQLMessageDialog::OSQLMessageDialog(const Reference< XMultiServiceFactory >& _rxORB)
+ :OSQLMessageDialogBase(_rxORB)
+{
+ registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
+ &m_aException, ::getCppuType(static_cast<SQLException*>(NULL)));
+ registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
+ &m_sHelpURL, ::getCppuType( &m_sHelpURL ) );
+}
+
+//-------------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//-------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OSQLMessageDialog(_rxFactory));
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//-------------------------------------------------------------------------
+::rtl::OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OSQLMessageDialog"));
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//-------------------------------------------------------------------------
+::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException)
+{
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ErrorMessageDialog"));
+ return aSupported;
+}
+
+//-------------------------------------------------------------------------
+sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
+{
+ switch (_nHandle)
+ {
+ case PROPERTY_ID_SQLEXCEPTION:
+ {
+ SQLExceptionInfo aInfo(_rValue);
+ if (!aInfo.isValid())
+ throw IllegalArgumentException();
+
+ _rOldValue = m_aException;
+ _rConvertedValue = aInfo.get();
+
+ return sal_True;
+ // always assume "modified", don't bother with with comparing the two values
+ }
+ default:
+ return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
+ }
+}
+
+//-------------------------------------------------------------------------
+Reference<XPropertySetInfo> SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException)
+{
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//-------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper()
+{
+ return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+//------------------------------------------------------------------------------
+Dialog* OSQLMessageDialog::createDialog(Window* _pParent)
+{
+ if ( m_aException.hasValue() )
+ return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL );
+
+ OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
+ return new OSQLMessageBox(_pParent, SQLException());
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */